146 lines
4.1 KiB
JavaScript
146 lines
4.1 KiB
JavaScript
/**
|
|
* Raw Scene API object - should always correspond with the Scene Schema
|
|
* @param apiComponent
|
|
*
|
|
* @property meshes []
|
|
* @property lights []
|
|
* @property textures []
|
|
* @property materials []
|
|
* @property fog
|
|
* @property showGrid
|
|
* @property showAxis
|
|
* @property gridSize
|
|
* @property gridColor
|
|
* @property cameraIndexEdit
|
|
* @property cameraIndexRun
|
|
* @property cubeCameras
|
|
* @property effect
|
|
* @property composer
|
|
* @property enableEffect
|
|
* @property enableComposer
|
|
* @property controls
|
|
*
|
|
* @constructor
|
|
*/
|
|
R3.D3.API.Scene = function(
|
|
apiComponent
|
|
) {
|
|
|
|
__API_COMPONENT__;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.meshes)) {
|
|
apiComponent.meshes = [];
|
|
}
|
|
this.meshes = apiComponent.meshes;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.lights)) {
|
|
apiComponent.lights = [];
|
|
}
|
|
this.lights = apiComponent.lights;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.textures)) {
|
|
apiComponent.textures = [];
|
|
}
|
|
this.textures = apiComponent.textures;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.materials)) {
|
|
apiComponent.materials = [];
|
|
}
|
|
this.materials = apiComponent.materials;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.fog)) {
|
|
apiComponent.fog = new R3.D3.API.Fog.Normal(
|
|
{
|
|
parent : this,
|
|
name : this.name + ' - Fog'
|
|
}
|
|
);
|
|
}
|
|
this.fog = apiComponent.fog;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.showGrid)) {
|
|
apiComponent.showGrid = true;
|
|
}
|
|
this.showGrid = apiComponent.showGrid;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.showAxis)) {
|
|
apiComponent.showAxis = true;
|
|
}
|
|
this.showAxis = apiComponent.showAxis;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.gridSize)) {
|
|
apiComponent.gridSize = 10;
|
|
}
|
|
this.gridSize = apiComponent.gridSize;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.gridColor)) {
|
|
apiComponent.gridColor = new R3.API.Color({
|
|
parent : this,
|
|
register : true,
|
|
name : this.name + ' - Grid Color',
|
|
r : 0.14117641,
|
|
g : 0.576470588,
|
|
b : 0.882352941
|
|
});
|
|
}
|
|
this.gridColor = apiComponent.gridColor;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.cameraIndexEdit)) {
|
|
apiComponent.cameraIndexEdit = R3.API.Project.CAMERA_INDEX_EDIT;
|
|
}
|
|
this.cameraIndexEdit = apiComponent.cameraIndexEdit;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.cameraIndexRun)) {
|
|
apiComponent.cameraIndexRun = R3.API.Project.CAMERA_INDEX_RUN;
|
|
}
|
|
this.cameraIndexRun = apiComponent.cameraIndexRun;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.cubeCameras)) {
|
|
apiComponent.cubeCameras = [];
|
|
}
|
|
this.cubeCameras = apiComponent.cubeCameras;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.composer)) {
|
|
apiComponent.composer = new R3.D3.API.Composer(
|
|
{
|
|
parent : this,
|
|
name : this.name + ' - Composer'
|
|
}
|
|
);
|
|
}
|
|
this.composer = apiComponent.composer;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.effect)) {
|
|
apiComponent.effect = new R3.D3.API.Effect(
|
|
{
|
|
parent : this,
|
|
name : this.name + ' - Effect'
|
|
}
|
|
);
|
|
}
|
|
this.effect = apiComponent.effect;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.enableComposer)) {
|
|
apiComponent.enableComposer = false;
|
|
}
|
|
this.enableComposer = apiComponent.enableComposer;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.enableEffect)) {
|
|
apiComponent.enableEffect = false;
|
|
}
|
|
this.enableEffect = apiComponent.enableEffect;
|
|
|
|
/**
|
|
* By default scenes have no viewport so they are able to render outside of viewports (svg rendering, rendertargets, etc)
|
|
* But if they do the renderer system will pick it up and render them in their appropriate viewport
|
|
*/
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.viewport)) {
|
|
apiComponent.viewports = [];
|
|
}
|
|
this.viewports = apiComponent.viewports;
|
|
|
|
};
|
|
|
|
R3.D3.API.Scene.prototype = Object.create(R3.API.Component.prototype);
|
|
R3.D3.API.Scene.prototype.constructor = R3.D3.API.Scene;
|