whole runtime refactoring
parent
46a00d4fb1
commit
6d3c30fee5
|
@ -4,7 +4,7 @@
|
||||||
* @param weight float
|
* @param weight float
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.BoneWeight = function BoneWeight(
|
GameLib.D3.API.BoneWeight = function BoneWeight(
|
||||||
boneIndex,
|
boneIndex,
|
||||||
weight
|
weight
|
||||||
) {
|
) {
|
|
@ -8,11 +8,11 @@
|
||||||
* @param quaternion
|
* @param quaternion
|
||||||
* @param position
|
* @param position
|
||||||
* @param rotation
|
* @param rotation
|
||||||
* @param scale GameLib.D3.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param up
|
* @param up
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Bone = function Bone(
|
GameLib.D3.API.Bone = function Bone(
|
||||||
id,
|
id,
|
||||||
boneId,
|
boneId,
|
||||||
name,
|
name,
|
||||||
|
@ -39,27 +39,27 @@ GameLib.D3.Bone = function Bone(
|
||||||
this.parentBoneId = parentBoneId;
|
this.parentBoneId = parentBoneId;
|
||||||
|
|
||||||
if (typeof quaternion == 'undefined') {
|
if (typeof quaternion == 'undefined') {
|
||||||
quaternion = new GameLib.D3.Vector4();
|
quaternion = new GameLib.D3.API.Vector4();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
if (typeof position == 'undefined') {
|
if (typeof position == 'undefined') {
|
||||||
position = new GameLib.D3.Vector3(0,0,0);
|
position = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (typeof rotation == 'undefined') {
|
if (typeof rotation == 'undefined') {
|
||||||
rotation = new GameLib.D3.Vector3(0,0,0);
|
rotation = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
|
||||||
if (typeof scale == 'undefined') {
|
if (typeof scale == 'undefined') {
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
scale = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
if (typeof up == 'undefined') {
|
if (typeof up == 'undefined') {
|
||||||
up = new GameLib.D3.Vector3(0,1,0);
|
up = new GameLib.D3.API.Vector3(0,1,0);
|
||||||
}
|
}
|
||||||
this.up = up;
|
this.up = up;
|
||||||
};
|
};
|
|
@ -7,8 +7,8 @@
|
||||||
* @param aspect
|
* @param aspect
|
||||||
* @param near
|
* @param near
|
||||||
* @param far
|
* @param far
|
||||||
* @param position GameLib.D3.Vector3
|
* @param position GameLib.D3.API.Vector3
|
||||||
* @param lookAt GameLib.D3.Vector3
|
* @param lookAt GameLib.D3.API.Vector3
|
||||||
* @param minX
|
* @param minX
|
||||||
* @param maxX
|
* @param maxX
|
||||||
* @param minY
|
* @param minY
|
||||||
|
@ -70,7 +70,7 @@ GameLib.D3.API.Camera = function(
|
||||||
this.far = far;
|
this.far = far;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
position = new GameLib.D3.Vector3(
|
position = new GameLib.D3.API.Vector3(
|
||||||
15,
|
15,
|
||||||
15,
|
15,
|
||||||
15
|
15
|
||||||
|
@ -79,7 +79,7 @@ GameLib.D3.API.Camera = function(
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(lookAt)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(lookAt)) {
|
||||||
lookAt = new GameLib.D3.Vector3(
|
lookAt = new GameLib.D3.API.Vector3(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
|
|
|
@ -99,12 +99,12 @@ GameLib.D3.API.ComponentInterface = function(
|
||||||
this.camera = camera;
|
this.camera = camera;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(startColor)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(startColor)) {
|
||||||
startColor = new GameLib.D3.Vector3(0, 0, 0);
|
startColor = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
}
|
}
|
||||||
this.startColor = startColor;
|
this.startColor = startColor;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(endColor)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(endColor)) {
|
||||||
endColor = new GameLib.D3.Vector3(1, 1, 1);
|
endColor = new GameLib.D3.API.Vector3(1, 1, 1);
|
||||||
}
|
}
|
||||||
this.endColor = endColor;
|
this.endColor = endColor;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ GameLib.D3.API.ComponentInterface = function(
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
targetOffset = new GameLib.D3.Vector3(0, 0, 0);
|
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
}
|
}
|
||||||
this.targetOffset = targetOffset;
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
|
@ -139,17 +139,17 @@ GameLib.D3.API.ComponentInterface = function(
|
||||||
this.rotationSpeed = rotationSpeed;
|
this.rotationSpeed = rotationSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(positionOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(positionOffset)) {
|
||||||
positionOffset = new GameLib.D3.Vector3();
|
positionOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.positionOffset = positionOffset;
|
this.positionOffset = positionOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternionOffset)) {
|
||||||
quaternionOffset = new GameLib.D3.Vector4();
|
quaternionOffset = new GameLib.D3.API.Vector4();
|
||||||
}
|
}
|
||||||
this.quaternionOffset = quaternionOffset;
|
this.quaternionOffset = quaternionOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
||||||
scaleOffset = new GameLib.D3.Vector3();
|
scaleOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.scaleOffset = scaleOffset;
|
this.scaleOffset = scaleOffset;
|
||||||
|
|
||||||
|
@ -179,12 +179,12 @@ GameLib.D3.API.ComponentInterface = function(
|
||||||
this.maxSpeed = maxSpeed;
|
this.maxSpeed = maxSpeed;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(baseOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(baseOffset)) {
|
||||||
baseOffset = new GameLib.D3.Vector3();
|
baseOffset = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.baseOffset = baseOffset;
|
this.baseOffset = baseOffset;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(maxOffset)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(maxOffset)) {
|
||||||
maxOffset = new GameLib.D3.Vector3(10, 10, 10);
|
maxOffset = new GameLib.D3.API.Vector3(10, 10, 10);
|
||||||
}
|
}
|
||||||
this.maxOffset = maxOffset;
|
this.maxOffset = maxOffset;
|
||||||
|
|
||||||
|
|
|
@ -36,17 +36,17 @@ GameLib.D3.API.Entity = function Entity(
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(position)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
position = new GameLib.D3.Vector3();
|
position = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.Vector4();
|
quaternion = new GameLib.D3.API.Vector4();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
scale = new GameLib.D3.Vector3(1, 1, 1);
|
scale = new GameLib.D3.API.Vector3(1, 1, 1);
|
||||||
}
|
}
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ GameLib.D3.API.Light = function(
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
||||||
color = new GameLib.D3.Color(1,1,1,1);
|
color = new GameLib.D3.API.Color(1,1,1,1);
|
||||||
}
|
}
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
|
@ -60,27 +60,27 @@ GameLib.D3.API.Light = function(
|
||||||
this.intensity = intensity;
|
this.intensity = intensity;
|
||||||
|
|
||||||
if (typeof position == 'undefined') {
|
if (typeof position == 'undefined') {
|
||||||
position = new GameLib.D3.Vector3(0,10,0);
|
position = new GameLib.D3.API.Vector3(0,10,0);
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (typeof targetPosition == 'undefined') {
|
if (typeof targetPosition == 'undefined') {
|
||||||
targetPosition = new GameLib.D3.Vector3(0,0,0);
|
targetPosition = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
this.targetPosition = targetPosition;
|
this.targetPosition = targetPosition;
|
||||||
|
|
||||||
if (typeof quaternion == 'undefined'){
|
if (typeof quaternion == 'undefined'){
|
||||||
quaternion = new GameLib.D3.Vector4();
|
quaternion = new GameLib.D3.API.Vector4();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
if (typeof rotation == 'undefined'){
|
if (typeof rotation == 'undefined'){
|
||||||
rotation = new GameLib.D3.Vector3(0,0,0);
|
rotation = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
|
||||||
if (typeof scale == 'undefined'){
|
if (typeof scale == 'undefined'){
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
scale = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ GameLib.D3.API.Material = function(
|
||||||
this.maps = maps;
|
this.maps = maps;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(specular)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(specular)) {
|
||||||
specular = new GameLib.D3.Color(0.06, 0.06, 0.06, 0.06);
|
specular = new GameLib.D3.API.Color(0.06, 0.06, 0.06, 0.06);
|
||||||
}
|
}
|
||||||
this.specular = specular;
|
this.specular = specular;
|
||||||
|
|
||||||
|
@ -169,12 +169,12 @@ GameLib.D3.API.Material = function(
|
||||||
this.aoMapIntensity = aoMapIntensity;
|
this.aoMapIntensity = aoMapIntensity;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(color)) {
|
||||||
color = new GameLib.D3.Color(1, 1, 1, 1)
|
color = new GameLib.D3.API.Color(1, 1, 1, 1)
|
||||||
}
|
}
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(emissive)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(emissive)) {
|
||||||
emissive = new GameLib.D3.Color(0, 0, 0, 0);
|
emissive = new GameLib.D3.API.Color(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
this.emissive = emissive;
|
this.emissive = emissive;
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
* @param skeleton
|
* @param skeleton
|
||||||
* @param skinIndices
|
* @param skinIndices
|
||||||
* @param skinWeights
|
* @param skinWeights
|
||||||
* @param position GameLib.D3.Vector3
|
* @param position GameLib.D3.API.Vector3
|
||||||
* @param quaternion GameLib.D3.Vector4
|
* @param quaternion GameLib.D3.API.Vector4
|
||||||
* @param rotation GameLib.D3.Vector3
|
* @param rotation GameLib.D3.API.Vector3
|
||||||
* @param scale GameLib.D3.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param up
|
* @param up
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -99,27 +99,27 @@ GameLib.D3.API.Mesh = function(
|
||||||
this.materials = materials;
|
this.materials = materials;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
position = new GameLib.D3.Vector3(0,0,0);
|
position = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.Vector4();
|
quaternion = new GameLib.D3.API.Vector4();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
||||||
rotation = new GameLib.D3.Vector3(0,0,0);
|
rotation = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
scale = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(up)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(up)) {
|
||||||
up = new GameLib.D3.Vector3(0,1,0);
|
up = new GameLib.D3.API.Vector3(0,1,0);
|
||||||
}
|
}
|
||||||
this.up = up;
|
this.up = up;
|
||||||
};
|
};
|
|
@ -4,10 +4,10 @@
|
||||||
* @param path String
|
* @param path String
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param meshes GameLib.D3.API.Mesh []
|
* @param meshes GameLib.D3.API.Mesh []
|
||||||
* @param quaternion GameLib.D3.Vector4
|
* @param quaternion GameLib.D3.API.Vector4
|
||||||
* @param position GameLib.D3.Vector3
|
* @param position GameLib.D3.API.Vector3
|
||||||
* @param rotation GameLib.D3.Vector3
|
* @param rotation GameLib.D3.API.Vector3
|
||||||
* @param scale GameLib.D3.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param parentSceneId
|
* @param parentSceneId
|
||||||
* @param lights GameLib.D3.API.Light[]
|
* @param lights GameLib.D3.API.Light[]
|
||||||
* @param worlds GameLib.D3.API.World[]
|
* @param worlds GameLib.D3.API.World[]
|
||||||
|
@ -58,22 +58,22 @@ GameLib.D3.API.Scene = function(
|
||||||
this.meshes = meshes;
|
this.meshes = meshes;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
|
||||||
quaternion = new GameLib.D3.Vector4();
|
quaternion = new GameLib.D3.API.Vector4();
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(position)) {
|
||||||
position = new GameLib.D3.Vector3();
|
position = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
|
||||||
rotation = new GameLib.D3.Vector3();
|
rotation = new GameLib.D3.API.Vector3();
|
||||||
}
|
}
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
|
||||||
scale = new GameLib.D3.Vector3(1,1,1);
|
scale = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ GameLib.D3.API.Texture = function(
|
||||||
this.wrapT = wrapT;
|
this.wrapT = wrapT;
|
||||||
|
|
||||||
if (typeof repeat == 'undefined') {
|
if (typeof repeat == 'undefined') {
|
||||||
repeat = new GameLib.D3.Vector2(1, 1);
|
repeat = new GameLib.D3.API.Vector2(1, 1);
|
||||||
}
|
}
|
||||||
this.repeat = repeat;
|
this.repeat = repeat;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ GameLib.D3.API.Texture = function(
|
||||||
this.anisotropy = anisotropy;
|
this.anisotropy = anisotropy;
|
||||||
|
|
||||||
if (typeof offset == 'undefined') {
|
if (typeof offset == 'undefined') {
|
||||||
offset = new GameLib.D3.Vector2(0, 0);
|
offset = new GameLib.D3.API.Vector2(0, 0);
|
||||||
}
|
}
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,11 @@ GameLib.D3.Camera = function Camera(
|
||||||
this.position
|
this.position
|
||||||
);
|
);
|
||||||
|
|
||||||
this.offsetPosition = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,5,5));
|
this.lookAt = new GameLib.D3.Runtime.Vector3(
|
||||||
|
graphics,
|
||||||
delete this.offsetPosition.updateInstance;
|
this,
|
||||||
|
this.lookAt
|
||||||
|
);
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/**
|
|
||||||
* Color Superset
|
|
||||||
* @param r
|
|
||||||
* @param g
|
|
||||||
* @param b
|
|
||||||
* @param a
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Color = function Color(r, g, b, a) {
|
|
||||||
this.r = r;
|
|
||||||
this.g = g;
|
|
||||||
this.b = b;
|
|
||||||
this.a = a;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the current color to HTML hex format (ex. #ffffff)
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Color.prototype.toHex = function() {
|
|
||||||
|
|
||||||
var rf = Math.floor(this.r == 1? 255 : this.r * 256.0).toString(16);
|
|
||||||
var gf = Math.floor(this.g == 1? 255 : this.g * 256.0).toString(16);
|
|
||||||
var bf = Math.floor(this.b == 1? 255 : this.b * 256.0).toString(16);
|
|
||||||
|
|
||||||
return '#' + rf + gf + bf;
|
|
||||||
};
|
|
|
@ -16,8 +16,8 @@ GameLib.D3.ComponentColorLerp = function(
|
||||||
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentColorLerp, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentColorLerp, GameLib.D3.ComponentInterface);
|
||||||
|
|
||||||
this.startColor = startColor || new GameLib.D3.Vector3(0, 0, 0);
|
this.startColor = startColor || new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.endColor = endColor || new GameLib.D3.Vector3(1, 1, 1);
|
this.endColor = endColor || new GameLib.D3.API.Vector3(1, 1, 1);
|
||||||
this.lerpSpeed = lerpSpeed || 1.0;
|
this.lerpSpeed = lerpSpeed || 1.0;
|
||||||
|
|
||||||
this.lerpTarget = this.endColor;
|
this.lerpTarget = this.endColor;
|
||||||
|
|
|
@ -19,7 +19,7 @@ GameLib.D3.ComponentEntityParent = function ComponentEntityParent(
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
this.originPosition = new GameLib.D3.Vector3(0, 0, 0);
|
this.originPosition = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
|
||||||
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentEntityParent, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentEntityParent, GameLib.D3.ComponentInterface);
|
||||||
|
|
|
@ -23,9 +23,9 @@ GameLib.D3.ComponentEntityPermutation = function ComponentEntityPermutation(
|
||||||
|
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
this.positionOffset = positionOffset || new GameLib.D3.Vector3(0, 0, 0);
|
this.positionOffset = positionOffset || new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.quaternionOffset = quaternionOffset || new GameLib.D3.Vector4(0, 0, 0, 1);
|
this.quaternionOffset = quaternionOffset || new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
||||||
this.scaleOffset = scaleOffset || new GameLib.D3.Vector3(0, 0, 0);
|
this.scaleOffset = scaleOffset || new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
|
||||||
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentEntityPermutation, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentEntityPermutation, GameLib.D3.ComponentInterface);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param targetEntity GameLib.D3.Entity
|
* @param targetEntity GameLib.D3.Entity
|
||||||
* @param targetOffset GameLib.D3.Vector3
|
* @param targetOffset GameLib.D3.API.Vector3
|
||||||
* @param minDistance
|
* @param minDistance
|
||||||
* @param moveSpeed
|
* @param moveSpeed
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -34,7 +34,7 @@ GameLib.D3.ComponentFollow = function ComponentFollow(
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
targetOffset = new GameLib.D3.Vector3(0, 0, 0);
|
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
}
|
}
|
||||||
this.targetOffset = targetOffset;
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ GameLib.D3.ComponentLookAt = function ComponentLookAt(
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(targetOffset)) {
|
||||||
targetOffset = new GameLib.D3.Vector3(0, 0, 0);
|
targetOffset = new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
}
|
}
|
||||||
this.targetOffset = targetOffset;
|
this.targetOffset = targetOffset;
|
||||||
|
|
||||||
this.lastTargetQuaternion = new GameLib.D3.Vector4(0, 0, 0, 1);
|
this.lastTargetQuaternion = new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
||||||
this.rotationSpeed = rotationSpeed || 22.0;
|
this.rotationSpeed = rotationSpeed || 22.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ GameLib.D3.ComponentMeshPermutation = function ComponentMeshPermutation(
|
||||||
|
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
this.positionOffset = positionOffset || new GameLib.D3.Vector3(0, 0, 0);
|
this.positionOffset = positionOffset || new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
this.quaternionOffset = quaternionOffset || new GameLib.D3.Vector4(0, 0, 0, 1);
|
this.quaternionOffset = quaternionOffset || new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
||||||
this.scaleOffset = scaleOffset || new GameLib.D3.Vector3(0, 0, 0);
|
this.scaleOffset = scaleOffset || new GameLib.D3.API.Vector3(0, 0, 0);
|
||||||
|
|
||||||
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface);
|
||||||
|
|
|
@ -36,15 +36,15 @@ GameLib.D3.ComponentPathFollowing = function ComponentPathFollowing(
|
||||||
this.maxSpeed = maxSpeed || 10.0;
|
this.maxSpeed = maxSpeed || 10.0;
|
||||||
this.acceleration = acceleration || 2.0;
|
this.acceleration = acceleration || 2.0;
|
||||||
|
|
||||||
this.baseOffset = baseOffset || new GameLib.D3.Vector3();
|
this.baseOffset = baseOffset || new GameLib.D3.API.Vector3();
|
||||||
this.maxOffset = maxOffset || new GameLib.D3.Vector3(10, 10, 10);
|
this.maxOffset = maxOffset || new GameLib.D3.API.Vector3(10, 10, 10);
|
||||||
this.steeringSpeed = steeringSpeed || 1.0;
|
this.steeringSpeed = steeringSpeed || 1.0;
|
||||||
|
|
||||||
|
|
||||||
//#ifdef RUNTIME__
|
//#ifdef RUNTIME__
|
||||||
// runtime code
|
// runtime code
|
||||||
this.offset = new GameLib.D3.Vector3(); // this one is our destination offset
|
this.offset = new GameLib.D3.API.Vector3(); // this one is our destination offset
|
||||||
this.currentOffset = new GameLib.D3.Vector3();
|
this.currentOffset = new GameLib.D3.API.Vector3();
|
||||||
this.currentPathValue = 0.0;
|
this.currentPathValue = 0.0;
|
||||||
this.currentSpeed = 0.0;
|
this.currentSpeed = 0.0;
|
||||||
this.direction = 0;
|
this.direction = 0;
|
||||||
|
|
|
@ -548,10 +548,10 @@ GameLib.D3.ComponentVehicleAIObjectAvoidance.prototype.onUpdate = function(
|
||||||
var cos = avgMoveVector.dot(forward);
|
var cos = avgMoveVector.dot(forward);
|
||||||
|
|
||||||
var angleRadians = Math.acos(cos);
|
var angleRadians = Math.acos(cos);
|
||||||
var steerAngleModifier = GameLib.D3.Vector3.AngleDirection(
|
var steerAngleModifier = GameLib.D3.API.Vector3.AngleDirection(
|
||||||
forward,
|
forward,
|
||||||
avgMoveVector,
|
avgMoveVector,
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
0
|
0
|
||||||
|
|
|
@ -111,10 +111,10 @@ GameLib.D3.ComponentVehicleAIPathSteering.prototype.onUpdate = function(
|
||||||
|
|
||||||
var cos = v1v2cpy.dot(forwardcpy);
|
var cos = v1v2cpy.dot(forwardcpy);
|
||||||
var angleRadians = Math.acos(cos);
|
var angleRadians = Math.acos(cos);
|
||||||
var steerAngleModifier = GameLib.D3.Vector3.AngleDirection(
|
var steerAngleModifier = GameLib.D3.API.Vector3.AngleDirection(
|
||||||
forwardcpy,
|
forwardcpy,
|
||||||
v1v2cpy,
|
v1v2cpy,
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
0
|
0
|
||||||
|
|
|
@ -14,6 +14,37 @@ GameLib.D3.Light = function Light(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.color = new GameLib.D3.Runtime.Color(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.color,
|
||||||
|
0.01
|
||||||
|
);
|
||||||
|
|
||||||
|
this.position = new GameLib.D3.Runtime.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.position
|
||||||
|
);
|
||||||
|
|
||||||
|
this.targetPosition = new GameLib.D3.Runtime.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.targetPosition
|
||||||
|
);
|
||||||
|
|
||||||
|
this.scale = new GameLib.D3.Runtime.Vector3(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.scale
|
||||||
|
);
|
||||||
|
|
||||||
|
this.quaternion = new GameLib.D3.Runtime.Vector4(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.quaternion
|
||||||
|
);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
@ -41,8 +72,7 @@ GameLib.D3.Light.prototype.createInstance = function(update) {
|
||||||
instance = this.instance;
|
instance = this.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!instance) ||
|
if (!instance) {
|
||||||
(instance && instance.lightType != this.lightType)) {
|
|
||||||
|
|
||||||
if (this.lightType == GameLib.D3.Light.LIGHT_TYPE_AMBIENT) {
|
if (this.lightType == GameLib.D3.Light.LIGHT_TYPE_AMBIENT) {
|
||||||
instance = new this.graphics.instance.AmbientLight(
|
instance = new this.graphics.instance.AmbientLight(
|
||||||
|
@ -108,9 +138,24 @@ GameLib.D3.Light.prototype.createInstance = function(update) {
|
||||||
instance.position.y = this.position.y;
|
instance.position.y = this.position.y;
|
||||||
instance.position.z = this.position.z;
|
instance.position.z = this.position.z;
|
||||||
|
|
||||||
instance.rotation.x = this.rotation.x;
|
instance.scale.x = this.scale.x;
|
||||||
instance.rotation.y = this.rotation.y;
|
instance.scale.y = this.scale.y;
|
||||||
instance.rotation.z = this.rotation.z;
|
instance.scale.z = this.scale.z;
|
||||||
|
|
||||||
|
if (instance.target) {
|
||||||
|
instance.target.x = this.targetPosition.x;
|
||||||
|
instance.target.y = this.targetPosition.y;
|
||||||
|
instance.target.z = this.targetPosition.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.quaternion.x = this.quaternion.x;
|
||||||
|
instance.quaternion.y = this.quaternion.y;
|
||||||
|
instance.quaternion.z = this.quaternion.z;
|
||||||
|
instance.quaternion.w = this.quaternion.w;
|
||||||
|
|
||||||
|
instance.intensity = this.intensity;
|
||||||
|
|
||||||
|
instance.color.set(this.color.toHex());
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,24 @@ GameLib.D3.Material = function Material(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.specular = new GameLib.D3.Runtime.Color(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.specular
|
||||||
|
);
|
||||||
|
|
||||||
|
this.color = new GameLib.D3.Runtime.Color(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.color
|
||||||
|
);
|
||||||
|
|
||||||
|
this.emissive = new GameLib.D3.Runtime.Color(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.emissive
|
||||||
|
);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Matrix 3 Maths
|
* Matrix 3 Maths
|
||||||
* @param row0 GameLib.D3.Vector3
|
* @param row0 GameLib.D3.API.Vector3
|
||||||
* @param row1 GameLib.D3.Vector3
|
* @param row1 GameLib.D3.API.Vector3
|
||||||
* @param row2 GameLib.D3.Vector3
|
* @param row2 GameLib.D3.API.Vector3
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Matrix3 = function(
|
GameLib.D3.Matrix3 = function(
|
||||||
|
@ -30,8 +30,8 @@ GameLib.D3.Matrix3 = function(
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Matrix3.prototype.identity = function () {
|
GameLib.D3.Matrix3.prototype.identity = function () {
|
||||||
this.rows = [
|
this.rows = [
|
||||||
new GameLib.D3.Vector4(1, 0, 0),
|
new GameLib.D3.API.Vector4(1, 0, 0),
|
||||||
new GameLib.D3.Vector4(0, 1, 0),
|
new GameLib.D3.API.Vector4(0, 1, 0),
|
||||||
new GameLib.D3.Vector4(0, 0, 1)
|
new GameLib.D3.API.Vector4(0, 0, 1)
|
||||||
];
|
];
|
||||||
};
|
};
|
|
@ -26,20 +26,20 @@ GameLib.D3.Matrix4 = function(
|
||||||
|
|
||||||
GameLib.D3.Matrix4.prototype.rotationMatrixX = function (radians) {
|
GameLib.D3.Matrix4.prototype.rotationMatrixX = function (radians) {
|
||||||
this.identity();
|
this.identity();
|
||||||
this.rows[1] = new GameLib.D3.Vector4(0, Math.cos(radians), -1 * Math.sin(radians), 0);
|
this.rows[1] = new GameLib.D3.API.Vector4(0, Math.cos(radians), -1 * Math.sin(radians), 0);
|
||||||
this.rows[2] = new GameLib.D3.Vector4(0, Math.sin(radians), Math.cos(radians), 0);
|
this.rows[2] = new GameLib.D3.API.Vector4(0, Math.sin(radians), Math.cos(radians), 0);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Matrix4.prototype.rotationMatrixY = function (radians) {
|
GameLib.D3.Matrix4.prototype.rotationMatrixY = function (radians) {
|
||||||
this.identity();
|
this.identity();
|
||||||
this.rows[0] = new GameLib.D3.Vector4(
|
this.rows[0] = new GameLib.D3.API.Vector4(
|
||||||
Math.cos(radians),
|
Math.cos(radians),
|
||||||
0,
|
0,
|
||||||
Math.sin(radians),
|
Math.sin(radians),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
this.rows[2] = new GameLib.D3.Vector4(
|
this.rows[2] = new GameLib.D3.API.Vector4(
|
||||||
-1 * Math.sin(radians),
|
-1 * Math.sin(radians),
|
||||||
0,
|
0,
|
||||||
Math.cos(radians),
|
Math.cos(radians),
|
||||||
|
@ -50,8 +50,8 @@ GameLib.D3.Matrix4.prototype.rotationMatrixY = function (radians) {
|
||||||
|
|
||||||
GameLib.D3.Matrix4.prototype.rotationMatrixZ = function (radians) {
|
GameLib.D3.Matrix4.prototype.rotationMatrixZ = function (radians) {
|
||||||
this.identity();
|
this.identity();
|
||||||
this.rows[0] = new GameLib.D3.Vector4(Math.cos(radians), -1 * Math.sin(radians), 0, 0);
|
this.rows[0] = new GameLib.D3.API.Vector4(Math.cos(radians), -1 * Math.sin(radians), 0, 0);
|
||||||
this.rows[1] = new GameLib.D3.Vector4(Math.sin(radians), Math.cos(radians), 0, 0);
|
this.rows[1] = new GameLib.D3.API.Vector4(Math.sin(radians), Math.cos(radians), 0, 0);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,15 +74,15 @@ GameLib.D3.Matrix4.prototype.rotateZ = function (radians, point) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Matrix4.prototype.multiply = function (mvp) {
|
GameLib.D3.Matrix4.prototype.multiply = function (mvp) {
|
||||||
if (mvp instanceof GameLib.D3.Vector4) {
|
if (mvp instanceof GameLib.D3.API.Vector4) {
|
||||||
return new GameLib.D3.Vector4(
|
return new GameLib.D3.API.Vector4(
|
||||||
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w,
|
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w,
|
||||||
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w,
|
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w,
|
||||||
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w,
|
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w,
|
||||||
this.rows[3].x * mvp.x + this.rows[3].y * mvp.y + this.rows[3].z * mvp.z + this.rows[3].w * mvp.w
|
this.rows[3].x * mvp.x + this.rows[3].y * mvp.y + this.rows[3].z * mvp.z + this.rows[3].w * mvp.w
|
||||||
);
|
);
|
||||||
} else if (mvp instanceof GameLib.D3.Vector3) {
|
} else if (mvp instanceof GameLib.D3.API.Vector3) {
|
||||||
return new GameLib.D3.Vector3(
|
return new GameLib.D3.API.Vector3(
|
||||||
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z,
|
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z,
|
||||||
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z,
|
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z,
|
||||||
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z
|
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z
|
||||||
|
@ -92,16 +92,16 @@ GameLib.D3.Matrix4.prototype.multiply = function (mvp) {
|
||||||
|
|
||||||
GameLib.D3.Matrix4.prototype.identity = function () {
|
GameLib.D3.Matrix4.prototype.identity = function () {
|
||||||
this.rows = [
|
this.rows = [
|
||||||
new GameLib.D3.Vector4(1, 0, 0, 0),
|
new GameLib.D3.API.Vector4(1, 0, 0, 0),
|
||||||
new GameLib.D3.Vector4(0, 1, 0, 0),
|
new GameLib.D3.API.Vector4(0, 1, 0, 0),
|
||||||
new GameLib.D3.Vector4(0, 0, 1, 0),
|
new GameLib.D3.API.Vector4(0, 0, 1, 0),
|
||||||
new GameLib.D3.Vector4(0, 0, 0, 1)
|
new GameLib.D3.API.Vector4(0, 0, 0, 1)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Matrix4.prototype.lookAt = function (position, target, up) {
|
GameLib.D3.Matrix4.prototype.lookAt = function (position, target, up) {
|
||||||
|
|
||||||
var pv = new GameLib.D3.Vector3(position.x, position.y, position.z);
|
var pv = new GameLib.D3.API.Vector3(position.x, position.y, position.z);
|
||||||
|
|
||||||
var z = pv.subtract(target).normalize();
|
var z = pv.subtract(target).normalize();
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,15 @@ GameLib.D3.Mesh = function Mesh(
|
||||||
|
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
|
|
||||||
this.offsetRotation = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
this.offsetRotation = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.API.Vector3(0,0,0));
|
||||||
|
|
||||||
delete this.offsetRotation.updateInstance;
|
delete this.offsetRotation.updateInstance;
|
||||||
|
|
||||||
// this.lookAtPoint = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
// this.lookAtPoint = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.API.Vector3(0,0,0));
|
||||||
//
|
//
|
||||||
// delete this.offsetRotation.updateInstance;
|
// delete this.offsetRotation.updateInstance;
|
||||||
//
|
//
|
||||||
// this.offsetRotation = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.Vector3(0,0,0));
|
// this.offsetRotation = new GameLib.D3.Runtime.Vector3(graphics, this, new GameLib.D3.API.Vector3(0,0,0));
|
||||||
//
|
//
|
||||||
// delete this.offsetRotation.updateInstance;
|
// delete this.offsetRotation.updateInstance;
|
||||||
|
|
||||||
|
@ -340,10 +340,10 @@ GameLib.D3.prototype.invertWindingOrder = function(triangles) {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.prototype.resetWindingOrder = function(faces, vertices) {
|
GameLib.D3.prototype.resetWindingOrder = function(faces, vertices) {
|
||||||
|
|
||||||
var vertexList = new GameLib.D3.Vector3.Points();
|
var vertexList = new GameLib.D3.API.Vector3.Points();
|
||||||
|
|
||||||
for (var v = 0; v < vertices.length; v++) {
|
for (var v = 0; v < vertices.length; v++) {
|
||||||
vertexList.add(new GameLib.D3.Vector3(
|
vertexList.add(new GameLib.D3.API.Vector3(
|
||||||
vertices[v].position.x,
|
vertices[v].position.x,
|
||||||
vertices[v].position.y,
|
vertices[v].position.y,
|
||||||
vertices[v].position.z
|
vertices[v].position.z
|
||||||
|
@ -379,7 +379,7 @@ GameLib.D3.prototype.resetWindingOrder = function(faces, vertices) {
|
||||||
|
|
||||||
for (var i = 0; i < triangles.length; i++) {
|
for (var i = 0; i < triangles.length; i++) {
|
||||||
if (
|
if (
|
||||||
GameLib.D3.Vector3.clockwise(
|
GameLib.D3.API.Vector3.clockwise(
|
||||||
vertices[triangles[i].v0].position,
|
vertices[triangles[i].v0].position,
|
||||||
vertices[triangles[i].v1].position,
|
vertices[triangles[i].v1].position,
|
||||||
vertices[triangles[i].v2].position,
|
vertices[triangles[i].v2].position,
|
||||||
|
@ -420,7 +420,7 @@ GameLib.D3.prototype.resetWindingOrder = function(faces, vertices) {
|
||||||
* if neighbor_tria exists and neighbor_tria not in processed:
|
* if neighbor_tria exists and neighbor_tria not in processed:
|
||||||
* to_process add (neighbor_tria, edge opposite oriented (BA))
|
* to_process add (neighbor_tria, edge opposite oriented (BA))
|
||||||
* @param faces GameLib.D3.TriangleFace[]
|
* @param faces GameLib.D3.TriangleFace[]
|
||||||
* @param orientationEdge GameLib.D3.Vector2
|
* @param orientationEdge GameLib.D3.API.Vector2
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.fixWindingOrder = function(faces, orientationEdge) {
|
GameLib.D3.fixWindingOrder = function(faces, orientationEdge) {
|
||||||
|
@ -444,7 +444,7 @@ GameLib.D3.fixWindingOrder = function(faces, orientationEdge) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a neighbouring triangle on a specific edge - preserving the edge orientation
|
* Returns a neighbouring triangle on a specific edge - preserving the edge orientation
|
||||||
* @param edge GameLib.D3.Vector2
|
* @param edge GameLib.D3.API.Vector2
|
||||||
* @param faces GameLib.D3.TriangleFace[]
|
* @param faces GameLib.D3.TriangleFace[]
|
||||||
* @param currentTriangle
|
* @param currentTriangle
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
|
@ -530,15 +530,15 @@ GameLib.D3.fixWindingOrder = function(faces, orientationEdge) {
|
||||||
processed.push(triangleEdge);
|
processed.push(triangleEdge);
|
||||||
|
|
||||||
var edges = [
|
var edges = [
|
||||||
new GameLib.D3.Vector2(
|
new GameLib.D3.API.Vector2(
|
||||||
triangleEdge.triangle.v0,
|
triangleEdge.triangle.v0,
|
||||||
triangleEdge.triangle.v1
|
triangleEdge.triangle.v1
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector2(
|
new GameLib.D3.API.Vector2(
|
||||||
triangleEdge.triangle.v1,
|
triangleEdge.triangle.v1,
|
||||||
triangleEdge.triangle.v2
|
triangleEdge.triangle.v2
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector2(
|
new GameLib.D3.API.Vector2(
|
||||||
triangleEdge.triangle.v2,
|
triangleEdge.triangle.v2,
|
||||||
triangleEdge.triangle.v0
|
triangleEdge.triangle.v0
|
||||||
)
|
)
|
||||||
|
@ -589,10 +589,10 @@ GameLib.D3.fixPolyZPlane = function(verticesFlat, grain) {
|
||||||
|
|
||||||
var vertices = [];
|
var vertices = [];
|
||||||
|
|
||||||
var points = new GameLib.D3.Vector4.Points();
|
var points = new GameLib.D3.API.Vector4.Points();
|
||||||
|
|
||||||
for (var i = 0; i < verticesFlat.length; i += 3) {
|
for (var i = 0; i < verticesFlat.length; i += 3) {
|
||||||
points.add(new GameLib.D3.Vector3(
|
points.add(new GameLib.D3.API.Vector3(
|
||||||
verticesFlat[i],
|
verticesFlat[i],
|
||||||
verticesFlat[i + 1],
|
verticesFlat[i + 1],
|
||||||
verticesFlat[i + 2]
|
verticesFlat[i + 2]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Contains a Poly vertex data structure
|
* Contains a Poly vertex data structure
|
||||||
* @param localIndex
|
* @param localIndex
|
||||||
* @param mvertIndex
|
* @param mvertIndex
|
||||||
* @param uv GameLib.D3.Vector2
|
* @param uv GameLib.D3.API.Vector2
|
||||||
* @param materialIndex
|
* @param materialIndex
|
||||||
* @param edgeIndex
|
* @param edgeIndex
|
||||||
* @constructor
|
* @constructor
|
||||||
|
|
|
@ -38,10 +38,10 @@ GameLib.D3.RigidBody = function(
|
||||||
shape
|
shape
|
||||||
) {
|
) {
|
||||||
this.id = GameLib.D3.Tools.RandomId();
|
this.id = GameLib.D3.Tools.RandomId();
|
||||||
this.position = position || new GameLib.D3.Vector3();
|
this.position = position || new GameLib.D3.API.Vector3();
|
||||||
this.velocity = velocity || new GameLib.D3.Vector3();
|
this.velocity = velocity || new GameLib.D3.API.Vector3();
|
||||||
this.angularVelocity = angularVelocity || new GameLib.D3.Vector3();
|
this.angularVelocity = angularVelocity || new GameLib.D3.API.Vector3();
|
||||||
this.quaternion = quaternion || new GameLib.D3.Vector4(0, 0, 0, 1);
|
this.quaternion = quaternion || new GameLib.D3.API.Vector4(0, 0, 0, 1);
|
||||||
this.mass = typeof mass == "undefined" ? 0 : mass;
|
this.mass = typeof mass == "undefined" ? 0 : mass;
|
||||||
this.friction = typeof friction == "undefined" ? 5 : friction;
|
this.friction = typeof friction == "undefined" ? 5 : friction;
|
||||||
this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping;
|
this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping;
|
||||||
|
@ -111,8 +111,8 @@ GameLib.D3.RigidBody.prototype.createInstance = function() {
|
||||||
/**
|
/**
|
||||||
* Adds a shape to this rigid body
|
* Adds a shape to this rigid body
|
||||||
* @param shape GameLib.D3.Shape
|
* @param shape GameLib.D3.Shape
|
||||||
* @param offset GameLib.D3.Vector3
|
* @param offset GameLib.D3.API.Vector3
|
||||||
* @param orientation GameLib.D3.Vector4
|
* @param orientation GameLib.D3.API.Vector4
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.RigidBody.prototype.addShape = function(
|
GameLib.D3.RigidBody.prototype.addShape = function(
|
||||||
|
@ -121,11 +121,11 @@ GameLib.D3.RigidBody.prototype.addShape = function(
|
||||||
orientation
|
orientation
|
||||||
) {
|
) {
|
||||||
if (!offset || typeof offset == 'undefined') {
|
if (!offset || typeof offset == 'undefined') {
|
||||||
offset = new GameLib.D3.Vector3(0,0,0);
|
offset = new GameLib.D3.API.Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!orientation || typeof orientation == 'undefined') {
|
if (!orientation || typeof orientation == 'undefined') {
|
||||||
orientation = new GameLib.D3.Vector4(0,0,0,1);
|
orientation = new GameLib.D3.API.Vector4(0,0,0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance.addShape(
|
this.instance.addShape(
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* Rigid Wheel superset
|
* Rigid Wheel superset
|
||||||
* @param body GameLib.D3.RigidBody
|
* @param body GameLib.D3.RigidBody
|
||||||
* @param position GameLib.D3.Vector3
|
* @param position GameLib.D3.API.Vector3
|
||||||
* @param axis GameLib.D3.Vector3
|
* @param axis GameLib.D3.API.Vector3
|
||||||
* @param direction GameLib.D3.Vector3
|
* @param direction GameLib.D3.API.Vector3
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.RigidWheel = function(
|
GameLib.D3.RigidWheel = function(
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Runtime color for updating instance objects
|
* Runtime color for updating instance objects
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentObject GameLib.D3.*
|
* @param parentObject GameLib.D3.*
|
||||||
* @param color GameLib.D3.Color
|
* @param color GameLib.D3.API.Color
|
||||||
* @param grain Number
|
* @param grain Number
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,7 @@ GameLib.D3.Runtime.Color = function RuntimeColor(graphics, parentObject, color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Color, GameLib.D3.Color);
|
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Color, GameLib.D3.API.Color);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
@ -44,9 +44,8 @@ GameLib.D3.Runtime.Color.prototype.createInstance = function(update) {
|
||||||
instance.r = this.r;
|
instance.r = this.r;
|
||||||
instance.g = this.g;
|
instance.g = this.g;
|
||||||
instance.b = this.b;
|
instance.b = this.b;
|
||||||
instance.a = this.a;
|
|
||||||
} else {
|
} else {
|
||||||
instance = new this.graphics.instance.Color(this.r, this.g, this.b, this.a);
|
instance = new this.graphics.instance.Color(this.r, this.g, this.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -75,4 +74,53 @@ GameLib.D3.Runtime.Color.prototype.toApiColor = function() {
|
||||||
this.b,
|
this.b,
|
||||||
this.a
|
this.a
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the current color to HTML hex format (ex. #ffffff)
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Runtime.Color.prototype.toHex = function() {
|
||||||
|
|
||||||
|
if (this.r < 0) {
|
||||||
|
this.r = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.g < 0) {
|
||||||
|
this.g = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.b < 0) {
|
||||||
|
this.b = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.r > 1) {
|
||||||
|
this.r = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.g > 1) {
|
||||||
|
this.g = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.b > 1) {
|
||||||
|
this.b = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rf = Math.floor(this.r >= 1? 255 : this.r * 256.0).toString(16);
|
||||||
|
var gf = Math.floor(this.g >= 1? 255 : this.g * 256.0).toString(16);
|
||||||
|
var bf = Math.floor(this.b >= 1? 255 : this.b * 256.0).toString(16);
|
||||||
|
|
||||||
|
if (rf.length < 2) {
|
||||||
|
rf = '0' + rf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gf.length < 2) {
|
||||||
|
gf = '0' + gf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bf.length < 2) {
|
||||||
|
bf = '0' + bf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '#' + rf + gf + bf;
|
||||||
};
|
};
|
|
@ -2,7 +2,7 @@
|
||||||
* Runtime vector2 for updating instance objects
|
* Runtime vector2 for updating instance objects
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentObject GameLib.D3.*
|
* @param parentObject GameLib.D3.*
|
||||||
* @param vector2 GameLib.D3.Vector2
|
* @param vector2 GameLib.D3.API.Vector2
|
||||||
* @param grain Number
|
* @param grain Number
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,7 @@ GameLib.D3.Runtime.Vector2 = function RuntimeVector2(graphics, parentObject, vec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector2, GameLib.D3.Vector2);
|
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector2, GameLib.D3.API.Vector2);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
@ -71,4 +71,109 @@ GameLib.D3.Runtime.Vector2.prototype.toApiVector = function() {
|
||||||
this.x,
|
this.x,
|
||||||
this.y
|
this.y
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2 = function Vector2(x, y) {
|
||||||
|
this.x = x || 0;
|
||||||
|
this.y = y || 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.copy = function (v) {
|
||||||
|
if (!GameLib.D3.Utils.UndefinedOrNull(v)) {
|
||||||
|
this.x = v.x;
|
||||||
|
this.y = v.y;
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x,
|
||||||
|
this.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.equals = function(v) {
|
||||||
|
return (((this.x == v.x) &&
|
||||||
|
(this.y == v.y)) ||
|
||||||
|
((this.y == v.x) &&
|
||||||
|
(this.x == v.y)));
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.add = function(v) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x + v.x,
|
||||||
|
this.y + v.y
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.subtract = function(v) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x - v.x,
|
||||||
|
this.y - v.y
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.multiply = function(v) {
|
||||||
|
if (v instanceof GameLib.D3.Runtime.Vector2) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x * v.x,
|
||||||
|
this.y * v.y
|
||||||
|
);
|
||||||
|
} else if (isNumber(v)) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x * v,
|
||||||
|
this.y * v
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.divide = function(v) {
|
||||||
|
if (v instanceof GameLib.D3.Runtime.Vector2) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x * (1.0 / v.x),
|
||||||
|
this.y * (1.0 / v.y)
|
||||||
|
);
|
||||||
|
} else if (isNumber(v)) {
|
||||||
|
var invS = 1.0 / v;
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x * invS,
|
||||||
|
this.y * invS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.set = function(x, y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.clamp = function(min, max) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
Math.max(min.x, Math.min(max.x, this.x)),
|
||||||
|
Math.max(min.y, Math.min(max.y, this.y))
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.length = function() {
|
||||||
|
return Math.sqrt(this.x * this.x + this.y * this.y);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.dot = function(v) {
|
||||||
|
return this.x * v.x + this.y * v.y;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.normalize = function() {
|
||||||
|
return this.multiply(1.0 / this.length());
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.angle = function() {
|
||||||
|
var angle = Math.atan2(this.y, this.x);
|
||||||
|
if ( angle < 0 ) angle += 2 * Math.PI;
|
||||||
|
return angle;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector2.prototype.lerp = function ( v, alpha ) {
|
||||||
|
return new GameLib.D3.Runtime.Vector2(
|
||||||
|
this.x + ( v.x - this.x ) * alpha,
|
||||||
|
this.y + ( v.y - this.y ) * alpha
|
||||||
|
);
|
||||||
};
|
};
|
|
@ -2,7 +2,7 @@
|
||||||
* Runtime vector3 for updating instance objects
|
* Runtime vector3 for updating instance objects
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentObject GameLib.D3.*
|
* @param parentObject GameLib.D3.*
|
||||||
* @param vector3 GameLib.D3.Vector3
|
* @param vector3 GameLib.D3.API.Vector3
|
||||||
* @param grain Number
|
* @param grain Number
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,7 @@ GameLib.D3.Runtime.Vector3 = function RuntimeVector3(graphics, parentObject, vec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector3, GameLib.D3.Vector3);
|
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector3, GameLib.D3.API.Vector3);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
@ -73,4 +73,238 @@ GameLib.D3.Runtime.Vector3.prototype.toApiVector = function() {
|
||||||
this.y,
|
this.y,
|
||||||
this.z
|
this.z
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.subtract = function (v) {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x - v.x,
|
||||||
|
this.y - v.y,
|
||||||
|
this.z - v.z
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.sub = function (v) {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x - v.x,
|
||||||
|
this.y - v.y,
|
||||||
|
this.z - v.z
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.cross = function (v) {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.y * v.z - this.z * v.y,
|
||||||
|
this.z * v.x - this.x * v.z,
|
||||||
|
this.x * v.y - this.y * v.x
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.clockwise = function (u, v, w, viewPoint) {
|
||||||
|
var normal = GameLib.D3.Runtime.Vector3.normal(u, v, w);
|
||||||
|
var uv = u.copy();
|
||||||
|
var winding = normal.dot(uv.subtract(viewPoint));
|
||||||
|
return (winding > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.normal = function (u, v, w) {
|
||||||
|
var vv = v.copy();
|
||||||
|
var wv = w.copy();
|
||||||
|
return vv.subtract(u).cross(wv.subtract(u));
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.lookAt = function (at, up) {
|
||||||
|
var lookAtMatrix = GameLib.D3.Matrix4.lookAt(this, at, up);
|
||||||
|
return this.multiply(lookAtMatrix);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.translate = function (v) {
|
||||||
|
this.x += v.x;
|
||||||
|
this.y += v.y;
|
||||||
|
this.z += v.z;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.add = function (v) {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x + v.x,
|
||||||
|
this.y + v.y,
|
||||||
|
this.z + v.z
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.squared = function () {
|
||||||
|
return this.x * this.x + this.y * this.y + this.z * this.z;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.copy = function () {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
this.z
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.set = function (x, y, z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.lerp = function ( v, alpha ) {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x + ( v.x - this.x ) * alpha,
|
||||||
|
this.y + ( v.y - this.y ) * alpha,
|
||||||
|
this.z + ( v.z - this.z ) * alpha
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.distanceTo = function(v) {
|
||||||
|
var dx = this.x - v.x,
|
||||||
|
dy = this.y - v.y,
|
||||||
|
dz = this.z - v.z;
|
||||||
|
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Runtime.Vector3.AngleDirection = function(forward, directionToCheck, up) {
|
||||||
|
var perp = forward.cross(directionToCheck);
|
||||||
|
var dir = perp.dot(up);
|
||||||
|
|
||||||
|
if (dir > 0.0) {
|
||||||
|
return 1.0;
|
||||||
|
} else if (dir < 0.0) {
|
||||||
|
return -1.0;
|
||||||
|
} else {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.multiply = function (s) {
|
||||||
|
if (s instanceof GameLib.D3.Runtime.Vector3) {
|
||||||
|
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x * s.x,
|
||||||
|
this.y * s.y,
|
||||||
|
this.z * s.z
|
||||||
|
)
|
||||||
|
|
||||||
|
} else if (s instanceof GameLib.D3.Matrix4) {
|
||||||
|
|
||||||
|
var x = s.rows[0].x * this.x + s.rows[0].y * this.y + s.rows[0].z * this.z + s.rows[0].w;
|
||||||
|
var y = s.rows[1].x * this.x + s.rows[1].y * this.y + s.rows[1].z * this.z + s.rows[1].w;
|
||||||
|
var z = s.rows[2].x * this.x + s.rows[2].y * this.y + s.rows[2].z * this.z + s.rows[2].w;
|
||||||
|
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z
|
||||||
|
);
|
||||||
|
|
||||||
|
} else if (s instanceof GameLib.D3.Matrix3) {
|
||||||
|
|
||||||
|
var x = s.rows[0].x * this.x + s.rows[0].y * this.y + s.rows[0].z * this.z;
|
||||||
|
var y = s.rows[1].x * this.x + s.rows[1].y * this.y + s.rows[1].z * this.z;
|
||||||
|
var z = s.rows[2].x * this.x + s.rows[2].y * this.y + s.rows[2].z * this.z;
|
||||||
|
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z
|
||||||
|
);
|
||||||
|
|
||||||
|
} else if(!isNaN(parseFloat(s)) && isFinite(s)) {
|
||||||
|
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x * s,
|
||||||
|
this.y * s,
|
||||||
|
this.z * s
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
console.log("functionality not implemented - please do this");
|
||||||
|
throw new Error("not implemented");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.dot = function (v) {
|
||||||
|
return (this.x * v.x) + (this.y * v.y) + (this.z * v.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.normalize = function () {
|
||||||
|
var EPSILON = 0.000001;
|
||||||
|
var v2 = this.squared();
|
||||||
|
|
||||||
|
if (v2 < EPSILON) {
|
||||||
|
return this; //do nothing for zero vector
|
||||||
|
}
|
||||||
|
|
||||||
|
var invLength = 1.0 / Math.sqrt(v2);
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x * invLength,
|
||||||
|
this.y * invLength,
|
||||||
|
this.z * invLength
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.clone = function () {
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
this.z
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.applyQuaternion = function(q) {
|
||||||
|
var x = this.x, y = this.y, z = this.z;
|
||||||
|
var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
|
||||||
|
|
||||||
|
// calculate quat * vector
|
||||||
|
|
||||||
|
var ix = qw * x + qy * z - qz * y;
|
||||||
|
var iy = qw * y + qz * x - qx * z;
|
||||||
|
var iz = qw * z + qx * y - qy * x;
|
||||||
|
var iw = - qx * x - qy * y - qz * z;
|
||||||
|
|
||||||
|
// calculate result * inverse quat
|
||||||
|
|
||||||
|
return new GameLib.D3.Runtime.Vector3(
|
||||||
|
ix * qw + iw * - qx + iy * - qz - iz * - qy,
|
||||||
|
iy * qw + iw * - qy + iz * - qx - ix * - qz,
|
||||||
|
iz * qw + iw * - qz + ix * - qy - iy * - qx
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.clamp = function(min, max) {
|
||||||
|
this.x = Math.max( min.x, Math.min( max.x, this.x ) );
|
||||||
|
this.y = Math.max( min.y, Math.min( max.y, this.y ) );
|
||||||
|
this.z = Math.max( min.z, Math.min( max.z, this.z ) );
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.negate = function() {
|
||||||
|
this.x = -this.x;
|
||||||
|
this.y = -this.y;
|
||||||
|
this.z = -this.z;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.length = function() {
|
||||||
|
return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.reflect = function(normal) {
|
||||||
|
return this.sub( v1.copy( normal ).multiply( 2 * this.dot( normal ) ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector3.prototype.angleTo = function (v) {
|
||||||
|
var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
|
||||||
|
return Math.acos( exports.Math.clamp( theta, - 1, 1 ) );
|
||||||
};
|
};
|
|
@ -2,7 +2,7 @@
|
||||||
* Runtime vector4 for updating instance objects
|
* Runtime vector4 for updating instance objects
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param parentObject GameLib.D3.*
|
* @param parentObject GameLib.D3.*
|
||||||
* @param vector4 GameLib.D3.Vector4
|
* @param vector4 GameLib.D3.API.Vector4
|
||||||
* @param grain Number
|
* @param grain Number
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,7 @@ GameLib.D3.Runtime.Vector4 = function RuntimeVector4(graphics, parentObject, vec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector4, GameLib.D3.Vector4);
|
GameLib.D3.Utils.Extend(GameLib.D3.Runtime.Vector4, GameLib.D3.API.Vector4);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
@ -75,4 +75,328 @@ GameLib.D3.Runtime.Vector4.prototype.toApiVector = function() {
|
||||||
this.z,
|
this.z,
|
||||||
this.w
|
this.w
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4 = function Vector4(x, y, z, w) {
|
||||||
|
|
||||||
|
this.x = 0;
|
||||||
|
this.y = 0;
|
||||||
|
this.z = 0;
|
||||||
|
this.w = 1;
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (z) {
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w) {
|
||||||
|
this.w = w;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.prototype.translate = function (v) {
|
||||||
|
this.x += v.x;
|
||||||
|
this.y += v.y;
|
||||||
|
this.z += v.z;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.prototype.copy = function () {
|
||||||
|
return new GameLib.D3.Runtime.Vector4(
|
||||||
|
this.x,
|
||||||
|
this.y,
|
||||||
|
this.z,
|
||||||
|
this.w
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.prototype.multiply = function (s) {
|
||||||
|
if (s instanceof GameLib.D3.API.Vector3) {
|
||||||
|
this.x *= s.x;
|
||||||
|
this.y *= s.y;
|
||||||
|
this.z *= s.z;
|
||||||
|
} else if (s instanceof GameLib.D3.Matrix4) {
|
||||||
|
var x = s.rows[0].x * this.x + s.rows[0].y * this.y + s.rows[0].z * this.z + s.rows[0].w * this.w;
|
||||||
|
var y = s.rows[1].x * this.x + s.rows[1].y * this.y + s.rows[1].z * this.z + s.rows[1].w * this.w;
|
||||||
|
var z = s.rows[2].x * this.x + s.rows[2].y * this.y + s.rows[2].z * this.z + s.rows[2].w * this.w;
|
||||||
|
var w = s.rows[3].x * this.x + s.rows[3].y * this.y + s.rows[3].z * this.z + s.rows[3].w * this.w;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.w = w;
|
||||||
|
} else {
|
||||||
|
console.log("functionality not implemented - please do this");
|
||||||
|
throw new Error("not implemented");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.prototype.normalize = function () {
|
||||||
|
|
||||||
|
// note - leave w untouched
|
||||||
|
var EPSILON = 0.000001;
|
||||||
|
|
||||||
|
var v2 = this.x * this.x + this.y * this.y + this.z * this.z;
|
||||||
|
|
||||||
|
if (v2 < EPSILON) {
|
||||||
|
return this; //do nothing for zero vector
|
||||||
|
}
|
||||||
|
|
||||||
|
var invLength = 1 / Math.sqrt(v2);
|
||||||
|
|
||||||
|
this.x *= invLength;
|
||||||
|
this.y *= invLength;
|
||||||
|
this.z *= invLength;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.prototype.subtract = function (v) {
|
||||||
|
|
||||||
|
if (v instanceof GameLib.D3.API.Vector3) {
|
||||||
|
this.x -= v.x;
|
||||||
|
this.y -= v.y;
|
||||||
|
this.z -= v.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v instanceof GameLib.D3.Runtime.Vector4) {
|
||||||
|
this.x -= v.x;
|
||||||
|
this.y -= v.y;
|
||||||
|
this.z -= v.z;
|
||||||
|
this.w -= v.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points = function () {
|
||||||
|
this.vectors = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.add = function (vector) {
|
||||||
|
|
||||||
|
if (vector instanceof GameLib.D3.API.Vector3) {
|
||||||
|
vector = new GameLib.D3.Runtime.Vector4(
|
||||||
|
vector.x,
|
||||||
|
vector.y,
|
||||||
|
vector.z,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vector instanceof GameLib.D3.Runtime.Vector4) {
|
||||||
|
console.warn("Vector needs to be of type Vector4");
|
||||||
|
throw new Error("Vector needs to be of type Vector4");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.vectors.push(vector);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.copy = function () {
|
||||||
|
|
||||||
|
var vectors = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
|
vectors.push(this.vectors[i].copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
return vectors;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.maximizeXDistance = function (grain) {
|
||||||
|
|
||||||
|
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
||||||
|
|
||||||
|
var multiplier = 0;
|
||||||
|
|
||||||
|
var rotationMatrixY = new GameLib.D3.Matrix4().rotationMatrixY(grain);
|
||||||
|
|
||||||
|
var totalRadians = 0;
|
||||||
|
|
||||||
|
var backupVectors = this.copy();
|
||||||
|
|
||||||
|
var maxXDistance = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < Math.PI * 2; i += grain) {
|
||||||
|
|
||||||
|
multiplier++;
|
||||||
|
|
||||||
|
for (var j = 0; j < this.vectors.length; j++) {
|
||||||
|
this.vectors[j] = rotationMatrixY.multiply(this.vectors[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var distances = this.distances();
|
||||||
|
|
||||||
|
if (distances.x > maxXDistance) {
|
||||||
|
|
||||||
|
maxXDistance = distances.x;
|
||||||
|
totalRadians = multiplier * grain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.vectors = backupVectors;
|
||||||
|
|
||||||
|
// console.log("distance: " + maxXDistance + " radians : " + totalRadians);
|
||||||
|
|
||||||
|
var maxRotationMatrix = new GameLib.D3.Matrix4().rotationMatrixY(totalRadians);
|
||||||
|
|
||||||
|
for (var k = 0; k < this.vectors.length; k++) {
|
||||||
|
this.vectors[k] = maxRotationMatrix.multiply(this.vectors[k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log("vectors (after): " + JSON.stringify(this.vectors, null, 2));
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.maximizeYDistance = function (grain) {
|
||||||
|
|
||||||
|
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
||||||
|
|
||||||
|
var multiplier = 0;
|
||||||
|
|
||||||
|
var rotationMatrixX = new GameLib.D3.Matrix4().rotationMatrixX(grain);
|
||||||
|
|
||||||
|
var totalRadians = 0;
|
||||||
|
|
||||||
|
var backupVectors = this.copy();
|
||||||
|
|
||||||
|
var maxYDistance = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < Math.PI * 2; i += grain) {
|
||||||
|
|
||||||
|
multiplier++;
|
||||||
|
|
||||||
|
for (var j = 0; j < this.vectors.length; j++) {
|
||||||
|
this.vectors[j] = rotationMatrixX.multiply(this.vectors[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var distances = this.distances();
|
||||||
|
|
||||||
|
if (distances.y > maxYDistance) {
|
||||||
|
maxYDistance = distances.y;
|
||||||
|
totalRadians = multiplier * grain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.vectors = backupVectors;
|
||||||
|
|
||||||
|
// console.log("distance: " + maxYDistance + " radians : " + totalRadians);
|
||||||
|
|
||||||
|
var maxRotationMatrix = new GameLib.D3.Matrix4().rotationMatrixX(totalRadians);
|
||||||
|
|
||||||
|
for (var k = 0; k < this.vectors.length; k++) {
|
||||||
|
this.vectors[k] = maxRotationMatrix.multiply(this.vectors[k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log("vectors (after): " + JSON.stringify(this.vectors, null, 2));
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.lookAt = function (at, up) {
|
||||||
|
|
||||||
|
var polyCenter = this.average();
|
||||||
|
|
||||||
|
console.log("poly center : " + JSON.stringify(polyCenter));
|
||||||
|
|
||||||
|
var lookAtMatrix = new GameLib.D3.Matrix4().lookAt(polyCenter, at, up);
|
||||||
|
|
||||||
|
lookAtMatrix.rows[0] = new GameLib.D3.Runtime.Vector4(1, 0, 0, 0);
|
||||||
|
lookAtMatrix.rows[1] = new GameLib.D3.Runtime.Vector4(0, 0, 1, 0);
|
||||||
|
lookAtMatrix.rows[2] = new GameLib.D3.Runtime.Vector4(0, 1, 0, 0);
|
||||||
|
|
||||||
|
console.log("look at matrix : " + JSON.stringify(lookAtMatrix, null, 2));
|
||||||
|
|
||||||
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
|
console.log("vector " + i + " (before): " + JSON.stringify(this.vectors[i]));
|
||||||
|
this.vectors[i] = lookAtMatrix.multiply(this.vectors[i]);
|
||||||
|
console.log("vector " + i + " (after) : " + JSON.stringify(this.vectors[i]));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.distances = function () {
|
||||||
|
|
||||||
|
var minX = this.vectors[0].x;
|
||||||
|
var minY = this.vectors[0].y;
|
||||||
|
var minZ = this.vectors[0].z;
|
||||||
|
|
||||||
|
var maxX = this.vectors[0].x;
|
||||||
|
var maxY = this.vectors[0].y;
|
||||||
|
var maxZ = this.vectors[0].z;
|
||||||
|
|
||||||
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
|
if (this.vectors[i].x < minX) {
|
||||||
|
minX = this.vectors[i].x;
|
||||||
|
}
|
||||||
|
if (this.vectors[i].y < minY) {
|
||||||
|
minY = this.vectors[i].y;
|
||||||
|
}
|
||||||
|
if (this.vectors[i].z < minZ) {
|
||||||
|
minZ = this.vectors[i].z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.vectors[i].x > maxX) {
|
||||||
|
maxX = this.vectors[i].x;
|
||||||
|
}
|
||||||
|
if (this.vectors[i].y > maxY) {
|
||||||
|
maxY = this.vectors[i].y;
|
||||||
|
}
|
||||||
|
if (this.vectors[i].z > maxZ) {
|
||||||
|
maxZ = this.vectors[i].z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Vector3(
|
||||||
|
Math.abs(maxX - minX),
|
||||||
|
Math.abs(maxY - minY),
|
||||||
|
Math.abs(maxY - minZ)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.average = function () {
|
||||||
|
var averageX = 0;
|
||||||
|
var averageY = 0;
|
||||||
|
var averageZ = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
|
averageX += this.vectors[i].x;
|
||||||
|
averageY += this.vectors[i].y;
|
||||||
|
averageZ += this.vectors[i].z;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GameLib.D3.API.Vector3(
|
||||||
|
averageX / this.vectors.length,
|
||||||
|
averageY / this.vectors.length,
|
||||||
|
averageZ / this.vectors.length
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.negate = function () {
|
||||||
|
|
||||||
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
|
this.vectors[i].x *= -1;
|
||||||
|
this.vectors[i].y *= -1;
|
||||||
|
this.vectors[i].z *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Runtime.Vector4.Points.prototype.toOrigin = function () {
|
||||||
|
|
||||||
|
var distanceFromOrigin = this.average().negate();
|
||||||
|
|
||||||
|
for (var i = 0; i < this.vectors.length; i++) {
|
||||||
|
this.vectors[i].translate(distanceFromOrigin);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -131,35 +131,35 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
apiLight.id,
|
apiLight.id,
|
||||||
apiLight.lightType,
|
apiLight.lightType,
|
||||||
apiLight.name,
|
apiLight.name,
|
||||||
new GameLib.D3.Color(
|
new GameLib.D3.API.Color(
|
||||||
apiLight.color.r,
|
apiLight.color.r,
|
||||||
apiLight.color.g,
|
apiLight.color.g,
|
||||||
apiLight.color.b,
|
apiLight.color.b,
|
||||||
apiLight.color.a
|
apiLight.color.a
|
||||||
),
|
),
|
||||||
apiLight.intensity,
|
apiLight.intensity,
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiLight.position.x,
|
apiLight.position.x,
|
||||||
apiLight.position.y,
|
apiLight.position.y,
|
||||||
apiLight.position.z
|
apiLight.position.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiLight.targetPosition.x,
|
apiLight.targetPosition.x,
|
||||||
apiLight.targetPosition.y,
|
apiLight.targetPosition.y,
|
||||||
apiLight.targetPosition.z
|
apiLight.targetPosition.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector4(
|
new GameLib.D3.API.Vector4(
|
||||||
apiLight.quaternion.x,
|
apiLight.quaternion.x,
|
||||||
apiLight.quaternion.y,
|
apiLight.quaternion.y,
|
||||||
apiLight.quaternion.z,
|
apiLight.quaternion.z,
|
||||||
apiLight.quaternion.w
|
apiLight.quaternion.w
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiLight.rotation.x,
|
apiLight.rotation.x,
|
||||||
apiLight.rotation.y,
|
apiLight.rotation.y,
|
||||||
apiLight.rotation.z
|
apiLight.rotation.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiLight.scale.x,
|
apiLight.scale.x,
|
||||||
apiLight.scale.y,
|
apiLight.scale.y,
|
||||||
apiLight.scale.z
|
apiLight.scale.z
|
||||||
|
@ -200,7 +200,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
apiMaterial.side,
|
apiMaterial.side,
|
||||||
apiMaterial.transparent,
|
apiMaterial.transparent,
|
||||||
GameLib.D3.API.TextureMapTemplate(),
|
GameLib.D3.API.TextureMapTemplate(),
|
||||||
new GameLib.D3.Color(
|
new GameLib.D3.API.Color(
|
||||||
apiMaterial.specular.r,
|
apiMaterial.specular.r,
|
||||||
apiMaterial.specular.g,
|
apiMaterial.specular.g,
|
||||||
apiMaterial.specular.b,
|
apiMaterial.specular.b,
|
||||||
|
@ -208,13 +208,13 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
),
|
),
|
||||||
apiMaterial.lightMapIntensity,
|
apiMaterial.lightMapIntensity,
|
||||||
apiMaterial.aoMapIntensity,
|
apiMaterial.aoMapIntensity,
|
||||||
new GameLib.D3.Color(
|
new GameLib.D3.API.Color(
|
||||||
apiMaterial.color.r,
|
apiMaterial.color.r,
|
||||||
apiMaterial.color.g,
|
apiMaterial.color.g,
|
||||||
apiMaterial.color.b,
|
apiMaterial.color.b,
|
||||||
apiMaterial.color.a
|
apiMaterial.color.a
|
||||||
),
|
),
|
||||||
new GameLib.D3.Color(
|
new GameLib.D3.API.Color(
|
||||||
apiMaterial.emissive.r,
|
apiMaterial.emissive.r,
|
||||||
apiMaterial.emissive.g,
|
apiMaterial.emissive.g,
|
||||||
apiMaterial.emissive.b,
|
apiMaterial.emissive.b,
|
||||||
|
@ -286,7 +286,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
apiTexture.imagePath,
|
apiTexture.imagePath,
|
||||||
apiTexture.wrapS,
|
apiTexture.wrapS,
|
||||||
apiTexture.wrapT,
|
apiTexture.wrapT,
|
||||||
new GameLib.D3.Vector2(
|
new GameLib.D3.API.Vector2(
|
||||||
apiTexture.repeat.x,
|
apiTexture.repeat.x,
|
||||||
apiTexture.repeat.y
|
apiTexture.repeat.y
|
||||||
),
|
),
|
||||||
|
@ -297,7 +297,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
apiTexture.minFilter,
|
apiTexture.minFilter,
|
||||||
apiTexture.textureType,
|
apiTexture.textureType,
|
||||||
apiTexture.anisotropy,
|
apiTexture.anisotropy,
|
||||||
new GameLib.D3.Vector2(
|
new GameLib.D3.API.Vector2(
|
||||||
apiTexture.offset.x,
|
apiTexture.offset.x,
|
||||||
apiTexture.offset.y
|
apiTexture.offset.y
|
||||||
),
|
),
|
||||||
|
@ -314,17 +314,6 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
imageFactory
|
imageFactory
|
||||||
);
|
);
|
||||||
|
|
||||||
texture.offset = new GameLib.D3.Runtime.Vector2(
|
|
||||||
graphics,
|
|
||||||
texture,
|
|
||||||
texture.offset
|
|
||||||
);
|
|
||||||
|
|
||||||
texture.repeat = new GameLib.D3.Runtime.Vector2(
|
|
||||||
graphics,
|
|
||||||
texture,
|
|
||||||
texture.repeat
|
|
||||||
);
|
|
||||||
|
|
||||||
gameLibTextureMap[map].texture = texture;
|
gameLibTextureMap[map].texture = texture;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +332,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
|
|
||||||
for (var bw = 0; bw < apiMesh.vertices[v].boneWeights.length; bw++) {
|
for (var bw = 0; bw < apiMesh.vertices[v].boneWeights.length; bw++) {
|
||||||
boneWeights.push(
|
boneWeights.push(
|
||||||
new GameLib.D3.BoneWeight(
|
new GameLib.D3.API.BoneWeight(
|
||||||
apiMesh.vertices[v].boneWeights[bw].boneIndex,
|
apiMesh.vertices[v].boneWeights[bw].boneIndex,
|
||||||
apiMesh.vertices[v].boneWeights[bw].weight
|
apiMesh.vertices[v].boneWeights[bw].weight
|
||||||
)
|
)
|
||||||
|
@ -352,7 +341,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
|
|
||||||
gameLibVertices.push(
|
gameLibVertices.push(
|
||||||
new GameLib.D3.Vertex(
|
new GameLib.D3.Vertex(
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiMesh.vertices[v].position.x,
|
apiMesh.vertices[v].position.x,
|
||||||
apiMesh.vertices[v].position.y,
|
apiMesh.vertices[v].position.y,
|
||||||
apiMesh.vertices[v].position.z
|
apiMesh.vertices[v].position.z
|
||||||
|
@ -378,28 +367,28 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
apiMesh.skeleton,
|
apiMesh.skeleton,
|
||||||
apiMesh.skinIndices,
|
apiMesh.skinIndices,
|
||||||
apiMesh.skinWeights,
|
apiMesh.skinWeights,
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiMesh.position.x,
|
apiMesh.position.x,
|
||||||
apiMesh.position.y,
|
apiMesh.position.y,
|
||||||
apiMesh.position.z
|
apiMesh.position.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector4(
|
new GameLib.D3.API.Vector4(
|
||||||
apiMesh.quaternion.x,
|
apiMesh.quaternion.x,
|
||||||
apiMesh.quaternion.y,
|
apiMesh.quaternion.y,
|
||||||
apiMesh.quaternion.z,
|
apiMesh.quaternion.z,
|
||||||
apiMesh.quaternion.w
|
apiMesh.quaternion.w
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiMesh.rotation.x,
|
apiMesh.rotation.x,
|
||||||
apiMesh.rotation.y,
|
apiMesh.rotation.y,
|
||||||
apiMesh.rotation.z
|
apiMesh.rotation.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiMesh.scale.x,
|
apiMesh.scale.x,
|
||||||
apiMesh.scale.y,
|
apiMesh.scale.y,
|
||||||
apiMesh.scale.z
|
apiMesh.scale.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
apiMesh.up.x,
|
apiMesh.up.x,
|
||||||
apiMesh.up.y,
|
apiMesh.up.y,
|
||||||
apiMesh.up.z
|
apiMesh.up.z
|
||||||
|
@ -501,23 +490,23 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
scene.path,
|
scene.path,
|
||||||
scene.name,
|
scene.name,
|
||||||
gameLibMeshes,
|
gameLibMeshes,
|
||||||
new GameLib.D3.Vector4(
|
new GameLib.D3.API.Vector4(
|
||||||
scene.quaternion.x,
|
scene.quaternion.x,
|
||||||
scene.quaternion.y,
|
scene.quaternion.y,
|
||||||
scene.quaternion.z,
|
scene.quaternion.z,
|
||||||
scene.quaternion.w
|
scene.quaternion.w
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
scene.position.x,
|
scene.position.x,
|
||||||
scene.position.y,
|
scene.position.y,
|
||||||
scene.position.z
|
scene.position.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
scene.rotation.x,
|
scene.rotation.x,
|
||||||
scene.rotation.y,
|
scene.rotation.y,
|
||||||
scene.rotation.z
|
scene.rotation.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.API.Vector3(
|
||||||
scene.scale.x,
|
scene.scale.x,
|
||||||
scene.scale.y,
|
scene.scale.y,
|
||||||
scene.scale.z
|
scene.scale.z
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
* Physics Shape Superset
|
* Physics Shape Superset
|
||||||
* @param engine GameLib.D3.Engine
|
* @param engine GameLib.D3.Engine
|
||||||
* @param shapeType
|
* @param shapeType
|
||||||
* @param scale GameLib.D3.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param vertices Number[]
|
* @param vertices Number[]
|
||||||
* @param indices Number[]
|
* @param indices Number[]
|
||||||
* @param radius Number
|
* @param radius Number
|
||||||
* @param halfExtensions GameLib.D3.Vector3
|
* @param halfExtensions GameLib.D3.API.Vector3
|
||||||
* @param radiusTop Number
|
* @param radiusTop Number
|
||||||
* @param radiusBottom Number
|
* @param radiusBottom Number
|
||||||
* @param height Number
|
* @param height Number
|
||||||
|
@ -37,7 +37,7 @@ GameLib.D3.Shape = function(
|
||||||
this.shapeType = shapeType;
|
this.shapeType = shapeType;
|
||||||
|
|
||||||
if (typeof scale == 'undefined') {
|
if (typeof scale == 'undefined') {
|
||||||
scale = new GameLib.D3.Vector3(1, 1, 1)
|
scale = new GameLib.D3.API.Vector3(1, 1, 1)
|
||||||
}
|
}
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ GameLib.D3.Shape = function(
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
|
|
||||||
if (typeof halfExtensions == 'undefined') {
|
if (typeof halfExtensions == 'undefined') {
|
||||||
halfExtensions = new GameLib.D3.Vector3(1,1,1);
|
halfExtensions = new GameLib.D3.API.Vector3(1,1,1);
|
||||||
}
|
}
|
||||||
this.halfExtensions = halfExtensions;
|
this.halfExtensions = halfExtensions;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Skeleton Superset
|
* Skeleton Superset
|
||||||
* @param id
|
* @param id
|
||||||
* @param bones GameLib.D3.Bone
|
* @param bones GameLib.D3.API.Bone
|
||||||
* @param boneInverses
|
* @param boneInverses
|
||||||
* @param useVertexTexture
|
* @param useVertexTexture
|
||||||
* @param boneTextureWidth
|
* @param boneTextureWidth
|
||||||
|
|
|
@ -21,6 +21,18 @@ GameLib.D3.Texture = function Texture(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.offset = new GameLib.D3.Runtime.Vector2(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.offset
|
||||||
|
);
|
||||||
|
|
||||||
|
this.repeat = new GameLib.D3.Runtime.Vector2(
|
||||||
|
graphics,
|
||||||
|
this,
|
||||||
|
this.repeat
|
||||||
|
);
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
|
|
@ -34,30 +34,30 @@ GameLib.D3.TriangleFace = function TriangleFace(
|
||||||
this.v1uv = v1uv;
|
this.v1uv = v1uv;
|
||||||
this.v2uv = v2uv;
|
this.v2uv = v2uv;
|
||||||
if (!color) {
|
if (!color) {
|
||||||
color = new GameLib.D3.Color(0xff, 0xff, 0xff, 0xff);
|
color = new GameLib.D3.API.Color(0xff, 0xff, 0xff, 0xff);
|
||||||
}
|
}
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
if (!vertexColors) {
|
if (!vertexColors) {
|
||||||
vertexColors = [
|
vertexColors = [
|
||||||
new GameLib.D3.Color(0xff, 0xff, 0xff, 0xff),
|
new GameLib.D3.API.Color(0xff, 0xff, 0xff, 0xff),
|
||||||
new GameLib.D3.Color(0xff, 0xff, 0xff, 0xff),
|
new GameLib.D3.API.Color(0xff, 0xff, 0xff, 0xff),
|
||||||
new GameLib.D3.Color(0xff, 0xff, 0xff, 0xff)
|
new GameLib.D3.API.Color(0xff, 0xff, 0xff, 0xff)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
this.vertexColors = vertexColors;
|
this.vertexColors = vertexColors;
|
||||||
|
|
||||||
if (!vertexNormals) {
|
if (!vertexNormals) {
|
||||||
vertexNormals = [
|
vertexNormals = [
|
||||||
new GameLib.D3.Vector3(),
|
new GameLib.D3.API.Vector3(),
|
||||||
new GameLib.D3.Vector3(),
|
new GameLib.D3.API.Vector3(),
|
||||||
new GameLib.D3.Vector3()
|
new GameLib.D3.API.Vector3()
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
this.vertexNormals = vertexNormals;
|
this.vertexNormals = vertexNormals;
|
||||||
|
|
||||||
if (!normal) {
|
if (!normal) {
|
||||||
normal = new GameLib.D3.Vector3(0);
|
normal = new GameLib.D3.API.Vector3(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.normal = normal;
|
this.normal = normal;
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
GameLib.D3.Vector2 = function Vector2(x, y) {
|
|
||||||
this.x = x || 0;
|
|
||||||
this.y = y || 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.copy = function (v) {
|
|
||||||
if (!GameLib.D3.Utils.UndefinedOrNull(v)) {
|
|
||||||
this.x = v.x;
|
|
||||||
this.y = v.y;
|
|
||||||
return this;
|
|
||||||
} else {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x,
|
|
||||||
this.y
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.equals = function(v) {
|
|
||||||
return (((this.x == v.x) &&
|
|
||||||
(this.y == v.y)) ||
|
|
||||||
((this.y == v.x) &&
|
|
||||||
(this.x == v.y)));
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.add = function(v) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x + v.x,
|
|
||||||
this.y + v.y
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.subtract = function(v) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x - v.x,
|
|
||||||
this.y - v.y
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.multiply = function(v) {
|
|
||||||
if (v instanceof GameLib.D3.Vector2) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x * v.x,
|
|
||||||
this.y * v.y
|
|
||||||
);
|
|
||||||
} else if (isNumber(v)) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x * v,
|
|
||||||
this.y * v
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.divide = function(v) {
|
|
||||||
if (v instanceof GameLib.D3.Vector2) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x * (1.0 / v.x),
|
|
||||||
this.y * (1.0 / v.y)
|
|
||||||
);
|
|
||||||
} else if (isNumber(v)) {
|
|
||||||
var invS = 1.0 / v;
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x * invS,
|
|
||||||
this.y * invS
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.set = function(x, y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.clamp = function(min, max) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
Math.max(min.x, Math.min(max.x, this.x)),
|
|
||||||
Math.max(min.y, Math.min(max.y, this.y))
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.length = function() {
|
|
||||||
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.dot = function(v) {
|
|
||||||
return this.x * v.x + this.y * v.y;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.normalize = function() {
|
|
||||||
return this.multiply(1.0 / this.length());
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.angle = function() {
|
|
||||||
var angle = Math.atan2(this.y, this.x);
|
|
||||||
if ( angle < 0 ) angle += 2 * Math.PI;
|
|
||||||
return angle;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector2.prototype.lerp = function ( v, alpha ) {
|
|
||||||
return new GameLib.D3.Vector2(
|
|
||||||
this.x + ( v.x - this.x ) * alpha,
|
|
||||||
this.y + ( v.y - this.y ) * alpha
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,235 +0,0 @@
|
||||||
GameLib.D3.Vector3 = GameLib.D3.API.Vector3;
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.subtract = function (v) {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x - v.x,
|
|
||||||
this.y - v.y,
|
|
||||||
this.z - v.z
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.sub = function (v) {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x - v.x,
|
|
||||||
this.y - v.y,
|
|
||||||
this.z - v.z
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.cross = function (v) {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.y * v.z - this.z * v.y,
|
|
||||||
this.z * v.x - this.x * v.z,
|
|
||||||
this.x * v.y - this.y * v.x
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.clockwise = function (u, v, w, viewPoint) {
|
|
||||||
var normal = GameLib.D3.Vector3.normal(u, v, w);
|
|
||||||
var uv = u.copy();
|
|
||||||
var winding = normal.dot(uv.subtract(viewPoint));
|
|
||||||
return (winding > 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.normal = function (u, v, w) {
|
|
||||||
var vv = v.copy();
|
|
||||||
var wv = w.copy();
|
|
||||||
return vv.subtract(u).cross(wv.subtract(u));
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.lookAt = function (at, up) {
|
|
||||||
var lookAtMatrix = GameLib.D3.Matrix4.lookAt(this, at, up);
|
|
||||||
return this.multiply(lookAtMatrix);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.translate = function (v) {
|
|
||||||
this.x += v.x;
|
|
||||||
this.y += v.y;
|
|
||||||
this.z += v.z;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.add = function (v) {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x + v.x,
|
|
||||||
this.y + v.y,
|
|
||||||
this.z + v.z
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.squared = function () {
|
|
||||||
return this.x * this.x + this.y * this.y + this.z * this.z;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.copy = function () {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x,
|
|
||||||
this.y,
|
|
||||||
this.z
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.set = function (x, y, z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.lerp = function ( v, alpha ) {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x + ( v.x - this.x ) * alpha,
|
|
||||||
this.y + ( v.y - this.y ) * alpha,
|
|
||||||
this.z + ( v.z - this.z ) * alpha
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.distanceTo = function(v) {
|
|
||||||
var dx = this.x - v.x,
|
|
||||||
dy = this.y - v.y,
|
|
||||||
dz = this.z - v.z;
|
|
||||||
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Vector3.AngleDirection = function(forward, directionToCheck, up) {
|
|
||||||
var perp = forward.cross(directionToCheck);
|
|
||||||
var dir = perp.dot(up);
|
|
||||||
|
|
||||||
if (dir > 0.0) {
|
|
||||||
return 1.0;
|
|
||||||
} else if (dir < 0.0) {
|
|
||||||
return -1.0;
|
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.multiply = function (s) {
|
|
||||||
if (s instanceof GameLib.D3.Vector3) {
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x * s.x,
|
|
||||||
this.y * s.y,
|
|
||||||
this.z * s.z
|
|
||||||
)
|
|
||||||
|
|
||||||
} else if (s instanceof GameLib.D3.Matrix4) {
|
|
||||||
|
|
||||||
var x = s.rows[0].x * this.x + s.rows[0].y * this.y + s.rows[0].z * this.z + s.rows[0].w;
|
|
||||||
var y = s.rows[1].x * this.x + s.rows[1].y * this.y + s.rows[1].z * this.z + s.rows[1].w;
|
|
||||||
var z = s.rows[2].x * this.x + s.rows[2].y * this.y + s.rows[2].z * this.z + s.rows[2].w;
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z
|
|
||||||
);
|
|
||||||
|
|
||||||
} else if (s instanceof GameLib.D3.Matrix3) {
|
|
||||||
|
|
||||||
var x = s.rows[0].x * this.x + s.rows[0].y * this.y + s.rows[0].z * this.z;
|
|
||||||
var y = s.rows[1].x * this.x + s.rows[1].y * this.y + s.rows[1].z * this.z;
|
|
||||||
var z = s.rows[2].x * this.x + s.rows[2].y * this.y + s.rows[2].z * this.z;
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z
|
|
||||||
);
|
|
||||||
|
|
||||||
} else if(!isNaN(parseFloat(s)) && isFinite(s)) {
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x * s,
|
|
||||||
this.y * s,
|
|
||||||
this.z * s
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
console.log("functionality not implemented - please do this");
|
|
||||||
throw new Error("not implemented");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.dot = function (v) {
|
|
||||||
return (this.x * v.x) + (this.y * v.y) + (this.z * v.z);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.normalize = function () {
|
|
||||||
var EPSILON = 0.000001;
|
|
||||||
var v2 = this.squared();
|
|
||||||
|
|
||||||
if (v2 < EPSILON) {
|
|
||||||
return this; //do nothing for zero vector
|
|
||||||
}
|
|
||||||
|
|
||||||
var invLength = 1.0 / Math.sqrt(v2);
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x * invLength,
|
|
||||||
this.y * invLength,
|
|
||||||
this.z * invLength
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.clone = function () {
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
this.x,
|
|
||||||
this.y,
|
|
||||||
this.z
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.applyQuaternion = function(q) {
|
|
||||||
var x = this.x, y = this.y, z = this.z;
|
|
||||||
var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
|
|
||||||
|
|
||||||
// calculate quat * vector
|
|
||||||
|
|
||||||
var ix = qw * x + qy * z - qz * y;
|
|
||||||
var iy = qw * y + qz * x - qx * z;
|
|
||||||
var iz = qw * z + qx * y - qy * x;
|
|
||||||
var iw = - qx * x - qy * y - qz * z;
|
|
||||||
|
|
||||||
// calculate result * inverse quat
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
ix * qw + iw * - qx + iy * - qz - iz * - qy,
|
|
||||||
iy * qw + iw * - qy + iz * - qx - ix * - qz,
|
|
||||||
iz * qw + iw * - qz + ix * - qy - iy * - qx
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.clamp = function(min, max) {
|
|
||||||
this.x = Math.max( min.x, Math.min( max.x, this.x ) );
|
|
||||||
this.y = Math.max( min.y, Math.min( max.y, this.y ) );
|
|
||||||
this.z = Math.max( min.z, Math.min( max.z, this.z ) );
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.negate = function() {
|
|
||||||
this.x = -this.x;
|
|
||||||
this.y = -this.y;
|
|
||||||
this.z = -this.z;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.length = function() {
|
|
||||||
return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.reflect = function(normal) {
|
|
||||||
return this.sub( v1.copy( normal ).multiply( 2 * this.dot( normal ) ) );
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.angleTo = function (v) {
|
|
||||||
var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
|
|
||||||
return Math.acos( exports.Math.clamp( theta, - 1, 1 ) );
|
|
||||||
};
|
|
|
@ -1,323 +0,0 @@
|
||||||
GameLib.D3.Vector4 = function Vector4(x, y, z, w) {
|
|
||||||
|
|
||||||
this.x = 0;
|
|
||||||
this.y = 0;
|
|
||||||
this.z = 0;
|
|
||||||
this.w = 1;
|
|
||||||
|
|
||||||
if (x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y) {
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (z) {
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w) {
|
|
||||||
this.w = w;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.prototype.translate = function (v) {
|
|
||||||
this.x += v.x;
|
|
||||||
this.y += v.y;
|
|
||||||
this.z += v.z;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.prototype.copy = function () {
|
|
||||||
return new GameLib.D3.Vector4(
|
|
||||||
this.x,
|
|
||||||
this.y,
|
|
||||||
this.z,
|
|
||||||
this.w
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.prototype.multiply = function (s) {
|
|
||||||
if (s instanceof GameLib.D3.Vector3) {
|
|
||||||
this.x *= s.x;
|
|
||||||
this.y *= s.y;
|
|
||||||
this.z *= s.z;
|
|
||||||
} else if (s instanceof GameLib.D3.Matrix4) {
|
|
||||||
var x = s.rows[0].x * this.x + s.rows[0].y * this.y + s.rows[0].z * this.z + s.rows[0].w * this.w;
|
|
||||||
var y = s.rows[1].x * this.x + s.rows[1].y * this.y + s.rows[1].z * this.z + s.rows[1].w * this.w;
|
|
||||||
var z = s.rows[2].x * this.x + s.rows[2].y * this.y + s.rows[2].z * this.z + s.rows[2].w * this.w;
|
|
||||||
var w = s.rows[3].x * this.x + s.rows[3].y * this.y + s.rows[3].z * this.z + s.rows[3].w * this.w;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.w = w;
|
|
||||||
} else {
|
|
||||||
console.log("functionality not implemented - please do this");
|
|
||||||
throw new Error("not implemented");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.prototype.normalize = function () {
|
|
||||||
|
|
||||||
// note - leave w untouched
|
|
||||||
var EPSILON = 0.000001;
|
|
||||||
|
|
||||||
var v2 = this.x * this.x + this.y * this.y + this.z * this.z;
|
|
||||||
|
|
||||||
if (v2 < EPSILON) {
|
|
||||||
return this; //do nothing for zero vector
|
|
||||||
}
|
|
||||||
|
|
||||||
var invLength = 1 / Math.sqrt(v2);
|
|
||||||
|
|
||||||
this.x *= invLength;
|
|
||||||
this.y *= invLength;
|
|
||||||
this.z *= invLength;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.prototype.subtract = function (v) {
|
|
||||||
|
|
||||||
if (v instanceof GameLib.D3.Vector3) {
|
|
||||||
this.x -= v.x;
|
|
||||||
this.y -= v.y;
|
|
||||||
this.z -= v.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v instanceof GameLib.D3.Vector4) {
|
|
||||||
this.x -= v.x;
|
|
||||||
this.y -= v.y;
|
|
||||||
this.z -= v.z;
|
|
||||||
this.w -= v.w;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points = function () {
|
|
||||||
this.vectors = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.add = function (vector) {
|
|
||||||
|
|
||||||
if (vector instanceof GameLib.D3.Vector3) {
|
|
||||||
vector = new GameLib.D3.Vector4(
|
|
||||||
vector.x,
|
|
||||||
vector.y,
|
|
||||||
vector.z,
|
|
||||||
1
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vector instanceof GameLib.D3.Vector4) {
|
|
||||||
console.warn("Vector needs to be of type Vector4");
|
|
||||||
throw new Error("Vector needs to be of type Vector4");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.vectors.push(vector);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.copy = function () {
|
|
||||||
|
|
||||||
var vectors = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
|
||||||
vectors.push(this.vectors[i].copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
return vectors;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.maximizeXDistance = function (grain) {
|
|
||||||
|
|
||||||
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
|
||||||
|
|
||||||
var multiplier = 0;
|
|
||||||
|
|
||||||
var rotationMatrixY = new GameLib.D3.Matrix4().rotationMatrixY(grain);
|
|
||||||
|
|
||||||
var totalRadians = 0;
|
|
||||||
|
|
||||||
var backupVectors = this.copy();
|
|
||||||
|
|
||||||
var maxXDistance = 0;
|
|
||||||
|
|
||||||
for (var i = 0; i < Math.PI * 2; i += grain) {
|
|
||||||
|
|
||||||
multiplier++;
|
|
||||||
|
|
||||||
for (var j = 0; j < this.vectors.length; j++) {
|
|
||||||
this.vectors[j] = rotationMatrixY.multiply(this.vectors[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var distances = this.distances();
|
|
||||||
|
|
||||||
if (distances.x > maxXDistance) {
|
|
||||||
|
|
||||||
maxXDistance = distances.x;
|
|
||||||
totalRadians = multiplier * grain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.vectors = backupVectors;
|
|
||||||
|
|
||||||
// console.log("distance: " + maxXDistance + " radians : " + totalRadians);
|
|
||||||
|
|
||||||
var maxRotationMatrix = new GameLib.D3.Matrix4().rotationMatrixY(totalRadians);
|
|
||||||
|
|
||||||
for (var k = 0; k < this.vectors.length; k++) {
|
|
||||||
this.vectors[k] = maxRotationMatrix.multiply(this.vectors[k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log("vectors (after): " + JSON.stringify(this.vectors, null, 2));
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.maximizeYDistance = function (grain) {
|
|
||||||
|
|
||||||
// console.log("vectors (before): " + JSON.stringify(this.vectors, null, 2));
|
|
||||||
|
|
||||||
var multiplier = 0;
|
|
||||||
|
|
||||||
var rotationMatrixX = new GameLib.D3.Matrix4().rotationMatrixX(grain);
|
|
||||||
|
|
||||||
var totalRadians = 0;
|
|
||||||
|
|
||||||
var backupVectors = this.copy();
|
|
||||||
|
|
||||||
var maxYDistance = 0;
|
|
||||||
|
|
||||||
for (var i = 0; i < Math.PI * 2; i += grain) {
|
|
||||||
|
|
||||||
multiplier++;
|
|
||||||
|
|
||||||
for (var j = 0; j < this.vectors.length; j++) {
|
|
||||||
this.vectors[j] = rotationMatrixX.multiply(this.vectors[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var distances = this.distances();
|
|
||||||
|
|
||||||
if (distances.y > maxYDistance) {
|
|
||||||
maxYDistance = distances.y;
|
|
||||||
totalRadians = multiplier * grain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.vectors = backupVectors;
|
|
||||||
|
|
||||||
// console.log("distance: " + maxYDistance + " radians : " + totalRadians);
|
|
||||||
|
|
||||||
var maxRotationMatrix = new GameLib.D3.Matrix4().rotationMatrixX(totalRadians);
|
|
||||||
|
|
||||||
for (var k = 0; k < this.vectors.length; k++) {
|
|
||||||
this.vectors[k] = maxRotationMatrix.multiply(this.vectors[k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log("vectors (after): " + JSON.stringify(this.vectors, null, 2));
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.lookAt = function (at, up) {
|
|
||||||
|
|
||||||
var polyCenter = this.average();
|
|
||||||
|
|
||||||
console.log("poly center : " + JSON.stringify(polyCenter));
|
|
||||||
|
|
||||||
var lookAtMatrix = new GameLib.D3.Matrix4().lookAt(polyCenter, at, up);
|
|
||||||
|
|
||||||
lookAtMatrix.rows[0] = new GameLib.D3.Vector4(1, 0, 0, 0);
|
|
||||||
lookAtMatrix.rows[1] = new GameLib.D3.Vector4(0, 0, 1, 0);
|
|
||||||
lookAtMatrix.rows[2] = new GameLib.D3.Vector4(0, 1, 0, 0);
|
|
||||||
|
|
||||||
console.log("look at matrix : " + JSON.stringify(lookAtMatrix, null, 2));
|
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
|
||||||
console.log("vector " + i + " (before): " + JSON.stringify(this.vectors[i]));
|
|
||||||
this.vectors[i] = lookAtMatrix.multiply(this.vectors[i]);
|
|
||||||
console.log("vector " + i + " (after) : " + JSON.stringify(this.vectors[i]));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.distances = function () {
|
|
||||||
|
|
||||||
var minX = this.vectors[0].x;
|
|
||||||
var minY = this.vectors[0].y;
|
|
||||||
var minZ = this.vectors[0].z;
|
|
||||||
|
|
||||||
var maxX = this.vectors[0].x;
|
|
||||||
var maxY = this.vectors[0].y;
|
|
||||||
var maxZ = this.vectors[0].z;
|
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
|
||||||
if (this.vectors[i].x < minX) {
|
|
||||||
minX = this.vectors[i].x;
|
|
||||||
}
|
|
||||||
if (this.vectors[i].y < minY) {
|
|
||||||
minY = this.vectors[i].y;
|
|
||||||
}
|
|
||||||
if (this.vectors[i].z < minZ) {
|
|
||||||
minZ = this.vectors[i].z;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.vectors[i].x > maxX) {
|
|
||||||
maxX = this.vectors[i].x;
|
|
||||||
}
|
|
||||||
if (this.vectors[i].y > maxY) {
|
|
||||||
maxY = this.vectors[i].y;
|
|
||||||
}
|
|
||||||
if (this.vectors[i].z > maxZ) {
|
|
||||||
maxZ = this.vectors[i].z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
Math.abs(maxX - minX),
|
|
||||||
Math.abs(maxY - minY),
|
|
||||||
Math.abs(maxY - minZ)
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.average = function () {
|
|
||||||
var averageX = 0;
|
|
||||||
var averageY = 0;
|
|
||||||
var averageZ = 0;
|
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
|
||||||
averageX += this.vectors[i].x;
|
|
||||||
averageY += this.vectors[i].y;
|
|
||||||
averageZ += this.vectors[i].z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GameLib.D3.Vector3(
|
|
||||||
averageX / this.vectors.length,
|
|
||||||
averageY / this.vectors.length,
|
|
||||||
averageZ / this.vectors.length
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.negate = function () {
|
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
|
||||||
this.vectors[i].x *= -1;
|
|
||||||
this.vectors[i].y *= -1;
|
|
||||||
this.vectors[i].z *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector4.Points.prototype.toOrigin = function () {
|
|
||||||
|
|
||||||
var distanceFromOrigin = this.average().negate();
|
|
||||||
|
|
||||||
for (var i = 0; i < this.vectors.length; i++) {
|
|
||||||
this.vectors[i].translate(distanceFromOrigin);
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* The normal gets assigned when the face calculates its normal
|
* The normal gets assigned when the face calculates its normal
|
||||||
* @param position
|
* @param position
|
||||||
* @param boneWeights GameLib.D3.BoneWeight[]
|
* @param boneWeights GameLib.D3.API.BoneWeight[]
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Vertex = function Vertex(
|
GameLib.D3.Vertex = function Vertex(
|
||||||
|
|
|
@ -24,7 +24,7 @@ GameLib.D3.World = function(
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (typeof gravity == 'undefined') {
|
if (typeof gravity == 'undefined') {
|
||||||
gravity = new GameLib.D3.Vector3(0, -9.81, 0);
|
gravity = new GameLib.D3.API.Vector3(0, -9.81, 0);
|
||||||
}
|
}
|
||||||
this.gravity = gravity;
|
this.gravity = gravity;
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ GameLib.D3.World.prototype.GetIndexedVertices = function(
|
||||||
/**
|
/**
|
||||||
* @param triangleMeshShape GameLib.D3.Shape
|
* @param triangleMeshShape GameLib.D3.Shape
|
||||||
* @param normalLength Number
|
* @param normalLength Number
|
||||||
* @param scale GameLib.D3.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param opacity Number
|
* @param opacity Number
|
||||||
* @param wireframeColor HexCode
|
* @param wireframeColor HexCode
|
||||||
* @param graphics THREE
|
* @param graphics THREE
|
||||||
|
@ -253,7 +253,7 @@ GameLib.D3.World.prototype.generateWireframeViewTriangleMesh = function(
|
||||||
/**
|
/**
|
||||||
* @param convexPolyMeshShape GameLib.D3.Shape
|
* @param convexPolyMeshShape GameLib.D3.Shape
|
||||||
* @param normalLength Number
|
* @param normalLength Number
|
||||||
* @param scale GameLib.D3.Vector3
|
* @param scale GameLib.D3.API.Vector3
|
||||||
* @param opacity Number
|
* @param opacity Number
|
||||||
* @param wireframeColor HexCode
|
* @param wireframeColor HexCode
|
||||||
* @param graphics THREE
|
* @param graphics THREE
|
||||||
|
|
14
src/index.js
14
src/index.js
|
@ -7,10 +7,10 @@ if (typeof GameLib.D3 === 'undefined') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof require != 'undefined') {
|
if (typeof require != 'undefined') {
|
||||||
GameLib.D3.Bone = require('./game-lib-bone.js');
|
GameLib.D3.API.Bone = require('./game-lib-bone.js');
|
||||||
GameLib.D3.BoneWeight = require('./game-lib-bone-weight');
|
GameLib.D3.API.BoneWeight = require('./game-lib-bone-weight');
|
||||||
GameLib.D3.Broadphase = require('./game-lib-broadphase');
|
GameLib.D3.Broadphase = require('./game-lib-broadphase');
|
||||||
GameLib.D3.Color = require('./game-lib-color');
|
GameLib.D3.API.Color = require('./game-lib-color');
|
||||||
GameLib.D3.FlyControls = require('./game-lib-fly-controls');
|
GameLib.D3.FlyControls = require('./game-lib-fly-controls');
|
||||||
GameLib.D3.Engine = require('./game-lib-engine');
|
GameLib.D3.Engine = require('./game-lib-engine');
|
||||||
GameLib.D3.Game = require('./game-lib-game');
|
GameLib.D3.Game = require('./game-lib-game');
|
||||||
|
@ -34,10 +34,10 @@ if (typeof require != 'undefined') {
|
||||||
GameLib.D3.Texture = require('./game-lib-texture');
|
GameLib.D3.Texture = require('./game-lib-texture');
|
||||||
GameLib.D3.TriangleEdge = require('./game-lib-triangle-edge');
|
GameLib.D3.TriangleEdge = require('./game-lib-triangle-edge');
|
||||||
GameLib.D3.TriangleFace = require('./game-lib-triangle-face');
|
GameLib.D3.TriangleFace = require('./game-lib-triangle-face');
|
||||||
GameLib.D3.Vector2 = require('./game-lib-vector-2');
|
GameLib.D3.API.Vector2 = require('./game-lib-vector-2');
|
||||||
GameLib.D3.Vector3 = require('./game-lib-vector-3');
|
GameLib.D3.API.Vector3 = require('./game-lib-vector-3');
|
||||||
GameLib.D3.Vector4 = require('./game-lib-vector-4');
|
GameLib.D3.API.Vector4 = require('./game-lib-vector-4');
|
||||||
GameLib.D3.Vector4.Points = require('./game-lib-vector-4-points');
|
GameLib.D3.API.Vector4.Points = require('./game-lib-vector-4-points');
|
||||||
GameLib.D3.Vertex = require('./game-lib-vertex');
|
GameLib.D3.Vertex = require('./game-lib-vertex');
|
||||||
GameLib.D3.World = require('./game-lib-world');
|
GameLib.D3.World = require('./game-lib-world');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue