r3-legacy/bak/game-lib-d3-input-editor.js

91 lines
2.1 KiB
JavaScript

/**
* Input parent class
* @param graphics GameLib.D3.Graphics
* @param apiInputEditor GameLib.D3.API.Input.Editor
* @constructor
*/
GameLib.D3.Input.Editor = function (
graphics,
apiInputEditor
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiInputEditor)) {
apiInputEditor = {};
}
if (apiInputEditor instanceof GameLib.D3.Input.Editor) {
return apiInputEditor;
}
GameLib.D3.API.Input.Editor.call(
this,
apiInputEditor.id,
apiInputEditor.name,
apiInputEditor.domElement,
apiInputEditor.camera,
apiInputEditor.parentEntity
);
if (this.domElement instanceof GameLib.API.DomElement) {
this.domElement = new GameLib.DomElement(
this.domElement
)
}
if (this.camera instanceof GameLib.D3.API.Camera) {
this.camera = new GameLib.D3.Camera(
this.graphics,
this.camera
)
}
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_INPUT_EDITOR,
{
'camera' : GameLib.D3.Camera
}
);
};
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() {
return true;
};
GameLib.D3.Input.Editor.prototype.updateInstance = function() {
};
/**
* GameLib.D3.Input.Editor to GameLib.D3.API.Input.Editor
* @returns {GameLib.D3.API.Input.Editor}
*/
GameLib.D3.Input.Editor.prototype.toApiObject = 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.FromObject = function(graphics, objectComponent) {
var apiInputEditor = GameLib.D3.API.Input.Editor.FromObject(objectComponent);
return new GameLib.D3.Input.Editor(
graphics,
apiInputEditor
);
};