cameras and meshes are now 3d objects
parent
6819ba95c0
commit
c1334bbb00
|
@ -262,7 +262,7 @@ GameLib.Component.STATS = 0x1d;
|
||||||
GameLib.Component.GUI = 0x1e;
|
GameLib.Component.GUI = 0x1e;
|
||||||
GameLib.Component.IMAGE = 0x1f;
|
GameLib.Component.IMAGE = 0x1f;
|
||||||
GameLib.Component.ENTITY = 0x20;
|
GameLib.Component.ENTITY = 0x20;
|
||||||
//GameLib.Component.MESH_SPHERE = 0x21;
|
GameLib.Component.OBJECT = 0x21;
|
||||||
//GameLib.Component.MESH_PLANE = 0x22;
|
//GameLib.Component.MESH_PLANE = 0x22;
|
||||||
//GameLib.Component.MESH_CURVE = 0x23;
|
//GameLib.Component.MESH_CURVE = 0x23;
|
||||||
GameLib.Component.PHYSICS_WORLD = 0x24;
|
GameLib.Component.PHYSICS_WORLD = 0x24;
|
||||||
|
@ -613,12 +613,12 @@ GameLib.Component.GetComponentInfo = function(number) {
|
||||||
constructor : GameLib.Entity,
|
constructor : GameLib.Entity,
|
||||||
apiConstructor : GameLib.API.Entity
|
apiConstructor : GameLib.API.Entity
|
||||||
};
|
};
|
||||||
case 0x21 : return null;/*return {
|
case 0x21 : return {
|
||||||
name : 'GameLib.D3.Mesh.Sphere',
|
name : 'GameLib.D3.Object',
|
||||||
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
constructor : GameLib.D3.Mesh.Sphere,
|
constructor : GameLib.D3.Object,
|
||||||
apiConstructor : GameLib.D3.API.Mesh
|
apiConstructor : GameLib.D3.API.Object
|
||||||
};*/
|
};
|
||||||
case 0x22 : return null;/*{
|
case 0x22 : return null;/*{
|
||||||
name : 'GameLib.D3.Mesh.Plane',
|
name : 'GameLib.D3.Mesh.Plane',
|
||||||
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
@ -1504,6 +1504,27 @@ GameLib.Component.prototype.toApiObject = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all children components of this Object (all linked objects only - no object references i.e. string ids)
|
||||||
|
* @returns {Array}
|
||||||
|
*/
|
||||||
|
GameLib.Component.prototype.getChildrenComponents = function() {
|
||||||
|
|
||||||
|
var components = [];
|
||||||
|
|
||||||
|
this.buildIdToObject();
|
||||||
|
|
||||||
|
Object.keys(this.idToObject).map(
|
||||||
|
function (objectId) {
|
||||||
|
if (this.id !== objectId) {
|
||||||
|
components.push(this.idToObject[objectId]);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
return components;
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.Component.prototype.processComponent = function(object) {
|
GameLib.Component.prototype.processComponent = function(object) {
|
||||||
if (object instanceof GameLib.Component) {
|
if (object instanceof GameLib.Component) {
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ GameLib.Canvas.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (property === 'id') {
|
if (property === 'id') {
|
||||||
this.instance.setAttribute('id', this.id);
|
this.instance.setAttribute('id', this.id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'autoUpdateSize' ||
|
if (property === 'autoUpdateSize' ||
|
||||||
|
@ -107,11 +108,15 @@ GameLib.Canvas.prototype.updateInstance = function(property) {
|
||||||
this.instance.width = this.width;
|
this.instance.width = this.width;
|
||||||
this.instance.height = this.height;
|
this.instance.height = this.height;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'texts') {
|
if (property === 'texts') {
|
||||||
this.writeText();
|
this.writeText();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Object
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
* @param objectType
|
||||||
|
* @param parentEntity
|
||||||
|
* @param useQuaternion
|
||||||
|
* @param position
|
||||||
|
* @param quaternion
|
||||||
|
* @param rotation
|
||||||
|
* @param scale
|
||||||
|
* @param up
|
||||||
|
* @param lookAt
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Object = function(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
objectType,
|
||||||
|
parentEntity,
|
||||||
|
useQuaternion,
|
||||||
|
position,
|
||||||
|
quaternion,
|
||||||
|
rotation,
|
||||||
|
scale,
|
||||||
|
up,
|
||||||
|
lookAt
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.Utils.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(objectType)) {
|
||||||
|
objectType = 0;
|
||||||
|
}
|
||||||
|
this.objectType = objectType;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||||
|
switch (this.objectType) {
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_NONE :
|
||||||
|
name = 'Object';
|
||||||
|
break;
|
||||||
|
/**
|
||||||
|
* Cameras
|
||||||
|
*/
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA :
|
||||||
|
name = 'Camera';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC :
|
||||||
|
name = 'Camera Orthographic';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE :
|
||||||
|
name = 'Camera Perspective';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE :
|
||||||
|
name = 'Camera Cube';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO :
|
||||||
|
name = 'Camera Stereo';
|
||||||
|
break;
|
||||||
|
/**
|
||||||
|
* Meshes
|
||||||
|
*/
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_MESH :
|
||||||
|
name = 'Mesh';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
name += ' (' + this.id + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(useQuaternion)) {
|
||||||
|
useQuaternion = true;
|
||||||
|
}
|
||||||
|
this.useQuaternion = useQuaternion;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(position)) {
|
||||||
|
position = new GameLib.API.Vector3();
|
||||||
|
}
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
||||||
|
quaternion = new GameLib.API.Quaternion();
|
||||||
|
}
|
||||||
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
||||||
|
rotation = new GameLib.API.Vector3();
|
||||||
|
}
|
||||||
|
this.rotation = rotation;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
||||||
|
scale = new GameLib.API.Vector3(1,1,1);
|
||||||
|
}
|
||||||
|
this.scale = scale;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(up)) {
|
||||||
|
up = new GameLib.API.Vector3(0,1,0);
|
||||||
|
}
|
||||||
|
this.up = up;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(lookAt)) {
|
||||||
|
lookAt = new GameLib.API.Vector3();
|
||||||
|
}
|
||||||
|
this.lookAt = lookAt;
|
||||||
|
|
||||||
|
GameLib.API.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.D3.API.Object.GetComponentType(this.objectType),
|
||||||
|
parentEntity
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Object.prototype = Object.create(GameLib.API.Component.prototype);
|
||||||
|
GameLib.D3.API.Object.prototype.constructor = GameLib.D3.API.Object;
|
||||||
|
|
||||||
|
GameLib.D3.API.Object.GetComponentType = function(objectType) {
|
||||||
|
|
||||||
|
var componentType = null;
|
||||||
|
|
||||||
|
switch (objectType) {
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_NONE :
|
||||||
|
componentType = GameLib.Component.OBJECT;
|
||||||
|
break;
|
||||||
|
/**
|
||||||
|
* Cameras
|
||||||
|
*/
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA :
|
||||||
|
componentType = GameLib.Component.CAMERA;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE :
|
||||||
|
componentType = GameLib.Component.CAMERA_PERSPECTIVE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC :
|
||||||
|
componentType = GameLib.Component.CAMERA_ORTHOGRAPHIC;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO :
|
||||||
|
componentType = GameLib.Component.CAMERA_STEREO;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE :
|
||||||
|
componentType = GameLib.Component.CAMERA_CUBE;
|
||||||
|
break;
|
||||||
|
/**
|
||||||
|
* Meshes
|
||||||
|
*/
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_MESH :
|
||||||
|
componentType = GameLib.Component.MESH;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error('unsupported camera type: ' + objectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return componentType;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_NONE = 0x0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cameras
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA = 0x11;
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE = 0x12;//0x1;
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC = 0x13;//0x2;
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO = 0x14;//0x3;
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE = 0x15;//0x4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meshes
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Object.OBJECT_TYPE_MESH = 0x21;
|
|
@ -1,133 +1,52 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.API.Camera
|
* GameLib.D3.API.Camera
|
||||||
* @param id
|
* @param apiD3Object
|
||||||
* @param name
|
|
||||||
* @param cameraType GameLib.D3.API.Camera.CAMERA_TYPE_*
|
|
||||||
* @param aspect
|
* @param aspect
|
||||||
* @param position GameLib.API.Vector3
|
|
||||||
* @param rotation
|
|
||||||
* @param quaternion
|
|
||||||
* @param lookAt GameLib.API.Vector3
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera = function(
|
GameLib.D3.API.Camera = function(
|
||||||
id,
|
apiD3Object,
|
||||||
name,
|
aspect
|
||||||
cameraType,
|
|
||||||
aspect,
|
|
||||||
position,
|
|
||||||
rotation,
|
|
||||||
quaternion,
|
|
||||||
lookAt,
|
|
||||||
parentEntity
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3Object)) {
|
||||||
id = GameLib.Utils.RandomId();
|
apiD3Object = {
|
||||||
}
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA
|
||||||
this.id = id;
|
};
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(cameraType)) {
|
|
||||||
throw new Error('No camera type specified - do not call this constructor directly');
|
|
||||||
}
|
|
||||||
this.cameraType = cameraType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.cameraType) {
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC :
|
|
||||||
name = 'Camera Orthographic';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE :
|
|
||||||
name = 'Camera Perspective';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_CUBE :
|
|
||||||
name = 'Camera Cube';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_STEREO :
|
|
||||||
name = 'Camera Stereo';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for camera');
|
|
||||||
name = 'Camera';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
name += ' (' + this.id + ')';
|
if (GameLib.Utils.UndefinedOrNull(apiD3Object.objectType)) {
|
||||||
|
apiD3Object.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA;
|
||||||
}
|
}
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(aspect)) {
|
if (GameLib.Utils.UndefinedOrNull(aspect)) {
|
||||||
aspect = 1;
|
aspect = 1;
|
||||||
}
|
}
|
||||||
this.aspect = aspect;
|
this.aspect = aspect;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3Object.position)) {
|
||||||
position = new GameLib.API.Vector3(
|
apiD3Object.position = new GameLib.API.Vector3(
|
||||||
15,
|
15,
|
||||||
15,
|
15,
|
||||||
15
|
15
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(lookAt)) {
|
GameLib.D3.API.Object.call(
|
||||||
lookAt = new GameLib.API.Vector3(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.lookAt = lookAt;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.API.Quaternion();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
this,
|
||||||
GameLib.D3.API.Camera.GetComponentType(this.cameraType),
|
apiD3Object.id,
|
||||||
parentEntity
|
apiD3Object.name,
|
||||||
|
apiD3Object.objectType,
|
||||||
|
apiD3Object.parentEntity,
|
||||||
|
apiD3Object.useQuaternion,
|
||||||
|
apiD3Object.position,
|
||||||
|
apiD3Object.quaternion,
|
||||||
|
apiD3Object.rotation,
|
||||||
|
apiD3Object.scale,
|
||||||
|
apiD3Object.up,
|
||||||
|
apiD3Object.lookAt
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Camera.prototype = Object.create(GameLib.API.Component.prototype);
|
GameLib.D3.API.Camera.prototype = Object.create(GameLib.D3.API.Object.prototype);
|
||||||
GameLib.D3.API.Camera.prototype.constructor = GameLib.D3.API.Camera;
|
GameLib.D3.API.Camera.prototype.constructor = GameLib.D3.API.Camera;
|
||||||
|
|
||||||
GameLib.D3.API.Camera.GetComponentType = function(cameraType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (cameraType) {
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE :
|
|
||||||
componentType = GameLib.Component.CAMERA_PERSPECTIVE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC :
|
|
||||||
componentType = GameLib.Component.CAMERA_ORTHOGRAPHIC;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_STEREO :
|
|
||||||
componentType = GameLib.Component.CAMERA_STEREO;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_CUBE :
|
|
||||||
componentType = GameLib.Component.CAMERA_CUBE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('unsupported camera type: ' + cameraType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE = 0x1;
|
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC = 0x2;
|
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_STEREO = 0x3;
|
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_CUBE = 0x4;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.API.Camera.Cube
|
* GameLib.D3.API.Camera.Cube
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param apiCamera
|
* @param apiD3ObjectCamera
|
||||||
* @param near
|
* @param near
|
||||||
* @param far
|
* @param far
|
||||||
* @param cubeResolution
|
* @param cubeResolution
|
||||||
* @param renderTarget
|
* @param renderTarget
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera.Cube = function(
|
GameLib.D3.API.Camera.Cube = function(
|
||||||
apiCamera,
|
apiD3ObjectCamera,
|
||||||
near,
|
near,
|
||||||
far,
|
far,
|
||||||
cubeResolution,
|
cubeResolution,
|
||||||
renderTarget
|
renderTarget
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
||||||
apiCamera = {
|
apiD3ObjectCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_CUBE
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera.cameraType)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
||||||
apiCamera.cameraType = GameLib.D3.API.Camera.CAMERA_TYPE_CUBE;
|
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(near)) {
|
if (GameLib.Utils.UndefinedOrNull(near)) {
|
||||||
|
@ -50,15 +50,8 @@ GameLib.D3.API.Camera.Cube = function(
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera.call(
|
GameLib.D3.API.Camera.call(
|
||||||
this,
|
this,
|
||||||
apiCamera.id,
|
apiD3ObjectCamera,
|
||||||
apiCamera.name,
|
apiD3ObjectCamera.aspect
|
||||||
apiCamera.cameraType,
|
|
||||||
1,
|
|
||||||
apiCamera.position,
|
|
||||||
apiCamera.rotation,
|
|
||||||
apiCamera.quaternion,
|
|
||||||
apiCamera.lookAt,
|
|
||||||
apiCamera.parentEntity
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* Also - the offset is always respected
|
* Also - the offset is always respected
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param apiCamera
|
* @param apiD3ObjectCamera
|
||||||
* @param aspectRatioMode
|
* @param aspectRatioMode
|
||||||
* @param minWidth
|
* @param minWidth
|
||||||
* @param minHeight
|
* @param minHeight
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
* @param zoom
|
* @param zoom
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera.Orthographic = function(
|
GameLib.D3.API.Camera.Orthographic = function(
|
||||||
apiCamera,
|
apiD3ObjectCamera,
|
||||||
aspectRatioMode,
|
aspectRatioMode,
|
||||||
minWidth,
|
minWidth,
|
||||||
minHeight,
|
minHeight,
|
||||||
|
@ -46,22 +46,22 @@ GameLib.D3.API.Camera.Orthographic = function(
|
||||||
zoom
|
zoom
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
||||||
apiCamera = {
|
apiD3ObjectCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera.cameraType)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
||||||
apiCamera.cameraType = GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC;
|
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera.position)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.position)) {
|
||||||
apiCamera.position = new GameLib.API.Vector3(0,0,10);
|
apiD3ObjectCamera.position = new GameLib.API.Vector3(0,0,10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera.lookAt)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.lookAt)) {
|
||||||
apiCamera.lookAt = new GameLib.API.Vector3(0,0,-1);
|
apiD3ObjectCamera.lookAt = new GameLib.API.Vector3(0,0,-10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(aspectRatioMode)) {
|
if (GameLib.Utils.UndefinedOrNull(aspectRatioMode)) {
|
||||||
|
@ -131,15 +131,8 @@ GameLib.D3.API.Camera.Orthographic = function(
|
||||||
|
|
||||||
GameLib.D3.API.Camera.call(
|
GameLib.D3.API.Camera.call(
|
||||||
this,
|
this,
|
||||||
apiCamera.id,
|
apiD3ObjectCamera,
|
||||||
apiCamera.name,
|
apiD3ObjectCamera.aspect
|
||||||
apiCamera.cameraType,
|
|
||||||
apiCamera.aspect,
|
|
||||||
apiCamera.position,
|
|
||||||
apiCamera.rotation,
|
|
||||||
apiCamera.quaternion,
|
|
||||||
apiCamera.lookAt,
|
|
||||||
apiCamera.parentEntity
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.API.Camera.Perspective
|
* GameLib.D3.API.Camera.Perspective
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param apiCamera
|
* @param apiD3ObjectCamera
|
||||||
* @param fov
|
* @param fov
|
||||||
* @param near
|
* @param near
|
||||||
* @param far
|
* @param far
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
* @param zoom
|
* @param zoom
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera.Perspective = function(
|
GameLib.D3.API.Camera.Perspective = function(
|
||||||
apiCamera,
|
apiD3ObjectCamera,
|
||||||
near,
|
near,
|
||||||
far,
|
far,
|
||||||
fov,
|
fov,
|
||||||
|
@ -21,14 +21,14 @@ GameLib.D3.API.Camera.Perspective = function(
|
||||||
zoom
|
zoom
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
||||||
apiCamera = {
|
apiD3ObjectCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera.cameraType)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
||||||
apiCamera.cameraType = GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE;
|
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(near)) {
|
if (GameLib.Utils.UndefinedOrNull(near)) {
|
||||||
|
@ -75,15 +75,8 @@ GameLib.D3.API.Camera.Perspective = function(
|
||||||
|
|
||||||
GameLib.D3.API.Camera.call(
|
GameLib.D3.API.Camera.call(
|
||||||
this,
|
this,
|
||||||
apiCamera.id,
|
apiD3ObjectCamera,
|
||||||
apiCamera.name,
|
apiD3ObjectCamera.aspect
|
||||||
apiCamera.cameraType,
|
|
||||||
apiCamera.aspect,
|
|
||||||
apiCamera.position,
|
|
||||||
apiCamera.rotation,
|
|
||||||
apiCamera.quaternion,
|
|
||||||
apiCamera.lookAt,
|
|
||||||
apiCamera.parentEntity
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.API.Camera.Stereo
|
* GameLib.D3.API.Camera.Stereo
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param apiCamera
|
* @param apiD3ObjectCamera
|
||||||
* @param stereoMode
|
* @param stereoMode
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera.Stereo = function(
|
GameLib.D3.API.Camera.Stereo = function(
|
||||||
apiCamera,
|
apiD3ObjectCamera,
|
||||||
stereoMode
|
stereoMode
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
||||||
apiCamera = {
|
apiD3ObjectCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_STEREO
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera.cameraType)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
||||||
apiCamera.cameraType = GameLib.D3.API.Camera.CAMERA_TYPE_STEREO;
|
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(stereoMode)) {
|
if (GameLib.Utils.UndefinedOrNull(stereoMode)) {
|
||||||
stereoMode = GameLib.D3.API.Camera.Stereo.STEREO_MODE_STEREO;
|
stereoMode = GameLib.D3.API.Camera.Stereo.STEREO_MODE_STEREO;
|
||||||
}
|
}
|
||||||
|
@ -26,15 +27,8 @@ GameLib.D3.API.Camera.Stereo = function(
|
||||||
|
|
||||||
GameLib.D3.API.Camera.call(
|
GameLib.D3.API.Camera.call(
|
||||||
this,
|
this,
|
||||||
apiCamera.id,
|
apiD3ObjectCamera,
|
||||||
apiCamera.name,
|
apiD3ObjectCamera.aspect
|
||||||
apiCamera.cameraType,
|
|
||||||
apiCamera.aspect,
|
|
||||||
apiCamera.position,
|
|
||||||
apiCamera.rotation,
|
|
||||||
apiCamera.quaternion,
|
|
||||||
apiCamera.lookAt,
|
|
||||||
apiCamera.parentEntity
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.API.Mesh
|
* GameLib.D3.API.Mesh
|
||||||
* @param id
|
* @param apiD3Object
|
||||||
* @param name
|
|
||||||
* @param meshType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param geometry
|
* @param geometry
|
||||||
* @param materials
|
* @param materials
|
||||||
* @param parentMesh
|
* @param parentMesh
|
||||||
* @param parentScene
|
* @param parentScene
|
||||||
* @param excludeFromEnvironment
|
* @param excludeFromEnvironment
|
||||||
* @param skeleton
|
* @param skeleton
|
||||||
* @param position
|
|
||||||
* @param quaternion
|
|
||||||
* @param rotation
|
|
||||||
* @param scale
|
|
||||||
* @param up
|
|
||||||
* @param renderOrder
|
* @param renderOrder
|
||||||
* @param useQuaternion
|
|
||||||
* @param visible
|
* @param visible
|
||||||
* @param castShadow
|
* @param castShadow
|
||||||
* @param receiveShadow
|
* @param receiveShadow
|
||||||
|
@ -26,23 +17,14 @@
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Mesh = function(
|
GameLib.D3.API.Mesh = function(
|
||||||
id,
|
apiD3Object,
|
||||||
name,
|
|
||||||
meshType,
|
|
||||||
parentEntity,
|
|
||||||
geometry,
|
geometry,
|
||||||
materials,
|
materials,
|
||||||
parentMesh,
|
parentMesh,
|
||||||
parentScene,
|
parentScene,
|
||||||
excludeFromEnvironment,
|
excludeFromEnvironment,
|
||||||
skeleton,
|
skeleton,
|
||||||
position,
|
|
||||||
quaternion,
|
|
||||||
rotation,
|
|
||||||
scale,
|
|
||||||
up,
|
|
||||||
renderOrder,
|
renderOrder,
|
||||||
useQuaternion,
|
|
||||||
visible,
|
visible,
|
||||||
castShadow,
|
castShadow,
|
||||||
receiveShadow,
|
receiveShadow,
|
||||||
|
@ -50,54 +32,15 @@ GameLib.D3.API.Mesh = function(
|
||||||
morphTargetInfluences,
|
morphTargetInfluences,
|
||||||
morphTargetDictionary
|
morphTargetDictionary
|
||||||
) {
|
) {
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3Object)) {
|
||||||
id = GameLib.Utils.RandomId();
|
apiD3Object = {
|
||||||
}
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_MESH
|
||||||
this.id = id;
|
};
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(meshType)) {
|
|
||||||
meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
|
|
||||||
}
|
|
||||||
this.meshType = meshType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.meshType) {
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_NORMAL :
|
|
||||||
name = 'Mesh';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_BOX :
|
|
||||||
name = 'Mesh Box';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_TEXT :
|
|
||||||
name = 'Mesh Text';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_CURVE :
|
|
||||||
name = 'Mesh Curve';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_LINE :
|
|
||||||
name = 'Mesh Line';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_SPHERE :
|
|
||||||
name = 'Mesh Sphere';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER :
|
|
||||||
name = 'Mesh Cylinder';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_PLANE :
|
|
||||||
name = 'Mesh Plane';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_SKINNED :
|
|
||||||
name = 'Mesh Skinned';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for mesh');
|
|
||||||
name = 'Mesh';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
name += ' (' + id + ')';
|
if (GameLib.Utils.UndefinedOrNull(apiD3Object.objectType)) {
|
||||||
|
apiD3Object.objectType = GameLib.D3.API.Object.OBJECT_TYPE_MESH;
|
||||||
}
|
}
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(geometry)) {
|
if (GameLib.Utils.UndefinedOrNull(geometry)) {
|
||||||
geometry = null;
|
geometry = null;
|
||||||
|
@ -131,41 +74,11 @@ GameLib.D3.API.Mesh = function(
|
||||||
}
|
}
|
||||||
this.skeleton = skeleton;
|
this.skeleton = skeleton;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.API.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.API.Quaternion();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.API.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.API.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(up)) {
|
|
||||||
up = new GameLib.API.Vector3(0,1,0);
|
|
||||||
}
|
|
||||||
this.up = up;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(renderOrder)) {
|
if (GameLib.Utils.UndefinedOrNull(renderOrder)) {
|
||||||
renderOrder = 0;
|
renderOrder = 0;
|
||||||
}
|
}
|
||||||
this.renderOrder = renderOrder;
|
this.renderOrder = renderOrder;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(useQuaternion)) {
|
|
||||||
useQuaternion = true;
|
|
||||||
}
|
|
||||||
this.useQuaternion = useQuaternion;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(visible)) {
|
if (GameLib.Utils.UndefinedOrNull(visible)) {
|
||||||
visible = true;
|
visible = true;
|
||||||
}
|
}
|
||||||
|
@ -196,57 +109,27 @@ GameLib.D3.API.Mesh = function(
|
||||||
}
|
}
|
||||||
this.morphTargetDictionary = morphTargetDictionary;
|
this.morphTargetDictionary = morphTargetDictionary;
|
||||||
|
|
||||||
var componentType = GameLib.Component.MESH;
|
GameLib.D3.API.Object.call(
|
||||||
|
|
||||||
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) {
|
|
||||||
componentType = GameLib.Component.MESH_PLANE
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_BOX) {
|
|
||||||
componentType = GameLib.Component.MESH_BOX
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER) {
|
|
||||||
componentType = GameLib.Component.MESH_CYLINDER
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_SPHERE) {
|
|
||||||
componentType = GameLib.Component.MESH_SPHERE
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_LINE) {
|
|
||||||
componentType = GameLib.Component.MESH_LINE
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_TEXT) {
|
|
||||||
componentType = GameLib.Component.MESH_TEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
this,
|
||||||
componentType,
|
apiD3Object.id,
|
||||||
parentEntity
|
apiD3Object.name,
|
||||||
|
apiD3Object.objectType,
|
||||||
|
apiD3Object.parentEntity,
|
||||||
|
apiD3Object.useQuaternion,
|
||||||
|
apiD3Object.position,
|
||||||
|
apiD3Object.quaternion,
|
||||||
|
apiD3Object.rotation,
|
||||||
|
apiD3Object.scale,
|
||||||
|
apiD3Object.up,
|
||||||
|
apiD3Object.lookAt
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.API.Component.prototype);
|
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.D3.API.Object.prototype);
|
||||||
GameLib.D3.API.Mesh.prototype.constructor = GameLib.D3.API.Mesh;
|
GameLib.D3.API.Mesh.prototype.constructor = GameLib.D3.API.Mesh;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mesh Type
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_NORMAL = 0x0;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_SKINNED = 0x1;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_CURVE = 0x2;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_SPHERE = 0x3;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_PLANE = 0x4;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_BOX = 0x5;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER = 0x6;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_TEXT = 0x7;
|
|
||||||
GameLib.D3.API.Mesh.MESH_TYPE_LINE = 0x8;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw Modes
|
* Draw Modes
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -0,0 +1,324 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.Object
|
||||||
|
* @param graphics
|
||||||
|
* @param apiObject
|
||||||
|
* @property objectType
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Object = function (
|
||||||
|
graphics,
|
||||||
|
apiObject
|
||||||
|
) {
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiObject)) {
|
||||||
|
apiObject = {
|
||||||
|
objectType: GameLib.D3.API.Object.OBJECT_TYPE_NONE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.API.Object.call(
|
||||||
|
this,
|
||||||
|
apiObject.id,
|
||||||
|
apiObject.name,
|
||||||
|
apiObject.objectType,
|
||||||
|
apiObject.parentEntity,
|
||||||
|
apiObject.useQuaternion,
|
||||||
|
apiObject.position,
|
||||||
|
apiObject.quaternion,
|
||||||
|
apiObject.rotation,
|
||||||
|
apiObject.scale,
|
||||||
|
apiObject.up,
|
||||||
|
apiObject.lookAt
|
||||||
|
);
|
||||||
|
|
||||||
|
this.position = new GameLib.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this.position,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
this.quaternion = new GameLib.Quaternion(
|
||||||
|
this.graphics,
|
||||||
|
this.quaternion,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
this.rotation = new GameLib.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this.rotation,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
this.scale = new GameLib.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this.scale,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
this.up = new GameLib.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this.up,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
this.lookAt = new GameLib.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this.lookAt,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.D3.Object.GetLinkedObjects(this.objectType)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Object.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
GameLib.D3.Object.prototype.constructor = GameLib.D3.Object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Linked Objects
|
||||||
|
* @param objectType
|
||||||
|
* @returns {{}}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Object.GetLinkedObjects = function(objectType) {
|
||||||
|
var linkedObjects = {};
|
||||||
|
|
||||||
|
switch (objectType) {
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE :
|
||||||
|
linkedObjects.renderTarget = GameLib.D3.RenderTarget;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO :
|
||||||
|
linkedObjects.effect = GameLib.D3.Effect;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Object.OBJECT_TYPE_MESH :
|
||||||
|
linkedObjects.parentMesh = GameLib.D3.Mesh;
|
||||||
|
linkedObjects.parentScene = GameLib.D3.Scene;
|
||||||
|
linkedObjects.materials = [GameLib.D3.Material];
|
||||||
|
linkedObjects.geometry = GameLib.D3.Geometry;
|
||||||
|
linkedObjects.skeleton = GameLib.D3.Skeleton;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return linkedObjects;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a mesh instance or updates it
|
||||||
|
*/
|
||||||
|
GameLib.D3.Object.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
if (!this.instance) {
|
||||||
|
console.warn('do not call the GameLib.D3.Object constructor directly');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateInstance('position');
|
||||||
|
|
||||||
|
if (this instanceof GameLib.D3.Camera) {
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.objectType === GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE ||
|
||||||
|
this.objectType === GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO
|
||||||
|
) {
|
||||||
|
this.updateInstance('lookAt');
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* We ignore 'lookAt' - since it updates the rotation etc.. We assume that after lookAt we have our orientation
|
||||||
|
* and store /use these values instead - lookAt is more a 'runtime' thing
|
||||||
|
*/
|
||||||
|
this.updateInstance('rotation');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateInstance('scale');
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.Component.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the mesh instance
|
||||||
|
*/
|
||||||
|
GameLib.D3.Object.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
||||||
|
console.warn('3d object instance not ready');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'objectType') {
|
||||||
|
var componentType = GameLib.D3.API.Object.GetComponentType(this.objectType);
|
||||||
|
this.replace(componentType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
property === 'useQuaternion' ||
|
||||||
|
property === 'quaternion' ||
|
||||||
|
property === 'rotation'
|
||||||
|
) {
|
||||||
|
if (this.useQuaternion) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.quaternion)) {
|
||||||
|
|
||||||
|
this.quaternion.axis.instance.x = this.quaternion.axis.x;
|
||||||
|
this.quaternion.axis.instance.y = this.quaternion.axis.y;
|
||||||
|
this.quaternion.axis.instance.z = this.quaternion.axis.z;
|
||||||
|
|
||||||
|
this.instance.quaternion.x = this.quaternion.x;
|
||||||
|
this.instance.quaternion.y = this.quaternion.y;
|
||||||
|
this.instance.quaternion.z = this.quaternion.z;
|
||||||
|
this.instance.quaternion.w = this.quaternion.w;
|
||||||
|
this.instance.quaternion.setFromAxisAngle(
|
||||||
|
this.quaternion.axis.instance,
|
||||||
|
this.quaternion.angle
|
||||||
|
);
|
||||||
|
|
||||||
|
this.rotation.x = this.instance.rotation.x;
|
||||||
|
this.rotation.y = this.instance.rotation.y;
|
||||||
|
this.rotation.z = this.instance.rotation.z;
|
||||||
|
|
||||||
|
this.rotation.instance.x = this.rotation.x;
|
||||||
|
this.rotation.instance.y = this.rotation.y;
|
||||||
|
this.rotation.instance.z = this.rotation.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.rotation)) {
|
||||||
|
|
||||||
|
this.rotation.instance.x = this.rotation.x;
|
||||||
|
this.rotation.instance.y = this.rotation.y;
|
||||||
|
this.rotation.instance.z = this.rotation.z;
|
||||||
|
|
||||||
|
this.instance.rotation.x = this.rotation.x;
|
||||||
|
this.instance.rotation.y = this.rotation.y;
|
||||||
|
this.instance.rotation.z = this.rotation.z;
|
||||||
|
|
||||||
|
this.quaternion.x = this.instance.quaternion.x;
|
||||||
|
this.quaternion.y = this.instance.quaternion.y;
|
||||||
|
this.quaternion.z = this.instance.quaternion.z;
|
||||||
|
this.quaternion.w = this.instance.quaternion.w;
|
||||||
|
|
||||||
|
this.quaternion.instance.x = this.quaternion.x;
|
||||||
|
this.quaternion.instance.y = this.quaternion.y;
|
||||||
|
this.quaternion.instance.z = this.quaternion.z;
|
||||||
|
this.quaternion.instance.w = this.quaternion.w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'position') {
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.position)) {
|
||||||
|
|
||||||
|
this.position.instance.x = this.position.x;
|
||||||
|
this.position.instance.y = this.position.y;
|
||||||
|
this.position.instance.z = this.position.z;
|
||||||
|
|
||||||
|
this.instance.position.x = this.position.x;
|
||||||
|
this.instance.position.y = this.position.y;
|
||||||
|
this.instance.position.z = this.position.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'scale') {
|
||||||
|
|
||||||
|
this.scale.instance.x = this.scale.x;
|
||||||
|
this.scale.instance.y = this.scale.y;
|
||||||
|
this.scale.instance.z = this.scale.z;
|
||||||
|
|
||||||
|
this.instance.scale.x = this.scale.x;
|
||||||
|
this.instance.scale.y = this.scale.y;
|
||||||
|
this.instance.scale.z = this.scale.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
property === 'up' ||
|
||||||
|
property === 'lookAt'
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.up.instance.x = this.up.x;
|
||||||
|
this.up.instance.y = this.up.y;
|
||||||
|
this.up.instance.z = this.up.z;
|
||||||
|
|
||||||
|
this.instance.up.x = this.up.x;
|
||||||
|
this.instance.up.y = this.up.y;
|
||||||
|
this.instance.up.z = this.up.z;
|
||||||
|
|
||||||
|
this.lookAt.instance.x = this.lookAt.x;
|
||||||
|
this.lookAt.instance.y = this.lookAt.y;
|
||||||
|
this.lookAt.instance.z = this.lookAt.z;
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.lookAt)) {
|
||||||
|
this.instance.lookAt(this.lookAt.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
||||||
|
this.instance.updateProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Object.prototype.updateFromInstance.call(this, 'rotation');
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update GameLib.D3.Object from its instance
|
||||||
|
* @param property
|
||||||
|
*/
|
||||||
|
GameLib.D3.Object.prototype.updateFromInstance = function(property) {
|
||||||
|
if (
|
||||||
|
property === 'rotation' ||
|
||||||
|
property === 'quaternion'
|
||||||
|
) {
|
||||||
|
this.rotation.x = this.instance.rotation.x;
|
||||||
|
this.rotation.y = this.instance.rotation.y;
|
||||||
|
this.rotation.z = this.instance.rotation.z;
|
||||||
|
|
||||||
|
this.quaternion.x = this.instance.quaternion.x;
|
||||||
|
this.quaternion.y = this.instance.quaternion.y;
|
||||||
|
this.quaternion.z = this.instance.quaternion.z;
|
||||||
|
this.quaternion.w = this.instance.quaternion.w;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Object to a GameLib.D3.API.Object
|
||||||
|
* @returns {GameLib.D3.API.Object}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Object.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiObject = new GameLib.D3.API.Object(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.objectType,
|
||||||
|
GameLib.Utils.IdOrNull(this.parentEntity),
|
||||||
|
this.useQuaternion,
|
||||||
|
this.position.toApiObject(),
|
||||||
|
this.quaternion.toApiObject(),
|
||||||
|
this.rotation.toApiObject(),
|
||||||
|
this.scale.toApiObject(),
|
||||||
|
this.up.toApiObject(),
|
||||||
|
this.lookAt.toApiObject()
|
||||||
|
);
|
||||||
|
|
||||||
|
return apiObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Object.prototype.translate = function(vector3) {
|
||||||
|
|
||||||
|
this.position.x += vector3.x;
|
||||||
|
this.position.y += vector3.y;
|
||||||
|
this.position.z += vector3.z;
|
||||||
|
|
||||||
|
this.updateInstance('position');
|
||||||
|
};
|
|
@ -1,78 +1,37 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.Camera
|
* GameLib.D3.Camera
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
* @param apiCamera GameLib.D3.API.Camera
|
* @param apiD3ObjectCamera GGameLib.D3.API.Object
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera = function(
|
GameLib.D3.Camera = function(
|
||||||
graphics,
|
graphics,
|
||||||
apiCamera
|
apiD3ObjectCamera
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
||||||
apiCamera = {};
|
apiD3ObjectCamera = {
|
||||||
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.Camera.call(
|
GameLib.D3.API.Camera.call(
|
||||||
this,
|
this,
|
||||||
apiCamera.id,
|
apiD3ObjectCamera,
|
||||||
apiCamera.name,
|
apiD3ObjectCamera.aspect
|
||||||
apiCamera.cameraType,
|
|
||||||
apiCamera.aspect,
|
|
||||||
apiCamera.position,
|
|
||||||
apiCamera.rotation,
|
|
||||||
apiCamera.quaternion,
|
|
||||||
apiCamera.lookAt,
|
|
||||||
apiCamera.parentEntity
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.position = new GameLib.Vector3(
|
GameLib.D3.Object.call(
|
||||||
graphics,
|
|
||||||
this.position,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.lookAt = new GameLib.Vector3(
|
|
||||||
graphics,
|
|
||||||
this.lookAt,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.rotation = new GameLib.Vector3(
|
|
||||||
graphics,
|
|
||||||
this.rotation,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.quaternion = new GameLib.Quaternion(
|
|
||||||
graphics,
|
|
||||||
this.quaternion,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
var linkedObjects = {};
|
|
||||||
|
|
||||||
switch (apiCamera.cameraType) {
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_CUBE :
|
|
||||||
linkedObjects.renderTarget = GameLib.D3.RenderTarget;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_STEREO :
|
|
||||||
linkedObjects.effect = GameLib.D3.Effect;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
this,
|
||||||
linkedObjects
|
this.graphics,
|
||||||
|
this
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Camera.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.Camera.prototype = Object.create(GameLib.D3.Object.prototype);
|
||||||
GameLib.D3.Camera.prototype.constructor = GameLib.D3.Camera;
|
GameLib.D3.Camera.prototype.constructor = GameLib.D3.Camera;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,29 +40,6 @@ GameLib.D3.Camera.prototype.constructor = GameLib.D3.Camera;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.prototype.createInstance = function() {
|
GameLib.D3.Camera.prototype.createInstance = function() {
|
||||||
|
|
||||||
/**
|
|
||||||
* Not all implementations of camera has a position (Stereo camera gets its position on update)
|
|
||||||
*/
|
|
||||||
if (GameLib.Utils.Defined(this.instance.position)) {
|
|
||||||
this.instance.position.x = this.position.x;
|
|
||||||
this.instance.position.y = this.position.y;
|
|
||||||
this.instance.position.z = this.position.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.rotation)) {
|
|
||||||
this.instance.rotation.x = this.rotation.x;
|
|
||||||
this.instance.rotation.y = this.rotation.y;
|
|
||||||
this.instance.rotation.z = this.rotation.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.quaternion)) {
|
|
||||||
this.instance.quaternion.x = this.quaternion.x;
|
|
||||||
this.instance.quaternion.y = this.quaternion.y;
|
|
||||||
this.instance.quaternion.z = this.quaternion.z;
|
|
||||||
this.instance.quaternion.w = this.quaternion.w;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not all implementations of camera has aspect ratio, we, however do have an aspect ratio for all our cameras
|
* Not all implementations of camera has aspect ratio, we, however do have an aspect ratio for all our cameras
|
||||||
*/
|
*/
|
||||||
|
@ -116,21 +52,7 @@ GameLib.D3.Camera.prototype.createInstance = function() {
|
||||||
this.instance.aspect = this.aspect;
|
this.instance.aspect = this.aspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
GameLib.D3.Object.prototype.createInstance.call(this);
|
||||||
* Only do lookAt for stereo and cube cameras
|
|
||||||
*/
|
|
||||||
if (
|
|
||||||
this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_STEREO ||
|
|
||||||
this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE
|
|
||||||
) {
|
|
||||||
this.instance.lookAt(this.lookAt.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
|
||||||
this.instance.updateProjectionMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,38 +60,6 @@ GameLib.D3.Camera.prototype.createInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.prototype.updateInstance = function(property) {
|
GameLib.D3.Camera.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(property)) {
|
|
||||||
console.warn('no camera property specified for : ' + this.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'cameraType') {
|
|
||||||
|
|
||||||
this.remove();
|
|
||||||
|
|
||||||
var args = [this.graphics, {
|
|
||||||
id : this.id,
|
|
||||||
name : this.name
|
|
||||||
}];
|
|
||||||
|
|
||||||
if (this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_STEREO) {
|
|
||||||
GameLib.D3.Camera.Stereo.apply(this, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_CUBE) {
|
|
||||||
GameLib.D3.Camera.Cube.apply(this, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE) {
|
|
||||||
GameLib.D3.Camera.Perspective.apply(this, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC) {
|
|
||||||
GameLib.D3.Camera.Orthographic.apply(this, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'aspect') {
|
if (property === 'aspect') {
|
||||||
if (GameLib.Utils.Defined(this.instance.aspect)) {
|
if (GameLib.Utils.Defined(this.instance.aspect)) {
|
||||||
this.instance.aspect = this.aspect;
|
this.instance.aspect = this.aspect;
|
||||||
|
@ -182,92 +72,12 @@ GameLib.D3.Camera.prototype.updateInstance = function(property) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'position') {
|
GameLib.D3.Object.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
this.instance.position.x = this.position.x;
|
|
||||||
this.instance.position.y = this.position.y;
|
|
||||||
this.instance.position.z = this.position.z;
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
|
||||||
this.instance.updateProjectionMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'rotation') {
|
|
||||||
|
|
||||||
this.instance.rotation.x = this.rotation.x;
|
|
||||||
this.instance.rotation.y = this.rotation.y;
|
|
||||||
this.instance.rotation.z = this.rotation.z;
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
|
||||||
this.instance.updateProjectionMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'quaternion') {
|
|
||||||
|
|
||||||
console.log('todo: update quaternion');
|
|
||||||
|
|
||||||
// return;
|
|
||||||
// if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
|
||||||
// this.instance.updateProjectionMatrix();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'lookAt') {
|
|
||||||
|
|
||||||
this.lookAt.instance.x = this.lookAt.x;
|
|
||||||
this.lookAt.instance.y = this.lookAt.y;
|
|
||||||
this.lookAt.instance.z = this.lookAt.z;
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.lookAt)) {
|
|
||||||
this.instance.lookAt(this.lookAt.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
|
||||||
this.instance.updateProjectionMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize default
|
* Update GameLib.D3.Camera from instance
|
||||||
* @param width
|
|
||||||
* @param height
|
|
||||||
*/
|
*/
|
||||||
// GameLib.D3.Camera.prototype.resize = function(width, height) {
|
|
||||||
// camera.aspect = width / height;
|
|
||||||
// camera.updateInstance();
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Camera to a new GameLib.D3.API.Camera
|
|
||||||
* @returns {GameLib.D3.API.Camera}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Camera.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
return new GameLib.D3.API.Camera(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.cameraType,
|
|
||||||
this.aspect,
|
|
||||||
this.position.toApiObject(),
|
|
||||||
this.lookAt.toApiObject(),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Camera.prototype.updateFromInstance = function() {
|
GameLib.D3.Camera.prototype.updateFromInstance = function() {
|
||||||
|
|
||||||
this.aspect = this.instance.aspect;
|
this.aspect = this.instance.aspect;
|
||||||
|
@ -284,3 +94,17 @@ GameLib.D3.Camera.prototype.updateFromInstance = function() {
|
||||||
console.warn('todo: update lookAt somehow...');
|
console.warn('todo: update lookAt somehow...');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Camera to a new GameLib.D3.API.Camera
|
||||||
|
* @returns {GameLib.D3.API.Camera}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Camera.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiD3Object = GameLib.D3.Object.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Camera(
|
||||||
|
apiD3Object,
|
||||||
|
this.aspect
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.Camera.Cube
|
* GameLib.D3.Camera.Cube
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
* @param apiCubeCamera
|
* @param apiD3ObjectCubeCamera
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.Cube = function(
|
GameLib.D3.Camera.Cube = function(
|
||||||
graphics,
|
graphics,
|
||||||
apiCubeCamera
|
apiD3ObjectCubeCamera
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiCubeCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCubeCamera)) {
|
||||||
apiCubeCamera = {
|
apiD3ObjectCubeCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_CUBE
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Cube.call(
|
GameLib.D3.API.Camera.Cube.call(
|
||||||
this,
|
this,
|
||||||
apiCubeCamera,
|
apiD3ObjectCubeCamera,
|
||||||
apiCubeCamera.near,
|
apiD3ObjectCubeCamera.near,
|
||||||
apiCubeCamera.far,
|
apiD3ObjectCubeCamera.far,
|
||||||
apiCubeCamera.cubeResolution,
|
apiD3ObjectCubeCamera.cubeResolution,
|
||||||
apiCubeCamera.renderTarget
|
apiD3ObjectCubeCamera.renderTarget
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.renderTarget instanceof GameLib.D3.API.RenderTarget.Cube) {
|
if (this.renderTarget instanceof GameLib.D3.API.RenderTarget.Cube) {
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.Camera.Orthographic
|
* GameLib.D3.Camera.Orthographic
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
* @param apiOrthographicCamera
|
* @param apiD3OBjectOrthographicCamera
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.Orthographic = function(
|
GameLib.D3.Camera.Orthographic = function(
|
||||||
graphics,
|
graphics,
|
||||||
apiOrthographicCamera
|
apiD3OBjectOrthographicCamera
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiOrthographicCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3OBjectOrthographicCamera)) {
|
||||||
apiOrthographicCamera = {
|
apiD3OBjectOrthographicCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC,
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC,
|
||||||
position : GameLib.API.Vector3(0,0,10),
|
position : GameLib.API.Vector3(0,0,10),
|
||||||
lookAt: GameLib.API.Vector3(0,0,-1)
|
lookAt: GameLib.API.Vector3(0,0,-10)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Orthographic.call(
|
GameLib.D3.API.Camera.Orthographic.call(
|
||||||
this,
|
this,
|
||||||
apiOrthographicCamera,
|
apiD3OBjectOrthographicCamera,
|
||||||
apiOrthographicCamera.aspectRatioMode,
|
apiD3OBjectOrthographicCamera.aspectRatioMode,
|
||||||
apiOrthographicCamera.minWidth,
|
apiD3OBjectOrthographicCamera.minWidth,
|
||||||
apiOrthographicCamera.minHeight,
|
apiD3OBjectOrthographicCamera.minHeight,
|
||||||
apiOrthographicCamera.width,
|
apiD3OBjectOrthographicCamera.width,
|
||||||
apiOrthographicCamera.height,
|
apiD3OBjectOrthographicCamera.height,
|
||||||
apiOrthographicCamera.near,
|
apiD3OBjectOrthographicCamera.near,
|
||||||
apiOrthographicCamera.far,
|
apiD3OBjectOrthographicCamera.far,
|
||||||
apiOrthographicCamera.left,
|
apiD3OBjectOrthographicCamera.left,
|
||||||
apiOrthographicCamera.right,
|
apiD3OBjectOrthographicCamera.right,
|
||||||
apiOrthographicCamera.top,
|
apiD3OBjectOrthographicCamera.top,
|
||||||
apiOrthographicCamera.bottom,
|
apiD3OBjectOrthographicCamera.bottom,
|
||||||
apiOrthographicCamera.zoom
|
apiD3OBjectOrthographicCamera.zoom
|
||||||
);
|
);
|
||||||
|
|
||||||
GameLib.D3.Camera.call(
|
GameLib.D3.Camera.call(
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.Camera.Perspective
|
* GameLib.D3.Camera.Perspective
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
* @param apiPerspectiveCamera
|
* @param apiD3ObjectPerspectiveCamera
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.Perspective = function(
|
GameLib.D3.Camera.Perspective = function(
|
||||||
graphics,
|
graphics,
|
||||||
apiPerspectiveCamera
|
apiD3ObjectPerspectiveCamera
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPerspectiveCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectPerspectiveCamera)) {
|
||||||
apiPerspectiveCamera = {
|
apiD3ObjectPerspectiveCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Perspective.call(
|
GameLib.D3.API.Camera.Perspective.call(
|
||||||
this,
|
this,
|
||||||
apiPerspectiveCamera,
|
apiD3ObjectPerspectiveCamera,
|
||||||
apiPerspectiveCamera.near,
|
apiD3ObjectPerspectiveCamera.near,
|
||||||
apiPerspectiveCamera.far,
|
apiD3ObjectPerspectiveCamera.far,
|
||||||
apiPerspectiveCamera.fov,
|
apiD3ObjectPerspectiveCamera.fov,
|
||||||
apiPerspectiveCamera.filmGauge,
|
apiD3ObjectPerspectiveCamera.filmGauge,
|
||||||
apiPerspectiveCamera.filmOffset,
|
apiD3ObjectPerspectiveCamera.filmOffset,
|
||||||
apiPerspectiveCamera.focus,
|
apiD3ObjectPerspectiveCamera.focus,
|
||||||
apiPerspectiveCamera.zoom
|
apiD3ObjectPerspectiveCamera.zoom
|
||||||
);
|
);
|
||||||
|
|
||||||
GameLib.D3.Camera.call(
|
GameLib.D3.Camera.call(
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.Camera.Stereo
|
* GameLib.D3.Camera.Stereo
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
* @param apiStereoCamera
|
* @param apiD3ObjectStereoCamera
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.Stereo = function(
|
GameLib.D3.Camera.Stereo = function(
|
||||||
graphics,
|
graphics,
|
||||||
apiStereoCamera
|
apiD3ObjectStereoCamera
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiStereoCamera)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectStereoCamera)) {
|
||||||
apiStereoCamera = {
|
apiD3ObjectStereoCamera = {
|
||||||
cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_STEREO
|
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Stereo.call(
|
GameLib.D3.API.Camera.Stereo.call(
|
||||||
this,
|
this,
|
||||||
apiStereoCamera,
|
apiD3ObjectStereoCamera,
|
||||||
apiStereoCamera.stereoMode
|
apiD3ObjectStereoCamera.stereoMode
|
||||||
);
|
);
|
||||||
|
|
||||||
GameLib.D3.Camera.call(
|
GameLib.D3.Camera.call(
|
||||||
|
|
|
@ -218,3 +218,4 @@ GameLib.D3.Geometry.prototype.updateFromInstance = function() {
|
||||||
console.warn('the child class should take care of updating from instance');
|
console.warn('the child class should take care of updating from instance');
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -469,3 +469,31 @@ GameLib.D3.Geometry.Normal.prototype.computeVertexNormals = function() {
|
||||||
console.log('re-computing vertex normals');
|
console.log('re-computing vertex normals');
|
||||||
this.instance.computeVertexNormals();
|
this.instance.computeVertexNormals();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invert winding order
|
||||||
|
*/
|
||||||
|
GameLib.D3.Geometry.Normal.prototype.invertWindingOrder = function() {
|
||||||
|
|
||||||
|
this.faces.forEach(
|
||||||
|
function (face) {
|
||||||
|
|
||||||
|
var tmpV1 = face.v1;
|
||||||
|
face.v1 = face.v2;
|
||||||
|
face.v2 = tmpV1;
|
||||||
|
|
||||||
|
var tmpV1uv = face.v1uv;
|
||||||
|
face.v1uv = face.v2uv;
|
||||||
|
face.v2uv = tmpV1uv;
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.instance) {
|
||||||
|
this.instance.computeVertexNormals();
|
||||||
|
this.instance.computeFaceNormals();
|
||||||
|
this.instance.elementsNeedUpdate = true;
|
||||||
|
this.instance.normalsNeedUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -41,7 +41,7 @@ GameLib.D3.Helper = function(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
object instanceof GameLib.D3.Mesh &&
|
object instanceof GameLib.D3.Mesh &&
|
||||||
object.meshType !== GameLib.D3.API.Mesh.MESH_TYPE_CURVE
|
object.meshType !== GameLib.D3.API.Object.OBJECT_TYPE_MESH_CURVE
|
||||||
) {
|
) {
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_EDGES;
|
helperType = GameLib.D3.Helper.HELPER_TYPE_EDGES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,39 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.D3.Mesh
|
* GameLib.D3.Mesh
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
* @param apiMesh GameLib.D3.API.Mesh
|
* @param apiD3ObjectMesh GameLib.D3.API.Mesh
|
||||||
* @property geometry
|
* @property geometry
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh = function (
|
GameLib.D3.Mesh = function (
|
||||||
graphics,
|
graphics,
|
||||||
apiMesh
|
apiD3ObjectMesh
|
||||||
) {
|
) {
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectMesh)) {
|
||||||
apiMesh = {
|
apiD3ObjectMesh = {
|
||||||
meshType: GameLib.D3.API.Mesh.MESH_TYPE_NORMAL
|
objectType: GameLib.D3.API.Object.OBJECT_TYPE_MESH
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.Mesh.call(
|
GameLib.D3.API.Mesh.call(
|
||||||
this,
|
this,
|
||||||
apiMesh.id,
|
apiD3ObjectMesh,
|
||||||
apiMesh.name,
|
apiD3ObjectMesh.geometry,
|
||||||
apiMesh.meshType,
|
apiD3ObjectMesh.materials,
|
||||||
apiMesh.parentEntity,
|
apiD3ObjectMesh.parentMesh,
|
||||||
apiMesh.geometry,
|
apiD3ObjectMesh.parentScene,
|
||||||
apiMesh.materials,
|
apiD3ObjectMesh.excludeFromEnvironment,
|
||||||
apiMesh.parentMesh,
|
apiD3ObjectMesh.skeleton,
|
||||||
apiMesh.parentScene,
|
apiD3ObjectMesh.renderOrder,
|
||||||
apiMesh.excludeFromEnvironment,
|
apiD3ObjectMesh.visible,
|
||||||
apiMesh.skeleton,
|
apiD3ObjectMesh.castShadow,
|
||||||
apiMesh.position,
|
apiD3ObjectMesh.receiveShadow,
|
||||||
apiMesh.quaternion,
|
apiD3ObjectMesh.drawMode,
|
||||||
apiMesh.rotation,
|
apiD3ObjectMesh.morphTargetInfluences,
|
||||||
apiMesh.scale,
|
apiD3ObjectMesh.morphTargetDictionary
|
||||||
apiMesh.up,
|
|
||||||
apiMesh.renderOrder,
|
|
||||||
apiMesh.useQuaternion,
|
|
||||||
apiMesh.visible,
|
|
||||||
apiMesh.castShadow,
|
|
||||||
apiMesh.receiveShadow,
|
|
||||||
apiMesh.drawMode,
|
|
||||||
apiMesh.morphTargetInfluences,
|
|
||||||
apiMesh.morphTargetDictionary
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -71,71 +62,22 @@ GameLib.D3.Mesh = function (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.position = new GameLib.Vector3(
|
|
||||||
this.graphics,
|
|
||||||
this.position,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.quaternion = new GameLib.Quaternion(
|
|
||||||
this.graphics,
|
|
||||||
this.quaternion,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.rotation = new GameLib.Vector3(
|
|
||||||
this.graphics,
|
|
||||||
this.rotation,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.scale = new GameLib.Vector3(
|
|
||||||
this.graphics,
|
|
||||||
this.scale,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.up = new GameLib.Vector3(
|
|
||||||
this.graphics,
|
|
||||||
this.up,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
var linkedObjects = {
|
|
||||||
'parentMesh' : GameLib.D3.Mesh,
|
|
||||||
'parentScene' : GameLib.D3.Scene,
|
|
||||||
'materials' : [GameLib.D3.Material],
|
|
||||||
'geometry' : GameLib.D3.Geometry,
|
|
||||||
'skeleton' : GameLib.D3.Skeleton
|
|
||||||
};
|
|
||||||
|
|
||||||
if (apiMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) {
|
|
||||||
linkedObjects.dotObject = GameLib.D3.Mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (apiMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_TEXT) {
|
|
||||||
linkedObjects.font = GameLib.D3.Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runtime meshes have helpers too
|
* Runtime meshes have helpers too
|
||||||
* @type {null}
|
* @type {null}
|
||||||
*/
|
*/
|
||||||
this.helper = null;
|
this.helper = null;
|
||||||
|
|
||||||
this.updateRotationFromAxisAngle = true;
|
GameLib.D3.Object.call(
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
this,
|
||||||
linkedObjects
|
this.graphics,
|
||||||
|
this
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.Mesh.prototype = Object.create(GameLib.D3.Object.prototype);
|
||||||
GameLib.D3.Mesh.prototype.constructor = GameLib.D3.Mesh;
|
GameLib.D3.Mesh.prototype.constructor = GameLib.D3.Mesh;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a mesh instance or updates it
|
* Creates a mesh instance or updates it
|
||||||
*/
|
*/
|
||||||
|
@ -197,37 +139,6 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
|
||||||
this.parentScene.addObject(this);
|
this.parentScene.addObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance.position.x = this.position.x;
|
|
||||||
this.instance.position.y = this.position.y;
|
|
||||||
this.instance.position.z = this.position.z;
|
|
||||||
|
|
||||||
if (this.useQuaternion) {
|
|
||||||
this.instance.quaternion.x = this.quaternion.x;
|
|
||||||
this.instance.quaternion.y = this.quaternion.y;
|
|
||||||
this.instance.quaternion.z = this.quaternion.z;
|
|
||||||
this.instance.quaternion.w = this.quaternion.w;
|
|
||||||
this.instance.quaternion.setFromAxisAngle(
|
|
||||||
new THREE.Vector3(
|
|
||||||
this.quaternion.axis.x,
|
|
||||||
this.quaternion.axis.y,
|
|
||||||
this.quaternion.axis.z
|
|
||||||
),
|
|
||||||
this.quaternion.angle
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.instance.rotation.x = this.rotation.x;
|
|
||||||
this.instance.rotation.y = this.rotation.y;
|
|
||||||
this.instance.rotation.z = this.rotation.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance.scale.x = this.scale.x;
|
|
||||||
this.instance.scale.y = this.scale.y;
|
|
||||||
this.instance.scale.z = this.scale.z;
|
|
||||||
|
|
||||||
this.instance.up.x = this.up.x;
|
|
||||||
this.instance.up.y = this.up.y;
|
|
||||||
this.instance.up.z = this.up.z;
|
|
||||||
|
|
||||||
this.instance.renderOrder = this.renderOrder;
|
this.instance.renderOrder = this.renderOrder;
|
||||||
|
|
||||||
this.instance.visible = this.visible;
|
this.instance.visible = this.visible;
|
||||||
|
@ -244,7 +155,7 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
|
||||||
this.morphTargetInfluences = this.instance.morphTargetInfluences;
|
this.morphTargetInfluences = this.instance.morphTargetInfluences;
|
||||||
this.morphTargetDictionary = this.instance.morphTargetDictionary;
|
this.morphTargetDictionary = this.instance.morphTargetDictionary;
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
GameLib.D3.Object.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,17 +246,10 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (property === 'parentScene') {
|
||||||
property === 'rotation' ||
|
/**
|
||||||
property === 'quaternion' ||
|
* This is handled by LinkingSystem - probably will change soon
|
||||||
property === 'useQuaternion'
|
*/
|
||||||
) {
|
|
||||||
this.updateInstanceRotation();
|
|
||||||
if (this.helper) {
|
|
||||||
this.removeHelper();
|
|
||||||
this.createHelper();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'parentMesh') {
|
if (property === 'parentMesh') {
|
||||||
|
@ -418,35 +322,12 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
|
||||||
this.instance.parent = this.parentMesh.instance;
|
this.instance.parent = this.parentMesh.instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.helper) {
|
if (this.helper) {
|
||||||
this.removeHelper();
|
this.removeHelper();
|
||||||
this.createHelper();
|
this.createHelper();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'scale') {
|
|
||||||
this.updateInstanceScale();
|
|
||||||
if (this.helper) {
|
|
||||||
this.removeHelper();
|
|
||||||
this.createHelper();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'position') {
|
|
||||||
this.updateInstancePosition();
|
|
||||||
if (this.helper) {
|
|
||||||
this.removeHelper();
|
|
||||||
this.createHelper();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'up') {
|
|
||||||
this.instance.up.x = this.up.x;
|
|
||||||
this.instance.up.y = this.up.y;
|
|
||||||
this.instance.up.z = this.up.z;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,230 +356,40 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
GameLib.D3.Object.prototype.updateInstance.call(this, property);
|
||||||
* 'parentScene' is handled by LinkingSystem
|
|
||||||
*/
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.lookAt = function(vector) {
|
|
||||||
|
|
||||||
this.instance.lookAt(
|
|
||||||
new THREE.Vector3(
|
|
||||||
vector.x,
|
|
||||||
vector.y,
|
|
||||||
vector.z
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.rotation.x = this.instance.rotation.x;
|
|
||||||
this.rotation.y = this.instance.rotation.y;
|
|
||||||
this.rotation.z = this.instance.rotation.z;
|
|
||||||
|
|
||||||
this.quaternion.x = this.instance.quaternion.x;
|
|
||||||
this.quaternion.y = this.instance.quaternion.y;
|
|
||||||
this.quaternion.z = this.instance.quaternion.z;
|
|
||||||
this.quaternion.w = this.instance.quaternion.w;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.invertWindingOrder = function() {
|
|
||||||
|
|
||||||
this.faces.forEach(
|
|
||||||
function (face) {
|
|
||||||
|
|
||||||
var tmpV1 = face.v1;
|
|
||||||
face.v1 = face.v2;
|
|
||||||
face.v2 = tmpV1;
|
|
||||||
|
|
||||||
var tmpV1uv = face.v1uv;
|
|
||||||
face.v1uv = face.v2uv;
|
|
||||||
face.v2uv = tmpV1uv;
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.instance) {
|
|
||||||
this.instance.geometry.computeVertexNormals();
|
|
||||||
this.instance.geometry.computeFaceNormals();
|
|
||||||
this.instance.geometry.normalsNeedUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.applyBones = function(geometry) {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup Bone Indexes
|
* Update our helper (if any)
|
||||||
*/
|
*/
|
||||||
this.skinIndices.map(
|
if (
|
||||||
function(skinIndex) {
|
property === 'useQuaternion' ||
|
||||||
geometry.skinIndices.push(
|
property === 'position' ||
|
||||||
new THREE.Vector4(
|
property === 'rotation' ||
|
||||||
skinIndex.x,
|
property === 'quaternion' ||
|
||||||
skinIndex.y,
|
property === 'scale' ||
|
||||||
skinIndex.z,
|
property === 'up' ||
|
||||||
skinIndex.w
|
property === 'lookAt'
|
||||||
)
|
) {
|
||||||
);
|
if (this.helper) {
|
||||||
|
this.removeHelper();
|
||||||
|
this.createHelper();
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup Bone Weights
|
|
||||||
*/
|
|
||||||
this.skinWeights.map(
|
|
||||||
function(skinWeight) {
|
|
||||||
geometry.skinWeights.push(
|
|
||||||
new THREE.Vector4(
|
|
||||||
skinWeight.x,
|
|
||||||
skinWeight.y,
|
|
||||||
skinWeight.z,
|
|
||||||
skinWeight.w
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a child instance to this instance
|
|
||||||
* @param childInstance
|
|
||||||
* @param child
|
|
||||||
*/
|
|
||||||
// GameLib.D3.Mesh.prototype.addChild = function(childInstance, child) {
|
|
||||||
//
|
|
||||||
// if (!this.instance) {
|
|
||||||
// throw new Error('mesh instance not loaded yet : ' + this.name);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (GameLib.Utils.UndefinedOrNull(childInstance)) {
|
|
||||||
// throw new Error('no child mesh instance');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (GameLib.Utils.UndefinedOrNull(child)) {
|
|
||||||
// throw new Error('no child mesh');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.instance.add(childInstance);
|
|
||||||
//
|
|
||||||
// childInstance.parent = this.instance;
|
|
||||||
//
|
|
||||||
// child.parentMesh = this;
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a parent for this mesh
|
|
||||||
* @param parentMesh
|
|
||||||
*/
|
|
||||||
// GameLib.D3.Mesh.prototype.setParentMesh = function(parentMesh) {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Are we removing this child from the parent?
|
|
||||||
// */
|
|
||||||
// if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
|
|
||||||
//
|
|
||||||
// if (this.instance && this.instance.parent && this.parentScene.instance) {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Update the parent matrix world
|
|
||||||
// */
|
|
||||||
// this.instance.parent.updateMatrixWorld();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Copy the child world position into a temporary vector
|
|
||||||
// * @type {THREE.Vector3}
|
|
||||||
// */
|
|
||||||
// var vector = new THREE.Vector3();
|
|
||||||
// vector.setFromMatrixPosition(this.instance.matrixWorld);
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Detach child from parent within this scene
|
|
||||||
// */
|
|
||||||
// THREE.SceneUtils.detach(
|
|
||||||
// this.instance,
|
|
||||||
// this.instance.parent,
|
|
||||||
// this.parentScene.instance
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * We remember from now on that we have no parent mesh
|
|
||||||
// * @type {null}
|
|
||||||
// */
|
|
||||||
// this.parentMesh = null;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * We store the world position back to the child
|
|
||||||
// */
|
|
||||||
// this.position.x = vector.x;
|
|
||||||
// this.position.y = vector.y;
|
|
||||||
// this.position.z = vector.z;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Update the instance position
|
|
||||||
// */
|
|
||||||
// this.updateInstancePosition();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Don't touch this instance parent - since it is now probably a scene object
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * TODO: do we apply rotation somehow?
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// throw new Error('Not enough information to detach')
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// if (!this.instance) {
|
|
||||||
// throw new Error('No valid instance at time of adding to parent for mesh ' + this.name);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!(parentMesh instanceof GameLib.D3.Mesh)) {
|
|
||||||
// throw new Error('Not a valid parent mesh');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.parentMesh = parentMesh;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Add this as a child to the parent
|
|
||||||
// */
|
|
||||||
// this.parentMesh.addChild(this.instance, this);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
// GameLib.D3.Mesh.prototype.getBoundingBox = function() {
|
|
||||||
//
|
|
||||||
// this.instance.geometry.computeBoundingBox();
|
|
||||||
//
|
|
||||||
// return new GameLib.Vector3(
|
|
||||||
// this.graphics,
|
|
||||||
// new GameLib.API.Vector3(
|
|
||||||
// this.instance.geometry.boundingBox.max.x - this.instance.geometry.boundingBox.min.x,
|
|
||||||
// this.instance.geometry.boundingBox.max.y - this.instance.geometry.boundingBox.min.y,
|
|
||||||
// this.instance.geometry.boundingBox.max.z - this.instance.geometry.boundingBox.min.z
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
|
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
|
||||||
|
* TODO: morph stuff
|
||||||
* @returns {GameLib.D3.API.Mesh}
|
* @returns {GameLib.D3.API.Mesh}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.prototype.toApiObject = function() {
|
GameLib.D3.Mesh.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiD3Object = GameLib.D3.Object.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
var apiMesh = new GameLib.D3.API.Mesh(
|
var apiMesh = new GameLib.D3.API.Mesh(
|
||||||
this.id,
|
apiD3Object,
|
||||||
this.name,
|
|
||||||
this.meshType,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity),
|
|
||||||
GameLib.Utils.IdOrNull(this.geometry),
|
GameLib.Utils.IdOrNull(this.geometry),
|
||||||
this.materials.map(
|
this.materials.map(
|
||||||
function(material) {
|
function(material) {
|
||||||
|
@ -709,19 +400,13 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
|
||||||
GameLib.Utils.IdOrNull(this.parentScene),
|
GameLib.Utils.IdOrNull(this.parentScene),
|
||||||
this.excludeFromEnvironment,
|
this.excludeFromEnvironment,
|
||||||
GameLib.Utils.IdOrNull(this.skeleton),
|
GameLib.Utils.IdOrNull(this.skeleton),
|
||||||
this.position.toApiObject(),
|
|
||||||
this.quaternion.toApiObject(),
|
|
||||||
this.rotation.toApiObject(),
|
|
||||||
this.scale.toApiObject(),
|
|
||||||
this.up.toApiObject(),
|
|
||||||
this.renderOrder,
|
this.renderOrder,
|
||||||
this.useQuaternion,
|
|
||||||
this.visible,
|
this.visible,
|
||||||
this.castShadow,
|
this.castShadow,
|
||||||
this.receiveShadow,
|
this.receiveShadow,
|
||||||
this.drawMode
|
this.drawMode
|
||||||
// this.morphTargetInfluences,
|
//morphTargetInfluences,
|
||||||
// this.morphTargetDictionary
|
//morphTargetDictionary
|
||||||
);
|
);
|
||||||
|
|
||||||
return apiMesh;
|
return apiMesh;
|
||||||
|
@ -753,86 +438,6 @@ GameLib.D3.Mesh.prototype.centerAroundOrigin = function() {
|
||||||
return position;
|
return position;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.applyAxisAngleToPosition = function(axis, angle) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(axis)) {
|
|
||||||
axis = this.quaternion.axis;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(angle)) {
|
|
||||||
angle = this.quaternion.angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.position.applyAxisAngle(axis, angle);
|
|
||||||
this.updateInstancePosition();
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.applyAxisAngleToUvs = function(axis, angle) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(axis)) {
|
|
||||||
axis = this.quaternion.axis;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(angle)) {
|
|
||||||
angle = this.quaternion.angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.instance.geometry.faceVertexUvs[0].map(
|
|
||||||
// function(uvs) {
|
|
||||||
// uvs.map(function(uv) {
|
|
||||||
//
|
|
||||||
// var x = uv.x;
|
|
||||||
//
|
|
||||||
// uv.x = uv.y;
|
|
||||||
// uv.y = x;
|
|
||||||
//
|
|
||||||
// //var v = new THREE.Vector3(uv.x, uv.y, 0);
|
|
||||||
// //v.applyAxisAngle(axis, angle);
|
|
||||||
// //uv.x = v.x;
|
|
||||||
// //uv.y = v.u;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
this.instance.geometry.uvsNeedUpdate = true;
|
|
||||||
//
|
|
||||||
// this.faces.map(
|
|
||||||
// function(face) {
|
|
||||||
// face.uvs.map(function(uvs){
|
|
||||||
// uvs.map(
|
|
||||||
// function(uv) {
|
|
||||||
// var v = new GameLib.Vector3(this.graphics, new GameLib.API.Vector3(uv.x, uv.y, 0));
|
|
||||||
// v.applyAxisAngle(axis, angle);
|
|
||||||
// uv.x = v.x;
|
|
||||||
// uv.y = v.y;
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.translate = function(vector3) {
|
|
||||||
|
|
||||||
this.position.x += vector3.x;
|
|
||||||
this.position.y += vector3.y;
|
|
||||||
this.position.z += vector3.z;
|
|
||||||
|
|
||||||
this.updateInstancePosition();
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.getDistanceFromCenter = function() {
|
|
||||||
var position = this.instance.geometry.center();
|
|
||||||
return new GameLib.Vector3(
|
|
||||||
this.graphics,
|
|
||||||
new GameLib.API.Vector3(
|
|
||||||
position.x,
|
|
||||||
position.y,
|
|
||||||
position.z
|
|
||||||
)
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies position, rotation and scale to the object vertice data, resets scale, rotation and sets position to origin.
|
* Applies position, rotation and scale to the object vertice data, resets scale, rotation and sets position to origin.
|
||||||
*/
|
*/
|
||||||
|
@ -841,6 +446,7 @@ GameLib.D3.Mesh.prototype.applyPositionRotationScale = function() {
|
||||||
this.instance.updateMatrix();
|
this.instance.updateMatrix();
|
||||||
|
|
||||||
this.instance.geometry.applyMatrix(this.instance.matrix);
|
this.instance.geometry.applyMatrix(this.instance.matrix);
|
||||||
|
this.geometry.instance.updateFromInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset position
|
* Reset position
|
||||||
|
@ -883,90 +489,6 @@ GameLib.D3.Mesh.prototype.applyPositionRotationScale = function() {
|
||||||
* Update our instance matrix
|
* Update our instance matrix
|
||||||
*/
|
*/
|
||||||
this.instance.updateMatrix();
|
this.instance.updateMatrix();
|
||||||
|
|
||||||
/**
|
|
||||||
* Let this reflect back to our vertices
|
|
||||||
*/
|
|
||||||
this.updateVerticesFromGeometryInstance(this.instance.geometry);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstanceRotationFromAxisAngle = function(axis, angle) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(axis)) {
|
|
||||||
axis = this.quaternion.axis;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(angle)) {
|
|
||||||
angle = this.quaternion.angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.quaternion.axis.instance.x = axis.x;
|
|
||||||
this.quaternion.axis.instance.y = axis.y;
|
|
||||||
this.quaternion.axis.instance.z = axis.z;
|
|
||||||
this.quaternion.instance.setFromAxisAngle(this.quaternion.axis.instance, angle);
|
|
||||||
this.instance.quaternion.copy(this.quaternion.instance);
|
|
||||||
this.quaternion.x = this.quaternion.instance.x;
|
|
||||||
this.quaternion.y = this.quaternion.instance.y;
|
|
||||||
this.quaternion.z = this.quaternion.instance.z;
|
|
||||||
this.quaternion.w = this.quaternion.instance.w;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstanceRotation = function() {
|
|
||||||
|
|
||||||
if (this.useQuaternion) {
|
|
||||||
|
|
||||||
this.updateInstanceRotationFromAxisAngle();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
this.rotation.instance.set(
|
|
||||||
this.rotation.x,
|
|
||||||
this.rotation.y,
|
|
||||||
this.rotation.z
|
|
||||||
);
|
|
||||||
|
|
||||||
this.instance.rotation.set(
|
|
||||||
this.rotation.x,
|
|
||||||
this.rotation.y,
|
|
||||||
this.rotation.z
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.helper) {
|
|
||||||
this.helper.updateInstance();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstancePosition = function() {
|
|
||||||
|
|
||||||
this.position.instance.set(
|
|
||||||
this.position.x,
|
|
||||||
this.position.y,
|
|
||||||
this.position.z
|
|
||||||
);
|
|
||||||
|
|
||||||
this.instance.position.copy(this.position.instance);
|
|
||||||
|
|
||||||
if (this.helper) {
|
|
||||||
this.removeHelper();
|
|
||||||
this.createHelper();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstanceScale = function() {
|
|
||||||
|
|
||||||
this.scale.instance.set(
|
|
||||||
this.scale.x,
|
|
||||||
this.scale.y,
|
|
||||||
this.scale.z
|
|
||||||
);
|
|
||||||
|
|
||||||
this.instance.scale.copy(this.scale.instance);
|
|
||||||
|
|
||||||
if (this.helper) {
|
|
||||||
this.removeHelper();
|
|
||||||
this.createHelper();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -975,92 +497,35 @@ GameLib.D3.Mesh.prototype.updateInstanceScale = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.prototype.getChildrenComponents = function() {
|
GameLib.D3.Mesh.prototype.getChildrenComponents = function() {
|
||||||
|
|
||||||
var components = [];
|
var children = GameLib.Component.prototype.getChildrenComponents.call(this);
|
||||||
|
|
||||||
this.buildIdToObject();
|
|
||||||
|
|
||||||
Object.keys(this.idToObject).map(
|
|
||||||
function(objectId) {
|
|
||||||
if (this.id !== objectId) {
|
|
||||||
components.push(this.idToObject[objectId]);
|
|
||||||
}
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
return components;
|
|
||||||
/*
|
|
||||||
|
|
||||||
this.materials.map(
|
|
||||||
function (material) {
|
|
||||||
|
|
||||||
if (material instanceof GameLib.D3.Material) {
|
|
||||||
GameLib.Utils.PushUnique(components, material);
|
|
||||||
|
|
||||||
for (var property in material.linkedObjects) {
|
|
||||||
if (
|
|
||||||
material.linkedObjects.hasOwnProperty(property) &&
|
|
||||||
material.hasOwnProperty(property) &&
|
|
||||||
material[property] &&
|
|
||||||
typeof material[property] !== 'string' &&
|
|
||||||
property !== 'parentEntity'
|
|
||||||
) {
|
|
||||||
GameLib.Utils.PushUnique(components, material[property]);
|
|
||||||
for (var tProperty in material[property].linkedObjects) {
|
|
||||||
if (
|
|
||||||
material[property].linkedObjects.hasOwnProperty(tProperty) &&
|
|
||||||
material[property].hasOwnProperty(tProperty) &&
|
|
||||||
material[property][tProperty] &&
|
|
||||||
typeof material[property][tProperty] !== 'string' &&
|
|
||||||
tProperty !== 'parentEntity'
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (material[property][tProperty] instanceof Array) {
|
|
||||||
material[property][tProperty].map(
|
|
||||||
function(object) {
|
|
||||||
GameLib.Utils.PushUnique(components, object);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
GameLib.Utils.PushUnique(components, material[property][tProperty]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Push RigidBodies
|
* Push RigidBodies
|
||||||
*/
|
*/
|
||||||
/* var rigidBodies = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RIGID_BODY);
|
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RIGID_BODY).map(
|
||||||
rigidBodies.map(
|
|
||||||
function(rigidBody) {
|
function(rigidBody) {
|
||||||
|
|
||||||
if (rigidBody.parentMesh === this) {
|
if (rigidBody.parentMesh === this) {
|
||||||
GameLib.Utils.PushUnique(components, rigidBody);
|
GameLib.Utils.PushUnique(children, rigidBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Push Shapes
|
* Push Shapes
|
||||||
*/
|
*/
|
||||||
/* var shapes = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SHAPE);
|
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SHAPE).map(
|
||||||
shapes.map(
|
|
||||||
function(shape) {
|
function(shape) {
|
||||||
|
|
||||||
if (shape.parentMesh === this) {
|
if (shape.parentMesh === this) {
|
||||||
GameLib.Utils.PushUnique(components, shape);
|
GameLib.Utils.PushUnique(children, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
// return components;
|
return children;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1099,18 +564,6 @@ GameLib.D3.Mesh.prototype.createHelper = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// GameLib.D3.Mesh.prototype.addMaterial = function(material) {
|
|
||||||
// if (this.materials.length === 1) {
|
|
||||||
// this.instance.material = material.instance;
|
|
||||||
// } else {
|
|
||||||
// this.instance.material = this.materials.map(
|
|
||||||
// function(material) {
|
|
||||||
// return material.instance;
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function for removing a helper for this Mesh - should be called from Systems only
|
* Convenience function for removing a helper for this Mesh - should be called from Systems only
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1158,14 +1158,14 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
object,
|
object,
|
||||||
property,
|
property,
|
||||||
{
|
{
|
||||||
'normal' : GameLib.D3.API.Mesh.MESH_TYPE_NORMAL,
|
'normal' : GameLib.D3.API.Object.OBJECT_TYPE_MESH,
|
||||||
'curve' : GameLib.D3.API.Mesh.MESH_TYPE_CURVE,
|
'curve' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_CURVE,
|
||||||
'skinned' : GameLib.D3.API.Mesh.MESH_TYPE_SKINNED,
|
'skinned' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_SKINNED,
|
||||||
'plane' : GameLib.D3.API.Mesh.MESH_TYPE_PLANE,
|
'plane' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_PLANE,
|
||||||
'sphere' : GameLib.D3.API.Mesh.MESH_TYPE_SPHERE,
|
'sphere' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_SPHERE,
|
||||||
'box' : GameLib.D3.API.Mesh.MESH_TYPE_BOX,
|
'box' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_BOX,
|
||||||
'cylinder' : GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER,
|
'cylinder' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_CYLINDER,
|
||||||
'text' : GameLib.D3.API.Mesh.MESH_TYPE_TEXT
|
'text' : GameLib.D3.API.Object.OBJECT_TYPE_MESH_TEXT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -1175,10 +1175,10 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
object,
|
object,
|
||||||
property,
|
property,
|
||||||
{
|
{
|
||||||
'perspective' : GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE,
|
'perspective' : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE,
|
||||||
'orthographic' : GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC,
|
'orthographic' : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC,
|
||||||
'stereo' : GameLib.D3.API.Camera.CAMERA_TYPE_STEREO,
|
'stereo' : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO,
|
||||||
'cube' : GameLib.D3.API.Camera.CAMERA_TYPE_CUBE
|
'cube' : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue