2016-11-29 12:54:25 +01:00
|
|
|
/**
|
|
|
|
* Raw Scene API object - should always correspond with the Scene Schema
|
|
|
|
* @param id String
|
|
|
|
* @param path String
|
|
|
|
* @param name String
|
|
|
|
* @param meshes GameLib.D3.API.Mesh []
|
2016-12-15 14:53:39 +01:00
|
|
|
* @param position GameLib.API.Vector3
|
2016-12-15 15:28:00 +01:00
|
|
|
* @param quaternion GameLib.API.Quaternion
|
2016-12-15 14:53:39 +01:00
|
|
|
* @param scale GameLib.API.Vector3
|
2016-11-29 12:54:25 +01:00
|
|
|
* @param parentSceneId
|
|
|
|
* @param lights GameLib.D3.API.Light[]
|
|
|
|
* @param worlds GameLib.D3.API.World[]
|
2016-12-15 15:28:00 +01:00
|
|
|
* @param entityManager GameLib.EntityManager
|
2016-11-29 12:54:25 +01:00
|
|
|
* @param shapes GameLib.D3.API.Shape[]
|
|
|
|
* @param cameras
|
|
|
|
* @param activeCameraIndex
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Scene = function(
|
|
|
|
id,
|
|
|
|
path,
|
|
|
|
name,
|
|
|
|
meshes,
|
|
|
|
position,
|
2016-12-15 15:28:00 +01:00
|
|
|
quaternion,
|
2016-11-29 12:54:25 +01:00
|
|
|
scale,
|
|
|
|
parentSceneId,
|
|
|
|
lights,
|
|
|
|
worlds,
|
2016-12-15 15:28:00 +01:00
|
|
|
entityManager,
|
2016-11-29 12:54:25 +01:00
|
|
|
shapes,
|
|
|
|
cameras,
|
2016-12-22 17:22:19 +01:00
|
|
|
activeCameraIndex
|
2016-11-29 12:54:25 +01:00
|
|
|
) {
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
2016-11-29 12:54:25 +01:00
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(path)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
path = null;
|
|
|
|
}
|
|
|
|
this.path = path;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
name = 'unnamed';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(meshes)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
meshes = [];
|
|
|
|
}
|
|
|
|
this.meshes = meshes;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
|
|
position = new GameLib.API.Vector3();
|
2016-11-29 12:54:25 +01:00
|
|
|
}
|
|
|
|
this.position = position;
|
|
|
|
|
2016-12-15 15:28:00 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
|
|
|
quaternion = new GameLib.API.Quaternion();
|
|
|
|
}
|
|
|
|
this.quaternion = quaternion;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
|
|
|
scale = new GameLib.API.Vector3(1,1,1);
|
2016-11-29 12:54:25 +01:00
|
|
|
}
|
|
|
|
this.scale = scale;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(parentSceneId)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
parentSceneId = null;
|
|
|
|
}
|
|
|
|
this.parentSceneId = parentSceneId;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(lights)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
lights = [];
|
|
|
|
}
|
|
|
|
this.lights = lights;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(worlds)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
worlds = [];
|
|
|
|
}
|
|
|
|
this.worlds = worlds;
|
|
|
|
|
2016-12-15 15:28:00 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
2016-12-16 16:03:48 +01:00
|
|
|
entityManager = new GameLib.API.EntityManager();
|
2016-11-29 12:54:25 +01:00
|
|
|
}
|
2016-12-15 15:28:00 +01:00
|
|
|
this.entityManager = entityManager;
|
2016-11-29 12:54:25 +01:00
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(shapes)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
shapes = [];
|
|
|
|
}
|
|
|
|
this.shapes = shapes;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
cameras = [];
|
|
|
|
}
|
|
|
|
this.cameras = cameras;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(activeCameraIndex)) {
|
2016-11-29 12:54:25 +01:00
|
|
|
activeCameraIndex = 0;
|
|
|
|
}
|
|
|
|
this.activeCameraIndex = activeCameraIndex;
|
|
|
|
};
|