api and runtime namespaces
parent
658c045a6f
commit
48cb9e477d
|
@ -1,11 +1,33 @@
|
||||||
|
/**
|
||||||
|
* GameLib Namespace
|
||||||
|
*/
|
||||||
if (typeof GameLib == 'undefined') {
|
if (typeof GameLib == 'undefined') {
|
||||||
function GameLib() {}
|
function GameLib() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameLib.D3 Namespace
|
||||||
|
*/
|
||||||
if (typeof GameLib.D3 == 'undefined') {
|
if (typeof GameLib.D3 == 'undefined') {
|
||||||
GameLib.D3 = function(){};
|
GameLib.D3 = function(){};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API Namespace
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
if (typeof GameLib.D3.API == 'undefined') {
|
||||||
|
GameLib.D3.API = function(){};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameLib.D3.Runtime Namespace
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
if (typeof GameLib.D3.Runtime == 'undefined') {
|
||||||
|
GameLib.D3.Runtime = function(){};
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof Q == 'undefined') {
|
if (typeof Q == 'undefined') {
|
||||||
|
|
||||||
if (typeof require == 'undefined') {
|
if (typeof require == 'undefined') {
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/**
|
||||||
|
* Raw Camera API object - should always correspond with the Camera Schema
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
* @param cameraType GameLib.D3.Camera.CAMERA_TYPE_*
|
||||||
|
* @param fov
|
||||||
|
* @param aspect
|
||||||
|
* @param near
|
||||||
|
* @param far
|
||||||
|
* @param position GameLib.D3.Vector3
|
||||||
|
* @param lookAt GameLib.D3.Vector3
|
||||||
|
* @param minX
|
||||||
|
* @param maxX
|
||||||
|
* @param minY
|
||||||
|
* @param maxY
|
||||||
|
* @param minZ
|
||||||
|
* @param maxZ
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Camera = function(
|
||||||
|
id,
|
||||||
|
cameraType,
|
||||||
|
name,
|
||||||
|
fov,
|
||||||
|
aspect,
|
||||||
|
near,
|
||||||
|
far,
|
||||||
|
position,
|
||||||
|
lookAt,
|
||||||
|
minX,
|
||||||
|
maxX,
|
||||||
|
minY,
|
||||||
|
maxY,
|
||||||
|
minZ,
|
||||||
|
maxZ
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(cameraType)) {
|
||||||
|
cameraType = GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE;
|
||||||
|
}
|
||||||
|
this.cameraType = cameraType;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'Camera (' + cameraType + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(fov)) {
|
||||||
|
fov = 75;
|
||||||
|
}
|
||||||
|
this.fov = fov;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(aspect)) {
|
||||||
|
aspect = window.innerWidth / window.innerHeight;
|
||||||
|
}
|
||||||
|
this.aspect = aspect;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(near)) {
|
||||||
|
near = 0.1;
|
||||||
|
}
|
||||||
|
this.near = near;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(far)) {
|
||||||
|
far = 1000;
|
||||||
|
}
|
||||||
|
this.far = far;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
|
position = new GameLib.D3.Vector3(
|
||||||
|
15,
|
||||||
|
15,
|
||||||
|
15
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lookAt)) {
|
||||||
|
lookAt = new GameLib.D3.Vector3(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.lookAt = lookAt;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(minX)) {
|
||||||
|
minX = -100;
|
||||||
|
}
|
||||||
|
this.minX = minX;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maxX)) {
|
||||||
|
maxX = 100;
|
||||||
|
}
|
||||||
|
this.maxX = maxX;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(minY)) {
|
||||||
|
minY = -100;
|
||||||
|
}
|
||||||
|
this.minY = minY;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maxY)) {
|
||||||
|
maxY = 100;
|
||||||
|
}
|
||||||
|
this.maxY = maxY;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(minZ)) {
|
||||||
|
minZ = -100;
|
||||||
|
}
|
||||||
|
this.minZ = minZ;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maxZ)) {
|
||||||
|
maxZ = 100;
|
||||||
|
}
|
||||||
|
this.maxZ = maxZ;
|
||||||
|
};
|
|
@ -0,0 +1,266 @@
|
||||||
|
/**
|
||||||
|
* Superset for storing Components to API, and generating them from componentType
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
* @param componentType
|
||||||
|
* @param camera
|
||||||
|
* @param startColor
|
||||||
|
* @param endColor
|
||||||
|
* @param lerpSpeed
|
||||||
|
* @param targetEntity
|
||||||
|
* @param targetOffset
|
||||||
|
* @param minDistance
|
||||||
|
* @param moveSpeed
|
||||||
|
* @param rotationSpeed
|
||||||
|
* @param positionOffset
|
||||||
|
* @param quaternionOffset
|
||||||
|
* @param scaleOffset
|
||||||
|
* @param sensorLength
|
||||||
|
* @param spline
|
||||||
|
* @param normalSpline
|
||||||
|
* @param acceleration
|
||||||
|
* @param maxSpeed
|
||||||
|
* @param baseOffset
|
||||||
|
* @param maxOffset
|
||||||
|
* @param steeringSpeed
|
||||||
|
* @param frontLWheelIndex
|
||||||
|
* @param frontRWheelIndex
|
||||||
|
* @param backLWheelIndex
|
||||||
|
* @param backRWheelIndex
|
||||||
|
* @param maxForce
|
||||||
|
* @param steering
|
||||||
|
* @param entitiesToCheck
|
||||||
|
* @param onInside
|
||||||
|
* @param onEnter
|
||||||
|
* @param onLeave
|
||||||
|
* @param onSetParent
|
||||||
|
* @param sphereRadius
|
||||||
|
* @param world
|
||||||
|
* @param maxSteerAngle
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.ComponentInterface = function(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
componentType,
|
||||||
|
camera,
|
||||||
|
startColor,
|
||||||
|
endColor,
|
||||||
|
lerpSpeed,
|
||||||
|
targetEntity,
|
||||||
|
targetOffset,
|
||||||
|
minDistance,
|
||||||
|
moveSpeed,
|
||||||
|
rotationSpeed,
|
||||||
|
positionOffset,
|
||||||
|
quaternionOffset,
|
||||||
|
scaleOffset,
|
||||||
|
sensorLength,
|
||||||
|
spline,
|
||||||
|
normalSpline,
|
||||||
|
acceleration,
|
||||||
|
maxSpeed,
|
||||||
|
baseOffset,
|
||||||
|
maxOffset,
|
||||||
|
steeringSpeed,
|
||||||
|
frontLWheelIndex,
|
||||||
|
frontRWheelIndex,
|
||||||
|
backLWheelIndex,
|
||||||
|
backRWheelIndex,
|
||||||
|
maxForce,
|
||||||
|
steering,
|
||||||
|
entitiesToCheck,
|
||||||
|
onInside,
|
||||||
|
onEnter,
|
||||||
|
onLeave,
|
||||||
|
onSetParent,
|
||||||
|
sphereRadius,
|
||||||
|
world,
|
||||||
|
maxSteerAngle
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'component-unnamed';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(componentType)) {
|
||||||
|
componentType = GameLib.D3.ComponentInterface.COMPONENT_INTERFACE;
|
||||||
|
}
|
||||||
|
this.componentType = componentType;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(camera)) {
|
||||||
|
camera = null;
|
||||||
|
}
|
||||||
|
this.camera = camera;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(startColor)) {
|
||||||
|
startColor = new GameLib.D3.Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
this.startColor = startColor;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(endColor)) {
|
||||||
|
endColor = new GameLib.D3.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)) {
|
||||||
|
targetEntity = null;
|
||||||
|
}
|
||||||
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
|
targetOffset = new GameLib.D3.Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(minDistance)) {
|
||||||
|
minDistance = 0;
|
||||||
|
}
|
||||||
|
this.minDistance = minDistance;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(moveSpeed)) {
|
||||||
|
moveSpeed = 12.5;
|
||||||
|
}
|
||||||
|
this.moveSpeed = moveSpeed;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(rotationSpeed)) {
|
||||||
|
rotationSpeed = 22.0;
|
||||||
|
}
|
||||||
|
this.rotationSpeed = rotationSpeed;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(positionOffset)) {
|
||||||
|
positionOffset = new GameLib.D3.Vector3();
|
||||||
|
}
|
||||||
|
this.positionOffset = positionOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
||||||
|
quaternionOffset = new GameLib.D3.Vector4();
|
||||||
|
}
|
||||||
|
this.quaternionOffset = quaternionOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
||||||
|
scaleOffset = new GameLib.D3.Vector3();
|
||||||
|
}
|
||||||
|
this.scaleOffset = scaleOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(sensorLength)) {
|
||||||
|
sensorLength = 5;
|
||||||
|
}
|
||||||
|
this.sensorLength = sensorLength;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(spline)) {
|
||||||
|
spline = new GameLib.D3.API.Spline(null, 'spline');
|
||||||
|
}
|
||||||
|
this.spline = spline;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(normalSpline)) {
|
||||||
|
normalSpline = new GameLib.D3.API.Spline(null, 'normal-spline');
|
||||||
|
}
|
||||||
|
this.normalSpline = normalSpline;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(acceleration)) {
|
||||||
|
acceleration = 2.0;
|
||||||
|
}
|
||||||
|
this.acceleration = acceleration;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maxSpeed)) {
|
||||||
|
maxSpeed = 10.0;
|
||||||
|
}
|
||||||
|
this.maxSpeed = maxSpeed;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(baseOffset)) {
|
||||||
|
baseOffset = new GameLib.D3.Vector3();
|
||||||
|
}
|
||||||
|
this.baseOffset = baseOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maxOffset)) {
|
||||||
|
maxOffset = new GameLib.D3.Vector3(10, 10, 10);
|
||||||
|
}
|
||||||
|
this.maxOffset = maxOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(steeringSpeed)) {
|
||||||
|
steeringSpeed = 1.0;
|
||||||
|
}
|
||||||
|
this.steeringSpeed = steeringSpeed;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(frontLWheelIndex)) {
|
||||||
|
frontLWheelIndex = 1;
|
||||||
|
}
|
||||||
|
this.frontLWheelIndex = frontLWheelIndex;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(frontRWheelIndex)) {
|
||||||
|
frontRWheelIndex = 2;
|
||||||
|
}
|
||||||
|
this.frontRWheelIndex = frontRWheelIndex;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(backLWheelIndex)) {
|
||||||
|
backLWheelIndex = 3;
|
||||||
|
}
|
||||||
|
this.backLWheelIndex = backLWheelIndex;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(backRWheelIndex)) {
|
||||||
|
backRWheelIndex = 4;
|
||||||
|
}
|
||||||
|
this.backRWheelIndex = backRWheelIndex;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maxForce)) {
|
||||||
|
maxForce = 400;
|
||||||
|
}
|
||||||
|
this.maxForce = maxForce;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* Entity API
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
* @param ids
|
||||||
|
* @param position
|
||||||
|
* @param quaternion
|
||||||
|
* @param scale
|
||||||
|
* @param parentScene
|
||||||
|
* @param mesh
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Entity = function Entity(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
ids,
|
||||||
|
position,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
parentScene,
|
||||||
|
mesh
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = this.constructor.name;
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(ids)) {
|
||||||
|
ids = [];
|
||||||
|
}
|
||||||
|
this.ids = ids;
|
||||||
|
|
||||||
|
if(GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
|
position = new GameLib.D3.Vector3();
|
||||||
|
}
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
|
quaternion = new GameLib.D3.Vector4();
|
||||||
|
}
|
||||||
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
|
scale = new GameLib.D3.Vector3(1, 1, 1);
|
||||||
|
}
|
||||||
|
this.scale = scale;
|
||||||
|
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(parentScene)) {
|
||||||
|
parentScene = null;
|
||||||
|
}
|
||||||
|
this.parentScene = parentScene;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(mesh)) {
|
||||||
|
mesh = null;
|
||||||
|
}
|
||||||
|
this.mesh = mesh;
|
||||||
|
};
|
|
@ -0,0 +1,111 @@
|
||||||
|
/**
|
||||||
|
* Raw Light API object - should always correspond with the Light Schema
|
||||||
|
* @param id
|
||||||
|
* @param lightType
|
||||||
|
* @param name
|
||||||
|
* @param color
|
||||||
|
* @param intensity
|
||||||
|
* @param position
|
||||||
|
* @param targetPosition
|
||||||
|
* @param quaternion
|
||||||
|
* @param rotation
|
||||||
|
* @param scale
|
||||||
|
* @param distance
|
||||||
|
* @param decay
|
||||||
|
* @param power
|
||||||
|
* @param angle
|
||||||
|
* @param penumbra
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Light = function(
|
||||||
|
id,
|
||||||
|
lightType,
|
||||||
|
name,
|
||||||
|
color,
|
||||||
|
intensity,
|
||||||
|
position,
|
||||||
|
targetPosition,
|
||||||
|
quaternion,
|
||||||
|
rotation,
|
||||||
|
scale,
|
||||||
|
distance,
|
||||||
|
decay,
|
||||||
|
power,
|
||||||
|
angle,
|
||||||
|
penumbra
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lightType)) {
|
||||||
|
lightType = GameLib.D3.Light.LIGHT_TYPE_AMBIENT;
|
||||||
|
}
|
||||||
|
this.lightType = lightType;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'Light (' + lightType + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
||||||
|
color = new GameLib.D3.Color(1,1,1,1);
|
||||||
|
}
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(intensity)) {
|
||||||
|
intensity = 1;
|
||||||
|
}
|
||||||
|
this.intensity = intensity;
|
||||||
|
|
||||||
|
if (typeof position == 'undefined') {
|
||||||
|
position = new GameLib.D3.Vector3(0,10,0);
|
||||||
|
}
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
if (typeof targetPosition == 'undefined') {
|
||||||
|
targetPosition = new GameLib.D3.Vector3(0,0,0);
|
||||||
|
}
|
||||||
|
this.targetPosition = targetPosition;
|
||||||
|
|
||||||
|
if (typeof quaternion == 'undefined'){
|
||||||
|
quaternion = new GameLib.D3.Vector4();
|
||||||
|
}
|
||||||
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
if (typeof rotation == 'undefined'){
|
||||||
|
rotation = new GameLib.D3.Vector3(0,0,0);
|
||||||
|
}
|
||||||
|
this.rotation = rotation;
|
||||||
|
|
||||||
|
if (typeof scale == 'undefined'){
|
||||||
|
scale = new GameLib.D3.Vector3(1,1,1);
|
||||||
|
}
|
||||||
|
this.scale = scale;
|
||||||
|
|
||||||
|
if (typeof distance == 'undefined'){
|
||||||
|
distance = 0;
|
||||||
|
}
|
||||||
|
this.distance = distance;
|
||||||
|
|
||||||
|
if (typeof decay == 'undefined'){
|
||||||
|
decay = 1;
|
||||||
|
}
|
||||||
|
this.decay = decay;
|
||||||
|
|
||||||
|
if (typeof power == 'undefined'){
|
||||||
|
power = 4 * Math.PI;
|
||||||
|
}
|
||||||
|
this.power = power;
|
||||||
|
|
||||||
|
if (typeof angle == 'undefined'){
|
||||||
|
angle = Math.PI / 3;
|
||||||
|
}
|
||||||
|
this.angle = angle;
|
||||||
|
|
||||||
|
if (typeof penumbra == 'undefined'){
|
||||||
|
penumbra = 0;
|
||||||
|
}
|
||||||
|
this.penumbra = penumbra;
|
||||||
|
};
|
|
@ -0,0 +1,405 @@
|
||||||
|
/**
|
||||||
|
* Raw material API object - should always correspond with the Material Schema
|
||||||
|
* @param id
|
||||||
|
* @param materialType
|
||||||
|
* @param name
|
||||||
|
* @param opacity
|
||||||
|
* @param side
|
||||||
|
* @param transparent
|
||||||
|
* @param maps
|
||||||
|
* @param specular
|
||||||
|
* @param lightMapIntensity
|
||||||
|
* @param aoMapIntensity
|
||||||
|
* @param color
|
||||||
|
* @param emissive
|
||||||
|
* @param emissiveIntensity
|
||||||
|
* @param combine
|
||||||
|
* @param shininess
|
||||||
|
* @param reflectivity
|
||||||
|
* @param refractionRatio
|
||||||
|
* @param fog
|
||||||
|
* @param wireframe
|
||||||
|
* @param wireframeLineWidth
|
||||||
|
* @param wireframeLineCap
|
||||||
|
* @param wireframeLineJoin
|
||||||
|
* @param vertexColors
|
||||||
|
* @param skinning
|
||||||
|
* @param morphTargets
|
||||||
|
* @param morphNormals
|
||||||
|
* @param lineWidth
|
||||||
|
* @param lineCap
|
||||||
|
* @param lineJoin
|
||||||
|
* @param dashSize
|
||||||
|
* @param gapWidth
|
||||||
|
* @param blending
|
||||||
|
* @param blendSrc
|
||||||
|
* @param blendDst
|
||||||
|
* @param blendEquation
|
||||||
|
* @param depthTest
|
||||||
|
* @param depthFunc
|
||||||
|
* @param depthWrite
|
||||||
|
* @param polygonOffset
|
||||||
|
* @param polygonOffsetFactor
|
||||||
|
* @param polygonOffsetUnits
|
||||||
|
* @param alphaTest
|
||||||
|
* @param clippingPlanes
|
||||||
|
* @param clipShadows
|
||||||
|
* @param visible
|
||||||
|
* @param overdraw
|
||||||
|
* @param shading
|
||||||
|
* @param bumpScale
|
||||||
|
* @param normalScale
|
||||||
|
* @param displacementScale
|
||||||
|
* @param displacementBias
|
||||||
|
* @param roughness
|
||||||
|
* @param metalness
|
||||||
|
* @param pointSize
|
||||||
|
* @param pointSizeAttenuation
|
||||||
|
* @param spriteRotation
|
||||||
|
* @param envMapIntensity
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Material = function(
|
||||||
|
id,
|
||||||
|
materialType,
|
||||||
|
name,
|
||||||
|
opacity,
|
||||||
|
side,
|
||||||
|
transparent,
|
||||||
|
maps,
|
||||||
|
specular,
|
||||||
|
lightMapIntensity,
|
||||||
|
aoMapIntensity,
|
||||||
|
color,
|
||||||
|
emissive,
|
||||||
|
emissiveIntensity,
|
||||||
|
combine,
|
||||||
|
shininess,
|
||||||
|
reflectivity,
|
||||||
|
refractionRatio,
|
||||||
|
fog,
|
||||||
|
wireframe,
|
||||||
|
wireframeLineWidth,
|
||||||
|
wireframeLineCap,
|
||||||
|
wireframeLineJoin,
|
||||||
|
vertexColors,
|
||||||
|
skinning,
|
||||||
|
morphTargets,
|
||||||
|
morphNormals,
|
||||||
|
lineWidth,
|
||||||
|
lineCap,
|
||||||
|
lineJoin,
|
||||||
|
dashSize,
|
||||||
|
gapWidth,
|
||||||
|
blending,
|
||||||
|
blendSrc,
|
||||||
|
blendDst,
|
||||||
|
blendEquation,
|
||||||
|
depthTest,
|
||||||
|
depthFunc,
|
||||||
|
depthWrite,
|
||||||
|
polygonOffset,
|
||||||
|
polygonOffsetFactor,
|
||||||
|
polygonOffsetUnits,
|
||||||
|
alphaTest,
|
||||||
|
clippingPlanes,
|
||||||
|
clipShadows,
|
||||||
|
visible,
|
||||||
|
overdraw,
|
||||||
|
shading,
|
||||||
|
bumpScale,
|
||||||
|
normalScale,
|
||||||
|
displacementScale,
|
||||||
|
displacementBias,
|
||||||
|
roughness,
|
||||||
|
metalness,
|
||||||
|
pointSize,
|
||||||
|
pointSizeAttenuation,
|
||||||
|
spriteRotation,
|
||||||
|
envMapIntensity
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(materialType)) {
|
||||||
|
materialType = GameLib.D3.Material.MATERIAL_TYPE_STANDARD;
|
||||||
|
}
|
||||||
|
this.materialType = materialType;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'Material (' + materialType + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(opacity)) {
|
||||||
|
opacity = 1.0;
|
||||||
|
}
|
||||||
|
this.opacity = opacity;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(side)) {
|
||||||
|
side = GameLib.D3.Material.TYPE_FRONT_SIDE;
|
||||||
|
}
|
||||||
|
this.side = side;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(transparent)) {
|
||||||
|
transparent = false;
|
||||||
|
}
|
||||||
|
this.transparent = transparent;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(maps)) {
|
||||||
|
maps = GameLib.D3.API.TextureMapTemplate();
|
||||||
|
}
|
||||||
|
this.maps = maps;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(specular)) {
|
||||||
|
specular = new GameLib.D3.Color(0.06, 0.06, 0.06, 0.06);
|
||||||
|
}
|
||||||
|
this.specular = specular;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lightMapIntensity)) {
|
||||||
|
lightMapIntensity = 1;
|
||||||
|
}
|
||||||
|
this.lightMapIntensity = lightMapIntensity;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(aoMapIntensity)) {
|
||||||
|
aoMapIntensity = 1;
|
||||||
|
}
|
||||||
|
this.aoMapIntensity = aoMapIntensity;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
||||||
|
color = new GameLib.D3.Color(1, 1, 1, 1)
|
||||||
|
}
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(emissive)) {
|
||||||
|
emissive = new GameLib.D3.Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
this.emissive = emissive;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(emissiveIntensity)) {
|
||||||
|
emissiveIntensity = 1;
|
||||||
|
}
|
||||||
|
this.emissiveIntensity = emissiveIntensity;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(combine)) {
|
||||||
|
combine = GameLib.D3.Material.TYPE_MULTIPLY_OPERATION;
|
||||||
|
}
|
||||||
|
this.combine = combine;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(shininess)) {
|
||||||
|
shininess = 30;
|
||||||
|
}
|
||||||
|
this.shininess = shininess;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(reflectivity)) {
|
||||||
|
reflectivity = 1;
|
||||||
|
}
|
||||||
|
this.reflectivity = reflectivity;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(refractionRatio)) {
|
||||||
|
refractionRatio = 0.98;
|
||||||
|
}
|
||||||
|
this.refractionRatio = refractionRatio;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(fog)) {
|
||||||
|
fog = true;
|
||||||
|
}
|
||||||
|
this.fog = fog;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(wireframe)) {
|
||||||
|
wireframe = false;
|
||||||
|
}
|
||||||
|
this.wireframe = wireframe;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(wireframeLineWidth)) {
|
||||||
|
wireframeLineWidth = 1;
|
||||||
|
}
|
||||||
|
this.wireframeLineWidth = wireframeLineWidth;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(wireframeLineCap)) {
|
||||||
|
wireframeLineCap = 'round';
|
||||||
|
}
|
||||||
|
this.wireframeLineCap = wireframeLineCap;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(wireframeLineJoin)) {
|
||||||
|
wireframeLineJoin = 'round';
|
||||||
|
}
|
||||||
|
this.wireframeLineJoin = wireframeLineJoin;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(vertexColors)) {
|
||||||
|
vertexColors = GameLib.D3.Material.TYPE_NO_COLORS;
|
||||||
|
}
|
||||||
|
this.vertexColors = vertexColors;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(skinning)) {
|
||||||
|
skinning = false;
|
||||||
|
}
|
||||||
|
this.skinning = skinning;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(morphTargets)) {
|
||||||
|
morphTargets = false;
|
||||||
|
}
|
||||||
|
this.morphTargets = morphTargets;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(morphNormals)) {
|
||||||
|
morphNormals = false;
|
||||||
|
}
|
||||||
|
this.morphNormals = morphNormals;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(overdraw)) {
|
||||||
|
overdraw = 0;
|
||||||
|
}
|
||||||
|
this.overdraw = overdraw;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lineWidth)) {
|
||||||
|
lineWidth = 1;
|
||||||
|
}
|
||||||
|
this.lineWidth = lineWidth;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lineCap)) {
|
||||||
|
lineCap = 'round';
|
||||||
|
}
|
||||||
|
this.lineCap = lineCap;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lineJoin)) {
|
||||||
|
lineJoin = 'round';
|
||||||
|
}
|
||||||
|
this.lineJoin = lineJoin;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(dashSize)) {
|
||||||
|
dashSize = 3;
|
||||||
|
}
|
||||||
|
this.dashSize = dashSize;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(gapWidth)) {
|
||||||
|
gapWidth = 1;
|
||||||
|
}
|
||||||
|
this.gapWidth = gapWidth;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(blending)) {
|
||||||
|
blending = GameLib.D3.Material.TYPE_NORMAL_BLENDING;
|
||||||
|
}
|
||||||
|
this.blending = blending;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(blendSrc)) {
|
||||||
|
blendSrc = GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR;
|
||||||
|
}
|
||||||
|
this.blendSrc = blendSrc;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(blendDst)) {
|
||||||
|
blendDst = GameLib.D3.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR;
|
||||||
|
}
|
||||||
|
this.blendDst = blendDst;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(blendEquation)) {
|
||||||
|
blendEquation = GameLib.D3.Material.TYPE_ADD_EQUATION;
|
||||||
|
}
|
||||||
|
this.blendEquation = blendEquation;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(depthTest)) {
|
||||||
|
depthTest = true;
|
||||||
|
}
|
||||||
|
this.depthTest = depthTest;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(depthFunc)) {
|
||||||
|
depthFunc = GameLib.D3.Material.TYPE_LESS_EQUAL_DEPTH;
|
||||||
|
}
|
||||||
|
this.depthFunc = depthFunc;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(depthWrite)) {
|
||||||
|
depthWrite = true;
|
||||||
|
}
|
||||||
|
this.depthWrite = depthWrite;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(polygonOffset)) {
|
||||||
|
polygonOffset = false;
|
||||||
|
}
|
||||||
|
this.polygonOffset = polygonOffset;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(polygonOffsetFactor)) {
|
||||||
|
polygonOffsetFactor = 1;
|
||||||
|
}
|
||||||
|
this.polygonOffsetFactor = polygonOffsetFactor;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(polygonOffsetUnits)) {
|
||||||
|
polygonOffsetUnits = 1;
|
||||||
|
}
|
||||||
|
this.polygonOffsetUnits = polygonOffsetUnits;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(alphaTest)) {
|
||||||
|
alphaTest = 0;
|
||||||
|
}
|
||||||
|
this.alphaTest = alphaTest;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(clippingPlanes)) {
|
||||||
|
clippingPlanes = [];
|
||||||
|
}
|
||||||
|
this.clippingPlanes = clippingPlanes;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(clipShadows)) {
|
||||||
|
clipShadows = false;
|
||||||
|
}
|
||||||
|
this.clipShadows = clipShadows;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(visible)) {
|
||||||
|
visible = true;
|
||||||
|
}
|
||||||
|
this.visible = visible;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(shading)) {
|
||||||
|
shading = GameLib.D3.Material.TYPE_FLAT_SHADING;
|
||||||
|
}
|
||||||
|
this.shading = shading;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(bumpScale)) {
|
||||||
|
bumpScale = 1;
|
||||||
|
}
|
||||||
|
this.bumpScale = bumpScale;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(normalScale)) {
|
||||||
|
normalScale = 1;
|
||||||
|
}
|
||||||
|
this.normalScale = normalScale;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(displacementScale)) {
|
||||||
|
displacementScale = 1;
|
||||||
|
}
|
||||||
|
this.displacementScale = displacementScale;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(displacementBias)) {
|
||||||
|
displacementBias = 0;
|
||||||
|
}
|
||||||
|
this.displacementBias = displacementBias;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(roughness)) {
|
||||||
|
roughness = 0.5;
|
||||||
|
}
|
||||||
|
this.roughness = roughness;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(metalness)) {
|
||||||
|
metalness = 0.5;
|
||||||
|
}
|
||||||
|
this.metalness = metalness;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(pointSize)) {
|
||||||
|
pointSize = 1;
|
||||||
|
}
|
||||||
|
this.pointSize = pointSize;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(pointSizeAttenuation)) {
|
||||||
|
pointSizeAttenuation = true;
|
||||||
|
}
|
||||||
|
this.pointSizeAttenuation = pointSizeAttenuation;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(spriteRotation)) {
|
||||||
|
spriteRotation = 0;
|
||||||
|
}
|
||||||
|
this.spriteRotation = spriteRotation;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(envMapIntensity)) {
|
||||||
|
envMapIntensity = 1.0;
|
||||||
|
}
|
||||||
|
this.envMapIntensity = envMapIntensity;
|
||||||
|
};
|
|
@ -0,0 +1,125 @@
|
||||||
|
/**
|
||||||
|
* Raw Mesh API object - should always correspond with the Mesh Schema
|
||||||
|
* @param id
|
||||||
|
* @param meshType
|
||||||
|
* @param name
|
||||||
|
* @param vertices GameLib.D3.Vertex[]
|
||||||
|
* @param faces GameLib.D3.TriangleFace[]
|
||||||
|
* @param faceVertexUvs
|
||||||
|
* @param materials GameLib.D3.API.Material[]
|
||||||
|
* @param parentMeshId
|
||||||
|
* @param parentSceneId
|
||||||
|
* @param skeleton
|
||||||
|
* @param skinIndices
|
||||||
|
* @param skinWeights
|
||||||
|
* @param position GameLib.D3.Vector3
|
||||||
|
* @param quaternion GameLib.D3.Vector4
|
||||||
|
* @param rotation GameLib.D3.Vector3
|
||||||
|
* @param scale GameLib.D3.Vector3
|
||||||
|
* @param up
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Mesh = function(
|
||||||
|
id,
|
||||||
|
meshType,
|
||||||
|
name,
|
||||||
|
vertices,
|
||||||
|
faces,
|
||||||
|
faceVertexUvs,
|
||||||
|
materials,
|
||||||
|
parentMeshId,
|
||||||
|
parentSceneId,
|
||||||
|
skeleton,
|
||||||
|
skinIndices,
|
||||||
|
skinWeights,
|
||||||
|
position,
|
||||||
|
quaternion,
|
||||||
|
rotation,
|
||||||
|
scale,
|
||||||
|
up
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(meshType)) {
|
||||||
|
meshType = GameLib.D3.Mesh.TYPE_NORMAL;
|
||||||
|
}
|
||||||
|
this.meshType = meshType;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'Mesh (' + meshType + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(vertices)) {
|
||||||
|
throw new Error('Cannot create a mesh with no vertices');
|
||||||
|
}
|
||||||
|
this.vertices = vertices;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(faces)) {
|
||||||
|
throw new Error('Cannot create a mesh with no faces');
|
||||||
|
}
|
||||||
|
this.faces = faces;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(parentMeshId)) {
|
||||||
|
parentMeshId = null;
|
||||||
|
}
|
||||||
|
this.parentMeshId = parentMeshId;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(parentSceneId)) {
|
||||||
|
parentSceneId = null;
|
||||||
|
}
|
||||||
|
this.parentSceneId = parentSceneId;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(skeleton)) {
|
||||||
|
skeleton = null;
|
||||||
|
}
|
||||||
|
this.skeleton = skeleton;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(faceVertexUvs)) {
|
||||||
|
faceVertexUvs = [];
|
||||||
|
}
|
||||||
|
this.faceVertexUvs = faceVertexUvs;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(skinIndices)) {
|
||||||
|
skinIndices = [];
|
||||||
|
}
|
||||||
|
this.skinIndices = skinIndices;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(skinWeights)) {
|
||||||
|
skinWeights = [];
|
||||||
|
}
|
||||||
|
this.skinWeights = skinWeights;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(materials)) {
|
||||||
|
materials = [];
|
||||||
|
}
|
||||||
|
this.materials = materials;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
|
position = new GameLib.D3.Vector3(0,0,0);
|
||||||
|
}
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
|
quaternion = new GameLib.D3.Vector4();
|
||||||
|
}
|
||||||
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
||||||
|
rotation = new GameLib.D3.Vector3(0,0,0);
|
||||||
|
}
|
||||||
|
this.rotation = rotation;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
|
scale = new GameLib.D3.Vector3(1,1,1);
|
||||||
|
}
|
||||||
|
this.scale = scale;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(up)) {
|
||||||
|
up = new GameLib.D3.Vector3(0,1,0);
|
||||||
|
}
|
||||||
|
this.up = up;
|
||||||
|
};
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* Raw Scene API object - should always correspond with the Scene Schema
|
||||||
|
* @param id String
|
||||||
|
* @param path String
|
||||||
|
* @param name String
|
||||||
|
* @param meshes GameLib.D3.API.Mesh []
|
||||||
|
* @param quaternion GameLib.D3.Vector4
|
||||||
|
* @param position GameLib.D3.Vector3
|
||||||
|
* @param rotation GameLib.D3.Vector3
|
||||||
|
* @param scale GameLib.D3.Vector3
|
||||||
|
* @param parentSceneId
|
||||||
|
* @param lights GameLib.D3.API.Light[]
|
||||||
|
* @param worlds GameLib.D3.API.World[]
|
||||||
|
* @param entities GameLib.D3.API.Entity[]
|
||||||
|
* @param components GameLib.D3.API.Component[]
|
||||||
|
* @param shapes GameLib.D3.API.Shape[]
|
||||||
|
* @param cameras
|
||||||
|
* @param activeCameraIndex
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Scene = function(
|
||||||
|
id,
|
||||||
|
path,
|
||||||
|
name,
|
||||||
|
meshes,
|
||||||
|
quaternion,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
scale,
|
||||||
|
parentSceneId,
|
||||||
|
lights,
|
||||||
|
worlds,
|
||||||
|
entities,
|
||||||
|
components,
|
||||||
|
shapes,
|
||||||
|
cameras,
|
||||||
|
activeCameraIndex,
|
||||||
|
splines
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(path)) {
|
||||||
|
path = null;
|
||||||
|
}
|
||||||
|
this.path = path;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'unnamed';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(meshes)) {
|
||||||
|
meshes = [];
|
||||||
|
}
|
||||||
|
this.meshes = meshes;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
|
quaternion = new GameLib.D3.Vector4();
|
||||||
|
}
|
||||||
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
|
position = new GameLib.D3.Vector3();
|
||||||
|
}
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
||||||
|
rotation = new GameLib.D3.Vector3();
|
||||||
|
}
|
||||||
|
this.rotation = rotation;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
|
scale = new GameLib.D3.Vector3(1,1,1);
|
||||||
|
}
|
||||||
|
this.scale = scale;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(parentSceneId)) {
|
||||||
|
parentSceneId = null;
|
||||||
|
}
|
||||||
|
this.parentSceneId = parentSceneId;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(lights)) {
|
||||||
|
lights = [];
|
||||||
|
}
|
||||||
|
this.lights = lights;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(worlds)) {
|
||||||
|
worlds = [];
|
||||||
|
}
|
||||||
|
this.worlds = worlds;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(entities)) {
|
||||||
|
entities = [];
|
||||||
|
}
|
||||||
|
this.entities = entities;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(components)) {
|
||||||
|
components = [];
|
||||||
|
}
|
||||||
|
this.components = components;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(shapes)) {
|
||||||
|
shapes = [];
|
||||||
|
}
|
||||||
|
this.shapes = shapes;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(cameras)) {
|
||||||
|
cameras = [];
|
||||||
|
}
|
||||||
|
this.cameras = cameras;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(activeCameraIndex)) {
|
||||||
|
activeCameraIndex = 0;
|
||||||
|
}
|
||||||
|
this.activeCameraIndex = activeCameraIndex;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(splines)) {
|
||||||
|
splines = [];
|
||||||
|
}
|
||||||
|
this.splines = splines;
|
||||||
|
};
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* API Spline
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Spline = function(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
vertices
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'spline-unnamed';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(vertices)) {
|
||||||
|
vertices = [];
|
||||||
|
}
|
||||||
|
this.vertices = vertices;
|
||||||
|
};
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* Raw API Texture Map Template - should match the contents of the Material Schema (maps property)
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.TextureMapTemplate = function() {
|
||||||
|
return new GameLib.D3.TextureMaps(
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap(),
|
||||||
|
new GameLib.D3.TextureMap()
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,153 @@
|
||||||
|
/**
|
||||||
|
* Raw Texture API object - should always correspond with the Texture Schema
|
||||||
|
* @param id
|
||||||
|
* @param typeId
|
||||||
|
* @param name
|
||||||
|
* @param imagePath
|
||||||
|
* @param wrapS
|
||||||
|
* @param wrapT
|
||||||
|
* @param repeat
|
||||||
|
* @param data
|
||||||
|
* @param format
|
||||||
|
* @param mapping
|
||||||
|
* @param magFilter
|
||||||
|
* @param minFilter
|
||||||
|
* @param textureType
|
||||||
|
* @param anisotropy
|
||||||
|
* @param offset
|
||||||
|
* @param generateMipmaps
|
||||||
|
* @param flipY
|
||||||
|
* @param mipmaps
|
||||||
|
* @param unpackAlignment
|
||||||
|
* @param premultiplyAlpha
|
||||||
|
* @param encoding
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Texture = function(
|
||||||
|
id,
|
||||||
|
typeId,
|
||||||
|
name,
|
||||||
|
imagePath,
|
||||||
|
wrapS,
|
||||||
|
wrapT,
|
||||||
|
repeat,
|
||||||
|
data,
|
||||||
|
format,
|
||||||
|
mapping,
|
||||||
|
magFilter,
|
||||||
|
minFilter,
|
||||||
|
textureType,
|
||||||
|
anisotropy,
|
||||||
|
offset,
|
||||||
|
generateMipmaps,
|
||||||
|
flipY,
|
||||||
|
mipmaps,
|
||||||
|
unpackAlignment,
|
||||||
|
premultiplyAlpha,
|
||||||
|
encoding
|
||||||
|
) {
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.D3.Tools.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(typeId)) {
|
||||||
|
typeId = GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE;
|
||||||
|
}
|
||||||
|
this.typeId = typeId;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'Texture (' + typeId + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(imagePath)) {
|
||||||
|
imagePath = null;
|
||||||
|
}
|
||||||
|
this.imagePath = imagePath;
|
||||||
|
|
||||||
|
if (typeof wrapS == 'undefined') {
|
||||||
|
wrapS = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING;
|
||||||
|
}
|
||||||
|
this.wrapS = wrapS;
|
||||||
|
|
||||||
|
if (typeof wrapT == 'undefined') {
|
||||||
|
wrapT = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING;
|
||||||
|
}
|
||||||
|
this.wrapT = wrapT;
|
||||||
|
|
||||||
|
if (typeof repeat == 'undefined') {
|
||||||
|
repeat = new GameLib.D3.Vector2(1, 1);
|
||||||
|
}
|
||||||
|
this.repeat = repeat;
|
||||||
|
|
||||||
|
if (typeof data == 'undefined') {
|
||||||
|
data = null;
|
||||||
|
}
|
||||||
|
this.data = data;
|
||||||
|
|
||||||
|
if (typeof format == 'undefined') {
|
||||||
|
format = GameLib.D3.Texture.TYPE_RGBA_FORMAT;
|
||||||
|
}
|
||||||
|
this.format = format;
|
||||||
|
|
||||||
|
if (typeof mapping == 'undefined') {
|
||||||
|
mapping = GameLib.D3.Texture.TYPE_UV_MAPPING;
|
||||||
|
}
|
||||||
|
this.mapping = mapping;
|
||||||
|
|
||||||
|
if (typeof magFilter == 'undefined') {
|
||||||
|
magFilter = GameLib.D3.Texture.TYPE_LINEAR_FILTER;
|
||||||
|
}
|
||||||
|
this.magFilter = magFilter;
|
||||||
|
|
||||||
|
if (typeof minFilter == 'undefined') {
|
||||||
|
minFilter = GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
|
||||||
|
}
|
||||||
|
this.minFilter = minFilter;
|
||||||
|
|
||||||
|
if (typeof textureType == 'undefined') {
|
||||||
|
textureType = GameLib.D3.Texture.TYPE_UNSIGNED_BYTE;
|
||||||
|
}
|
||||||
|
this.textureType = textureType;
|
||||||
|
|
||||||
|
if (typeof anisotropy == 'undefined') {
|
||||||
|
anisotropy = 1;
|
||||||
|
}
|
||||||
|
this.anisotropy = anisotropy;
|
||||||
|
|
||||||
|
if (typeof offset == 'undefined') {
|
||||||
|
offset = new GameLib.D3.Vector2(0, 0);
|
||||||
|
}
|
||||||
|
this.offset = offset;
|
||||||
|
|
||||||
|
if (typeof generateMipmaps == 'undefined') {
|
||||||
|
generateMipmaps = true;
|
||||||
|
}
|
||||||
|
this.generateMipmaps = generateMipmaps;
|
||||||
|
|
||||||
|
if (typeof flipY == 'undefined') {
|
||||||
|
flipY = true;
|
||||||
|
}
|
||||||
|
this.flipY = flipY;
|
||||||
|
|
||||||
|
if (typeof mipmaps == 'undefined') {
|
||||||
|
mipmaps = [];
|
||||||
|
}
|
||||||
|
this.mipmaps = mipmaps;
|
||||||
|
|
||||||
|
if (typeof unpackAlignment == 'undefined') {
|
||||||
|
unpackAlignment = 4;
|
||||||
|
}
|
||||||
|
this.unpackAlignment = unpackAlignment;
|
||||||
|
|
||||||
|
if (typeof premultiplyAlpha == 'undefined') {
|
||||||
|
premultiplyAlpha = false;
|
||||||
|
}
|
||||||
|
this.premultiplyAlpha = premultiplyAlpha;
|
||||||
|
|
||||||
|
if (typeof encoding == 'undefined') {
|
||||||
|
encoding = GameLib.D3.Texture.TYPE_LINEAR_ENCODING;
|
||||||
|
}
|
||||||
|
this.encoding = encoding;
|
||||||
|
};
|
|
@ -0,0 +1,5 @@
|
||||||
|
GameLib.D3.API.Vector3 = function Vector3(x, y, z) {
|
||||||
|
this.x = x || 0;
|
||||||
|
this.y = y || 0;
|
||||||
|
this.z = z || 0;
|
||||||
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Creates a camera object
|
* Creates a camera object
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param apiCamera GameLib.D3.Camera.API
|
* @param apiCamera GameLib.D3.API.Camera
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera = function Camera(
|
GameLib.D3.Camera = function Camera(
|
||||||
|
@ -18,13 +18,13 @@ GameLib.D3.Camera = function Camera(
|
||||||
|
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
this.position = new GameLib.D3.Vector3.Runtime(
|
this.position = new GameLib.D3.Runtime.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this,
|
this,
|
||||||
this.position
|
this.position
|
||||||
);
|
);
|
||||||
|
|
||||||
this.offsetPosition = new GameLib.D3.Vector3.Runtime(graphics, this, new GameLib.D3.Vector3(0,5,5));
|
this.offsetPosition = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,5,5));
|
||||||
|
|
||||||
delete this.offsetPosition.updateInstance;
|
delete this.offsetPosition.updateInstance;
|
||||||
|
|
||||||
|
@ -33,126 +33,6 @@ GameLib.D3.Camera = function Camera(
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw Camera API object - should always correspond with the Camera Schema
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param cameraType GameLib.D3.Camera.CAMERA_TYPE_*
|
|
||||||
* @param fov
|
|
||||||
* @param aspect
|
|
||||||
* @param near
|
|
||||||
* @param far
|
|
||||||
* @param position GameLib.D3.Vector3
|
|
||||||
* @param lookAt GameLib.D3.Vector3
|
|
||||||
* @param minX
|
|
||||||
* @param maxX
|
|
||||||
* @param minY
|
|
||||||
* @param maxY
|
|
||||||
* @param minZ
|
|
||||||
* @param maxZ
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Camera.API = function(
|
|
||||||
id,
|
|
||||||
cameraType,
|
|
||||||
name,
|
|
||||||
fov,
|
|
||||||
aspect,
|
|
||||||
near,
|
|
||||||
far,
|
|
||||||
position,
|
|
||||||
lookAt,
|
|
||||||
minX,
|
|
||||||
maxX,
|
|
||||||
minY,
|
|
||||||
maxY,
|
|
||||||
minZ,
|
|
||||||
maxZ
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(cameraType)) {
|
|
||||||
cameraType = GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE;
|
|
||||||
}
|
|
||||||
this.cameraType = cameraType;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Camera (' + cameraType + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(fov)) {
|
|
||||||
fov = 75;
|
|
||||||
}
|
|
||||||
this.fov = fov;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(aspect)) {
|
|
||||||
aspect = window.innerWidth / window.innerHeight;
|
|
||||||
}
|
|
||||||
this.aspect = aspect;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(near)) {
|
|
||||||
near = 0.1;
|
|
||||||
}
|
|
||||||
this.near = near;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(far)) {
|
|
||||||
far = 1000;
|
|
||||||
}
|
|
||||||
this.far = far;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.D3.Vector3(
|
|
||||||
15,
|
|
||||||
15,
|
|
||||||
15
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lookAt)) {
|
|
||||||
lookAt = new GameLib.D3.Vector3(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.lookAt = lookAt;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(minX)) {
|
|
||||||
minX = -100;
|
|
||||||
}
|
|
||||||
this.minX = minX;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxX)) {
|
|
||||||
maxX = 100;
|
|
||||||
}
|
|
||||||
this.maxX = maxX;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(minY)) {
|
|
||||||
minY = -100;
|
|
||||||
}
|
|
||||||
this.minY = minY;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxY)) {
|
|
||||||
maxY = 100;
|
|
||||||
}
|
|
||||||
this.maxY = maxY;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(minZ)) {
|
|
||||||
minZ = -100;
|
|
||||||
}
|
|
||||||
this.minZ = minZ;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxZ)) {
|
|
||||||
maxZ = 100;
|
|
||||||
}
|
|
||||||
this.maxZ = maxZ;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Camera types
|
* Camera types
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -37,272 +37,7 @@ 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;
|
||||||
|
|
||||||
/**
|
|
||||||
* Superset for storing Components to API, and generating them from componentType
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param componentType
|
|
||||||
* @param camera
|
|
||||||
* @param startColor
|
|
||||||
* @param endColor
|
|
||||||
* @param lerpSpeed
|
|
||||||
* @param targetEntity
|
|
||||||
* @param targetOffset
|
|
||||||
* @param minDistance
|
|
||||||
* @param moveSpeed
|
|
||||||
* @param rotationSpeed
|
|
||||||
* @param positionOffset
|
|
||||||
* @param quaternionOffset
|
|
||||||
* @param scaleOffset
|
|
||||||
* @param sensorLength
|
|
||||||
* @param spline
|
|
||||||
* @param normalSpline
|
|
||||||
* @param acceleration
|
|
||||||
* @param maxSpeed
|
|
||||||
* @param baseOffset
|
|
||||||
* @param maxOffset
|
|
||||||
* @param steeringSpeed
|
|
||||||
* @param frontLWheelIndex
|
|
||||||
* @param frontRWheelIndex
|
|
||||||
* @param backLWheelIndex
|
|
||||||
* @param backRWheelIndex
|
|
||||||
* @param maxForce
|
|
||||||
* @param steering
|
|
||||||
* @param entitiesToCheck
|
|
||||||
* @param onInside
|
|
||||||
* @param onEnter
|
|
||||||
* @param onLeave
|
|
||||||
* @param onSetParent
|
|
||||||
* @param sphereRadius
|
|
||||||
* @param world
|
|
||||||
* @param maxSteerAngle
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.ComponentInterface.API = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
componentType,
|
|
||||||
camera,
|
|
||||||
startColor,
|
|
||||||
endColor,
|
|
||||||
lerpSpeed,
|
|
||||||
targetEntity,
|
|
||||||
targetOffset,
|
|
||||||
minDistance,
|
|
||||||
moveSpeed,
|
|
||||||
rotationSpeed,
|
|
||||||
positionOffset,
|
|
||||||
quaternionOffset,
|
|
||||||
scaleOffset,
|
|
||||||
sensorLength,
|
|
||||||
spline,
|
|
||||||
normalSpline,
|
|
||||||
acceleration,
|
|
||||||
maxSpeed,
|
|
||||||
baseOffset,
|
|
||||||
maxOffset,
|
|
||||||
steeringSpeed,
|
|
||||||
frontLWheelIndex,
|
|
||||||
frontRWheelIndex,
|
|
||||||
backLWheelIndex,
|
|
||||||
backRWheelIndex,
|
|
||||||
maxForce,
|
|
||||||
steering,
|
|
||||||
entitiesToCheck,
|
|
||||||
onInside,
|
|
||||||
onEnter,
|
|
||||||
onLeave,
|
|
||||||
onSetParent,
|
|
||||||
sphereRadius,
|
|
||||||
world,
|
|
||||||
maxSteerAngle
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'component-unnamed';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(componentType)) {
|
|
||||||
componentType = GameLib.D3.ComponentInterface.COMPONENT_INTERFACE;
|
|
||||||
}
|
|
||||||
this.componentType = componentType;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(camera)) {
|
|
||||||
camera = null;
|
|
||||||
}
|
|
||||||
this.camera = camera;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(startColor)) {
|
|
||||||
startColor = new GameLib.D3.Vector3(0, 0, 0);
|
|
||||||
}
|
|
||||||
this.startColor = startColor;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(endColor)) {
|
|
||||||
endColor = new GameLib.D3.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)) {
|
|
||||||
targetEntity = null;
|
|
||||||
}
|
|
||||||
this.targetEntity = targetEntity;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
|
||||||
targetOffset = new GameLib.D3.Vector3(0, 0, 0);
|
|
||||||
}
|
|
||||||
this.targetOffset = targetOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(minDistance)) {
|
|
||||||
minDistance = 0;
|
|
||||||
}
|
|
||||||
this.minDistance = minDistance;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(moveSpeed)) {
|
|
||||||
moveSpeed = 12.5;
|
|
||||||
}
|
|
||||||
this.moveSpeed = moveSpeed;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotationSpeed)) {
|
|
||||||
rotationSpeed = 22.0;
|
|
||||||
}
|
|
||||||
this.rotationSpeed = rotationSpeed;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(positionOffset)) {
|
|
||||||
positionOffset = new GameLib.D3.Vector3();
|
|
||||||
}
|
|
||||||
this.positionOffset = positionOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
|
||||||
quaternionOffset = new GameLib.D3.Vector4();
|
|
||||||
}
|
|
||||||
this.quaternionOffset = quaternionOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
|
||||||
scaleOffset = new GameLib.D3.Vector3();
|
|
||||||
}
|
|
||||||
this.scaleOffset = scaleOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(sensorLength)) {
|
|
||||||
sensorLength = 5;
|
|
||||||
}
|
|
||||||
this.sensorLength = sensorLength;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(spline)) {
|
|
||||||
spline = new GameLib.D3.API.Spline(null, 'spline');
|
|
||||||
}
|
|
||||||
this.spline = spline;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(normalSpline)) {
|
|
||||||
normalSpline = new GameLib.D3.API.Spline(null, 'normal-spline');
|
|
||||||
}
|
|
||||||
this.normalSpline = normalSpline;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(acceleration)) {
|
|
||||||
acceleration = 2.0;
|
|
||||||
}
|
|
||||||
this.acceleration = acceleration;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxSpeed)) {
|
|
||||||
maxSpeed = 10.0;
|
|
||||||
}
|
|
||||||
this.maxSpeed = maxSpeed;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(baseOffset)) {
|
|
||||||
baseOffset = new GameLib.D3.Vector3();
|
|
||||||
}
|
|
||||||
this.baseOffset = baseOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxOffset)) {
|
|
||||||
maxOffset = new GameLib.D3.Vector3(10, 10, 10);
|
|
||||||
}
|
|
||||||
this.maxOffset = maxOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(steeringSpeed)) {
|
|
||||||
steeringSpeed = 1.0;
|
|
||||||
}
|
|
||||||
this.steeringSpeed = steeringSpeed;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(frontLWheelIndex)) {
|
|
||||||
frontLWheelIndex = 1;
|
|
||||||
}
|
|
||||||
this.frontLWheelIndex = frontLWheelIndex;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(frontRWheelIndex)) {
|
|
||||||
frontRWheelIndex = 2;
|
|
||||||
}
|
|
||||||
this.frontRWheelIndex = frontRWheelIndex;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(backLWheelIndex)) {
|
|
||||||
backLWheelIndex = 3;
|
|
||||||
}
|
|
||||||
this.backLWheelIndex = backLWheelIndex;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(backRWheelIndex)) {
|
|
||||||
backRWheelIndex = 4;
|
|
||||||
}
|
|
||||||
this.backRWheelIndex = backRWheelIndex;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxForce)) {
|
|
||||||
maxForce = 400;
|
|
||||||
}
|
|
||||||
this.maxForce = maxForce;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// will be not used
|
// will be not used
|
||||||
GameLib.D3.ComponentInterface.prototype.setParentEntity = function(
|
GameLib.D3.ComponentInterface.prototype.setParentEntity = function(
|
||||||
|
|
|
@ -17,64 +17,6 @@ GameLib.D3.Entity = function(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(parentScene)) {
|
|
||||||
parentScene = null;
|
|
||||||
}
|
|
||||||
this.parentScene = parentScene;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(mesh)) {
|
|
||||||
mesh = null;
|
|
||||||
}
|
|
||||||
this.mesh = mesh;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entity API
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param ids
|
|
||||||
* @param position
|
|
||||||
* @param quaternion
|
|
||||||
* @param scale
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Entity.API = function Entity(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
ids,
|
|
||||||
position,
|
|
||||||
quaternion,
|
|
||||||
scale
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = this.constructor.name;
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(ids)) {
|
|
||||||
ids = [];
|
|
||||||
}
|
|
||||||
this.ids = ids;
|
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.D3.Vector3();
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.D3.Vector4();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.D3.Vector3(1, 1, 1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Light Superset - The apiLight properties get moved into the Light object itself, and then the instance is created
|
* Light Superset - The apiLight properties get moved into the Light object itself, and then the instance is created
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param apiLight GameLib.D3.Light.API
|
* @param apiLight GameLib.D3.API.Light
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Light = function Light(
|
GameLib.D3.Light = function Light(
|
||||||
|
@ -20,118 +20,6 @@ GameLib.D3.Light = function Light(
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw Light API object - should always correspond with the Light Schema
|
|
||||||
* @param id
|
|
||||||
* @param lightType
|
|
||||||
* @param name
|
|
||||||
* @param color
|
|
||||||
* @param intensity
|
|
||||||
* @param position
|
|
||||||
* @param targetPosition
|
|
||||||
* @param quaternion
|
|
||||||
* @param rotation
|
|
||||||
* @param scale
|
|
||||||
* @param distance
|
|
||||||
* @param decay
|
|
||||||
* @param power
|
|
||||||
* @param angle
|
|
||||||
* @param penumbra
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Light.API = function(
|
|
||||||
id,
|
|
||||||
lightType,
|
|
||||||
name,
|
|
||||||
color,
|
|
||||||
intensity,
|
|
||||||
position,
|
|
||||||
targetPosition,
|
|
||||||
quaternion,
|
|
||||||
rotation,
|
|
||||||
scale,
|
|
||||||
distance,
|
|
||||||
decay,
|
|
||||||
power,
|
|
||||||
angle,
|
|
||||||
penumbra
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lightType)) {
|
|
||||||
lightType = GameLib.D3.Light.LIGHT_TYPE_AMBIENT;
|
|
||||||
}
|
|
||||||
this.lightType = lightType;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Light (' + lightType + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
|
||||||
color = new GameLib.D3.Color(1,1,1,1);
|
|
||||||
}
|
|
||||||
this.color = color;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(intensity)) {
|
|
||||||
intensity = 1;
|
|
||||||
}
|
|
||||||
this.intensity = intensity;
|
|
||||||
|
|
||||||
if (typeof position == 'undefined') {
|
|
||||||
position = new GameLib.D3.Vector3(0,10,0);
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (typeof targetPosition == 'undefined') {
|
|
||||||
targetPosition = new GameLib.D3.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.targetPosition = targetPosition;
|
|
||||||
|
|
||||||
if (typeof quaternion == 'undefined'){
|
|
||||||
quaternion = new GameLib.D3.Vector4();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if (typeof rotation == 'undefined'){
|
|
||||||
rotation = new GameLib.D3.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (typeof scale == 'undefined'){
|
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (typeof distance == 'undefined'){
|
|
||||||
distance = 0;
|
|
||||||
}
|
|
||||||
this.distance = distance;
|
|
||||||
|
|
||||||
if (typeof decay == 'undefined'){
|
|
||||||
decay = 1;
|
|
||||||
}
|
|
||||||
this.decay = decay;
|
|
||||||
|
|
||||||
if (typeof power == 'undefined'){
|
|
||||||
power = 4 * Math.PI;
|
|
||||||
}
|
|
||||||
this.power = power;
|
|
||||||
|
|
||||||
if (typeof angle == 'undefined'){
|
|
||||||
angle = Math.PI / 3;
|
|
||||||
}
|
|
||||||
this.angle = angle;
|
|
||||||
|
|
||||||
if (typeof penumbra == 'undefined'){
|
|
||||||
penumbra = 0;
|
|
||||||
}
|
|
||||||
this.penumbra = penumbra;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Light Types
|
* Light Types
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
* Material Superset - The apiMaterial properties get moved into the Material object itself, and then the instance is
|
* Material Superset - The apiMaterial properties get moved into the Material object itself, and then the instance is
|
||||||
* created
|
* created
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param apiMaterial GameLib.D3.Material.API
|
* @param apiMaterial GameLib.D3.API.Material
|
||||||
* @constructor
|
* @constructor
|
||||||
* @returns {GameLib.D3.Material | GameLib.D3.Material.API}
|
* @returns {GameLib.D3.Material | GameLib.D3.API.Material}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material = function Material(
|
GameLib.D3.Material = function Material(
|
||||||
graphics,
|
graphics,
|
||||||
|
@ -24,412 +24,6 @@ GameLib.D3.Material = function Material(
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw material API object - should always correspond with the Material Schema
|
|
||||||
* @param id
|
|
||||||
* @param materialType
|
|
||||||
* @param name
|
|
||||||
* @param opacity
|
|
||||||
* @param side
|
|
||||||
* @param transparent
|
|
||||||
* @param maps
|
|
||||||
* @param specular
|
|
||||||
* @param lightMapIntensity
|
|
||||||
* @param aoMapIntensity
|
|
||||||
* @param color
|
|
||||||
* @param emissive
|
|
||||||
* @param emissiveIntensity
|
|
||||||
* @param combine
|
|
||||||
* @param shininess
|
|
||||||
* @param reflectivity
|
|
||||||
* @param refractionRatio
|
|
||||||
* @param fog
|
|
||||||
* @param wireframe
|
|
||||||
* @param wireframeLineWidth
|
|
||||||
* @param wireframeLineCap
|
|
||||||
* @param wireframeLineJoin
|
|
||||||
* @param vertexColors
|
|
||||||
* @param skinning
|
|
||||||
* @param morphTargets
|
|
||||||
* @param morphNormals
|
|
||||||
* @param lineWidth
|
|
||||||
* @param lineCap
|
|
||||||
* @param lineJoin
|
|
||||||
* @param dashSize
|
|
||||||
* @param gapWidth
|
|
||||||
* @param blending
|
|
||||||
* @param blendSrc
|
|
||||||
* @param blendDst
|
|
||||||
* @param blendEquation
|
|
||||||
* @param depthTest
|
|
||||||
* @param depthFunc
|
|
||||||
* @param depthWrite
|
|
||||||
* @param polygonOffset
|
|
||||||
* @param polygonOffsetFactor
|
|
||||||
* @param polygonOffsetUnits
|
|
||||||
* @param alphaTest
|
|
||||||
* @param clippingPlanes
|
|
||||||
* @param clipShadows
|
|
||||||
* @param visible
|
|
||||||
* @param overdraw
|
|
||||||
* @param shading
|
|
||||||
* @param bumpScale
|
|
||||||
* @param normalScale
|
|
||||||
* @param displacementScale
|
|
||||||
* @param displacementBias
|
|
||||||
* @param roughness
|
|
||||||
* @param metalness
|
|
||||||
* @param pointSize
|
|
||||||
* @param pointSizeAttenuation
|
|
||||||
* @param spriteRotation
|
|
||||||
* @param envMapIntensity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Material.API = function(
|
|
||||||
id,
|
|
||||||
materialType,
|
|
||||||
name,
|
|
||||||
opacity,
|
|
||||||
side,
|
|
||||||
transparent,
|
|
||||||
maps,
|
|
||||||
specular,
|
|
||||||
lightMapIntensity,
|
|
||||||
aoMapIntensity,
|
|
||||||
color,
|
|
||||||
emissive,
|
|
||||||
emissiveIntensity,
|
|
||||||
combine,
|
|
||||||
shininess,
|
|
||||||
reflectivity,
|
|
||||||
refractionRatio,
|
|
||||||
fog,
|
|
||||||
wireframe,
|
|
||||||
wireframeLineWidth,
|
|
||||||
wireframeLineCap,
|
|
||||||
wireframeLineJoin,
|
|
||||||
vertexColors,
|
|
||||||
skinning,
|
|
||||||
morphTargets,
|
|
||||||
morphNormals,
|
|
||||||
lineWidth,
|
|
||||||
lineCap,
|
|
||||||
lineJoin,
|
|
||||||
dashSize,
|
|
||||||
gapWidth,
|
|
||||||
blending,
|
|
||||||
blendSrc,
|
|
||||||
blendDst,
|
|
||||||
blendEquation,
|
|
||||||
depthTest,
|
|
||||||
depthFunc,
|
|
||||||
depthWrite,
|
|
||||||
polygonOffset,
|
|
||||||
polygonOffsetFactor,
|
|
||||||
polygonOffsetUnits,
|
|
||||||
alphaTest,
|
|
||||||
clippingPlanes,
|
|
||||||
clipShadows,
|
|
||||||
visible,
|
|
||||||
overdraw,
|
|
||||||
shading,
|
|
||||||
bumpScale,
|
|
||||||
normalScale,
|
|
||||||
displacementScale,
|
|
||||||
displacementBias,
|
|
||||||
roughness,
|
|
||||||
metalness,
|
|
||||||
pointSize,
|
|
||||||
pointSizeAttenuation,
|
|
||||||
spriteRotation,
|
|
||||||
envMapIntensity
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(materialType)) {
|
|
||||||
materialType = GameLib.D3.Material.MATERIAL_TYPE_STANDARD;
|
|
||||||
}
|
|
||||||
this.materialType = materialType;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Material (' + materialType + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(opacity)) {
|
|
||||||
opacity = 1.0;
|
|
||||||
}
|
|
||||||
this.opacity = opacity;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(side)) {
|
|
||||||
side = GameLib.D3.Material.TYPE_FRONT_SIDE;
|
|
||||||
}
|
|
||||||
this.side = side;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(transparent)) {
|
|
||||||
transparent = false;
|
|
||||||
}
|
|
||||||
this.transparent = transparent;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maps)) {
|
|
||||||
maps = GameLib.D3.TextureMapTemplate.API();
|
|
||||||
}
|
|
||||||
this.maps = maps;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(specular)) {
|
|
||||||
specular = new GameLib.D3.Color(0.06, 0.06, 0.06, 0.06);
|
|
||||||
}
|
|
||||||
this.specular = specular;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lightMapIntensity)) {
|
|
||||||
lightMapIntensity = 1;
|
|
||||||
}
|
|
||||||
this.lightMapIntensity = lightMapIntensity;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(aoMapIntensity)) {
|
|
||||||
aoMapIntensity = 1;
|
|
||||||
}
|
|
||||||
this.aoMapIntensity = aoMapIntensity;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
|
||||||
color = new GameLib.D3.Color(1, 1, 1, 1)
|
|
||||||
}
|
|
||||||
this.color = color;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(emissive)) {
|
|
||||||
emissive = new GameLib.D3.Color(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
this.emissive = emissive;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(emissiveIntensity)) {
|
|
||||||
emissiveIntensity = 1;
|
|
||||||
}
|
|
||||||
this.emissiveIntensity = emissiveIntensity;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(combine)) {
|
|
||||||
combine = GameLib.D3.Material.TYPE_MULTIPLY_OPERATION;
|
|
||||||
}
|
|
||||||
this.combine = combine;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(shininess)) {
|
|
||||||
shininess = 30;
|
|
||||||
}
|
|
||||||
this.shininess = shininess;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(reflectivity)) {
|
|
||||||
reflectivity = 1;
|
|
||||||
}
|
|
||||||
this.reflectivity = reflectivity;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(refractionRatio)) {
|
|
||||||
refractionRatio = 0.98;
|
|
||||||
}
|
|
||||||
this.refractionRatio = refractionRatio;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(fog)) {
|
|
||||||
fog = true;
|
|
||||||
}
|
|
||||||
this.fog = fog;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(wireframe)) {
|
|
||||||
wireframe = false;
|
|
||||||
}
|
|
||||||
this.wireframe = wireframe;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(wireframeLineWidth)) {
|
|
||||||
wireframeLineWidth = 1;
|
|
||||||
}
|
|
||||||
this.wireframeLineWidth = wireframeLineWidth;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(wireframeLineCap)) {
|
|
||||||
wireframeLineCap = 'round';
|
|
||||||
}
|
|
||||||
this.wireframeLineCap = wireframeLineCap;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(wireframeLineJoin)) {
|
|
||||||
wireframeLineJoin = 'round';
|
|
||||||
}
|
|
||||||
this.wireframeLineJoin = wireframeLineJoin;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(vertexColors)) {
|
|
||||||
vertexColors = GameLib.D3.Material.TYPE_NO_COLORS;
|
|
||||||
}
|
|
||||||
this.vertexColors = vertexColors;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(skinning)) {
|
|
||||||
skinning = false;
|
|
||||||
}
|
|
||||||
this.skinning = skinning;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(morphTargets)) {
|
|
||||||
morphTargets = false;
|
|
||||||
}
|
|
||||||
this.morphTargets = morphTargets;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(morphNormals)) {
|
|
||||||
morphNormals = false;
|
|
||||||
}
|
|
||||||
this.morphNormals = morphNormals;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(overdraw)) {
|
|
||||||
overdraw = 0;
|
|
||||||
}
|
|
||||||
this.overdraw = overdraw;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lineWidth)) {
|
|
||||||
lineWidth = 1;
|
|
||||||
}
|
|
||||||
this.lineWidth = lineWidth;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lineCap)) {
|
|
||||||
lineCap = 'round';
|
|
||||||
}
|
|
||||||
this.lineCap = lineCap;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lineJoin)) {
|
|
||||||
lineJoin = 'round';
|
|
||||||
}
|
|
||||||
this.lineJoin = lineJoin;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(dashSize)) {
|
|
||||||
dashSize = 3;
|
|
||||||
}
|
|
||||||
this.dashSize = dashSize;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(gapWidth)) {
|
|
||||||
gapWidth = 1;
|
|
||||||
}
|
|
||||||
this.gapWidth = gapWidth;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(blending)) {
|
|
||||||
blending = GameLib.D3.Material.TYPE_NORMAL_BLENDING;
|
|
||||||
}
|
|
||||||
this.blending = blending;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(blendSrc)) {
|
|
||||||
blendSrc = GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR;
|
|
||||||
}
|
|
||||||
this.blendSrc = blendSrc;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(blendDst)) {
|
|
||||||
blendDst = GameLib.D3.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR;
|
|
||||||
}
|
|
||||||
this.blendDst = blendDst;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(blendEquation)) {
|
|
||||||
blendEquation = GameLib.D3.Material.TYPE_ADD_EQUATION;
|
|
||||||
}
|
|
||||||
this.blendEquation = blendEquation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(depthTest)) {
|
|
||||||
depthTest = true;
|
|
||||||
}
|
|
||||||
this.depthTest = depthTest;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(depthFunc)) {
|
|
||||||
depthFunc = GameLib.D3.Material.TYPE_LESS_EQUAL_DEPTH;
|
|
||||||
}
|
|
||||||
this.depthFunc = depthFunc;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(depthWrite)) {
|
|
||||||
depthWrite = true;
|
|
||||||
}
|
|
||||||
this.depthWrite = depthWrite;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(polygonOffset)) {
|
|
||||||
polygonOffset = false;
|
|
||||||
}
|
|
||||||
this.polygonOffset = polygonOffset;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(polygonOffsetFactor)) {
|
|
||||||
polygonOffsetFactor = 1;
|
|
||||||
}
|
|
||||||
this.polygonOffsetFactor = polygonOffsetFactor;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(polygonOffsetUnits)) {
|
|
||||||
polygonOffsetUnits = 1;
|
|
||||||
}
|
|
||||||
this.polygonOffsetUnits = polygonOffsetUnits;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(alphaTest)) {
|
|
||||||
alphaTest = 0;
|
|
||||||
}
|
|
||||||
this.alphaTest = alphaTest;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(clippingPlanes)) {
|
|
||||||
clippingPlanes = [];
|
|
||||||
}
|
|
||||||
this.clippingPlanes = clippingPlanes;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(clipShadows)) {
|
|
||||||
clipShadows = false;
|
|
||||||
}
|
|
||||||
this.clipShadows = clipShadows;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(visible)) {
|
|
||||||
visible = true;
|
|
||||||
}
|
|
||||||
this.visible = visible;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(shading)) {
|
|
||||||
shading = GameLib.D3.Material.TYPE_FLAT_SHADING;
|
|
||||||
}
|
|
||||||
this.shading = shading;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(bumpScale)) {
|
|
||||||
bumpScale = 1;
|
|
||||||
}
|
|
||||||
this.bumpScale = bumpScale;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(normalScale)) {
|
|
||||||
normalScale = 1;
|
|
||||||
}
|
|
||||||
this.normalScale = normalScale;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(displacementScale)) {
|
|
||||||
displacementScale = 1;
|
|
||||||
}
|
|
||||||
this.displacementScale = displacementScale;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(displacementBias)) {
|
|
||||||
displacementBias = 0;
|
|
||||||
}
|
|
||||||
this.displacementBias = displacementBias;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(roughness)) {
|
|
||||||
roughness = 0.5;
|
|
||||||
}
|
|
||||||
this.roughness = roughness;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(metalness)) {
|
|
||||||
metalness = 0.5;
|
|
||||||
}
|
|
||||||
this.metalness = metalness;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(pointSize)) {
|
|
||||||
pointSize = 1;
|
|
||||||
}
|
|
||||||
this.pointSize = pointSize;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(pointSizeAttenuation)) {
|
|
||||||
pointSizeAttenuation = true;
|
|
||||||
}
|
|
||||||
this.pointSizeAttenuation = pointSizeAttenuation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(spriteRotation)) {
|
|
||||||
spriteRotation = 0;
|
|
||||||
}
|
|
||||||
this.spriteRotation = spriteRotation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(envMapIntensity)) {
|
|
||||||
envMapIntensity = 1.0;
|
|
||||||
}
|
|
||||||
this.envMapIntensity = envMapIntensity;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combine Method
|
* Combine Method
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
|
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param computeNormals Boolean
|
* @param computeNormals Boolean
|
||||||
* @param apiMesh GameLib.D3.Mesh.API
|
* @param apiMesh GameLib.D3.API.Mesh
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh = function Mesh(
|
GameLib.D3.Mesh = function Mesh(
|
||||||
|
@ -26,147 +26,21 @@ GameLib.D3.Mesh = function Mesh(
|
||||||
|
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
|
|
||||||
this.offsetRotation = new GameLib.D3.Vector3.Runtime(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
this.offsetRotation = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
||||||
|
|
||||||
delete this.offsetRotation.updateInstance;
|
delete this.offsetRotation.updateInstance;
|
||||||
|
|
||||||
// this.lookAtPoint = new GameLib.D3.Vector3.Runtime(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
// this.lookAtPoint = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
||||||
//
|
//
|
||||||
// delete this.offsetRotation.updateInstance;
|
// delete this.offsetRotation.updateInstance;
|
||||||
//
|
//
|
||||||
// this.offsetRotation = new GameLib.D3.Vector3.Runtime(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
// this.offsetRotation = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
||||||
//
|
//
|
||||||
// delete this.offsetRotation.updateInstance;
|
// delete this.offsetRotation.updateInstance;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw Mesh API object - should always correspond with the Mesh Schema
|
|
||||||
* @param id
|
|
||||||
* @param meshType
|
|
||||||
* @param name
|
|
||||||
* @param vertices GameLib.D3.Vertex[]
|
|
||||||
* @param faces GameLib.D3.TriangleFace[]
|
|
||||||
* @param faceVertexUvs
|
|
||||||
* @param materials GameLib.D3.Material.API[]
|
|
||||||
* @param parentMeshId
|
|
||||||
* @param parentSceneId
|
|
||||||
* @param skeleton
|
|
||||||
* @param skinIndices
|
|
||||||
* @param skinWeights
|
|
||||||
* @param position GameLib.D3.Vector3
|
|
||||||
* @param quaternion GameLib.D3.Vector4
|
|
||||||
* @param rotation GameLib.D3.Vector3
|
|
||||||
* @param scale GameLib.D3.Vector3
|
|
||||||
* @param up
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Mesh.API = function(
|
|
||||||
id,
|
|
||||||
meshType,
|
|
||||||
name,
|
|
||||||
vertices,
|
|
||||||
faces,
|
|
||||||
faceVertexUvs,
|
|
||||||
materials,
|
|
||||||
parentMeshId,
|
|
||||||
parentSceneId,
|
|
||||||
skeleton,
|
|
||||||
skinIndices,
|
|
||||||
skinWeights,
|
|
||||||
position,
|
|
||||||
quaternion,
|
|
||||||
rotation,
|
|
||||||
scale,
|
|
||||||
up
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(meshType)) {
|
|
||||||
meshType = GameLib.D3.Mesh.TYPE_NORMAL;
|
|
||||||
}
|
|
||||||
this.meshType = meshType;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Mesh (' + meshType + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(vertices)) {
|
|
||||||
throw new Error('Cannot create a mesh with no vertices');
|
|
||||||
}
|
|
||||||
this.vertices = vertices;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(faces)) {
|
|
||||||
throw new Error('Cannot create a mesh with no faces');
|
|
||||||
}
|
|
||||||
this.faces = faces;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(parentMeshId)) {
|
|
||||||
parentMeshId = null;
|
|
||||||
}
|
|
||||||
this.parentMeshId = parentMeshId;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(parentSceneId)) {
|
|
||||||
parentSceneId = null;
|
|
||||||
}
|
|
||||||
this.parentSceneId = parentSceneId;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(skeleton)) {
|
|
||||||
skeleton = null;
|
|
||||||
}
|
|
||||||
this.skeleton = skeleton;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(faceVertexUvs)) {
|
|
||||||
faceVertexUvs = [];
|
|
||||||
}
|
|
||||||
this.faceVertexUvs = faceVertexUvs;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(skinIndices)) {
|
|
||||||
skinIndices = [];
|
|
||||||
}
|
|
||||||
this.skinIndices = skinIndices;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(skinWeights)) {
|
|
||||||
skinWeights = [];
|
|
||||||
}
|
|
||||||
this.skinWeights = skinWeights;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(materials)) {
|
|
||||||
materials = [];
|
|
||||||
}
|
|
||||||
this.materials = materials;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.D3.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.D3.Vector4();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.D3.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(up)) {
|
|
||||||
up = new GameLib.D3.Vector3(0,1,0);
|
|
||||||
}
|
|
||||||
this.up = up;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mesh Type
|
* Mesh Type
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
* Runtime vector3 for updating instance objects
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param parentObject GameLib.D3.*
|
||||||
|
* @param vector3 GameLib.D3.Vector3
|
||||||
|
* @param grain Number
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Runtime.Vector3 = function RuntimeVector3(graphics, parentObject, vector3, grain) {
|
||||||
|
|
||||||
|
for (var property in vector3) {
|
||||||
|
if (vector3.hasOwnProperty(property)) {
|
||||||
|
this[property] = vector3[property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector3, GameLib.D3.Vector3);
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
this.parentObject = parentObject;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(grain)) {
|
||||||
|
grain = 0.001;
|
||||||
|
}
|
||||||
|
this.grain = grain;
|
||||||
|
|
||||||
|
this.instance = this.createInstance();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance vector3
|
||||||
|
* @param update
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
|
var instance = null;
|
||||||
|
|
||||||
|
if (update) {
|
||||||
|
instance = this.instance;
|
||||||
|
instance.x = this.x;
|
||||||
|
instance.y = this.y;
|
||||||
|
instance.z = this.z;
|
||||||
|
} else {
|
||||||
|
instance = new this.graphics.instance.Vector3(this.x, this.y, this.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance vector, calls updateInstance on the parent object
|
||||||
|
*/
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.updateInstance = function() {
|
||||||
|
|
||||||
|
this.createInstance(true);
|
||||||
|
|
||||||
|
if (this.parentObject.updateInstance) {
|
||||||
|
this.parentObject.updateInstance();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts runtime vector to API Vector
|
||||||
|
* @returns {GameLib.D3.API.Vector3}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.toApiVector = function() {
|
||||||
|
return new GameLib.D3.Api.Vector3(
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
this.z
|
||||||
|
);
|
||||||
|
};
|
|
@ -3,7 +3,7 @@
|
||||||
* created
|
* created
|
||||||
* @param graphics
|
* @param graphics
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
* @param apiScene GameLib.D3.Scene.API
|
* @param apiScene GameLib.D3.API.Scene
|
||||||
* @param imageFactory
|
* @param imageFactory
|
||||||
* @param meshIdToMesh
|
* @param meshIdToMesh
|
||||||
* @param idToComponent
|
* @param idToComponent
|
||||||
|
@ -45,124 +45,6 @@ GameLib.D3.Scene = function Scene(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw Scene API object - should always correspond with the Scene Schema
|
|
||||||
* @param id String
|
|
||||||
* @param path String
|
|
||||||
* @param name String
|
|
||||||
* @param meshes GameLib.D3.Mesh.API []
|
|
||||||
* @param quaternion GameLib.D3.Vector4
|
|
||||||
* @param position GameLib.D3.Vector3
|
|
||||||
* @param rotation GameLib.D3.Vector3
|
|
||||||
* @param scale GameLib.D3.Vector3
|
|
||||||
* @param parentSceneId
|
|
||||||
* @param lights GameLib.D3.Light.API[]
|
|
||||||
* @param worlds GameLib.D3.World.API[]
|
|
||||||
* @param entities GameLib.D3.Entity.API[]
|
|
||||||
* @param components GameLib.D3.Component.API[]
|
|
||||||
* @param shapes GameLib.D3.Shape.API[]
|
|
||||||
* @param cameras
|
|
||||||
* @param activeCameraIndex
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Scene.API = function(
|
|
||||||
id,
|
|
||||||
path,
|
|
||||||
name,
|
|
||||||
meshes,
|
|
||||||
quaternion,
|
|
||||||
position,
|
|
||||||
rotation,
|
|
||||||
scale,
|
|
||||||
parentSceneId,
|
|
||||||
lights,
|
|
||||||
worlds,
|
|
||||||
entities,
|
|
||||||
components,
|
|
||||||
shapes,
|
|
||||||
cameras,
|
|
||||||
activeCameraIndex
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(path)) {
|
|
||||||
path = null;
|
|
||||||
}
|
|
||||||
this.path = path;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'unnamed';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(meshes)) {
|
|
||||||
meshes = [];
|
|
||||||
}
|
|
||||||
this.meshes = meshes;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.D3.Vector4();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.D3.Vector3();
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.D3.Vector3();
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(parentSceneId)) {
|
|
||||||
parentSceneId = null;
|
|
||||||
}
|
|
||||||
this.parentSceneId = parentSceneId;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lights)) {
|
|
||||||
lights = [];
|
|
||||||
}
|
|
||||||
this.lights = lights;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(worlds)) {
|
|
||||||
worlds = [];
|
|
||||||
}
|
|
||||||
this.worlds = worlds;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(entities)) {
|
|
||||||
entities = [];
|
|
||||||
}
|
|
||||||
this.entities = entities;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(components)) {
|
|
||||||
components = [];
|
|
||||||
}
|
|
||||||
this.components = components;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(shapes)) {
|
|
||||||
shapes = [];
|
|
||||||
}
|
|
||||||
this.shapes = shapes;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(cameras)) {
|
|
||||||
cameras = [];
|
|
||||||
}
|
|
||||||
this.cameras = cameras;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(activeCameraIndex)) {
|
|
||||||
activeCameraIndex = 0;
|
|
||||||
}
|
|
||||||
this.activeCameraIndex = activeCameraIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance scene
|
* Creates an instance scene
|
||||||
|
@ -317,7 +199,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
apiMaterial.opacity,
|
apiMaterial.opacity,
|
||||||
apiMaterial.side,
|
apiMaterial.side,
|
||||||
apiMaterial.transparent,
|
apiMaterial.transparent,
|
||||||
GameLib.D3.TextureMapTemplate.API(),
|
GameLib.D3.API.TextureMapTemplate(),
|
||||||
new GameLib.D3.Color(
|
new GameLib.D3.Color(
|
||||||
apiMaterial.specular.r,
|
apiMaterial.specular.r,
|
||||||
apiMaterial.specular.g,
|
apiMaterial.specular.g,
|
||||||
|
@ -511,19 +393,19 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gameLibMesh.position = new GameLib.D3.Vector3.Runtime(
|
gameLibMesh.position = new GameLib.D3.Runtime.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
gameLibMesh,
|
gameLibMesh,
|
||||||
gameLibMesh.position
|
gameLibMesh.position
|
||||||
);
|
);
|
||||||
|
|
||||||
gameLibMesh.rotation = new GameLib.D3.Vector3.Runtime(
|
gameLibMesh.rotation = new GameLib.D3.Runtime.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
gameLibMesh,
|
gameLibMesh,
|
||||||
gameLibMesh.rotation
|
gameLibMesh.rotation
|
||||||
);
|
);
|
||||||
|
|
||||||
gameLibMesh.scale = new GameLib.D3.Vector3.Runtime(
|
gameLibMesh.scale = new GameLib.D3.Runtime.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
gameLibMesh,
|
gameLibMesh,
|
||||||
gameLibMesh.scale
|
gameLibMesh.scale
|
||||||
|
@ -566,6 +448,24 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
|
|
||||||
var activeCameraIndex = scene.activeCameraIndex;
|
var activeCameraIndex = scene.activeCameraIndex;
|
||||||
|
|
||||||
|
var splines = [];
|
||||||
|
|
||||||
|
for (var s = 0; 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(
|
var scene3d = new GameLib.D3.Scene(
|
||||||
graphics,
|
graphics,
|
||||||
progressCallback,
|
progressCallback,
|
||||||
|
@ -602,7 +502,8 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
components,
|
components,
|
||||||
shapes,
|
shapes,
|
||||||
cameras,
|
cameras,
|
||||||
activeCameraIndex
|
activeCameraIndex,
|
||||||
|
splines
|
||||||
),
|
),
|
||||||
imageFactory,
|
imageFactory,
|
||||||
meshIdToMesh
|
meshIdToMesh
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Spline constructor
|
* Spline constructor
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param apiSpline GameLib.D3.Spline.API
|
* @param apiSpline GameLib.D3.API.Spline
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Spline = function(
|
GameLib.D3.Spline = function(
|
||||||
|
@ -21,32 +21,6 @@ GameLib.D3.Spline = function(
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* API Spline
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Spline.API = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
vertices
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'spline-unnamed';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(vertices)) {
|
|
||||||
vertices = [];
|
|
||||||
}
|
|
||||||
this.vertices = vertices;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance spline
|
* Creates an instance spline
|
||||||
* @param update boolean
|
* @param update boolean
|
||||||
|
|
|
@ -62,24 +62,3 @@ GameLib.D3.TextureMapTemplate = function TextureMapTemplate(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw API Texture Map Template - should match the contents of the Material Schema (maps property)
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.TextureMapTemplate.API = function() {
|
|
||||||
return new GameLib.D3.TextureMaps(
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap(),
|
|
||||||
new GameLib.D3.TextureMap()
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
|
@ -43,31 +43,3 @@ GameLib.D3.TextureMaps = function TextureMaps(
|
||||||
this.roughness = roughness;
|
this.roughness = roughness;
|
||||||
this.specular = specular;
|
this.specular = specular;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.TextureMaps.API = function TextureMaps(
|
|
||||||
alpha,
|
|
||||||
ao,
|
|
||||||
bump,
|
|
||||||
diffuse,
|
|
||||||
displacement,
|
|
||||||
emissive,
|
|
||||||
environment,
|
|
||||||
light,
|
|
||||||
metalness,
|
|
||||||
normal,
|
|
||||||
roughness,
|
|
||||||
specular
|
|
||||||
) {
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_ALPHA] == alpha;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_AO] == ao;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_BUMP] == bump;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE] == diffuse;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_DISPLACEMENT] == displacement;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_EMISSIVE] == emissive;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_ENVIRONMENT] == environment;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_LIGHT] == light;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_METALNESS] == metalness;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_NORMAL] == normal;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_ROUGHNESS] == roughness;
|
|
||||||
this[GameLib.D3.Texture.TEXTURE_TYPE_SPECULAR] == specular;
|
|
||||||
};
|
|
|
@ -51,161 +51,6 @@ GameLib.D3.Texture.prototype.loadTexture = function(imageFactory) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw Texture API object - should always correspond with the Texture Schema
|
|
||||||
* @param id
|
|
||||||
* @param typeId
|
|
||||||
* @param name
|
|
||||||
* @param imagePath
|
|
||||||
* @param wrapS
|
|
||||||
* @param wrapT
|
|
||||||
* @param repeat
|
|
||||||
* @param data
|
|
||||||
* @param format
|
|
||||||
* @param mapping
|
|
||||||
* @param magFilter
|
|
||||||
* @param minFilter
|
|
||||||
* @param textureType
|
|
||||||
* @param anisotropy
|
|
||||||
* @param offset
|
|
||||||
* @param generateMipmaps
|
|
||||||
* @param flipY
|
|
||||||
* @param mipmaps
|
|
||||||
* @param unpackAlignment
|
|
||||||
* @param premultiplyAlpha
|
|
||||||
* @param encoding
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Texture.API = function(
|
|
||||||
id,
|
|
||||||
typeId,
|
|
||||||
name,
|
|
||||||
imagePath,
|
|
||||||
wrapS,
|
|
||||||
wrapT,
|
|
||||||
repeat,
|
|
||||||
data,
|
|
||||||
format,
|
|
||||||
mapping,
|
|
||||||
magFilter,
|
|
||||||
minFilter,
|
|
||||||
textureType,
|
|
||||||
anisotropy,
|
|
||||||
offset,
|
|
||||||
generateMipmaps,
|
|
||||||
flipY,
|
|
||||||
mipmaps,
|
|
||||||
unpackAlignment,
|
|
||||||
premultiplyAlpha,
|
|
||||||
encoding
|
|
||||||
) {
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.D3.Tools.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(typeId)) {
|
|
||||||
typeId = GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE;
|
|
||||||
}
|
|
||||||
this.typeId = typeId;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Texture (' + typeId + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(imagePath)) {
|
|
||||||
imagePath = null;
|
|
||||||
}
|
|
||||||
this.imagePath = imagePath;
|
|
||||||
|
|
||||||
if (typeof wrapS == 'undefined') {
|
|
||||||
wrapS = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING;
|
|
||||||
}
|
|
||||||
this.wrapS = wrapS;
|
|
||||||
|
|
||||||
if (typeof wrapT == 'undefined') {
|
|
||||||
wrapT = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING;
|
|
||||||
}
|
|
||||||
this.wrapT = wrapT;
|
|
||||||
|
|
||||||
if (typeof repeat == 'undefined') {
|
|
||||||
repeat = new GameLib.D3.Vector2(1, 1);
|
|
||||||
}
|
|
||||||
this.repeat = repeat;
|
|
||||||
|
|
||||||
if (typeof data == 'undefined') {
|
|
||||||
data = null;
|
|
||||||
}
|
|
||||||
this.data = data;
|
|
||||||
|
|
||||||
if (typeof format == 'undefined') {
|
|
||||||
format = GameLib.D3.Texture.TYPE_RGBA_FORMAT;
|
|
||||||
}
|
|
||||||
this.format = format;
|
|
||||||
|
|
||||||
if (typeof mapping == 'undefined') {
|
|
||||||
mapping = GameLib.D3.Texture.TYPE_UV_MAPPING;
|
|
||||||
}
|
|
||||||
this.mapping = mapping;
|
|
||||||
|
|
||||||
if (typeof magFilter == 'undefined') {
|
|
||||||
magFilter = GameLib.D3.Texture.TYPE_LINEAR_FILTER;
|
|
||||||
}
|
|
||||||
this.magFilter = magFilter;
|
|
||||||
|
|
||||||
if (typeof minFilter == 'undefined') {
|
|
||||||
minFilter = GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
|
|
||||||
}
|
|
||||||
this.minFilter = minFilter;
|
|
||||||
|
|
||||||
if (typeof textureType == 'undefined') {
|
|
||||||
textureType = GameLib.D3.Texture.TYPE_UNSIGNED_BYTE;
|
|
||||||
}
|
|
||||||
this.textureType = textureType;
|
|
||||||
|
|
||||||
if (typeof anisotropy == 'undefined') {
|
|
||||||
anisotropy = 1;
|
|
||||||
}
|
|
||||||
this.anisotropy = anisotropy;
|
|
||||||
|
|
||||||
if (typeof offset == 'undefined') {
|
|
||||||
offset = new GameLib.D3.Vector2(0, 0);
|
|
||||||
}
|
|
||||||
this.offset = offset;
|
|
||||||
|
|
||||||
if (typeof generateMipmaps == 'undefined') {
|
|
||||||
generateMipmaps = true;
|
|
||||||
}
|
|
||||||
this.generateMipmaps = generateMipmaps;
|
|
||||||
|
|
||||||
if (typeof flipY == 'undefined') {
|
|
||||||
flipY = true;
|
|
||||||
}
|
|
||||||
this.flipY = flipY;
|
|
||||||
|
|
||||||
if (typeof mipmaps == 'undefined') {
|
|
||||||
mipmaps = [];
|
|
||||||
}
|
|
||||||
this.mipmaps = mipmaps;
|
|
||||||
|
|
||||||
if (typeof unpackAlignment == 'undefined') {
|
|
||||||
unpackAlignment = 4;
|
|
||||||
}
|
|
||||||
this.unpackAlignment = unpackAlignment;
|
|
||||||
|
|
||||||
if (typeof premultiplyAlpha == 'undefined') {
|
|
||||||
premultiplyAlpha = false;
|
|
||||||
}
|
|
||||||
this.premultiplyAlpha = premultiplyAlpha;
|
|
||||||
|
|
||||||
if (typeof encoding == 'undefined') {
|
|
||||||
encoding = GameLib.D3.Texture.TYPE_LINEAR_ENCODING;
|
|
||||||
}
|
|
||||||
this.encoding = encoding;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Texture Formats
|
* Texture Formats
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|
|
@ -1,56 +1,4 @@
|
||||||
GameLib.D3.Vector3 = function Vector3(x, y, z) {
|
GameLib.D3.Vector3 = GameLib.D3.API.Vector3;
|
||||||
this.x = x || 0;
|
|
||||||
this.y = y || 0;
|
|
||||||
this.z = z || 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runtime vector for updating instance objects
|
|
||||||
* @param graphics GameLib.D3.Graphics
|
|
||||||
* @param parentObject GameLib.D3.*
|
|
||||||
* @param apiVector GameLib.D3.Vector3
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Vector3.Runtime = function RuntimeVector3(graphics, parentObject, apiVector) {
|
|
||||||
|
|
||||||
for (var property in apiVector) {
|
|
||||||
if (apiVector.hasOwnProperty(property)) {
|
|
||||||
this[property] = apiVector[property];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.Vector3.Runtime, GameLib.D3.Vector3);
|
|
||||||
|
|
||||||
this.apiVector = apiVector;
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
this.parentObject = parentObject;
|
|
||||||
|
|
||||||
this.grain = 0.001;
|
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.Runtime.prototype.createInstance = function() {
|
|
||||||
return new this.graphics.instance.Vector3(this.x, this.y, this.z);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.Runtime.prototype.updateInstance = function() {
|
|
||||||
|
|
||||||
if (this.parentObject.updateInstance) {
|
|
||||||
this.parentObject.updateInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.apiVector.x = this.x;
|
|
||||||
this.apiVector.y = this.y;
|
|
||||||
this.apiVector.z = this.z;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.subtract = function (v) {
|
GameLib.D3.Vector3.prototype.subtract = function (v) {
|
||||||
return new GameLib.D3.Vector3(
|
return new GameLib.D3.Vector3(
|
||||||
|
|
Loading…
Reference in New Issue