delayed controls for edit

beta.r3js.org
-=yb4f310 2017-10-27 10:03:53 +02:00
parent aa574574a6
commit c765a5a0d8
2 changed files with 20 additions and 27 deletions

View File

@ -34,12 +34,16 @@ GameLib.D3.Controls = function (
domElement : GameLib.DomElement domElement : GameLib.DomElement
}; };
var delayed = false;
if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_EDITOR) { if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_EDITOR) {
componentType = GameLib.Component.COMPONENT_CONTROLS_EDITOR; componentType = GameLib.Component.COMPONENT_CONTROLS_EDITOR;
linkedObjects.raycaster = GameLib.D3.Raycaster; linkedObjects.raycaster = GameLib.D3.Raycaster;
linkedObjects.camera = GameLib.D3.Camera; linkedObjects.camera = GameLib.D3.Camera;
delayed = true;
} }
if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_TOUCH) { if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_TOUCH) {
@ -57,7 +61,8 @@ GameLib.D3.Controls = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
componentType, componentType,
linkedObjects linkedObjects,
delayed
); );
}; };

View File

@ -59,28 +59,23 @@ GameLib.D3.Controls.Editor.prototype.constructor = GameLib.D3.Controls.Editor;
* @returns {THREE.EditorControls} * @returns {THREE.EditorControls}
*/ */
GameLib.D3.Controls.Editor.prototype.createInstance = function() { 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.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 * 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'); 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); GameLib.D3.Controls.prototype.updateInstance.call(this);
}; };