r3-legacy/bak/r3-api-graphics-runtime-a.js

65 lines
1.6 KiB
JavaScript

/**
* R3.API.GraphicsRuntime
* @param id
* @param name
* @param graphicsType
* @param parent
* @constructor
*/
R3.API.GraphicsRuntime = function(
id,
name,
graphicsType,
parent
) {
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = 'Graphics Runtime (' + id + ')';
}
this.name = name;
if (R3.Utils.UndefinedOrNull(graphicsType)) {
graphicsType = null;
}
this.graphicsType = graphicsType;
R3.API.Component.call(
this,
R3.API.GraphicsRuntime.GetComponentType(this.graphicsType),
parent
);
};
R3.API.GraphicsRuntime.prototype = Object.create(R3.API.Component.prototype);
R3.API.GraphicsRuntime.prototype.constructor = R3.API.GraphicsRuntime;
R3.API.GraphicsRuntime.GetComponentType = function(graphicsType) {
var componentType = null;
switch (graphicsType) {
case R3.API.GraphicsRuntime.GRAPHICS_TYPE_NONE :
componentType = R3.Component.GRAPHICS;
break;
case R3.API.GraphicsRuntime.GRAPHICS_TYPE_THREE_JS :
componentType = R3.Component.GRAPHICS_THREE;
break;
case R3.API.GraphicsRuntime.GRAPHICS_TYPE_IMPACT_JS :
componentType = R3.Component.GRAPHICS_IMPACT;
break;
default:
throw new Error('Invalid graphics type');
}
return componentType;
};
R3.API.GraphicsRuntime.GRAPHICS_TYPE_NONE = 0x0;
R3.API.GraphicsRuntime.GRAPHICS_TYPE_THREE_JS = 0x1;
R3.API.GraphicsRuntime.GRAPHICS_TYPE_IMPACT_JS = 0x2;