beta.r3js.org
Theunis Johannes Botha 2018-04-09 10:05:13 +02:00
parent 142c51b558
commit 49a7605ff5
73 changed files with 1793 additions and 1793 deletions

View File

@ -1 +1 @@
#GameLib 3D (and 2D eventually) #R3 3D (and 2D eventually)

View File

@ -1,32 +0,0 @@
/**
* GameLib.D3.API.Camera.Stereo.Normal
* @constructor
* @param apiStereoCamera
*/
GameLib.D3.API.Camera.Stereo.Normal = function(
apiStereoCamera
) {
if (GameLib.Utils.UndefinedOrNull(apiStereoCamera)) {
apiStereoCamera = {
stereoType : GameLib.D3.API.Camera.Stereo.STEREO_TYPE_NORMAL
};
}
if (GameLib.Utils.UndefinedOrNull(apiStereoCamera.stereoType)) {
apiStereoCamera.stereoType = GameLib.D3.API.Camera.Stereo.STEREO_TYPE_NORMAL;
}
GameLib.D3.API.Camera.Stereo.call(
this,
apiStereoCamera,
apiStereoCamera.stereoType,
apiStereoCamera.eyeSep,
apiStereoCamera.main,
apiStereoCamera.cameraL,
apiStereoCamera.cameraR
);
};
GameLib.D3.API.Camera.Stereo.Normal.prototype = Object.create(GameLib.D3.API.Camera.Stereo.prototype);
GameLib.D3.API.Camera.Stereo.Normal.prototype.constructor = GameLib.D3.API.Camera.Stereo.Normal;

View File

@ -1,98 +0,0 @@
/**
* Follow Component
* @param id
* @param name
* @param currentComponent GameLib.Component
* @param targetComponent GameLib.Component
* @param targetPositionOffset GameLib.API.Vector3
* @param minDistance
* @param moveSpeed
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Follow = function (
id,
name,
currentComponent,
targetComponent,
targetPositionOffset,
minDistance,
moveSpeed,
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_FOLLOW,
{
'currentComponent': GameLib.Component,
'targetComponent': GameLib.Component
},
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(currentComponent)) {
currentComponent = null;
}
this.currentComponent = currentComponent;
if (GameLib.Utils.UndefinedOrNull(targetComponent)) {
targetComponent = null;
}
this.targetComponent = targetComponent;
if(GameLib.Utils.UndefinedOrNull(targetPositionOffset)) {
targetPositionOffset = new GameLib.API.Vector3(0, 0, 0);
}
this.targetPositionOffset = targetPositionOffset;
if (GameLib.Utils.UndefinedOrNull(minDistance)) {
minDistance = 2;
}
this.minDistance = minDistance;
if (GameLib.Utils.UndefinedOrNull(moveSpeed)) {
moveSpeed = 12.5;
}
this.moveSpeed = moveSpeed;
this.target = new GameLib.API.Vector3(0, 0, 0);
this.targetToParent = new GameLib.API.Vector3(0, 0, 0);
this.rotatedTargetOffset = new GameLib.API.Vector3(0, 0, 0);
this.rotated = new GameLib.API.Quaternion();
};
GameLib.D3.API.Follow.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Follow.prototype.constructor = GameLib.D3.API.Follow;
/**
* Object to GameLib.D3.API.Follow
* @param objectComponent
* @returns {GameLib.D3.API.Follow}
* @constructor
*/
GameLib.D3.API.Follow.FromObject = function(objectComponent) {
return new GameLib.D3.API.Follow(
objectComponent.id,
objectComponent.name,
objectComponent.currentComponent,
objectComponent.targetComponent,
GameLib.API.Vector3.FromObject(objectComponent.targetPositionOffset),
objectComponent.minDistance,
objectComponent.moveSpeed,
objectComponent.parentEntity
);
};

View File

@ -1,39 +0,0 @@
/**
* Graphics API
* @param id String
* @param name
* @param graphicsType
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Graphics = function (
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_GRAPHICS,
null,
null,
parentEntity
);
};
GameLib.D3.API.Graphics.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Graphics.prototype.constructor = GameLib.D3.API.Graphics;
/**
* Object to GameLib.D3.API.Graphics
* @param objectComponent
* @constructor
*/
GameLib.D3.API.Graphics.FromObjectComponent = function(objectComponent) {
return new GameLib.D3.API.Graphics(
objectComponent.id,
objectComponent.name,
objectComponent.graphicsType,
objectComponent.parentEntity
);
};

View File

@ -1,87 +0,0 @@
/**
* This component renders a scene
* @param id String
* @param name String
* @param helperType
* @param object
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Helper = function (
id,
name,
helperType,
object,
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_HELPER,
null,
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Helper (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(object)) {
console.warn('Cannot create a helper for an Object which does not exist');
throw new Error('Cannot create a helper for an Object which does not exist');
}
if (GameLib.Utils.UndefinedOrNull(helperType)) {
if (
object instanceof GameLib.D3.Mesh &&
object.meshType != GameLib.D3.Mesh.TYPE_CURVE
) {
helperType = GameLib.D3.Helper.HELPER_TYPE_WIREFRAME;
}
if (object instanceof GameLib.D3.Light) {
if (object.lightType == GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL) {
helperType = GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT;
}
if (object.lightType == GameLib.D3.Light.LIGHT_TYPE_POINT) {
helperType = GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT;
}
if (object.lightType == GameLib.D3.Light.LIGHT_TYPE_SPOT) {
helperType = GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT;
}
}
if (object instanceof GameLib.D3.Skeleton) {
helperType = GameLib.D3.Helper.HELPER_TYPE_SKELETON;
}
}
this.helperType = helperType;
};
GameLib.D3.API.Helper.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Helper.prototype.constructor = GameLib.D3.API.Helper;
/**
* Object to GameLib.D3.API.Helper
* @param objectComponent
* @constructor
*/
GameLib.D3.API.Helper.FromObjectComponent = function(objectComponent) {
return new GameLib.D3.API.Helper(
objectComponent.id,
objectComponent.name,
objectComponent.helperType,
objectComponent.object,
objectComponent.parentEntity
);
};

View File

@ -1,5 +0,0 @@
/**
* GameLib.D3.API.Input namespace
* @constructor
*/
GameLib.D3.API.Input = function() {};

View File

@ -1,50 +0,0 @@
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param domElementId
* @param camera GameLib.D3.Camera
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Input.Editor = function (
id,
name,
domElementId,
camera,
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_EDITOR_INPUT,
{
'camera' : GameLib.D3.Camera
},
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
domElementId = "divCanvas";
}
this.domElementId = domElementId;
if (GameLib.Utils.UndefinedOrNull(camera)) {
camera = null;
}
this.camera = camera;
};
GameLib.D3.API.Input.Editor.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Input.Editor.prototype.constructor = GameLib.D3.API.Input.Editor;

View File

@ -1,46 +0,0 @@
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param domElementId
* @param camera GameLib.D3.Camera
* @constructor
*/
GameLib.D3.API.Input.Fly = function (
id,
name,
domElementId,
camera
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_FLY_INPUT,
{
'camera' : GameLib.D3.Camera
}
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
domElementId = "divCanvas";
}
this.domElementId = domElementId;
if (GameLib.Utils.UndefinedOrNull(camera)) {
camera = null;
}
this.camera = camera;
};
GameLib.D3.API.Input.Fly.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Input.Fly.prototype.constructor = GameLib.D3.API.Input.Fly;

View File

@ -1,85 +0,0 @@
/**
* Looks from currentPosition to targetPosition (default up is 0,1,0)
* @param id
* @param name
* @param currentComponent GameLib.Component
* @param targetComponent GameLib.Component
* @param targetPositionOffset GameLib.API.Vector3
* @param rotationSpeed Number
* @param parentEntity
* @constructor
*/
GameLib.D3.API.LookAt = function (
id,
name,
currentComponent,
targetComponent,
targetPositionOffset,
rotationSpeed,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if(GameLib.Utils.UndefinedOrNull(currentComponent)) {
currentComponent = null;
}
this.currentComponent = currentComponent;
if(GameLib.Utils.UndefinedOrNull(targetComponent)) {
targetComponent = null;
}
this.targetComponent = targetComponent;
if(GameLib.Utils.UndefinedOrNull(targetPositionOffset)) {
targetPositionOffset = new GameLib.API.Vector3(0, 0, 0);
}
this.targetPositionOffset = targetPositionOffset;
if (GameLib.Utils.UndefinedOrNull(rotationSpeed)) {
rotationSpeed = 22.0;
}
this.rotationSpeed = rotationSpeed;
this.lookAtMatrix = new GameLib.API.Matrix4();
this.up = new GameLib.API.Vector3(0, 1, 0);
this.currentRotation = new GameLib.API.Quaternion();
this.targetPosition = new GameLib.API.Vector3();
if(GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
GameLib.D3.API.LookAt.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.LookAt.prototype.constructor = GameLib.D3.API.LookAt;
/**
* Object to GameLib.D3.API.LookAt
* @param objectComponent
* @returns {GameLib.D3.API.LookAt}
* @constructor
*/
GameLib.D3.API.LookAt.FromObject = function(objectComponent) {
return new GameLib.D3.API.LookAt(
objectComponent.id,
objectComponent.name,
objectComponent.currentComponent,
objectComponent.targetComponent,
GameLib.API.Vector3.FromObject(objectComponent.targetPositionOffset),
objectComponent.rotationSpeed,
objectComponent.parentEntity
);
};

View File

@ -1,203 +0,0 @@
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param spline GameLib.D3.API.Spline
* @param mesh GameLib.D3.API.Mesh
* @param raytraceMesh GameLib.D3.API.Mesh
* @param accelleration Number
* @param maxSpeed Number
* @param baseOffset GameLib.API.Vector
* @param maxOffset GameLib.API.Vector
* @param steeringSpeed Number
* @param targetOffset GameLib.API.Vector3
* @param currentOffset GameLib.API.Vector3
* @param currentPathValue Number
* @param currentSpeed Number
* @param direction Number
* @param raycaster GameLib.D3.Raycaster
* @param currentPosition GameLib.API.Vector3
* @param futurePosition GameLib.API.Vector3
* @param up GameLib.API.Vector3
* @param rotationMatrix GameLib.API.Matrix4
* @param rotationVector GameLib.API.Quaternion
* @param parentEntity
* @constructor
*/
GameLib.D3.API.PathFollowing = function (
id,
name,
spline,
mesh,
raytraceMesh,
accelleration,
maxSpeed,
baseOffset,
maxOffset,
steeringSpeed,
targetOffset,
currentOffset,
currentPathValue,
currentSpeed,
direction,
raycaster,
currentPosition,
futurePosition,
up,
rotationMatrix,
rotationVector,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(spline)) {
spline = null;
}
this.spline = spline;
if (GameLib.Utils.UndefinedOrNull(mesh)) {
mesh = null;
}
this.mesh = mesh;
if (GameLib.Utils.UndefinedOrNull(raytraceMesh)) {
raytraceMesh = null;
}
this.raytraceMesh = raytraceMesh;
if (GameLib.Utils.UndefinedOrNull(maxSpeed)) {
maxSpeed = 0.03;
}
this.maxSpeed = maxSpeed;
if (GameLib.Utils.UndefinedOrNull(accelleration)) {
accelleration = 0.1;
}
this.accelleration = accelleration;
if (GameLib.Utils.UndefinedOrNull(baseOffset)) {
baseOffset = new GameLib.API.Vector3();
}
this.baseOffset = baseOffset;
if (GameLib.Utils.UndefinedOrNull(maxOffset)) {
maxOffset = new GameLib.API.Vector3();
}
this.maxOffset = maxOffset;
if (GameLib.Utils.UndefinedOrNull(steeringSpeed)) {
steeringSpeed = 1.0;
}
this.steeringSpeed = steeringSpeed;
if (GameLib.Utils.UndefinedOrNull(targetOffset)) {
targetOffset = new GameLib.API.Vector3();
}
this.targetOffset = targetOffset;
if (GameLib.Utils.UndefinedOrNull(currentOffset)) {
currentOffset = new GameLib.API.Vector3();
}
this.currentOffset = currentOffset;
if (GameLib.Utils.UndefinedOrNull(currentPathValue)) {
currentPathValue = 0;
}
this.currentPathValue = currentPathValue;
if (GameLib.Utils.UndefinedOrNull(currentSpeed)) {
currentSpeed = 0;
}
this.currentSpeed = currentSpeed;
if (GameLib.Utils.UndefinedOrNull(direction)) {
direction = 1;
}
this.direction = direction;
if (GameLib.Utils.UndefinedOrNull(raycaster)) {
raycaster = new GameLib.D3.API.Raycaster();
}
this.raycaster = raycaster;
if (GameLib.Utils.UndefinedOrNull(currentPosition)) {
currentPosition = new GameLib.API.Vector3();
}
this.currentPosition = currentPosition;
if (GameLib.Utils.UndefinedOrNull(futurePosition)) {
futurePosition = new GameLib.API.Vector3();
}
this.futurePosition = futurePosition;
if(GameLib.Utils.UndefinedOrNull(up)) {
up = new GameLib.API.Vector3(0, 1, 0);
}
this.up = up;
if (GameLib.Utils.UndefinedOrNull(rotationMatrix)) {
rotationMatrix = new GameLib.API.Matrix4();
}
this.rotationMatrix = rotationMatrix;
if (GameLib.Utils.UndefinedOrNull(rotationVector)) {
rotationVector = new GameLib.API.Quaternion();
}
this.rotationVector = rotationVector;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
GameLib.D3.API.PathFollowing.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.PathFollowing.prototype.constructor = GameLib.D3.API.PathFollowing;
/**
* Returns an API path following component from an Object path following component
* @param objectComponent
* @constructor
*/
GameLib.D3.API.PathFollowing.FromObject = function(objectComponent) {
var apiRaycaster = null;
if (objectComponent.raycaster) {
apiRaycaster = GameLib.D3.API.Raycaster.FromObject(objectComponent.raycaster);
}
return new GameLib.D3.API.PathFollowing(
objectComponent.id,
objectComponent.name,
objectComponent.spline,
objectComponent.mesh,
objectComponent.raytraceMesh,
objectComponent.accelleration,
objectComponent.maxSpeed,
GameLib.API.Vector3.FromObject(objectComponent.baseOffset),
GameLib.API.Vector3.FromObject(objectComponent.maxOffset),
objectComponent.steeringSpeed,
GameLib.API.Vector3.FromObject(objectComponent.targetOffset),
GameLib.API.Vector3.FromObject(objectComponent.currentOffset),
objectComponent.currentPathValue,
objectComponent.currentSpeed,
objectComponent.direction,
apiRaycaster,
GameLib.API.Vector3.FromObject(objectComponent.currentPosition),
GameLib.API.Vector3.FromObject(objectComponent.futurePosition),
GameLib.API.Vector3.FromObject(objectComponent.up),
GameLib.API.Matrix4.FromObject(objectComponent.rotationMatrix),
GameLib.API.Quaternion.FromObject(objectComponent.rotationVector),
objectComponent.parentEntity
);
};

View File

@ -1,63 +0,0 @@
/**
* Engine Superset
* @param engineType
* @param instance {CANNON | Ammo | Goblin}
* @constructor
*/
GameLib.D3.Engine = function Engine(
engineType,
instance
) {
this.engineType = engineType;
this.instance = instance;
};
GameLib.D3.Engine.prototype.toApiEngine = function() {
//TODO: create API.Engine sometime
return {
engineType : this.engineType
}
};
/**
* True if CANNON physics
* @returns {boolean}
*/
GameLib.D3.Engine.prototype.isCannon = function() {
return (this.engineType == GameLib.D3.Engine.ENGINE_TYPE_CANNON)
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.D3.Engine.prototype.isNotCannonThrow = function() {
if (this.engineType != GameLib.D3.Engine.ENGINE_TYPE_CANNON) {
console.warn('Only CANNON supported for this function');
throw new Error('Only CANNON supported for this function');
}
};
/**
* True if Ammo physics
* @returns {boolean}
*/
GameLib.D3.Engine.prototype.isAmmo = function() {
return (this.engineType == GameLib.D3.Engine.ENGINE_TYPE_AMMO)
};
/**
* True if Goblin physics
* @returns {boolean}
*/
GameLib.D3.Engine.prototype.isGoblin = function() {
return (this.engineType == GameLib.D3.Engine.ENGINE_TYPE_GOBLIN)
};
/**
* Physics GameLib.D3.Engine Types
* @type {number}
*/
GameLib.D3.Engine.ENGINE_TYPE_CANNON = 0x1;
GameLib.D3.Engine.ENGINE_TYPE_AMMO = 0x2;
GameLib.D3.Engine.ENGINE_TYPE_GOBLIN = 0x3;

View File

@ -1,5 +0,0 @@
/**
* GameLib.D3.Input namespace
* @constructor
*/
GameLib.D3.Input = function () {};

View File

@ -1,90 +0,0 @@
/**
* Input parent class
* @param graphics GameLib.D3.Graphics
* @param apiInputEditor GameLib.D3.API.Input.Editor
* @constructor
*/
GameLib.D3.Input.Editor = function (
graphics,
apiInputEditor
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiInputEditor)) {
apiInputEditor = {};
}
if (apiInputEditor instanceof GameLib.D3.Input.Editor) {
return apiInputEditor;
}
GameLib.D3.API.Input.Editor.call(
this,
apiInputEditor.id,
apiInputEditor.name,
apiInputEditor.domElement,
apiInputEditor.camera,
apiInputEditor.parentEntity
);
if (this.domElement instanceof GameLib.API.DomElement) {
this.domElement = new GameLib.DomElement(
this.domElement
)
}
if (this.camera instanceof GameLib.D3.API.Camera) {
this.camera = new GameLib.D3.Camera(
this.graphics,
this.camera
)
}
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_INPUT_EDITOR,
{
'camera' : GameLib.D3.Camera
}
);
};
GameLib.D3.Input.Editor.prototype = Object.create(GameLib.D3.API.Input.Editor.prototype);
GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor;
GameLib.D3.Input.Editor.prototype.createInstance = function() {
return true;
};
GameLib.D3.Input.Editor.prototype.updateInstance = function() {
};
/**
* GameLib.D3.Input.Editor to GameLib.D3.API.Input.Editor
* @returns {GameLib.D3.API.Input.Editor}
*/
GameLib.D3.Input.Editor.prototype.toApiObject = function() {
var apiInputEditor = new GameLib.D3.API.Input.Editor(
this.id,
this.name,
this.domElementId,
GameLib.Utils.IdOrNull(this.camera),
GameLib.Utils.IdOrNull(this.parentEntity)
);
return apiInputEditor;
};
GameLib.D3.Input.Editor.FromObject = function(graphics, objectComponent) {
var apiInputEditor = GameLib.D3.API.Input.Editor.FromObject(objectComponent);
return new GameLib.D3.Input.Editor(
graphics,
apiInputEditor
);
};

View File

@ -1,77 +0,0 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime
* @param apiMeshLine
* @constructor
*/
GameLib.D3.Mesh.Line = function (
graphics,
apiMeshLine
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshLine)) {
apiMeshLine = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE
};
}
GameLib.D3.API.Mesh.Line.call(
this,
apiMeshLine,
apiMeshLine.lineWidth
);
GameLib.D3.Mesh.call(
this,
this.graphics,
this
);
};
GameLib.D3.Mesh.Line.prototype = Object.create(GameLib.D3.Mesh.prototype);
GameLib.D3.Mesh.Line.prototype.constructor = GameLib.D3.Mesh.Line;
GameLib.D3.Mesh.Line.prototype.createInstance = function() {
var geometry = new THREE.Geometry();
geometry.vertices.push(
this.vertices.map(
function(vertex){
return vertex.instance;
}
)
);
this.instance = new THREE.Line(geometry);
GameLib.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.lineWidth = this.lineWidth;
};
GameLib.D3.Mesh.Line.prototype.updateInstance = function(property) {
this.instance.linewidth = this.lineWidth;
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
};
/**
* Converts a GameLib.D3.Mesh.Line to a GameLib.D3.API.Mesh.Line
* @returns {GameLib.D3.API.Mesh.Line}
*/
GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshLine = new GameLib.D3.API.Mesh.Line(
apiMesh,
this.lineWidth
);
return apiMeshLine;
};

View File

@ -1,20 +0,0 @@
/**
* Rigid Wheel superset
* @param body GameLib.D3.RigidBody
* @param position GameLib.API.Vector3
* @param axis GameLib.API.Vector3
* @param direction GameLib.API.Vector3
* @constructor
*/
GameLib.D3.RigidWheel = function(
body,
position,
axis,
direction
) {
this.id = GameLib.Utils.RandomId();
this.body = body;
this.position = position;
this.axis = axis;
this.direction = direction;
};

View File

@ -1,5 +1,5 @@
/** /**
* GameLib.D3.API.Camera.Stereo.Anaglyph * R3.D3.API.Camera.Stereo.Anaglyph
* @constructor * @constructor
* @param apiStereoCamera * @param apiStereoCamera
* @param colorMatrixLeft * @param colorMatrixLeft
@ -7,7 +7,7 @@
* @param orthographicCamera * @param orthographicCamera
* @param orthographicScene * @param orthographicScene
*/ */
GameLib.D3.API.Camera.Stereo.Anaglyph = function( R3.D3.API.Camera.Stereo.Anaglyph = function(
apiStereoCamera, apiStereoCamera,
colorMatrixLeft, colorMatrixLeft,
colorMatrixRight, colorMatrixRight,
@ -19,17 +19,17 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
meshPlane meshPlane
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiStereoCamera)) { if (R3.Utils.UndefinedOrNull(apiStereoCamera)) {
apiStereoCamera = { apiStereoCamera = {
stereoType : GameLib.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH stereoType : R3.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiStereoCamera.stereoType)) { if (R3.Utils.UndefinedOrNull(apiStereoCamera.stereoType)) {
apiStereoCamera.stereoType = GameLib.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH; apiStereoCamera.stereoType = R3.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH;
} }
if (GameLib.Utils.UndefinedOrNull(colorMatrixLeft)) { if (R3.Utils.UndefinedOrNull(colorMatrixLeft)) {
colorMatrixLeft = [ colorMatrixLeft = [
1.0671679973602295, -0.0016435992438346148, 0.0001777536963345483, // r out 1.0671679973602295, -0.0016435992438346148, 0.0001777536963345483, // r out
-0.028107794001698494, -0.00019593400065787137, -0.0002875397040043026, // g out -0.028107794001698494, -0.00019593400065787137, -0.0002875397040043026, // g out
@ -38,7 +38,7 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
} }
this.colorMatrixLeft = colorMatrixLeft; this.colorMatrixLeft = colorMatrixLeft;
if (GameLib.Utils.UndefinedOrNull(colorMatrixRight)) { if (R3.Utils.UndefinedOrNull(colorMatrixRight)) {
colorMatrixRight = [ colorMatrixRight = [
-0.0355340838432312, -0.06440307199954987, 0.018319187685847282, // r out -0.0355340838432312, -0.06440307199954987, 0.018319187685847282, // r out
-0.10269022732973099, 0.8079727292060852, -0.04835830628871918, // g out -0.10269022732973099, 0.8079727292060852, -0.04835830628871918, // g out
@ -47,18 +47,18 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
} }
this.colorMatrixRight = colorMatrixRight; this.colorMatrixRight = colorMatrixRight;
if (GameLib.Utils.UndefinedOrNull(orthographicCamera)) { if (R3.Utils.UndefinedOrNull(orthographicCamera)) {
orthographicCamera = new GameLib.D3.API.Camera.Orthographic(null, null, 0, 1, -1, 1, 1, -1); orthographicCamera = new R3.D3.API.Camera.Orthographic(null, null, 0, 1, -1, 1, 1, -1);
} }
this.orthographicCamera = orthographicCamera; this.orthographicCamera = orthographicCamera;
if (GameLib.Utils.UndefinedOrNull(orthographicScene)) { if (R3.Utils.UndefinedOrNull(orthographicScene)) {
orthographicScene = new GameLib.D3.API.Scene(null, 'Orthographic Stereo Anaglyph Scene'); orthographicScene = new R3.D3.API.Scene(null, 'Orthographic Stereo Anaglyph Scene');
} }
this.orthographicScene = orthographicScene; this.orthographicScene = orthographicScene;
// //
// if (GameLib.Utils.UndefinedOrNull(renderTargetL)) { // if (R3.Utils.UndefinedOrNull(renderTargetL)) {
// renderTargetL = new GameLib.D3.API.RenderTarget(null, null, null, ) // renderTargetL = new R3.D3.API.RenderTarget(null, null, null, )
// } // }
// //
// renderTargetL, // renderTargetL,
@ -66,7 +66,7 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
// shaderMaterial, // shaderMaterial,
// meshPlane // meshPlane
GameLib.D3.API.Camera.Stereo.call( R3.D3.API.Camera.Stereo.call(
this, this,
apiStereoCamera, apiStereoCamera,
apiStereoCamera.stereoType, apiStereoCamera.stereoType,
@ -77,5 +77,5 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
); );
}; };
GameLib.D3.API.Camera.Stereo.Anaglyph.prototype = Object.create(GameLib.D3.API.Camera.Stereo.prototype); R3.D3.API.Camera.Stereo.Anaglyph.prototype = Object.create(R3.D3.API.Camera.Stereo.prototype);
GameLib.D3.API.Camera.Stereo.Anaglyph.prototype.constructor = GameLib.D3.API.Camera.Stereo.Anaglyph; R3.D3.API.Camera.Stereo.Anaglyph.prototype.constructor = R3.D3.API.Camera.Stereo.Anaglyph;

View File

@ -0,0 +1,32 @@
/**
* R3.D3.API.Camera.Stereo.Normal
* @constructor
* @param apiStereoCamera
*/
R3.D3.API.Camera.Stereo.Normal = function(
apiStereoCamera
) {
if (R3.Utils.UndefinedOrNull(apiStereoCamera)) {
apiStereoCamera = {
stereoType : R3.D3.API.Camera.Stereo.STEREO_TYPE_NORMAL
};
}
if (R3.Utils.UndefinedOrNull(apiStereoCamera.stereoType)) {
apiStereoCamera.stereoType = R3.D3.API.Camera.Stereo.STEREO_TYPE_NORMAL;
}
R3.D3.API.Camera.Stereo.call(
this,
apiStereoCamera,
apiStereoCamera.stereoType,
apiStereoCamera.eyeSep,
apiStereoCamera.main,
apiStereoCamera.cameraL,
apiStereoCamera.cameraR
);
};
R3.D3.API.Camera.Stereo.Normal.prototype = Object.create(R3.D3.API.Camera.Stereo.prototype);
R3.D3.API.Camera.Stereo.Normal.prototype.constructor = R3.D3.API.Camera.Stereo.Normal;

View File

@ -5,7 +5,7 @@
* @param baseUrl * @param baseUrl
* @param path * @param path
* @param imageFactory * @param imageFactory
* @param games [GameLib.API.D3.Game] * @param games [R3.API.D3.Game]
* @param scenes * @param scenes
* @param cameras * @param cameras
* @param composers * @param composers
@ -19,7 +19,7 @@
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Editor = function( R3.D3.API.Editor = function(
id, id,
name, name,
baseUrl, baseUrl,
@ -38,116 +38,116 @@ GameLib.D3.API.Editor = function(
selectedObjects, selectedObjects,
parentEntity parentEntity
) { ) {
GameLib.Component.call( R3.Component.call(
this, this,
GameLib.Component.COMPONENT_EDITOR, R3.Component.COMPONENT_EDITOR,
{ {
'imageFactory' : GameLib.D3.ImageFactory, 'imageFactory' : R3.D3.ImageFactory,
'games' : [GameLib.D3.Game], 'games' : [R3.D3.Game],
'scenes' : [GameLib.D3.Scene], 'scenes' : [R3.D3.Scene],
'cameras' : [GameLib.D3.Camera], 'cameras' : [R3.D3.Camera],
'composers' : [GameLib.D3.Composer], 'composers' : [R3.D3.Composer],
'viewports' : [GameLib.D3.Viewport], 'viewports' : [R3.D3.Viewport],
'renderers' : [GameLib.D3.Renderer], 'renderers' : [R3.D3.Renderer],
'renderTargets' : [GameLib.D3.RenderTarget], 'renderTargets' : [R3.D3.RenderTarget],
'systems' : [GameLib.System], 'systems' : [R3.System],
'entityManager' : GameLib.EntityManager 'entityManager' : R3.EntityManager
}, },
null, null,
parentEntity parentEntity
); );
if (GameLib.Utils.UndefinedOrNull(id)) { if (R3.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = R3.Utils.RandomId();
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) { if (R3.Utils.UndefinedOrNull(name)) {
name = 'Editor (' + this.id + ')'; name = 'Editor (' + this.id + ')';
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(baseUrl)) { if (R3.Utils.UndefinedOrNull(baseUrl)) {
baseUrl = ''; baseUrl = '';
} }
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
if (GameLib.Utils.UndefinedOrNull(path)) { if (R3.Utils.UndefinedOrNull(path)) {
path = ''; path = '';
} }
this.path = path; this.path = path;
if (GameLib.Utils.UndefinedOrNull(imageFactory)) { if (R3.Utils.UndefinedOrNull(imageFactory)) {
imageFactory = null; imageFactory = null;
} }
this.imageFactory = imageFactory; this.imageFactory = imageFactory;
if (GameLib.Utils.UndefinedOrNull(games)) { if (R3.Utils.UndefinedOrNull(games)) {
games = []; games = [];
} }
this.games = games; this.games = games;
if (GameLib.Utils.UndefinedOrNull(scenes)) { if (R3.Utils.UndefinedOrNull(scenes)) {
scenes = []; scenes = [];
} }
this.scenes = scenes; this.scenes = scenes;
if (GameLib.Utils.UndefinedOrNull(cameras)) { if (R3.Utils.UndefinedOrNull(cameras)) {
cameras = []; cameras = [];
} }
this.cameras = cameras; this.cameras = cameras;
if (GameLib.Utils.UndefinedOrNull(composers)) { if (R3.Utils.UndefinedOrNull(composers)) {
composers = []; composers = [];
} }
this.composers = composers; this.composers = composers;
if (GameLib.Utils.UndefinedOrNull(viewports)) { if (R3.Utils.UndefinedOrNull(viewports)) {
viewports = []; viewports = [];
} }
this.viewports = viewports; this.viewports = viewports;
if (GameLib.Utils.UndefinedOrNull(renderers)) { if (R3.Utils.UndefinedOrNull(renderers)) {
renderers = []; renderers = [];
} }
this.renderers = renderers; this.renderers = renderers;
if (GameLib.Utils.UndefinedOrNull(renderTargets)) { if (R3.Utils.UndefinedOrNull(renderTargets)) {
renderTargets = []; renderTargets = [];
} }
this.renderTargets = renderTargets; this.renderTargets = renderTargets;
if (GameLib.Utils.UndefinedOrNull(systems)) { if (R3.Utils.UndefinedOrNull(systems)) {
systems = []; systems = [];
} }
this.systems = systems; this.systems = systems;
if (GameLib.Utils.UndefinedOrNull(entityManager)) { if (R3.Utils.UndefinedOrNull(entityManager)) {
entityManager = new GameLib.API.EntityManager(); entityManager = new R3.API.EntityManager();
} }
this.entityManager = entityManager; this.entityManager = entityManager;
if (GameLib.Utils.UndefinedOrNull(allSelected)) { if (R3.Utils.UndefinedOrNull(allSelected)) {
allSelected = false; allSelected = false;
} }
this.allSelected = allSelected; this.allSelected = allSelected;
if (GameLib.Utils.UndefinedOrNull(selectedObjects)) { if (R3.Utils.UndefinedOrNull(selectedObjects)) {
selectedObjects = []; selectedObjects = [];
} }
this.selectedObjects = selectedObjects; this.selectedObjects = selectedObjects;
}; };
GameLib.D3.API.Editor.prototype = Object.create(GameLib.Component.prototype); R3.D3.API.Editor.prototype = Object.create(R3.Component.prototype);
GameLib.D3.API.Editor.prototype.constructor = GameLib.D3.API.Editor; R3.D3.API.Editor.prototype.constructor = R3.D3.API.Editor;
/** /**
* Creates an API Editor from an Object Editor * Creates an API Editor from an Object Editor
* @param objectEditor * @param objectEditor
* @constructor * @constructor
*/ */
GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) { R3.D3.API.Editor.FromObjectEditor = function(objectEditor) {
var apiImageFactory = null; var apiImageFactory = null;
var apiGames = []; var apiGames = [];
@ -161,13 +161,13 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
var apiEntityManager = null; var apiEntityManager = null;
if (objectEditor.imageFactory) { if (objectEditor.imageFactory) {
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectEditor.imageFactory); apiImageFactory = R3.D3.API.ImageFactory.FromObjectImageFactory(objectEditor.imageFactory);
} }
if (objectEditor.games) { if (objectEditor.games) {
apiGames = objectEditor.games.map( apiGames = objectEditor.games.map(
function(objectGame){ function(objectGame){
return GameLib.D3.API.Game.FromObjectGame(objectGame); return R3.D3.API.Game.FromObjectGame(objectGame);
} }
); );
} }
@ -175,7 +175,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.scenes) { if (objectEditor.scenes) {
apiScenes = objectEditor.scenes.map( apiScenes = objectEditor.scenes.map(
function(objectScene){ function(objectScene){
return GameLib.D3.API.Scene.FromObjectScene(objectScene); return R3.D3.API.Scene.FromObjectScene(objectScene);
} }
); );
} }
@ -183,7 +183,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.cameras) { if (objectEditor.cameras) {
apiCameras = objectEditor.cameras.map( apiCameras = objectEditor.cameras.map(
function(objectCamera){ function(objectCamera){
return GameLib.D3.API.Camera.FromObjectCamera(objectCamera); return R3.D3.API.Camera.FromObjectCamera(objectCamera);
} }
); );
} }
@ -191,7 +191,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.composers) { if (objectEditor.composers) {
apiComposers = objectEditor.composers.map( apiComposers = objectEditor.composers.map(
function(objectComposer){ function(objectComposer){
return GameLib.D3.API.Composer.FromObjectComponent(objectComposer); return R3.D3.API.Composer.FromObjectComponent(objectComposer);
} }
); );
} }
@ -199,7 +199,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.viewports) { if (objectEditor.viewports) {
apiViewports = objectEditor.viewports.map( apiViewports = objectEditor.viewports.map(
function(objectViewport){ function(objectViewport){
return GameLib.D3.API.Viewport.FromObjectViewport(objectViewport); return R3.D3.API.Viewport.FromObjectViewport(objectViewport);
} }
); );
} }
@ -207,7 +207,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.renderers) { if (objectEditor.renderers) {
apiRenderers = objectEditor.renderers.map( apiRenderers = objectEditor.renderers.map(
function(objectRenderer){ function(objectRenderer){
return GameLib.D3.API.Renderer.FromObjectComponent(objectRenderer); return R3.D3.API.Renderer.FromObjectComponent(objectRenderer);
} }
); );
} }
@ -215,7 +215,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.renderTargets) { if (objectEditor.renderTargets) {
apiRenderTargets = objectEditor.renderTargets.map( apiRenderTargets = objectEditor.renderTargets.map(
function(objectRenderTarget){ function(objectRenderTarget){
return GameLib.D3.API.RenderTarget.FromObjectComponent(objectRenderTarget); return R3.D3.API.RenderTarget.FromObjectComponent(objectRenderTarget);
} }
); );
} }
@ -223,16 +223,16 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
if (objectEditor.systems) { if (objectEditor.systems) {
apiSystems = objectEditor.systems.map( apiSystems = objectEditor.systems.map(
function(objectSystem){ function(objectSystem){
return GameLib.API.System.FromObjectComponent(objectSystem); return R3.API.System.FromObjectComponent(objectSystem);
} }
); );
} }
if (objectEditor.entityManager) { if (objectEditor.entityManager) {
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectEditor.entityManager); apiEntityManager = R3.API.EntityManager.FromObjectEntityManager(objectEditor.entityManager);
} }
return new GameLib.D3.API.Editor( return new R3.D3.API.Editor(
objectEditor.id, objectEditor.id,
objectEditor.name, objectEditor.name,
objectEditor.baseUrl, objectEditor.baseUrl,

98
bak/r3-d3-api-follow.js Normal file
View File

@ -0,0 +1,98 @@
/**
* Follow Component
* @param id
* @param name
* @param currentComponent R3.Component
* @param targetComponent R3.Component
* @param targetPositionOffset R3.API.Vector3
* @param minDistance
* @param moveSpeed
* @param parentEntity
* @constructor
*/
R3.D3.API.Follow = function (
id,
name,
currentComponent,
targetComponent,
targetPositionOffset,
minDistance,
moveSpeed,
parentEntity
) {
R3.Component.call(
this,
R3.Component.COMPONENT_FOLLOW,
{
'currentComponent': R3.Component,
'targetComponent': R3.Component
},
parentEntity
);
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (R3.Utils.UndefinedOrNull(currentComponent)) {
currentComponent = null;
}
this.currentComponent = currentComponent;
if (R3.Utils.UndefinedOrNull(targetComponent)) {
targetComponent = null;
}
this.targetComponent = targetComponent;
if(R3.Utils.UndefinedOrNull(targetPositionOffset)) {
targetPositionOffset = new R3.API.Vector3(0, 0, 0);
}
this.targetPositionOffset = targetPositionOffset;
if (R3.Utils.UndefinedOrNull(minDistance)) {
minDistance = 2;
}
this.minDistance = minDistance;
if (R3.Utils.UndefinedOrNull(moveSpeed)) {
moveSpeed = 12.5;
}
this.moveSpeed = moveSpeed;
this.target = new R3.API.Vector3(0, 0, 0);
this.targetToParent = new R3.API.Vector3(0, 0, 0);
this.rotatedTargetOffset = new R3.API.Vector3(0, 0, 0);
this.rotated = new R3.API.Quaternion();
};
R3.D3.API.Follow.prototype = Object.create(R3.Component.prototype);
R3.D3.API.Follow.prototype.constructor = R3.D3.API.Follow;
/**
* Object to R3.D3.API.Follow
* @param objectComponent
* @returns {R3.D3.API.Follow}
* @constructor
*/
R3.D3.API.Follow.FromObject = function(objectComponent) {
return new R3.D3.API.Follow(
objectComponent.id,
objectComponent.name,
objectComponent.currentComponent,
objectComponent.targetComponent,
R3.API.Vector3.FromObject(objectComponent.targetPositionOffset),
objectComponent.minDistance,
objectComponent.moveSpeed,
objectComponent.parentEntity
);
};

View File

@ -18,7 +18,7 @@
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Game = function( R3.D3.API.Game = function(
id, id,
name, name,
baseUrl, baseUrl,
@ -34,100 +34,100 @@ GameLib.D3.API.Game = function(
entityManager, entityManager,
parentEntity parentEntity
) { ) {
GameLib.Component.call( R3.Component.call(
this, this,
GameLib.Component.COMPONENT_GAME, R3.Component.COMPONENT_GAME,
{ {
'imageFactory' : GameLib.D3.ImageFactory, 'imageFactory' : R3.D3.ImageFactory,
'cameras' : [GameLib.D3.Camera], 'cameras' : [R3.D3.Camera],
'composers' : [GameLib.D3.Composer], 'composers' : [R3.D3.Composer],
'viewports' : [GameLib.D3.Viewport], 'viewports' : [R3.D3.Viewport],
'renderers' : [GameLib.D3.Renderer], 'renderers' : [R3.D3.Renderer],
'renderTargets' : [GameLib.D3.RenderTarget], 'renderTargets' : [R3.D3.RenderTarget],
'systems' : [GameLib.System], 'systems' : [R3.System],
'entityManager' : GameLib.EntityManager 'entityManager' : R3.EntityManager
}, },
null, null,
parentEntity parentEntity
); );
if (GameLib.Utils.UndefinedOrNull(id)) { if (R3.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = R3.Utils.RandomId();
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) { if (R3.Utils.UndefinedOrNull(name)) {
name = 'Game (' + this.id + ')'; name = 'Game (' + this.id + ')';
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(baseUrl)) { if (R3.Utils.UndefinedOrNull(baseUrl)) {
baseUrl = ''; baseUrl = '';
console.warn('The base URL required for downloading images is not set - textured meshes will not render properly'); console.warn('The base URL required for downloading images is not set - textured meshes will not render properly');
} }
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
if (GameLib.Utils.UndefinedOrNull(path)) { if (R3.Utils.UndefinedOrNull(path)) {
path = ''; path = '';
} }
this.path = path; this.path = path;
if (GameLib.Utils.UndefinedOrNull(imageFactory)) { if (R3.Utils.UndefinedOrNull(imageFactory)) {
imageFactory = null; imageFactory = null;
} }
this.imageFactory = imageFactory; this.imageFactory = imageFactory;
if (GameLib.Utils.UndefinedOrNull(gameType)) { if (R3.Utils.UndefinedOrNull(gameType)) {
gameType = GameLib.D3.Game.GAME_TYPE_VR_PONG; gameType = R3.D3.Game.GAME_TYPE_VR_PONG;
} }
this.gameType = gameType; this.gameType = gameType;
if (GameLib.Utils.UndefinedOrNull(cameras)) { if (R3.Utils.UndefinedOrNull(cameras)) {
cameras = []; cameras = [];
} }
this.cameras = cameras; this.cameras = cameras;
if (GameLib.Utils.UndefinedOrNull(composers)) { if (R3.Utils.UndefinedOrNull(composers)) {
composers = []; composers = [];
} }
this.composers = composers; this.composers = composers;
if (GameLib.Utils.UndefinedOrNull(viewports)) { if (R3.Utils.UndefinedOrNull(viewports)) {
viewports = []; viewports = [];
} }
this.viewports = viewports; this.viewports = viewports;
if (GameLib.Utils.UndefinedOrNull(renderers)) { if (R3.Utils.UndefinedOrNull(renderers)) {
renderers = []; renderers = [];
} }
this.renderers = renderers; this.renderers = renderers;
if (GameLib.Utils.UndefinedOrNull(renderTargets)) { if (R3.Utils.UndefinedOrNull(renderTargets)) {
renderTargets = []; renderTargets = [];
} }
this.renderTargets = renderTargets; this.renderTargets = renderTargets;
if (GameLib.Utils.UndefinedOrNull(systems)) { if (R3.Utils.UndefinedOrNull(systems)) {
systems = []; systems = [];
} }
this.systems = systems; this.systems = systems;
if (GameLib.Utils.UndefinedOrNull(entityManager)) { if (R3.Utils.UndefinedOrNull(entityManager)) {
entityManager = null; entityManager = null;
} }
this.entityManager = entityManager; this.entityManager = entityManager;
}; };
GameLib.D3.API.Game.prototype = Object.create(GameLib.Component.prototype); R3.D3.API.Game.prototype = Object.create(R3.Component.prototype);
GameLib.D3.API.Game.prototype.constructor = GameLib.D3.API.Game; R3.D3.API.Game.prototype.constructor = R3.D3.API.Game;
/** /**
* Creates an API camera from an Object camera * Creates an API camera from an Object camera
* @param objectGame * @param objectGame
* @constructor * @constructor
*/ */
GameLib.D3.API.Game.FromObjectGame = function(objectGame) { R3.D3.API.Game.FromObjectGame = function(objectGame) {
var apiImageFactory = null; var apiImageFactory = null;
var apiCameras = []; var apiCameras = [];
@ -140,13 +140,13 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
var apiEntityManager = null; var apiEntityManager = null;
if (objectGame.imageFactory) { if (objectGame.imageFactory) {
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectGame.imageFactory); apiImageFactory = R3.D3.API.ImageFactory.FromObjectImageFactory(objectGame.imageFactory);
} }
if (objectGame.cameras) { if (objectGame.cameras) {
apiCameras = objectGame.cameras.map( apiCameras = objectGame.cameras.map(
function(objectCamera){ function(objectCamera){
return GameLib.D3.API.Camera.FromObjectCamera(objectCamera); return R3.D3.API.Camera.FromObjectCamera(objectCamera);
} }
); );
} }
@ -154,7 +154,7 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
if (objectGame.composers) { if (objectGame.composers) {
apiComposers = objectGame.composers.map( apiComposers = objectGame.composers.map(
function(objectComposer){ function(objectComposer){
return GameLib.D3.API.Composer.FromObjectComponent(objectComposer); return R3.D3.API.Composer.FromObjectComponent(objectComposer);
} }
); );
} }
@ -162,7 +162,7 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
if (objectGame.viewports) { if (objectGame.viewports) {
apiViewports = objectGame.viewports.map( apiViewports = objectGame.viewports.map(
function(objectViewport){ function(objectViewport){
return GameLib.D3.API.Viewport.FromObjectViewport(objectViewport); return R3.D3.API.Viewport.FromObjectViewport(objectViewport);
} }
); );
} }
@ -170,7 +170,7 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
if (objectGame.renderers) { if (objectGame.renderers) {
apiRenderers = objectGame.renderers.map( apiRenderers = objectGame.renderers.map(
function(objectRenderer){ function(objectRenderer){
return GameLib.D3.API.Renderer.FromObjectComponent(objectRenderer); return R3.D3.API.Renderer.FromObjectComponent(objectRenderer);
} }
); );
} }
@ -178,7 +178,7 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
if (objectGame.renderTargets) { if (objectGame.renderTargets) {
apiRenderTargets = objectGame.renderTargets.map( apiRenderTargets = objectGame.renderTargets.map(
function(objectRenderTarget){ function(objectRenderTarget){
return GameLib.D3.API.RenderTarget.FromObjectComponent(objectRenderTarget); return R3.D3.API.RenderTarget.FromObjectComponent(objectRenderTarget);
} }
); );
} }
@ -186,16 +186,16 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
if (objectGame.systems) { if (objectGame.systems) {
apiSystems = objectGame.systems.map( apiSystems = objectGame.systems.map(
function(objectSystem){ function(objectSystem){
return GameLib.API.System.FromObjectComponent(objectSystem); return R3.API.System.FromObjectComponent(objectSystem);
} }
); );
} }
if (objectGame.entityManager) { if (objectGame.entityManager) {
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectGame.entityManager); apiEntityManager = R3.API.EntityManager.FromObjectEntityManager(objectGame.entityManager);
} }
return new GameLib.D3.API.Game( return new R3.D3.API.Game(
objectGame.id, objectGame.id,
objectGame.name, objectGame.name,
objectGame.baseUrl, objectGame.baseUrl,

39
bak/r3-d3-api-graphics.js Normal file
View File

@ -0,0 +1,39 @@
/**
* Graphics API
* @param id String
* @param name
* @param graphicsType
* @param parentEntity
* @constructor
*/
R3.D3.API.Graphics = function (
parentEntity
) {
R3.Component.call(
this,
R3.Component.COMPONENT_GRAPHICS,
null,
null,
parentEntity
);
};
R3.D3.API.Graphics.prototype = Object.create(R3.Component.prototype);
R3.D3.API.Graphics.prototype.constructor = R3.D3.API.Graphics;
/**
* Object to R3.D3.API.Graphics
* @param objectComponent
* @constructor
*/
R3.D3.API.Graphics.FromObjectComponent = function(objectComponent) {
return new R3.D3.API.Graphics(
objectComponent.id,
objectComponent.name,
objectComponent.graphicsType,
objectComponent.parentEntity
);
};

87
bak/r3-d3-api-helper.js Normal file
View File

@ -0,0 +1,87 @@
/**
* This component renders a scene
* @param id String
* @param name String
* @param helperType
* @param object
* @param parentEntity
* @constructor
*/
R3.D3.API.Helper = function (
id,
name,
helperType,
object,
parentEntity
) {
R3.Component.call(
this,
R3.Component.COMPONENT_HELPER,
null,
null,
parentEntity
);
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = 'Helper (' + id + ')';
}
this.name = name;
if (R3.Utils.UndefinedOrNull(object)) {
console.warn('Cannot create a helper for an Object which does not exist');
throw new Error('Cannot create a helper for an Object which does not exist');
}
if (R3.Utils.UndefinedOrNull(helperType)) {
if (
object instanceof R3.D3.Mesh &&
object.meshType != R3.D3.Mesh.TYPE_CURVE
) {
helperType = R3.D3.Helper.HELPER_TYPE_WIREFRAME;
}
if (object instanceof R3.D3.Light) {
if (object.lightType == R3.D3.Light.LIGHT_TYPE_DIRECTIONAL) {
helperType = R3.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT;
}
if (object.lightType == R3.D3.Light.LIGHT_TYPE_POINT) {
helperType = R3.D3.Helper.HELPER_TYPE_POINT_LIGHT;
}
if (object.lightType == R3.D3.Light.LIGHT_TYPE_SPOT) {
helperType = R3.D3.Helper.HELPER_TYPE_SPOT_LIGHT;
}
}
if (object instanceof R3.D3.Skeleton) {
helperType = R3.D3.Helper.HELPER_TYPE_SKELETON;
}
}
this.helperType = helperType;
};
R3.D3.API.Helper.prototype = Object.create(R3.Component.prototype);
R3.D3.API.Helper.prototype.constructor = R3.D3.API.Helper;
/**
* Object to R3.D3.API.Helper
* @param objectComponent
* @constructor
*/
R3.D3.API.Helper.FromObjectComponent = function(objectComponent) {
return new R3.D3.API.Helper(
objectComponent.id,
objectComponent.name,
objectComponent.helperType,
objectComponent.object,
objectComponent.parentEntity
);
};

View File

@ -6,44 +6,44 @@
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.ImageFactory = function( R3.D3.API.ImageFactory = function(
id, id,
name, name,
baseUrl, baseUrl,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (R3.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = R3.Utils.RandomId();
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) { if (R3.Utils.UndefinedOrNull(name)) {
name = 'ImageFactory (' + this.id + ')'; name = 'ImageFactory (' + this.id + ')';
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(baseUrl)) { if (R3.Utils.UndefinedOrNull(baseUrl)) {
baseUrl = ''; baseUrl = '';
console.warn('No baseURL defined for image factory'); console.warn('No baseURL defined for image factory');
} }
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { if (R3.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null; parentEntity = null;
} }
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
}; };
GameLib.D3.API.ImageFactory.prototype = Object.create(GameLib.Component.prototype); R3.D3.API.ImageFactory.prototype = Object.create(R3.Component.prototype);
GameLib.D3.API.ImageFactory.prototype.constructor = GameLib.D3.API.ImageFactory; R3.D3.API.ImageFactory.prototype.constructor = R3.D3.API.ImageFactory;
/** /**
* Returns an API ImageFactory from an Object ImageFactory * Returns an API ImageFactory from an Object ImageFactory
* @param objectImageFactory * @param objectImageFactory
* @constructor * @constructor
*/ */
GameLib.D3.API.ImageFactory.FromObject = function(objectImageFactory) { R3.D3.API.ImageFactory.FromObject = function(objectImageFactory) {
return new GameLib.D3.API.ImageFactory( return new R3.D3.API.ImageFactory(
objectImageFactory.id, objectImageFactory.id,
objectImageFactory.name, objectImageFactory.name,
objectImageFactory.baseUrl, objectImageFactory.baseUrl,

5
bak/r3-d3-api-input-a.js Normal file
View File

@ -0,0 +1,5 @@
/**
* R3.D3.API.Input namespace
* @constructor
*/
R3.D3.API.Input = function() {};

View File

@ -3,7 +3,7 @@
* @param id String * @param id String
* @param name String * @param name String
* @param domElementId * @param domElementId
* @param pathFollowingComponent GameLib.D3.Mesh * @param pathFollowingComponent R3.D3.Mesh
* @param parentEntity * @param parentEntity
* @param wheelFL * @param wheelFL
* @param wheelFR * @param wheelFR
@ -15,7 +15,7 @@
* @param rotationFactor * @param rotationFactor
* @constructor * @constructor
*/ */
GameLib.D3.API.Input.Drive = function ( R3.D3.API.Input.Drive = function (
id, id,
name, name,
domElementId, domElementId,
@ -30,84 +30,84 @@ GameLib.D3.API.Input.Drive = function (
distanceGrain, distanceGrain,
rotationFactor rotationFactor
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (R3.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = R3.Utils.RandomId();
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) { if (R3.Utils.UndefinedOrNull(name)) {
name = 'Input.Drive (' + this.id + ')'; name = 'Input.Drive (' + this.id + ')';
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElementId)) { if (R3.Utils.UndefinedOrNull(domElementId)) {
domElementId = "divCanvas"; domElementId = "divCanvas";
} }
this.domElementId = domElementId; this.domElementId = domElementId;
if (GameLib.Utils.UndefinedOrNull(pathFollowingComponent)) { if (R3.Utils.UndefinedOrNull(pathFollowingComponent)) {
pathFollowingComponent = null; pathFollowingComponent = null;
} }
this.pathFollowingComponent = pathFollowingComponent; this.pathFollowingComponent = pathFollowingComponent;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { if (R3.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null; parentEntity = null;
} }
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(wheelFL)) { if (R3.Utils.UndefinedOrNull(wheelFL)) {
wheelFL = null; wheelFL = null;
} }
this.wheelFL = wheelFL; this.wheelFL = wheelFL;
if (GameLib.Utils.UndefinedOrNull(wheelFR)) { if (R3.Utils.UndefinedOrNull(wheelFR)) {
wheelFR = null; wheelFR = null;
} }
this.wheelFR = wheelFR; this.wheelFR = wheelFR;
if (GameLib.Utils.UndefinedOrNull(wheelRL)) { if (R3.Utils.UndefinedOrNull(wheelRL)) {
wheelRL = null; wheelRL = null;
} }
this.wheelRL = wheelRL; this.wheelRL = wheelRL;
if (GameLib.Utils.UndefinedOrNull(wheelRR)) { if (R3.Utils.UndefinedOrNull(wheelRR)) {
wheelRR = null; wheelRR = null;
} }
this.wheelRR = wheelRR; this.wheelRR = wheelRR;
if (GameLib.Utils.UndefinedOrNull(heightOffset)) { if (R3.Utils.UndefinedOrNull(heightOffset)) {
heightOffset = 0; heightOffset = 0;
} }
this.heightOffset = heightOffset; this.heightOffset = heightOffset;
if (GameLib.Utils.UndefinedOrNull(distance)) { if (R3.Utils.UndefinedOrNull(distance)) {
distance = 0; distance = 0;
} }
this.distance = distance; this.distance = distance;
if (GameLib.Utils.UndefinedOrNull(distanceGrain)) { if (R3.Utils.UndefinedOrNull(distanceGrain)) {
distanceGrain = 0.1; distanceGrain = 0.1;
} }
this.distanceGrain = distanceGrain; this.distanceGrain = distanceGrain;
if (GameLib.Utils.UndefinedOrNull(rotationFactor)) { if (R3.Utils.UndefinedOrNull(rotationFactor)) {
rotationFactor = 0.1; rotationFactor = 0.1;
} }
this.rotationFactor = rotationFactor; this.rotationFactor = rotationFactor;
}; };
GameLib.D3.API.Input.Drive.prototype = Object.create(GameLib.Component.prototype); R3.D3.API.Input.Drive.prototype = Object.create(R3.Component.prototype);
GameLib.D3.API.Input.Drive.prototype.constructor = GameLib.D3.API.Input.Drive; R3.D3.API.Input.Drive.prototype.constructor = R3.D3.API.Input.Drive;
/** /**
* Object to GameLib.D3.API.Input.Drive * Object to R3.D3.API.Input.Drive
* @param objectComponent * @param objectComponent
* @returns {GameLib.D3.API.Input.Drive} * @returns {R3.D3.API.Input.Drive}
* @constructor * @constructor
*/ */
GameLib.D3.API.Input.Drive.FromObject = function(objectComponent) { R3.D3.API.Input.Drive.FromObject = function(objectComponent) {
return new GameLib.D3.API.Input.Drive( return new R3.D3.API.Input.Drive(
objectComponent.id, objectComponent.id,
objectComponent.name, objectComponent.name,
objectComponent.domElementId, objectComponent.domElementId,

View File

@ -0,0 +1,50 @@
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param domElementId
* @param camera R3.D3.Camera
* @param parentEntity
* @constructor
*/
R3.D3.API.Input.Editor = function (
id,
name,
domElementId,
camera,
parentEntity
) {
R3.Component.call(
this,
R3.Component.COMPONENT_EDITOR_INPUT,
{
'camera' : R3.D3.Camera
},
null,
parentEntity
);
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (R3.Utils.UndefinedOrNull(domElementId)) {
domElementId = "divCanvas";
}
this.domElementId = domElementId;
if (R3.Utils.UndefinedOrNull(camera)) {
camera = null;
}
this.camera = camera;
};
R3.D3.API.Input.Editor.prototype = Object.create(R3.Component.prototype);
R3.D3.API.Input.Editor.prototype.constructor = R3.D3.API.Input.Editor;

View File

@ -7,7 +7,7 @@
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Input.Editor = function ( R3.D3.API.Input.Editor = function (
id, id,
name, name,
domElement, domElement,
@ -15,44 +15,44 @@ GameLib.D3.API.Input.Editor = function (
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (R3.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = R3.Utils.RandomId();
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) { if (R3.Utils.UndefinedOrNull(name)) {
name = 'Input Editor (' + this.id + ')'; name = 'Input Editor (' + this.id + ')';
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElement)) { if (R3.Utils.UndefinedOrNull(domElement)) {
domElement = null; domElement = null;
} }
this.domElement = domElement; this.domElement = domElement;
if (GameLib.Utils.UndefinedOrNull(camera)) { if (R3.Utils.UndefinedOrNull(camera)) {
camera = null; camera = null;
} }
this.camera = camera; this.camera = camera;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { if (R3.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null; parentEntity = null;
} }
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
}; };
GameLib.D3.API.Input.Editor.prototype = Object.create(GameLib.Component.prototype); R3.D3.API.Input.Editor.prototype = Object.create(R3.Component.prototype);
GameLib.D3.API.Input.Editor.prototype.constructor = GameLib.D3.API.Input.Editor; R3.D3.API.Input.Editor.prototype.constructor = R3.D3.API.Input.Editor;
/** /**
* Object to GameLib.D3.API.Input.Editor * Object to R3.D3.API.Input.Editor
* @param objectComponent * @param objectComponent
* @returns {GameLib.D3.API.Input.Editor} * @returns {R3.D3.API.Input.Editor}
* @constructor * @constructor
*/ */
GameLib.D3.API.Input.Editor.FromObject = function(objectComponent) { R3.D3.API.Input.Editor.FromObject = function(objectComponent) {
return new GameLib.D3.API.Input.Editor( return new R3.D3.API.Input.Editor(
objectComponent.id, objectComponent.id,
objectComponent.name, objectComponent.name,
objectComponent.domElement, objectComponent.domElement,

View File

@ -0,0 +1,46 @@
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param domElementId
* @param camera R3.D3.Camera
* @constructor
*/
R3.D3.API.Input.Fly = function (
id,
name,
domElementId,
camera
) {
R3.Component.call(
this,
R3.Component.COMPONENT_FLY_INPUT,
{
'camera' : R3.D3.Camera
}
);
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (R3.Utils.UndefinedOrNull(domElementId)) {
domElementId = "divCanvas";
}
this.domElementId = domElementId;
if (R3.Utils.UndefinedOrNull(camera)) {
camera = null;
}
this.camera = camera;
};
R3.D3.API.Input.Fly.prototype = Object.create(R3.Component.prototype);
R3.D3.API.Input.Fly.prototype.constructor = R3.D3.API.Input.Fly;

85
bak/r3-d3-api-look-at.js Normal file
View File

@ -0,0 +1,85 @@
/**
* Looks from currentPosition to targetPosition (default up is 0,1,0)
* @param id
* @param name
* @param currentComponent R3.Component
* @param targetComponent R3.Component
* @param targetPositionOffset R3.API.Vector3
* @param rotationSpeed Number
* @param parentEntity
* @constructor
*/
R3.D3.API.LookAt = function (
id,
name,
currentComponent,
targetComponent,
targetPositionOffset,
rotationSpeed,
parentEntity
) {
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if(R3.Utils.UndefinedOrNull(currentComponent)) {
currentComponent = null;
}
this.currentComponent = currentComponent;
if(R3.Utils.UndefinedOrNull(targetComponent)) {
targetComponent = null;
}
this.targetComponent = targetComponent;
if(R3.Utils.UndefinedOrNull(targetPositionOffset)) {
targetPositionOffset = new R3.API.Vector3(0, 0, 0);
}
this.targetPositionOffset = targetPositionOffset;
if (R3.Utils.UndefinedOrNull(rotationSpeed)) {
rotationSpeed = 22.0;
}
this.rotationSpeed = rotationSpeed;
this.lookAtMatrix = new R3.API.Matrix4();
this.up = new R3.API.Vector3(0, 1, 0);
this.currentRotation = new R3.API.Quaternion();
this.targetPosition = new R3.API.Vector3();
if(R3.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
R3.D3.API.LookAt.prototype = Object.create(R3.Component.prototype);
R3.D3.API.LookAt.prototype.constructor = R3.D3.API.LookAt;
/**
* Object to R3.D3.API.LookAt
* @param objectComponent
* @returns {R3.D3.API.LookAt}
* @constructor
*/
R3.D3.API.LookAt.FromObject = function(objectComponent) {
return new R3.D3.API.LookAt(
objectComponent.id,
objectComponent.name,
objectComponent.currentComponent,
objectComponent.targetComponent,
R3.API.Vector3.FromObject(objectComponent.targetPositionOffset),
objectComponent.rotationSpeed,
objectComponent.parentEntity
);
};

View File

@ -1,44 +1,44 @@
/** /**
* GameLib.D3.API.Mesh.Box * R3.D3.API.Mesh.Box
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param width * @param width
* @param height * @param height
* @param depth * @param depth
*/ */
GameLib.D3.API.Mesh.Box = function( R3.D3.API.Mesh.Box = function(
apiMesh, apiMesh,
width, width,
height, height,
depth depth
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_BOX meshType : R3.D3.API.Mesh.MESH_TYPE_BOX
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_BOX; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_BOX;
} }
if (GameLib.Utils.UndefinedOrNull(width)) { if (R3.Utils.UndefinedOrNull(width)) {
width = 1; width = 1;
} }
this.width = width; this.width = width;
if (GameLib.Utils.UndefinedOrNull(height)) { if (R3.Utils.UndefinedOrNull(height)) {
height = 1; height = 1;
} }
this.height = height; this.height = height;
if (GameLib.Utils.UndefinedOrNull(depth)) { if (R3.Utils.UndefinedOrNull(depth)) {
depth = 1; depth = 1;
} }
this.depth = depth; this.depth = depth;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -68,5 +68,5 @@ GameLib.D3.API.Mesh.Box = function(
); );
}; };
GameLib.D3.API.Mesh.Box.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Box.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Box.prototype.constructor = GameLib.D3.API.Mesh.Box; R3.D3.API.Mesh.Box.prototype.constructor = R3.D3.API.Mesh.Box;

View File

@ -1,30 +1,30 @@
/** /**
* GameLib.D3.API.Mesh.Curve * R3.D3.API.Mesh.Curve
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param pointSize * @param pointSize
*/ */
GameLib.D3.API.Mesh.Curve = function( R3.D3.API.Mesh.Curve = function(
apiMesh, apiMesh,
pointSize pointSize
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CURVE meshType : R3.D3.API.Mesh.MESH_TYPE_CURVE
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_CURVE; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_CURVE;
} }
if (GameLib.Utils.UndefinedOrNull(pointSize)) { if (R3.Utils.UndefinedOrNull(pointSize)) {
pointSize = 1; pointSize = 1;
} }
this.pointSize = pointSize; this.pointSize = pointSize;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -54,5 +54,5 @@ GameLib.D3.API.Mesh.Curve = function(
); );
}; };
GameLib.D3.API.Mesh.Curve.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Curve.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Curve.prototype.constructor = GameLib.D3.API.Mesh.Curve; R3.D3.API.Mesh.Curve.prototype.constructor = R3.D3.API.Mesh.Curve;

View File

@ -1,5 +1,5 @@
/** /**
* GameLib.D3.API.Mesh.Cylinder * R3.D3.API.Mesh.Cylinder
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param radiusTop * @param radiusTop
@ -11,7 +11,7 @@
* @param thetaStart * @param thetaStart
* @param thetaLength * @param thetaLength
*/ */
GameLib.D3.API.Mesh.Cylinder = function( R3.D3.API.Mesh.Cylinder = function(
apiMesh, apiMesh,
radiusTop, radiusTop,
radiusBottom, radiusBottom,
@ -22,57 +22,57 @@ GameLib.D3.API.Mesh.Cylinder = function(
thetaStart, thetaStart,
thetaLength thetaLength
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER meshType : R3.D3.API.Mesh.MESH_TYPE_CYLINDER
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_CYLINDER;
} }
if (GameLib.Utils.UndefinedOrNull(radiusTop)) { if (R3.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1; radiusTop = 1;
} }
this.radiusTop = radiusTop; this.radiusTop = radiusTop;
if (GameLib.Utils.UndefinedOrNull(radiusBottom)) { if (R3.Utils.UndefinedOrNull(radiusBottom)) {
radiusBottom = 1; radiusBottom = 1;
} }
this.radiusBottom = radiusBottom; this.radiusBottom = radiusBottom;
if (GameLib.Utils.UndefinedOrNull(height)) { if (R3.Utils.UndefinedOrNull(height)) {
height = 5; height = 5;
} }
this.height = height; this.height = height;
if (GameLib.Utils.UndefinedOrNull(radiusSegments)) { if (R3.Utils.UndefinedOrNull(radiusSegments)) {
radiusSegments = 10; radiusSegments = 10;
} }
this.radiusSegments = radiusSegments; this.radiusSegments = radiusSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) { if (R3.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 10; heightSegments = 10;
} }
this.heightSegments = heightSegments; this.heightSegments = heightSegments;
if (GameLib.Utils.UndefinedOrNull(openEnded)) { if (R3.Utils.UndefinedOrNull(openEnded)) {
openEnded = false; openEnded = false;
} }
this.openEnded = openEnded; this.openEnded = openEnded;
if (GameLib.Utils.UndefinedOrNull(thetaStart)) { if (R3.Utils.UndefinedOrNull(thetaStart)) {
thetaStart = 0; thetaStart = 0;
} }
this.thetaStart = thetaStart; this.thetaStart = thetaStart;
if (GameLib.Utils.UndefinedOrNull(thetaLength)) { if (R3.Utils.UndefinedOrNull(thetaLength)) {
thetaLength = Math.PI * 2; thetaLength = Math.PI * 2;
} }
this.thetaLength = thetaLength; this.thetaLength = thetaLength;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -102,5 +102,5 @@ GameLib.D3.API.Mesh.Cylinder = function(
); );
}; };
GameLib.D3.API.Mesh.Cylinder.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Cylinder.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Cylinder.prototype.constructor = GameLib.D3.API.Mesh.Cylinder; R3.D3.API.Mesh.Cylinder.prototype.constructor = R3.D3.API.Mesh.Cylinder;

View File

@ -1,30 +1,30 @@
/** /**
* GameLib.D3.API.Mesh.Line * R3.D3.API.Mesh.Line
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param lineWidth * @param lineWidth
*/ */
GameLib.D3.API.Mesh.Line = function( R3.D3.API.Mesh.Line = function(
apiMesh, apiMesh,
lineWidth lineWidth
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_LINE meshType : R3.D3.API.Mesh.MESH_TYPE_LINE
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_LINE; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_LINE;
} }
if (GameLib.Utils.UndefinedOrNull(lineWidth)) { if (R3.Utils.UndefinedOrNull(lineWidth)) {
lineWidth = 1; lineWidth = 1;
} }
this.lineWidth = lineWidth; this.lineWidth = lineWidth;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -54,5 +54,5 @@ GameLib.D3.API.Mesh.Line = function(
); );
}; };
GameLib.D3.API.Mesh.Line.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Line.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Line.prototype.constructor = GameLib.D3.API.Mesh.Line; R3.D3.API.Mesh.Line.prototype.constructor = R3.D3.API.Mesh.Line;

View File

@ -1,5 +1,5 @@
/** /**
* GameLib.D3.API.Mesh.Plane * R3.D3.API.Mesh.Plane
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param width * @param width
@ -14,7 +14,7 @@
* @param dotMapWeight * @param dotMapWeight
* @param dotObject * @param dotObject
*/ */
GameLib.D3.API.Mesh.Plane = function( R3.D3.API.Mesh.Plane = function(
apiMesh, apiMesh,
width, width,
height, height,
@ -29,72 +29,72 @@ GameLib.D3.API.Mesh.Plane = function(
dotObject dotObject
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_PLANE meshType : R3.D3.API.Mesh.MESH_TYPE_PLANE
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_PLANE; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_PLANE;
} }
if (GameLib.Utils.UndefinedOrNull(width)) { if (R3.Utils.UndefinedOrNull(width)) {
width = 1; width = 1;
} }
this.width = width; this.width = width;
if (GameLib.Utils.UndefinedOrNull(height)) { if (R3.Utils.UndefinedOrNull(height)) {
height = 1; height = 1;
} }
this.height = height; this.height = height;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) { if (R3.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 5; widthSegments = 5;
} }
this.widthSegments = widthSegments; this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) { if (R3.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 5; heightSegments = 5;
} }
this.heightSegments = heightSegments; this.heightSegments = heightSegments;
if (GameLib.Utils.UndefinedOrNull(heightMapScale)) { if (R3.Utils.UndefinedOrNull(heightMapScale)) {
heightMapScale = 1; heightMapScale = 1;
} }
this.heightMapScale = heightMapScale; this.heightMapScale = heightMapScale;
if (GameLib.Utils.UndefinedOrNull(isHeightMap)) { if (R3.Utils.UndefinedOrNull(isHeightMap)) {
isHeightMap = false; isHeightMap = false;
} }
this.isHeightMap = isHeightMap; this.isHeightMap = isHeightMap;
if (GameLib.Utils.UndefinedOrNull(isDotMap)) { if (R3.Utils.UndefinedOrNull(isDotMap)) {
isDotMap = false; isDotMap = false;
} }
this.isDotMap = isDotMap; this.isDotMap = isDotMap;
if (GameLib.Utils.UndefinedOrNull(dotMapScale)) { if (R3.Utils.UndefinedOrNull(dotMapScale)) {
dotMapScale = new GameLib.API.Vector3(0.01, 0.01, 0.01); dotMapScale = new R3.API.Vector3(0.01, 0.01, 0.01);
} }
this.dotMapScale = dotMapScale; this.dotMapScale = dotMapScale;
if (GameLib.Utils.UndefinedOrNull(dotMapOffset)) { if (R3.Utils.UndefinedOrNull(dotMapOffset)) {
dotMapOffset = new GameLib.API.Vector3(1, -1, 5); dotMapOffset = new R3.API.Vector3(1, -1, 5);
} }
this.dotMapOffset = dotMapOffset; this.dotMapOffset = dotMapOffset;
if (GameLib.Utils.UndefinedOrNull(dotMapWeight)) { if (R3.Utils.UndefinedOrNull(dotMapWeight)) {
dotMapWeight = new GameLib.API.Vector3(1, 1, 1); dotMapWeight = new R3.API.Vector3(1, 1, 1);
} }
this.dotMapWeight = dotMapWeight; this.dotMapWeight = dotMapWeight;
if (GameLib.Utils.UndefinedOrNull(dotObject)) { if (R3.Utils.UndefinedOrNull(dotObject)) {
dotObject = null; dotObject = null;
} }
this.dotObject = dotObject; this.dotObject = dotObject;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -124,5 +124,5 @@ GameLib.D3.API.Mesh.Plane = function(
); );
}; };
GameLib.D3.API.Mesh.Plane.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Plane.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Plane.prototype.constructor = GameLib.D3.API.Mesh.Plane; R3.D3.API.Mesh.Plane.prototype.constructor = R3.D3.API.Mesh.Plane;

View File

@ -1,44 +1,44 @@
/** /**
* GameLib.D3.API.Mesh.Sphere * R3.D3.API.Mesh.Sphere
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param radius * @param radius
* @param widthSegments * @param widthSegments
* @param heightSegments * @param heightSegments
*/ */
GameLib.D3.API.Mesh.Sphere = function( R3.D3.API.Mesh.Sphere = function(
apiMesh, apiMesh,
radius, radius,
widthSegments, widthSegments,
heightSegments heightSegments
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_SPHERE meshType : R3.D3.API.Mesh.MESH_TYPE_SPHERE
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_SPHERE; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_SPHERE;
} }
if (GameLib.Utils.UndefinedOrNull(radius)) { if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1; radius = 1;
} }
this.radius = radius; this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) { if (R3.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 5; widthSegments = 5;
} }
this.widthSegments = widthSegments; this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) { if (R3.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 5; heightSegments = 5;
} }
this.heightSegments = heightSegments; this.heightSegments = heightSegments;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -68,5 +68,5 @@ GameLib.D3.API.Mesh.Sphere = function(
); );
}; };
GameLib.D3.API.Mesh.Sphere.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Sphere.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Sphere.prototype.constructor = GameLib.D3.API.Mesh.Sphere; R3.D3.API.Mesh.Sphere.prototype.constructor = R3.D3.API.Mesh.Sphere;

View File

@ -1,5 +1,5 @@
/** /**
* GameLib.D3.API.Mesh.Text * R3.D3.API.Mesh.Text
* @constructor * @constructor
* @param apiMesh * @param apiMesh
* @param text * @param text
@ -12,7 +12,7 @@
* @param bevelSize * @param bevelSize
* @param bevelSegments * @param bevelSegments
*/ */
GameLib.D3.API.Mesh.Text = function( R3.D3.API.Mesh.Text = function(
apiMesh, apiMesh,
text, text,
font, font,
@ -25,62 +25,62 @@ GameLib.D3.API.Mesh.Text = function(
bevelSegments bevelSegments
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (R3.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT meshType : R3.D3.API.Mesh.MESH_TYPE_TEXT
}; };
} }
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) { if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_TEXT; apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_TEXT;
} }
if (GameLib.Utils.UndefinedOrNull(text)) { if (R3.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310'; text = '-=<yb4f310';
} }
this.text = text; this.text = text;
if (GameLib.Utils.UndefinedOrNull(font)) { if (R3.Utils.UndefinedOrNull(font)) {
font = new GameLib.D3.API.Font() font = new R3.D3.API.Font()
} }
this.font = font; this.font = font;
if (GameLib.Utils.UndefinedOrNull(size)) { if (R3.Utils.UndefinedOrNull(size)) {
size = 100; size = 100;
} }
this.size = size; this.size = size;
if (GameLib.Utils.UndefinedOrNull(height)) { if (R3.Utils.UndefinedOrNull(height)) {
height = 50; height = 50;
} }
this.height = height; this.height = height;
if (GameLib.Utils.UndefinedOrNull(curveSegments)) { if (R3.Utils.UndefinedOrNull(curveSegments)) {
curveSegments = 12; curveSegments = 12;
} }
this.curveSegments = curveSegments; this.curveSegments = curveSegments;
if (GameLib.Utils.UndefinedOrNull(bevelEnabled)) { if (R3.Utils.UndefinedOrNull(bevelEnabled)) {
bevelEnabled = false; bevelEnabled = false;
} }
this.bevelEnabled = bevelEnabled; this.bevelEnabled = bevelEnabled;
if (GameLib.Utils.UndefinedOrNull(bevelThickness)) { if (R3.Utils.UndefinedOrNull(bevelThickness)) {
bevelThickness = 10; bevelThickness = 10;
} }
this.bevelThickness = bevelThickness; this.bevelThickness = bevelThickness;
if (GameLib.Utils.UndefinedOrNull(bevelSize)) { if (R3.Utils.UndefinedOrNull(bevelSize)) {
bevelSize = 8; bevelSize = 8;
} }
this.bevelSize = bevelSize; this.bevelSize = bevelSize;
if (GameLib.Utils.UndefinedOrNull(bevelSegments)) { if (R3.Utils.UndefinedOrNull(bevelSegments)) {
bevelSegments = 3; bevelSegments = 3;
} }
this.bevelSegments = bevelSegments; this.bevelSegments = bevelSegments;
GameLib.D3.API.Mesh.call( R3.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.name, apiMesh.name,
@ -110,5 +110,5 @@ GameLib.D3.API.Mesh.Text = function(
); );
}; };
GameLib.D3.API.Mesh.Text.prototype = Object.create(GameLib.D3.API.Mesh.prototype); R3.D3.API.Mesh.Text.prototype = Object.create(R3.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Text.prototype.constructor = GameLib.D3.API.Mesh.Text; R3.D3.API.Mesh.Text.prototype.constructor = R3.D3.API.Mesh.Text;

View File

@ -0,0 +1,203 @@
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param spline R3.D3.API.Spline
* @param mesh R3.D3.API.Mesh
* @param raytraceMesh R3.D3.API.Mesh
* @param accelleration Number
* @param maxSpeed Number
* @param baseOffset R3.API.Vector
* @param maxOffset R3.API.Vector
* @param steeringSpeed Number
* @param targetOffset R3.API.Vector3
* @param currentOffset R3.API.Vector3
* @param currentPathValue Number
* @param currentSpeed Number
* @param direction Number
* @param raycaster R3.D3.Raycaster
* @param currentPosition R3.API.Vector3
* @param futurePosition R3.API.Vector3
* @param up R3.API.Vector3
* @param rotationMatrix R3.API.Matrix4
* @param rotationVector R3.API.Quaternion
* @param parentEntity
* @constructor
*/
R3.D3.API.PathFollowing = function (
id,
name,
spline,
mesh,
raytraceMesh,
accelleration,
maxSpeed,
baseOffset,
maxOffset,
steeringSpeed,
targetOffset,
currentOffset,
currentPathValue,
currentSpeed,
direction,
raycaster,
currentPosition,
futurePosition,
up,
rotationMatrix,
rotationVector,
parentEntity
) {
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (R3.Utils.UndefinedOrNull(spline)) {
spline = null;
}
this.spline = spline;
if (R3.Utils.UndefinedOrNull(mesh)) {
mesh = null;
}
this.mesh = mesh;
if (R3.Utils.UndefinedOrNull(raytraceMesh)) {
raytraceMesh = null;
}
this.raytraceMesh = raytraceMesh;
if (R3.Utils.UndefinedOrNull(maxSpeed)) {
maxSpeed = 0.03;
}
this.maxSpeed = maxSpeed;
if (R3.Utils.UndefinedOrNull(accelleration)) {
accelleration = 0.1;
}
this.accelleration = accelleration;
if (R3.Utils.UndefinedOrNull(baseOffset)) {
baseOffset = new R3.API.Vector3();
}
this.baseOffset = baseOffset;
if (R3.Utils.UndefinedOrNull(maxOffset)) {
maxOffset = new R3.API.Vector3();
}
this.maxOffset = maxOffset;
if (R3.Utils.UndefinedOrNull(steeringSpeed)) {
steeringSpeed = 1.0;
}
this.steeringSpeed = steeringSpeed;
if (R3.Utils.UndefinedOrNull(targetOffset)) {
targetOffset = new R3.API.Vector3();
}
this.targetOffset = targetOffset;
if (R3.Utils.UndefinedOrNull(currentOffset)) {
currentOffset = new R3.API.Vector3();
}
this.currentOffset = currentOffset;
if (R3.Utils.UndefinedOrNull(currentPathValue)) {
currentPathValue = 0;
}
this.currentPathValue = currentPathValue;
if (R3.Utils.UndefinedOrNull(currentSpeed)) {
currentSpeed = 0;
}
this.currentSpeed = currentSpeed;
if (R3.Utils.UndefinedOrNull(direction)) {
direction = 1;
}
this.direction = direction;
if (R3.Utils.UndefinedOrNull(raycaster)) {
raycaster = new R3.D3.API.Raycaster();
}
this.raycaster = raycaster;
if (R3.Utils.UndefinedOrNull(currentPosition)) {
currentPosition = new R3.API.Vector3();
}
this.currentPosition = currentPosition;
if (R3.Utils.UndefinedOrNull(futurePosition)) {
futurePosition = new R3.API.Vector3();
}
this.futurePosition = futurePosition;
if(R3.Utils.UndefinedOrNull(up)) {
up = new R3.API.Vector3(0, 1, 0);
}
this.up = up;
if (R3.Utils.UndefinedOrNull(rotationMatrix)) {
rotationMatrix = new R3.API.Matrix4();
}
this.rotationMatrix = rotationMatrix;
if (R3.Utils.UndefinedOrNull(rotationVector)) {
rotationVector = new R3.API.Quaternion();
}
this.rotationVector = rotationVector;
if (R3.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
R3.D3.API.PathFollowing.prototype = Object.create(R3.Component.prototype);
R3.D3.API.PathFollowing.prototype.constructor = R3.D3.API.PathFollowing;
/**
* Returns an API path following component from an Object path following component
* @param objectComponent
* @constructor
*/
R3.D3.API.PathFollowing.FromObject = function(objectComponent) {
var apiRaycaster = null;
if (objectComponent.raycaster) {
apiRaycaster = R3.D3.API.Raycaster.FromObject(objectComponent.raycaster);
}
return new R3.D3.API.PathFollowing(
objectComponent.id,
objectComponent.name,
objectComponent.spline,
objectComponent.mesh,
objectComponent.raytraceMesh,
objectComponent.accelleration,
objectComponent.maxSpeed,
R3.API.Vector3.FromObject(objectComponent.baseOffset),
R3.API.Vector3.FromObject(objectComponent.maxOffset),
objectComponent.steeringSpeed,
R3.API.Vector3.FromObject(objectComponent.targetOffset),
R3.API.Vector3.FromObject(objectComponent.currentOffset),
objectComponent.currentPathValue,
objectComponent.currentSpeed,
objectComponent.direction,
apiRaycaster,
R3.API.Vector3.FromObject(objectComponent.currentPosition),
R3.API.Vector3.FromObject(objectComponent.futurePosition),
R3.API.Vector3.FromObject(objectComponent.up),
R3.API.Matrix4.FromObject(objectComponent.rotationMatrix),
R3.API.Quaternion.FromObject(objectComponent.rotationVector),
objectComponent.parentEntity
);
};

View File

@ -7,36 +7,36 @@
* @param lastUpdate * @param lastUpdate
* @constructor * @constructor
*/ */
GameLib.D3.API.SelectedObject = function ( R3.D3.API.SelectedObject = function (
object, object,
helper, helper,
lastUpdate lastUpdate
) { ) {
if (GameLib.Utils.UndefinedOrNull(object)) { if (R3.Utils.UndefinedOrNull(object)) {
console.warn('Cannot select no object'); console.warn('Cannot select no object');
throw new Error('Cannot select no object'); throw new Error('Cannot select no object');
} }
this.object = object; this.object = object;
if (GameLib.Utils.UndefinedOrNull(helper)) { if (R3.Utils.UndefinedOrNull(helper)) {
helper = null; helper = null;
} }
this.helper = helper; this.helper = helper;
if (GameLib.Utils.UndefinedOrNull(lastUpdate)) { if (R3.Utils.UndefinedOrNull(lastUpdate)) {
lastUpdate = Date.now(); lastUpdate = Date.now();
} }
this.lastUpdate = lastUpdate; this.lastUpdate = lastUpdate;
}; };
/** /**
* Object to GameLib.D3.API.SelectedObject * Object to R3.D3.API.SelectedObject
* @param objectComponent * @param objectComponent
* @returns {GameLib.D3.API.SelectedObject} * @returns {R3.D3.API.SelectedObject}
* @constructor * @constructor
*/ */
GameLib.D3.API.SelectedObject.FromObjectSelectedObject = function(objectComponent) { R3.D3.API.SelectedObject.FromObjectSelectedObject = function(objectComponent) {
return new GameLib.D3.API.SelectedObject( return new R3.D3.API.SelectedObject(
objectComponent.id, objectComponent.id,
objectComponent.name, objectComponent.name,
objectComponent.object, objectComponent.object,

View File

@ -1,13 +1,13 @@
/** /**
* Creates a Editor object * Creates a Editor object
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param apiEditor GameLib.D3.API.Editor * @param apiEditor R3.D3.API.Editor
* @param onSelectionChanged * @param onSelectionChanged
* @param onSelectObject * @param onSelectObject
* @param onDeSelectObject * @param onDeSelectObject
* @constructor * @constructor
*/ */
GameLib.D3.Editor = function( R3.D3.Editor = function(
graphics, graphics,
apiEditor, apiEditor,
onSelectionChanged, onSelectionChanged,
@ -18,15 +18,15 @@ GameLib.D3.Editor = function(
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiEditor)) { if (R3.Utils.UndefinedOrNull(apiEditor)) {
apiEditor = {}; apiEditor = {};
} }
if (apiEditor instanceof GameLib.D3.Editor) { if (apiEditor instanceof R3.D3.Editor) {
return apiEditor; return apiEditor;
} }
GameLib.D3.API.Editor.call( R3.D3.API.Editor.call(
this, this,
apiEditor.id, apiEditor.id,
apiEditor.name, apiEditor.name,
@ -47,8 +47,8 @@ GameLib.D3.Editor = function(
apiEditor.parentEntity apiEditor.parentEntity
); );
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) { if (this.imageFactory instanceof R3.D3.API.ImageFactory) {
this.imageFactory = new GameLib.D3.ImageFactory( this.imageFactory = new R3.D3.ImageFactory(
this.graphics, this.graphics,
this.imageFactory this.imageFactory
); );
@ -57,8 +57,8 @@ GameLib.D3.Editor = function(
if (this.games) { if (this.games) {
this.games = this.games.map( this.games = this.games.map(
function (apiGame) { function (apiGame) {
if (apiGame instanceof GameLib.D3.API.Game) { if (apiGame instanceof R3.D3.API.Game) {
return new GameLib.D3.Game( return new R3.D3.Game(
this.graphics, this.graphics,
apiGame, apiGame,
this.imageFactory this.imageFactory
@ -74,8 +74,8 @@ GameLib.D3.Editor = function(
this.scenes = this.scenes.map( this.scenes = this.scenes.map(
function (apiScene) { function (apiScene) {
if (apiScene instanceof GameLib.D3.API.Scene) { if (apiScene instanceof R3.D3.API.Scene) {
return new GameLib.D3.Scene( return new R3.D3.Scene(
this.graphics, this.graphics,
apiScene, apiScene,
this.imageFactory, this.imageFactory,
@ -90,8 +90,8 @@ GameLib.D3.Editor = function(
this.cameras = this.cameras.map( this.cameras = this.cameras.map(
function (apiCamera) { function (apiCamera) {
if (apiCamera instanceof GameLib.D3.API.Camera) { if (apiCamera instanceof R3.D3.API.Camera) {
return new GameLib.D3.Camera( return new R3.D3.Camera(
this.graphics, this.graphics,
apiCamera apiCamera
) )
@ -104,8 +104,8 @@ GameLib.D3.Editor = function(
this.composers = this.composers.map( this.composers = this.composers.map(
function (apiComposer) { function (apiComposer) {
if (apiComposer instanceof GameLib.D3.API.Composer) { if (apiComposer instanceof R3.D3.API.Composer) {
return new GameLib.D3.Composer( return new R3.D3.Composer(
this.graphics, this.graphics,
apiComposer apiComposer
) )
@ -118,8 +118,8 @@ GameLib.D3.Editor = function(
this.viewports = this.viewports.map( this.viewports = this.viewports.map(
function (apiViewport) { function (apiViewport) {
if (apiViewport instanceof GameLib.D3.API.Viewport) { if (apiViewport instanceof R3.D3.API.Viewport) {
return new GameLib.D3.Viewport( return new R3.D3.Viewport(
this.graphics, this.graphics,
apiViewport apiViewport
) )
@ -132,8 +132,8 @@ GameLib.D3.Editor = function(
this.renderers = this.renderers.map( this.renderers = this.renderers.map(
function (apiRenderer) { function (apiRenderer) {
if (apiRenderer instanceof GameLib.D3.API.Renderer) { if (apiRenderer instanceof R3.D3.API.Renderer) {
return new GameLib.D3.Renderer( return new R3.D3.Renderer(
this.graphics, this.graphics,
apiRenderer apiRenderer
) )
@ -146,8 +146,8 @@ GameLib.D3.Editor = function(
this.renderTargets = this.renderTargets.map( this.renderTargets = this.renderTargets.map(
function (apiRenderTarget) { function (apiRenderTarget) {
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) { if (apiRenderTarget instanceof R3.D3.API.RenderTarget) {
return new GameLib.D3.RenderTarget( return new R3.D3.RenderTarget(
this.graphics, this.graphics,
apiRenderTarget apiRenderTarget
) )
@ -160,8 +160,8 @@ GameLib.D3.Editor = function(
this.systems = this.systems.map( this.systems = this.systems.map(
function (apiSystem) { function (apiSystem) {
if (apiSystem instanceof GameLib.API.System) { if (apiSystem instanceof R3.API.System) {
return new GameLib.System( return new R3.System(
this.graphics, this.graphics,
apiSystem apiSystem
) )
@ -173,8 +173,8 @@ GameLib.D3.Editor = function(
); );
if (this.entityManager) { if (this.entityManager) {
if (this.entityManager instanceof GameLib.API.EntityManager) { if (this.entityManager instanceof R3.API.EntityManager) {
this.entityManager = new GameLib.EntityManager( this.entityManager = new R3.EntityManager(
this.graphics, this.graphics,
this.entityManager this.entityManager
); );
@ -184,17 +184,17 @@ GameLib.D3.Editor = function(
} }
} }
if (GameLib.Utils.UndefinedOrNull(onSelectionChanged)) { if (R3.Utils.UndefinedOrNull(onSelectionChanged)) {
onSelectionChanged = null; onSelectionChanged = null;
} }
this.onSelectionChanged = onSelectionChanged; this.onSelectionChanged = onSelectionChanged;
if (GameLib.Utils.UndefinedOrNull(onSelectObject)) { if (R3.Utils.UndefinedOrNull(onSelectObject)) {
onSelectObject = null; onSelectObject = null;
} }
this.onSelectObject = onSelectObject; this.onSelectObject = onSelectObject;
if (GameLib.Utils.UndefinedOrNull(onDeSelectObject)) { if (R3.Utils.UndefinedOrNull(onDeSelectObject)) {
onDeSelectObject = null; onDeSelectObject = null;
} }
this.onDeSelectObject = onDeSelectObject; this.onDeSelectObject = onDeSelectObject;
@ -211,14 +211,14 @@ GameLib.D3.Editor = function(
this.instance = this.createInstance(); this.instance = this.createInstance();
}; };
GameLib.D3.Editor.prototype = Object.create(GameLib.D3.API.Editor.prototype); R3.D3.Editor.prototype = Object.create(R3.D3.API.Editor.prototype);
GameLib.D3.Editor.prototype.constructor = GameLib.D3.Editor; R3.D3.Editor.prototype.constructor = R3.D3.Editor;
/** /**
* Creates a camera instance of 'graphics' type (only THREE for now) * Creates a camera instance of 'graphics' type (only THREE for now)
* @returns {THREE.Editor} * @returns {THREE.Editor}
*/ */
GameLib.D3.Editor.prototype.createInstance = function(update) { R3.D3.Editor.prototype.createInstance = function(update) {
var instance = null; var instance = null;
@ -232,15 +232,15 @@ GameLib.D3.Editor.prototype.createInstance = function(update) {
/** /**
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.D3.Editor.prototype.updateInstance = function() { R3.D3.Editor.prototype.updateInstance = function() {
this.instance = this.createInstance(true); this.instance = this.createInstance(true);
}; };
/** /**
* Converts a GameLib.D3.Editor to a new GameLib.D3.API.Editor * Converts a R3.D3.Editor to a new R3.D3.API.Editor
* @returns {GameLib.D3.API.Editor} * @returns {R3.D3.API.Editor}
*/ */
GameLib.D3.Editor.prototype.toApiObject = function() { R3.D3.Editor.prototype.toApiObject = function() {
var apiImageFactory = null; var apiImageFactory = null;
var apiGames = []; var apiGames = [];
@ -253,14 +253,14 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
var apiSystems = []; var apiSystems = [];
var apiEntityManager = null; var apiEntityManager = null;
if (this.imageFactory instanceof GameLib.D3.ImageFactory) { if (this.imageFactory instanceof R3.D3.ImageFactory) {
apiImageFactory = this.imageFactory.toApiObject(); apiImageFactory = this.imageFactory.toApiObject();
} }
if (this.games) { if (this.games) {
apiGames = this.games.map( apiGames = this.games.map(
function(game) { function(game) {
if (game instanceof GameLib.D3.Game) { if (game instanceof R3.D3.Game) {
return game.toApiObject(); return game.toApiObject();
} else { } else {
console.warn('game not an instance of Game'); console.warn('game not an instance of Game');
@ -273,7 +273,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.scenes) { if (this.scenes) {
apiScenes = this.scenes.map( apiScenes = this.scenes.map(
function(scene) { function(scene) {
if (scene instanceof GameLib.D3.Scene) { if (scene instanceof R3.D3.Scene) {
return scene.toApiObject(); return scene.toApiObject();
} else { } else {
console.warn('scene not an instance of Scene'); console.warn('scene not an instance of Scene');
@ -286,7 +286,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.cameras) { if (this.cameras) {
apiCameras = this.cameras.map( apiCameras = this.cameras.map(
function(camera) { function(camera) {
if (camera instanceof GameLib.D3.Camera) { if (camera instanceof R3.D3.Camera) {
return camera.toApiObject(); return camera.toApiObject();
} else { } else {
console.warn('camera not an instance of Camera'); console.warn('camera not an instance of Camera');
@ -299,7 +299,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.composers) { if (this.composers) {
apiComposers = this.composers.map( apiComposers = this.composers.map(
function(composer) { function(composer) {
if (composer instanceof GameLib.D3.Composer) { if (composer instanceof R3.D3.Composer) {
return composer.toApiObject(); return composer.toApiObject();
} else { } else {
console.warn('composer not an instance of Composer'); console.warn('composer not an instance of Composer');
@ -312,7 +312,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.viewports) { if (this.viewports) {
apiViewports = this.viewports.map( apiViewports = this.viewports.map(
function(viewport) { function(viewport) {
if (viewport instanceof GameLib.D3.Viewport) { if (viewport instanceof R3.D3.Viewport) {
return viewport.toApiObject(); return viewport.toApiObject();
} else { } else {
console.warn('viewport not an instance of Viewport'); console.warn('viewport not an instance of Viewport');
@ -325,7 +325,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.renderers) { if (this.renderers) {
apiRenderers = this.renderers.map( apiRenderers = this.renderers.map(
function(renderer) { function(renderer) {
if (renderer instanceof GameLib.D3.Renderer) { if (renderer instanceof R3.D3.Renderer) {
return renderer.toApiObject(); return renderer.toApiObject();
} else { } else {
console.warn('renderer not an instance of Renderer'); console.warn('renderer not an instance of Renderer');
@ -338,7 +338,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.renderTargets) { if (this.renderTargets) {
apiRenderTargets = this.renderTargets.map( apiRenderTargets = this.renderTargets.map(
function(renderTarget) { function(renderTarget) {
if (renderTarget instanceof GameLib.D3.RenderTarget) { if (renderTarget instanceof R3.D3.RenderTarget) {
return renderTarget.toApiObject(); return renderTarget.toApiObject();
} else { } else {
console.warn('renderTarget not an instance of RenderTarget'); console.warn('renderTarget not an instance of RenderTarget');
@ -351,7 +351,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
if (this.systems) { if (this.systems) {
apiSystems = this.systems.map( apiSystems = this.systems.map(
function(system) { function(system) {
if (system instanceof GameLib.System) { if (system instanceof R3.System) {
return system.toApiObject(); return system.toApiObject();
} else { } else {
console.warn('system not an instance of System'); console.warn('system not an instance of System');
@ -362,7 +362,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
} }
if (this.entityManager) { if (this.entityManager) {
if (this.entityManager instanceof GameLib.EntityManager) { if (this.entityManager instanceof R3.EntityManager) {
apiEntityManager = this.entityManager.toApiObject(); apiEntityManager = this.entityManager.toApiObject();
} else { } else {
console.warn('entityManager not an instance of EntityManager'); console.warn('entityManager not an instance of EntityManager');
@ -370,7 +370,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
} }
} }
return new GameLib.D3.API.Editor( return new R3.D3.API.Editor(
this.id, this.id,
this.name, this.name,
this.baseUrl, this.baseUrl,
@ -387,23 +387,23 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
apiEntityManager, apiEntityManager,
this.allSelected, this.allSelected,
this.selectedObjects, this.selectedObjects,
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
}; };
/** /**
* Converts from an Object Editor to a GameLib.D3.Editor * Converts from an Object Editor to a R3.D3.Editor
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param objectEditor Object * @param objectEditor Object
* @returns {GameLib.D3.Editor} * @returns {R3.D3.Editor}
* @constructor * @constructor
*/ */
GameLib.D3.Editor.FromObjectEditor = function(graphics, objectEditor) { R3.D3.Editor.FromObjectEditor = function(graphics, objectEditor) {
var apiEditor = GameLib.D3.API.Editor.FromObjectEditor(objectEditor); var apiEditor = R3.D3.API.Editor.FromObjectEditor(objectEditor);
return new GameLib.D3.Editor( return new R3.D3.Editor(
graphics, graphics,
apiEditor apiEditor
); );
@ -411,13 +411,13 @@ GameLib.D3.Editor.FromObjectEditor = function(graphics, objectEditor) {
}; };
/** /**
* Selects a GameLib Object * Selects a R3 Object
* @param object GameLib.* * @param object R3.*
*/ */
GameLib.D3.Editor.prototype.selectObject = function(object) { R3.D3.Editor.prototype.selectObject = function(object) {
this.selectedObjects.push( this.selectedObjects.push(
new GameLib.D3.SelectedObject( new R3.D3.SelectedObject(
this.graphics, this.graphics,
object object
) )
@ -430,10 +430,10 @@ GameLib.D3.Editor.prototype.selectObject = function(object) {
}; };
/** /**
* Selects a GameLib Object * Selects a R3 Object
* @param object GameLib.* * @param object R3.*
*/ */
GameLib.D3.Editor.prototype.deSelectObject = function(object) { R3.D3.Editor.prototype.deSelectObject = function(object) {
var results = this.selectedObjects.reduce( var results = this.selectedObjects.reduce(
function(results, selectedObject) { function(results, selectedObject) {
@ -459,7 +459,7 @@ GameLib.D3.Editor.prototype.deSelectObject = function(object) {
}; };
GameLib.D3.Editor.prototype.setSize = function(width, height) { R3.D3.Editor.prototype.setSize = function(width, height) {
this.viewports.map( this.viewports.map(
function(viewport){ function(viewport){
@ -478,16 +478,16 @@ GameLib.D3.Editor.prototype.setSize = function(width, height) {
/** /**
* Adds a scene to the Editor * Adds a scene to the Editor
* @param scene GameLib.D3.API.Scene * @param scene R3.D3.API.Scene
*/ */
GameLib.D3.Editor.prototype.addScene = function(scene) { R3.D3.Editor.prototype.addScene = function(scene) {
if (!scene instanceof GameLib.D3.Scene && if (!scene instanceof R3.D3.Scene &&
!scene instanceof GameLib.D3.API.Scene) { !scene instanceof R3.D3.API.Scene) {
throw new Error('Unhandled scene type : ' + scene); throw new Error('Unhandled scene type : ' + scene);
} }
scene = new GameLib.D3.Scene(this.graphics, scene); scene = new R3.D3.Scene(this.graphics, scene);
this.scenes.push(scene); this.scenes.push(scene);
@ -506,8 +506,8 @@ GameLib.D3.Editor.prototype.addScene = function(scene) {
*/ */
var entities = this.entityManager.query( var entities = this.entityManager.query(
[ [
GameLib.D3.Renderer, R3.D3.Renderer,
GameLib.System R3.System
] ]
); );
@ -521,11 +521,11 @@ GameLib.D3.Editor.prototype.addScene = function(scene) {
/** /**
* Now we need to notify all systems of this new components * Now we need to notify all systems of this new components
*/ */
var systems = entity.getComponents(GameLib.System); var systems = entity.getComponents(R3.System);
systems.map( systems.map(
function(system){ function(system){
system.notify('meshes', GameLib.D3.Mesh) system.notify('meshes', R3.D3.Mesh)
}.bind(this) }.bind(this)
) )

63
bak/r3-d3-engine.js Normal file
View File

@ -0,0 +1,63 @@
/**
* Engine Superset
* @param engineType
* @param instance {CANNON | Ammo | Goblin}
* @constructor
*/
R3.D3.Engine = function Engine(
engineType,
instance
) {
this.engineType = engineType;
this.instance = instance;
};
R3.D3.Engine.prototype.toApiEngine = function() {
//TODO: create API.Engine sometime
return {
engineType : this.engineType
}
};
/**
* True if CANNON physics
* @returns {boolean}
*/
R3.D3.Engine.prototype.isCannon = function() {
return (this.engineType == R3.D3.Engine.ENGINE_TYPE_CANNON)
};
/**
* Logs a warning and throws an error if not cannon
*/
R3.D3.Engine.prototype.isNotCannonThrow = function() {
if (this.engineType != R3.D3.Engine.ENGINE_TYPE_CANNON) {
console.warn('Only CANNON supported for this function');
throw new Error('Only CANNON supported for this function');
}
};
/**
* True if Ammo physics
* @returns {boolean}
*/
R3.D3.Engine.prototype.isAmmo = function() {
return (this.engineType == R3.D3.Engine.ENGINE_TYPE_AMMO)
};
/**
* True if Goblin physics
* @returns {boolean}
*/
R3.D3.Engine.prototype.isGoblin = function() {
return (this.engineType == R3.D3.Engine.ENGINE_TYPE_GOBLIN)
};
/**
* Physics R3.D3.Engine Types
* @type {number}
*/
R3.D3.Engine.ENGINE_TYPE_CANNON = 0x1;
R3.D3.Engine.ENGINE_TYPE_AMMO = 0x2;
R3.D3.Engine.ENGINE_TYPE_GOBLIN = 0x3;

View File

@ -5,7 +5,7 @@
* @param canvas * @param canvas
* @constructor * @constructor
*/ */
GameLib.D3.FlyControls = function( R3.D3.FlyControls = function(
camera, camera,
THREE, THREE,
canvas canvas

View File

@ -1,25 +1,25 @@
/** /**
* Runtime Follow Component * Runtime Follow Component
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param apiFollow * @param apiFollow
* @constructor * @constructor
*/ */
GameLib.D3.Follow = function ( R3.D3.Follow = function (
graphics, graphics,
apiFollow apiFollow
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiFollow)) { if (R3.Utils.UndefinedOrNull(apiFollow)) {
apiFollow = {}; apiFollow = {};
} }
if (apiFollow instanceof GameLib.D3.Follow) { if (apiFollow instanceof R3.D3.Follow) {
return apiFollow; return apiFollow;
} }
GameLib.D3.API.Follow.call( R3.D3.API.Follow.call(
this, this,
apiFollow.id, apiFollow.id,
apiFollow.name, apiFollow.name,
@ -31,31 +31,31 @@ GameLib.D3.Follow = function (
apiFollow.parentEntity apiFollow.parentEntity
); );
this.targetPositionOffset = new GameLib.Vector3( this.targetPositionOffset = new R3.Vector3(
this.graphics, this.graphics,
this.targetPositionOffset, this.targetPositionOffset,
this this
); );
this.target = new GameLib.Vector3( this.target = new R3.Vector3(
this.graphics, this.graphics,
this.target, this.target,
this this
); );
this.targetToParent = new GameLib.Vector3( this.targetToParent = new R3.Vector3(
this.graphics, this.graphics,
this.targetToParent, this.targetToParent,
this this
); );
this.rotatedTargetOffset = new GameLib.Vector3( this.rotatedTargetOffset = new R3.Vector3(
this.graphics, this.graphics,
this.rotatedTargetOffset, this.rotatedTargetOffset,
this this
); );
this.rotated = new GameLib.Quaternion( this.rotated = new R3.Quaternion(
this.graphics, this.graphics,
this.rotated, this.rotated,
this this
@ -65,30 +65,30 @@ GameLib.D3.Follow = function (
}; };
GameLib.D3.Follow.prototype = Object.create(GameLib.D3.API.Follow.prototype); R3.D3.Follow.prototype = Object.create(R3.D3.API.Follow.prototype);
GameLib.D3.Follow.prototype.constructor = GameLib.D3.Follow; R3.D3.Follow.prototype.constructor = R3.D3.Follow;
GameLib.D3.Follow.prototype.toApiObject = function() { R3.D3.Follow.prototype.toApiObject = function() {
var apiFollow = new GameLib.D3.API.Follow( var apiFollow = new R3.D3.API.Follow(
this.id, this.id,
this.name, this.name,
GameLib.Utils.IdOrNull(this.currentComponent), R3.Utils.IdOrNull(this.currentComponent),
GameLib.Utils.IdOrNull(this.targetComponent), R3.Utils.IdOrNull(this.targetComponent),
this.targetPositionOffset.toApiObject(), this.targetPositionOffset.toApiObject(),
this.minDistance, this.minDistance,
this.moveSpeed, this.moveSpeed,
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
return apiFollow; return apiFollow;
}; };
GameLib.D3.Follow.FromObject = function(graphics, objectComponent) { R3.D3.Follow.FromObject = function(graphics, objectComponent) {
var apiFollow = GameLib.D3.API.Follow.FromObject(objectComponent); var apiFollow = R3.D3.API.Follow.FromObject(objectComponent);
return new GameLib.D3.Follow( return new R3.D3.Follow(
graphics, graphics,
apiFollow apiFollow
); );
@ -98,7 +98,7 @@ GameLib.D3.Follow.FromObject = function(graphics, objectComponent) {
* Updates the component * Updates the component
* @param deltaTime * @param deltaTime
*/ */
GameLib.D3.Follow.prototype.update = function(deltaTime) { R3.D3.Follow.prototype.update = function(deltaTime) {
if (this.currentComponent && this.targetComponent) { if (this.currentComponent && this.targetComponent) {

View File

@ -1,10 +1,10 @@
/** /**
* Game Runtime * Game Runtime
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param apiGame GameLib.D3.API.Game * @param apiGame R3.D3.API.Game
* @constructor * @constructor
*/ */
GameLib.D3.Game = function ( R3.D3.Game = function (
graphics, graphics,
apiGame apiGame
) { ) {
@ -12,15 +12,15 @@ GameLib.D3.Game = function (
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiGame)) { if (R3.Utils.UndefinedOrNull(apiGame)) {
apiGame = {}; apiGame = {};
} }
if (apiGame instanceof GameLib.D3.Game) { if (apiGame instanceof R3.D3.Game) {
return apiGame; return apiGame;
} }
GameLib.D3.API.Game.call( R3.D3.API.Game.call(
this, this,
apiGame.id, apiGame.id,
apiGame.name, apiGame.name,
@ -38,8 +38,8 @@ GameLib.D3.Game = function (
apiGame.parentEntity apiGame.parentEntity
); );
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) { if (this.imageFactory instanceof R3.D3.API.ImageFactory) {
this.imageFactory = new GameLib.D3.ImageFactory( this.imageFactory = new R3.D3.ImageFactory(
this.graphics, this.graphics,
this.imageFactory this.imageFactory
); );
@ -47,8 +47,8 @@ GameLib.D3.Game = function (
this.cameras = this.cameras.map( this.cameras = this.cameras.map(
function (apiCamera) { function (apiCamera) {
if (apiCamera instanceof GameLib.D3.API.Camera) { if (apiCamera instanceof R3.D3.API.Camera) {
return new GameLib.D3.Camera( return new R3.D3.Camera(
this.graphics, this.graphics,
apiCamera apiCamera
) )
@ -61,8 +61,8 @@ GameLib.D3.Game = function (
this.composers = this.composers.map( this.composers = this.composers.map(
function (apiComposer) { function (apiComposer) {
if (apiComposer instanceof GameLib.D3.API.Composer) { if (apiComposer instanceof R3.D3.API.Composer) {
return new GameLib.D3.Composer( return new R3.D3.Composer(
this.graphics, this.graphics,
apiComposer apiComposer
) )
@ -75,8 +75,8 @@ GameLib.D3.Game = function (
this.viewports = this.viewports.map( this.viewports = this.viewports.map(
function (apiViewport) { function (apiViewport) {
if (apiViewport instanceof GameLib.D3.API.Viewport) { if (apiViewport instanceof R3.D3.API.Viewport) {
return new GameLib.D3.Viewport( return new R3.D3.Viewport(
this.graphics, this.graphics,
apiViewport apiViewport
) )
@ -89,8 +89,8 @@ GameLib.D3.Game = function (
this.renderers = this.renderers.map( this.renderers = this.renderers.map(
function (apiRenderer) { function (apiRenderer) {
if (apiRenderer instanceof GameLib.D3.API.Renderer) { if (apiRenderer instanceof R3.D3.API.Renderer) {
return new GameLib.D3.Renderer( return new R3.D3.Renderer(
this.graphics, this.graphics,
apiRenderer apiRenderer
) )
@ -103,8 +103,8 @@ GameLib.D3.Game = function (
this.renderTargets = this.renderTargets.map( this.renderTargets = this.renderTargets.map(
function (apiRenderTarget) { function (apiRenderTarget) {
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) { if (apiRenderTarget instanceof R3.D3.API.RenderTarget) {
return new GameLib.D3.RenderTarget( return new R3.D3.RenderTarget(
this.graphics, this.graphics,
apiRenderTarget apiRenderTarget
) )
@ -117,8 +117,8 @@ GameLib.D3.Game = function (
this.systems = this.systems.map( this.systems = this.systems.map(
function (apiSystem) { function (apiSystem) {
if (apiSystem instanceof GameLib.API.System) { if (apiSystem instanceof R3.API.System) {
return new GameLib.System( return new R3.System(
this.graphics, this.graphics,
apiSystem apiSystem
) )
@ -130,8 +130,8 @@ GameLib.D3.Game = function (
); );
if (this.entityManager) { if (this.entityManager) {
if (this.entityManager instanceof GameLib.API.EntityManager) { if (this.entityManager instanceof R3.API.EntityManager) {
this.entityManager = new GameLib.EntityManager( this.entityManager = new R3.EntityManager(
this.graphics, this.graphics,
this.entityManager this.entityManager
); );
@ -146,17 +146,17 @@ GameLib.D3.Game = function (
this.linkObjects(this.idToObject); this.linkObjects(this.idToObject);
}; };
GameLib.D3.Game.prototype = Object.create(GameLib.D3.API.Game.prototype); R3.D3.Game.prototype = Object.create(R3.D3.API.Game.prototype);
GameLib.D3.Game.prototype.constructor = GameLib.D3.Game; R3.D3.Game.prototype.constructor = R3.D3.Game;
GameLib.D3.Game.GAME_TYPE_VR_PONG = 0x1; R3.D3.Game.GAME_TYPE_VR_PONG = 0x1;
GameLib.D3.Game.GAME_TYPE_VR_RACER = 0x2; R3.D3.Game.GAME_TYPE_VR_RACER = 0x2;
/** /**
* Creates a camera instance of 'graphics' type (only THREE for now) * Creates a camera instance of 'graphics' type (only THREE for now)
* @returns {THREE.Game} * @returns {THREE.Game}
*/ */
GameLib.D3.Game.prototype.createInstance = function(update) { R3.D3.Game.prototype.createInstance = function(update) {
var instance = null; var instance = null;
@ -167,7 +167,7 @@ GameLib.D3.Game.prototype.createInstance = function(update) {
return instance; return instance;
}; };
// GameLib.D3.Game.prototype.setSize = function(width, height) { // R3.D3.Game.prototype.setSize = function(width, height) {
// //
// // var w = 0; // // var w = 0;
// // var h = 0; // // var h = 0;
@ -193,15 +193,15 @@ GameLib.D3.Game.prototype.createInstance = function(update) {
/** /**
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.D3.Game.prototype.updateInstance = function() { R3.D3.Game.prototype.updateInstance = function() {
this.instance = this.createInstance(true); this.instance = this.createInstance(true);
}; };
/** /**
* Converts a GameLib.D3.Game to a new GameLib.D3.API.Game * Converts a R3.D3.Game to a new R3.D3.API.Game
* @returns {GameLib.D3.API.Game} * @returns {R3.D3.API.Game}
*/ */
GameLib.D3.Game.prototype.toApiObject = function() { R3.D3.Game.prototype.toApiObject = function() {
var apiImageFactory = null; var apiImageFactory = null;
var apiCameras = []; var apiCameras = [];
@ -212,14 +212,14 @@ GameLib.D3.Game.prototype.toApiObject = function() {
var apiSystems = []; var apiSystems = [];
var apiEntityManager = null; var apiEntityManager = null;
if (this.imageFactory instanceof GameLib.D3.ImageFactory) { if (this.imageFactory instanceof R3.D3.ImageFactory) {
apiImageFactory = this.imageFactory.toApiObject(); apiImageFactory = this.imageFactory.toApiObject();
} }
if (this.cameras) { if (this.cameras) {
apiCameras = this.cameras.map( apiCameras = this.cameras.map(
function(camera) { function(camera) {
if (camera instanceof GameLib.D3.Camera) { if (camera instanceof R3.D3.Camera) {
return camera.toApiObject(); return camera.toApiObject();
} else { } else {
console.warn('camera not an instance of Camera'); console.warn('camera not an instance of Camera');
@ -232,7 +232,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
if (this.composers) { if (this.composers) {
apiComposers = this.composers.map( apiComposers = this.composers.map(
function(composer) { function(composer) {
if (composer instanceof GameLib.D3.Composer) { if (composer instanceof R3.D3.Composer) {
return composer.toApiObject(); return composer.toApiObject();
} else { } else {
console.warn('composer not an instance of Composer'); console.warn('composer not an instance of Composer');
@ -245,7 +245,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
if (this.viewports) { if (this.viewports) {
apiViewports = this.viewports.map( apiViewports = this.viewports.map(
function(viewport) { function(viewport) {
if (viewport instanceof GameLib.D3.Viewport) { if (viewport instanceof R3.D3.Viewport) {
return viewport.toApiObject(); return viewport.toApiObject();
} else { } else {
console.warn('viewport not an instance of Viewport'); console.warn('viewport not an instance of Viewport');
@ -258,7 +258,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
if (this.renderers) { if (this.renderers) {
apiRenderers = this.renderers.map( apiRenderers = this.renderers.map(
function(renderer) { function(renderer) {
if (renderer instanceof GameLib.D3.Renderer) { if (renderer instanceof R3.D3.Renderer) {
return renderer.toApiObject(); return renderer.toApiObject();
} else { } else {
console.warn('renderer not an instance of Renderer'); console.warn('renderer not an instance of Renderer');
@ -271,7 +271,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
if (this.renderTargets) { if (this.renderTargets) {
apiRenderTargets = this.renderTargets.map( apiRenderTargets = this.renderTargets.map(
function(renderTarget) { function(renderTarget) {
if (renderTarget instanceof GameLib.D3.RenderTarget) { if (renderTarget instanceof R3.D3.RenderTarget) {
return renderTarget.toApiObject(); return renderTarget.toApiObject();
} else { } else {
console.warn('renderTarget not an instance of RenderTarget'); console.warn('renderTarget not an instance of RenderTarget');
@ -284,7 +284,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
if (this.systems) { if (this.systems) {
apiSystems = this.systems.map( apiSystems = this.systems.map(
function(system) { function(system) {
if (system instanceof GameLib.System) { if (system instanceof R3.System) {
return system.toApiObject(); return system.toApiObject();
} else { } else {
console.warn('system not an instance of System'); console.warn('system not an instance of System');
@ -295,7 +295,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
} }
if (this.entityManager) { if (this.entityManager) {
if (this.entityManager instanceof GameLib.EntityManager) { if (this.entityManager instanceof R3.EntityManager) {
apiEntityManager = this.entityManager.toApiObject(); apiEntityManager = this.entityManager.toApiObject();
} else { } else {
console.warn('entityManager not an instance of EntityManager'); console.warn('entityManager not an instance of EntityManager');
@ -303,7 +303,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
} }
} }
return new GameLib.D3.API.Game( return new R3.D3.API.Game(
this.id, this.id,
this.name, this.name,
this.baseUrl, this.baseUrl,
@ -317,22 +317,22 @@ GameLib.D3.Game.prototype.toApiObject = function() {
apiRenderTargets, apiRenderTargets,
apiSystems, apiSystems,
apiEntityManager, apiEntityManager,
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
}; };
/** /**
* Converts from an Object Game to a GameLib.D3.Game * Converts from an Object Game to a R3.D3.Game
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param objectGame Object * @param objectGame Object
* @returns {GameLib.D3.Game} * @returns {R3.D3.Game}
* @constructor * @constructor
*/ */
GameLib.D3.Game.FromObjectGame = function(graphics, objectGame) { R3.D3.Game.FromObjectGame = function(graphics, objectGame) {
var apiGame = GameLib.D3.API.Game.FromObjectGame(objectGame); var apiGame = R3.D3.API.Game.FromObjectGame(objectGame);
return new GameLib.D3.Game( return new R3.D3.Game(
graphics, graphics,
apiGame apiGame
); );
@ -346,12 +346,12 @@ GameLib.D3.Game.FromObjectGame = function(graphics, objectGame) {
* @param onLoaded * @param onLoaded
* @constructor * @constructor
*/ */
GameLib.D3.Game.LoadGame = function( R3.D3.Game.LoadGame = function(
graphics, graphics,
objectGame, objectGame,
onLoaded onLoaded
) { ) {
var game = GameLib.D3.Game.FromObjectGame( var game = R3.D3.Game.FromObjectGame(
graphics, graphics,
objectGame objectGame
); );
@ -361,14 +361,14 @@ GameLib.D3.Game.LoadGame = function(
/** /**
* Loads a Game from the API * Loads a Game from the API
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param partialGameObject Object * @param partialGameObject Object
* @param onLoaded callback * @param onLoaded callback
* @param apiUrl * @param apiUrl
* @returns {*} * @returns {*}
* @constructor * @constructor
*/ */
GameLib.D3.Game.LoadGameFromApi = function( R3.D3.Game.LoadGameFromApi = function(
graphics, graphics,
partialGameObject, partialGameObject,
onLoaded, onLoaded,
@ -410,7 +410,7 @@ GameLib.D3.Game.LoadGameFromApi = function(
var objectGame = response.game[0]; var objectGame = response.game[0];
GameLib.D3.Game.LoadGame( R3.D3.Game.LoadGame(
graphics, graphics,
objectGame, objectGame,
onLoaded onLoaded
@ -422,7 +422,7 @@ GameLib.D3.Game.LoadGameFromApi = function(
xhr.send(); xhr.send();
}; };
GameLib.D3.Game.prototype.setSize = function(width, height) { R3.D3.Game.prototype.setSize = function(width, height) {
this.renderers.map( this.renderers.map(
function(renderer) { function(renderer) {
renderer.setSize(width, height); renderer.setSize(width, height);

View File

@ -6,7 +6,7 @@
* @param heightScale Number * @param heightScale Number
* @constructor * @constructor
*/ */
GameLib.D3.Heightmap = function Heightmap( R3.D3.Heightmap = function Heightmap(
sizeX, sizeX,
sizeY, sizeY,
matrix, matrix,
@ -40,7 +40,7 @@ GameLib.D3.Heightmap = function Heightmap(
}; };
GameLib.D3.Heightmap.prototype.toApiHeightMap = function() { R3.D3.Heightmap.prototype.toApiHeightMap = function() {
//TODO - create API heightmap someday //TODO - create API heightmap someday
return { return {
sizeX: this.sizeX, sizeX: this.sizeX,
@ -53,12 +53,12 @@ GameLib.D3.Heightmap.prototype.toApiHeightMap = function() {
/** /**
* Creates a graphics instance mesh from the graphics, physics and physics shape * Creates a graphics instance mesh from the graphics, physics and physics shape
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param shape GameLib.D3.Shape * @param shape R3.D3.Shape
* @param engine GameLib.D3.Engine * @param engine R3.D3.Engine
* @returns {THREE.Mesh|this.meshes} * @returns {THREE.Mesh|this.meshes}
*/ */
GameLib.D3.Heightmap.GenerateInstanceMesh = function( R3.D3.Heightmap.GenerateInstanceMesh = function(
graphics, graphics,
shape, shape,
engine engine
@ -113,7 +113,7 @@ GameLib.D3.Heightmap.GenerateInstanceMesh = function(
* @param callback * @param callback
* @constructor * @constructor
*/ */
GameLib.D3.Heightmap.GenerateHeightmapDataFromImage = function ( R3.D3.Heightmap.GenerateHeightmapDataFromImage = function (
imagePath, imagePath,
heightScale, heightScale,
callback callback
@ -152,7 +152,7 @@ GameLib.D3.Heightmap.GenerateHeightmapDataFromImage = function (
// todo: delete canvas here // todo: delete canvas here
callback( callback(
new GameLib.D3.Heightmap( new R3.D3.Heightmap(
sizeX, sizeX,
sizeY, sizeY,
matrix, matrix,

View File

@ -3,10 +3,10 @@
* @param graphics * @param graphics
* @param apiImageFactory * @param apiImageFactory
* @param progressCallback * @param progressCallback
* @returns {GameLib.D3.ImageFactory} * @returns {R3.D3.ImageFactory}
* @constructor * @constructor
*/ */
GameLib.D3.ImageFactory = function ( R3.D3.ImageFactory = function (
graphics, graphics,
apiImageFactory, apiImageFactory,
progressCallback progressCallback
@ -14,15 +14,15 @@ GameLib.D3.ImageFactory = function (
graphics.isNotThreeThrow(); graphics.isNotThreeThrow();
this.graphics = graphics; this.graphics = graphics;
if (GameLib.Utils.UndefinedOrNull(apiImageFactory)) { if (R3.Utils.UndefinedOrNull(apiImageFactory)) {
apiImageFactory = {}; apiImageFactory = {};
} }
if (apiImageFactory instanceof GameLib.D3.ImageFactory) { if (apiImageFactory instanceof R3.D3.ImageFactory) {
return apiImageFactory; return apiImageFactory;
} }
GameLib.D3.API.ImageFactory.call( R3.D3.API.ImageFactory.call(
this, this,
apiImageFactory.id, apiImageFactory.id,
apiImageFactory.name, apiImageFactory.name,
@ -30,23 +30,23 @@ GameLib.D3.ImageFactory = function (
apiImageFactory.parentEntity apiImageFactory.parentEntity
); );
if (GameLib.Utils.UndefinedOrNull(progressCallback)) { if (R3.Utils.UndefinedOrNull(progressCallback)) {
progressCallback = null; progressCallback = null;
} }
this.progressCallback = progressCallback; this.progressCallback = progressCallback;
GameLib.Component.call( R3.Component.call(
this, this,
GameLib.Component.COMPONENT_IMAGE_FACTORY R3.Component.COMPONENT_IMAGE_FACTORY
); );
this.promiseList = {}; this.promiseList = {};
}; };
GameLib.D3.ImageFactory.prototype = Object.create(GameLib.D3.API.ImageFactory.prototype); R3.D3.ImageFactory.prototype = Object.create(R3.D3.API.ImageFactory.prototype);
GameLib.D3.ImageFactory.prototype.constructor = GameLib.D3.ImageFactory; R3.D3.ImageFactory.prototype.constructor = R3.D3.ImageFactory;
GameLib.D3.ImageFactory.prototype.createInstance = function(update) { R3.D3.ImageFactory.prototype.createInstance = function(update) {
if (!this.loaded) { if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name); console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
@ -69,7 +69,7 @@ GameLib.D3.ImageFactory.prototype.createInstance = function(update) {
/** /**
* Update instance * Update instance
*/ */
GameLib.D3.ImageFactory.prototype.updateInstance = function() { R3.D3.ImageFactory.prototype.updateInstance = function() {
this.instance = this.createInstance(true); this.instance = this.createInstance(true);
}; };
@ -80,7 +80,7 @@ GameLib.D3.ImageFactory.prototype.updateInstance = function() {
* @returns {*} * @returns {*}
* @constructor * @constructor
*/ */
GameLib.D3.ImageFactory.prototype.loadImage = function( R3.D3.ImageFactory.prototype.loadImage = function(
imagePath, imagePath,
force force
) { ) {
@ -104,8 +104,8 @@ GameLib.D3.ImageFactory.prototype.loadImage = function(
this.baseUrl + imagePath + '?ts=' + Date.now(), this.baseUrl + imagePath + '?ts=' + Date.now(),
function (image) { function (image) {
GameLib.Event.Emit( R3.Event.Emit(
GameLib.Event.IMAGE_LOADED, R3.Event.IMAGE_LOADED,
{ {
imagePath : imagePath, imagePath : imagePath,
imageInstance : image imageInstance : image
@ -128,29 +128,29 @@ GameLib.D3.ImageFactory.prototype.loadImage = function(
}; };
/** /**
* Converts a GameLib.D3.ImageFactory to a GameLib.D3.API.ImageFactory * Converts a R3.D3.ImageFactory to a R3.D3.API.ImageFactory
* @returns {GameLib.D3.API.ImageFactory} * @returns {R3.D3.API.ImageFactory}
*/ */
GameLib.D3.ImageFactory.prototype.toApiObject = function() { R3.D3.ImageFactory.prototype.toApiObject = function() {
return new GameLib.D3.API.ImageFactory( return new R3.D3.API.ImageFactory(
this.id, this.id,
this.name, this.name,
this.baseUrl, this.baseUrl,
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
}; };
/** /**
* Returns a new GameLib.D3.ImageFactory from a GameLib.D3.API.ImageFactory * Returns a new R3.D3.ImageFactory from a R3.D3.API.ImageFactory
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param objectImageFactory GameLib.D3.API.ImageFactory * @param objectImageFactory R3.D3.API.ImageFactory
* @returns {GameLib.D3.ImageFactory} * @returns {R3.D3.ImageFactory}
*/ */
GameLib.D3.ImageFactory.FromObject = function(graphics, objectImageFactory) { R3.D3.ImageFactory.FromObject = function(graphics, objectImageFactory) {
return new GameLib.D3.ImageFactory( return new R3.D3.ImageFactory(
graphics, graphics,
GameLib.D3.API.ImageFactory.FromObject(objectImageFactory) R3.D3.API.ImageFactory.FromObject(objectImageFactory)
); );
}; };

5
bak/r3-d3-input-a.js Normal file
View File

@ -0,0 +1,5 @@
/**
* R3.D3.Input namespace
* @constructor
*/
R3.D3.Input = function () {};

View File

@ -1,11 +1,11 @@
/** /**
* Input parent class * Input parent class
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param apiInputDrive GameLib.D3.API.Input.Drive * @param apiInputDrive R3.D3.API.Input.Drive
* @param dom GameLib.Dom * @param dom R3.Dom
* @constructor * @constructor
*/ */
GameLib.D3.Input.Drive = function ( R3.D3.Input.Drive = function (
graphics, graphics,
apiInputDrive, apiInputDrive,
dom dom
@ -14,15 +14,15 @@ GameLib.D3.Input.Drive = function (
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiInputDrive)) { if (R3.Utils.UndefinedOrNull(apiInputDrive)) {
apiInputDrive = {}; apiInputDrive = {};
} }
if (apiInputDrive instanceof GameLib.D3.Drive) { if (apiInputDrive instanceof R3.D3.Drive) {
return apiInputDrive; return apiInputDrive;
} }
GameLib.D3.API.Input.Drive.call( R3.D3.API.Input.Drive.call(
this, this,
apiInputDrive.id, apiInputDrive.id,
apiInputDrive.name, apiInputDrive.name,
@ -39,7 +39,7 @@ GameLib.D3.Input.Drive = function (
apiInputDrive.rotationFactor apiInputDrive.rotationFactor
); );
if (GameLib.Utils.UndefinedOrNull(dom)) { if (R3.Utils.UndefinedOrNull(dom)) {
console.warn('Cannot create Input without an handle to the DOM'); console.warn('Cannot create Input without an handle to the DOM');
throw new Error('Cannot create Input without an handle to the DOM'); throw new Error('Cannot create Input without an handle to the DOM');
} }
@ -49,23 +49,23 @@ GameLib.D3.Input.Drive = function (
this.keyRight = false; this.keyRight = false;
GameLib.Component.call( R3.Component.call(
this, this,
GameLib.Component.COMPONENT_INPUT_DRIVE, R3.Component.COMPONENT_INPUT_DRIVE,
{ {
'pathFollowingComponent' : GameLib.D3.PathFollowing, 'pathFollowingComponent' : R3.D3.PathFollowing,
'wheelFL' : GameLib.D3.Mesh, 'wheelFL' : R3.D3.Mesh,
'wheelFR' : GameLib.D3.Mesh, 'wheelFR' : R3.D3.Mesh,
'wheelRL' : GameLib.D3.Mesh, 'wheelRL' : R3.D3.Mesh,
'wheelRR' : GameLib.D3.Mesh 'wheelRR' : R3.D3.Mesh
} }
); );
}; };
GameLib.D3.Input.Drive.prototype = Object.create(GameLib.D3.API.Input.Drive.prototype); R3.D3.Input.Drive.prototype = Object.create(R3.D3.API.Input.Drive.prototype);
GameLib.D3.Input.Drive.prototype.constructor = GameLib.D3.Input.Drive; R3.D3.Input.Drive.prototype.constructor = R3.D3.Input.Drive;
GameLib.D3.Input.Drive.prototype.createInstance = function(update) { R3.D3.Input.Drive.prototype.createInstance = function(update) {
if (update) { if (update) {
return this.instance; return this.instance;
@ -104,26 +104,26 @@ GameLib.D3.Input.Drive.prototype.createInstance = function(update) {
return instance; return instance;
}; };
GameLib.D3.Input.Drive.prototype.updateInstance = function() { R3.D3.Input.Drive.prototype.updateInstance = function() {
this.instance = this.createInstance(true); this.instance = this.createInstance(true);
}; };
/** /**
* GameLib.D3.Input.Drive to GameLib.D3.API.Input.Drive * R3.D3.Input.Drive to R3.D3.API.Input.Drive
* @returns {GameLib.D3.API.Input.Drive} * @returns {R3.D3.API.Input.Drive}
*/ */
GameLib.D3.Input.Drive.prototype.toApiObject = function() { R3.D3.Input.Drive.prototype.toApiObject = function() {
var apiInputDrive = new GameLib.D3.API.Input.Drive( var apiInputDrive = new R3.D3.API.Input.Drive(
this.id, this.id,
this.name, this.name,
this.domElementId, this.domElementId,
GameLib.Utils.IdOrNull(this.pathFollowingComponent), R3.Utils.IdOrNull(this.pathFollowingComponent),
GameLib.Utils.IdOrNull(this.parentEntity), R3.Utils.IdOrNull(this.parentEntity),
GameLib.Utils.IdOrNull(this.wheelFL), R3.Utils.IdOrNull(this.wheelFL),
GameLib.Utils.IdOrNull(this.wheelFR), R3.Utils.IdOrNull(this.wheelFR),
GameLib.Utils.IdOrNull(this.wheelRL), R3.Utils.IdOrNull(this.wheelRL),
GameLib.Utils.IdOrNull(this.wheelRR), R3.Utils.IdOrNull(this.wheelRR),
this.heightOffset, this.heightOffset,
this.distance, this.distance,
this.distanceGrain, this.distanceGrain,
@ -133,17 +133,17 @@ GameLib.D3.Input.Drive.prototype.toApiObject = function() {
return apiInputDrive; return apiInputDrive;
}; };
GameLib.D3.Input.Drive.FromObject = function(graphics, objectComponent) { R3.D3.Input.Drive.FromObject = function(graphics, objectComponent) {
var apiInputDrive = GameLib.D3.API.Input.Drive.FromObject(objectComponent); var apiInputDrive = R3.D3.API.Input.Drive.FromObject(objectComponent);
return new GameLib.D3.Input.Drive( return new R3.D3.Input.Drive(
graphics, graphics,
apiInputDrive apiInputDrive
); );
}; };
GameLib.D3.Input.Drive.prototype.update = function(deltaTime) { R3.D3.Input.Drive.prototype.update = function(deltaTime) {
if (this.pathFollowingComponent) { if (this.pathFollowingComponent) {
this.pathFollowingComponent.mesh.localPosition.x = (this.heightOffset * this.pathFollowingComponent.rotationMatrix.up.x); this.pathFollowingComponent.mesh.localPosition.x = (this.heightOffset * this.pathFollowingComponent.rotationMatrix.up.x);

View File

@ -1,11 +1,11 @@
/** /**
* Input parent class * Input parent class
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param parentObject * @param parentObject
* @param apiInputEditor GameLib.D3.API.Input.Editor * @param apiInputEditor R3.D3.API.Input.Editor
* @constructor * @constructor
*/ */
GameLib.D3.Input.Editor = function RuntimeEditorInput( R3.D3.Input.Editor = function RuntimeEditorInput(
graphics, graphics,
parentObject, parentObject,
apiInputEditor apiInputEditor
@ -14,12 +14,12 @@ GameLib.D3.Input.Editor = function RuntimeEditorInput(
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(parentObject)) { if (R3.Utils.UndefinedOrNull(parentObject)) {
parentObject = null; parentObject = null;
} }
this.parentObject = parentObject; this.parentObject = parentObject;
GameLib.D3.API.Input.Editor.call( R3.D3.API.Input.Editor.call(
this, this,
apiInputEditor.id, apiInputEditor.id,
apiInputEditor.name, apiInputEditor.name,
@ -33,10 +33,10 @@ GameLib.D3.Input.Editor = function RuntimeEditorInput(
*/ */
}; };
GameLib.D3.Input.Editor.prototype = Object.create(GameLib.D3.API.Input.Editor.prototype); R3.D3.Input.Editor.prototype = Object.create(R3.D3.API.Input.Editor.prototype);
GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor; R3.D3.Input.Editor.prototype.constructor = R3.D3.Input.Editor;
GameLib.D3.Input.Editor.prototype.createInstance = function(update) { R3.D3.Input.Editor.prototype.createInstance = function(update) {
var instance = null; var instance = null;
@ -52,26 +52,26 @@ GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
return instance; return instance;
}; };
GameLib.D3.Input.Editor.prototype.updateInstance = function() { R3.D3.Input.Editor.prototype.updateInstance = function() {
this.instance = this.createInstance(true); this.instance = this.createInstance(true);
}; };
GameLib.D3.Input.Editor.prototype.toApiComponent = function() { R3.D3.Input.Editor.prototype.toApiComponent = function() {
var apiInputEditor = new GameLib.D3.API.Input.Editor( var apiInputEditor = new R3.D3.API.Input.Editor(
this.id, this.id,
this.name, this.name,
this.domElementId, this.domElementId,
GameLib.Utils.IdOrNull(this.camera), R3.Utils.IdOrNull(this.camera),
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
return apiInputEditor; return apiInputEditor;
}; };
GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent) { R3.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent) {
var apiInputEditor = new GameLib.D3.API.Input.Editor( var apiInputEditor = new R3.D3.API.Input.Editor(
objectComponent.id, objectComponent.id,
objectComponent.name, objectComponent.name,
objectComponent.domElementId, objectComponent.domElementId,
@ -79,7 +79,7 @@ GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent
objectComponent.parentEntity objectComponent.parentEntity
); );
return new GameLib.D3.Input.Editor( return new R3.D3.Input.Editor(
graphics, graphics,
this, this,
apiInputEditor apiInputEditor

90
bak/r3-d3-input-editor.js Normal file
View File

@ -0,0 +1,90 @@
/**
* Input parent class
* @param graphics R3.D3.Graphics
* @param apiInputEditor R3.D3.API.Input.Editor
* @constructor
*/
R3.D3.Input.Editor = function (
graphics,
apiInputEditor
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiInputEditor)) {
apiInputEditor = {};
}
if (apiInputEditor instanceof R3.D3.Input.Editor) {
return apiInputEditor;
}
R3.D3.API.Input.Editor.call(
this,
apiInputEditor.id,
apiInputEditor.name,
apiInputEditor.domElement,
apiInputEditor.camera,
apiInputEditor.parentEntity
);
if (this.domElement instanceof R3.API.DomElement) {
this.domElement = new R3.DomElement(
this.domElement
)
}
if (this.camera instanceof R3.D3.API.Camera) {
this.camera = new R3.D3.Camera(
this.graphics,
this.camera
)
}
R3.Component.call(
this,
R3.Component.COMPONENT_INPUT_EDITOR,
{
'camera' : R3.D3.Camera
}
);
};
R3.D3.Input.Editor.prototype = Object.create(R3.D3.API.Input.Editor.prototype);
R3.D3.Input.Editor.prototype.constructor = R3.D3.Input.Editor;
R3.D3.Input.Editor.prototype.createInstance = function() {
return true;
};
R3.D3.Input.Editor.prototype.updateInstance = function() {
};
/**
* R3.D3.Input.Editor to R3.D3.API.Input.Editor
* @returns {R3.D3.API.Input.Editor}
*/
R3.D3.Input.Editor.prototype.toApiObject = function() {
var apiInputEditor = new R3.D3.API.Input.Editor(
this.id,
this.name,
this.domElementId,
R3.Utils.IdOrNull(this.camera),
R3.Utils.IdOrNull(this.parentEntity)
);
return apiInputEditor;
};
R3.D3.Input.Editor.FromObject = function(graphics, objectComponent) {
var apiInputEditor = R3.D3.API.Input.Editor.FromObject(objectComponent);
return new R3.D3.Input.Editor(
graphics,
apiInputEditor
);
};

View File

@ -1,11 +1,11 @@
/** /**
* Input parent class * Input parent class
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param parentObject * @param parentObject
* @param apiInputFly GameLib.D3.API.Input.Fly * @param apiInputFly R3.D3.API.Input.Fly
* @constructor * @constructor
*/ */
GameLib.D3.Input.Fly = function RuntimeEditorInput( R3.D3.Input.Fly = function RuntimeEditorInput(
graphics, graphics,
parentObject, parentObject,
apiInputFly apiInputFly
@ -14,12 +14,12 @@ GameLib.D3.Input.Fly = function RuntimeEditorInput(
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(parentObject)) { if (R3.Utils.UndefinedOrNull(parentObject)) {
parentObject = null; parentObject = null;
} }
this.parentObject = parentObject; this.parentObject = parentObject;
GameLib.D3.API.Input.Fly.call( R3.D3.API.Input.Fly.call(
this, this,
apiInputFly.id, apiInputFly.id,
apiInputFly.name, apiInputFly.name,
@ -55,40 +55,40 @@ GameLib.D3.Input.Fly = function RuntimeEditorInput(
*/ */
}; };
GameLib.D3.Input.Fly.prototype = Object.create(GameLib.D3.API.Input.Fly.prototype); R3.D3.Input.Fly.prototype = Object.create(R3.D3.API.Input.Fly.prototype);
GameLib.D3.Input.Fly.prototype.constructor = GameLib.D3.Input.Fly; R3.D3.Input.Fly.prototype.constructor = R3.D3.Input.Fly;
GameLib.D3.Input.Fly.prototype.createInstance = function(update) { R3.D3.Input.Fly.prototype.createInstance = function(update) {
//todo //todo
}; };
GameLib.D3.Input.Fly.prototype.updateInstance = function() { R3.D3.Input.Fly.prototype.updateInstance = function() {
this.instance = this.createInstance(true); this.instance = this.createInstance(true);
}; };
GameLib.D3.Input.Fly.prototype.toApiComponent = function() { R3.D3.Input.Fly.prototype.toApiComponent = function() {
var apiInputFly = new GameLib.D3.API.Input.Fly( var apiInputFly = new R3.D3.API.Input.Fly(
this.id, this.id,
this.name, this.name,
this.domElementId, this.domElementId,
GameLib.Utils.IdOrNull(this.camera) R3.Utils.IdOrNull(this.camera)
); );
return apiInputFly; return apiInputFly;
}; };
GameLib.D3.Input.Fly.FromObjectComponent = function(graphics, objectComponent) { R3.D3.Input.Fly.FromObjectComponent = function(graphics, objectComponent) {
var apiInputFly = new GameLib.D3.API.Input.Fly( var apiInputFly = new R3.D3.API.Input.Fly(
objectComponent.id, objectComponent.id,
objectComponent.name, objectComponent.name,
objectComponent.domElementId, objectComponent.domElementId,
objectComponent.camera objectComponent.camera
); );
return new GameLib.D3.Input.Fly( return new R3.D3.Input.Fly(
graphics, graphics,
this, this,
apiInputFly apiInputFly
@ -101,7 +101,7 @@ GameLib.D3.Input.Fly.FromObjectComponent = function(graphics, objectComponent) {
* Go forward / backward on mouse wheel * Go forward / backward on mouse wheel
* @param event * @param event
*/ */
GameLib.D3.Input.Fly.prototype.onMouseWheel = function(event) { R3.D3.Input.Fly.prototype.onMouseWheel = function(event) {
this.moveForward = true; this.moveForward = true;
this.applyTranslation(event.wheelDelta * 0.001); this.applyTranslation(event.wheelDelta * 0.001);
event.preventDefault(); event.preventDefault();
@ -112,7 +112,7 @@ GameLib.D3.Input.Fly.prototype.onMouseWheel = function(event) {
* Start rotating the camera on mouse middle button down * Start rotating the camera on mouse middle button down
* @param event * @param event
*/ */
GameLib.D3.Input.Fly.prototype.onMouseDown = function(event) { R3.D3.Input.Fly.prototype.onMouseDown = function(event) {
if (event.button == 1) { if (event.button == 1) {
this.canRotate = true; this.canRotate = true;
this.canvas.addEventListener('mousemove', this.mouseMoveCallback, false); this.canvas.addEventListener('mousemove', this.mouseMoveCallback, false);
@ -123,7 +123,7 @@ GameLib.D3.Input.Fly.prototype.onMouseWheel = function(event) {
* Stop rotating on middle mouse button down * Stop rotating on middle mouse button down
* @param event * @param event
*/ */
GameLib.D3.Input.Fly.prototype.onMouseUp = function(event) { R3.D3.Input.Fly.prototype.onMouseUp = function(event) {
if (event.button == 1) { if (event.button == 1) {
this.canRotate = false; this.canRotate = false;
this.canvas.removeEventListener('mousemove', this.mouseMoveCallback); this.canvas.removeEventListener('mousemove', this.mouseMoveCallback);
@ -133,7 +133,7 @@ GameLib.D3.Input.Fly.prototype.onMouseUp = function(event) {
/** /**
* Apply current yaw and pitch to camera * Apply current yaw and pitch to camera
*/ */
GameLib.D3.Input.Fly.prototype.applyRotation = function() { R3.D3.Input.Fly.prototype.applyRotation = function() {
this.camera.rotation.set(this.pitch, this.yaw, 0, "YXZ"); this.camera.rotation.set(this.pitch, this.yaw, 0, "YXZ");
}; };
@ -141,7 +141,7 @@ GameLib.D3.Input.Fly.prototype.applyRotation = function() {
* Apply current position to camera * Apply current position to camera
* @param deltaTime * @param deltaTime
*/ */
GameLib.D3.Input.Fly.prototype.applyTranslation = function(deltaTime) { R3.D3.Input.Fly.prototype.applyTranslation = function(deltaTime) {
var direction = new this.THREE.Vector3(0, 0, -1); var direction = new this.THREE.Vector3(0, 0, -1);
var rotation = new this.THREE.Euler(0, 0, 0, "YXZ"); var rotation = new this.THREE.Euler(0, 0, 0, "YXZ");
rotation.set(this.pitch, this.yaw, 0, "YXZ"); rotation.set(this.pitch, this.yaw, 0, "YXZ");
@ -193,7 +193,7 @@ GameLib.D3.Input.Fly.prototype.applyTranslation = function(deltaTime) {
* movement to the camera * movement to the camera
* @param deltaTime * @param deltaTime
*/ */
GameLib.D3.Input.Fly.prototype.update = function(deltaTime) { R3.D3.Input.Fly.prototype.update = function(deltaTime) {
this.applyRotation(); this.applyRotation();
this.applyTranslation(deltaTime); this.applyTranslation(deltaTime);
}; };
@ -202,7 +202,7 @@ GameLib.D3.Input.Fly.prototype.update = function(deltaTime) {
* Rotate on mouse move * Rotate on mouse move
* @param event * @param event
*/ */
GameLib.D3.Input.Fly.prototype.onMouseMove = function ( event ) { R3.D3.Input.Fly.prototype.onMouseMove = function ( event ) {
if (this.canRotate) { if (this.canRotate) {
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0; var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0; var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
@ -216,7 +216,7 @@ GameLib.D3.Input.Fly.prototype.onMouseMove = function ( event ) {
* Keyboard controls * Keyboard controls
* @param event * @param event
*/ */
GameLib.D3.Input.Fly.prototype.onKeyDown = function ( event ) { R3.D3.Input.Fly.prototype.onKeyDown = function ( event ) {
switch ( event.keyCode ) { switch ( event.keyCode ) {
case 87: // w case 87: // w
@ -249,7 +249,7 @@ GameLib.D3.Input.Fly.prototype.onKeyDown = function ( event ) {
* Keyboard controls * Keyboard controls
* @param event * @param event
*/ */
GameLib.D3.Input.Fly.prototype.onKeyUp = function ( event ) { R3.D3.Input.Fly.prototype.onKeyUp = function ( event ) {
switch ( event.keyCode ) { switch ( event.keyCode ) {
case 38: // up case 38: // up

View File

@ -1,25 +1,25 @@
/** /**
* Entities with LookAt component looks to targetPosition (default up is 0,1,0) * Entities with LookAt component looks to targetPosition (default up is 0,1,0)
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiLookAt GameLib.D3.API.LookAt * @param apiLookAt R3.D3.API.LookAt
* @constructor * @constructor
*/ */
GameLib.D3.LookAt = function ( R3.D3.LookAt = function (
graphics, graphics,
apiLookAt apiLookAt
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiLookAt)) { if (R3.Utils.UndefinedOrNull(apiLookAt)) {
apiLookAt = {}; apiLookAt = {};
} }
if (apiLookAt instanceof GameLib.D3.LookAt) { if (apiLookAt instanceof R3.D3.LookAt) {
return apiLookAt; return apiLookAt;
} }
GameLib.D3.API.LookAt.call( R3.D3.API.LookAt.call(
this, this,
apiLookAt.id, apiLookAt.id,
apiLookAt.name, apiLookAt.name,
@ -30,81 +30,81 @@ GameLib.D3.LookAt = function (
apiLookAt.parentEntity apiLookAt.parentEntity
); );
this.targetPositionOffset = new GameLib.Vector3( this.targetPositionOffset = new R3.Vector3(
this.graphics, this.graphics,
this.targetPositionOffset, this.targetPositionOffset,
this this
); );
this.lookAtMatrix = new GameLib.Matrix4( this.lookAtMatrix = new R3.Matrix4(
this.graphics, this.graphics,
this.lookAtMatrix, this.lookAtMatrix,
this this
); );
this.up = new GameLib.Vector3( this.up = new R3.Vector3(
this.graphics, this.graphics,
this.up, this.up,
this this
); );
this.currentRotation = new GameLib.Quaternion( this.currentRotation = new R3.Quaternion(
this.graphics, this.graphics,
this.currentRotation, this.currentRotation,
this this
); );
this.targetPosition = new GameLib.Vector3( this.targetPosition = new R3.Vector3(
this.graphics, this.graphics,
this.targetPosition, this.targetPosition,
this this
); );
GameLib.Component.call( R3.Component.call(
this, this,
GameLib.Component.COMPONENT_LOOK_AT, R3.Component.COMPONENT_LOOK_AT,
{ {
'currentComponent' : GameLib.Component, 'currentComponent' : R3.Component,
'targetComponent' : GameLib.Component 'targetComponent' : R3.Component
} }
); );
}; };
GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype); R3.D3.LookAt.prototype = Object.create(R3.D3.API.LookAt.prototype);
GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt; R3.D3.LookAt.prototype.constructor = R3.D3.LookAt;
GameLib.D3.LookAt.prototype.createInstance = function() { R3.D3.LookAt.prototype.createInstance = function() {
this.instance = true; this.instance = true;
GameLib.Component.prototype.createInstance.call(this); R3.Component.prototype.createInstance.call(this);
}; };
GameLib.D3.LookAt.prototype.updateInstance = function() { R3.D3.LookAt.prototype.updateInstance = function() {
}; };
/** /**
* to API object * to API object
* @returns {GameLib.D3.API.LookAt} * @returns {R3.D3.API.LookAt}
*/ */
GameLib.D3.LookAt.prototype.toApiObject = function() { R3.D3.LookAt.prototype.toApiObject = function() {
var apiLookAt = new GameLib.D3.API.LookAt( var apiLookAt = new R3.D3.API.LookAt(
this.id, this.id,
this.name, this.name,
GameLib.Utils.IdOrNull(this.currentComponent), R3.Utils.IdOrNull(this.currentComponent),
GameLib.Utils.IdOrNull(this.targetComponent), R3.Utils.IdOrNull(this.targetComponent),
this.targetPositionOffset.toApiObject(), this.targetPositionOffset.toApiObject(),
this.rotationSpeed, this.rotationSpeed,
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
return apiLookAt; return apiLookAt;
}; };
GameLib.D3.LookAt.FromObject = function(graphics, objectComponent) { R3.D3.LookAt.FromObject = function(graphics, objectComponent) {
var apiLookAt = GameLib.D3.API.LookAt.FromObject(objectComponent); var apiLookAt = R3.D3.API.LookAt.FromObject(objectComponent);
return new GameLib.D3.LookAt( return new R3.D3.LookAt(
graphics, graphics,
apiLookAt apiLookAt
); );
@ -114,7 +114,7 @@ GameLib.D3.LookAt.FromObject = function(graphics, objectComponent) {
* Looks at using time * Looks at using time
* @param deltaTime * @param deltaTime
*/ */
GameLib.D3.LookAt.prototype.update = function(deltaTime) { R3.D3.LookAt.prototype.update = function(deltaTime) {
if (this.currentComponent && this.targetComponent) { if (this.currentComponent && this.targetComponent) {
@ -130,7 +130,7 @@ GameLib.D3.LookAt.prototype.update = function(deltaTime) {
// this.up // this.up
// ); // );
// //
// this.currentRotation = new GameLib.Quaternion(this.graphics, this, new GameLib.API.Quaternion()); // this.currentRotation = new R3.Quaternion(this.graphics, this, new R3.API.Quaternion());
// //
// this.currentRotation.setFromRotationMatrix(this.lookAtMatrix); // this.currentRotation.setFromRotationMatrix(this.lookAtMatrix);

View File

@ -1,23 +1,23 @@
/** /**
* GameLib.D3.Mesh.Box * R3.D3.Mesh.Box
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiMeshBox * @param apiMeshBox
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Box = function ( R3.D3.Mesh.Box = function (
graphics, graphics,
apiMeshBox apiMeshBox
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshBox)) { if (R3.Utils.UndefinedOrNull(apiMeshBox)) {
apiMeshBox = { apiMeshBox = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_BOX meshType: R3.D3.API.Mesh.MESH_TYPE_BOX
}; };
} }
GameLib.D3.API.Mesh.Box.call( R3.D3.API.Mesh.Box.call(
this, this,
apiMeshBox, apiMeshBox,
apiMeshBox.width, apiMeshBox.width,
@ -25,17 +25,17 @@ GameLib.D3.Mesh.Box = function (
apiMeshBox.depth apiMeshBox.depth
); );
GameLib.D3.Mesh.call( R3.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
this this
); );
}; };
GameLib.D3.Mesh.Box.prototype = Object.create(GameLib.D3.Mesh.prototype); R3.D3.Mesh.Box.prototype = Object.create(R3.D3.Mesh.prototype);
GameLib.D3.Mesh.Box.prototype.constructor = GameLib.D3.Mesh.Box; R3.D3.Mesh.Box.prototype.constructor = R3.D3.Mesh.Box;
GameLib.D3.Mesh.Box.prototype.createInstance = function() { R3.D3.Mesh.Box.prototype.createInstance = function() {
var geometry = null; var geometry = null;
@ -50,10 +50,10 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
this.updateVerticesFromGeometryInstance(geometry); this.updateVerticesFromGeometryInstance(geometry);
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); R3.D3.Mesh.prototype.createInstance.call(this);
}; };
GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) { R3.D3.Mesh.Box.prototype.updateInstance = function(property) {
if ( if (
property === 'width' || property === 'width' ||
@ -75,18 +75,18 @@ GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
return; return;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); R3.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh.Box to a GameLib.D3.API.Mesh.Box * Converts a R3.D3.Mesh.Box to a R3.D3.API.Mesh.Box
* @returns {GameLib.D3.API.Mesh.Box} * @returns {R3.D3.API.Mesh.Box}
*/ */
GameLib.D3.Mesh.Box.prototype.toApiObject = function() { R3.D3.Mesh.Box.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshBox = new GameLib.D3.API.Mesh.Box( var apiMeshBox = new R3.D3.API.Mesh.Box(
apiMesh, apiMesh,
this.width, this.width,
this.height, this.height,

View File

@ -1,40 +1,40 @@
/** /**
* GameLib.D3.Mesh.Curve * R3.D3.Mesh.Curve
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiMeshCurve * @param apiMeshCurve
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Curve = function ( R3.D3.Mesh.Curve = function (
graphics, graphics,
apiMeshCurve apiMeshCurve
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshCurve)) { if (R3.Utils.UndefinedOrNull(apiMeshCurve)) {
apiMeshCurve = { apiMeshCurve = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_CURVE meshType: R3.D3.API.Mesh.MESH_TYPE_CURVE
}; };
} }
GameLib.D3.API.Mesh.Curve.call( R3.D3.API.Mesh.Curve.call(
this, this,
apiMeshCurve, apiMeshCurve,
apiMeshCurve.pointSize apiMeshCurve.pointSize
); );
GameLib.D3.Mesh.call( R3.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
this this
); );
}; };
GameLib.D3.Mesh.Curve.prototype = Object.create(GameLib.D3.Mesh.prototype); R3.D3.Mesh.Curve.prototype = Object.create(R3.D3.Mesh.prototype);
GameLib.D3.Mesh.Curve.prototype.constructor = GameLib.D3.Mesh.Curve; R3.D3.Mesh.Curve.prototype.constructor = R3.D3.Mesh.Curve;
GameLib.D3.Mesh.Curve.prototype.createInstance = function() { R3.D3.Mesh.Curve.prototype.createInstance = function() {
console.warn('todo: not fully implemented'); console.warn('todo: not fully implemented');
@ -57,14 +57,14 @@ GameLib.D3.Mesh.Curve.prototype.createInstance = function() {
}; };
/** /**
* Converts a GameLib.D3.Mesh.Curve to a GameLib.D3.API.Mesh.Curve * Converts a R3.D3.Mesh.Curve to a R3.D3.API.Mesh.Curve
* @returns {GameLib.D3.API.Mesh.Curve} * @returns {R3.D3.API.Mesh.Curve}
*/ */
GameLib.D3.Mesh.Curve.prototype.toApiObject = function() { R3.D3.Mesh.Curve.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshCurve = new GameLib.D3.API.Mesh.Curve( var apiMeshCurve = new R3.D3.API.Mesh.Curve(
apiMesh, apiMesh,
this.pointSize this.pointSize
); );

View File

@ -1,23 +1,23 @@
/** /**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created * Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiMeshCylinder * @param apiMeshCylinder
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Cylinder = function ( R3.D3.Mesh.Cylinder = function (
graphics, graphics,
apiMeshCylinder apiMeshCylinder
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshCylinder)) { if (R3.Utils.UndefinedOrNull(apiMeshCylinder)) {
apiMeshCylinder = { apiMeshCylinder = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER meshType : R3.D3.API.Mesh.MESH_TYPE_CYLINDER
}; };
} }
GameLib.D3.API.Mesh.Cylinder.call( R3.D3.API.Mesh.Cylinder.call(
this, this,
apiMeshCylinder, apiMeshCylinder,
apiMeshCylinder.radiusTop, apiMeshCylinder.radiusTop,
@ -30,17 +30,17 @@ GameLib.D3.Mesh.Cylinder = function (
apiMeshCylinder.thetaLength apiMeshCylinder.thetaLength
); );
GameLib.D3.Mesh.call( R3.D3.Mesh.call(
this, this,
graphics, graphics,
this this
); );
}; };
GameLib.D3.Mesh.Cylinder.prototype = Object.create(GameLib.D3.Mesh.prototype); R3.D3.Mesh.Cylinder.prototype = Object.create(R3.D3.Mesh.prototype);
GameLib.D3.Mesh.Cylinder.prototype.constructor = GameLib.D3.Mesh.Cylinder; R3.D3.Mesh.Cylinder.prototype.constructor = R3.D3.Mesh.Cylinder;
GameLib.D3.Mesh.Cylinder.prototype.createInstance = function() { R3.D3.Mesh.Cylinder.prototype.createInstance = function() {
var geometry = null; var geometry = null;
@ -58,10 +58,10 @@ GameLib.D3.Mesh.Cylinder.prototype.createInstance = function() {
this.updateVerticesFromGeometryInstance(geometry); this.updateVerticesFromGeometryInstance(geometry);
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); R3.D3.Mesh.prototype.createInstance.call(this);
}; };
GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function(property) { R3.D3.Mesh.Cylinder.prototype.updateInstance = function(property) {
if ( if (
property === 'radiusTop' || property === 'radiusTop' ||
@ -90,18 +90,18 @@ GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function(property) {
this.instance.geometry = geometry; this.instance.geometry = geometry;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); R3.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh.Cylinder to a GameLib.D3.API.Mesh.Cylinder * Converts a R3.D3.Mesh.Cylinder to a R3.D3.API.Mesh.Cylinder
* @returns {GameLib.D3.API.Mesh.Cylinder} * @returns {R3.D3.API.Mesh.Cylinder}
*/ */
GameLib.D3.Mesh.Cylinder.prototype.toApiObject = function() { R3.D3.Mesh.Cylinder.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshCylinder = new GameLib.D3.API.Mesh.Cylinder( var apiMeshCylinder = new R3.D3.API.Mesh.Cylinder(
apiMesh, apiMesh,
this.radiusTop, this.radiusTop,
this.radiusBottom, this.radiusBottom,
@ -119,7 +119,7 @@ GameLib.D3.Mesh.Cylinder.prototype.toApiObject = function() {
/** /**
* This function turns the cylinder into a 'display' where each plane on the cylinder is mapped onto a flat texture * This function turns the cylinder into a 'display' where each plane on the cylinder is mapped onto a flat texture
*/ */
GameLib.D3.Mesh.Cylinder.prototype.turnIntoDisplay = function() { R3.D3.Mesh.Cylinder.prototype.turnIntoDisplay = function() {
this.heightSegments = 1; this.heightSegments = 1;
this.updateInstance('heightSegments'); this.updateInstance('heightSegments');
@ -137,7 +137,7 @@ GameLib.D3.Mesh.Cylinder.prototype.turnIntoDisplay = function() {
for (var i = 0; i < this.radiusSegments; i++) { for (var i = 0; i < this.radiusSegments; i++) {
this.materials.push( this.materials.push(
new GameLib.D3.Material(this.graphics) new R3.D3.Material(this.graphics)
) )
} }

77
bak/r3-d3-mesh-line.js Normal file
View File

@ -0,0 +1,77 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics R3.GraphicsRuntime
* @param apiMeshLine
* @constructor
*/
R3.D3.Mesh.Line = function (
graphics,
apiMeshLine
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiMeshLine)) {
apiMeshLine = {
meshType: R3.D3.API.Mesh.MESH_TYPE_LINE
};
}
R3.D3.API.Mesh.Line.call(
this,
apiMeshLine,
apiMeshLine.lineWidth
);
R3.D3.Mesh.call(
this,
this.graphics,
this
);
};
R3.D3.Mesh.Line.prototype = Object.create(R3.D3.Mesh.prototype);
R3.D3.Mesh.Line.prototype.constructor = R3.D3.Mesh.Line;
R3.D3.Mesh.Line.prototype.createInstance = function() {
var geometry = new THREE.Geometry();
geometry.vertices.push(
this.vertices.map(
function(vertex){
return vertex.instance;
}
)
);
this.instance = new THREE.Line(geometry);
R3.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.lineWidth = this.lineWidth;
};
R3.D3.Mesh.Line.prototype.updateInstance = function(property) {
this.instance.linewidth = this.lineWidth;
R3.D3.Mesh.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.D3.Mesh.Line to a R3.D3.API.Mesh.Line
* @returns {R3.D3.API.Mesh.Line}
*/
R3.D3.Mesh.Line.prototype.toApiObject = function() {
var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshLine = new R3.D3.API.Mesh.Line(
apiMesh,
this.lineWidth
);
return apiMeshLine;
};

View File

@ -1,10 +1,10 @@
/** /**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created * Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiMeshPlane * @param apiMeshPlane
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Plane = function ( R3.D3.Mesh.Plane = function (
graphics, graphics,
apiMeshPlane apiMeshPlane
) { ) {
@ -12,13 +12,13 @@ GameLib.D3.Mesh.Plane = function (
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshPlane)) { if (R3.Utils.UndefinedOrNull(apiMeshPlane)) {
apiMeshPlane = { apiMeshPlane = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_PLANE meshType : R3.D3.API.Mesh.MESH_TYPE_PLANE
}; };
} }
GameLib.D3.API.Mesh.Plane.call( R3.D3.API.Mesh.Plane.call(
this, this,
apiMeshPlane, apiMeshPlane,
apiMeshPlane.width, apiMeshPlane.width,
@ -34,19 +34,19 @@ GameLib.D3.Mesh.Plane = function (
apiMeshPlane.dotObject apiMeshPlane.dotObject
); );
this.dotMapScale = new GameLib.Vector3( this.dotMapScale = new R3.Vector3(
this.graphics, this.graphics,
this.dotMapScale, this.dotMapScale,
this this
); );
this.dotMapOffset = new GameLib.Vector3( this.dotMapOffset = new R3.Vector3(
this.graphics, this.graphics,
this.dotMapOffset, this.dotMapOffset,
this this
); );
this.dotMapWeight = new GameLib.Vector3( this.dotMapWeight = new R3.Vector3(
this.graphics, this.graphics,
this.dotMapWeight, this.dotMapWeight,
this this
@ -54,7 +54,7 @@ GameLib.D3.Mesh.Plane = function (
this.dots = []; this.dots = [];
GameLib.D3.Mesh.call( R3.D3.Mesh.call(
this, this,
graphics, graphics,
apiMeshPlane apiMeshPlane
@ -62,10 +62,10 @@ GameLib.D3.Mesh.Plane = function (
}; };
GameLib.D3.Mesh.Plane.prototype = Object.create(GameLib.D3.Mesh.prototype); R3.D3.Mesh.Plane.prototype = Object.create(R3.D3.Mesh.prototype);
GameLib.D3.Mesh.Plane.prototype.constructor = GameLib.D3.Mesh.Plane; R3.D3.Mesh.Plane.prototype.constructor = R3.D3.Mesh.Plane;
GameLib.D3.Mesh.Plane.prototype.createInstance = function() { R3.D3.Mesh.Plane.prototype.createInstance = function() {
var geometry = null; var geometry = null;
@ -94,7 +94,7 @@ GameLib.D3.Mesh.Plane.prototype.createInstance = function() {
/** /**
* Now construct the mesh instance * Now construct the mesh instance
*/ */
GameLib.D3.Mesh.prototype.createInstance.call(this); R3.D3.Mesh.prototype.createInstance.call(this);
if (this.isDotMap && this.dotObject) { if (this.isDotMap && this.dotObject) {
this.generateDotMap(); this.generateDotMap();
@ -104,7 +104,7 @@ GameLib.D3.Mesh.Plane.prototype.createInstance = function() {
/** /**
* *
*/ */
GameLib.D3.Mesh.Plane.prototype.updateInstance = function(property) { R3.D3.Mesh.Plane.prototype.updateInstance = function(property) {
var geometry = null; var geometry = null;
@ -156,18 +156,18 @@ GameLib.D3.Mesh.Plane.prototype.updateInstance = function(property) {
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); R3.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh.Plane to a GameLib.D3.API.Mesh.Plane * Converts a R3.D3.Mesh.Plane to a R3.D3.API.Mesh.Plane
* @returns {GameLib.D3.API.Mesh.Plane} * @returns {R3.D3.API.Mesh.Plane}
*/ */
GameLib.D3.Mesh.Plane.prototype.toApiObject = function() { R3.D3.Mesh.Plane.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshPlane = new GameLib.D3.API.Mesh.Plane( var apiMeshPlane = new R3.D3.API.Mesh.Plane(
apiMesh, apiMesh,
this.width, this.width,
this.height, this.height,
@ -179,7 +179,7 @@ GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
this.dotMapScale.toApiObject(), this.dotMapScale.toApiObject(),
this.dotMapOffset.toApiObject(), this.dotMapOffset.toApiObject(),
this.dotMapWeight.toApiObject(), this.dotMapWeight.toApiObject(),
GameLib.Utils.IdOrNull(this.dotObject) R3.Utils.IdOrNull(this.dotObject)
); );
return apiMeshPlane; return apiMeshPlane;
@ -188,7 +188,7 @@ GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
GameLib.D3.Mesh.Plane.prototype.generateDotMap = function() { R3.D3.Mesh.Plane.prototype.generateDotMap = function() {
this.dots = []; this.dots = [];
@ -239,7 +239,7 @@ GameLib.D3.Mesh.Plane.prototype.generateDotMap = function() {
* *
* @returns {THREE.PlaneGeometry} * @returns {THREE.PlaneGeometry}
*/ */
GameLib.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() { R3.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() {
var data = this.getHeightData(); var data = this.getHeightData();
@ -267,45 +267,45 @@ GameLib.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() {
// this.updateInstance(); // this.updateInstance();
}; };
GameLib.D3.Mesh.Plane.prototype.createPhysicsObjects = function() { R3.D3.Mesh.Plane.prototype.createPhysicsObjects = function() {
GameLib.Event.Emit( R3.Event.Emit(
GameLib.Event.GET_PHYSICS_RUNTIME, R3.Event.GET_PHYSICS_RUNTIME,
null, null,
function(physics){ function(physics){
/** /**
* Create the plane shape * Create the plane shape
* @type {GameLib.D3.API.Shape} * @type {R3.D3.API.Shape}
*/ */
var apiShapePlane = new GameLib.D3.API.Shape( var apiShapePlane = new R3.D3.API.Shape(
null, null,
'Shape Plane (' + this.name + ')' 'Shape Plane (' + this.name + ')'
); );
apiShapePlane.parentMesh = this; apiShapePlane.parentMesh = this;
var shapePlane = new GameLib.D3.Shape.Plane( var shapePlane = new R3.D3.Shape.Plane(
physics, physics,
apiShapePlane apiShapePlane
); );
var apiRigidBody = new GameLib.D3.API.RigidBody( var apiRigidBody = new R3.D3.API.RigidBody(
null, null,
'Rigid Body (' + this.name + ')', 'Rigid Body (' + this.name + ')',
0, 0,
null, null,
new GameLib.API.Vector3( new R3.API.Vector3(
this.position.x, this.position.x,
this.position.y, this.position.y,
this.position.z this.position.z
), ),
new GameLib.API.Quaternion( new R3.API.Quaternion(
this.quaternion.x, this.quaternion.x,
this.quaternion.y, this.quaternion.y,
this.quaternion.z, this.quaternion.z,
this.quaternion.w, this.quaternion.w,
new GameLib.API.Vector3( new R3.API.Vector3(
this.quaternion.axis.x, this.quaternion.axis.x,
this.quaternion.axis.y, this.quaternion.axis.y,
this.quaternion.axis.z this.quaternion.axis.z
@ -320,14 +320,14 @@ GameLib.D3.Mesh.Plane.prototype.createPhysicsObjects = function() {
/** /**
* Construct the rigid body * Construct the rigid body
* @type {GameLib.D3.RigidBody} * @type {R3.D3.RigidBody}
*/ */
var rigidBody = new GameLib.D3.RigidBody( var rigidBody = new R3.D3.RigidBody(
physics, physics,
apiRigidBody apiRigidBody
); );
if (this.parentEntity instanceof GameLib.Entity) { if (this.parentEntity instanceof R3.Entity) {
this.parentEntity.addComponent(shapePlane); this.parentEntity.addComponent(shapePlane);
this.parentEntity.addComponent(rigidBody); this.parentEntity.addComponent(rigidBody);
} }

View File

@ -1,23 +1,23 @@
/** /**
* GameLib.D3.Mesh.Sphere * R3.D3.Mesh.Sphere
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiMeshSphere * @param apiMeshSphere
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Sphere = function ( R3.D3.Mesh.Sphere = function (
graphics, graphics,
apiMeshSphere apiMeshSphere
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshSphere)) { if (R3.Utils.UndefinedOrNull(apiMeshSphere)) {
apiMeshSphere = { apiMeshSphere = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_SPHERE meshType: R3.D3.API.Mesh.MESH_TYPE_SPHERE
}; };
} }
GameLib.D3.API.Mesh.Sphere.call( R3.D3.API.Mesh.Sphere.call(
this, this,
apiMeshSphere, apiMeshSphere,
apiMeshSphere.radius, apiMeshSphere.radius,
@ -25,17 +25,17 @@ GameLib.D3.Mesh.Sphere = function (
apiMeshSphere.heightSegments apiMeshSphere.heightSegments
); );
GameLib.D3.Mesh.call( R3.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
this this
); );
}; };
GameLib.D3.Mesh.Sphere.prototype = Object.create(GameLib.D3.Mesh.prototype); R3.D3.Mesh.Sphere.prototype = Object.create(R3.D3.Mesh.prototype);
GameLib.D3.Mesh.Sphere.prototype.constructor = GameLib.D3.Mesh.Sphere; R3.D3.Mesh.Sphere.prototype.constructor = R3.D3.Mesh.Sphere;
GameLib.D3.Mesh.Sphere.prototype.createInstance = function() { R3.D3.Mesh.Sphere.prototype.createInstance = function() {
var geometry = null; var geometry = null;
@ -48,10 +48,10 @@ GameLib.D3.Mesh.Sphere.prototype.createInstance = function() {
this.updateVerticesFromGeometryInstance(geometry); this.updateVerticesFromGeometryInstance(geometry);
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); R3.D3.Mesh.prototype.createInstance.call(this);
}; };
GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) { R3.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
if ( if (
property === 'radius' || property === 'radius' ||
@ -74,18 +74,18 @@ GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
return; return;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); R3.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh.Sphere to a GameLib.D3.API.Mesh.Sphere * Converts a R3.D3.Mesh.Sphere to a R3.D3.API.Mesh.Sphere
* @returns {GameLib.D3.API.Mesh.Sphere} * @returns {R3.D3.API.Mesh.Sphere}
*/ */
GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() { R3.D3.Mesh.Sphere.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshSphere = new GameLib.D3.API.Mesh.Sphere( var apiMeshSphere = new R3.D3.API.Mesh.Sphere(
apiMesh, apiMesh,
this.radius, this.radius,
this.widthSegments, this.widthSegments,
@ -95,41 +95,41 @@ GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() {
return apiMeshSphere; return apiMeshSphere;
}; };
GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() { R3.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
GameLib.Event.Emit( R3.Event.Emit(
GameLib.Event.GET_PHYSICS_RUNTIME, R3.Event.GET_PHYSICS_RUNTIME,
null, null,
function(physics){ function(physics){
var apiShapeSphere = new GameLib.D3.API.Shape( var apiShapeSphere = new R3.D3.API.Shape(
null, null,
'Sphere Shape (' + this.name + ')' 'Sphere Shape (' + this.name + ')'
); );
apiShapeSphere.parentMesh = this; apiShapeSphere.parentMesh = this;
var shapeSphere = new GameLib.D3.Shape.Sphere( var shapeSphere = new R3.D3.Shape.Sphere(
physics, physics,
apiShapeSphere, apiShapeSphere,
this.radius this.radius
); );
var apiRigidBody = new GameLib.D3.API.RigidBody( var apiRigidBody = new R3.D3.API.RigidBody(
null, null,
'Rigid Body (' + this.name + ')', 'Rigid Body (' + this.name + ')',
1, 1,
null, null,
new GameLib.API.Vector3( new R3.API.Vector3(
this.position.x, this.position.x,
this.position.y, this.position.y,
this.position.z this.position.z
), ),
new GameLib.API.Quaternion( new R3.API.Quaternion(
this.quaternion.x, this.quaternion.x,
this.quaternion.y, this.quaternion.y,
this.quaternion.z, this.quaternion.z,
this.quaternion.w, this.quaternion.w,
new GameLib.API.Vector3( new R3.API.Vector3(
this.quaternion.axis.x, this.quaternion.axis.x,
this.quaternion.axis.y, this.quaternion.axis.y,
this.quaternion.axis.z this.quaternion.axis.z
@ -142,12 +142,12 @@ GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
apiRigidBody.shapes.push(shapeSphere); apiRigidBody.shapes.push(shapeSphere);
var rigidBody = new GameLib.D3.RigidBody( var rigidBody = new R3.D3.RigidBody(
physics, physics,
apiRigidBody apiRigidBody
); );
if (this.parentEntity instanceof GameLib.Entity) { if (this.parentEntity instanceof R3.Entity) {
this.parentEntity.addComponent(shapeSphere); this.parentEntity.addComponent(shapeSphere);
this.parentEntity.addComponent(rigidBody); this.parentEntity.addComponent(rigidBody);
} }
@ -164,16 +164,16 @@ GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
}; };
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a R3.D3.Mesh
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Sphere.FromObject = function(graphics, objectMesh) { R3.D3.Mesh.Sphere.FromObject = function(graphics, objectMesh) {
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh); var apiMesh = R3.D3.API.Mesh.FromObject(objectMesh);
return new GameLib.D3.Mesh.Sphere( return new R3.D3.Mesh.Sphere(
graphics, graphics,
apiMesh, apiMesh,
objectMesh.radius, objectMesh.radius,

View File

@ -1,23 +1,23 @@
/** /**
* GameLib.D3.Mesh.Text * R3.D3.Mesh.Text
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiMeshText * @param apiMeshText
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Text = function ( R3.D3.Mesh.Text = function (
graphics, graphics,
apiMeshText apiMeshText
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshText)) { if (R3.Utils.UndefinedOrNull(apiMeshText)) {
apiMeshText = { apiMeshText = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT meshType : R3.D3.API.Mesh.MESH_TYPE_TEXT
}; };
} }
GameLib.D3.API.Mesh.Text.call( R3.D3.API.Mesh.Text.call(
this, this,
apiMeshText, apiMeshText,
apiMeshText.text, apiMeshText.text,
@ -31,24 +31,24 @@ GameLib.D3.Mesh.Text = function (
apiMeshText.bevelSegments apiMeshText.bevelSegments
); );
if (this.font instanceof GameLib.D3.API.Font) { if (this.font instanceof R3.D3.API.Font) {
this.font = new GameLib.D3.Font( this.font = new R3.D3.Font(
this.graphics, this.graphics,
this.font this.font
) )
} }
GameLib.D3.Mesh.call( R3.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
this this
); );
}; };
GameLib.D3.Mesh.Text.prototype = Object.create(GameLib.D3.Mesh.prototype); R3.D3.Mesh.Text.prototype = Object.create(R3.D3.Mesh.prototype);
GameLib.D3.Mesh.Text.prototype.constructor = GameLib.D3.Mesh.Text; R3.D3.Mesh.Text.prototype.constructor = R3.D3.Mesh.Text;
GameLib.D3.Mesh.Text.prototype.createInstance = function() { R3.D3.Mesh.Text.prototype.createInstance = function() {
var geometry = null; var geometry = null;
@ -71,10 +71,10 @@ GameLib.D3.Mesh.Text.prototype.createInstance = function() {
this.updateVerticesFromGeometryInstance(geometry); this.updateVerticesFromGeometryInstance(geometry);
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); R3.D3.Mesh.prototype.createInstance.call(this);
}; };
GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) { R3.D3.Mesh.Text.prototype.updateInstance = function(property) {
if ( if (
property === 'text' || property === 'text' ||
@ -111,19 +111,19 @@ GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
return; return;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); R3.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh.Text to a GameLib.D3.API.Mesh.Text * Converts a R3.D3.Mesh.Text to a R3.D3.API.Mesh.Text
* @returns {GameLib.D3.API.Mesh.Text} * @returns {R3.D3.API.Mesh.Text}
*/ */
GameLib.D3.Mesh.Text.prototype.toApiObject = function() { R3.D3.Mesh.Text.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshText = new GameLib.D3.API.Mesh.Text( var apiMeshText = new R3.D3.API.Mesh.Text(
apiMesh, apiMesh,
this.text, this.text,
this.font, this.font,

View File

@ -1,10 +1,10 @@
/** /**
* This component makes the parentEntity (ex. car) follow the path provided by the spline * This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param graphics GameLib.GraphicsRuntime * @param graphics R3.GraphicsRuntime
* @param apiPathFollowing GameLib.D3.API.PathFollowing * @param apiPathFollowing R3.D3.API.PathFollowing
* @constructor * @constructor
*/ */
GameLib.D3.PathFollowing = function ( R3.D3.PathFollowing = function (
graphics, graphics,
apiPathFollowing apiPathFollowing
) { ) {
@ -12,15 +12,15 @@ GameLib.D3.PathFollowing = function (
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiPathFollowing)) { if (R3.Utils.UndefinedOrNull(apiPathFollowing)) {
apiPathFollowing = {}; apiPathFollowing = {};
} }
if (apiPathFollowing instanceof GameLib.D3.PathFollowing) { if (apiPathFollowing instanceof R3.D3.PathFollowing) {
return apiPathFollowing; return apiPathFollowing;
} }
GameLib.D3.API.PathFollowing.call( R3.D3.API.PathFollowing.call(
this, this,
apiPathFollowing.id, apiPathFollowing.id,
apiPathFollowing.name, apiPathFollowing.name,
@ -46,99 +46,99 @@ GameLib.D3.PathFollowing = function (
apiPathFollowing.parentEntity apiPathFollowing.parentEntity
); );
this.baseOffset = new GameLib.Vector3( this.baseOffset = new R3.Vector3(
this.graphics, this.graphics,
this.baseOffset, this.baseOffset,
this this
); );
this.maxOffset = new GameLib.Vector3( this.maxOffset = new R3.Vector3(
this.graphics, this.graphics,
this.maxOffset, this.maxOffset,
this this
); );
this.targetOffset = new GameLib.Vector3( this.targetOffset = new R3.Vector3(
this.graphics, this.graphics,
this.targetOffset, this.targetOffset,
this this
); );
this.currentOffset = new GameLib.Vector3( this.currentOffset = new R3.Vector3(
this.graphics, this.graphics,
this.currentOffset, this.currentOffset,
this this
); );
this.raycaster = new GameLib.D3.Raycaster( this.raycaster = new R3.D3.Raycaster(
this.graphics, this.graphics,
this.raycaster this.raycaster
); );
this.currentPosition = new GameLib.Vector3( this.currentPosition = new R3.Vector3(
this.graphics, this.graphics,
this.currentPosition, this.currentPosition,
this this
); );
this.futurePosition = new GameLib.Vector3( this.futurePosition = new R3.Vector3(
this.graphics, this.graphics,
this.futurePosition, this.futurePosition,
this this
); );
this.up = new GameLib.Vector3( this.up = new R3.Vector3(
this.graphics, this.graphics,
this.up, this.up,
this this
); );
this.rotationMatrix = new GameLib.Matrix4( this.rotationMatrix = new R3.Matrix4(
this.graphics, this.graphics,
this.rotationMatrix, this.rotationMatrix,
this this
); );
this.rotationVector = new GameLib.Quaternion( this.rotationVector = new R3.Quaternion(
this.graphics, this.graphics,
this.rotationVector, this.rotationVector,
this this
); );
this.mx = new GameLib.Utils.MovingAverage(10); this.mx = new R3.Utils.MovingAverage(10);
this.my = new GameLib.Utils.MovingAverage(10); this.my = new R3.Utils.MovingAverage(10);
this.mz = new GameLib.Utils.MovingAverage(10); this.mz = new R3.Utils.MovingAverage(10);
GameLib.Component.call( R3.Component.call(
this, this,
GameLib.Component.COMPONENT_PATH_FOLLOWING, R3.Component.COMPONENT_PATH_FOLLOWING,
{ {
'spline': GameLib.D3.Spline, 'spline': R3.D3.Spline,
'mesh' : GameLib.D3.Mesh, 'mesh' : R3.D3.Mesh,
'raytraceMesh' : GameLib.D3.Mesh 'raytraceMesh' : R3.D3.Mesh
} }
); );
}; };
GameLib.D3.PathFollowing.prototype = Object.create(GameLib.D3.API.PathFollowing.prototype); R3.D3.PathFollowing.prototype = Object.create(R3.D3.API.PathFollowing.prototype);
GameLib.D3.PathFollowing.prototype.constructor = GameLib.D3.PathFollowing; R3.D3.PathFollowing.prototype.constructor = R3.D3.PathFollowing;
GameLib.D3.PathFollowing.prototype.createInstance = function() { R3.D3.PathFollowing.prototype.createInstance = function() {
console.log('GameLib.D3.PathFollowing.prototype.createInstance()'); console.log('R3.D3.PathFollowing.prototype.createInstance()');
GameLib.Component.prototype.createInstance.call(this); R3.Component.prototype.createInstance.call(this);
}; };
GameLib.D3.PathFollowing.prototype.toApiObject = function() { R3.D3.PathFollowing.prototype.toApiObject = function() {
var apiPathFollowing = new GameLib.D3.API.PathFollowing( var apiPathFollowing = new R3.D3.API.PathFollowing(
this.id, this.id,
this.name, this.name,
GameLib.Utils.IdOrNull(this.spline), R3.Utils.IdOrNull(this.spline),
GameLib.Utils.IdOrNull(this.mesh), R3.Utils.IdOrNull(this.mesh),
GameLib.Utils.IdOrNull(this.raytraceMesh), R3.Utils.IdOrNull(this.raytraceMesh),
this.accelleration, this.accelleration,
this.maxSpeed, this.maxSpeed,
this.baseOffset.toApiObject(), this.baseOffset.toApiObject(),
@ -155,24 +155,24 @@ GameLib.D3.PathFollowing.prototype.toApiObject = function() {
this.up.toApiObject(), this.up.toApiObject(),
this.rotationMatrix.toApiObject(), this.rotationMatrix.toApiObject(),
this.rotationVector.toApiObject(), this.rotationVector.toApiObject(),
GameLib.Utils.IdOrNull(this.parentEntity) R3.Utils.IdOrNull(this.parentEntity)
); );
return apiPathFollowing; return apiPathFollowing;
}; };
/** /**
* Object path following to GameLib.D3.PathFollowing * Object path following to R3.D3.PathFollowing
* @param graphics * @param graphics
* @param objectComponent * @param objectComponent
* @returns {GameLib.D3.PathFollowing} * @returns {R3.D3.PathFollowing}
* @constructor * @constructor
*/ */
GameLib.D3.PathFollowing.FromObject = function(graphics, objectComponent) { R3.D3.PathFollowing.FromObject = function(graphics, objectComponent) {
var apiPathFollowing = GameLib.D3.API.PathFollowing.FromObject(objectComponent); var apiPathFollowing = R3.D3.API.PathFollowing.FromObject(objectComponent);
return new GameLib.D3.PathFollowing( return new R3.D3.PathFollowing(
graphics, graphics,
apiPathFollowing apiPathFollowing
); );
@ -182,7 +182,7 @@ GameLib.D3.PathFollowing.FromObject = function(graphics, objectComponent) {
* Updates the component * Updates the component
* @param deltaTime * @param deltaTime
*/ */
GameLib.D3.PathFollowing.prototype.update = function(deltaTime) { R3.D3.PathFollowing.prototype.update = function(deltaTime) {
if (this.spline && this.mesh && this.raytraceMesh) { if (this.spline && this.mesh && this.raytraceMesh) {

View File

@ -2,12 +2,12 @@
* Physics SuperSet Namespace Object * Physics SuperSet Namespace Object
* @param id * @param id
* @param name * @param name
* @param engine GameLib.D3.Engine * @param engine R3.D3.Engine
* @param worlds * @param worlds
* @returns {{World: World}} * @returns {{World: World}}
* @constructor * @constructor
*/ */
GameLib.D3.Physics = function( R3.D3.Physics = function(
id, id,
name, name,
engine, engine,
@ -28,5 +28,5 @@ GameLib.D3.Physics = function(
* Solver Types * Solver Types
* @type {number} * @type {number}
*/ */
GameLib.D3.Physics.SPLIT_SOLVER = 0x1; R3.D3.Physics.SPLIT_SOLVER = 0x1;
GameLib.D3.Physics.GS_SOLVER = 0x2; R3.D3.Physics.GS_SOLVER = 0x2;

View File

@ -1,11 +1,11 @@
/** /**
* Raycast Vehicles :) * Raycast Vehicles :)
* @param engine GameLib.D3.Engine * @param engine R3.D3.Engine
* @param chassisBody GameLib.D3.RigidBody * @param chassisBody R3.D3.RigidBody
* @param wheels GameLib.D3.RaycastWheel[] * @param wheels R3.D3.RaycastWheel[]
* @constructor * @constructor
*/ */
GameLib.D3.RaycastVehicle = function( R3.D3.RaycastVehicle = function(
engine, engine,
chassisBody, chassisBody,
wheels, wheels,
@ -14,7 +14,7 @@ GameLib.D3.RaycastVehicle = function(
this.engine = engine; this.engine = engine;
this.engine.isNotCannonThrow(); this.engine.isNotCannonThrow();
this.id = GameLib.Utils.RandomId(); this.id = R3.Utils.RandomId();
this.chassisBody = chassisBody; this.chassisBody = chassisBody;
@ -23,21 +23,21 @@ GameLib.D3.RaycastVehicle = function(
} }
this.wheels = wheels; this.wheels = wheels;
if(GameLib.Utils.UndefinedOrNull(wheelBodies)) { if(R3.Utils.UndefinedOrNull(wheelBodies)) {
wheelBodies = []; wheelBodies = [];
} }
this.wheelBodies = wheelBodies; this.wheelBodies = wheelBodies;
this.instance = this.createInstance(); this.instance = this.createInstance();
GameLib.Utils.Extend(GameLib.D3.RaycastVehicle, GameLib.Component); R3.Utils.Extend(R3.D3.RaycastVehicle, R3.Component);
}; };
/** /**
* private * private
* @returns {GameLib.D3.RaycastVehicle|GameLib.D3.Physics.RaycastVehicle|*} * @returns {R3.D3.RaycastVehicle|R3.D3.Physics.RaycastVehicle|*}
*/ */
GameLib.D3.RaycastVehicle.prototype.createInstance = function() { R3.D3.RaycastVehicle.prototype.createInstance = function() {
return new this.engine.instance.RaycastVehicle({ return new this.engine.instance.RaycastVehicle({
chassisBody: this.chassisBody.instance chassisBody: this.chassisBody.instance
}); });
@ -45,10 +45,10 @@ GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
/** /**
* Adds a raycast wheel to this vehicle * Adds a raycast wheel to this vehicle
* @param wheel GameLib.D3.RaycastWheel * @param wheel R3.D3.RaycastWheel
* @param wheelRigidBody GameLib.D3.RigidBody * @param wheelRigidBody R3.D3.RigidBody
*/ */
GameLib.D3.RaycastVehicle.prototype.addWheel = function ( R3.D3.RaycastVehicle.prototype.addWheel = function (
wheel, wheel,
wheelRigidBody wheelRigidBody
) { ) {
@ -62,14 +62,14 @@ GameLib.D3.RaycastVehicle.prototype.addWheel = function (
* @returns {*} * @returns {*}
* @constructor * @constructor
*/ */
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() { R3.D3.RaycastVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelInfos; return this.instance.wheelInfos;
}; };
// Override component methods // // Override component methods //
GameLib.D3.RaycastVehicle.prototype.onUpdate = function( R3.D3.RaycastVehicle.prototype.onUpdate = function(
deltaTime, deltaTime,
parentEntity parentEntity
) { ) {
@ -82,7 +82,7 @@ GameLib.D3.RaycastVehicle.prototype.onUpdate = function(
} }
}; };
GameLib.D3.RaycastVehicle.prototype.onRegistered = function( R3.D3.RaycastVehicle.prototype.onRegistered = function(
parentScene parentScene
) { ) {

View File

@ -1,4 +1,4 @@
GameLib.D3.RaycastWheel = function( R3.D3.RaycastWheel = function(
engine, engine,
chassisConnectionPointLocal, chassisConnectionPointLocal,
chassisConnectionPointWorld, chassisConnectionPointWorld,
@ -30,7 +30,7 @@ GameLib.D3.RaycastWheel = function(
this.engine = engine; this.engine = engine;
this.engine.isNotCannonThrow(); this.engine.isNotCannonThrow();
this.id = GameLib.Utils.RandomId(); this.id = R3.Utils.RandomId();
if(typeof chassisConnectionPointLocal == 'undefined' || chassisConnectionPointLocal == null) { if(typeof chassisConnectionPointLocal == 'undefined' || chassisConnectionPointLocal == null) {
chassisConnectionPointLocal = new this.engine.instance.Vec3(); chassisConnectionPointLocal = new this.engine.instance.Vec3();
@ -168,7 +168,7 @@ GameLib.D3.RaycastWheel = function(
this.wheelIndex = -1; this.wheelIndex = -1;
}; };
GameLib.D3.RaycastWheel.prototype.createInstance = function() { R3.D3.RaycastWheel.prototype.createInstance = function() {
return { return {
chassisConnectionPointLocal : this.chassisConnectionPointLocal, chassisConnectionPointLocal : this.chassisConnectionPointLocal,
chassisConnectionPointWorld : this.chassisConnectionPointWorld, chassisConnectionPointWorld : this.chassisConnectionPointWorld,

View File

@ -1,16 +1,16 @@
/** /**
* Physics Rigid Body Vehicle Superset * Physics Rigid Body Vehicle Superset
* @param engine GameLib.D3.Engine * @param engine R3.D3.Engine
* @param chassisBody GameLib.D3.RigidBody * @param chassisBody R3.D3.RigidBody
* @param wheels GameLib.D3.RigidWheel[] * @param wheels R3.D3.RigidWheel[]
* @constructor * @constructor
*/ */
GameLib.D3.RigidBodyVehicle = function( R3.D3.RigidBodyVehicle = function(
engine, engine,
chassisBody, chassisBody,
wheels wheels
) { ) {
this.id = GameLib.Utils.RandomId(); this.id = R3.Utils.RandomId();
this.engine = engine; this.engine = engine;
this.engine.isNotCannonThrow(); this.engine.isNotCannonThrow();
@ -28,15 +28,15 @@ GameLib.D3.RigidBodyVehicle = function(
* Returns physics wheelbody info (for updates) * Returns physics wheelbody info (for updates)
* @returns {Array} * @returns {Array}
*/ */
GameLib.D3.RigidBodyVehicle.prototype.getWheelInfo = function() { R3.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelBodies; return this.instance.wheelBodies;
}; };
/** /**
* *
* @returns {GameLib.D3.RigidVehicle} * @returns {R3.D3.RigidVehicle}
*/ */
GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() { R3.D3.RigidBodyVehicle.prototype.createInstance = function() {
return new this.engine.instance.RigidVehicle({ return new this.engine.instance.RigidVehicle({
chassisBody: this.chassisBody.instance chassisBody: this.chassisBody.instance
}); });
@ -44,9 +44,9 @@ GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
/** /**
* Adds a wheel to this rigid body vehicle * Adds a wheel to this rigid body vehicle
* @param wheel GameLib.D3.RigidWheel * @param wheel R3.D3.RigidWheel
*/ */
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) { R3.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
this.wheels.push(wheel); this.wheels.push(wheel);

View File

@ -1,6 +1,6 @@
/** /**
* RigidBody Superset * RigidBody Superset
* @param engine GameLib.D3.Engine * @param engine R3.D3.Engine
* @param mass * @param mass
* @param friction * @param friction
* @param position * @param position
@ -15,12 +15,12 @@
* @param collisionFilterGroup * @param collisionFilterGroup
* @param collisionFilterMask * @param collisionFilterMask
* @param fixedRotation * @param fixedRotation
* @param shape GameLib.D3.Shape * @param shape R3.D3.Shape
* @param kinematic Boolean * @param kinematic Boolean
* @returns {GameLib.D3.Physics.RigidBody} * @returns {R3.D3.Physics.RigidBody}
* @constructor * @constructor
*/ */
GameLib.D3.RigidBody = function( R3.D3.RigidBody = function(
engine, engine,
mass, mass,
friction, friction,
@ -39,11 +39,11 @@ GameLib.D3.RigidBody = function(
shape, shape,
kinematic kinematic
) { ) {
this.id = GameLib.Utils.RandomId(); this.id = R3.Utils.RandomId();
this.position = position || new GameLib.API.Vector3(); this.position = position || new R3.API.Vector3();
this.velocity = velocity || new GameLib.API.Vector3(); this.velocity = velocity || new R3.API.Vector3();
this.angularVelocity = angularVelocity || new GameLib.API.Vector3(); this.angularVelocity = angularVelocity || new R3.API.Vector3();
this.quaternion = quaternion || new GameLib.API.Quaternion(0, 0, 0, 1); this.quaternion = quaternion || new R3.API.Quaternion(0, 0, 0, 1);
this.mass = typeof mass == "undefined" ? 0 : mass; this.mass = typeof mass == "undefined" ? 0 : mass;
this.friction = typeof friction == "undefined" ? 5 : friction; this.friction = typeof friction == "undefined" ? 5 : friction;
this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping; this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping;
@ -62,14 +62,14 @@ GameLib.D3.RigidBody = function(
this.instance = this.createInstance(); this.instance = this.createInstance();
// Todo: this should be executed somewhere in r3-z, so that we don't execute it on every construction of an object. // Todo: this should be executed somewhere in r3-z, so that we don't execute it on every construction of an object.
GameLib.Utils.Extend(GameLib.D3.RigidBody, GameLib.Component); R3.Utils.Extend(R3.D3.RigidBody, R3.Component);
}; };
/** /**
* private function * private function
* @returns {*} * @returns {*}
*/ */
GameLib.D3.RigidBody.prototype.createInstance = function() { R3.D3.RigidBody.prototype.createInstance = function() {
var instance = new this.engine.instance.Body({ var instance = new this.engine.instance.Body({
mass: this.mass, mass: this.mass,
@ -111,28 +111,28 @@ GameLib.D3.RigidBody.prototype.createInstance = function() {
return instance; return instance;
}; };
GameLib.D3.RigidBody.prototype.toApiRigidBody = function() { R3.D3.RigidBody.prototype.toApiRigidBody = function() {
return null; return null;
}; };
/** /**
* Adds a shape to this rigid body * Adds a shape to this rigid body
* @param shape GameLib.D3.Shape * @param shape R3.D3.Shape
* @param offset GameLib.API.Vector3 * @param offset R3.API.Vector3
* @param orientation GameLib.API.Quaternion * @param orientation R3.API.Quaternion
* @constructor * @constructor
*/ */
GameLib.D3.RigidBody.prototype.addShape = function( R3.D3.RigidBody.prototype.addShape = function(
shape, shape,
offset, offset,
orientation orientation
) { ) {
if (!offset || typeof offset == 'undefined') { if (!offset || typeof offset == 'undefined') {
offset = new GameLib.API.Vector3(0,0,0); offset = new R3.API.Vector3(0,0,0);
} }
if (!orientation || typeof orientation == 'undefined') { if (!orientation || typeof orientation == 'undefined') {
orientation = new GameLib.API.Quaternion(0,0,0,1); orientation = new R3.API.Quaternion(0,0,0,1);
} }
this.instance.addShape( this.instance.addShape(
@ -152,7 +152,7 @@ GameLib.D3.RigidBody.prototype.addShape = function(
}; };
///////////////////////// Methods to override ////////////////////////// ///////////////////////// Methods to override //////////////////////////
GameLib.D3.RigidBody.prototype.onUpdate = function( R3.D3.RigidBody.prototype.onUpdate = function(
deltaTime, deltaTime,
parentEntity parentEntity
) { ) {

20
bak/r3-d3-rigid-wheel.js Normal file
View File

@ -0,0 +1,20 @@
/**
* Rigid Wheel superset
* @param body R3.D3.RigidBody
* @param position R3.API.Vector3
* @param axis R3.API.Vector3
* @param direction R3.API.Vector3
* @constructor
*/
R3.D3.RigidWheel = function(
body,
position,
axis,
direction
) {
this.id = R3.Utils.RandomId();
this.body = body;
this.position = position;
this.axis = axis;
this.direction = direction;
};

View File

@ -1,12 +1,12 @@
/** /**
* Selected Objects * Selected Objects
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param object * @param object
* @param helper * @param helper
* @param lastUpdate * @param lastUpdate
* @constructor * @constructor
*/ */
GameLib.D3.SelectedObject = function SelectedObject( R3.D3.SelectedObject = function SelectedObject(
graphics, graphics,
object, object,
helper, helper,
@ -15,14 +15,14 @@ GameLib.D3.SelectedObject = function SelectedObject(
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(object)) { if (R3.Utils.UndefinedOrNull(object)) {
console.warn('Cannot select no object'); console.warn('Cannot select no object');
throw new Error('Cannot select no object'); throw new Error('Cannot select no object');
} }
this.object = object; this.object = object;
if (GameLib.Utils.UndefinedOrNull(helper)) { if (R3.Utils.UndefinedOrNull(helper)) {
helper = new GameLib.D3.Helper( helper = new R3.D3.Helper(
this.graphics, this.graphics,
null, null,
null, null,
@ -31,7 +31,7 @@ GameLib.D3.SelectedObject = function SelectedObject(
} }
this.helper = helper; this.helper = helper;
if (GameLib.Utils.UndefinedOrNull(lastUpdate)) { if (R3.Utils.UndefinedOrNull(lastUpdate)) {
lastUpdate = Date.now(); lastUpdate = Date.now();
} }
this.lastUpdate = lastUpdate; this.lastUpdate = lastUpdate;

View File

@ -1,21 +1,21 @@
/** /**
* Physics Shape Superset * Physics Shape Superset
* @param engine GameLib.D3.Engine * @param engine R3.D3.Engine
* @param shapeType * @param shapeType
* @param scale GameLib.API.Vector3 * @param scale R3.API.Vector3
* @param vertices Number[] * @param vertices Number[]
* @param indices Number[] * @param indices Number[]
* @param radius Number * @param radius Number
* @param halfExtensions GameLib.API.Vector3 * @param halfExtensions R3.API.Vector3
* @param radiusTop Number * @param radiusTop Number
* @param radiusBottom Number * @param radiusBottom Number
* @param height Number * @param height Number
* @param numSegments Number * @param numSegments Number
* @param heightmap GameLib.D3.Heightmap * @param heightmap R3.D3.Heightmap
* @param elementSize * @param elementSize
* @constructor * @constructor
*/ */
GameLib.D3.Shape = function( R3.D3.Shape = function(
engine, engine,
shapeType, shapeType,
scale, scale,
@ -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.API.Vector3(1, 1, 1) scale = new R3.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.API.Vector3(1,1,1); halfExtensions = new R3.API.Vector3(1,1,1);
} }
this.halfExtensions = halfExtensions; this.halfExtensions = halfExtensions;
@ -82,7 +82,7 @@ GameLib.D3.Shape = function(
this.numSegments = numSegments; this.numSegments = numSegments;
if (typeof heightmap == 'undefined') { if (typeof heightmap == 'undefined') {
heightmap = new GameLib.D3.Heightmap(); heightmap = new R3.D3.Heightmap();
} }
this.heightmap = heightmap; this.heightmap = heightmap;
@ -93,37 +93,37 @@ GameLib.D3.Shape = function(
* Shape constants * Shape constants
* @type {number} * @type {number}
*/ */
GameLib.D3.Shape.SHAPE_TYPE_SPHERE = 1; R3.D3.Shape.SHAPE_TYPE_SPHERE = 1;
GameLib.D3.Shape.SHAPE_TYPE_BOX = 2; R3.D3.Shape.SHAPE_TYPE_BOX = 2;
GameLib.D3.Shape.SHAPE_TYPE_TRIMESH = 3; R3.D3.Shape.SHAPE_TYPE_TRIMESH = 3;
GameLib.D3.Shape.SHAPE_TYPE_CYLINDER = 4; R3.D3.Shape.SHAPE_TYPE_CYLINDER = 4;
GameLib.D3.Shape.SHAPE_TYPE_HEIGHT_MAP = 5; R3.D3.Shape.SHAPE_TYPE_HEIGHT_MAP = 5;
GameLib.D3.Shape.SHAPE_TYPE_CONVEX_HULL = 6; R3.D3.Shape.SHAPE_TYPE_CONVEX_HULL = 6;
GameLib.D3.Shape.SHAPE_TYPE_PLANE = 7; R3.D3.Shape.SHAPE_TYPE_PLANE = 7;
/** /**
* *
*/ */
GameLib.D3.Shape.prototype.createInstance = function() { R3.D3.Shape.prototype.createInstance = function() {
var instance = null; var instance = null;
if (this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_TRIMESH) { if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_TRIMESH) {
} else if (this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_SPHERE) {; } else if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_SPHERE) {;
} else if (this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_BOX) { } else if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_BOX) {
} else if (this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_CYLINDER) { } else if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_CYLINDER) {
} else if (this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_HEIGHT_MAP) { } else if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_HEIGHT_MAP) {
} else if (this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_CONVEX_HULL) { } else if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_CONVEX_HULL) {
instance = new this.engine.instance.ConvexPolyhedron( instance = new this.engine.instance.ConvexPolyhedron(
this.vertices, this.indices this.vertices, this.indices
); );
} else if(this.shapeType == GameLib.D3.Shape.SHAPE_TYPE_PLANE) { } else if(this.shapeType == R3.D3.Shape.SHAPE_TYPE_PLANE) {
instance = new this.engine.instance.Plane(); instance = new this.engine.instance.Plane();
} else { } else {
console.warn('Shape type not implemented: ' + this.shapeType); console.warn('Shape type not implemented: ' + this.shapeType);
@ -139,12 +139,12 @@ GameLib.D3.Shape.prototype.createInstance = function() {
/** /**
* update * update
*/ */
GameLib.D3.Shape.prototype.update = function( R3.D3.Shape.prototype.update = function(
engine engine
) { ) {
engine.isNotCannonThrow(); engine.isNotCannonThrow();
if(this.shapeType === GameLib.D3.Shape.SHAPE_TYPE_TRIMESH) { if(this.shapeType === R3.D3.Shape.SHAPE_TYPE_TRIMESH) {
this.instance.setScale( this.instance.setScale(
new engine.instance.Vec3( new engine.instance.Vec3(
this.scale.x, this.scale.x,
@ -161,12 +161,12 @@ GameLib.D3.Shape.prototype.update = function(
}; };
/** /**
* Converts a GameLib.D3.Shape to a GameLib.D3.API.Shape * Converts a R3.D3.Shape to a R3.D3.API.Shape
* @returns {GameLib.D3.API.Shape} * @returns {R3.D3.API.Shape}
*/ */
GameLib.D3.Shape.prototype.toApiShape = function() { R3.D3.Shape.prototype.toApiShape = function() {
return new GameLib.D3.API.Shape( return new R3.D3.API.Shape(
this.engine.toApiEngine(), this.engine.toApiEngine(),
this.shapeType, this.shapeType,
this.scale.toApiVector(), this.scale.toApiVector(),
@ -185,11 +185,11 @@ GameLib.D3.Shape.prototype.toApiShape = function() {
/** /**
* Converts from an Object to a Shape * Converts from an Object to a Shape
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param objectShape Object * @param objectShape Object
* @constructor * @constructor
*/ */
GameLib.D3.Shape.FromObjectShape = function(graphics, objectShape) { R3.D3.Shape.FromObjectShape = function(graphics, objectShape) {
//todo: implement this still //todo: implement this still
return null; return null;
}; };

View File

@ -1,4 +1,4 @@
GameLib.D3.SkyBox = function ( R3.D3.SkyBox = function (
graphics graphics
) { ) {
this.id = null; this.id = null;
@ -9,7 +9,7 @@ GameLib.D3.SkyBox = function (
this.texturesFolder = null; this.texturesFolder = null;
}; };
GameLib.D3.SkyBox.prototype.load = function ( R3.D3.SkyBox.prototype.load = function (
texturesFolder texturesFolder
) { ) {
this.texturesFolder = texturesFolder; this.texturesFolder = texturesFolder;
@ -49,7 +49,7 @@ GameLib.D3.SkyBox.prototype.load = function (
]); ]);
}; };
GameLib.D3.SkyBox.prototype.render = function ( R3.D3.SkyBox.prototype.render = function (
threeRenderer, threeRenderer,
threeCamera threeCamera
) { ) {

View File

@ -9,7 +9,7 @@
* @param rigidBodies * @param rigidBodies
* @constructor * @constructor
*/ */
GameLib.D3.World = function( R3.D3.World = function(
id, id,
name, name,
engine, engine,
@ -24,25 +24,25 @@ GameLib.D3.World = function(
this.name = name; this.name = name;
if (typeof gravity == 'undefined') { if (typeof gravity == 'undefined') {
gravity = new GameLib.API.Vector3(0, -9.81, 0); gravity = new R3.API.Vector3(0, -9.81, 0);
} }
this.gravity = gravity; this.gravity = gravity;
if (typeof broadphase == 'undefined') { if (typeof broadphase == 'undefined') {
broadphase = new GameLib.D3.Broadphase( broadphase = new R3.D3.Broadphase(
null, null,
'broadPhaseNaive', 'broadPhaseNaive',
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE, R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
engine engine
); );
} }
this.broadphase = broadphase; this.broadphase = broadphase;
if (typeof solver == 'undefined') { if (typeof solver == 'undefined') {
solver = new GameLib.D3.Solver( solver = new R3.D3.Solver(
null, null,
engine, engine,
GameLib.D3.Solver.GS_SOLVER R3.D3.Solver.GS_SOLVER
); );
} }
this.solver = solver; this.solver = solver;
@ -61,9 +61,9 @@ GameLib.D3.World = function(
/** /**
* private * private
* @returns {GameLib.D3.World|GameLib.D3.Physics.World|*} * @returns {R3.D3.World|R3.D3.Physics.World|*}
*/ */
GameLib.D3.World.prototype.createInstance = function() { R3.D3.World.prototype.createInstance = function() {
var instance = new this.engine.instance.World(); var instance = new this.engine.instance.World();
@ -80,7 +80,7 @@ GameLib.D3.World.prototype.createInstance = function() {
return instance; return instance;
}; };
GameLib.D3.World.prototype.toApiWorld = function() { R3.D3.World.prototype.toApiWorld = function() {
//TODO: create API.World someday //TODO: create API.World someday
return { return {
id: this.id, id: this.id,
@ -94,10 +94,10 @@ GameLib.D3.World.prototype.toApiWorld = function() {
}; };
GameLib.D3.World.FromObjectWorld = function(engine, objectWorld) { R3.D3.World.FromObjectWorld = function(engine, objectWorld) {
//todo implement this fully //todo implement this fully
return new GameLib.D3.World( return new R3.D3.World(
objectWorld.id, objectWorld.id,
objectWorld.name, objectWorld.name,
engine, engine,
@ -110,10 +110,10 @@ GameLib.D3.World.FromObjectWorld = function(engine, objectWorld) {
/** /**
* *
* @param rigidBody GameLib.D3.RigidBody * @param rigidBody R3.D3.RigidBody
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.addRigidBody = function( R3.D3.World.prototype.addRigidBody = function(
rigidBody rigidBody
) { ) {
this.instance.addBody(rigidBody.instance); this.instance.addBody(rigidBody.instance);
@ -121,16 +121,16 @@ GameLib.D3.World.prototype.addRigidBody = function(
/** /**
* *
* @param vehicle (GameLib.D3.RigidBodyVehicle | GameLib.D3.RaycastVehicle) * @param vehicle (R3.D3.RigidBodyVehicle | R3.D3.RaycastVehicle)
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.addVehicle = function( R3.D3.World.prototype.addVehicle = function(
vehicle vehicle
) { ) {
vehicle.instance.addToWorld(this.instance); vehicle.instance.addToWorld(this.instance);
}; };
GameLib.D3.World.prototype.step = function( R3.D3.World.prototype.step = function(
fixedStep, fixedStep,
dtStep dtStep
) { ) {
@ -153,11 +153,11 @@ GameLib.D3.World.prototype.step = function(
this.lastCallTime = now; this.lastCallTime = now;
}; };
GameLib.D3.World.prototype.GetIndexedVertices = function( R3.D3.World.prototype.GetIndexedVertices = function(
triangleMeshShape triangleMeshShape
) { ) {
if(this.engine.engineType == GameLib.D3.Physics.TYPE_CANNON) { if(this.engine.engineType == R3.D3.Physics.TYPE_CANNON) {
return { return {
vertices : triangleMeshShape.vertices, vertices : triangleMeshShape.vertices,
@ -172,16 +172,16 @@ GameLib.D3.World.prototype.GetIndexedVertices = function(
}; };
/** /**
* @param triangleMeshShape GameLib.D3.Shape * @param triangleMeshShape R3.D3.Shape
* @param normalLength Number * @param normalLength Number
* @param scale GameLib.API.Vector3 * @param scale R3.API.Vector3
* @param opacity Number * @param opacity Number
* @param wireframeColor HexCode * @param wireframeColor HexCode
* @param graphics THREE * @param graphics THREE
* @returns {THREE.Mesh|this.meshes} * @returns {THREE.Mesh|this.meshes}
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.generateWireframeViewTriangleMesh = function( R3.D3.World.prototype.generateWireframeViewTriangleMesh = function(
graphics, graphics,
triangleMeshShape, triangleMeshShape,
normalLength, normalLength,
@ -279,16 +279,16 @@ GameLib.D3.World.prototype.generateWireframeViewTriangleMesh = function(
}; };
/** /**
* @param convexPolyMeshShape GameLib.D3.Shape * @param convexPolyMeshShape R3.D3.Shape
* @param normalLength Number * @param normalLength Number
* @param scale GameLib.API.Vector3 * @param scale R3.API.Vector3
* @param opacity Number * @param opacity Number
* @param wireframeColor HexCode * @param wireframeColor HexCode
* @param graphics THREE * @param graphics THREE
* @returns {THREE.Mesh|this.meshes} * @returns {THREE.Mesh|this.meshes}
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.generateWireframeViewConvexPolyMesh = function( R3.D3.World.prototype.generateWireframeViewConvexPolyMesh = function(
graphics, graphics,
convexPolyMeshShape, convexPolyMeshShape,
normalLength, normalLength,
@ -376,7 +376,7 @@ GameLib.D3.World.prototype.generateWireframeViewConvexPolyMesh = function(
}; };
/** /**
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param graphicsMesh THREE.Mesh * @param graphicsMesh THREE.Mesh
* @param mass Number * @param mass Number
* @param friction Number * @param friction Number
@ -386,7 +386,7 @@ GameLib.D3.World.prototype.generateWireframeViewConvexPolyMesh = function(
* @returns {Object} * @returns {Object}
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function( R3.D3.World.prototype.generateTriangleMeshShapeDivided = function(
graphics, graphics,
graphicsMesh, graphicsMesh,
mass, mass,
@ -477,7 +477,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
} }
}; };
GameLib.D3.World.prototype.generateConvexPolyShape = function( R3.D3.World.prototype.generateConvexPolyShape = function(
graphics, graphics,
mesh mesh
) { ) {
@ -503,9 +503,9 @@ GameLib.D3.World.prototype.generateConvexPolyShape = function(
convexVertices[vert] = new CANNON.Vec3(vertices[vert * 3] * mesh.scale.x, vertices[vert * 3 + 1] * mesh.scale.y, vertices[vert * 3 + 2] * mesh.scale.z); convexVertices[vert] = new CANNON.Vec3(vertices[vert * 3] * mesh.scale.x, vertices[vert * 3 + 1] * mesh.scale.y, vertices[vert * 3 + 2] * mesh.scale.z);
} }
var meshShape = new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_CONVEX_HULL, {x:1,y:1,z:1},convexVertices, convexIndices); var meshShape = new R3.D3.Shape(this.engine, R3.D3.Shape.SHAPE_TYPE_CONVEX_HULL, {x:1,y:1,z:1},convexVertices, convexIndices);
var body = new GameLib.D3.RigidBody(this.engine, 0, 1); var body = new R3.D3.RigidBody(this.engine, 0, 1);
body.addShape(meshShape); body.addShape(meshShape);
this.addRigidBody(body); this.addRigidBody(body);
@ -540,12 +540,12 @@ GameLib.D3.World.prototype.generateConvexPolyShape = function(
}; };
/** /**
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param graphicsMesh THREE.Mesh * @param graphicsMesh THREE.Mesh
* @returns {GameLib.D3.Shape} * @returns {R3.D3.Shape}
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.generateTriangleMeshShape = function( R3.D3.World.prototype.generateTriangleMeshShape = function(
graphics, graphics,
graphicsMesh graphicsMesh
) { ) {
@ -618,21 +618,21 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
processedFaces++; processedFaces++;
} }
return new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, {x : 1, y : 1, z : 1}, vertices, faces); return new R3.D3.Shape(this.engine, R3.D3.Shape.SHAPE_TYPE_TRIMESH, {x : 1, y : 1, z : 1}, vertices, faces);
}; };
/** /**
* @param triangleMeshBody GameLib.D3.RigidBody * @param triangleMeshBody R3.D3.RigidBody
* @param rayscale Number * @param rayscale Number
* @param maxTriangleDistance Number * @param maxTriangleDistance Number
* @param createCompoundShape Boolean * @param createCompoundShape Boolean
* @param graphics GameLib.D3.Graphics * @param graphics R3.D3.Graphics
* @param triangleMeshShapes GameLib.D3.Shape[] * @param triangleMeshShapes R3.D3.Shape[]
* @param createDebugView Boolean * @param createDebugView Boolean
* @returns {GameLib.D3.RigidBody} * @returns {R3.D3.RigidBody}
* @constructor * @constructor
*/ */
GameLib.D3.World.prototype.fixupTriangleMeshShape = function( R3.D3.World.prototype.fixupTriangleMeshShape = function(
triangleMeshBody, triangleMeshBody,
triangleMeshShapes, triangleMeshShapes,
rayscale, rayscale,
@ -870,13 +870,13 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
for(var e in bFaceIndexed) { for(var e in bFaceIndexed) {
var element = bFaceIndexed[e]; var element = bFaceIndexed[e];
var shape = new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, { x : 1, y : 1, z : 1 }, element.vertices, element.indices); var shape = new R3.D3.Shape(this.engine, R3.D3.Shape.SHAPE_TYPE_TRIMESH, { x : 1, y : 1, z : 1 }, element.vertices, element.indices);
if(createCompoundShape) { if(createCompoundShape) {
triangleMeshBody.addShape(shape); triangleMeshBody.addShape(shape);
} else { } else {
var body = new GameLib.D3.RigidBody(this.engine, 0, 12); var body = new R3.D3.RigidBody(this.engine, 0, 12);
//TODO: this is just a hack. //TODO: this is just a hack.
body.instance.collisionFilterGroup = 1 | 2; // puts this body in two groups. body.instance.collisionFilterGroup = 1 | 2; // puts this body in two groups.

View File

@ -4,7 +4,7 @@
* @param document DOM Document * @param document DOM Document
* @param window DOM Window * @param window DOM Window
*/ */
GameLib.Dom = function( R3.Dom = function(
document, document,
window window
) { ) {

View File

@ -1,11 +1,11 @@
/** /**
* Matrix 3 Maths * Matrix 3 Maths
* @param row0 GameLib.API.Vector3 * @param row0 R3.API.Vector3
* @param row1 GameLib.API.Vector3 * @param row1 R3.API.Vector3
* @param row2 GameLib.API.Vector3 * @param row2 R3.API.Vector3
* @constructor * @constructor
*/ */
GameLib.Matrix3 = function( R3.Matrix3 = function(
row0, row0,
row1, row1,
row2 row2
@ -28,10 +28,10 @@ GameLib.Matrix3 = function(
/** /**
* Set matrix to identity * Set matrix to identity
*/ */
GameLib.Matrix3.prototype.identity = function () { R3.Matrix3.prototype.identity = function () {
this.rows = [ this.rows = [
new GameLib.API.Vector3(1, 0, 0), new R3.API.Vector3(1, 0, 0),
new GameLib.API.Vector3(0, 1, 0), new R3.API.Vector3(0, 1, 0),
new GameLib.API.Vector3(0, 0, 1) new R3.API.Vector3(0, 0, 1)
]; ];
}; };

View File

@ -30,7 +30,7 @@ gulp.task(
) )
) )
.pipe( .pipe(
replace(new RegExp('GameLib.D3.Utils.Extend\\(.*?\\);', 'g'), function (replacement) { replace(new RegExp('R3.D3.Utils.Extend\\(.*?\\);', 'g'), function (replacement) {
__EXTENDS__ += replacement + "\n"; __EXTENDS__ += replacement + "\n";
return "//" + replacement; return "//" + replacement;
}) })

View File

@ -3,13 +3,13 @@ var chai = require('chai'),
sinonChai = require("sinon-chai"), sinonChai = require("sinon-chai"),
config = require('../config.js'), config = require('../config.js'),
assert = chai.assert, assert = chai.assert,
GameLib = require('../build/r3'), R3 = require('../build/r3'),
CANNON = require('cannon'), CANNON = require('cannon'),
THREE = require('three'); THREE = require('three');
chai.use(sinonChai); chai.use(sinonChai);
describe('GameLib object creation', function(){ describe('R3 object creation', function(){
this.timeout(0); this.timeout(0);
@ -38,18 +38,18 @@ describe('GameLib object creation', function(){
it('Should create a Bone object', function (done) { it('Should create a Bone object', function (done) {
var bone = new GameLib.D3.Bone( var bone = new R3.D3.Bone(
null, null,
1, 1,
'test bone 1', 'test bone 1',
[2, 3, 4] [2, 3, 4]
); );
assert(bone.position instanceof GameLib.D3.Vector3); assert(bone.position instanceof R3.D3.Vector3);
assert(bone.rotation instanceof GameLib.D3.Vector3); assert(bone.rotation instanceof R3.D3.Vector3);
assert(bone.scale instanceof GameLib.D3.Vector3); assert(bone.scale instanceof R3.D3.Vector3);
assert(bone.up instanceof GameLib.D3.Vector3); assert(bone.up instanceof R3.D3.Vector3);
assert(bone.quaternion instanceof GameLib.D3.Vector4); assert(bone.quaternion instanceof R3.D3.Vector4);
assert(bone.parentBoneId == null); assert(bone.parentBoneId == null);
assert.deepEqual(bone.childBoneIds, [2,3,4]); assert.deepEqual(bone.childBoneIds, [2,3,4]);
@ -58,7 +58,7 @@ describe('GameLib object creation', function(){
it('Should create a BoneWeight object', function (done) { it('Should create a BoneWeight object', function (done) {
var boneWeight = new GameLib.D3.BoneWeight( var boneWeight = new R3.D3.BoneWeight(
1, 1,
0.5 0.5
); );
@ -71,34 +71,34 @@ describe('GameLib object creation', function(){
it('Should create a Broadphase object', function (done) { it('Should create a Broadphase object', function (done) {
var engine = new GameLib.D3.Engine( var engine = new R3.D3.Engine(
GameLib.D3.Engine.ENGINE_TYPE_CANNON, R3.D3.Engine.ENGINE_TYPE_CANNON,
CANNON CANNON
); );
assert(engine.engineType == GameLib.D3.Engine.ENGINE_TYPE_CANNON); assert(engine.engineType == R3.D3.Engine.ENGINE_TYPE_CANNON);
assert(engine.instance instanceof Object); assert(engine.instance instanceof Object);
var broadphase = new GameLib.D3.Broadphase( var broadphase = new R3.D3.Broadphase(
null, null,
'broad-phase', 'broad-phase',
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE, R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
engine, engine,
true true
); );
assert(broadphase.id == null); assert(broadphase.id == null);
assert(broadphase.instance instanceof CANNON.NaiveBroadphase); assert(broadphase.instance instanceof CANNON.NaiveBroadphase);
assert(broadphase.engine instanceof GameLib.D3.Engine); assert(broadphase.engine instanceof R3.D3.Engine);
assert(broadphase.name == 'broad-phase'); assert(broadphase.name == 'broad-phase');
assert(broadphase.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE); assert(broadphase.broadphaseType == R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE);
done(); done();
}); });
it('Should create a Color object', function (done) { it('Should create a Color object', function (done) {
var color = new GameLib.D3.Color( var color = new R3.D3.Color(
0.1, 0.1,
0.2, 0.2,
0.3, 0.3,
@ -115,7 +115,7 @@ describe('GameLib object creation', function(){
it('Should create a Color object', function (done) { it('Should create a Color object', function (done) {
var color = new GameLib.D3.Color( var color = new R3.D3.Color(
0.1, 0.1,
0.2, 0.2,
0.3, 0.3,
@ -133,12 +133,12 @@ describe('GameLib object creation', function(){
it('Should create an Engine object', function (done) { it('Should create an Engine object', function (done) {
var engine = new GameLib.D3.Engine( var engine = new R3.D3.Engine(
GameLib.D3.Engine.ENGINE_TYPE_CANNON, R3.D3.Engine.ENGINE_TYPE_CANNON,
CANNON CANNON
); );
assert(engine.engineType == GameLib.D3.Engine.ENGINE_TYPE_CANNON); assert(engine.engineType == R3.D3.Engine.ENGINE_TYPE_CANNON);
assert(engine.instance instanceof Object); assert(engine.instance instanceof Object);
done(); done();
@ -151,18 +151,18 @@ describe('GameLib object creation', function(){
it('Should load the scene via API', function(done) { it('Should load the scene via API', function(done) {
var scene = new GameLib.D3.Scene( var scene = new R3.D3.Scene(
null, null,
'/gamewheel/root/root/test', '/gamewheel/root/root/test',
'test' 'test'
); );
var graphics = new GameLib.D3.Graphics( var graphics = new R3.D3.Graphics(
GameLib.D3.Graphics.GRAPHICS_TYPE_THREE, R3.D3.Graphics.GRAPHICS_TYPE_THREE,
THREE THREE
); );
GameLib.D3.Scene.LoadSceneFromApi( R3.D3.Scene.LoadSceneFromApi(
scene, scene,
function(stuff){ function(stuff){
done(); done();