r3-legacy/bak/r3-d3-input-editor.bak

87 lines
2.0 KiB
Plaintext
Raw Normal View History

2016-12-19 17:44:15 +01:00
/**
* Input parent class
2018-04-09 10:05:13 +02:00
* @param graphics R3.D3.Graphics
2016-12-19 17:44:15 +01:00
* @param parentObject
2018-04-09 10:05:13 +02:00
* @param apiInputEditor R3.D3.API.Input.Editor
2016-12-19 17:44:15 +01:00
* @constructor
*/
2018-04-09 10:05:13 +02:00
R3.D3.Input.Editor = function RuntimeEditorInput(
2016-12-19 17:44:15 +01:00
graphics,
parentObject,
apiInputEditor
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(parentObject)) {
2016-12-19 17:44:15 +01:00
parentObject = null;
}
this.parentObject = parentObject;
2018-04-09 10:05:13 +02:00
R3.D3.API.Input.Editor.call(
2016-12-19 17:44:15 +01:00
this,
apiInputEditor.id,
apiInputEditor.name,
apiInputEditor.domElementId,
2017-01-02 17:05:40 +01:00
apiInputEditor.camera,
apiInputEditor.parentEntity
2016-12-19 17:44:15 +01:00
);
/**
* Don't create an instance here - since we don't have our camera loaded yet...
*/
};
2018-04-09 10:05:13 +02:00
R3.D3.Input.Editor.prototype = Object.create(R3.D3.API.Input.Editor.prototype);
R3.D3.Input.Editor.prototype.constructor = R3.D3.Input.Editor;
2016-12-19 17:44:15 +01:00
2018-04-09 10:05:13 +02:00
R3.D3.Input.Editor.prototype.createInstance = function(update) {
2016-12-19 17:44:15 +01:00
var instance = null;
if (this.camera && this.domElementId) {
instance = new THREE.EditorControls(
this.camera.instance,
document.getElementById(this.domElementId)
);
}
this.instance = instance;
return instance;
};
2018-04-09 10:05:13 +02:00
R3.D3.Input.Editor.prototype.updateInstance = function() {
2016-12-19 17:44:15 +01:00
this.instance = this.createInstance(true);
};
2018-04-09 10:05:13 +02:00
R3.D3.Input.Editor.prototype.toApiComponent = function() {
2016-12-19 17:44:15 +01:00
2018-04-09 10:05:13 +02:00
var apiInputEditor = new R3.D3.API.Input.Editor(
2016-12-19 17:44:15 +01:00
this.id,
this.name,
this.domElementId,
2018-04-09 10:05:13 +02:00
R3.Utils.IdOrNull(this.camera),
R3.Utils.IdOrNull(this.parentEntity)
2016-12-19 17:44:15 +01:00
);
return apiInputEditor;
};
2018-04-09 10:05:13 +02:00
R3.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent) {
2016-12-19 17:44:15 +01:00
2018-04-09 10:05:13 +02:00
var apiInputEditor = new R3.D3.API.Input.Editor(
2016-12-19 17:44:15 +01:00
objectComponent.id,
objectComponent.name,
objectComponent.domElementId,
2017-01-02 17:05:40 +01:00
objectComponent.camera,
objectComponent.parentEntity
2016-12-19 17:44:15 +01:00
);
2018-04-09 10:05:13 +02:00
return new R3.D3.Input.Editor(
2016-12-19 17:44:15 +01:00
graphics,
this,
apiInputEditor
);
};