r3-legacy/src/r3-graphics-runtime-a.js

71 lines
1.6 KiB
JavaScript

/**
* Graphics
* @constructor
* @param apiGraphics
*/
R3.GraphicsRuntime = function(
apiGraphics
) {
if (R3.Utils.UndefinedOrNull(apiGraphics)) {
apiGraphics = {
graphicsType : R3.API.GraphicsRuntime.GRAPHICS_TYPE_NONE
};
}
R3.API.GraphicsRuntime.call(
this,
apiGraphics.id,
apiGraphics.name,
apiGraphics.graphicsType,
apiGraphics.parentEntity
);
R3.Component.call(this);
};
R3.GraphicsRuntime.prototype = Object.create(R3.Component.prototype);
R3.GraphicsRuntime.prototype.constructor = R3.GraphicsRuntime;
R3.GraphicsRuntime.prototype.createInstance = function() {
console.log(this.graphicsType + ' graphics runtime created');
R3.Component.prototype.createInstance.call(this);
};
R3.GraphicsRuntime.prototype.updateInstance = function(property) {
if (property === 'graphicsType') {
var componentType = R3.API.Renderer.GetComponentType(this.graphicsType);
this.replace(componentType);
return;
}
R3.Component.prototype.updateInstance.call(this, property);
};
R3.GraphicsRuntime.prototype.toApiObject = function(property) {
return new R3.API.GraphicsRuntime(
this.id,
this.name,
this.graphicsType,
R3.Utils.IdOrNull(this.parentEntity)
);
};
/**
* Logs a warning and throws an error if not cannon
*/
R3.GraphicsRuntime.prototype.isNotThreeThrow = function() {
if (this.instance !== THREE) {
console.error('Only THREE supported');
throw new Error('Only THREE supported');
}
};
R3.GraphicsRuntime.prototype.isThree = function() {
return (this.instance === THREE);
};