diff --git a/src/game-lib-d3-controls-0.js b/src/game-lib-d3-controls-0.js index aa9cfee..6504978 100644 --- a/src/game-lib-d3-controls-0.js +++ b/src/game-lib-d3-controls-0.js @@ -34,12 +34,16 @@ GameLib.D3.Controls = function ( domElement : GameLib.DomElement }; + var delayed = false; + if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_EDITOR) { componentType = GameLib.Component.COMPONENT_CONTROLS_EDITOR; linkedObjects.raycaster = GameLib.D3.Raycaster; linkedObjects.camera = GameLib.D3.Camera; + + delayed = true; } if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_TOUCH) { @@ -57,7 +61,8 @@ GameLib.D3.Controls = function ( GameLib.Component.call( this, componentType, - linkedObjects + linkedObjects, + delayed ); }; diff --git a/src/game-lib-d3-controls-editor.js b/src/game-lib-d3-controls-editor.js index 4f64f95..1d6a153 100644 --- a/src/game-lib-d3-controls-editor.js +++ b/src/game-lib-d3-controls-editor.js @@ -59,28 +59,23 @@ GameLib.D3.Controls.Editor.prototype.constructor = GameLib.D3.Controls.Editor; * @returns {THREE.EditorControls} */ GameLib.D3.Controls.Editor.prototype.createInstance = function() { - console.log('delaying controls instance creation - call GameLib.D3.Controls.Editor.delayedInstance() to create the instance'); + + if (!this.camera || !this.camera.instance) { + throw new Error('No camera at time of instance'); + } + + if (!this.domElement || !this.domElement.instance) { + throw new Error('No dom element at time of instance'); + } + + this.instance = new THREE.EditorControls( + this.camera.instance, + this.domElement.instance + ); + GameLib.D3.Controls.prototype.createInstance.call(this); }; -GameLib.D3.Controls.Editor.prototype.delayedInstance = function() { - - console.log('GameLib.D3.Controls.Editor.delayedInstance() called'); - - if (!this.camera || !this.camera.instance) { - throw new Error('No camera at time of instance'); - } - - if (!this.domElement || !this.domElement.instance) { - throw new Error('No dom element at time of instance'); - } - - this.instance = new THREE.EditorControls( - this.camera.instance, - this.domElement.instance - ); -}; - /** * Update Instance */ @@ -88,13 +83,6 @@ GameLib.D3.Controls.Editor.prototype.updateInstance = function() { console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability'); - // if (this.instance) { - // this.instance.dispose(); - // delete this.instance; - // } - // - // this.delayedInstance(); - GameLib.D3.Controls.prototype.updateInstance.call(this); };