something broken somewhere
parent
accc868f71
commit
6c2a6a38ac
|
@ -39,7 +39,7 @@ GameLib.D3.API.Bone = function Bone(
|
||||||
this.parentBoneId = parentBoneId;
|
this.parentBoneId = parentBoneId;
|
||||||
|
|
||||||
if (typeof quaternion == 'undefined') {
|
if (typeof quaternion == 'undefined') {
|
||||||
quaternion = new GameLib.D3.API.Vector4();
|
quaternion = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* @param maxY
|
* @param maxY
|
||||||
* @param minZ
|
* @param minZ
|
||||||
* @param maxZ
|
* @param maxZ
|
||||||
* @param quaternion GameLib.D3.Vector4
|
* @param quaternion GameLib.D3.Quaternion
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera = function(
|
GameLib.D3.API.Camera = function(
|
||||||
|
@ -81,7 +81,7 @@ GameLib.D3.API.Camera = function(
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.API.Vector4();
|
quaternion = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
GameLib.D3.API.Color = function Color(r, g, b, a) {
|
GameLib.D3.API.Color = function ApiColor(r, g, b, a) {
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(r)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(r)) {
|
||||||
r = 1;
|
r = 1;
|
||||||
|
|
|
@ -3,81 +3,75 @@
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param componentType
|
* @param componentType
|
||||||
* @param camera
|
* @param camera GameLib.D3.Camera
|
||||||
* @param startColor
|
* @param parentEntity GameLib.D3.Entity
|
||||||
* @param endColor
|
* @param targetEntity GameLib.D3.Entity
|
||||||
* @param lerpSpeed
|
|
||||||
* @param targetEntity
|
|
||||||
* @param targetOffset
|
* @param targetOffset
|
||||||
* @param minDistance
|
* @param minDistance
|
||||||
* @param moveSpeed
|
* @param moveSpeed
|
||||||
|
* @param target
|
||||||
|
* @param targetToParent
|
||||||
|
* @param rotatedTargetOffset
|
||||||
|
* @param rotated
|
||||||
* @param rotationSpeed
|
* @param rotationSpeed
|
||||||
* @param positionOffset
|
* @param lookAtMatrix
|
||||||
* @param quaternionOffset
|
* @param spline GameLib.D3.Spline
|
||||||
* @param scaleOffset
|
* @param mesh GameLib.D3.Mesh
|
||||||
* @param sensorLength
|
* @param accelleration
|
||||||
* @param spline
|
|
||||||
* @param normalSpline
|
|
||||||
* @param acceleration
|
|
||||||
* @param maxSpeed
|
* @param maxSpeed
|
||||||
* @param baseOffset
|
* @param baseOffset
|
||||||
* @param maxOffset
|
* @param maxOffset
|
||||||
* @param steeringSpeed
|
* @param steeringSpeed
|
||||||
* @param frontLWheelIndex
|
* @param up
|
||||||
* @param frontRWheelIndex
|
* @param currentOffset
|
||||||
* @param backLWheelIndex
|
* @param currentPathValue
|
||||||
* @param backRWheelIndex
|
* @param currentSpeed
|
||||||
* @param maxForce
|
* @param direction
|
||||||
* @param steering
|
* @param currentPosition
|
||||||
* @param entitiesToCheck
|
|
||||||
* @param onInside
|
|
||||||
* @param onEnter
|
|
||||||
* @param onLeave
|
|
||||||
* @param onSetParent
|
|
||||||
* @param sphereRadius
|
|
||||||
* @param world
|
|
||||||
* @param maxSteerAngle
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.ComponentInterface = function(
|
GameLib.D3.API.ComponentInterface = function(
|
||||||
|
// General
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
componentType,
|
componentType,
|
||||||
|
|
||||||
|
// Camera Component
|
||||||
camera,
|
camera,
|
||||||
startColor,
|
parentEntity,
|
||||||
endColor,
|
|
||||||
lerpSpeed,
|
// Follow Component
|
||||||
targetEntity,
|
targetEntity,
|
||||||
targetOffset,
|
targetOffset,
|
||||||
minDistance,
|
minDistance,
|
||||||
moveSpeed,
|
moveSpeed,
|
||||||
|
target,
|
||||||
|
targetToParent,
|
||||||
|
rotatedTargetOffset,
|
||||||
|
rotated,
|
||||||
|
|
||||||
|
// LookAt Component
|
||||||
rotationSpeed,
|
rotationSpeed,
|
||||||
positionOffset,
|
lookAtMatrix,
|
||||||
quaternionOffset,
|
up,
|
||||||
scaleOffset,
|
|
||||||
sensorLength,
|
// Path Following Component
|
||||||
spline,
|
spline,
|
||||||
normalSpline,
|
mesh,
|
||||||
acceleration,
|
accelleration,
|
||||||
maxSpeed,
|
maxSpeed,
|
||||||
baseOffset,
|
baseOffset,
|
||||||
maxOffset,
|
maxOffset,
|
||||||
steeringSpeed,
|
steeringSpeed,
|
||||||
frontLWheelIndex,
|
currentOffset,
|
||||||
frontRWheelIndex,
|
currentPathValue,
|
||||||
backLWheelIndex,
|
currentSpeed,
|
||||||
backRWheelIndex,
|
direction,
|
||||||
maxForce,
|
currentPosition
|
||||||
steering,
|
|
||||||
entitiesToCheck,
|
|
||||||
onInside,
|
|
||||||
onEnter,
|
|
||||||
onLeave,
|
|
||||||
onSetParent,
|
|
||||||
sphereRadius,
|
|
||||||
world,
|
|
||||||
maxSteerAngle
|
|
||||||
) {
|
) {
|
||||||
|
/**
|
||||||
|
* General
|
||||||
|
*/
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.D3.Utils.RandomId();
|
id = GameLib.D3.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -93,88 +87,100 @@ GameLib.D3.API.ComponentInterface = function(
|
||||||
}
|
}
|
||||||
this.componentType = componentType;
|
this.componentType = componentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Camera Component
|
||||||
|
*/
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(camera)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(camera)) {
|
||||||
camera = null;
|
camera = null;
|
||||||
}
|
}
|
||||||
this.camera = camera;
|
this.camera = camera;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(startColor)) {
|
/**
|
||||||
startColor = new GameLib.D3.API.Vector3(0, 0, 0);
|
* Follow Component
|
||||||
}
|
*/
|
||||||
this.startColor = startColor;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(endColor)) {
|
|
||||||
endColor = new GameLib.D3.API.Vector3(1, 1, 1);
|
|
||||||
}
|
|
||||||
this.endColor = endColor;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lerpSpeed)) {
|
|
||||||
lerpSpeed = 1.0;
|
|
||||||
}
|
|
||||||
this.lerpSpeed = lerpSpeed;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(targetEntity)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(targetEntity)) {
|
||||||
targetEntity = null;
|
targetEntity = null;
|
||||||
}
|
}
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
}
|
}
|
||||||
this.targetOffset = targetOffset;
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(minDistance)) {
|
|
||||||
minDistance = 0;
|
|
||||||
}
|
|
||||||
this.minDistance = minDistance;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(moveSpeed)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(moveSpeed)) {
|
||||||
moveSpeed = 12.5;
|
moveSpeed = 12.5;
|
||||||
}
|
}
|
||||||
this.moveSpeed = moveSpeed;
|
this.moveSpeed = moveSpeed;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(minDistance)) {
|
||||||
|
minDistance = 0;
|
||||||
|
}
|
||||||
|
this.minDistance = minDistance;
|
||||||
|
|
||||||
|
if(GameLib.D3.Utils.UndefinedOrNull(target)) {
|
||||||
|
target = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
this.target = target;
|
||||||
|
|
||||||
|
if(GameLib.D3.Utils.UndefinedOrNull(targetToParent)) {
|
||||||
|
targetToParent = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
this.targetToParent = targetToParent;
|
||||||
|
|
||||||
|
if(GameLib.D3.Utils.UndefinedOrNull(rotatedTargetOffset)) {
|
||||||
|
rotatedTargetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
this.rotatedTargetOffset = rotatedTargetOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(rotated)) {
|
||||||
|
rotated = new GameLib.D3.API.Quaternion();
|
||||||
|
}
|
||||||
|
this.rotated = rotated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LookAt Component
|
||||||
|
*/
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotationSpeed)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotationSpeed)) {
|
||||||
rotationSpeed = 22.0;
|
rotationSpeed = 22.0;
|
||||||
}
|
}
|
||||||
this.rotationSpeed = rotationSpeed;
|
this.rotationSpeed = rotationSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(positionOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(lookAtMatrix)) {
|
||||||
positionOffset = new GameLib.D3.API.Vector3();
|
lookAtMatrix = new GameLib.D3.API.Matrix4();
|
||||||
}
|
}
|
||||||
this.positionOffset = positionOffset;
|
this.lookAtMatrix = lookAtMatrix;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(up)) {
|
||||||
quaternionOffset = new GameLib.D3.API.Vector4();
|
up = new GameLib.D3.API.Vector3(0, 1, 0);
|
||||||
}
|
}
|
||||||
this.quaternionOffset = quaternionOffset;
|
this.up = up;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
|
||||||
scaleOffset = new GameLib.D3.API.Vector3();
|
|
||||||
}
|
|
||||||
this.scaleOffset = scaleOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(sensorLength)) {
|
|
||||||
sensorLength = 5;
|
|
||||||
}
|
|
||||||
this.sensorLength = sensorLength;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path Following Component
|
||||||
|
*/
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(spline)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(spline)) {
|
||||||
spline = new GameLib.D3.API.Spline(null, 'spline');
|
spline = null;
|
||||||
}
|
}
|
||||||
this.spline = spline;
|
this.spline = spline;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(normalSpline)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(mesh)) {
|
||||||
normalSpline = new GameLib.D3.API.Spline(null, 'normal-spline');
|
mesh = null;
|
||||||
}
|
}
|
||||||
this.normalSpline = normalSpline;
|
this.mesh = mesh;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(acceleration)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(accelleration)) {
|
||||||
acceleration = 2.0;
|
accelleration = 0.1;
|
||||||
}
|
}
|
||||||
this.acceleration = acceleration;
|
this.accelleration = accelleration;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxSpeed)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(maxSpeed)) {
|
||||||
maxSpeed = 10.0;
|
maxSpeed = 0.03;
|
||||||
}
|
}
|
||||||
this.maxSpeed = maxSpeed;
|
this.maxSpeed = maxSpeed;
|
||||||
|
|
||||||
|
@ -193,74 +199,28 @@ GameLib.D3.API.ComponentInterface = function(
|
||||||
}
|
}
|
||||||
this.steeringSpeed = steeringSpeed;
|
this.steeringSpeed = steeringSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(frontLWheelIndex)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentOffset)) {
|
||||||
frontLWheelIndex = 1;
|
currentOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.frontLWheelIndex = frontLWheelIndex;
|
this.currentOffset = currentOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(frontRWheelIndex)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentPathValue)) {
|
||||||
frontRWheelIndex = 2;
|
currentPathValue = 0;
|
||||||
}
|
}
|
||||||
this.frontRWheelIndex = frontRWheelIndex;
|
this.currentPathValue = currentPathValue;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(backLWheelIndex)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentSpeed)) {
|
||||||
backLWheelIndex = 3;
|
currentSpeed = 0;
|
||||||
}
|
}
|
||||||
this.backLWheelIndex = backLWheelIndex;
|
this.currentSpeed = currentSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(backRWheelIndex)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(direction)) {
|
||||||
backRWheelIndex = 4;
|
direction = 1;
|
||||||
}
|
}
|
||||||
this.backRWheelIndex = backRWheelIndex;
|
this.direction = direction;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxForce)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentPosition)) {
|
||||||
maxForce = 400;
|
currentPosition = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.maxForce = maxForce;
|
this.currentPosition = currentPosition;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(steering)) {
|
|
||||||
steering = 0.5;
|
|
||||||
}
|
|
||||||
this.steering = steering;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(entitiesToCheck)) {
|
|
||||||
entitiesToCheck = [];
|
|
||||||
}
|
|
||||||
this.entitiesToCheck = entitiesToCheck;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(onInside)) {
|
|
||||||
onInside = null;
|
|
||||||
}
|
|
||||||
this.onInside = onInside;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(onEnter)) {
|
|
||||||
onEnter = null;
|
|
||||||
}
|
|
||||||
this.onEnter = onEnter;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(onLeave)) {
|
|
||||||
onLeave = null;
|
|
||||||
}
|
|
||||||
this.onLeave = onLeave;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(onSetParent)) {
|
|
||||||
onSetParent = null;
|
|
||||||
}
|
|
||||||
this.onSetParent = onSetParent;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(sphereRadius)) {
|
|
||||||
sphereRadius = 1.0;
|
|
||||||
}
|
|
||||||
this.sphereRadius = sphereRadius;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(world)) {
|
|
||||||
world = null;
|
|
||||||
}
|
|
||||||
this.world = world;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxSteerAngle)) {
|
|
||||||
maxSteerAngle = 0.5;
|
|
||||||
}
|
|
||||||
this.maxSteerAngle = maxSteerAngle;
|
|
||||||
|
|
||||||
};
|
};
|
|
@ -6,8 +6,8 @@
|
||||||
* @param position
|
* @param position
|
||||||
* @param quaternion
|
* @param quaternion
|
||||||
* @param scale
|
* @param scale
|
||||||
* @param parentScene
|
* @param parentScene GameLib.D3.Scene
|
||||||
* @param mesh
|
* @param mesh GameLib.D3.Mesh
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Entity = function Entity(
|
GameLib.D3.API.Entity = function Entity(
|
||||||
|
@ -41,7 +41,7 @@ GameLib.D3.API.Entity = function Entity(
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.API.Vector4();
|
quaternion = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ GameLib.D3.Entity = function Entity(
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
quaternion = new GameLib.D3.API.Quaternion(0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ GameLib.D3.API.Light = function(
|
||||||
this.targetPosition = targetPosition;
|
this.targetPosition = targetPosition;
|
||||||
|
|
||||||
if (typeof quaternion == 'undefined'){
|
if (typeof quaternion == 'undefined'){
|
||||||
quaternion = new GameLib.D3.API.Vector4();
|
quaternion = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* Api Matrix 4
|
* Api Matrix 4
|
||||||
* @param row0 GameLib.D3.API.Vector4
|
* @param row0 GameLib.D3.API.Quaternion
|
||||||
* @param row1 GameLib.D3.API.Vector4
|
* @param row1 GameLib.D3.API.Quaternion
|
||||||
* @param row2 GameLib.D3.API.Vector4
|
* @param row2 GameLib.D3.API.Quaternion
|
||||||
* @param row3 GameLib.D3.API.Vector4
|
* @param row3 GameLib.D3.API.Quaternion
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Matrix4 = function ApiMatrix4(
|
GameLib.D3.API.Matrix4 = function ApiMatrix4(
|
||||||
|
@ -15,42 +15,42 @@ GameLib.D3.API.Matrix4 = function ApiMatrix4(
|
||||||
this.rows = [];
|
this.rows = [];
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(row0)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(row0)) {
|
||||||
row0 = new GameLib.D3.API.Vector4(1, 0, 0, 0);
|
row0 = new GameLib.D3.API.Quaternion(1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
this.rows[0] = row0;
|
this.rows[0] = row0;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(row1)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(row1)) {
|
||||||
row1 = new GameLib.D3.API.Vector4(0, 1, 0, 0);
|
row1 = new GameLib.D3.API.Quaternion(0, 1, 0, 0);
|
||||||
}
|
}
|
||||||
this.rows[1] = row1;
|
this.rows[1] = row1;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(row2)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(row2)) {
|
||||||
row2 = new GameLib.D3.API.Vector4(0, 0, 1, 0);
|
row2 = new GameLib.D3.API.Quaternion(0, 0, 1, 0);
|
||||||
}
|
}
|
||||||
this.rows[2] = row2;
|
this.rows[2] = row2;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(row3)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(row3)) {
|
||||||
row3 = new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
row3 = new GameLib.D3.API.Quaternion(0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
this.rows[3] = row3;
|
this.rows[3] = row3;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Matrix4.prototype.rotationMatrixX = function (radians) {
|
GameLib.D3.API.Matrix4.prototype.rotationMatrixX = function (radians) {
|
||||||
this.identity();
|
this.identity();
|
||||||
this.rows[1] = new GameLib.D3.API.Vector4(0, Math.cos(radians), -1 * Math.sin(radians), 0);
|
this.rows[1] = new GameLib.D3.API.Quaternion(0, Math.cos(radians), -1 * Math.sin(radians), 0);
|
||||||
this.rows[2] = new GameLib.D3.API.Vector4(0, Math.sin(radians), Math.cos(radians), 0);
|
this.rows[2] = new GameLib.D3.API.Quaternion(0, Math.sin(radians), Math.cos(radians), 0);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Matrix4.prototype.rotationMatrixY = function (radians) {
|
GameLib.D3.API.Matrix4.prototype.rotationMatrixY = function (radians) {
|
||||||
this.identity();
|
this.identity();
|
||||||
this.rows[0] = new GameLib.D3.API.Vector4(
|
this.rows[0] = new GameLib.D3.API.Quaternion(
|
||||||
Math.cos(radians),
|
Math.cos(radians),
|
||||||
0,
|
0,
|
||||||
Math.sin(radians),
|
Math.sin(radians),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
this.rows[2] = new GameLib.D3.API.Vector4(
|
this.rows[2] = new GameLib.D3.API.Quaternion(
|
||||||
-1 * Math.sin(radians),
|
-1 * Math.sin(radians),
|
||||||
0,
|
0,
|
||||||
Math.cos(radians),
|
Math.cos(radians),
|
||||||
|
@ -61,8 +61,8 @@ GameLib.D3.API.Matrix4.prototype.rotationMatrixY = function (radians) {
|
||||||
|
|
||||||
GameLib.D3.API.Matrix4.prototype.rotationMatrixZ = function (radians) {
|
GameLib.D3.API.Matrix4.prototype.rotationMatrixZ = function (radians) {
|
||||||
this.identity();
|
this.identity();
|
||||||
this.rows[0] = new GameLib.D3.API.Vector4(Math.cos(radians), -1 * Math.sin(radians), 0, 0);
|
this.rows[0] = new GameLib.D3.API.Quaternion(Math.cos(radians), -1 * Math.sin(radians), 0, 0);
|
||||||
this.rows[1] = new GameLib.D3.API.Vector4(Math.sin(radians), Math.cos(radians), 0, 0);
|
this.rows[1] = new GameLib.D3.API.Quaternion(Math.sin(radians), Math.cos(radians), 0, 0);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ GameLib.D3.API.Matrix4.prototype.rotateZ = function (radians, point) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Matrix4.prototype.multiply = function (mvp) {
|
GameLib.D3.API.Matrix4.prototype.multiply = function (mvp) {
|
||||||
if (mvp instanceof GameLib.D3.API.Vector4) {
|
if (mvp instanceof GameLib.D3.API.Quaternion) {
|
||||||
return new GameLib.D3.API.Vector4(
|
return new GameLib.D3.API.Quaternion(
|
||||||
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w,
|
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w,
|
||||||
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w,
|
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w,
|
||||||
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w,
|
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w,
|
||||||
|
@ -103,10 +103,10 @@ GameLib.D3.API.Matrix4.prototype.multiply = function (mvp) {
|
||||||
|
|
||||||
GameLib.D3.API.Matrix4.prototype.identity = function () {
|
GameLib.D3.API.Matrix4.prototype.identity = function () {
|
||||||
this.rows = [
|
this.rows = [
|
||||||
new GameLib.D3.API.Vector4(1, 0, 0, 0),
|
new GameLib.D3.API.Quaternion(1, 0, 0, 0),
|
||||||
new GameLib.D3.API.Vector4(0, 1, 0, 0),
|
new GameLib.D3.API.Quaternion(0, 1, 0, 0),
|
||||||
new GameLib.D3.API.Vector4(0, 0, 1, 0),
|
new GameLib.D3.API.Quaternion(0, 0, 1, 0),
|
||||||
new GameLib.D3.API.Vector4(0, 0, 0, 1)
|
new GameLib.D3.API.Quaternion(0, 0, 0, 1)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
* @param skinIndices
|
* @param skinIndices
|
||||||
* @param skinWeights
|
* @param skinWeights
|
||||||
* @param position GameLib.D3.API.Vector3
|
* @param position GameLib.D3.API.Vector3
|
||||||
* @param quaternion GameLib.D3.API.Vector4
|
* @param quaternion GameLib.D3.API.Quaternion
|
||||||
* @param rotation GameLib.D3.API.Vector3
|
|
||||||
* @param scale GameLib.D3.API.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param up
|
* @param up
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -34,7 +33,6 @@ GameLib.D3.API.Mesh = function(
|
||||||
skinWeights,
|
skinWeights,
|
||||||
position,
|
position,
|
||||||
quaternion,
|
quaternion,
|
||||||
rotation,
|
|
||||||
scale,
|
scale,
|
||||||
up
|
up
|
||||||
) {
|
) {
|
||||||
|
@ -104,15 +102,10 @@ GameLib.D3.API.Mesh = function(
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.API.Vector4();
|
quaternion = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.D3.API.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
scale = new GameLib.D3.API.Vector3(1,1,1);
|
scale = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
GameLib.D3.API.Vector4 = function ApiVector4(x, y, z, w) {
|
GameLib.D3.API.Quaternion = function ApiQuaternion(x, y, z, w, axis, angle) {
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(x)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(x)) {
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -20,17 +20,26 @@ GameLib.D3.API.Vector4 = function ApiVector4(x, y, z, w) {
|
||||||
}
|
}
|
||||||
this.w = w;
|
this.w = w;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(axis)) {
|
||||||
|
axis = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
this.axis = axis;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(angle)) {
|
||||||
|
angle = 0;
|
||||||
|
}
|
||||||
|
this.angle = angle;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.prototype.translate = function (v) {
|
GameLib.D3.API.Quaternion.prototype.translate = function (v) {
|
||||||
this.x += v.x;
|
this.x += v.x;
|
||||||
this.y += v.y;
|
this.y += v.y;
|
||||||
this.z += v.z;
|
this.z += v.z;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.prototype.copy = function () {
|
GameLib.D3.API.Quaternion.prototype.copy = function () {
|
||||||
return new GameLib.D3.API.Vector4(
|
return new GameLib.D3.API.Quaternion(
|
||||||
this.x,
|
this.x,
|
||||||
this.y,
|
this.y,
|
||||||
this.z,
|
this.z,
|
||||||
|
@ -41,7 +50,7 @@ GameLib.D3.API.Vector4.prototype.copy = function () {
|
||||||
/**
|
/**
|
||||||
* Note, this normalize function leaves 'w' component untouched
|
* Note, this normalize function leaves 'w' component untouched
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Vector4.prototype.normalize = function () {
|
GameLib.D3.API.Quaternion.prototype.normalize = function () {
|
||||||
|
|
||||||
var EPSILON = 0.000001;
|
var EPSILON = 0.000001;
|
||||||
|
|
||||||
|
@ -58,7 +67,7 @@ GameLib.D3.API.Vector4.prototype.normalize = function () {
|
||||||
this.z *= invLength;
|
this.z *= invLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.prototype.multiply = function (s) {
|
GameLib.D3.API.Quaternion.prototype.multiply = function (s) {
|
||||||
if (s instanceof GameLib.D3.API.Vector3) {
|
if (s instanceof GameLib.D3.API.Vector3) {
|
||||||
this.x *= s.x;
|
this.x *= s.x;
|
||||||
this.y *= s.y;
|
this.y *= s.y;
|
||||||
|
@ -78,7 +87,19 @@ GameLib.D3.API.Vector4.prototype.multiply = function (s) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.prototype.subtract = function (v) {
|
GameLib.D3.API.Quaternion.prototype.setFromAngle = function (angle) {
|
||||||
|
|
||||||
|
this.instance.setFromAxisAngle(this.axis.instance, angle);
|
||||||
|
|
||||||
|
this.x = this.instance.x;
|
||||||
|
this.y = this.instance.y;
|
||||||
|
this.z = this.instance.z;
|
||||||
|
this.w = this.instance.w;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Quaternion.prototype.subtract = function (v) {
|
||||||
|
|
||||||
if (v instanceof GameLib.D3.API.Vector3) {
|
if (v instanceof GameLib.D3.API.Vector3) {
|
||||||
this.x -= v.x;
|
this.x -= v.x;
|
||||||
|
@ -86,7 +107,7 @@ GameLib.D3.API.Vector4.prototype.subtract = function (v) {
|
||||||
this.z -= v.z;
|
this.z -= v.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v instanceof GameLib.D3.API.Vector4) {
|
if (v instanceof GameLib.D3.API.Quaternion) {
|
||||||
this.x -= v.x;
|
this.x -= v.x;
|
||||||
this.y -= v.y;
|
this.y -= v.y;
|
||||||
this.z -= v.z;
|
this.z -= v.z;
|
|
@ -1,11 +1,11 @@
|
||||||
GameLib.D3.API.Vector4.Points = function () {
|
GameLib.D3.API.Quaternion.Points = function () {
|
||||||
this.vectors = [];
|
this.vectors = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.add = function (vector) {
|
GameLib.D3.API.Quaternion.Points.prototype.add = function (vector) {
|
||||||
|
|
||||||
if (vector instanceof GameLib.D3.API.Vector3) {
|
if (vector instanceof GameLib.D3.API.Vector3) {
|
||||||
vector = new GameLib.D3.API.Vector4(
|
vector = new GameLib.D3.API.Quaternion(
|
||||||
vector.x,
|
vector.x,
|
||||||
vector.y,
|
vector.y,
|
||||||
vector.z,
|
vector.z,
|
||||||
|
@ -13,9 +13,9 @@ GameLib.D3.API.Vector4.Points.prototype.add = function (vector) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vector instanceof GameLib.D3.API.Vector4) {
|
if (!vector instanceof GameLib.D3.API.Quaternion) {
|
||||||
console.warn("Vector needs to be of type Vector4");
|
console.warn("Vector needs to be of type Quaternion");
|
||||||
throw new Error("Vector needs to be of type Vector4");
|
throw new Error("Vector needs to be of type Quaternion");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.vectors.push(vector);
|
this.vectors.push(vector);
|
||||||
|
@ -23,7 +23,7 @@ GameLib.D3.API.Vector4.Points.prototype.add = function (vector) {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.copy = function () {
|
GameLib.D3.API.Quaternion.Points.prototype.copy = function () {
|
||||||
|
|
||||||
var vectors = [];
|
var vectors = [];
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ GameLib.D3.API.Vector4.Points.prototype.copy = function () {
|
||||||
return vectors;
|
return vectors;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.maximizeXDistance = function (grain) {
|
GameLib.D3.API.Quaternion.Points.prototype.maximizeXDistance = function (grain) {
|
||||||
|
|
||||||
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ GameLib.D3.API.Vector4.Points.prototype.maximizeXDistance = function (grain) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.maximizeYDistance = function (grain) {
|
GameLib.D3.API.Quaternion.Points.prototype.maximizeYDistance = function (grain) {
|
||||||
|
|
||||||
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ GameLib.D3.API.Vector4.Points.prototype.maximizeYDistance = function (grain) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.lookAt = function (at, up) {
|
GameLib.D3.API.Quaternion.Points.prototype.lookAt = function (at, up) {
|
||||||
|
|
||||||
var polyCenter = this.average();
|
var polyCenter = this.average();
|
||||||
|
|
||||||
|
@ -132,9 +132,9 @@ GameLib.D3.API.Vector4.Points.prototype.lookAt = function (at, up) {
|
||||||
|
|
||||||
var lookAtMatrix = new GameLib.D3.API.Matrix4().lookAt(polyCenter, at, up);
|
var lookAtMatrix = new GameLib.D3.API.Matrix4().lookAt(polyCenter, at, up);
|
||||||
|
|
||||||
lookAtMatrix.rows[0] = new GameLib.D3.API.Vector4(1, 0, 0, 0);
|
lookAtMatrix.rows[0] = new GameLib.D3.API.Quaternion(1, 0, 0, 0);
|
||||||
lookAtMatrix.rows[1] = new GameLib.D3.API.Vector4(0, 0, 1, 0);
|
lookAtMatrix.rows[1] = new GameLib.D3.API.Quaternion(0, 0, 1, 0);
|
||||||
lookAtMatrix.rows[2] = new GameLib.D3.API.Vector4(0, 1, 0, 0);
|
lookAtMatrix.rows[2] = new GameLib.D3.API.Quaternion(0, 1, 0, 0);
|
||||||
|
|
||||||
console.log("look at matrix : " + JSON.stringify(lookAtMatrix, null, 2));
|
console.log("look at matrix : " + JSON.stringify(lookAtMatrix, null, 2));
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ GameLib.D3.API.Vector4.Points.prototype.lookAt = function (at, up) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.distances = function () {
|
GameLib.D3.API.Quaternion.Points.prototype.distances = function () {
|
||||||
|
|
||||||
var minX = this.vectors[0].x;
|
var minX = this.vectors[0].x;
|
||||||
var minY = this.vectors[0].y;
|
var minY = this.vectors[0].y;
|
||||||
|
@ -184,7 +184,7 @@ GameLib.D3.API.Vector4.Points.prototype.distances = function () {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.average = function () {
|
GameLib.D3.API.Quaternion.Points.prototype.average = function () {
|
||||||
var averageX = 0;
|
var averageX = 0;
|
||||||
var averageY = 0;
|
var averageY = 0;
|
||||||
var averageZ = 0;
|
var averageZ = 0;
|
||||||
|
@ -202,7 +202,7 @@ GameLib.D3.API.Vector4.Points.prototype.average = function () {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.negate = function () {
|
GameLib.D3.API.Quaternion.Points.prototype.negate = function () {
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
this.vectors[i].x *= -1;
|
this.vectors[i].x *= -1;
|
||||||
|
@ -214,7 +214,7 @@ GameLib.D3.API.Vector4.Points.prototype.negate = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.API.Vector4.Points.prototype.toOrigin = function () {
|
GameLib.D3.API.Quaternion.Points.prototype.toOrigin = function () {
|
||||||
|
|
||||||
var distanceFromOrigin = this.average().negate();
|
var distanceFromOrigin = this.average().negate();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @param path String
|
* @param path String
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param meshes GameLib.D3.API.Mesh []
|
* @param meshes GameLib.D3.API.Mesh []
|
||||||
* @param quaternion GameLib.D3.API.Vector4
|
* @param quaternion GameLib.D3.API.Quaternion
|
||||||
* @param position GameLib.D3.API.Vector3
|
* @param position GameLib.D3.API.Vector3
|
||||||
* @param rotation GameLib.D3.API.Vector3
|
* @param rotation GameLib.D3.API.Vector3
|
||||||
* @param scale GameLib.D3.API.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
|
@ -26,7 +26,6 @@ GameLib.D3.API.Scene = function(
|
||||||
meshes,
|
meshes,
|
||||||
quaternion,
|
quaternion,
|
||||||
position,
|
position,
|
||||||
rotation,
|
|
||||||
scale,
|
scale,
|
||||||
parentSceneId,
|
parentSceneId,
|
||||||
lights,
|
lights,
|
||||||
|
@ -59,7 +58,7 @@ GameLib.D3.API.Scene = function(
|
||||||
this.meshes = meshes;
|
this.meshes = meshes;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.API.Vector4();
|
quaternion = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
@ -68,11 +67,6 @@ GameLib.D3.API.Scene = function(
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.D3.API.Vector3();
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
scale = new GameLib.D3.API.Vector3(1,1,1);
|
scale = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,10 @@ GameLib.D3.Broadphase.prototype.createInstance = function() {
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Broadphase.prototype.toApiBroadphase = function() {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadphase Types
|
* Broadphase Types
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -24,7 +24,7 @@ GameLib.D3.Camera = function Camera(
|
||||||
this.position
|
this.position
|
||||||
);
|
);
|
||||||
|
|
||||||
this.quaternion = new GameLib.D3.Vector4(
|
this.quaternion = new GameLib.D3.Quaternion(
|
||||||
graphics,
|
graphics,
|
||||||
this,
|
this,
|
||||||
this.quaternion
|
this.quaternion
|
||||||
|
@ -115,4 +115,85 @@ GameLib.D3.Camera.prototype.createInstance = function(update) {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.prototype.updateInstance = function() {
|
GameLib.D3.Camera.prototype.updateInstance = function() {
|
||||||
this.instance = this.createInstance(true);
|
this.instance = this.createInstance(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Camera to a new GameLib.D3.API.Camera
|
||||||
|
* @returns {GameLib.D3.API.Camera}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Camera.prototype.toApiCamera = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Camera(
|
||||||
|
this.id,
|
||||||
|
this.cameraType,
|
||||||
|
this.name,
|
||||||
|
this.fov,
|
||||||
|
this.aspect,
|
||||||
|
this.near,
|
||||||
|
this.far,
|
||||||
|
this.position.toApiVector(),
|
||||||
|
this.lookAt.toApiVector(),
|
||||||
|
this.minX,
|
||||||
|
this.maxX,
|
||||||
|
this.minY,
|
||||||
|
this.maxY,
|
||||||
|
this.minZ,
|
||||||
|
this.maxZ,
|
||||||
|
this.quaternion.toApiQuaternion()
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from an Object camera to a GameLib.D3.Camera
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectCamera Object
|
||||||
|
* @returns {GameLib.D3.Camera}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Camera.FromObjectCamera = function(graphics, objectCamera) {
|
||||||
|
|
||||||
|
var apiCamera = new GameLib.D3.API.Camera(
|
||||||
|
objectCamera.id,
|
||||||
|
objectCamera.cameraType,
|
||||||
|
objectCamera.name,
|
||||||
|
objectCamera.fov,
|
||||||
|
objectCamera.aspect,
|
||||||
|
objectCamera.near,
|
||||||
|
objectCamera.far,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectCamera.position.x,
|
||||||
|
objectCamera.position.y,
|
||||||
|
objectCamera.position.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectCamera.lookAt.x,
|
||||||
|
objectCamera.lookAt.y,
|
||||||
|
objectCamera.lookAt.z
|
||||||
|
),
|
||||||
|
objectCamera.minX,
|
||||||
|
objectCamera.maxX,
|
||||||
|
objectCamera.minY,
|
||||||
|
objectCamera.maxY,
|
||||||
|
objectCamera.minZ,
|
||||||
|
objectCamera.maxZ,
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectCamera.quaternion.x,
|
||||||
|
objectCamera.quaternion.y,
|
||||||
|
objectCamera.quaternion.z,
|
||||||
|
objectCamera.quaternion.w,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectCamera.quaternion.axis.x,
|
||||||
|
objectCamera.quaternion.axis.y,
|
||||||
|
objectCamera.quaternion.axis.z
|
||||||
|
),
|
||||||
|
objectCamera.quaternion.angle
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GameLib.D3.Camera(
|
||||||
|
graphics,
|
||||||
|
apiCamera
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ GameLib.D3.ComponentEntityPermutation = function ComponentEntityPermutation(
|
||||||
|
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
||||||
quaternionOffset = new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
quaternionOffset = new GameLib.D3.API.Quaternion(0, 0, 0, 1);
|
||||||
} this.quaternionOffset = quaternionOffset;
|
} this.quaternionOffset = quaternionOffset;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
* @param minDistance
|
* @param minDistance
|
||||||
* @param moveSpeed
|
* @param moveSpeed
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @param target GameLib.D3.Vector3
|
* @param target GameLib.D3.API.Vector3
|
||||||
* @param targetToParent GameLib.D3.Vector3
|
* @param targetToParent GameLib.D3.API.Vector3
|
||||||
* @param rotatedTargetOffset GameLib.D3.Vector3
|
* @param rotatedTargetOffset GameLib.D3.API.Vector3
|
||||||
* @param rotated GameLib.D3.Vector4
|
* @param rotated GameLib.D3.API.Quaternion
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.ComponentFollow = function ComponentFollow(
|
GameLib.D3.ComponentFollow = function ComponentFollow(
|
||||||
|
@ -52,12 +52,14 @@ GameLib.D3.ComponentFollow = function ComponentFollow(
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
targetOffset = new GameLib.D3.Vector3(
|
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
targetOffset = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
targetOffset
|
||||||
|
);
|
||||||
|
|
||||||
this.targetOffset = targetOffset;
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(moveSpeed)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(moveSpeed)) {
|
||||||
|
@ -70,40 +72,49 @@ GameLib.D3.ComponentFollow = function ComponentFollow(
|
||||||
}
|
}
|
||||||
this.minDistance = minDistance;
|
this.minDistance = minDistance;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(target)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(target)) {
|
||||||
target = new GameLib.D3.Vector3(
|
target = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
target = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
target
|
||||||
|
);
|
||||||
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(targetToParent)) {
|
|
||||||
targetToParent = new GameLib.D3.Vector3(
|
if(GameLib.D3.Utils.UndefinedOrNull(targetToParent)) {
|
||||||
this.graphics,
|
targetToParent = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
targetToParent = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
targetToParent
|
||||||
|
);
|
||||||
|
|
||||||
this.targetToParent = targetToParent;
|
this.targetToParent = targetToParent;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotatedTargetOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(rotatedTargetOffset)) {
|
||||||
rotatedTargetOffset = new GameLib.D3.Vector3(
|
rotatedTargetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
rotatedTargetOffset = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
rotatedTargetOffset
|
||||||
|
);
|
||||||
|
|
||||||
this.rotatedTargetOffset = rotatedTargetOffset;
|
this.rotatedTargetOffset = rotatedTargetOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotated)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotated)) {
|
||||||
rotated = new GameLib.D3.Vector3(
|
rotated = new GameLib.D3.API.Quaternion();
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
rotated = new GameLib.D3.Quaternion(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
rotated
|
||||||
|
);
|
||||||
|
|
||||||
this.rotated = rotated;
|
this.rotated = rotated;
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentFollow, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentFollow, GameLib.D3.ComponentInterface);
|
||||||
|
|
|
@ -37,7 +37,321 @@ GameLib.D3.ComponentInterface.COMPONENT_TRIGGER_SPHERE_SPHERE = 0xF;
|
||||||
GameLib.D3.ComponentInterface.COMPONENT_VEHICLE_AI_OBJECT_AVOIDENCE = 0x10;
|
GameLib.D3.ComponentInterface.COMPONENT_VEHICLE_AI_OBJECT_AVOIDENCE = 0x10;
|
||||||
GameLib.D3.ComponentInterface.COMPONENT_VEHICLE_AI_PATH_STEERING = 0x11;
|
GameLib.D3.ComponentInterface.COMPONENT_VEHICLE_AI_PATH_STEERING = 0x11;
|
||||||
|
|
||||||
|
GameLib.D3.ComponentInterface.prototype.toApiComponent = function() {
|
||||||
|
|
||||||
|
var apiComponent = null;
|
||||||
|
|
||||||
|
if (this instanceof GameLib.D3.ComponentCamera) {
|
||||||
|
|
||||||
|
apiComponent = new GameLib.D3.API.ComponentInterface(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
GameLib.D3.ComponentInterface.COMPONENT_CAMERA,
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.camera),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.parentEntity)
|
||||||
|
);
|
||||||
|
|
||||||
|
} else if (this instanceof GameLib.D3.ComponentFollow) {
|
||||||
|
|
||||||
|
apiComponent = new GameLib.D3.API.ComponentInterface(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
GameLib.D3.ComponentInterface.COMPONENT_FOLLOW,
|
||||||
|
null,
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.parentEntity),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.targetEntity),
|
||||||
|
this.targetOffset.toApiVector(),
|
||||||
|
this.minDistance,
|
||||||
|
this.moveSpeed,
|
||||||
|
this.target.toApiVector(),
|
||||||
|
this.targetToParent.toApiVector(),
|
||||||
|
this.rotatedTargetOffset.toApiVector(),
|
||||||
|
this.rotated.toApiQuaternion()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else if (this instanceof GameLib.D3.ComponentLookAt) {
|
||||||
|
|
||||||
|
apiComponent = new GameLib.D3.API.ComponentInterface(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
GameLib.D3.ComponentInterface.COMPONENT_LOOK_AT,
|
||||||
|
null,
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.parentEntity),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.targetEntity),
|
||||||
|
this.targetOffset.toApiVector(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
this.rotationSpeed,
|
||||||
|
this.lookAtMatrix.toApiMatrix(),
|
||||||
|
this.up.toApiVector()
|
||||||
|
)
|
||||||
|
} else if (this instanceof GameLib.D3.ComponentPathFollowing) {
|
||||||
|
|
||||||
|
apiComponent = new GameLib.D3.API.ComponentInterface(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
GameLib.D3.ComponentInterface.COMPONENT_PATH_FOLLOWING,
|
||||||
|
null,
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.parentEntity),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.targetEntity),
|
||||||
|
this.targetOffset.toApiVector(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
this.up.toApiVector(),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.spline),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.mesh),
|
||||||
|
this.accelleration,
|
||||||
|
this.maxSpeed,
|
||||||
|
this.baseOffset.toApiVector(),
|
||||||
|
this.maxOffset.toApiVector(),
|
||||||
|
this.steeringSpeed,
|
||||||
|
this.currentOffset.toApiVector(),
|
||||||
|
this.currentPathValue,
|
||||||
|
this.currentSpeed,
|
||||||
|
this.direction,
|
||||||
|
this.currentPosition.toApiVector()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.warn('cannot save components of this type yet: ' + this.componentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiComponent;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts and Object component into a proper GameLib.D3.Component
|
||||||
|
* @param graphics
|
||||||
|
* @param objectComponent
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.ComponentInterface.FromObjectComponent = function(graphics, objectComponent) {
|
||||||
|
|
||||||
|
var component = null;
|
||||||
|
|
||||||
|
switch (objectComponent.componentType) {
|
||||||
|
|
||||||
|
case GameLib.D3.ComponentInterface.COMPONENT_CAMERA :
|
||||||
|
component = new GameLib.D3.ComponentCamera(
|
||||||
|
objectComponent.id,
|
||||||
|
objectComponent.name,
|
||||||
|
objectComponent.camera,
|
||||||
|
objectComponent.parentEntity
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameLib.D3.ComponentInterface.COMPONENT_FOLLOW :
|
||||||
|
component = new GameLib.D3.ComponentFollow(
|
||||||
|
objectComponent.id,
|
||||||
|
objectComponent.name,
|
||||||
|
graphics,
|
||||||
|
objectComponent.targetEntity,
|
||||||
|
new GameLib.D3.API.Vector3 (
|
||||||
|
objectComponent.targetOffset.x,
|
||||||
|
objectComponent.targetOffset.y,
|
||||||
|
objectComponent.targetOffset.z
|
||||||
|
),
|
||||||
|
objectComponent.minDistance,
|
||||||
|
objectComponent.moveSpeed,
|
||||||
|
objectComponent.parentEntity,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.target.x,
|
||||||
|
objectComponent.target.y,
|
||||||
|
objectComponent.target.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.targetToParent.x,
|
||||||
|
objectComponent.targetToParent.y,
|
||||||
|
objectComponent.targetToParent.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.rotatedTargetOffset.x,
|
||||||
|
objectComponent.rotatedTargetOffset.y,
|
||||||
|
objectComponent.rotatedTargetOffset.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectComponent.rotated.x,
|
||||||
|
objectComponent.rotated.x,
|
||||||
|
objectComponent.rotated.x,
|
||||||
|
objectComponent.rotated.x,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.rotated.axis.x,
|
||||||
|
objectComponent.rotated.axis.y,
|
||||||
|
objectComponent.rotated.axis.z
|
||||||
|
),
|
||||||
|
objectComponent.rotated.angle
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameLib.D3.ComponentInterface.COMPONENT_LOOK_AT :
|
||||||
|
component = new GameLib.D3.ComponentLookAt(
|
||||||
|
objectComponent.id,
|
||||||
|
objectComponent.name,
|
||||||
|
graphics,
|
||||||
|
objectComponent.parentEntity,
|
||||||
|
objectComponent.targetEntity,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.targetOffset.x,
|
||||||
|
objectComponent.targetOffset.y,
|
||||||
|
objectComponent.targetOffset.z
|
||||||
|
),
|
||||||
|
objectComponent.rotationSpeed,
|
||||||
|
objectComponent.lookAtMatrix,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.up.x,
|
||||||
|
objectComponent.up.y,
|
||||||
|
objectComponent.up.z
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameLib.D3.ComponentInterface.COMPONENT_PATH_FOLLOWING :
|
||||||
|
component = new GameLib.D3.ComponentPathFollowing(
|
||||||
|
objectComponent.id,
|
||||||
|
objectComponent.name,
|
||||||
|
graphics,
|
||||||
|
objectComponent.parentEntity,
|
||||||
|
objectComponent.spline,
|
||||||
|
objectComponent.mesh,
|
||||||
|
objectComponent.accelleration,
|
||||||
|
objectComponent.maxSpeed,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.baseOffset.x,
|
||||||
|
objectComponent.baseOffset.y,
|
||||||
|
objectComponent.baseOffset.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.maxOffset.x,
|
||||||
|
objectComponent.maxOffset.y,
|
||||||
|
objectComponent.maxOffset.z
|
||||||
|
),
|
||||||
|
objectComponent.steeringSpeed,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.targetOffset.x,
|
||||||
|
objectComponent.targetOffset.y,
|
||||||
|
objectComponent.targetOffset.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.currentOffset.x,
|
||||||
|
objectComponent.currentOffset.y,
|
||||||
|
objectComponent.currentOffset.z
|
||||||
|
),
|
||||||
|
objectComponent.currentPathValue,
|
||||||
|
objectComponent.currentSpeed,
|
||||||
|
objectComponent.direction,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectComponent.up.x,
|
||||||
|
objectComponent.up.y,
|
||||||
|
objectComponent.up.z
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.warn('This type of component is not yet read from the database:' + objectComponent.componentType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return component;
|
||||||
|
//
|
||||||
|
// var apiComponent = new GameLib.D3.API.ComponentInterface(
|
||||||
|
// objectComponent.id,
|
||||||
|
// objectComponent.name,
|
||||||
|
// objectComponent.componentType,
|
||||||
|
// objectComponent.camera,
|
||||||
|
// new GameLib.D3.API.Color(
|
||||||
|
// objectComponent.startColor.r,
|
||||||
|
// objectComponent.startColor.g,
|
||||||
|
// objectComponent.startColor.b,
|
||||||
|
// objectComponent.startColor.a
|
||||||
|
// ),
|
||||||
|
// new GameLib.D3.API.Color(
|
||||||
|
// objectComponent.endColor.r,
|
||||||
|
// objectComponent.endColor.g,
|
||||||
|
// objectComponent.endColor.b,
|
||||||
|
// objectComponent.endColor.a
|
||||||
|
// ),
|
||||||
|
// objectComponent.lerpSpeed,
|
||||||
|
// objectComponent.targetEntity,
|
||||||
|
// new GameLib.D3.API.Vector3(
|
||||||
|
// objectComponent.targetOffset.x,
|
||||||
|
// objectComponent.targetOffset.y,
|
||||||
|
// objectComponent.targetOffset.z
|
||||||
|
// ),
|
||||||
|
// objectComponent.minDistance,
|
||||||
|
// objectComponent.moveSpeed,
|
||||||
|
// objectComponent.rotationSpeed,
|
||||||
|
// new GameLib.D3.API.Vector3(
|
||||||
|
// objectComponent.positionOffset.x,
|
||||||
|
// objectComponent.positionOffset.y,
|
||||||
|
// objectComponent.positionOffset.z
|
||||||
|
// ),
|
||||||
|
// new GameLib.D3.API.Vector3(
|
||||||
|
// objectComponent.quaternionOffset.x,
|
||||||
|
// objectComponent.quaternionOffset.y,
|
||||||
|
// objectComponent.quaternionOffset.z
|
||||||
|
// ),
|
||||||
|
// new GameLib.D3.API.Vector3(
|
||||||
|
// objectComponent.scaleOffset.x,
|
||||||
|
// objectComponent.scaleOffset.y,
|
||||||
|
// objectComponent.scaleOffset.z
|
||||||
|
// ),
|
||||||
|
// objectComponent.sensorLength,
|
||||||
|
// objectComponent.spline,
|
||||||
|
// objectComponent.accelleration,
|
||||||
|
// objectComponent.maxSpeed,
|
||||||
|
// new GameLib.D3.API.Vector3(
|
||||||
|
// objectComponent.baseOffset.x,
|
||||||
|
// objectComponent.baseOffset.y,
|
||||||
|
// objectComponent.baseOffset.z
|
||||||
|
// ),
|
||||||
|
// new GameLib.D3.API.Vector3(
|
||||||
|
// objectComponent.maxOffset.x,
|
||||||
|
// objectComponent.maxOffset.y,
|
||||||
|
// objectComponent.maxOffset.z
|
||||||
|
// ),
|
||||||
|
// objectComponent.steeringSpeed,
|
||||||
|
// objectComponent.frontLWheelIndex,
|
||||||
|
// objectComponent.frontRWheelIndex,
|
||||||
|
// objectComponent.backLWheelIndex,
|
||||||
|
// objectComponent.backRWheelIndex,
|
||||||
|
// objectComponent.maxForce,
|
||||||
|
// objectComponent.steering,
|
||||||
|
// objectComponent.entitiesToCheck.map(function(objectEntity){
|
||||||
|
// return GameLib.D3.Entity.FromObjectEntity(graphics, objectEntity);
|
||||||
|
// }),
|
||||||
|
// objectComponent.onInside,
|
||||||
|
// objectComponent.onEnter,
|
||||||
|
// objectComponent.onLeave,
|
||||||
|
// objectComponent.onSetParent,
|
||||||
|
// objectComponent.sphereRadius,
|
||||||
|
// GameLib.D3.World.FromObjectWorld(objectComponent.world),
|
||||||
|
// objectComponent.maxSteerAngle
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// var component = null;
|
||||||
|
//
|
||||||
|
// switch (apiComponent.componentType) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
// will be not used
|
// will be not used
|
||||||
GameLib.D3.ComponentInterface.prototype.setParentEntity = function(
|
GameLib.D3.ComponentInterface.prototype.setParentEntity = function(
|
||||||
|
@ -101,4 +415,24 @@ GameLib.D3.ComponentInterface.prototype.onSetParentEntity = function(
|
||||||
|
|
||||||
GameLib.D3.ComponentInterface.prototype.clone = function() {
|
GameLib.D3.ComponentInterface.prototype.clone = function() {
|
||||||
return _.cloneDeep(this);
|
return _.cloneDeep(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* links component ids to actual objects
|
||||||
|
* @param idToObject Object linking object ids to objects
|
||||||
|
*/
|
||||||
|
GameLib.D3.ComponentInterface.prototype.linkObjects = function(idToObject) {
|
||||||
|
/**
|
||||||
|
* @param camera GameLib.D3.Camera
|
||||||
|
* @param parentEntity GameLib.D3.Entity
|
||||||
|
* @param targetEntity GameLib.D3.Entity
|
||||||
|
* @param spline GameLib.D3.Spline
|
||||||
|
* @param mesh GameLib.D3.Mesh
|
||||||
|
*/
|
||||||
|
|
||||||
|
GameLib.D3.Utils.Link('camera', idToObject, this, this.camera);
|
||||||
|
GameLib.D3.Utils.Link('parentEntity', idToObject, this, this.parentEntity);
|
||||||
|
GameLib.D3.Utils.Link('targetEntity', idToObject, this, this.targetEntity);
|
||||||
|
GameLib.D3.Utils.Link('spline', idToObject, this, this.spline);
|
||||||
|
GameLib.D3.Utils.Link('mesh', idToObject, this, this.mesh);
|
||||||
};
|
};
|
|
@ -5,9 +5,9 @@
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentEntity GameLib.D3.Entity
|
* @param parentEntity GameLib.D3.Entity
|
||||||
* @param targetEntity GameLib.D3.Entity
|
* @param targetEntity GameLib.D3.Entity
|
||||||
* @param targetOffset GameLib.D3.Vector3
|
* @param targetOffset GameLib.D3.API.Vector3
|
||||||
* @param rotationSpeed
|
* @param rotationSpeed
|
||||||
* @param lookAtMatrix GameLib.D3.Matrix4
|
* @param lookAtMatrix GameLib.D3.API.Matrix4
|
||||||
* @param up GameLib.D3.Vector3
|
* @param up GameLib.D3.Vector3
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -46,12 +46,13 @@ GameLib.D3.ComponentLookAt = function ComponentLookAt(
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
targetOffset = new GameLib.D3.Vector3(
|
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
targetOffset = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
targetOffset
|
||||||
|
);
|
||||||
this.targetOffset = targetOffset;
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotationSpeed)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotationSpeed)) {
|
||||||
|
@ -60,21 +61,23 @@ GameLib.D3.ComponentLookAt = function ComponentLookAt(
|
||||||
this.rotationSpeed = rotationSpeed;
|
this.rotationSpeed = rotationSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lookAtMatrix)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(lookAtMatrix)) {
|
||||||
lookAtMatrix = new GameLib.D3.Matrix4(
|
lookAtMatrix = new GameLib.D3.API.Matrix4();
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Matrix4()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
lookAtMatrix = new GameLib.D3.Matrix4(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
lookAtMatrix
|
||||||
|
);
|
||||||
this.lookAtMatrix = lookAtMatrix;
|
this.lookAtMatrix = lookAtMatrix;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(up)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(up)) {
|
||||||
up = new GameLib.D3.Vector3(
|
up = new GameLib.D3.API.Vector3(0, 1, 0);
|
||||||
this.graphics,
|
|
||||||
this,
|
|
||||||
new GameLib.D3.API.Vector3(0, 1, 0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
up = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
up
|
||||||
|
);
|
||||||
this.up = up;
|
this.up = up;
|
||||||
|
|
||||||
this.targetPosition = new GameLib.D3.Vector3(
|
this.targetPosition = new GameLib.D3.Vector3(
|
||||||
|
@ -83,10 +86,10 @@ GameLib.D3.ComponentLookAt = function ComponentLookAt(
|
||||||
new GameLib.D3.API.Vector3(0, 0, 0)
|
new GameLib.D3.API.Vector3(0, 0, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.currentRotation = new GameLib.D3.Vector4(
|
this.currentRotation = new GameLib.D3.Quaternion(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this,
|
this,
|
||||||
new GameLib.D3.API.Vector4()
|
new GameLib.D3.API.Quaternion()
|
||||||
);
|
);
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentLookAt, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentLookAt, GameLib.D3.ComponentInterface);
|
||||||
|
|
|
@ -24,7 +24,7 @@ GameLib.D3.ComponentMeshPermutation = function ComponentMeshPermutation(
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
this.positionOffset = positionOffset || new GameLib.D3.API.Vector3(0, 0, 0);
|
this.positionOffset = positionOffset || new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.quaternionOffset = quaternionOffset || new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
this.quaternionOffset = quaternionOffset || new GameLib.D3.API.Quaternion(0, 0, 0, 1);
|
||||||
this.scaleOffset = scaleOffset || new GameLib.D3.API.Vector3(1, 1, 1);
|
this.scaleOffset = scaleOffset || new GameLib.D3.API.Vector3(1, 1, 1);
|
||||||
|
|
||||||
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* @param baseOffset GameLib.D3.Vector
|
* @param baseOffset GameLib.D3.Vector
|
||||||
* @param maxOffset GameLib.D3.Vector
|
* @param maxOffset GameLib.D3.Vector
|
||||||
* @param steeringSpeed Number
|
* @param steeringSpeed Number
|
||||||
* @param offset GameLib.D3.Vector3
|
* @param targetOffset GameLib.D3.Vector3
|
||||||
* @param currentOffset GameLib.D3.Vector3
|
* @param currentOffset GameLib.D3.Vector3
|
||||||
* @param currentPathValue Number
|
* @param currentPathValue Number
|
||||||
* @param currentSpeed Number
|
* @param currentSpeed Number
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
* @param futurePosition GameLib.D3.Vector3
|
* @param futurePosition GameLib.D3.Vector3
|
||||||
* @param up GameLib.D3.Vector3
|
* @param up GameLib.D3.Vector3
|
||||||
* @param rotationMatrix GameLib.D3.Matrix4
|
* @param rotationMatrix GameLib.D3.Matrix4
|
||||||
* @param rotationVector GameLib.D3.Vector4
|
* @param rotationVector GameLib.D3.Quaternion
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
|
@ -39,7 +39,7 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
baseOffset,
|
baseOffset,
|
||||||
maxOffset,
|
maxOffset,
|
||||||
steeringSpeed,
|
steeringSpeed,
|
||||||
offset,
|
targetOffset,
|
||||||
currentOffset,
|
currentOffset,
|
||||||
currentPathValue,
|
currentPathValue,
|
||||||
currentSpeed,
|
currentSpeed,
|
||||||
|
@ -64,6 +64,9 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(parentEntity)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
parentEntity = null;
|
parentEntity = null;
|
||||||
}
|
}
|
||||||
|
@ -90,13 +93,23 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
this.accelleration = accelleration;
|
this.accelleration = accelleration;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(baseOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(baseOffset)) {
|
||||||
baseOffset = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(), 0.1);
|
baseOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
|
baseOffset = new GameLib.D3.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
baseOffset
|
||||||
|
);
|
||||||
this.baseOffset = baseOffset;
|
this.baseOffset = baseOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(maxOffset)) {
|
||||||
maxOffset = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(10, 10, 10), 0.1);
|
maxOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
|
maxOffset = new GameLib.D3.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
maxOffset
|
||||||
|
);
|
||||||
this.maxOffset = maxOffset;
|
this.maxOffset = maxOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(steeringSpeed)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(steeringSpeed)) {
|
||||||
|
@ -104,14 +117,24 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
}
|
}
|
||||||
this.steeringSpeed = steeringSpeed;
|
this.steeringSpeed = steeringSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(offset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
offset = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(), 0.1);
|
targetOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.offset = offset;
|
targetOffset = new GameLib.D3.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
targetOffset
|
||||||
|
);
|
||||||
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(currentOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentOffset)) {
|
||||||
currentOffset = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(), 0.1);
|
currentOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
|
currentOffset = new GameLib.D3.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
currentOffset
|
||||||
|
);
|
||||||
this.currentOffset = currentOffset;
|
this.currentOffset = currentOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(currentPathValue)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentPathValue)) {
|
||||||
|
@ -162,18 +185,33 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
this.raycaster = raycaster;
|
this.raycaster = raycaster;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(currentPosition)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(currentPosition)) {
|
||||||
currentPosition = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(), 0.1);
|
currentPosition = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
|
currentPosition = new GameLib.D3.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
currentPosition
|
||||||
|
);
|
||||||
this.currentPosition = currentPosition;
|
this.currentPosition = currentPosition;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(futurePosition)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(futurePosition)) {
|
||||||
futurePosition = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(), 0.1);
|
futurePosition = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
|
futurePosition = new GameLib.D3.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
futurePosition
|
||||||
|
);
|
||||||
this.futurePosition = futurePosition;
|
this.futurePosition = futurePosition;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(up)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(up)) {
|
||||||
up = new GameLib.D3.Vector3(graphics, this, new GameLib.D3.API.Vector3(0, 1, 0), 0.1);
|
up = new GameLib.D3.API.Vector3(0, 1, 0);
|
||||||
}
|
}
|
||||||
|
up = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
up
|
||||||
|
);
|
||||||
this.up = up;
|
this.up = up;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotationMatrix)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotationMatrix)) {
|
||||||
|
@ -186,8 +224,14 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
this.rotationMatrix = rotationMatrix;
|
this.rotationMatrix = rotationMatrix;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotationVector)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotationVector)) {
|
||||||
rotationVector = new GameLib.D3.Vector4(graphics, this, new GameLib.D3.API.Vector4(), 0.1);
|
rotationVector = new GameLib.D3.API.Quaternion();
|
||||||
}
|
}
|
||||||
|
rotationVector = new GameLib.D3.Quaternion(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
rotationVector
|
||||||
|
);
|
||||||
|
//rotationVector.normalize();
|
||||||
this.rotationVector = rotationVector;
|
this.rotationVector = rotationVector;
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentPathFollowing, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentPathFollowing, GameLib.D3.ComponentInterface);
|
||||||
|
@ -220,58 +264,19 @@ GameLib.D3.ComponentPathFollowing.prototype.onUpdate = function(
|
||||||
|
|
||||||
this.futurePosition = this.spline.getPointAt(this.currentPathValue);
|
this.futurePosition = this.spline.getPointAt(this.currentPathValue);
|
||||||
|
|
||||||
// - - - - - - - - - - - - -
|
|
||||||
// Ray trace from the future position.
|
|
||||||
// - - - - - - - - -- - - - -
|
|
||||||
|
|
||||||
this.raycaster.setPosition(
|
this.raycaster.setPosition(
|
||||||
this.futurePosition
|
this.futurePosition
|
||||||
);
|
);
|
||||||
|
|
||||||
// var futureNormal = new THREE.Vector3(0, 1, 0);
|
|
||||||
// var futurePositionRayCasted = new THREE.Vector3(
|
|
||||||
// futurePosition.x,
|
|
||||||
// futurePosition.y,
|
|
||||||
// futurePosition.z
|
|
||||||
// );
|
|
||||||
|
|
||||||
var normal = this.raycaster.getFaceNormal(this.mesh);
|
var normal = this.raycaster.getFaceNormal(this.mesh);
|
||||||
|
|
||||||
this.up.x = this.mx(normal.x);
|
if (normal) {
|
||||||
this.up.y = this.my(normal.y);
|
this.up.x = this.mx(normal.x);
|
||||||
this.up.z = this.mz(normal.z);
|
this.up.y = this.my(normal.y);
|
||||||
|
this.up.z = this.mz(normal.z);
|
||||||
this.up.updateInstance();
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - -
|
|
||||||
// Ray trace from the current position.
|
|
||||||
// - - - - - - - - -- - - - -
|
|
||||||
//
|
|
||||||
// ComponentPathFollowing_Three_Raycaster.set(
|
|
||||||
// currentPosition,
|
|
||||||
// new THREE.Vector3(
|
|
||||||
// 0,
|
|
||||||
// -1,
|
|
||||||
// 0
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
// var currentNormal = new THREE.Vector3(0, 1, 0);
|
|
||||||
// for(var m = 0, ml = this.trackThreeMeshArray.length; m < ml; ++m) {
|
|
||||||
// var intersect = ComponentPathFollowing_Three_Raycaster.intersectObject(
|
|
||||||
// this.meshes[m].instance
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// if(intersect && intersect.length > 0) {
|
|
||||||
// currentNormal = intersect[0].face.normal;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//var avgNormal = currentNormal.add(this.pastNormal).add(futureNormal).normalize();
|
|
||||||
// var avgNormal = (this.pastNormal).add(futureNormal).normalize();
|
|
||||||
// this.pastNormal = futureNormal;
|
|
||||||
|
|
||||||
|
this.up.updateInstance();
|
||||||
|
}
|
||||||
|
|
||||||
this.rotationMatrix.lookAt(
|
this.rotationMatrix.lookAt(
|
||||||
this.currentPosition,
|
this.currentPosition,
|
||||||
|
@ -281,37 +286,6 @@ GameLib.D3.ComponentPathFollowing.prototype.onUpdate = function(
|
||||||
|
|
||||||
this.rotationVector.setFromRotationMatrix(this.rotationMatrix);
|
this.rotationVector.setFromRotationMatrix(this.rotationMatrix);
|
||||||
|
|
||||||
// var targetVector = new THREE.Vector3(
|
|
||||||
// this.maxOffset.x * this.offset.x,
|
|
||||||
// this.maxOffset.y * this.offset.y,
|
|
||||||
// this.maxOffset.z * this.offset.z
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// var lerpedOffset = new THREE.Vector3(
|
|
||||||
// this.currentOffset.x,
|
|
||||||
// this.currentOffset.y,
|
|
||||||
// this.currentOffset.z
|
|
||||||
// ).lerp(
|
|
||||||
// targetVector,
|
|
||||||
// (this.grain * this.steeringSpeed)
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// this.currentOffset.x = lerpedOffset.x;
|
|
||||||
// this.currentOffset.y = lerpedOffset.y;
|
|
||||||
// this.currentOffset.z = lerpedOffset.z;
|
|
||||||
//
|
|
||||||
// var transformedOffset = new THREE.Vector3(
|
|
||||||
// this.baseOffset.x + lerpedOffset.x,
|
|
||||||
// this.baseOffset.y + lerpedOffset.y,
|
|
||||||
// this.baseOffset.z + lerpedOffset.z
|
|
||||||
// ).applyQuaternion(quaternion);
|
|
||||||
|
|
||||||
// apply to parent rigidbody instead of direclty to the mesh.
|
|
||||||
/* parentEntity.position.x = futurePositionRayCasted.x + transformedOffset.x;
|
|
||||||
parentEntity.position.y = futurePositionRayCasted.y + transformedOffset.y + this.parentEntity.mesh.geometry.boundingBox.y;
|
|
||||||
parentEntity.position.z = futurePositionRayCasted.z + transformedOffset.z;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Position
|
* Update Position
|
||||||
*/
|
*/
|
||||||
|
@ -327,39 +301,6 @@ GameLib.D3.ComponentPathFollowing.prototype.onUpdate = function(
|
||||||
this.parentEntity.quaternion.z = this.rotationVector.z;
|
this.parentEntity.quaternion.z = this.rotationVector.z;
|
||||||
this.parentEntity.quaternion.w = this.rotationVector.w;
|
this.parentEntity.quaternion.w = this.rotationVector.w;
|
||||||
|
|
||||||
// // original code
|
|
||||||
//
|
|
||||||
// this.step += this.grain;
|
|
||||||
//
|
|
||||||
// if (this.step > 1) {
|
|
||||||
// this.step = 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var lookAtStep = this.step + this.grain * 2;
|
|
||||||
//
|
|
||||||
// if (lookAtStep > 1) {
|
|
||||||
// lookAtStep = 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var position = this.scene.splines[0].instance.getPoint(this.step);
|
|
||||||
// var futurePosition = this.scene.splines[0].instance.getPoint(lookAtStep);
|
|
||||||
//
|
|
||||||
// this.raycaster.set(position, new THREE.Vector3(0, -1, 0));
|
|
||||||
//
|
|
||||||
// var intersect = this.raycaster.intersectObject(this.scene.meshes[6].instance);
|
|
||||||
//
|
|
||||||
// this.scene.entities[1].position.x = position.x;
|
|
||||||
// this.scene.entities[1].position.y = position.y;
|
|
||||||
// this.scene.entities[1].position.z = position.z;
|
|
||||||
//
|
|
||||||
// var matrix = new THREE.Matrix4().lookAt(position, futurePosition, intersect[0].face.normal);
|
|
||||||
//
|
|
||||||
// var quaternion = new THREE.Quaternion().setFromRotationMatrix(matrix);
|
|
||||||
//
|
|
||||||
// this.scene.entities[1].quaternion.x = quaternion.x;
|
|
||||||
// this.scene.entities[1].quaternion.y = quaternion.y;
|
|
||||||
// this.scene.entities[1].quaternion.z = quaternion.z;
|
|
||||||
// this.scene.entities[1].quaternion.w = quaternion.w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -12,6 +12,14 @@ GameLib.D3.Engine = function Engine(
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Engine.prototype.toApiEngine = function() {
|
||||||
|
|
||||||
|
//TODO: create API.Engine sometime
|
||||||
|
return {
|
||||||
|
engineType : this.engineType
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if CANNON physics
|
* True if CANNON physics
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|
|
@ -1,22 +1,101 @@
|
||||||
/**
|
/**
|
||||||
* Entity Runtime
|
* Entity Runtime
|
||||||
* @param apiEntity
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentScene
|
* @param apiEntity GameLib.D3.API.Entity
|
||||||
* @param mesh
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Entity = function Entity(
|
GameLib.D3.Entity = function Entity(
|
||||||
apiEntity,
|
graphics,
|
||||||
parentScene,
|
apiEntity
|
||||||
mesh
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
for (var property in apiEntity) {
|
for (var property in apiEntity) {
|
||||||
if (apiEntity.hasOwnProperty(property)) {
|
if (apiEntity.hasOwnProperty(property)) {
|
||||||
this[property] = apiEntity[property];
|
this[property] = apiEntity[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
this.position = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
this.position
|
||||||
|
);
|
||||||
|
|
||||||
|
this.quaternion = new GameLib.D3.Quaternion(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
this.quaternion
|
||||||
|
);
|
||||||
|
|
||||||
|
this.scale = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
this.scale
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Entity to GameLib.D3.API.Entity
|
||||||
|
* @returns {GameLib.D3.API.Entity}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Entity.prototype.toApiEntity = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Entity(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.ids,
|
||||||
|
this.position.toApiVector(),
|
||||||
|
this.quaternion.toApiQuaternion(),
|
||||||
|
this.scale.toApiVector(),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.parentScene),
|
||||||
|
GameLib.D3.Utils.IdOrNull(this.mesh)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectEntity Object
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Entity.FromObjectEntity = function(graphics, objectEntity) {
|
||||||
|
|
||||||
|
var apiEntity = new GameLib.D3.API.Entity(
|
||||||
|
objectEntity.id,
|
||||||
|
objectEntity.name,
|
||||||
|
objectEntity.ids,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectEntity.position.x,
|
||||||
|
objectEntity.position.y,
|
||||||
|
objectEntity.position.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectEntity.quaternion.x,
|
||||||
|
objectEntity.quaternion.y,
|
||||||
|
objectEntity.quaternion.z,
|
||||||
|
objectEntity.quaternion.w,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectEntity.quaternion.axis.x,
|
||||||
|
objectEntity.quaternion.axis.y,
|
||||||
|
objectEntity.quaternion.axis.z
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectEntity.scale.x,
|
||||||
|
objectEntity.scale.y,
|
||||||
|
objectEntity.scale.z
|
||||||
|
),
|
||||||
|
objectEntity.parentScene,
|
||||||
|
objectEntity.mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GameLib.D3.Entity(
|
||||||
|
graphics,
|
||||||
|
apiEntity
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +107,7 @@ GameLib.D3.Entity.prototype.update = function(
|
||||||
) {
|
) {
|
||||||
for(var c in this.ids) {
|
for(var c in this.ids) {
|
||||||
var id = this.ids[c];
|
var id = this.ids[c];
|
||||||
var component = this.parentScene.idToComponent[id];
|
var component = this.parentScene.idToObject[id];
|
||||||
if(component && component.onUpdate) {
|
if(component && component.onUpdate) {
|
||||||
component.onUpdate(deltaTime, this);
|
component.onUpdate(deltaTime, this);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +154,7 @@ GameLib.D3.Entity.prototype.lateUpdate = function(
|
||||||
) {
|
) {
|
||||||
for(var c in this.ids) {
|
for(var c in this.ids) {
|
||||||
var id = this.ids[c];
|
var id = this.ids[c];
|
||||||
var component = this.parentScene.idToComponent[id];
|
var component = this.parentScene.idToObject[id];
|
||||||
if(component && component.onLateUpdate) {
|
if(component && component.onLateUpdate) {
|
||||||
component.onLateUpdate(deltaTime, this);
|
component.onLateUpdate(deltaTime, this);
|
||||||
}
|
}
|
||||||
|
@ -130,9 +209,9 @@ GameLib.D3.Entity.prototype.addComponent = function(
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Entity.prototype.removeComponent = function(component) {
|
GameLib.D3.Entity.prototype.removeComponent = function(component) {
|
||||||
if(component && component.id && this.parentScene.idToComponent[component.id]) {
|
if(component && component.id && this.parentScene.idToObject[component.id]) {
|
||||||
this.ids = this.ids.splice(this.ids.indexOf(component), 1);
|
this.ids = this.ids.splice(this.ids.indexOf(component), 1);
|
||||||
delete this.parentScene.idToComponent[component.id];
|
delete this.parentScene.idToObject[component.id];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,7 +221,7 @@ GameLib.D3.Entity.prototype.getComponent = function(
|
||||||
for (var componentId in this.ids) {
|
for (var componentId in this.ids) {
|
||||||
if (this.ids.hasOwnProperty(componentId)) {
|
if (this.ids.hasOwnProperty(componentId)) {
|
||||||
var id = this.ids[componentId];
|
var id = this.ids[componentId];
|
||||||
var component = this.parentScene.idToComponent[id];
|
var component = this.parentScene.idToObject[id];
|
||||||
if (component instanceof componentType) {
|
if (component instanceof componentType) {
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
@ -170,4 +249,14 @@ GameLib.D3.Entity.prototype.onRegistered = function(
|
||||||
parentScene
|
parentScene
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Entity.prototype.linkObjects = function(idToObject) {
|
||||||
|
/**
|
||||||
|
* @param scene GameLib.D3.Scene
|
||||||
|
* @param mesh GameLib.D3.Mesh
|
||||||
|
*/
|
||||||
|
GameLib.D3.Utils.Link('parentScene', idToObject, this, this.parentScene);
|
||||||
|
GameLib.D3.Utils.Link('mesh', idToObject, this, this.mesh);
|
||||||
|
|
||||||
};
|
};
|
|
@ -39,6 +39,18 @@ GameLib.D3.Heightmap = function Heightmap(
|
||||||
this.elementSize = heightScale;
|
this.elementSize = heightScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Heightmap.prototype.toApiHeightMap = function() {
|
||||||
|
//TODO - create API heightmap someday
|
||||||
|
return {
|
||||||
|
sizeX: this.sizeX,
|
||||||
|
sizeY: this.sizeY,
|
||||||
|
matrix: this.matrix,
|
||||||
|
elementSize: this.elementSize,
|
||||||
|
heightScale: this.heightScale
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a graphics instance mesh from the graphics, physics and physics shape
|
* Creates a graphics instance mesh from the graphics, physics and physics shape
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
|
|
@ -42,7 +42,7 @@ GameLib.D3.Light = function Light(
|
||||||
this.scale
|
this.scale
|
||||||
);
|
);
|
||||||
|
|
||||||
this.quaternion = new GameLib.D3.Vector4(
|
this.quaternion = new GameLib.D3.Quaternion(
|
||||||
graphics,
|
graphics,
|
||||||
this,
|
this,
|
||||||
this.quaternion
|
this.quaternion
|
||||||
|
@ -154,3 +154,90 @@ GameLib.D3.Light.prototype.updateInstance = function() {
|
||||||
GameLib.D3.Light.prototype.clone = function() {
|
GameLib.D3.Light.prototype.clone = function() {
|
||||||
return _.cloneDeep(this);
|
return _.cloneDeep(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Light to a GameLib.D3.API.Light
|
||||||
|
* @returns {GameLib.D3.API.Light}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Light.prototype.toApiLight = function() {
|
||||||
|
return new GameLib.D3.API.Light(
|
||||||
|
this.id,
|
||||||
|
this.lightType,
|
||||||
|
this.name,
|
||||||
|
this.color.toApiColor(),
|
||||||
|
this.intensity,
|
||||||
|
this.position.toApiVector(),
|
||||||
|
this.targetPosition.toApiVector(),
|
||||||
|
this.quaternion.toApiQuaternion(),
|
||||||
|
this.rotation,
|
||||||
|
this.scale.toApiVector(),
|
||||||
|
this.distance,
|
||||||
|
this.decay,
|
||||||
|
this.power,
|
||||||
|
this.angle,
|
||||||
|
this.penumbra
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new GameLib.D3.Light from a GameLib.D3.API.Light
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param apiLight GameLib.D3.API.Light
|
||||||
|
* @returns {GameLib.D3.API.Light}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Light.FromObjectLight = function(graphics, apiLight) {
|
||||||
|
|
||||||
|
return new GameLib.D3.Light(
|
||||||
|
graphics,
|
||||||
|
new GameLib.D3.API.Light(
|
||||||
|
apiLight.id,
|
||||||
|
apiLight.lightType,
|
||||||
|
apiLight.name,
|
||||||
|
new GameLib.D3.API.Color(
|
||||||
|
apiLight.color.r,
|
||||||
|
apiLight.color.g,
|
||||||
|
apiLight.color.b,
|
||||||
|
apiLight.color.a
|
||||||
|
),
|
||||||
|
apiLight.intensity,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
apiLight.position.x,
|
||||||
|
apiLight.position.y,
|
||||||
|
apiLight.position.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
apiLight.targetPosition.x,
|
||||||
|
apiLight.targetPosition.y,
|
||||||
|
apiLight.targetPosition.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
apiLight.quaternion.x,
|
||||||
|
apiLight.quaternion.y,
|
||||||
|
apiLight.quaternion.z,
|
||||||
|
apiLight.quaternion.w,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
apiLight.quaternion.axis.x,
|
||||||
|
apiLight.quaternion.axis.y,
|
||||||
|
apiLight.quaternion.axis.z
|
||||||
|
),
|
||||||
|
apiLight.quaternion.angle
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
apiLight.rotation.x,
|
||||||
|
apiLight.rotation.y,
|
||||||
|
apiLight.rotation.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
apiLight.scale.x,
|
||||||
|
apiLight.scale.y,
|
||||||
|
apiLight.scale.z
|
||||||
|
),
|
||||||
|
apiLight.distance,
|
||||||
|
apiLight.decay,
|
||||||
|
apiLight.power,
|
||||||
|
apiLight.angle,
|
||||||
|
apiLight.penumbra
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
|
@ -341,4 +341,175 @@ GameLib.D3.Material.prototype.updateInstance = function() {
|
||||||
|
|
||||||
GameLib.D3.Material.prototype.clone = function() {
|
GameLib.D3.Material.prototype.clone = function() {
|
||||||
return _.cloneDeep(this);
|
return _.cloneDeep(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Material to a GameLib.D3.API.Material
|
||||||
|
* @returns {GameLib.D3.API.Material}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.prototype.toApiMaterial = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Material(
|
||||||
|
this.id,
|
||||||
|
this.materialType,
|
||||||
|
this.name,
|
||||||
|
this.opacity,
|
||||||
|
this.side,
|
||||||
|
this.transparent,
|
||||||
|
this.maps.toApiTextureMaps(),
|
||||||
|
this.specular.toApiColor(),
|
||||||
|
this.lightMapIntensity,
|
||||||
|
this.aoMapIntensity,
|
||||||
|
this.color.toApiColor(),
|
||||||
|
this.emissive.toApiColor(),
|
||||||
|
this.emissiveIntensity,
|
||||||
|
this.combine,
|
||||||
|
this.shininess,
|
||||||
|
this.reflectivity,
|
||||||
|
this.refractionRatio,
|
||||||
|
this.fog,
|
||||||
|
this.wireframe,
|
||||||
|
this.wireframeLineWidth,
|
||||||
|
this.wireframeLineCap,
|
||||||
|
this.wireframeLineJoin,
|
||||||
|
this.vertexColors,
|
||||||
|
this.skinning,
|
||||||
|
this.morphTargets,
|
||||||
|
this.morphNormals,
|
||||||
|
this.lineWidth,
|
||||||
|
this.lineCap,
|
||||||
|
this.lineJoin,
|
||||||
|
this.dashSize,
|
||||||
|
this.gapWidth,
|
||||||
|
this.blending,
|
||||||
|
this.blendSrc,
|
||||||
|
this.blendDst,
|
||||||
|
this.blendEquation,
|
||||||
|
this.depthTest,
|
||||||
|
this.depthFunc,
|
||||||
|
this.depthWrite,
|
||||||
|
this.polygonOffset,
|
||||||
|
this.polygonOffsetFactor,
|
||||||
|
this.polygonOffsetUnits,
|
||||||
|
this.alphaTest,
|
||||||
|
this.clippingPlanes,
|
||||||
|
this.clipShadows,
|
||||||
|
this.visible,
|
||||||
|
this.overdraw,
|
||||||
|
this.shading,
|
||||||
|
this.bumpScale,
|
||||||
|
this.normalScale,
|
||||||
|
this.displacementScale,
|
||||||
|
this.displacementBias,
|
||||||
|
this.roughness,
|
||||||
|
this.metalness,
|
||||||
|
this.pointSize,
|
||||||
|
this.pointSizeAttenuation,
|
||||||
|
this.spriteRotation,
|
||||||
|
this.envMapIntensity
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a GameLib.D3.Material from a material Object
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectMaterial Object
|
||||||
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.FromObjectMaterial = function(graphics, objectMaterial, imageFactory) {
|
||||||
|
|
||||||
|
var gameLibMaterial = new GameLib.D3.Material(
|
||||||
|
graphics,
|
||||||
|
new GameLib.D3.API.Material(
|
||||||
|
objectMaterial.id,
|
||||||
|
objectMaterial.materialType,
|
||||||
|
objectMaterial.name,
|
||||||
|
objectMaterial.opacity,
|
||||||
|
objectMaterial.side,
|
||||||
|
objectMaterial.transparent,
|
||||||
|
GameLib.D3.API.TextureMapTemplate(),
|
||||||
|
new GameLib.D3.API.Color(
|
||||||
|
objectMaterial.specular.r,
|
||||||
|
objectMaterial.specular.g,
|
||||||
|
objectMaterial.specular.b,
|
||||||
|
objectMaterial.specular.a
|
||||||
|
),
|
||||||
|
objectMaterial.lightMapIntensity,
|
||||||
|
objectMaterial.aoMapIntensity,
|
||||||
|
new GameLib.D3.API.Color(
|
||||||
|
objectMaterial.color.r,
|
||||||
|
objectMaterial.color.g,
|
||||||
|
objectMaterial.color.b,
|
||||||
|
objectMaterial.color.a
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Color(
|
||||||
|
objectMaterial.emissive.r,
|
||||||
|
objectMaterial.emissive.g,
|
||||||
|
objectMaterial.emissive.b,
|
||||||
|
objectMaterial.emissive.a
|
||||||
|
),
|
||||||
|
objectMaterial.emissiveIntensity,
|
||||||
|
objectMaterial.combine,
|
||||||
|
objectMaterial.shininess,
|
||||||
|
objectMaterial.reflectivity,
|
||||||
|
objectMaterial.refractionRatio,
|
||||||
|
objectMaterial.fog,
|
||||||
|
objectMaterial.wireframe,
|
||||||
|
objectMaterial.wireframeLineWidth,
|
||||||
|
objectMaterial.wireframeLineCap,
|
||||||
|
objectMaterial.wireframeLineJoin,
|
||||||
|
objectMaterial.vertexColors,
|
||||||
|
objectMaterial.skinning,
|
||||||
|
objectMaterial.morphTargets,
|
||||||
|
objectMaterial.morphNormals,
|
||||||
|
objectMaterial.lineWidth,
|
||||||
|
objectMaterial.lineCap,
|
||||||
|
objectMaterial.lineJoin,
|
||||||
|
objectMaterial.dashSize,
|
||||||
|
objectMaterial.gapWidth,
|
||||||
|
objectMaterial.blending,
|
||||||
|
objectMaterial.blendSrc,
|
||||||
|
objectMaterial.blendDst,
|
||||||
|
objectMaterial.blendEquation,
|
||||||
|
objectMaterial.depthTest,
|
||||||
|
objectMaterial.depthFunc,
|
||||||
|
objectMaterial.depthWrite,
|
||||||
|
objectMaterial.polygonOffset,
|
||||||
|
objectMaterial.polygonOffsetFactor,
|
||||||
|
objectMaterial.polygonOffsetUnits,
|
||||||
|
objectMaterial.alphaTest,
|
||||||
|
objectMaterial.clippingPlanes,
|
||||||
|
objectMaterial.clipShadows,
|
||||||
|
objectMaterial.visible,
|
||||||
|
objectMaterial.overdraw,
|
||||||
|
objectMaterial.shading,
|
||||||
|
objectMaterial.bumpScale,
|
||||||
|
objectMaterial.normalScale,
|
||||||
|
objectMaterial.displacementScale,
|
||||||
|
objectMaterial.displacementBias,
|
||||||
|
objectMaterial.roughness,
|
||||||
|
objectMaterial.metalness,
|
||||||
|
objectMaterial.pointSize,
|
||||||
|
objectMaterial.pointSizeAttenuation,
|
||||||
|
objectMaterial.spriteRotation,
|
||||||
|
objectMaterial.envMapIntensity
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
var objectMaps = objectMaterial.maps;
|
||||||
|
|
||||||
|
var gameLibTextureMap = new GameLib.D3.TextureMapTemplate(graphics);
|
||||||
|
|
||||||
|
for (var map in gameLibTextureMap) {
|
||||||
|
|
||||||
|
if (gameLibTextureMap.hasOwnProperty(map) && objectMaps[map] && objectMaps[map].texture && objectMaps[map].texture.imagePath) {
|
||||||
|
|
||||||
|
gameLibTextureMap[map].texture = GameLib.D3.Texture.FromObjectTexture(graphics, objectMaps[map].texture, gameLibMaterial, map, gameLibTextureMap, imageFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameLibMaterial.maps = gameLibTextureMap;
|
||||||
|
|
||||||
|
return gameLibMaterial;
|
||||||
|
};
|
||||||
|
|
|
@ -30,8 +30,8 @@ GameLib.D3.Matrix3 = function(
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Matrix3.prototype.identity = function () {
|
GameLib.D3.Matrix3.prototype.identity = function () {
|
||||||
this.rows = [
|
this.rows = [
|
||||||
new GameLib.D3.API.Vector4(1, 0, 0),
|
new GameLib.D3.API.Vector3(1, 0, 0),
|
||||||
new GameLib.D3.API.Vector4(0, 1, 0),
|
new GameLib.D3.API.Vector3(0, 1, 0),
|
||||||
new GameLib.D3.API.Vector4(0, 0, 1)
|
new GameLib.D3.API.Vector3(0, 0, 1)
|
||||||
];
|
];
|
||||||
};
|
};
|
|
@ -2,20 +2,20 @@
|
||||||
* Runtime Matrix4
|
* Runtime Matrix4
|
||||||
* @param graphics
|
* @param graphics
|
||||||
* @param parentObject
|
* @param parentObject
|
||||||
* @param matrix4
|
* @param apiMatrix4
|
||||||
* @param grain
|
* @param grain
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Matrix4 = function(
|
GameLib.D3.Matrix4 = function(
|
||||||
graphics,
|
graphics,
|
||||||
parentObject,
|
parentObject,
|
||||||
matrix4,
|
apiMatrix4,
|
||||||
grain
|
grain
|
||||||
) {
|
) {
|
||||||
|
|
||||||
for (var property in matrix4) {
|
for (var property in apiMatrix4) {
|
||||||
if (matrix4.hasOwnProperty(property)) {
|
if (apiMatrix4.hasOwnProperty(property)) {
|
||||||
this[property] = matrix4[property];
|
this[property] = apiMatrix4[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,28 +32,28 @@ GameLib.D3.Matrix4 = function(
|
||||||
}
|
}
|
||||||
this.grain = grain;
|
this.grain = grain;
|
||||||
|
|
||||||
this.rows[0] = new GameLib.D3.Vector4(
|
this.rows[0] = new GameLib.D3.Quaternion(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this,
|
this,
|
||||||
this.rows[0],
|
this.rows[0],
|
||||||
grain
|
grain
|
||||||
);
|
);
|
||||||
|
|
||||||
this.rows[1] = new GameLib.D3.Vector4(
|
this.rows[1] = new GameLib.D3.Quaternion(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this,
|
this,
|
||||||
this.rows[1],
|
this.rows[1],
|
||||||
grain
|
grain
|
||||||
);
|
);
|
||||||
|
|
||||||
this.rows[2] = new GameLib.D3.Vector4(
|
this.rows[2] = new GameLib.D3.Quaternion(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this,
|
this,
|
||||||
this.rows[2],
|
this.rows[2],
|
||||||
grain
|
grain
|
||||||
);
|
);
|
||||||
|
|
||||||
this.rows[3] = new GameLib.D3.Vector4(
|
this.rows[3] = new GameLib.D3.Quaternion(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this,
|
this,
|
||||||
this.rows[3],
|
this.rows[3],
|
||||||
|
@ -133,3 +133,59 @@ GameLib.D3.Matrix4.prototype.lookAt = function (position, target, up) {
|
||||||
this.rows[3].w = this.instance.elements[15];
|
this.rows[3].w = this.instance.elements[15];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameLib.D3.Matrix4 to GameLib.D3.API.Matrix4
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Matrix4.prototype.toApiMatrix = function () {
|
||||||
|
return new GameLib.D3.API.Matrix4(
|
||||||
|
this.rows[0].toApiQuaternion(),
|
||||||
|
this.rows[1].toApiQuaternion(),
|
||||||
|
this.rows[2].toApiQuaternion(),
|
||||||
|
this.rows[3].toApiQuaternion()
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a GameLib.D3.Matrix4 from an Object matrix
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectMatrix Object
|
||||||
|
* @param parentObject
|
||||||
|
* @returns {GameLib.D3.Matrix4}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Matrix4.FromObjectMatrix = function(graphics, objectMatrix, parentObject) {
|
||||||
|
var apiMatrix = new GameLib.D3.API.Matrix4(
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectMatrix[0],
|
||||||
|
objectMatrix[1],
|
||||||
|
objectMatrix[2],
|
||||||
|
objectMatrix[3]
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectMatrix[4],
|
||||||
|
objectMatrix[5],
|
||||||
|
objectMatrix[6],
|
||||||
|
objectMatrix[7]
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectMatrix[8],
|
||||||
|
objectMatrix[9],
|
||||||
|
objectMatrix[10],
|
||||||
|
objectMatrix[11]
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectMatrix[12],
|
||||||
|
objectMatrix[13],
|
||||||
|
objectMatrix[14],
|
||||||
|
objectMatrix[15]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GameLib.D3.Matrix4(
|
||||||
|
graphics,
|
||||||
|
parentObject,
|
||||||
|
apiMatrix
|
||||||
|
)
|
||||||
|
};
|
|
@ -45,14 +45,8 @@ GameLib.D3.Mesh = function Mesh(
|
||||||
/**
|
/**
|
||||||
* We don't do a Runtime rotation since it interferes with the quaternion update
|
* We don't do a Runtime rotation since it interferes with the quaternion update
|
||||||
*/
|
*/
|
||||||
this.rotation = new GameLib.D3.Vector3(
|
|
||||||
graphics,
|
|
||||||
this,
|
|
||||||
this.rotation,
|
|
||||||
0.001
|
|
||||||
);
|
|
||||||
|
|
||||||
this.quaternion = new GameLib.D3.Vector4(
|
this.quaternion = new GameLib.D3.Quaternion(
|
||||||
graphics,
|
graphics,
|
||||||
this,
|
this,
|
||||||
this.quaternion
|
this.quaternion
|
||||||
|
@ -266,7 +260,7 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
*/
|
*/
|
||||||
for (var si = 0; si < this.skinIndices.length; si++) {
|
for (var si = 0; si < this.skinIndices.length; si++) {
|
||||||
instanceGeometry.skinIndices.push(
|
instanceGeometry.skinIndices.push(
|
||||||
new this.graphics.instance.Vector4(
|
new this.graphics.instance.Quaternion(
|
||||||
this.skinIndices[si].x,
|
this.skinIndices[si].x,
|
||||||
this.skinIndices[si].y,
|
this.skinIndices[si].y,
|
||||||
this.skinIndices[si].z,
|
this.skinIndices[si].z,
|
||||||
|
@ -280,7 +274,7 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
*/
|
*/
|
||||||
for (var sw = 0; sw < this.skinWeights.length; sw++) {
|
for (var sw = 0; sw < this.skinWeights.length; sw++) {
|
||||||
instanceGeometry.skinWeights.push(
|
instanceGeometry.skinWeights.push(
|
||||||
new this.graphics.instance.Vector4(
|
new this.graphics.instance.Quaternion(
|
||||||
this.skinWeights[sw].x,
|
this.skinWeights[sw].x,
|
||||||
this.skinWeights[sw].y,
|
this.skinWeights[sw].y,
|
||||||
this.skinWeights[sw].z,
|
this.skinWeights[sw].z,
|
||||||
|
@ -331,21 +325,6 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
instance.up.y = this.up.y;
|
instance.up.y = this.up.y;
|
||||||
instance.up.z = this.up.z;
|
instance.up.z = this.up.z;
|
||||||
|
|
||||||
/**
|
|
||||||
* We don't do rotation for now - it should be dealt with by quaternion
|
|
||||||
*/
|
|
||||||
// instance.rotation.x = this.rotation.x;
|
|
||||||
// instance.rotation.y = this.rotation.y;
|
|
||||||
// instance.rotation.z = this.rotation.z;
|
|
||||||
//
|
|
||||||
// instance.quaternion.setFromEuler(
|
|
||||||
// new THREE.Euler(
|
|
||||||
// instance.rotation.x,
|
|
||||||
// instance.rotation.y,
|
|
||||||
// instance.rotation.z
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
instance.quaternion.x = this.quaternion.x;
|
instance.quaternion.x = this.quaternion.x;
|
||||||
instance.quaternion.y = this.quaternion.y;
|
instance.quaternion.y = this.quaternion.y;
|
||||||
instance.quaternion.z = this.quaternion.z;
|
instance.quaternion.z = this.quaternion.z;
|
||||||
|
@ -354,10 +333,129 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the mesh instance
|
||||||
|
*/
|
||||||
GameLib.D3.Mesh.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.prototype.updateInstance = function() {
|
||||||
this.instance = this.createInstance(true);
|
this.instance = this.createInstance(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones a mesh
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
GameLib.D3.Mesh.prototype.clone = function() {
|
GameLib.D3.Mesh.prototype.clone = function() {
|
||||||
return _.cloneDeep(this);
|
return _.cloneDeep(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
|
||||||
|
* @returns {GameLib.D3.API.Mesh}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Mesh.prototype.toApiMesh = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Mesh(
|
||||||
|
this.id,
|
||||||
|
this.meshType,
|
||||||
|
this.name,
|
||||||
|
this.vertices,
|
||||||
|
this.faces,
|
||||||
|
this.faceVertexUvs,
|
||||||
|
this.materials.map(function(material){return material.toApiMaterial()}),
|
||||||
|
this.parentMeshId,
|
||||||
|
this.parentSceneId,
|
||||||
|
this.skeleton,
|
||||||
|
this.skinIndices,
|
||||||
|
this.skinWeights,
|
||||||
|
this.position.toApiVector(),
|
||||||
|
this.quaternion.toApiQuaternion(),
|
||||||
|
this.scale.toApiVector(),
|
||||||
|
this.up.toApiVector()
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a standard object mesh to a GameLib.D3.Mesh
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectMesh {Object}
|
||||||
|
* @param computeNormals boolean to indicate whether or not to recalculate normals
|
||||||
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Mesh.FromObjectMesh = function(graphics, objectMesh, computeNormals, imageFactory) {
|
||||||
|
|
||||||
|
var apiMesh = new GameLib.D3.API.Mesh(
|
||||||
|
objectMesh.id,
|
||||||
|
objectMesh.meshType,
|
||||||
|
objectMesh.name,
|
||||||
|
objectMesh.vertices.map(
|
||||||
|
function (objectVertex) {
|
||||||
|
return new GameLib.D3.Vertex(
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectVertex.position.x,
|
||||||
|
objectVertex.position.y,
|
||||||
|
objectVertex.position.z
|
||||||
|
),
|
||||||
|
objectVertex.boneWeights.map(
|
||||||
|
function (boneWeight) {
|
||||||
|
return new GameLib.D3.API.BoneWeight(
|
||||||
|
boneWeight.boneIndex,
|
||||||
|
boneWeight.weight
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectMesh.faces,
|
||||||
|
objectMesh.faceVertexUvs,
|
||||||
|
objectMesh.materials.map(
|
||||||
|
function (objectMaterial) {
|
||||||
|
return GameLib.D3.Material.FromObjectMaterial(
|
||||||
|
graphics,
|
||||||
|
objectMaterial,
|
||||||
|
imageFactory
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectMesh.parentMeshId,
|
||||||
|
objectMesh.parentSceneId,
|
||||||
|
objectMesh.skeleton,
|
||||||
|
objectMesh.skinIndices,
|
||||||
|
objectMesh.skinWeights,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectMesh.position.x,
|
||||||
|
objectMesh.position.y,
|
||||||
|
objectMesh.position.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectMesh.quaternion.x,
|
||||||
|
objectMesh.quaternion.y,
|
||||||
|
objectMesh.quaternion.z,
|
||||||
|
objectMesh.quaternion.w,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectMesh.quaternion.axis.x,
|
||||||
|
objectMesh.quaternion.axis.y,
|
||||||
|
objectMesh.quaternion.axis.z
|
||||||
|
),
|
||||||
|
objectMesh.quaternion.angle
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectMesh.scale.x,
|
||||||
|
objectMesh.scale.y,
|
||||||
|
objectMesh.scale.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectMesh.up.x,
|
||||||
|
objectMesh.up.y,
|
||||||
|
objectMesh.up.z
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GameLib.D3.Mesh(
|
||||||
|
graphics,
|
||||||
|
computeNormals,
|
||||||
|
apiMesh
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,27 +1,25 @@
|
||||||
/**
|
/**
|
||||||
* Runtime vector4 for updating instance objects
|
* Runtime quaternion for updating instance objects
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentObject GameLib.D3.*
|
* @param parentObject GameLib.D3.*
|
||||||
* @param vector4 GameLib.D3.API.Vector4
|
* @param quaternion GameLib.D3.API.Quaternion
|
||||||
* @param grain Number
|
* @param grain Number
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vector4 = function RuntimeVector4(
|
GameLib.D3.Quaternion = function RuntimeQuaternion(
|
||||||
graphics,
|
graphics,
|
||||||
parentObject,
|
parentObject,
|
||||||
vector4,
|
quaternion,
|
||||||
grain
|
grain
|
||||||
) {
|
) {
|
||||||
|
|
||||||
for (var property in vector4) {
|
for (var property in quaternion) {
|
||||||
if (vector4.hasOwnProperty(property)) {
|
if (quaternion.hasOwnProperty(property)) {
|
||||||
|
this[property] = quaternion[property];
|
||||||
|
|
||||||
this[property] = vector4[property];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.Vector4, GameLib.D3.API.Vector4);
|
GameLib.D3.Utils.Extend(GameLib.D3.Quaternion, GameLib.D3.API.Quaternion);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
@ -34,15 +32,22 @@ GameLib.D3.Vector4 = function RuntimeVector4(
|
||||||
}
|
}
|
||||||
this.grain = grain;
|
this.grain = grain;
|
||||||
|
|
||||||
|
this.axis = new GameLib.D3.Vector3(
|
||||||
|
this.graphics,
|
||||||
|
this,
|
||||||
|
this.axis,
|
||||||
|
0.001
|
||||||
|
);
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance vector4
|
* Creates an instance quaternion
|
||||||
* @param update
|
* @param update
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vector4.prototype.createInstance = function(update) {
|
GameLib.D3.Quaternion.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
var instance = null;
|
var instance = null;
|
||||||
|
|
||||||
|
@ -62,7 +67,7 @@ GameLib.D3.Vector4.prototype.createInstance = function(update) {
|
||||||
/**
|
/**
|
||||||
* Updates the instance vector, calls updateInstance on the parent object
|
* Updates the instance vector, calls updateInstance on the parent object
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vector4.prototype.updateInstance = function() {
|
GameLib.D3.Quaternion.prototype.updateInstance = function() {
|
||||||
|
|
||||||
this.createInstance(true);
|
this.createInstance(true);
|
||||||
|
|
||||||
|
@ -72,19 +77,21 @@ GameLib.D3.Vector4.prototype.updateInstance = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts runtime vector to API Vector
|
* Converts runtime quaternion to API quaternion
|
||||||
* @returns {GameLib.D3.API.Vector4}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vector4.prototype.toApiVector = function() {
|
GameLib.D3.Quaternion.prototype.toApiQuaternion = function() {
|
||||||
return new GameLib.D3.API.Vector4(
|
return new GameLib.D3.API.Quaternion(
|
||||||
this.x,
|
this.x,
|
||||||
this.y,
|
this.y,
|
||||||
this.z,
|
this.z,
|
||||||
this.w
|
this.w,
|
||||||
|
this.axis.toApiVector(),
|
||||||
|
this.angle
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Vector4.prototype.normalize = function () {
|
GameLib.D3.Quaternion.prototype.normalize = function () {
|
||||||
|
|
||||||
this.updateInstance();
|
this.updateInstance();
|
||||||
|
|
||||||
|
@ -102,7 +109,7 @@ GameLib.D3.Vector4.prototype.normalize = function () {
|
||||||
*
|
*
|
||||||
* @param matrix4 GameLib.D3.Matrix4
|
* @param matrix4 GameLib.D3.Matrix4
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vector4.prototype.setFromRotationMatrix = function(matrix4) {
|
GameLib.D3.Quaternion.prototype.setFromRotationMatrix = function(matrix4) {
|
||||||
|
|
||||||
this.instance.setFromRotationMatrix(matrix4.instance);
|
this.instance.setFromRotationMatrix(matrix4.instance);
|
||||||
|
|
||||||
|
@ -114,15 +121,15 @@ GameLib.D3.Vector4.prototype.setFromRotationMatrix = function(matrix4) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param vector4 GameLib.D3.Vector4
|
* @param quaternion GameLib.D3.Quaternion
|
||||||
* @param t
|
* @param t
|
||||||
* @returns {GameLib.D3.Vector4}
|
* @returns {GameLib.D3.Quaternion}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vector4.prototype.slerp = function (vector4, t) {
|
GameLib.D3.Quaternion.prototype.slerp = function (quaternion, t) {
|
||||||
|
|
||||||
this.updateInstance();
|
this.updateInstance();
|
||||||
|
|
||||||
this.instance.slerp(vector4.instance, t);
|
this.instance.slerp(quaternion.instance, t);
|
||||||
|
|
||||||
this.x = this.instance.x;
|
this.x = this.instance.x;
|
||||||
this.y = this.instance.y;
|
this.y = this.instance.y;
|
|
@ -43,7 +43,7 @@ GameLib.D3.RigidBody = function(
|
||||||
this.position = position || new GameLib.D3.API.Vector3();
|
this.position = position || new GameLib.D3.API.Vector3();
|
||||||
this.velocity = velocity || new GameLib.D3.API.Vector3();
|
this.velocity = velocity || new GameLib.D3.API.Vector3();
|
||||||
this.angularVelocity = angularVelocity || new GameLib.D3.API.Vector3();
|
this.angularVelocity = angularVelocity || new GameLib.D3.API.Vector3();
|
||||||
this.quaternion = quaternion || new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
this.quaternion = quaternion || new GameLib.D3.API.Quaternion(0, 0, 0, 1);
|
||||||
this.mass = typeof mass == "undefined" ? 0 : mass;
|
this.mass = typeof mass == "undefined" ? 0 : mass;
|
||||||
this.friction = typeof friction == "undefined" ? 5 : friction;
|
this.friction = typeof friction == "undefined" ? 5 : friction;
|
||||||
this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping;
|
this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping;
|
||||||
|
@ -111,11 +111,15 @@ GameLib.D3.RigidBody.prototype.createInstance = function() {
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.RigidBody.prototype.toApiRigidBody = function() {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a shape to this rigid body
|
* Adds a shape to this rigid body
|
||||||
* @param shape GameLib.D3.Shape
|
* @param shape GameLib.D3.Shape
|
||||||
* @param offset GameLib.D3.API.Vector3
|
* @param offset GameLib.D3.API.Vector3
|
||||||
* @param orientation GameLib.D3.API.Vector4
|
* @param orientation GameLib.D3.API.Quaternion
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.RigidBody.prototype.addShape = function(
|
GameLib.D3.RigidBody.prototype.addShape = function(
|
||||||
|
@ -128,7 +132,7 @@ GameLib.D3.RigidBody.prototype.addShape = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!orientation || typeof orientation == 'undefined') {
|
if (!orientation || typeof orientation == 'undefined') {
|
||||||
orientation = new GameLib.D3.API.Vector4(0,0,0,1);
|
orientation = new GameLib.D3.API.Quaternion(0,0,0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance.addShape(
|
this.instance.addShape(
|
||||||
|
|
|
@ -5,20 +5,18 @@
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
* @param apiScene GameLib.D3.API.Scene
|
* @param apiScene GameLib.D3.API.Scene
|
||||||
* @param imageFactory
|
* @param imageFactory
|
||||||
* @param meshIdToMesh
|
|
||||||
* @param idToComponent
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene = function Scene(
|
GameLib.D3.Scene = function Scene(
|
||||||
graphics,
|
graphics,
|
||||||
progressCallback,
|
progressCallback,
|
||||||
apiScene,
|
apiScene,
|
||||||
imageFactory,
|
imageFactory
|
||||||
meshIdToMesh,
|
|
||||||
idToComponent
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
for (var property in apiScene) {
|
var property;
|
||||||
|
|
||||||
|
for (property in apiScene) {
|
||||||
if (apiScene.hasOwnProperty(property)) {
|
if (apiScene.hasOwnProperty(property)) {
|
||||||
this[property] = apiScene[property];
|
this[property] = apiScene[property];
|
||||||
}
|
}
|
||||||
|
@ -39,34 +37,43 @@ GameLib.D3.Scene = function Scene(
|
||||||
this.scale
|
this.scale
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
this.quaternion = new GameLib.D3.Quaternion(
|
||||||
* We don't do a Runtime rotation since it interferes with the quaternion update
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.quaternion = new GameLib.D3.Vector4(
|
|
||||||
graphics,
|
graphics,
|
||||||
this,
|
this,
|
||||||
this.quaternion
|
this.quaternion
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(meshIdToMesh)) {
|
|
||||||
meshIdToMesh = {};
|
|
||||||
}
|
|
||||||
this.meshIdToMesh = meshIdToMesh;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(idToComponent)) {
|
|
||||||
idToComponent = {};
|
|
||||||
}
|
|
||||||
this.idToComponent = idToComponent;
|
|
||||||
|
|
||||||
this.progressCallback = progressCallback;
|
this.progressCallback = progressCallback;
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
|
|
||||||
this.imageFactory = imageFactory;
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
};
|
this.interestingProperties = [
|
||||||
|
"cameras",
|
||||||
|
"meshes",
|
||||||
|
"lights",
|
||||||
|
"components",
|
||||||
|
"entities",
|
||||||
|
"splines"
|
||||||
|
];
|
||||||
|
|
||||||
|
this.idToObject = {};
|
||||||
|
|
||||||
|
this.idToObject[this.id] = this;
|
||||||
|
|
||||||
|
for (var p = 0; p < this.interestingProperties.length; p++) {
|
||||||
|
property = this.interestingProperties[p];
|
||||||
|
if (this.hasOwnProperty(property)) {
|
||||||
|
for (var i = 0; i < this[property].length; i++) {
|
||||||
|
var object = this[property][i];
|
||||||
|
this.idToObject[object.id] = object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.linkObjects();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance scene
|
* Creates an instance scene
|
||||||
|
@ -74,7 +81,7 @@ GameLib.D3.Scene = function Scene(
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.prototype.createInstance = function() {
|
GameLib.D3.Scene.prototype.createInstance = function() {
|
||||||
|
|
||||||
var instance = new this.graphics.instance.Scene();
|
var instance = new THREE.Scene();
|
||||||
|
|
||||||
instance.name = this.name;
|
instance.name = this.name;
|
||||||
|
|
||||||
|
@ -97,9 +104,205 @@ GameLib.D3.Scene.prototype.createInstance = function() {
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Scene to a GameLib.D3.API.Scene
|
||||||
|
* @returns {GameLib.D3.API.Scene}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Scene.prototype.toApiScene = function() {
|
||||||
|
|
||||||
|
var apiMeshes = this.meshes.map(
|
||||||
|
function(mesh) {
|
||||||
|
return mesh.toApiMesh();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiLights = this.lights.map(
|
||||||
|
function(light) {
|
||||||
|
return light.toApiLight();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiComponents = this.components.map(
|
||||||
|
function(component) {
|
||||||
|
return component.toApiComponent();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiEntities = this.entities.map(
|
||||||
|
function(entity) {
|
||||||
|
return entity.toApiEntity();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiCameras = this.cameras.map(
|
||||||
|
function(camera) {
|
||||||
|
return camera.toApiCamera();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiSplines = this.splines.map(
|
||||||
|
function(spline) {
|
||||||
|
return spline.toApiSpline();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiWorlds = this.worlds.map(
|
||||||
|
function(world) {
|
||||||
|
return world.toApiWorld();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var apiShapes = this.shapes.map(
|
||||||
|
function(shape) {
|
||||||
|
return shape.toApiShape();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Scene(
|
||||||
|
this.id,
|
||||||
|
this.path,
|
||||||
|
this.name,
|
||||||
|
apiMeshes,
|
||||||
|
this.quaternion.toApiQuaternion(),
|
||||||
|
this.position.toApiVector(),
|
||||||
|
this.scale.toApiVector(),
|
||||||
|
this.parentSceneId,
|
||||||
|
apiLights,
|
||||||
|
apiWorlds,
|
||||||
|
apiEntities,
|
||||||
|
apiComponents,
|
||||||
|
apiShapes,
|
||||||
|
apiCameras,
|
||||||
|
this.activeCameraIndex,
|
||||||
|
apiSplines
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a scene Object to a GameLib.D3.Scene object
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectScene Object
|
||||||
|
* @param computeNormals boolean to indicate whether or not to recalculate normals
|
||||||
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
|
* @param progressCallback callback
|
||||||
|
* @returns {GameLib.D3.Scene}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Scene.FromObjectScene = function(
|
||||||
|
graphics,
|
||||||
|
objectScene,
|
||||||
|
computeNormals,
|
||||||
|
imageFactory,
|
||||||
|
progressCallback
|
||||||
|
) {
|
||||||
|
var apiScene = new GameLib.D3.API.Scene(
|
||||||
|
objectScene.id,
|
||||||
|
objectScene.path,
|
||||||
|
objectScene.name,
|
||||||
|
objectScene.meshes.map(
|
||||||
|
function (objectMesh) {
|
||||||
|
return GameLib.D3.Mesh.FromObjectMesh(
|
||||||
|
graphics,
|
||||||
|
objectMesh,
|
||||||
|
computeNormals,
|
||||||
|
imageFactory
|
||||||
|
)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Quaternion(
|
||||||
|
objectScene.quaternion.x,
|
||||||
|
objectScene.quaternion.y,
|
||||||
|
objectScene.quaternion.z,
|
||||||
|
objectScene.quaternion.w,
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectScene.quaternion.axis.x,
|
||||||
|
objectScene.quaternion.axis.y,
|
||||||
|
objectScene.quaternion.axis.z
|
||||||
|
),
|
||||||
|
objectScene.quaternion.angle
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectScene.position.x,
|
||||||
|
objectScene.position.y,
|
||||||
|
objectScene.position.z
|
||||||
|
),
|
||||||
|
new GameLib.D3.API.Vector3(
|
||||||
|
objectScene.scale.x,
|
||||||
|
objectScene.scale.y,
|
||||||
|
objectScene.scale.z
|
||||||
|
),
|
||||||
|
objectScene.parentSceneId,
|
||||||
|
objectScene.lights.map(
|
||||||
|
function (objectLight) {
|
||||||
|
return GameLib.D3.Light.FromObjectLight(
|
||||||
|
graphics,
|
||||||
|
objectLight
|
||||||
|
)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectScene.worlds.map(
|
||||||
|
function (objectWorld) {
|
||||||
|
return GameLib.D3.World.FromObjectWorld(
|
||||||
|
graphics,
|
||||||
|
objectWorld
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectScene.entities.map(
|
||||||
|
function (objectEntity) {
|
||||||
|
return GameLib.D3.Entity.FromObjectEntity(
|
||||||
|
graphics,
|
||||||
|
objectEntity
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectScene.components.map(
|
||||||
|
function (objectComponent) {
|
||||||
|
return GameLib.D3.ComponentInterface.FromObjectComponent(
|
||||||
|
graphics,
|
||||||
|
objectComponent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectScene.shapes.map(
|
||||||
|
function (objectShape) {
|
||||||
|
return GameLib.D3.Shape.FromObjectShape(
|
||||||
|
graphics,
|
||||||
|
objectShape
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectScene.cameras.map(
|
||||||
|
function (objectCamera) {
|
||||||
|
return GameLib.D3.Camera.FromObjectCamera(
|
||||||
|
graphics,
|
||||||
|
objectCamera
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
objectScene.activeCameraIndex,
|
||||||
|
objectScene.splines.map(
|
||||||
|
function (objectSpline) {
|
||||||
|
return GameLib.D3.Spline.FromObjectSpline(
|
||||||
|
graphics,
|
||||||
|
objectSpline
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GameLib.D3.Scene(
|
||||||
|
graphics,
|
||||||
|
progressCallback,
|
||||||
|
apiScene,
|
||||||
|
imageFactory
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms raw scene data into a GameLib.D3.Scene
|
* Transforms raw scene data into a GameLib.D3.Scene
|
||||||
* @param scene Object (as it comes from the API)
|
* @param objectScene Object (as it comes from the API)
|
||||||
* @param onLoaded
|
* @param onLoaded
|
||||||
* @param graphics
|
* @param graphics
|
||||||
* @param uploadUrl
|
* @param uploadUrl
|
||||||
|
@ -108,404 +311,25 @@ GameLib.D3.Scene.prototype.createInstance = function() {
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.LoadScene = function(
|
GameLib.D3.Scene.LoadScene = function(
|
||||||
scene,
|
objectScene,
|
||||||
onLoaded,
|
onLoaded,
|
||||||
graphics,
|
graphics,
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
progressCallback,
|
progressCallback,
|
||||||
computeNormals
|
computeNormals
|
||||||
) {
|
) {
|
||||||
var entities = [];
|
onLoaded(
|
||||||
|
GameLib.D3.Scene.FromObjectScene(
|
||||||
var worlds = [];
|
|
||||||
|
|
||||||
var components = [];
|
|
||||||
|
|
||||||
var shapes = [];
|
|
||||||
|
|
||||||
var imageFactory = GameLib.D3.ImageFactory(graphics, uploadUrl);
|
|
||||||
|
|
||||||
if (scene.worlds && scene.worlds.length > 0) {
|
|
||||||
console.warn('Implement physics worlds code here');
|
|
||||||
}
|
|
||||||
|
|
||||||
var lights = [];
|
|
||||||
|
|
||||||
if (scene.lights && scene.lights.length > 0) {
|
|
||||||
for (var l = 0; l < scene.lights.length; l++) {
|
|
||||||
|
|
||||||
var apiLight = scene.lights[l];
|
|
||||||
|
|
||||||
var light = new GameLib.D3.Light(
|
|
||||||
graphics,
|
|
||||||
new GameLib.D3.API.Light(
|
|
||||||
apiLight.id,
|
|
||||||
apiLight.lightType,
|
|
||||||
apiLight.name,
|
|
||||||
new GameLib.D3.API.Color(
|
|
||||||
apiLight.color.r,
|
|
||||||
apiLight.color.g,
|
|
||||||
apiLight.color.b,
|
|
||||||
apiLight.color.a
|
|
||||||
),
|
|
||||||
apiLight.intensity,
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiLight.position.x,
|
|
||||||
apiLight.position.y,
|
|
||||||
apiLight.position.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiLight.targetPosition.x,
|
|
||||||
apiLight.targetPosition.y,
|
|
||||||
apiLight.targetPosition.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector4(
|
|
||||||
apiLight.quaternion.x,
|
|
||||||
apiLight.quaternion.y,
|
|
||||||
apiLight.quaternion.z,
|
|
||||||
apiLight.quaternion.w
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiLight.rotation.x,
|
|
||||||
apiLight.rotation.y,
|
|
||||||
apiLight.rotation.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiLight.scale.x,
|
|
||||||
apiLight.scale.y,
|
|
||||||
apiLight.scale.z
|
|
||||||
),
|
|
||||||
apiLight.distance,
|
|
||||||
apiLight.decay,
|
|
||||||
apiLight.power,
|
|
||||||
apiLight.angle,
|
|
||||||
apiLight.penumbra
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
lights.push(light);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var gameLibMeshes = [];
|
|
||||||
|
|
||||||
var meshIdToMesh = {};
|
|
||||||
|
|
||||||
for (var m = 0; m < scene.meshes.length; m++) {
|
|
||||||
|
|
||||||
var apiMesh = scene.meshes[m];
|
|
||||||
|
|
||||||
var gameLibMaterials = [];
|
|
||||||
|
|
||||||
for (var mat = 0; mat < apiMesh.materials.length; mat++) {
|
|
||||||
|
|
||||||
var apiMaterial = apiMesh.materials[mat];
|
|
||||||
|
|
||||||
var gameLibMaterial = new GameLib.D3.Material(
|
|
||||||
graphics,
|
|
||||||
new GameLib.D3.API.Material(
|
|
||||||
apiMaterial.id,
|
|
||||||
apiMaterial.materialType,
|
|
||||||
apiMaterial.name,
|
|
||||||
apiMaterial.opacity,
|
|
||||||
apiMaterial.side,
|
|
||||||
apiMaterial.transparent,
|
|
||||||
GameLib.D3.API.TextureMapTemplate(),
|
|
||||||
new GameLib.D3.API.Color(
|
|
||||||
apiMaterial.specular.r,
|
|
||||||
apiMaterial.specular.g,
|
|
||||||
apiMaterial.specular.b,
|
|
||||||
apiMaterial.specular.a
|
|
||||||
),
|
|
||||||
apiMaterial.lightMapIntensity,
|
|
||||||
apiMaterial.aoMapIntensity,
|
|
||||||
new GameLib.D3.API.Color(
|
|
||||||
apiMaterial.color.r,
|
|
||||||
apiMaterial.color.g,
|
|
||||||
apiMaterial.color.b,
|
|
||||||
apiMaterial.color.a
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Color(
|
|
||||||
apiMaterial.emissive.r,
|
|
||||||
apiMaterial.emissive.g,
|
|
||||||
apiMaterial.emissive.b,
|
|
||||||
apiMaterial.emissive.a
|
|
||||||
),
|
|
||||||
apiMaterial.emissiveIntensity,
|
|
||||||
apiMaterial.combine,
|
|
||||||
apiMaterial.shininess,
|
|
||||||
apiMaterial.reflectivity,
|
|
||||||
apiMaterial.refractionRatio,
|
|
||||||
apiMaterial.fog,
|
|
||||||
apiMaterial.wireframe,
|
|
||||||
apiMaterial.wireframeLineWidth,
|
|
||||||
apiMaterial.wireframeLineCap,
|
|
||||||
apiMaterial.wireframeLineJoin,
|
|
||||||
apiMaterial.vertexColors,
|
|
||||||
apiMaterial.skinning,
|
|
||||||
apiMaterial.morphTargets,
|
|
||||||
apiMaterial.morphNormals,
|
|
||||||
apiMaterial.lineWidth,
|
|
||||||
apiMaterial.lineCap,
|
|
||||||
apiMaterial.lineJoin,
|
|
||||||
apiMaterial.dashSize,
|
|
||||||
apiMaterial.gapWidth,
|
|
||||||
apiMaterial.blending,
|
|
||||||
apiMaterial.blendSrc,
|
|
||||||
apiMaterial.blendDst,
|
|
||||||
apiMaterial.blendEquation,
|
|
||||||
apiMaterial.depthTest,
|
|
||||||
apiMaterial.depthFunc,
|
|
||||||
apiMaterial.depthWrite,
|
|
||||||
apiMaterial.polygonOffset,
|
|
||||||
apiMaterial.polygonOffsetFactor,
|
|
||||||
apiMaterial.polygonOffsetUnits,
|
|
||||||
apiMaterial.alphaTest,
|
|
||||||
apiMaterial.clippingPlanes,
|
|
||||||
apiMaterial.clipShadows,
|
|
||||||
apiMaterial.visible,
|
|
||||||
apiMaterial.overdraw,
|
|
||||||
apiMaterial.shading,
|
|
||||||
apiMaterial.bumpScale,
|
|
||||||
apiMaterial.normalScale,
|
|
||||||
apiMaterial.displacementScale,
|
|
||||||
apiMaterial.displacementBias,
|
|
||||||
apiMaterial.roughness,
|
|
||||||
apiMaterial.metalness,
|
|
||||||
apiMaterial.pointSize,
|
|
||||||
apiMaterial.pointSizeAttenuation,
|
|
||||||
apiMaterial.spriteRotation,
|
|
||||||
apiMaterial.envMapIntensity
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
var apiMaps = apiMaterial.maps;
|
|
||||||
|
|
||||||
var gameLibTextureMap = new GameLib.D3.TextureMapTemplate(graphics);
|
|
||||||
|
|
||||||
for (var map in gameLibTextureMap) {
|
|
||||||
|
|
||||||
if (gameLibTextureMap.hasOwnProperty(map) && apiMaps[map] && apiMaps[map].texture && apiMaps[map].texture.imagePath) {
|
|
||||||
|
|
||||||
var apiTexture = apiMaps[map].texture;
|
|
||||||
|
|
||||||
var texture = new GameLib.D3.Texture(
|
|
||||||
new GameLib.D3.API.Texture(
|
|
||||||
apiTexture.id,
|
|
||||||
map,
|
|
||||||
apiTexture.name,
|
|
||||||
apiTexture.imagePath,
|
|
||||||
apiTexture.wrapS,
|
|
||||||
apiTexture.wrapT,
|
|
||||||
new GameLib.D3.API.Vector2(
|
|
||||||
apiTexture.repeat.x,
|
|
||||||
apiTexture.repeat.y
|
|
||||||
),
|
|
||||||
apiTexture.data,
|
|
||||||
apiTexture.format,
|
|
||||||
apiTexture.mapping,
|
|
||||||
apiTexture.magFilter,
|
|
||||||
apiTexture.minFilter,
|
|
||||||
apiTexture.textureType,
|
|
||||||
apiTexture.anisotropy,
|
|
||||||
new GameLib.D3.API.Vector2(
|
|
||||||
apiTexture.offset.x,
|
|
||||||
apiTexture.offset.y
|
|
||||||
),
|
|
||||||
apiTexture.generateMipmaps,
|
|
||||||
apiTexture.flipY,
|
|
||||||
apiTexture.mipmaps,
|
|
||||||
apiTexture.unpackAlignment,
|
|
||||||
apiTexture.premultiplyAlpha,
|
|
||||||
apiTexture.encoding
|
|
||||||
),
|
|
||||||
graphics,
|
|
||||||
gameLibMaterial,
|
|
||||||
gameLibTextureMap[map].instanceMapId,
|
|
||||||
imageFactory
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
gameLibTextureMap[map].texture = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gameLibMaterial.maps = gameLibTextureMap;
|
|
||||||
|
|
||||||
gameLibMaterials.push(gameLibMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
var gameLibVertices = [];
|
|
||||||
|
|
||||||
for (var v = 0; v < apiMesh.vertices.length; v++) {
|
|
||||||
|
|
||||||
var boneWeights = [];
|
|
||||||
|
|
||||||
for (var bw = 0; bw < apiMesh.vertices[v].boneWeights.length; bw++) {
|
|
||||||
boneWeights.push(
|
|
||||||
new GameLib.D3.API.BoneWeight(
|
|
||||||
apiMesh.vertices[v].boneWeights[bw].boneIndex,
|
|
||||||
apiMesh.vertices[v].boneWeights[bw].weight
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
gameLibVertices.push(
|
|
||||||
new GameLib.D3.Vertex(
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiMesh.vertices[v].position.x,
|
|
||||||
apiMesh.vertices[v].position.y,
|
|
||||||
apiMesh.vertices[v].position.z
|
|
||||||
),
|
|
||||||
boneWeights
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
var gameLibMesh = new GameLib.D3.Mesh(
|
|
||||||
graphics,
|
graphics,
|
||||||
|
objectScene,
|
||||||
computeNormals,
|
computeNormals,
|
||||||
new GameLib.D3.API.Mesh(
|
GameLib.D3.ImageFactory(
|
||||||
apiMesh.id,
|
graphics,
|
||||||
apiMesh.meshType,
|
uploadUrl
|
||||||
apiMesh.name,
|
|
||||||
gameLibVertices,
|
|
||||||
apiMesh.faces,
|
|
||||||
apiMesh.faceVertexUvs,
|
|
||||||
gameLibMaterials,
|
|
||||||
apiMesh.parentMeshId,
|
|
||||||
apiMesh.parentSceneId,
|
|
||||||
apiMesh.skeleton,
|
|
||||||
apiMesh.skinIndices,
|
|
||||||
apiMesh.skinWeights,
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiMesh.position.x,
|
|
||||||
apiMesh.position.y,
|
|
||||||
apiMesh.position.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector4(
|
|
||||||
apiMesh.quaternion.x,
|
|
||||||
apiMesh.quaternion.y,
|
|
||||||
apiMesh.quaternion.z,
|
|
||||||
apiMesh.quaternion.w
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiMesh.rotation.x,
|
|
||||||
apiMesh.rotation.y,
|
|
||||||
apiMesh.rotation.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiMesh.scale.x,
|
|
||||||
apiMesh.scale.y,
|
|
||||||
apiMesh.scale.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
apiMesh.up.x,
|
|
||||||
apiMesh.up.y,
|
|
||||||
apiMesh.up.z
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
gameLibMeshes.push(gameLibMesh);
|
|
||||||
|
|
||||||
meshIdToMesh[gameLibMesh.id] = gameLibMesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cameras = [];
|
|
||||||
|
|
||||||
for (var c = 0; scene.cameras && c < scene.cameras.length; c++) {
|
|
||||||
|
|
||||||
var apiCamera = scene.cameras[c];
|
|
||||||
|
|
||||||
var camera = new GameLib.D3.Camera(
|
|
||||||
graphics,
|
|
||||||
new GameLib.D3.API.Camera(
|
|
||||||
apiCamera.id,
|
|
||||||
apiCamera.cameraType,
|
|
||||||
apiCamera.name,
|
|
||||||
apiCamera.fov,
|
|
||||||
apiCamera.aspect,
|
|
||||||
apiCamera.near,
|
|
||||||
apiCamera.far,
|
|
||||||
apiCamera.position,
|
|
||||||
apiCamera.lookAt,
|
|
||||||
apiCamera.minX,
|
|
||||||
apiCamera.maxX,
|
|
||||||
apiCamera.minY,
|
|
||||||
apiCamera.maxY,
|
|
||||||
apiCamera.minZ,
|
|
||||||
apiCamera.maxZ
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
cameras.push(camera);
|
|
||||||
}
|
|
||||||
|
|
||||||
var activeCameraIndex = scene.activeCameraIndex;
|
|
||||||
|
|
||||||
var splines = [];
|
|
||||||
|
|
||||||
for (var s = 0; scene.splines && s < scene.splines.length; s++) {
|
|
||||||
|
|
||||||
var apiSpline = scene.spline[s];
|
|
||||||
|
|
||||||
var spline = new GameLib.D3.Spline(
|
|
||||||
graphics,
|
|
||||||
new GameLib.D3.API.Spline(
|
|
||||||
apiSpline.id,
|
|
||||||
apiSpline.name,
|
|
||||||
apiSpline.vertices
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
splines.push(spline);
|
|
||||||
}
|
|
||||||
|
|
||||||
var scene3d = new GameLib.D3.Scene(
|
|
||||||
graphics,
|
|
||||||
progressCallback,
|
|
||||||
new GameLib.D3.API.Scene(
|
|
||||||
scene.id,
|
|
||||||
scene.path,
|
|
||||||
scene.name,
|
|
||||||
gameLibMeshes,
|
|
||||||
new GameLib.D3.API.Vector4(
|
|
||||||
scene.quaternion.x,
|
|
||||||
scene.quaternion.y,
|
|
||||||
scene.quaternion.z,
|
|
||||||
scene.quaternion.w
|
|
||||||
),
|
),
|
||||||
new GameLib.D3.API.Vector3(
|
progressCallback
|
||||||
scene.position.x,
|
)
|
||||||
scene.position.y,
|
|
||||||
scene.position.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
scene.rotation.x,
|
|
||||||
scene.rotation.y,
|
|
||||||
scene.rotation.z
|
|
||||||
),
|
|
||||||
new GameLib.D3.API.Vector3(
|
|
||||||
scene.scale.x,
|
|
||||||
scene.scale.y,
|
|
||||||
scene.scale.z
|
|
||||||
),
|
|
||||||
scene.parentSceneId,
|
|
||||||
lights,
|
|
||||||
worlds,
|
|
||||||
entities,
|
|
||||||
components,
|
|
||||||
shapes,
|
|
||||||
cameras,
|
|
||||||
activeCameraIndex,
|
|
||||||
splines
|
|
||||||
),
|
|
||||||
imageFactory,
|
|
||||||
meshIdToMesh
|
|
||||||
);
|
);
|
||||||
|
|
||||||
onLoaded(scene3d);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -626,7 +450,13 @@ GameLib.D3.Scene.prototype.render = function(
|
||||||
GameLib.D3.Scene.prototype.registerEntity = function(
|
GameLib.D3.Scene.prototype.registerEntity = function(
|
||||||
entity
|
entity
|
||||||
) {
|
) {
|
||||||
this.entities.push(entity);
|
if (!this.idToObject.hasOwnProperty(entity.id)) {
|
||||||
|
this.idToObject[entity.id] = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.entities.indexOf(entity) == -1) {
|
||||||
|
this.entities.push(entity);
|
||||||
|
}
|
||||||
|
|
||||||
entity.register(this);
|
entity.register(this);
|
||||||
|
|
||||||
|
@ -634,9 +464,9 @@ GameLib.D3.Scene.prototype.registerEntity = function(
|
||||||
|
|
||||||
var id = entity.ids[c];
|
var id = entity.ids[c];
|
||||||
|
|
||||||
var component = this.idToComponent[id];
|
var component = this.idToObject[id];
|
||||||
|
|
||||||
if(component) {
|
if (component) {
|
||||||
component.setParentEntity(this, entity);
|
component.setParentEntity(this, entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,8 +480,27 @@ GameLib.D3.Scene.prototype.registerEntity = function(
|
||||||
GameLib.D3.Scene.prototype.registerComponent = function(
|
GameLib.D3.Scene.prototype.registerComponent = function(
|
||||||
component
|
component
|
||||||
) {
|
) {
|
||||||
this.idToComponent[component.id] = component;
|
this.components.push(component);
|
||||||
if(component.onRegistered && typeof component.onRegistered == 'function') {
|
|
||||||
|
this.idToObject[component.id] = component;
|
||||||
|
|
||||||
|
if (component.onRegistered && typeof component.onRegistered == 'function') {
|
||||||
component.onRegistered(this);
|
component.onRegistered(this);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After we created a scene and idToObject has been created, we should execute this function to map
|
||||||
|
* the components witht their ids to the proper objects
|
||||||
|
*/
|
||||||
|
GameLib.D3.Scene.prototype.linkObjects = function() {
|
||||||
|
|
||||||
|
this.components.map(function(component) {
|
||||||
|
component.linkObjects(this.idToObject);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this.entities.map(function(entity) {
|
||||||
|
entity.linkObjects(this.idToObject);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
};
|
};
|
|
@ -181,3 +181,37 @@ GameLib.D3.Shape.prototype.update = function(
|
||||||
this.instance.updateTree();
|
this.instance.updateTree();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Shape to a GameLib.D3.API.Shape
|
||||||
|
* @returns {GameLib.D3.API.Shape}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Shape.prototype.toApiShape = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Shape(
|
||||||
|
this.engine.toApiEngine(),
|
||||||
|
this.shapeType,
|
||||||
|
this.scale.toApiVector(),
|
||||||
|
this.vertices,
|
||||||
|
this.indices,
|
||||||
|
this.radius,
|
||||||
|
this.halfExtensions,
|
||||||
|
this.radiusTop,
|
||||||
|
this.radiusBottom,
|
||||||
|
this.height,
|
||||||
|
this.numSegments,
|
||||||
|
this.heightmap.toApiHeightMap()
|
||||||
|
)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from an Object to a Shape
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectShape Object
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Shape.FromObjectShape = function(graphics, objectShape) {
|
||||||
|
//todo: implement this still
|
||||||
|
return null;
|
||||||
|
};
|
|
@ -73,6 +73,11 @@ GameLib.D3.Solver.prototype.createInstance = function(){
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Solver.prototype.toApiSolver = function() {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Solver Types
|
* Solver Types
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -62,4 +62,39 @@ GameLib.D3.Spline.prototype.getPointAt = function(proper) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Spline to GameLib.D3.API.Spline
|
||||||
|
* @returns {GameLib.D3.API.Spline}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Spline.prototype.toApiSpline = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Spline(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.vertices
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a GameLib.D3.Spline from a spline Object
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectSpline Object
|
||||||
|
* @returns {GameLib.D3.Spline}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Spline.FromObjectSpline = function(
|
||||||
|
graphics,
|
||||||
|
objectSpline
|
||||||
|
) {
|
||||||
|
|
||||||
|
return new GameLib.D3.Spline(
|
||||||
|
graphics,
|
||||||
|
new GameLib.D3.API.Spline(
|
||||||
|
objectSpline.id,
|
||||||
|
objectSpline.name,
|
||||||
|
objectSpline.vertices
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -18,4 +18,16 @@ GameLib.D3.TextureMap = function TextureMap(
|
||||||
instanceMapId = null;
|
instanceMapId = null;
|
||||||
}
|
}
|
||||||
this.instanceMapId = instanceMapId;
|
this.instanceMapId = instanceMapId;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.TextureMap.prototype.toApiTextureMap = function() {
|
||||||
|
|
||||||
|
var apiTexture = null;
|
||||||
|
|
||||||
|
if (this.texture) {
|
||||||
|
apiTexture = this.texture.toApiTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GameLib.D3.TextureMap(apiTexture, this.instanceMapId);
|
||||||
|
|
||||||
};
|
};
|
|
@ -43,3 +43,24 @@ GameLib.D3.TextureMaps = function TextureMaps(
|
||||||
this.roughness = roughness;
|
this.roughness = roughness;
|
||||||
this.specular = specular;
|
this.specular = specular;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns API textures from the Texture Maps
|
||||||
|
* @returns {GameLib.D3.TextureMaps}
|
||||||
|
*/
|
||||||
|
GameLib.D3.TextureMaps.prototype.toApiTextureMaps = function() {
|
||||||
|
return new GameLib.D3.TextureMaps(
|
||||||
|
this.alpha.toApiTextureMap(),
|
||||||
|
this.ao.toApiTextureMap(),
|
||||||
|
this.bump.toApiTextureMap(),
|
||||||
|
this.diffuse.toApiTextureMap(),
|
||||||
|
this.displacement.toApiTextureMap(),
|
||||||
|
this.emissive.toApiTextureMap(),
|
||||||
|
this.environment.toApiTextureMap(),
|
||||||
|
this.light.toApiTextureMap(),
|
||||||
|
this.metalness.toApiTextureMap(),
|
||||||
|
this.normal.toApiTextureMap(),
|
||||||
|
this.roughness.toApiTextureMap(),
|
||||||
|
this.specular.toApiTextureMap()
|
||||||
|
);
|
||||||
|
};
|
|
@ -198,6 +198,98 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
|
||||||
this.instance = this.createInstance(true);
|
this.instance = this.createInstance(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones this texture object
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
GameLib.D3.Texture.prototype.clone = function() {
|
GameLib.D3.Texture.prototype.clone = function() {
|
||||||
return _.cloneDeep(this);
|
return _.cloneDeep(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Texture to a GameLib.D3.API.Texture
|
||||||
|
* @returns {GameLib.D3.API.Texture}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Texture.prototype.toApiTexture = function() {
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Texture(
|
||||||
|
this.id,
|
||||||
|
this.typeId,
|
||||||
|
this.name,
|
||||||
|
this.imagePath,
|
||||||
|
this.wrapS,
|
||||||
|
this.wrapT,
|
||||||
|
this.repeat.toApiVector(),
|
||||||
|
this.data,
|
||||||
|
this.format,
|
||||||
|
this.mapping,
|
||||||
|
this.magFilter,
|
||||||
|
this.minFilter,
|
||||||
|
this.textureType,
|
||||||
|
this.anisotropy,
|
||||||
|
this.offset.toApiVector(),
|
||||||
|
this.generateMipmaps,
|
||||||
|
this.flipY,
|
||||||
|
this.mipmaps,
|
||||||
|
this.unpackAlignment,
|
||||||
|
this.premultiplyAlpha,
|
||||||
|
this.encoding
|
||||||
|
)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from an Object texture to a GameLib.D3.Texture
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param objectTexture Object
|
||||||
|
* @param gameLibMaterial GameLib.D3.Material
|
||||||
|
* @param map GameLib.D3.TextureMap
|
||||||
|
* @param gameLibTextureMap GameLib.D3.TextureMapTemplate
|
||||||
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Texture.FromObjectTexture = function(
|
||||||
|
graphics,
|
||||||
|
objectTexture,
|
||||||
|
gameLibMaterial,
|
||||||
|
map,
|
||||||
|
gameLibTextureMap,
|
||||||
|
imageFactory
|
||||||
|
) {
|
||||||
|
return new GameLib.D3.Texture(
|
||||||
|
new GameLib.D3.API.Texture(
|
||||||
|
objectTexture.id,
|
||||||
|
map,
|
||||||
|
objectTexture.name,
|
||||||
|
objectTexture.imagePath,
|
||||||
|
objectTexture.wrapS,
|
||||||
|
objectTexture.wrapT,
|
||||||
|
new GameLib.D3.API.Vector2(
|
||||||
|
objectTexture.repeat.x,
|
||||||
|
objectTexture.repeat.y
|
||||||
|
),
|
||||||
|
objectTexture.data,
|
||||||
|
objectTexture.format,
|
||||||
|
objectTexture.mapping,
|
||||||
|
objectTexture.magFilter,
|
||||||
|
objectTexture.minFilter,
|
||||||
|
objectTexture.textureType,
|
||||||
|
objectTexture.anisotropy,
|
||||||
|
new GameLib.D3.API.Vector2(
|
||||||
|
objectTexture.offset.x,
|
||||||
|
objectTexture.offset.y
|
||||||
|
),
|
||||||
|
objectTexture.generateMipmaps,
|
||||||
|
objectTexture.flipY,
|
||||||
|
objectTexture.mipmaps,
|
||||||
|
objectTexture.unpackAlignment,
|
||||||
|
objectTexture.premultiplyAlpha,
|
||||||
|
objectTexture.encoding
|
||||||
|
),
|
||||||
|
graphics,
|
||||||
|
gameLibMaterial,
|
||||||
|
gameLibTextureMap[map].instanceMapId,
|
||||||
|
imageFactory
|
||||||
|
);
|
||||||
};
|
};
|
|
@ -16,6 +16,44 @@ GameLib.D3.Utils.UndefinedOrNull = function (
|
||||||
return typeof variable == 'undefined' || variable == null;
|
return typeof variable == 'undefined' || variable == null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns either an ID of the object or Null
|
||||||
|
* @param object
|
||||||
|
* @returns {null}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Utils.IdOrNull = function (object) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(object)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(object.id)) {
|
||||||
|
console.warn('saving an object reference with no ID : ', object);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return object.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Links an object to its parent through idToObject array
|
||||||
|
* @param propertyString
|
||||||
|
* @param idToObject
|
||||||
|
* @param parentObject
|
||||||
|
* @param id
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Utils.Link = function(propertyString, idToObject, parentObject, id) {
|
||||||
|
|
||||||
|
if (!GameLib.D3.Utils.UndefinedOrNull(parentObject[propertyString])) {
|
||||||
|
|
||||||
|
if (!idToObject.hasOwnProperty(id)) {
|
||||||
|
console.warn('camera linking failed for object:' + parentObject.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
parentObject[propertyString] = idToObject[id];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.D3.Utils.Raycast = function (
|
GameLib.D3.Utils.Raycast = function (
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
|
@ -303,7 +341,7 @@ GameLib.D3.Utils.FixPolyZPlane = function(verticesFlat, grain) {
|
||||||
|
|
||||||
var vertices = [];
|
var vertices = [];
|
||||||
|
|
||||||
var points = new GameLib.D3.API.Vector4.Points();
|
var points = new GameLib.D3.API.Quaternion.Points();
|
||||||
|
|
||||||
for (var i = 0; i < verticesFlat.length; i += 3) {
|
for (var i = 0; i < verticesFlat.length; i += 3) {
|
||||||
points.add(new GameLib.D3.API.Vector3(
|
points.add(new GameLib.D3.API.Vector3(
|
||||||
|
|
|
@ -80,6 +80,34 @@ GameLib.D3.World.prototype.createInstance = function() {
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.World.prototype.toApiWorld = function() {
|
||||||
|
//TODO: create API.World someday
|
||||||
|
return {
|
||||||
|
id: this.id,
|
||||||
|
name: this.name,
|
||||||
|
engine: this.engine.toApiEngine(),
|
||||||
|
gravity: this.gravity,
|
||||||
|
broadphase: this.broadphase.toApiBroadphase(),
|
||||||
|
solver: this.solver.toApiSolver(),
|
||||||
|
rigidBodies: this.rigidBodies.map(function(rigidBody){return rigidBody.toApiRigidBody()})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.World.FromObjectWorld = function(engine, objectWorld) {
|
||||||
|
|
||||||
|
//todo implement this fully
|
||||||
|
return new GameLib.D3.World(
|
||||||
|
objectWorld.id,
|
||||||
|
objectWorld.name,
|
||||||
|
engine,
|
||||||
|
objectWorld.gravity,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param rigidBody GameLib.D3.RigidBody
|
* @param rigidBody GameLib.D3.RigidBody
|
||||||
|
|
Loading…
Reference in New Issue