87 lines
2.1 KiB
Plaintext
87 lines
2.1 KiB
Plaintext
|
/**
|
||
|
* Input parent class
|
||
|
* @param graphics GameLib.D3.Graphics
|
||
|
* @param parentObject
|
||
|
* @param apiInputEditor GameLib.D3.API.Input.Editor
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.Input.Editor = function RuntimeEditorInput(
|
||
|
graphics,
|
||
|
parentObject,
|
||
|
apiInputEditor
|
||
|
) {
|
||
|
|
||
|
this.graphics = graphics;
|
||
|
this.graphics.isNotThreeThrow();
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
|
||
|
parentObject = null;
|
||
|
}
|
||
|
this.parentObject = parentObject;
|
||
|
|
||
|
GameLib.D3.API.Input.Editor.call(
|
||
|
this,
|
||
|
apiInputEditor.id,
|
||
|
apiInputEditor.name,
|
||
|
apiInputEditor.domElementId,
|
||
|
apiInputEditor.camera,
|
||
|
apiInputEditor.parentEntity
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
* Don't create an instance here - since we don't have our camera loaded yet...
|
||
|
*/
|
||
|
};
|
||
|
|
||
|
GameLib.D3.Input.Editor.prototype = Object.create(GameLib.D3.API.Input.Editor.prototype);
|
||
|
GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor;
|
||
|
|
||
|
GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
|
||
|
|
||
|
var instance = null;
|
||
|
|
||
|
if (this.camera && this.domElementId) {
|
||
|
instance = new THREE.EditorControls(
|
||
|
this.camera.instance,
|
||
|
document.getElementById(this.domElementId)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
this.instance = instance;
|
||
|
|
||
|
return instance;
|
||
|
};
|
||
|
|
||
|
GameLib.D3.Input.Editor.prototype.updateInstance = function() {
|
||
|
this.instance = this.createInstance(true);
|
||
|
};
|
||
|
|
||
|
GameLib.D3.Input.Editor.prototype.toApiComponent = function() {
|
||
|
|
||
|
var apiInputEditor = new GameLib.D3.API.Input.Editor(
|
||
|
this.id,
|
||
|
this.name,
|
||
|
this.domElementId,
|
||
|
GameLib.Utils.IdOrNull(this.camera),
|
||
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||
|
);
|
||
|
|
||
|
return apiInputEditor;
|
||
|
};
|
||
|
|
||
|
GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent) {
|
||
|
|
||
|
var apiInputEditor = new GameLib.D3.API.Input.Editor(
|
||
|
objectComponent.id,
|
||
|
objectComponent.name,
|
||
|
objectComponent.domElementId,
|
||
|
objectComponent.camera,
|
||
|
objectComponent.parentEntity
|
||
|
);
|
||
|
|
||
|
return new GameLib.D3.Input.Editor(
|
||
|
graphics,
|
||
|
this,
|
||
|
apiInputEditor
|
||
|
);
|
||
|
};
|