diff --git a/src/components/cursor-controller.js b/src/components/cursor-controller.js index 0a921397c4c835b526986650da199c8358a606b7..e64e68bb67ce877752758afcb29cf0c3f2e5e1bb 100644 --- a/src/components/cursor-controller.js +++ b/src/components/cursor-controller.js @@ -54,12 +54,20 @@ AFRAME.registerComponent("cursor-controller", { "_handlePrimaryDown", "_handlePrimaryUp", "_handleModelLoaded", + "_handleCursorLoaded", "_handleControllerConnected", "_handleControllerDisconnected" ]; functionNames.forEach(name => { this[name] = this[name].bind(this); }); + + this.el.sceneEl.renderer.sortObjects = true; + this.data.cursor.addEventListener("loaded", this._handleCursorLoaded); + }, + + remove: function() { + this.data.cursor.removeEventListener("loaded", this._handleCursorLoaded); }, update: function(oldData) { @@ -397,6 +405,10 @@ AFRAME.registerComponent("cursor-controller", { this.physicalHand = this.data.playerRig.querySelector(this.data.physicalHandSelector); }, + _handleCursorLoaded: function() { + this.data.cursor.object3DMap.mesh.renderOrder = 1; + }, + _handleControllerConnected: function(e) { const data = { controller: e.target,