rename
parent
142c51b558
commit
49a7605ff5
|
@ -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;
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* GameLib.D3.API.Input namespace
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Input = function() {};
|
|
@ -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;
|
|
@ -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;
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -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;
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* GameLib.D3.Input namespace
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Input = function () {};
|
|
@ -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
|
||||
);
|
||||
};
|
||||
|
|
@ -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;
|
||||
};
|
|
@ -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;
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* GameLib.D3.API.Camera.Stereo.Anaglyph
|
||||
* R3.D3.API.Camera.Stereo.Anaglyph
|
||||
* @constructor
|
||||
* @param apiStereoCamera
|
||||
* @param colorMatrixLeft
|
||||
|
@ -7,7 +7,7 @@
|
|||
* @param orthographicCamera
|
||||
* @param orthographicScene
|
||||
*/
|
||||
GameLib.D3.API.Camera.Stereo.Anaglyph = function(
|
||||
R3.D3.API.Camera.Stereo.Anaglyph = function(
|
||||
apiStereoCamera,
|
||||
colorMatrixLeft,
|
||||
colorMatrixRight,
|
||||
|
@ -19,17 +19,17 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
|
|||
meshPlane
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiStereoCamera)) {
|
||||
if (R3.Utils.UndefinedOrNull(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)) {
|
||||
apiStereoCamera.stereoType = GameLib.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH;
|
||||
if (R3.Utils.UndefinedOrNull(apiStereoCamera.stereoType)) {
|
||||
apiStereoCamera.stereoType = R3.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(colorMatrixLeft)) {
|
||||
if (R3.Utils.UndefinedOrNull(colorMatrixLeft)) {
|
||||
colorMatrixLeft = [
|
||||
1.0671679973602295, -0.0016435992438346148, 0.0001777536963345483, // r out
|
||||
-0.028107794001698494, -0.00019593400065787137, -0.0002875397040043026, // g out
|
||||
|
@ -38,7 +38,7 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
|
|||
}
|
||||
this.colorMatrixLeft = colorMatrixLeft;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(colorMatrixRight)) {
|
||||
if (R3.Utils.UndefinedOrNull(colorMatrixRight)) {
|
||||
colorMatrixRight = [
|
||||
-0.0355340838432312, -0.06440307199954987, 0.018319187685847282, // r out
|
||||
-0.10269022732973099, 0.8079727292060852, -0.04835830628871918, // g out
|
||||
|
@ -47,18 +47,18 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
|
|||
}
|
||||
this.colorMatrixRight = colorMatrixRight;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(orthographicCamera)) {
|
||||
orthographicCamera = new GameLib.D3.API.Camera.Orthographic(null, null, 0, 1, -1, 1, 1, -1);
|
||||
if (R3.Utils.UndefinedOrNull(orthographicCamera)) {
|
||||
orthographicCamera = new R3.D3.API.Camera.Orthographic(null, null, 0, 1, -1, 1, 1, -1);
|
||||
}
|
||||
this.orthographicCamera = orthographicCamera;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(orthographicScene)) {
|
||||
orthographicScene = new GameLib.D3.API.Scene(null, 'Orthographic Stereo Anaglyph Scene');
|
||||
if (R3.Utils.UndefinedOrNull(orthographicScene)) {
|
||||
orthographicScene = new R3.D3.API.Scene(null, 'Orthographic Stereo Anaglyph Scene');
|
||||
}
|
||||
this.orthographicScene = orthographicScene;
|
||||
//
|
||||
// if (GameLib.Utils.UndefinedOrNull(renderTargetL)) {
|
||||
// renderTargetL = new GameLib.D3.API.RenderTarget(null, null, null, )
|
||||
// if (R3.Utils.UndefinedOrNull(renderTargetL)) {
|
||||
// renderTargetL = new R3.D3.API.RenderTarget(null, null, null, )
|
||||
// }
|
||||
//
|
||||
// renderTargetL,
|
||||
|
@ -66,7 +66,7 @@ GameLib.D3.API.Camera.Stereo.Anaglyph = function(
|
|||
// shaderMaterial,
|
||||
// meshPlane
|
||||
|
||||
GameLib.D3.API.Camera.Stereo.call(
|
||||
R3.D3.API.Camera.Stereo.call(
|
||||
this,
|
||||
apiStereoCamera,
|
||||
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);
|
||||
GameLib.D3.API.Camera.Stereo.Anaglyph.prototype.constructor = GameLib.D3.API.Camera.Stereo.Anaglyph;
|
||||
R3.D3.API.Camera.Stereo.Anaglyph.prototype = Object.create(R3.D3.API.Camera.Stereo.prototype);
|
||||
R3.D3.API.Camera.Stereo.Anaglyph.prototype.constructor = R3.D3.API.Camera.Stereo.Anaglyph;
|
|
@ -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;
|
|
@ -5,7 +5,7 @@
|
|||
* @param baseUrl
|
||||
* @param path
|
||||
* @param imageFactory
|
||||
* @param games [GameLib.API.D3.Game]
|
||||
* @param games [R3.API.D3.Game]
|
||||
* @param scenes
|
||||
* @param cameras
|
||||
* @param composers
|
||||
|
@ -19,7 +19,7 @@
|
|||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Editor = function(
|
||||
R3.D3.API.Editor = function(
|
||||
id,
|
||||
name,
|
||||
baseUrl,
|
||||
|
@ -38,116 +38,116 @@ GameLib.D3.API.Editor = function(
|
|||
selectedObjects,
|
||||
parentEntity
|
||||
) {
|
||||
GameLib.Component.call(
|
||||
R3.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_EDITOR,
|
||||
R3.Component.COMPONENT_EDITOR,
|
||||
{
|
||||
'imageFactory' : GameLib.D3.ImageFactory,
|
||||
'games' : [GameLib.D3.Game],
|
||||
'scenes' : [GameLib.D3.Scene],
|
||||
'cameras' : [GameLib.D3.Camera],
|
||||
'composers' : [GameLib.D3.Composer],
|
||||
'viewports' : [GameLib.D3.Viewport],
|
||||
'renderers' : [GameLib.D3.Renderer],
|
||||
'renderTargets' : [GameLib.D3.RenderTarget],
|
||||
'systems' : [GameLib.System],
|
||||
'entityManager' : GameLib.EntityManager
|
||||
'imageFactory' : R3.D3.ImageFactory,
|
||||
'games' : [R3.D3.Game],
|
||||
'scenes' : [R3.D3.Scene],
|
||||
'cameras' : [R3.D3.Camera],
|
||||
'composers' : [R3.D3.Composer],
|
||||
'viewports' : [R3.D3.Viewport],
|
||||
'renderers' : [R3.D3.Renderer],
|
||||
'renderTargets' : [R3.D3.RenderTarget],
|
||||
'systems' : [R3.System],
|
||||
'entityManager' : R3.EntityManager
|
||||
},
|
||||
null,
|
||||
parentEntity
|
||||
);
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||
id = GameLib.Utils.RandomId();
|
||||
if (R3.Utils.UndefinedOrNull(id)) {
|
||||
id = R3.Utils.RandomId();
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||
if (R3.Utils.UndefinedOrNull(name)) {
|
||||
name = 'Editor (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(baseUrl)) {
|
||||
if (R3.Utils.UndefinedOrNull(baseUrl)) {
|
||||
baseUrl = '';
|
||||
}
|
||||
this.baseUrl = baseUrl;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(path)) {
|
||||
if (R3.Utils.UndefinedOrNull(path)) {
|
||||
path = '';
|
||||
}
|
||||
this.path = path;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||
if (R3.Utils.UndefinedOrNull(imageFactory)) {
|
||||
imageFactory = null;
|
||||
}
|
||||
this.imageFactory = imageFactory;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(games)) {
|
||||
if (R3.Utils.UndefinedOrNull(games)) {
|
||||
games = [];
|
||||
}
|
||||
this.games = games;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(scenes)) {
|
||||
if (R3.Utils.UndefinedOrNull(scenes)) {
|
||||
scenes = [];
|
||||
}
|
||||
this.scenes = scenes;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
||||
if (R3.Utils.UndefinedOrNull(cameras)) {
|
||||
cameras = [];
|
||||
}
|
||||
this.cameras = cameras;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(composers)) {
|
||||
if (R3.Utils.UndefinedOrNull(composers)) {
|
||||
composers = [];
|
||||
}
|
||||
this.composers = composers;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(viewports)) {
|
||||
if (R3.Utils.UndefinedOrNull(viewports)) {
|
||||
viewports = [];
|
||||
}
|
||||
this.viewports = viewports;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(renderers)) {
|
||||
if (R3.Utils.UndefinedOrNull(renderers)) {
|
||||
renderers = [];
|
||||
}
|
||||
this.renderers = renderers;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(renderTargets)) {
|
||||
if (R3.Utils.UndefinedOrNull(renderTargets)) {
|
||||
renderTargets = [];
|
||||
}
|
||||
this.renderTargets = renderTargets;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(systems)) {
|
||||
if (R3.Utils.UndefinedOrNull(systems)) {
|
||||
systems = [];
|
||||
}
|
||||
this.systems = systems;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
||||
entityManager = new GameLib.API.EntityManager();
|
||||
if (R3.Utils.UndefinedOrNull(entityManager)) {
|
||||
entityManager = new R3.API.EntityManager();
|
||||
}
|
||||
this.entityManager = entityManager;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(allSelected)) {
|
||||
if (R3.Utils.UndefinedOrNull(allSelected)) {
|
||||
allSelected = false;
|
||||
}
|
||||
this.allSelected = allSelected;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(selectedObjects)) {
|
||||
if (R3.Utils.UndefinedOrNull(selectedObjects)) {
|
||||
selectedObjects = [];
|
||||
}
|
||||
this.selectedObjects = selectedObjects;
|
||||
|
||||
};
|
||||
|
||||
GameLib.D3.API.Editor.prototype = Object.create(GameLib.Component.prototype);
|
||||
GameLib.D3.API.Editor.prototype.constructor = GameLib.D3.API.Editor;
|
||||
R3.D3.API.Editor.prototype = Object.create(R3.Component.prototype);
|
||||
R3.D3.API.Editor.prototype.constructor = R3.D3.API.Editor;
|
||||
|
||||
/**
|
||||
* Creates an API Editor from an Object Editor
|
||||
* @param objectEditor
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
||||
R3.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
||||
|
||||
var apiImageFactory = null;
|
||||
var apiGames = [];
|
||||
|
@ -161,13 +161,13 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
|||
var apiEntityManager = null;
|
||||
|
||||
if (objectEditor.imageFactory) {
|
||||
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectEditor.imageFactory);
|
||||
apiImageFactory = R3.D3.API.ImageFactory.FromObjectImageFactory(objectEditor.imageFactory);
|
||||
}
|
||||
|
||||
if (objectEditor.games) {
|
||||
apiGames = objectEditor.games.map(
|
||||
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) {
|
||||
apiScenes = objectEditor.scenes.map(
|
||||
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) {
|
||||
apiCameras = objectEditor.cameras.map(
|
||||
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) {
|
||||
apiComposers = objectEditor.composers.map(
|
||||
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) {
|
||||
apiViewports = objectEditor.viewports.map(
|
||||
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) {
|
||||
apiRenderers = objectEditor.renderers.map(
|
||||
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) {
|
||||
apiRenderTargets = objectEditor.renderTargets.map(
|
||||
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) {
|
||||
apiSystems = objectEditor.systems.map(
|
||||
function(objectSystem){
|
||||
return GameLib.API.System.FromObjectComponent(objectSystem);
|
||||
return R3.API.System.FromObjectComponent(objectSystem);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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.name,
|
||||
objectEditor.baseUrl,
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -18,7 +18,7 @@
|
|||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Game = function(
|
||||
R3.D3.API.Game = function(
|
||||
id,
|
||||
name,
|
||||
baseUrl,
|
||||
|
@ -34,100 +34,100 @@ GameLib.D3.API.Game = function(
|
|||
entityManager,
|
||||
parentEntity
|
||||
) {
|
||||
GameLib.Component.call(
|
||||
R3.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_GAME,
|
||||
R3.Component.COMPONENT_GAME,
|
||||
{
|
||||
'imageFactory' : GameLib.D3.ImageFactory,
|
||||
'cameras' : [GameLib.D3.Camera],
|
||||
'composers' : [GameLib.D3.Composer],
|
||||
'viewports' : [GameLib.D3.Viewport],
|
||||
'renderers' : [GameLib.D3.Renderer],
|
||||
'renderTargets' : [GameLib.D3.RenderTarget],
|
||||
'systems' : [GameLib.System],
|
||||
'entityManager' : GameLib.EntityManager
|
||||
'imageFactory' : R3.D3.ImageFactory,
|
||||
'cameras' : [R3.D3.Camera],
|
||||
'composers' : [R3.D3.Composer],
|
||||
'viewports' : [R3.D3.Viewport],
|
||||
'renderers' : [R3.D3.Renderer],
|
||||
'renderTargets' : [R3.D3.RenderTarget],
|
||||
'systems' : [R3.System],
|
||||
'entityManager' : R3.EntityManager
|
||||
},
|
||||
null,
|
||||
parentEntity
|
||||
);
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||
id = GameLib.Utils.RandomId();
|
||||
if (R3.Utils.UndefinedOrNull(id)) {
|
||||
id = R3.Utils.RandomId();
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||
if (R3.Utils.UndefinedOrNull(name)) {
|
||||
name = 'Game (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(baseUrl)) {
|
||||
if (R3.Utils.UndefinedOrNull(baseUrl)) {
|
||||
baseUrl = '';
|
||||
console.warn('The base URL required for downloading images is not set - textured meshes will not render properly');
|
||||
}
|
||||
this.baseUrl = baseUrl;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(path)) {
|
||||
if (R3.Utils.UndefinedOrNull(path)) {
|
||||
path = '';
|
||||
}
|
||||
this.path = path;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||
if (R3.Utils.UndefinedOrNull(imageFactory)) {
|
||||
imageFactory = null;
|
||||
}
|
||||
this.imageFactory = imageFactory;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(gameType)) {
|
||||
gameType = GameLib.D3.Game.GAME_TYPE_VR_PONG;
|
||||
if (R3.Utils.UndefinedOrNull(gameType)) {
|
||||
gameType = R3.D3.Game.GAME_TYPE_VR_PONG;
|
||||
}
|
||||
this.gameType = gameType;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
||||
if (R3.Utils.UndefinedOrNull(cameras)) {
|
||||
cameras = [];
|
||||
}
|
||||
this.cameras = cameras;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(composers)) {
|
||||
if (R3.Utils.UndefinedOrNull(composers)) {
|
||||
composers = [];
|
||||
}
|
||||
this.composers = composers;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(viewports)) {
|
||||
if (R3.Utils.UndefinedOrNull(viewports)) {
|
||||
viewports = [];
|
||||
}
|
||||
this.viewports = viewports;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(renderers)) {
|
||||
if (R3.Utils.UndefinedOrNull(renderers)) {
|
||||
renderers = [];
|
||||
}
|
||||
this.renderers = renderers;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(renderTargets)) {
|
||||
if (R3.Utils.UndefinedOrNull(renderTargets)) {
|
||||
renderTargets = [];
|
||||
}
|
||||
this.renderTargets = renderTargets;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(systems)) {
|
||||
if (R3.Utils.UndefinedOrNull(systems)) {
|
||||
systems = [];
|
||||
}
|
||||
this.systems = systems;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
||||
if (R3.Utils.UndefinedOrNull(entityManager)) {
|
||||
entityManager = null;
|
||||
}
|
||||
this.entityManager = entityManager;
|
||||
|
||||
};
|
||||
|
||||
GameLib.D3.API.Game.prototype = Object.create(GameLib.Component.prototype);
|
||||
GameLib.D3.API.Game.prototype.constructor = GameLib.D3.API.Game;
|
||||
R3.D3.API.Game.prototype = Object.create(R3.Component.prototype);
|
||||
R3.D3.API.Game.prototype.constructor = R3.D3.API.Game;
|
||||
|
||||
/**
|
||||
* Creates an API camera from an Object camera
|
||||
* @param objectGame
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||
R3.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||
|
||||
var apiImageFactory = null;
|
||||
var apiCameras = [];
|
||||
|
@ -140,13 +140,13 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
|||
var apiEntityManager = null;
|
||||
|
||||
if (objectGame.imageFactory) {
|
||||
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectGame.imageFactory);
|
||||
apiImageFactory = R3.D3.API.ImageFactory.FromObjectImageFactory(objectGame.imageFactory);
|
||||
}
|
||||
|
||||
if (objectGame.cameras) {
|
||||
apiCameras = objectGame.cameras.map(
|
||||
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) {
|
||||
apiComposers = objectGame.composers.map(
|
||||
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) {
|
||||
apiViewports = objectGame.viewports.map(
|
||||
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) {
|
||||
apiRenderers = objectGame.renderers.map(
|
||||
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) {
|
||||
apiRenderTargets = objectGame.renderTargets.map(
|
||||
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) {
|
||||
apiSystems = objectGame.systems.map(
|
||||
function(objectSystem){
|
||||
return GameLib.API.System.FromObjectComponent(objectSystem);
|
||||
return R3.API.System.FromObjectComponent(objectSystem);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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.name,
|
||||
objectGame.baseUrl,
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -6,44 +6,44 @@
|
|||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.ImageFactory = function(
|
||||
R3.D3.API.ImageFactory = function(
|
||||
id,
|
||||
name,
|
||||
baseUrl,
|
||||
parentEntity
|
||||
) {
|
||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||
id = GameLib.Utils.RandomId();
|
||||
if (R3.Utils.UndefinedOrNull(id)) {
|
||||
id = R3.Utils.RandomId();
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||
if (R3.Utils.UndefinedOrNull(name)) {
|
||||
name = 'ImageFactory (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(baseUrl)) {
|
||||
if (R3.Utils.UndefinedOrNull(baseUrl)) {
|
||||
baseUrl = '';
|
||||
console.warn('No baseURL defined for image factory');
|
||||
}
|
||||
this.baseUrl = baseUrl;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||
if (R3.Utils.UndefinedOrNull(parentEntity)) {
|
||||
parentEntity = null;
|
||||
}
|
||||
this.parentEntity = parentEntity;
|
||||
};
|
||||
|
||||
GameLib.D3.API.ImageFactory.prototype = Object.create(GameLib.Component.prototype);
|
||||
GameLib.D3.API.ImageFactory.prototype.constructor = GameLib.D3.API.ImageFactory;
|
||||
R3.D3.API.ImageFactory.prototype = Object.create(R3.Component.prototype);
|
||||
R3.D3.API.ImageFactory.prototype.constructor = R3.D3.API.ImageFactory;
|
||||
|
||||
/**
|
||||
* Returns an API ImageFactory from an Object ImageFactory
|
||||
* @param objectImageFactory
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.ImageFactory.FromObject = function(objectImageFactory) {
|
||||
return new GameLib.D3.API.ImageFactory(
|
||||
R3.D3.API.ImageFactory.FromObject = function(objectImageFactory) {
|
||||
return new R3.D3.API.ImageFactory(
|
||||
objectImageFactory.id,
|
||||
objectImageFactory.name,
|
||||
objectImageFactory.baseUrl,
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* R3.D3.API.Input namespace
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.API.Input = function() {};
|
|
@ -3,7 +3,7 @@
|
|||
* @param id String
|
||||
* @param name String
|
||||
* @param domElementId
|
||||
* @param pathFollowingComponent GameLib.D3.Mesh
|
||||
* @param pathFollowingComponent R3.D3.Mesh
|
||||
* @param parentEntity
|
||||
* @param wheelFL
|
||||
* @param wheelFR
|
||||
|
@ -15,7 +15,7 @@
|
|||
* @param rotationFactor
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Input.Drive = function (
|
||||
R3.D3.API.Input.Drive = function (
|
||||
id,
|
||||
name,
|
||||
domElementId,
|
||||
|
@ -30,84 +30,84 @@ GameLib.D3.API.Input.Drive = function (
|
|||
distanceGrain,
|
||||
rotationFactor
|
||||
) {
|
||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||
id = GameLib.Utils.RandomId();
|
||||
if (R3.Utils.UndefinedOrNull(id)) {
|
||||
id = R3.Utils.RandomId();
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||
if (R3.Utils.UndefinedOrNull(name)) {
|
||||
name = 'Input.Drive (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
|
||||
if (R3.Utils.UndefinedOrNull(domElementId)) {
|
||||
domElementId = "divCanvas";
|
||||
}
|
||||
this.domElementId = domElementId;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(pathFollowingComponent)) {
|
||||
if (R3.Utils.UndefinedOrNull(pathFollowingComponent)) {
|
||||
pathFollowingComponent = null;
|
||||
}
|
||||
this.pathFollowingComponent = pathFollowingComponent;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||
if (R3.Utils.UndefinedOrNull(parentEntity)) {
|
||||
parentEntity = null;
|
||||
}
|
||||
this.parentEntity = parentEntity;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(wheelFL)) {
|
||||
if (R3.Utils.UndefinedOrNull(wheelFL)) {
|
||||
wheelFL = null;
|
||||
}
|
||||
this.wheelFL = wheelFL;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(wheelFR)) {
|
||||
if (R3.Utils.UndefinedOrNull(wheelFR)) {
|
||||
wheelFR = null;
|
||||
}
|
||||
this.wheelFR = wheelFR;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(wheelRL)) {
|
||||
if (R3.Utils.UndefinedOrNull(wheelRL)) {
|
||||
wheelRL = null;
|
||||
}
|
||||
this.wheelRL = wheelRL;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(wheelRR)) {
|
||||
if (R3.Utils.UndefinedOrNull(wheelRR)) {
|
||||
wheelRR = null;
|
||||
}
|
||||
this.wheelRR = wheelRR;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(heightOffset)) {
|
||||
if (R3.Utils.UndefinedOrNull(heightOffset)) {
|
||||
heightOffset = 0;
|
||||
}
|
||||
this.heightOffset = heightOffset;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(distance)) {
|
||||
if (R3.Utils.UndefinedOrNull(distance)) {
|
||||
distance = 0;
|
||||
}
|
||||
this.distance = distance;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(distanceGrain)) {
|
||||
if (R3.Utils.UndefinedOrNull(distanceGrain)) {
|
||||
distanceGrain = 0.1;
|
||||
}
|
||||
this.distanceGrain = distanceGrain;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(rotationFactor)) {
|
||||
if (R3.Utils.UndefinedOrNull(rotationFactor)) {
|
||||
rotationFactor = 0.1;
|
||||
}
|
||||
this.rotationFactor = rotationFactor;
|
||||
|
||||
};
|
||||
|
||||
GameLib.D3.API.Input.Drive.prototype = Object.create(GameLib.Component.prototype);
|
||||
GameLib.D3.API.Input.Drive.prototype.constructor = GameLib.D3.API.Input.Drive;
|
||||
R3.D3.API.Input.Drive.prototype = Object.create(R3.Component.prototype);
|
||||
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
|
||||
* @returns {GameLib.D3.API.Input.Drive}
|
||||
* @returns {R3.D3.API.Input.Drive}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Input.Drive.FromObject = function(objectComponent) {
|
||||
return new GameLib.D3.API.Input.Drive(
|
||||
R3.D3.API.Input.Drive.FromObject = function(objectComponent) {
|
||||
return new R3.D3.API.Input.Drive(
|
||||
objectComponent.id,
|
||||
objectComponent.name,
|
||||
objectComponent.domElementId,
|
|
@ -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;
|
|
@ -7,7 +7,7 @@
|
|||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Input.Editor = function (
|
||||
R3.D3.API.Input.Editor = function (
|
||||
id,
|
||||
name,
|
||||
domElement,
|
||||
|
@ -15,44 +15,44 @@ GameLib.D3.API.Input.Editor = function (
|
|||
parentEntity
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||
id = GameLib.Utils.RandomId();
|
||||
if (R3.Utils.UndefinedOrNull(id)) {
|
||||
id = R3.Utils.RandomId();
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||
if (R3.Utils.UndefinedOrNull(name)) {
|
||||
name = 'Input Editor (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(domElement)) {
|
||||
if (R3.Utils.UndefinedOrNull(domElement)) {
|
||||
domElement = null;
|
||||
}
|
||||
this.domElement = domElement;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
||||
if (R3.Utils.UndefinedOrNull(camera)) {
|
||||
camera = null;
|
||||
}
|
||||
this.camera = camera;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||
if (R3.Utils.UndefinedOrNull(parentEntity)) {
|
||||
parentEntity = null;
|
||||
}
|
||||
this.parentEntity = parentEntity;
|
||||
|
||||
};
|
||||
|
||||
GameLib.D3.API.Input.Editor.prototype = Object.create(GameLib.Component.prototype);
|
||||
GameLib.D3.API.Input.Editor.prototype.constructor = GameLib.D3.API.Input.Editor;
|
||||
R3.D3.API.Input.Editor.prototype = Object.create(R3.Component.prototype);
|
||||
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
|
||||
* @returns {GameLib.D3.API.Input.Editor}
|
||||
* @returns {R3.D3.API.Input.Editor}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Input.Editor.FromObject = function(objectComponent) {
|
||||
return new GameLib.D3.API.Input.Editor(
|
||||
R3.D3.API.Input.Editor.FromObject = function(objectComponent) {
|
||||
return new R3.D3.API.Input.Editor(
|
||||
objectComponent.id,
|
||||
objectComponent.name,
|
||||
objectComponent.domElement,
|
|
@ -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;
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -1,44 +1,44 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Box
|
||||
* R3.D3.API.Mesh.Box
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param width
|
||||
* @param height
|
||||
* @param depth
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Box = function(
|
||||
R3.D3.API.Mesh.Box = function(
|
||||
apiMesh,
|
||||
width,
|
||||
height,
|
||||
depth
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_BOX
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_BOX
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_BOX;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_BOX;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
||||
if (R3.Utils.UndefinedOrNull(width)) {
|
||||
width = 1;
|
||||
}
|
||||
this.width = width;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||
if (R3.Utils.UndefinedOrNull(height)) {
|
||||
height = 1;
|
||||
}
|
||||
this.height = height;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(depth)) {
|
||||
if (R3.Utils.UndefinedOrNull(depth)) {
|
||||
depth = 1;
|
||||
}
|
||||
this.depth = depth;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Box.prototype.constructor = GameLib.D3.API.Mesh.Box;
|
||||
R3.D3.API.Mesh.Box.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Box.prototype.constructor = R3.D3.API.Mesh.Box;
|
|
@ -1,30 +1,30 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Curve
|
||||
* R3.D3.API.Mesh.Curve
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param pointSize
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Curve = function(
|
||||
R3.D3.API.Mesh.Curve = function(
|
||||
apiMesh,
|
||||
pointSize
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CURVE
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_CURVE
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_CURVE;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_CURVE;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(pointSize)) {
|
||||
if (R3.Utils.UndefinedOrNull(pointSize)) {
|
||||
pointSize = 1;
|
||||
}
|
||||
this.pointSize = pointSize;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Curve.prototype.constructor = GameLib.D3.API.Mesh.Curve;
|
||||
R3.D3.API.Mesh.Curve.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Curve.prototype.constructor = R3.D3.API.Mesh.Curve;
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Cylinder
|
||||
* R3.D3.API.Mesh.Cylinder
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param radiusTop
|
||||
|
@ -11,7 +11,7 @@
|
|||
* @param thetaStart
|
||||
* @param thetaLength
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Cylinder = function(
|
||||
R3.D3.API.Mesh.Cylinder = function(
|
||||
apiMesh,
|
||||
radiusTop,
|
||||
radiusBottom,
|
||||
|
@ -22,57 +22,57 @@ GameLib.D3.API.Mesh.Cylinder = function(
|
|||
thetaStart,
|
||||
thetaLength
|
||||
) {
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_CYLINDER
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_CYLINDER;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
|
||||
if (R3.Utils.UndefinedOrNull(radiusTop)) {
|
||||
radiusTop = 1;
|
||||
}
|
||||
this.radiusTop = radiusTop;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(radiusBottom)) {
|
||||
if (R3.Utils.UndefinedOrNull(radiusBottom)) {
|
||||
radiusBottom = 1;
|
||||
}
|
||||
this.radiusBottom = radiusBottom;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||
if (R3.Utils.UndefinedOrNull(height)) {
|
||||
height = 5;
|
||||
}
|
||||
this.height = height;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(radiusSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(radiusSegments)) {
|
||||
radiusSegments = 10;
|
||||
}
|
||||
this.radiusSegments = radiusSegments;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(heightSegments)) {
|
||||
heightSegments = 10;
|
||||
}
|
||||
this.heightSegments = heightSegments;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(openEnded)) {
|
||||
if (R3.Utils.UndefinedOrNull(openEnded)) {
|
||||
openEnded = false;
|
||||
}
|
||||
this.openEnded = openEnded;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(thetaStart)) {
|
||||
if (R3.Utils.UndefinedOrNull(thetaStart)) {
|
||||
thetaStart = 0;
|
||||
}
|
||||
this.thetaStart = thetaStart;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(thetaLength)) {
|
||||
if (R3.Utils.UndefinedOrNull(thetaLength)) {
|
||||
thetaLength = Math.PI * 2;
|
||||
}
|
||||
this.thetaLength = thetaLength;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Cylinder.prototype.constructor = GameLib.D3.API.Mesh.Cylinder;
|
||||
R3.D3.API.Mesh.Cylinder.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Cylinder.prototype.constructor = R3.D3.API.Mesh.Cylinder;
|
|
@ -1,30 +1,30 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Line
|
||||
* R3.D3.API.Mesh.Line
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param lineWidth
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Line = function(
|
||||
R3.D3.API.Mesh.Line = function(
|
||||
apiMesh,
|
||||
lineWidth
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_LINE
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_LINE
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_LINE;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_LINE;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(lineWidth)) {
|
||||
if (R3.Utils.UndefinedOrNull(lineWidth)) {
|
||||
lineWidth = 1;
|
||||
}
|
||||
this.lineWidth = lineWidth;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Line.prototype.constructor = GameLib.D3.API.Mesh.Line;
|
||||
R3.D3.API.Mesh.Line.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Line.prototype.constructor = R3.D3.API.Mesh.Line;
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Plane
|
||||
* R3.D3.API.Mesh.Plane
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param width
|
||||
|
@ -14,7 +14,7 @@
|
|||
* @param dotMapWeight
|
||||
* @param dotObject
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Plane = function(
|
||||
R3.D3.API.Mesh.Plane = function(
|
||||
apiMesh,
|
||||
width,
|
||||
height,
|
||||
|
@ -29,72 +29,72 @@ GameLib.D3.API.Mesh.Plane = function(
|
|||
dotObject
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_PLANE
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_PLANE
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_PLANE;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_PLANE;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
||||
if (R3.Utils.UndefinedOrNull(width)) {
|
||||
width = 1;
|
||||
}
|
||||
this.width = width;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||
if (R3.Utils.UndefinedOrNull(height)) {
|
||||
height = 1;
|
||||
}
|
||||
this.height = height;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(widthSegments)) {
|
||||
widthSegments = 5;
|
||||
}
|
||||
this.widthSegments = widthSegments;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(heightSegments)) {
|
||||
heightSegments = 5;
|
||||
}
|
||||
this.heightSegments = heightSegments;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(heightMapScale)) {
|
||||
if (R3.Utils.UndefinedOrNull(heightMapScale)) {
|
||||
heightMapScale = 1;
|
||||
}
|
||||
this.heightMapScale = heightMapScale;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(isHeightMap)) {
|
||||
if (R3.Utils.UndefinedOrNull(isHeightMap)) {
|
||||
isHeightMap = false;
|
||||
}
|
||||
this.isHeightMap = isHeightMap;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(isDotMap)) {
|
||||
if (R3.Utils.UndefinedOrNull(isDotMap)) {
|
||||
isDotMap = false;
|
||||
}
|
||||
this.isDotMap = isDotMap;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(dotMapScale)) {
|
||||
dotMapScale = new GameLib.API.Vector3(0.01, 0.01, 0.01);
|
||||
if (R3.Utils.UndefinedOrNull(dotMapScale)) {
|
||||
dotMapScale = new R3.API.Vector3(0.01, 0.01, 0.01);
|
||||
}
|
||||
this.dotMapScale = dotMapScale;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(dotMapOffset)) {
|
||||
dotMapOffset = new GameLib.API.Vector3(1, -1, 5);
|
||||
if (R3.Utils.UndefinedOrNull(dotMapOffset)) {
|
||||
dotMapOffset = new R3.API.Vector3(1, -1, 5);
|
||||
}
|
||||
this.dotMapOffset = dotMapOffset;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(dotMapWeight)) {
|
||||
dotMapWeight = new GameLib.API.Vector3(1, 1, 1);
|
||||
if (R3.Utils.UndefinedOrNull(dotMapWeight)) {
|
||||
dotMapWeight = new R3.API.Vector3(1, 1, 1);
|
||||
}
|
||||
this.dotMapWeight = dotMapWeight;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(dotObject)) {
|
||||
if (R3.Utils.UndefinedOrNull(dotObject)) {
|
||||
dotObject = null;
|
||||
}
|
||||
this.dotObject = dotObject;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Plane.prototype.constructor = GameLib.D3.API.Mesh.Plane;
|
||||
R3.D3.API.Mesh.Plane.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Plane.prototype.constructor = R3.D3.API.Mesh.Plane;
|
|
@ -1,44 +1,44 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Sphere
|
||||
* R3.D3.API.Mesh.Sphere
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param radius
|
||||
* @param widthSegments
|
||||
* @param heightSegments
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Sphere = function(
|
||||
R3.D3.API.Mesh.Sphere = function(
|
||||
apiMesh,
|
||||
radius,
|
||||
widthSegments,
|
||||
heightSegments
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_SPHERE
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_SPHERE
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_SPHERE;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_SPHERE;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(radius)) {
|
||||
if (R3.Utils.UndefinedOrNull(radius)) {
|
||||
radius = 1;
|
||||
}
|
||||
this.radius = radius;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(widthSegments)) {
|
||||
widthSegments = 5;
|
||||
}
|
||||
this.widthSegments = widthSegments;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(heightSegments)) {
|
||||
heightSegments = 5;
|
||||
}
|
||||
this.heightSegments = heightSegments;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Sphere.prototype.constructor = GameLib.D3.API.Mesh.Sphere;
|
||||
R3.D3.API.Mesh.Sphere.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Sphere.prototype.constructor = R3.D3.API.Mesh.Sphere;
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* GameLib.D3.API.Mesh.Text
|
||||
* R3.D3.API.Mesh.Text
|
||||
* @constructor
|
||||
* @param apiMesh
|
||||
* @param text
|
||||
|
@ -12,7 +12,7 @@
|
|||
* @param bevelSize
|
||||
* @param bevelSegments
|
||||
*/
|
||||
GameLib.D3.API.Mesh.Text = function(
|
||||
R3.D3.API.Mesh.Text = function(
|
||||
apiMesh,
|
||||
text,
|
||||
font,
|
||||
|
@ -25,62 +25,62 @@ GameLib.D3.API.Mesh.Text = function(
|
|||
bevelSegments
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh)) {
|
||||
apiMesh = {
|
||||
meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT
|
||||
meshType : R3.D3.API.Mesh.MESH_TYPE_TEXT
|
||||
};
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_TEXT;
|
||||
if (R3.Utils.UndefinedOrNull(apiMesh.meshType)) {
|
||||
apiMesh.meshType = R3.D3.API.Mesh.MESH_TYPE_TEXT;
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(text)) {
|
||||
if (R3.Utils.UndefinedOrNull(text)) {
|
||||
text = '-=<yb4f310';
|
||||
}
|
||||
this.text = text;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(font)) {
|
||||
font = new GameLib.D3.API.Font()
|
||||
if (R3.Utils.UndefinedOrNull(font)) {
|
||||
font = new R3.D3.API.Font()
|
||||
}
|
||||
this.font = font;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(size)) {
|
||||
if (R3.Utils.UndefinedOrNull(size)) {
|
||||
size = 100;
|
||||
}
|
||||
this.size = size;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||
if (R3.Utils.UndefinedOrNull(height)) {
|
||||
height = 50;
|
||||
}
|
||||
this.height = height;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(curveSegments)) {
|
||||
curveSegments = 12;
|
||||
}
|
||||
this.curveSegments = curveSegments;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(bevelEnabled)) {
|
||||
if (R3.Utils.UndefinedOrNull(bevelEnabled)) {
|
||||
bevelEnabled = false;
|
||||
}
|
||||
this.bevelEnabled = bevelEnabled;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(bevelThickness)) {
|
||||
if (R3.Utils.UndefinedOrNull(bevelThickness)) {
|
||||
bevelThickness = 10;
|
||||
}
|
||||
this.bevelThickness = bevelThickness;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(bevelSize)) {
|
||||
if (R3.Utils.UndefinedOrNull(bevelSize)) {
|
||||
bevelSize = 8;
|
||||
}
|
||||
this.bevelSize = bevelSize;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(bevelSegments)) {
|
||||
if (R3.Utils.UndefinedOrNull(bevelSegments)) {
|
||||
bevelSegments = 3;
|
||||
}
|
||||
this.bevelSegments = bevelSegments;
|
||||
|
||||
GameLib.D3.API.Mesh.call(
|
||||
R3.D3.API.Mesh.call(
|
||||
this,
|
||||
apiMesh.id,
|
||||
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);
|
||||
GameLib.D3.API.Mesh.Text.prototype.constructor = GameLib.D3.API.Mesh.Text;
|
||||
R3.D3.API.Mesh.Text.prototype = Object.create(R3.D3.API.Mesh.prototype);
|
||||
R3.D3.API.Mesh.Text.prototype.constructor = R3.D3.API.Mesh.Text;
|
|
@ -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
|
||||
);
|
||||
};
|
|
@ -7,36 +7,36 @@
|
|||
* @param lastUpdate
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.SelectedObject = function (
|
||||
R3.D3.API.SelectedObject = function (
|
||||
object,
|
||||
helper,
|
||||
lastUpdate
|
||||
) {
|
||||
if (GameLib.Utils.UndefinedOrNull(object)) {
|
||||
if (R3.Utils.UndefinedOrNull(object)) {
|
||||
console.warn('Cannot select no object');
|
||||
throw new Error('Cannot select no object');
|
||||
}
|
||||
this.object = object;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(helper)) {
|
||||
if (R3.Utils.UndefinedOrNull(helper)) {
|
||||
helper = null;
|
||||
}
|
||||
this.helper = helper;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(lastUpdate)) {
|
||||
if (R3.Utils.UndefinedOrNull(lastUpdate)) {
|
||||
lastUpdate = Date.now();
|
||||
}
|
||||
this.lastUpdate = lastUpdate;
|
||||
};
|
||||
|
||||
/**
|
||||
* Object to GameLib.D3.API.SelectedObject
|
||||
* Object to R3.D3.API.SelectedObject
|
||||
* @param objectComponent
|
||||
* @returns {GameLib.D3.API.SelectedObject}
|
||||
* @returns {R3.D3.API.SelectedObject}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.SelectedObject.FromObjectSelectedObject = function(objectComponent) {
|
||||
return new GameLib.D3.API.SelectedObject(
|
||||
R3.D3.API.SelectedObject.FromObjectSelectedObject = function(objectComponent) {
|
||||
return new R3.D3.API.SelectedObject(
|
||||
objectComponent.id,
|
||||
objectComponent.name,
|
||||
objectComponent.object,
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* Creates a Editor object
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param apiEditor GameLib.D3.API.Editor
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param apiEditor R3.D3.API.Editor
|
||||
* @param onSelectionChanged
|
||||
* @param onSelectObject
|
||||
* @param onDeSelectObject
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Editor = function(
|
||||
R3.D3.Editor = function(
|
||||
graphics,
|
||||
apiEditor,
|
||||
onSelectionChanged,
|
||||
|
@ -18,15 +18,15 @@ GameLib.D3.Editor = function(
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiEditor)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiEditor)) {
|
||||
apiEditor = {};
|
||||
}
|
||||
|
||||
if (apiEditor instanceof GameLib.D3.Editor) {
|
||||
if (apiEditor instanceof R3.D3.Editor) {
|
||||
return apiEditor;
|
||||
}
|
||||
|
||||
GameLib.D3.API.Editor.call(
|
||||
R3.D3.API.Editor.call(
|
||||
this,
|
||||
apiEditor.id,
|
||||
apiEditor.name,
|
||||
|
@ -47,8 +47,8 @@ GameLib.D3.Editor = function(
|
|||
apiEditor.parentEntity
|
||||
);
|
||||
|
||||
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) {
|
||||
this.imageFactory = new GameLib.D3.ImageFactory(
|
||||
if (this.imageFactory instanceof R3.D3.API.ImageFactory) {
|
||||
this.imageFactory = new R3.D3.ImageFactory(
|
||||
this.graphics,
|
||||
this.imageFactory
|
||||
);
|
||||
|
@ -57,8 +57,8 @@ GameLib.D3.Editor = function(
|
|||
if (this.games) {
|
||||
this.games = this.games.map(
|
||||
function (apiGame) {
|
||||
if (apiGame instanceof GameLib.D3.API.Game) {
|
||||
return new GameLib.D3.Game(
|
||||
if (apiGame instanceof R3.D3.API.Game) {
|
||||
return new R3.D3.Game(
|
||||
this.graphics,
|
||||
apiGame,
|
||||
this.imageFactory
|
||||
|
@ -74,8 +74,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.scenes = this.scenes.map(
|
||||
function (apiScene) {
|
||||
if (apiScene instanceof GameLib.D3.API.Scene) {
|
||||
return new GameLib.D3.Scene(
|
||||
if (apiScene instanceof R3.D3.API.Scene) {
|
||||
return new R3.D3.Scene(
|
||||
this.graphics,
|
||||
apiScene,
|
||||
this.imageFactory,
|
||||
|
@ -90,8 +90,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.cameras = this.cameras.map(
|
||||
function (apiCamera) {
|
||||
if (apiCamera instanceof GameLib.D3.API.Camera) {
|
||||
return new GameLib.D3.Camera(
|
||||
if (apiCamera instanceof R3.D3.API.Camera) {
|
||||
return new R3.D3.Camera(
|
||||
this.graphics,
|
||||
apiCamera
|
||||
)
|
||||
|
@ -104,8 +104,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.composers = this.composers.map(
|
||||
function (apiComposer) {
|
||||
if (apiComposer instanceof GameLib.D3.API.Composer) {
|
||||
return new GameLib.D3.Composer(
|
||||
if (apiComposer instanceof R3.D3.API.Composer) {
|
||||
return new R3.D3.Composer(
|
||||
this.graphics,
|
||||
apiComposer
|
||||
)
|
||||
|
@ -118,8 +118,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.viewports = this.viewports.map(
|
||||
function (apiViewport) {
|
||||
if (apiViewport instanceof GameLib.D3.API.Viewport) {
|
||||
return new GameLib.D3.Viewport(
|
||||
if (apiViewport instanceof R3.D3.API.Viewport) {
|
||||
return new R3.D3.Viewport(
|
||||
this.graphics,
|
||||
apiViewport
|
||||
)
|
||||
|
@ -132,8 +132,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.renderers = this.renderers.map(
|
||||
function (apiRenderer) {
|
||||
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
||||
return new GameLib.D3.Renderer(
|
||||
if (apiRenderer instanceof R3.D3.API.Renderer) {
|
||||
return new R3.D3.Renderer(
|
||||
this.graphics,
|
||||
apiRenderer
|
||||
)
|
||||
|
@ -146,8 +146,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.renderTargets = this.renderTargets.map(
|
||||
function (apiRenderTarget) {
|
||||
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||
return new GameLib.D3.RenderTarget(
|
||||
if (apiRenderTarget instanceof R3.D3.API.RenderTarget) {
|
||||
return new R3.D3.RenderTarget(
|
||||
this.graphics,
|
||||
apiRenderTarget
|
||||
)
|
||||
|
@ -160,8 +160,8 @@ GameLib.D3.Editor = function(
|
|||
|
||||
this.systems = this.systems.map(
|
||||
function (apiSystem) {
|
||||
if (apiSystem instanceof GameLib.API.System) {
|
||||
return new GameLib.System(
|
||||
if (apiSystem instanceof R3.API.System) {
|
||||
return new R3.System(
|
||||
this.graphics,
|
||||
apiSystem
|
||||
)
|
||||
|
@ -173,8 +173,8 @@ GameLib.D3.Editor = function(
|
|||
);
|
||||
|
||||
if (this.entityManager) {
|
||||
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
||||
this.entityManager = new GameLib.EntityManager(
|
||||
if (this.entityManager instanceof R3.API.EntityManager) {
|
||||
this.entityManager = new R3.EntityManager(
|
||||
this.graphics,
|
||||
this.entityManager
|
||||
);
|
||||
|
@ -184,17 +184,17 @@ GameLib.D3.Editor = function(
|
|||
}
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(onSelectionChanged)) {
|
||||
if (R3.Utils.UndefinedOrNull(onSelectionChanged)) {
|
||||
onSelectionChanged = null;
|
||||
}
|
||||
this.onSelectionChanged = onSelectionChanged;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(onSelectObject)) {
|
||||
if (R3.Utils.UndefinedOrNull(onSelectObject)) {
|
||||
onSelectObject = null;
|
||||
}
|
||||
this.onSelectObject = onSelectObject;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(onDeSelectObject)) {
|
||||
if (R3.Utils.UndefinedOrNull(onDeSelectObject)) {
|
||||
onDeSelectObject = null;
|
||||
}
|
||||
this.onDeSelectObject = onDeSelectObject;
|
||||
|
@ -211,14 +211,14 @@ GameLib.D3.Editor = function(
|
|||
this.instance = this.createInstance();
|
||||
};
|
||||
|
||||
GameLib.D3.Editor.prototype = Object.create(GameLib.D3.API.Editor.prototype);
|
||||
GameLib.D3.Editor.prototype.constructor = GameLib.D3.Editor;
|
||||
R3.D3.Editor.prototype = Object.create(R3.D3.API.Editor.prototype);
|
||||
R3.D3.Editor.prototype.constructor = R3.D3.Editor;
|
||||
|
||||
/**
|
||||
* Creates a camera instance of 'graphics' type (only THREE for now)
|
||||
* @returns {THREE.Editor}
|
||||
*/
|
||||
GameLib.D3.Editor.prototype.createInstance = function(update) {
|
||||
R3.D3.Editor.prototype.createInstance = function(update) {
|
||||
|
||||
var instance = null;
|
||||
|
||||
|
@ -232,15 +232,15 @@ GameLib.D3.Editor.prototype.createInstance = function(update) {
|
|||
/**
|
||||
* Updates the instance with the current state
|
||||
*/
|
||||
GameLib.D3.Editor.prototype.updateInstance = function() {
|
||||
R3.D3.Editor.prototype.updateInstance = function() {
|
||||
this.instance = this.createInstance(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a GameLib.D3.Editor to a new GameLib.D3.API.Editor
|
||||
* @returns {GameLib.D3.API.Editor}
|
||||
* Converts a R3.D3.Editor to a new R3.D3.API.Editor
|
||||
* @returns {R3.D3.API.Editor}
|
||||
*/
|
||||
GameLib.D3.Editor.prototype.toApiObject = function() {
|
||||
R3.D3.Editor.prototype.toApiObject = function() {
|
||||
|
||||
var apiImageFactory = null;
|
||||
var apiGames = [];
|
||||
|
@ -253,14 +253,14 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
var apiSystems = [];
|
||||
var apiEntityManager = null;
|
||||
|
||||
if (this.imageFactory instanceof GameLib.D3.ImageFactory) {
|
||||
if (this.imageFactory instanceof R3.D3.ImageFactory) {
|
||||
apiImageFactory = this.imageFactory.toApiObject();
|
||||
}
|
||||
|
||||
if (this.games) {
|
||||
apiGames = this.games.map(
|
||||
function(game) {
|
||||
if (game instanceof GameLib.D3.Game) {
|
||||
if (game instanceof R3.D3.Game) {
|
||||
return game.toApiObject();
|
||||
} else {
|
||||
console.warn('game not an instance of Game');
|
||||
|
@ -273,7 +273,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.scenes) {
|
||||
apiScenes = this.scenes.map(
|
||||
function(scene) {
|
||||
if (scene instanceof GameLib.D3.Scene) {
|
||||
if (scene instanceof R3.D3.Scene) {
|
||||
return scene.toApiObject();
|
||||
} else {
|
||||
console.warn('scene not an instance of Scene');
|
||||
|
@ -286,7 +286,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.cameras) {
|
||||
apiCameras = this.cameras.map(
|
||||
function(camera) {
|
||||
if (camera instanceof GameLib.D3.Camera) {
|
||||
if (camera instanceof R3.D3.Camera) {
|
||||
return camera.toApiObject();
|
||||
} else {
|
||||
console.warn('camera not an instance of Camera');
|
||||
|
@ -299,7 +299,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.composers) {
|
||||
apiComposers = this.composers.map(
|
||||
function(composer) {
|
||||
if (composer instanceof GameLib.D3.Composer) {
|
||||
if (composer instanceof R3.D3.Composer) {
|
||||
return composer.toApiObject();
|
||||
} else {
|
||||
console.warn('composer not an instance of Composer');
|
||||
|
@ -312,7 +312,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.viewports) {
|
||||
apiViewports = this.viewports.map(
|
||||
function(viewport) {
|
||||
if (viewport instanceof GameLib.D3.Viewport) {
|
||||
if (viewport instanceof R3.D3.Viewport) {
|
||||
return viewport.toApiObject();
|
||||
} else {
|
||||
console.warn('viewport not an instance of Viewport');
|
||||
|
@ -325,7 +325,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.renderers) {
|
||||
apiRenderers = this.renderers.map(
|
||||
function(renderer) {
|
||||
if (renderer instanceof GameLib.D3.Renderer) {
|
||||
if (renderer instanceof R3.D3.Renderer) {
|
||||
return renderer.toApiObject();
|
||||
} else {
|
||||
console.warn('renderer not an instance of Renderer');
|
||||
|
@ -338,7 +338,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.renderTargets) {
|
||||
apiRenderTargets = this.renderTargets.map(
|
||||
function(renderTarget) {
|
||||
if (renderTarget instanceof GameLib.D3.RenderTarget) {
|
||||
if (renderTarget instanceof R3.D3.RenderTarget) {
|
||||
return renderTarget.toApiObject();
|
||||
} else {
|
||||
console.warn('renderTarget not an instance of RenderTarget');
|
||||
|
@ -351,7 +351,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
if (this.systems) {
|
||||
apiSystems = this.systems.map(
|
||||
function(system) {
|
||||
if (system instanceof GameLib.System) {
|
||||
if (system instanceof R3.System) {
|
||||
return system.toApiObject();
|
||||
} else {
|
||||
console.warn('system not an instance of System');
|
||||
|
@ -362,7 +362,7 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
}
|
||||
|
||||
if (this.entityManager) {
|
||||
if (this.entityManager instanceof GameLib.EntityManager) {
|
||||
if (this.entityManager instanceof R3.EntityManager) {
|
||||
apiEntityManager = this.entityManager.toApiObject();
|
||||
} else {
|
||||
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.name,
|
||||
this.baseUrl,
|
||||
|
@ -387,23 +387,23 @@ GameLib.D3.Editor.prototype.toApiObject = function() {
|
|||
apiEntityManager,
|
||||
this.allSelected,
|
||||
this.selectedObjects,
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts from an Object Editor to a GameLib.D3.Editor
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* Converts from an Object Editor to a R3.D3.Editor
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param objectEditor Object
|
||||
* @returns {GameLib.D3.Editor}
|
||||
* @returns {R3.D3.Editor}
|
||||
* @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,
|
||||
apiEditor
|
||||
);
|
||||
|
@ -411,13 +411,13 @@ GameLib.D3.Editor.FromObjectEditor = function(graphics, objectEditor) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Selects a GameLib Object
|
||||
* @param object GameLib.*
|
||||
* Selects a R3 Object
|
||||
* @param object R3.*
|
||||
*/
|
||||
GameLib.D3.Editor.prototype.selectObject = function(object) {
|
||||
R3.D3.Editor.prototype.selectObject = function(object) {
|
||||
|
||||
this.selectedObjects.push(
|
||||
new GameLib.D3.SelectedObject(
|
||||
new R3.D3.SelectedObject(
|
||||
this.graphics,
|
||||
object
|
||||
)
|
||||
|
@ -430,10 +430,10 @@ GameLib.D3.Editor.prototype.selectObject = function(object) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Selects a GameLib Object
|
||||
* @param object GameLib.*
|
||||
* Selects a R3 Object
|
||||
* @param object R3.*
|
||||
*/
|
||||
GameLib.D3.Editor.prototype.deSelectObject = function(object) {
|
||||
R3.D3.Editor.prototype.deSelectObject = function(object) {
|
||||
|
||||
var results = this.selectedObjects.reduce(
|
||||
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(
|
||||
function(viewport){
|
||||
|
@ -478,16 +478,16 @@ GameLib.D3.Editor.prototype.setSize = function(width, height) {
|
|||
|
||||
/**
|
||||
* 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 &&
|
||||
!scene instanceof GameLib.D3.API.Scene) {
|
||||
if (!scene instanceof R3.D3.Scene &&
|
||||
!scene instanceof R3.D3.API.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);
|
||||
|
||||
|
@ -506,8 +506,8 @@ GameLib.D3.Editor.prototype.addScene = function(scene) {
|
|||
*/
|
||||
var entities = this.entityManager.query(
|
||||
[
|
||||
GameLib.D3.Renderer,
|
||||
GameLib.System
|
||||
R3.D3.Renderer,
|
||||
R3.System
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -521,11 +521,11 @@ GameLib.D3.Editor.prototype.addScene = function(scene) {
|
|||
/**
|
||||
* 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(
|
||||
function(system){
|
||||
system.notify('meshes', GameLib.D3.Mesh)
|
||||
system.notify('meshes', R3.D3.Mesh)
|
||||
}.bind(this)
|
||||
)
|
||||
|
|
@ -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;
|
|
@ -5,7 +5,7 @@
|
|||
* @param canvas
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.FlyControls = function(
|
||||
R3.D3.FlyControls = function(
|
||||
camera,
|
||||
THREE,
|
||||
canvas
|
|
@ -1,25 +1,25 @@
|
|||
/**
|
||||
* Runtime Follow Component
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param apiFollow
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Follow = function (
|
||||
R3.D3.Follow = function (
|
||||
graphics,
|
||||
apiFollow
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiFollow)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiFollow)) {
|
||||
apiFollow = {};
|
||||
}
|
||||
|
||||
if (apiFollow instanceof GameLib.D3.Follow) {
|
||||
if (apiFollow instanceof R3.D3.Follow) {
|
||||
return apiFollow;
|
||||
}
|
||||
|
||||
GameLib.D3.API.Follow.call(
|
||||
R3.D3.API.Follow.call(
|
||||
this,
|
||||
apiFollow.id,
|
||||
apiFollow.name,
|
||||
|
@ -31,31 +31,31 @@ GameLib.D3.Follow = function (
|
|||
apiFollow.parentEntity
|
||||
);
|
||||
|
||||
this.targetPositionOffset = new GameLib.Vector3(
|
||||
this.targetPositionOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.targetPositionOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.target = new GameLib.Vector3(
|
||||
this.target = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.target,
|
||||
this
|
||||
);
|
||||
|
||||
this.targetToParent = new GameLib.Vector3(
|
||||
this.targetToParent = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.targetToParent,
|
||||
this
|
||||
);
|
||||
|
||||
this.rotatedTargetOffset = new GameLib.Vector3(
|
||||
this.rotatedTargetOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.rotatedTargetOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.rotated = new GameLib.Quaternion(
|
||||
this.rotated = new R3.Quaternion(
|
||||
this.graphics,
|
||||
this.rotated,
|
||||
this
|
||||
|
@ -65,30 +65,30 @@ GameLib.D3.Follow = function (
|
|||
|
||||
};
|
||||
|
||||
GameLib.D3.Follow.prototype = Object.create(GameLib.D3.API.Follow.prototype);
|
||||
GameLib.D3.Follow.prototype.constructor = GameLib.D3.Follow;
|
||||
R3.D3.Follow.prototype = Object.create(R3.D3.API.Follow.prototype);
|
||||
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.name,
|
||||
GameLib.Utils.IdOrNull(this.currentComponent),
|
||||
GameLib.Utils.IdOrNull(this.targetComponent),
|
||||
R3.Utils.IdOrNull(this.currentComponent),
|
||||
R3.Utils.IdOrNull(this.targetComponent),
|
||||
this.targetPositionOffset.toApiObject(),
|
||||
this.minDistance,
|
||||
this.moveSpeed,
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
|
||||
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,
|
||||
apiFollow
|
||||
);
|
||||
|
@ -98,7 +98,7 @@ GameLib.D3.Follow.FromObject = function(graphics, objectComponent) {
|
|||
* Updates the component
|
||||
* @param deltaTime
|
||||
*/
|
||||
GameLib.D3.Follow.prototype.update = function(deltaTime) {
|
||||
R3.D3.Follow.prototype.update = function(deltaTime) {
|
||||
|
||||
if (this.currentComponent && this.targetComponent) {
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
/**
|
||||
* Game Runtime
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param apiGame GameLib.D3.API.Game
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param apiGame R3.D3.API.Game
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Game = function (
|
||||
R3.D3.Game = function (
|
||||
graphics,
|
||||
apiGame
|
||||
) {
|
||||
|
@ -12,15 +12,15 @@ GameLib.D3.Game = function (
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiGame)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiGame)) {
|
||||
apiGame = {};
|
||||
}
|
||||
|
||||
if (apiGame instanceof GameLib.D3.Game) {
|
||||
if (apiGame instanceof R3.D3.Game) {
|
||||
return apiGame;
|
||||
}
|
||||
|
||||
GameLib.D3.API.Game.call(
|
||||
R3.D3.API.Game.call(
|
||||
this,
|
||||
apiGame.id,
|
||||
apiGame.name,
|
||||
|
@ -38,8 +38,8 @@ GameLib.D3.Game = function (
|
|||
apiGame.parentEntity
|
||||
);
|
||||
|
||||
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) {
|
||||
this.imageFactory = new GameLib.D3.ImageFactory(
|
||||
if (this.imageFactory instanceof R3.D3.API.ImageFactory) {
|
||||
this.imageFactory = new R3.D3.ImageFactory(
|
||||
this.graphics,
|
||||
this.imageFactory
|
||||
);
|
||||
|
@ -47,8 +47,8 @@ GameLib.D3.Game = function (
|
|||
|
||||
this.cameras = this.cameras.map(
|
||||
function (apiCamera) {
|
||||
if (apiCamera instanceof GameLib.D3.API.Camera) {
|
||||
return new GameLib.D3.Camera(
|
||||
if (apiCamera instanceof R3.D3.API.Camera) {
|
||||
return new R3.D3.Camera(
|
||||
this.graphics,
|
||||
apiCamera
|
||||
)
|
||||
|
@ -61,8 +61,8 @@ GameLib.D3.Game = function (
|
|||
|
||||
this.composers = this.composers.map(
|
||||
function (apiComposer) {
|
||||
if (apiComposer instanceof GameLib.D3.API.Composer) {
|
||||
return new GameLib.D3.Composer(
|
||||
if (apiComposer instanceof R3.D3.API.Composer) {
|
||||
return new R3.D3.Composer(
|
||||
this.graphics,
|
||||
apiComposer
|
||||
)
|
||||
|
@ -75,8 +75,8 @@ GameLib.D3.Game = function (
|
|||
|
||||
this.viewports = this.viewports.map(
|
||||
function (apiViewport) {
|
||||
if (apiViewport instanceof GameLib.D3.API.Viewport) {
|
||||
return new GameLib.D3.Viewport(
|
||||
if (apiViewport instanceof R3.D3.API.Viewport) {
|
||||
return new R3.D3.Viewport(
|
||||
this.graphics,
|
||||
apiViewport
|
||||
)
|
||||
|
@ -89,8 +89,8 @@ GameLib.D3.Game = function (
|
|||
|
||||
this.renderers = this.renderers.map(
|
||||
function (apiRenderer) {
|
||||
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
||||
return new GameLib.D3.Renderer(
|
||||
if (apiRenderer instanceof R3.D3.API.Renderer) {
|
||||
return new R3.D3.Renderer(
|
||||
this.graphics,
|
||||
apiRenderer
|
||||
)
|
||||
|
@ -103,8 +103,8 @@ GameLib.D3.Game = function (
|
|||
|
||||
this.renderTargets = this.renderTargets.map(
|
||||
function (apiRenderTarget) {
|
||||
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||
return new GameLib.D3.RenderTarget(
|
||||
if (apiRenderTarget instanceof R3.D3.API.RenderTarget) {
|
||||
return new R3.D3.RenderTarget(
|
||||
this.graphics,
|
||||
apiRenderTarget
|
||||
)
|
||||
|
@ -117,8 +117,8 @@ GameLib.D3.Game = function (
|
|||
|
||||
this.systems = this.systems.map(
|
||||
function (apiSystem) {
|
||||
if (apiSystem instanceof GameLib.API.System) {
|
||||
return new GameLib.System(
|
||||
if (apiSystem instanceof R3.API.System) {
|
||||
return new R3.System(
|
||||
this.graphics,
|
||||
apiSystem
|
||||
)
|
||||
|
@ -130,8 +130,8 @@ GameLib.D3.Game = function (
|
|||
);
|
||||
|
||||
if (this.entityManager) {
|
||||
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
||||
this.entityManager = new GameLib.EntityManager(
|
||||
if (this.entityManager instanceof R3.API.EntityManager) {
|
||||
this.entityManager = new R3.EntityManager(
|
||||
this.graphics,
|
||||
this.entityManager
|
||||
);
|
||||
|
@ -146,17 +146,17 @@ GameLib.D3.Game = function (
|
|||
this.linkObjects(this.idToObject);
|
||||
};
|
||||
|
||||
GameLib.D3.Game.prototype = Object.create(GameLib.D3.API.Game.prototype);
|
||||
GameLib.D3.Game.prototype.constructor = GameLib.D3.Game;
|
||||
R3.D3.Game.prototype = Object.create(R3.D3.API.Game.prototype);
|
||||
R3.D3.Game.prototype.constructor = R3.D3.Game;
|
||||
|
||||
GameLib.D3.Game.GAME_TYPE_VR_PONG = 0x1;
|
||||
GameLib.D3.Game.GAME_TYPE_VR_RACER = 0x2;
|
||||
R3.D3.Game.GAME_TYPE_VR_PONG = 0x1;
|
||||
R3.D3.Game.GAME_TYPE_VR_RACER = 0x2;
|
||||
|
||||
/**
|
||||
* Creates a camera instance of 'graphics' type (only THREE for now)
|
||||
* @returns {THREE.Game}
|
||||
*/
|
||||
GameLib.D3.Game.prototype.createInstance = function(update) {
|
||||
R3.D3.Game.prototype.createInstance = function(update) {
|
||||
|
||||
var instance = null;
|
||||
|
||||
|
@ -167,7 +167,7 @@ GameLib.D3.Game.prototype.createInstance = function(update) {
|
|||
return instance;
|
||||
};
|
||||
|
||||
// GameLib.D3.Game.prototype.setSize = function(width, height) {
|
||||
// R3.D3.Game.prototype.setSize = function(width, height) {
|
||||
//
|
||||
// // var w = 0;
|
||||
// // var h = 0;
|
||||
|
@ -193,15 +193,15 @@ GameLib.D3.Game.prototype.createInstance = function(update) {
|
|||
/**
|
||||
* Updates the instance with the current state
|
||||
*/
|
||||
GameLib.D3.Game.prototype.updateInstance = function() {
|
||||
R3.D3.Game.prototype.updateInstance = function() {
|
||||
this.instance = this.createInstance(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a GameLib.D3.Game to a new GameLib.D3.API.Game
|
||||
* @returns {GameLib.D3.API.Game}
|
||||
* Converts a R3.D3.Game to a new R3.D3.API.Game
|
||||
* @returns {R3.D3.API.Game}
|
||||
*/
|
||||
GameLib.D3.Game.prototype.toApiObject = function() {
|
||||
R3.D3.Game.prototype.toApiObject = function() {
|
||||
|
||||
var apiImageFactory = null;
|
||||
var apiCameras = [];
|
||||
|
@ -212,14 +212,14 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
var apiSystems = [];
|
||||
var apiEntityManager = null;
|
||||
|
||||
if (this.imageFactory instanceof GameLib.D3.ImageFactory) {
|
||||
if (this.imageFactory instanceof R3.D3.ImageFactory) {
|
||||
apiImageFactory = this.imageFactory.toApiObject();
|
||||
}
|
||||
|
||||
if (this.cameras) {
|
||||
apiCameras = this.cameras.map(
|
||||
function(camera) {
|
||||
if (camera instanceof GameLib.D3.Camera) {
|
||||
if (camera instanceof R3.D3.Camera) {
|
||||
return camera.toApiObject();
|
||||
} else {
|
||||
console.warn('camera not an instance of Camera');
|
||||
|
@ -232,7 +232,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
if (this.composers) {
|
||||
apiComposers = this.composers.map(
|
||||
function(composer) {
|
||||
if (composer instanceof GameLib.D3.Composer) {
|
||||
if (composer instanceof R3.D3.Composer) {
|
||||
return composer.toApiObject();
|
||||
} else {
|
||||
console.warn('composer not an instance of Composer');
|
||||
|
@ -245,7 +245,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
if (this.viewports) {
|
||||
apiViewports = this.viewports.map(
|
||||
function(viewport) {
|
||||
if (viewport instanceof GameLib.D3.Viewport) {
|
||||
if (viewport instanceof R3.D3.Viewport) {
|
||||
return viewport.toApiObject();
|
||||
} else {
|
||||
console.warn('viewport not an instance of Viewport');
|
||||
|
@ -258,7 +258,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
if (this.renderers) {
|
||||
apiRenderers = this.renderers.map(
|
||||
function(renderer) {
|
||||
if (renderer instanceof GameLib.D3.Renderer) {
|
||||
if (renderer instanceof R3.D3.Renderer) {
|
||||
return renderer.toApiObject();
|
||||
} else {
|
||||
console.warn('renderer not an instance of Renderer');
|
||||
|
@ -271,7 +271,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
if (this.renderTargets) {
|
||||
apiRenderTargets = this.renderTargets.map(
|
||||
function(renderTarget) {
|
||||
if (renderTarget instanceof GameLib.D3.RenderTarget) {
|
||||
if (renderTarget instanceof R3.D3.RenderTarget) {
|
||||
return renderTarget.toApiObject();
|
||||
} else {
|
||||
console.warn('renderTarget not an instance of RenderTarget');
|
||||
|
@ -284,7 +284,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
if (this.systems) {
|
||||
apiSystems = this.systems.map(
|
||||
function(system) {
|
||||
if (system instanceof GameLib.System) {
|
||||
if (system instanceof R3.System) {
|
||||
return system.toApiObject();
|
||||
} else {
|
||||
console.warn('system not an instance of System');
|
||||
|
@ -295,7 +295,7 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
}
|
||||
|
||||
if (this.entityManager) {
|
||||
if (this.entityManager instanceof GameLib.EntityManager) {
|
||||
if (this.entityManager instanceof R3.EntityManager) {
|
||||
apiEntityManager = this.entityManager.toApiObject();
|
||||
} else {
|
||||
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.name,
|
||||
this.baseUrl,
|
||||
|
@ -317,22 +317,22 @@ GameLib.D3.Game.prototype.toApiObject = function() {
|
|||
apiRenderTargets,
|
||||
apiSystems,
|
||||
apiEntityManager,
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts from an Object Game to a GameLib.D3.Game
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* Converts from an Object Game to a R3.D3.Game
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param objectGame Object
|
||||
* @returns {GameLib.D3.Game}
|
||||
* @returns {R3.D3.Game}
|
||||
* @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,
|
||||
apiGame
|
||||
);
|
||||
|
@ -346,12 +346,12 @@ GameLib.D3.Game.FromObjectGame = function(graphics, objectGame) {
|
|||
* @param onLoaded
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Game.LoadGame = function(
|
||||
R3.D3.Game.LoadGame = function(
|
||||
graphics,
|
||||
objectGame,
|
||||
onLoaded
|
||||
) {
|
||||
var game = GameLib.D3.Game.FromObjectGame(
|
||||
var game = R3.D3.Game.FromObjectGame(
|
||||
graphics,
|
||||
objectGame
|
||||
);
|
||||
|
@ -361,14 +361,14 @@ GameLib.D3.Game.LoadGame = function(
|
|||
|
||||
/**
|
||||
* Loads a Game from the API
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param partialGameObject Object
|
||||
* @param onLoaded callback
|
||||
* @param apiUrl
|
||||
* @returns {*}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Game.LoadGameFromApi = function(
|
||||
R3.D3.Game.LoadGameFromApi = function(
|
||||
graphics,
|
||||
partialGameObject,
|
||||
onLoaded,
|
||||
|
@ -410,7 +410,7 @@ GameLib.D3.Game.LoadGameFromApi = function(
|
|||
|
||||
var objectGame = response.game[0];
|
||||
|
||||
GameLib.D3.Game.LoadGame(
|
||||
R3.D3.Game.LoadGame(
|
||||
graphics,
|
||||
objectGame,
|
||||
onLoaded
|
||||
|
@ -422,7 +422,7 @@ GameLib.D3.Game.LoadGameFromApi = function(
|
|||
xhr.send();
|
||||
};
|
||||
|
||||
GameLib.D3.Game.prototype.setSize = function(width, height) {
|
||||
R3.D3.Game.prototype.setSize = function(width, height) {
|
||||
this.renderers.map(
|
||||
function(renderer) {
|
||||
renderer.setSize(width, height);
|
|
@ -6,7 +6,7 @@
|
|||
* @param heightScale Number
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Heightmap = function Heightmap(
|
||||
R3.D3.Heightmap = function Heightmap(
|
||||
sizeX,
|
||||
sizeY,
|
||||
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
|
||||
return {
|
||||
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
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param shape GameLib.D3.Shape
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param shape R3.D3.Shape
|
||||
* @param engine R3.D3.Engine
|
||||
* @returns {THREE.Mesh|this.meshes}
|
||||
*/
|
||||
GameLib.D3.Heightmap.GenerateInstanceMesh = function(
|
||||
R3.D3.Heightmap.GenerateInstanceMesh = function(
|
||||
graphics,
|
||||
shape,
|
||||
engine
|
||||
|
@ -113,7 +113,7 @@ GameLib.D3.Heightmap.GenerateInstanceMesh = function(
|
|||
* @param callback
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Heightmap.GenerateHeightmapDataFromImage = function (
|
||||
R3.D3.Heightmap.GenerateHeightmapDataFromImage = function (
|
||||
imagePath,
|
||||
heightScale,
|
||||
callback
|
||||
|
@ -152,7 +152,7 @@ GameLib.D3.Heightmap.GenerateHeightmapDataFromImage = function (
|
|||
// todo: delete canvas here
|
||||
|
||||
callback(
|
||||
new GameLib.D3.Heightmap(
|
||||
new R3.D3.Heightmap(
|
||||
sizeX,
|
||||
sizeY,
|
||||
matrix,
|
|
@ -3,10 +3,10 @@
|
|||
* @param graphics
|
||||
* @param apiImageFactory
|
||||
* @param progressCallback
|
||||
* @returns {GameLib.D3.ImageFactory}
|
||||
* @returns {R3.D3.ImageFactory}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.ImageFactory = function (
|
||||
R3.D3.ImageFactory = function (
|
||||
graphics,
|
||||
apiImageFactory,
|
||||
progressCallback
|
||||
|
@ -14,15 +14,15 @@ GameLib.D3.ImageFactory = function (
|
|||
graphics.isNotThreeThrow();
|
||||
this.graphics = graphics;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiImageFactory)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiImageFactory)) {
|
||||
apiImageFactory = {};
|
||||
}
|
||||
|
||||
if (apiImageFactory instanceof GameLib.D3.ImageFactory) {
|
||||
if (apiImageFactory instanceof R3.D3.ImageFactory) {
|
||||
return apiImageFactory;
|
||||
}
|
||||
|
||||
GameLib.D3.API.ImageFactory.call(
|
||||
R3.D3.API.ImageFactory.call(
|
||||
this,
|
||||
apiImageFactory.id,
|
||||
apiImageFactory.name,
|
||||
|
@ -30,23 +30,23 @@ GameLib.D3.ImageFactory = function (
|
|||
apiImageFactory.parentEntity
|
||||
);
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(progressCallback)) {
|
||||
if (R3.Utils.UndefinedOrNull(progressCallback)) {
|
||||
progressCallback = null;
|
||||
}
|
||||
this.progressCallback = progressCallback;
|
||||
|
||||
GameLib.Component.call(
|
||||
R3.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_IMAGE_FACTORY
|
||||
R3.Component.COMPONENT_IMAGE_FACTORY
|
||||
);
|
||||
|
||||
this.promiseList = {};
|
||||
};
|
||||
|
||||
GameLib.D3.ImageFactory.prototype = Object.create(GameLib.D3.API.ImageFactory.prototype);
|
||||
GameLib.D3.ImageFactory.prototype.constructor = GameLib.D3.ImageFactory;
|
||||
R3.D3.ImageFactory.prototype = Object.create(R3.D3.API.ImageFactory.prototype);
|
||||
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) {
|
||||
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
|
||||
*/
|
||||
GameLib.D3.ImageFactory.prototype.updateInstance = function() {
|
||||
R3.D3.ImageFactory.prototype.updateInstance = function() {
|
||||
this.instance = this.createInstance(true);
|
||||
};
|
||||
|
||||
|
@ -80,7 +80,7 @@ GameLib.D3.ImageFactory.prototype.updateInstance = function() {
|
|||
* @returns {*}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.ImageFactory.prototype.loadImage = function(
|
||||
R3.D3.ImageFactory.prototype.loadImage = function(
|
||||
imagePath,
|
||||
force
|
||||
) {
|
||||
|
@ -104,8 +104,8 @@ GameLib.D3.ImageFactory.prototype.loadImage = function(
|
|||
this.baseUrl + imagePath + '?ts=' + Date.now(),
|
||||
function (image) {
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.IMAGE_LOADED,
|
||||
R3.Event.Emit(
|
||||
R3.Event.IMAGE_LOADED,
|
||||
{
|
||||
imagePath : imagePath,
|
||||
imageInstance : image
|
||||
|
@ -128,29 +128,29 @@ GameLib.D3.ImageFactory.prototype.loadImage = function(
|
|||
};
|
||||
|
||||
/**
|
||||
* Converts a GameLib.D3.ImageFactory to a GameLib.D3.API.ImageFactory
|
||||
* @returns {GameLib.D3.API.ImageFactory}
|
||||
* Converts a R3.D3.ImageFactory to a R3.D3.API.ImageFactory
|
||||
* @returns {R3.D3.API.ImageFactory}
|
||||
*/
|
||||
GameLib.D3.ImageFactory.prototype.toApiObject = function() {
|
||||
return new GameLib.D3.API.ImageFactory(
|
||||
R3.D3.ImageFactory.prototype.toApiObject = function() {
|
||||
return new R3.D3.API.ImageFactory(
|
||||
this.id,
|
||||
this.name,
|
||||
this.baseUrl,
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a new GameLib.D3.ImageFactory from a GameLib.D3.API.ImageFactory
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param objectImageFactory GameLib.D3.API.ImageFactory
|
||||
* @returns {GameLib.D3.ImageFactory}
|
||||
* Returns a new R3.D3.ImageFactory from a R3.D3.API.ImageFactory
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param objectImageFactory R3.D3.API.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,
|
||||
GameLib.D3.API.ImageFactory.FromObject(objectImageFactory)
|
||||
R3.D3.API.ImageFactory.FromObject(objectImageFactory)
|
||||
);
|
||||
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* R3.D3.Input namespace
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Input = function () {};
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* Input parent class
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param apiInputDrive GameLib.D3.API.Input.Drive
|
||||
* @param dom GameLib.Dom
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param apiInputDrive R3.D3.API.Input.Drive
|
||||
* @param dom R3.Dom
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Input.Drive = function (
|
||||
R3.D3.Input.Drive = function (
|
||||
graphics,
|
||||
apiInputDrive,
|
||||
dom
|
||||
|
@ -14,15 +14,15 @@ GameLib.D3.Input.Drive = function (
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiInputDrive)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiInputDrive)) {
|
||||
apiInputDrive = {};
|
||||
}
|
||||
|
||||
if (apiInputDrive instanceof GameLib.D3.Drive) {
|
||||
if (apiInputDrive instanceof R3.D3.Drive) {
|
||||
return apiInputDrive;
|
||||
}
|
||||
|
||||
GameLib.D3.API.Input.Drive.call(
|
||||
R3.D3.API.Input.Drive.call(
|
||||
this,
|
||||
apiInputDrive.id,
|
||||
apiInputDrive.name,
|
||||
|
@ -39,7 +39,7 @@ GameLib.D3.Input.Drive = function (
|
|||
apiInputDrive.rotationFactor
|
||||
);
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(dom)) {
|
||||
if (R3.Utils.UndefinedOrNull(dom)) {
|
||||
console.warn('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;
|
||||
|
||||
GameLib.Component.call(
|
||||
R3.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_INPUT_DRIVE,
|
||||
R3.Component.COMPONENT_INPUT_DRIVE,
|
||||
{
|
||||
'pathFollowingComponent' : GameLib.D3.PathFollowing,
|
||||
'wheelFL' : GameLib.D3.Mesh,
|
||||
'wheelFR' : GameLib.D3.Mesh,
|
||||
'wheelRL' : GameLib.D3.Mesh,
|
||||
'wheelRR' : GameLib.D3.Mesh
|
||||
'pathFollowingComponent' : R3.D3.PathFollowing,
|
||||
'wheelFL' : R3.D3.Mesh,
|
||||
'wheelFR' : R3.D3.Mesh,
|
||||
'wheelRL' : R3.D3.Mesh,
|
||||
'wheelRR' : R3.D3.Mesh
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Drive.prototype = Object.create(GameLib.D3.API.Input.Drive.prototype);
|
||||
GameLib.D3.Input.Drive.prototype.constructor = GameLib.D3.Input.Drive;
|
||||
R3.D3.Input.Drive.prototype = Object.create(R3.D3.API.Input.Drive.prototype);
|
||||
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) {
|
||||
return this.instance;
|
||||
|
@ -104,26 +104,26 @@ GameLib.D3.Input.Drive.prototype.createInstance = function(update) {
|
|||
return instance;
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Drive.prototype.updateInstance = function() {
|
||||
R3.D3.Input.Drive.prototype.updateInstance = function() {
|
||||
this.instance = this.createInstance(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* GameLib.D3.Input.Drive to GameLib.D3.API.Input.Drive
|
||||
* @returns {GameLib.D3.API.Input.Drive}
|
||||
* R3.D3.Input.Drive to R3.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.name,
|
||||
this.domElementId,
|
||||
GameLib.Utils.IdOrNull(this.pathFollowingComponent),
|
||||
GameLib.Utils.IdOrNull(this.parentEntity),
|
||||
GameLib.Utils.IdOrNull(this.wheelFL),
|
||||
GameLib.Utils.IdOrNull(this.wheelFR),
|
||||
GameLib.Utils.IdOrNull(this.wheelRL),
|
||||
GameLib.Utils.IdOrNull(this.wheelRR),
|
||||
R3.Utils.IdOrNull(this.pathFollowingComponent),
|
||||
R3.Utils.IdOrNull(this.parentEntity),
|
||||
R3.Utils.IdOrNull(this.wheelFL),
|
||||
R3.Utils.IdOrNull(this.wheelFR),
|
||||
R3.Utils.IdOrNull(this.wheelRL),
|
||||
R3.Utils.IdOrNull(this.wheelRR),
|
||||
this.heightOffset,
|
||||
this.distance,
|
||||
this.distanceGrain,
|
||||
|
@ -133,17 +133,17 @@ GameLib.D3.Input.Drive.prototype.toApiObject = function() {
|
|||
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,
|
||||
apiInputDrive
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Drive.prototype.update = function(deltaTime) {
|
||||
R3.D3.Input.Drive.prototype.update = function(deltaTime) {
|
||||
if (this.pathFollowingComponent) {
|
||||
|
||||
this.pathFollowingComponent.mesh.localPosition.x = (this.heightOffset * this.pathFollowingComponent.rotationMatrix.up.x);
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* Input parent class
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param parentObject
|
||||
* @param apiInputEditor GameLib.D3.API.Input.Editor
|
||||
* @param apiInputEditor R3.D3.API.Input.Editor
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Input.Editor = function RuntimeEditorInput(
|
||||
R3.D3.Input.Editor = function RuntimeEditorInput(
|
||||
graphics,
|
||||
parentObject,
|
||||
apiInputEditor
|
||||
|
@ -14,12 +14,12 @@ GameLib.D3.Input.Editor = function RuntimeEditorInput(
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
|
||||
if (R3.Utils.UndefinedOrNull(parentObject)) {
|
||||
parentObject = null;
|
||||
}
|
||||
this.parentObject = parentObject;
|
||||
|
||||
GameLib.D3.API.Input.Editor.call(
|
||||
R3.D3.API.Input.Editor.call(
|
||||
this,
|
||||
apiInputEditor.id,
|
||||
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);
|
||||
GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor;
|
||||
R3.D3.Input.Editor.prototype = Object.create(R3.D3.API.Input.Editor.prototype);
|
||||
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;
|
||||
|
||||
|
@ -52,26 +52,26 @@ GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
|
|||
return instance;
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Editor.prototype.updateInstance = function() {
|
||||
R3.D3.Input.Editor.prototype.updateInstance = function() {
|
||||
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.name,
|
||||
this.domElementId,
|
||||
GameLib.Utils.IdOrNull(this.camera),
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.camera),
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
|
||||
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.name,
|
||||
objectComponent.domElementId,
|
||||
|
@ -79,7 +79,7 @@ GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent
|
|||
objectComponent.parentEntity
|
||||
);
|
||||
|
||||
return new GameLib.D3.Input.Editor(
|
||||
return new R3.D3.Input.Editor(
|
||||
graphics,
|
||||
this,
|
||||
apiInputEditor
|
|
@ -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
|
||||
);
|
||||
};
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* Input parent class
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param parentObject
|
||||
* @param apiInputFly GameLib.D3.API.Input.Fly
|
||||
* @param apiInputFly R3.D3.API.Input.Fly
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Input.Fly = function RuntimeEditorInput(
|
||||
R3.D3.Input.Fly = function RuntimeEditorInput(
|
||||
graphics,
|
||||
parentObject,
|
||||
apiInputFly
|
||||
|
@ -14,12 +14,12 @@ GameLib.D3.Input.Fly = function RuntimeEditorInput(
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
|
||||
if (R3.Utils.UndefinedOrNull(parentObject)) {
|
||||
parentObject = null;
|
||||
}
|
||||
this.parentObject = parentObject;
|
||||
|
||||
GameLib.D3.API.Input.Fly.call(
|
||||
R3.D3.API.Input.Fly.call(
|
||||
this,
|
||||
apiInputFly.id,
|
||||
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);
|
||||
GameLib.D3.Input.Fly.prototype.constructor = GameLib.D3.Input.Fly;
|
||||
R3.D3.Input.Fly.prototype = Object.create(R3.D3.API.Input.Fly.prototype);
|
||||
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
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Fly.prototype.updateInstance = function() {
|
||||
R3.D3.Input.Fly.prototype.updateInstance = function() {
|
||||
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.name,
|
||||
this.domElementId,
|
||||
GameLib.Utils.IdOrNull(this.camera)
|
||||
R3.Utils.IdOrNull(this.camera)
|
||||
);
|
||||
|
||||
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.name,
|
||||
objectComponent.domElementId,
|
||||
objectComponent.camera
|
||||
);
|
||||
|
||||
return new GameLib.D3.Input.Fly(
|
||||
return new R3.D3.Input.Fly(
|
||||
graphics,
|
||||
this,
|
||||
apiInputFly
|
||||
|
@ -101,7 +101,7 @@ GameLib.D3.Input.Fly.FromObjectComponent = function(graphics, objectComponent) {
|
|||
* Go forward / backward on mouse wheel
|
||||
* @param event
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.onMouseWheel = function(event) {
|
||||
R3.D3.Input.Fly.prototype.onMouseWheel = function(event) {
|
||||
this.moveForward = true;
|
||||
this.applyTranslation(event.wheelDelta * 0.001);
|
||||
event.preventDefault();
|
||||
|
@ -112,7 +112,7 @@ GameLib.D3.Input.Fly.prototype.onMouseWheel = function(event) {
|
|||
* Start rotating the camera on mouse middle button down
|
||||
* @param event
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.onMouseDown = function(event) {
|
||||
R3.D3.Input.Fly.prototype.onMouseDown = function(event) {
|
||||
if (event.button == 1) {
|
||||
this.canRotate = true;
|
||||
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
|
||||
* @param event
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.onMouseUp = function(event) {
|
||||
R3.D3.Input.Fly.prototype.onMouseUp = function(event) {
|
||||
if (event.button == 1) {
|
||||
this.canRotate = false;
|
||||
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
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.applyRotation = function() {
|
||||
R3.D3.Input.Fly.prototype.applyRotation = function() {
|
||||
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
|
||||
* @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 rotation = new this.THREE.Euler(0, 0, 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
|
||||
* @param deltaTime
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.update = function(deltaTime) {
|
||||
R3.D3.Input.Fly.prototype.update = function(deltaTime) {
|
||||
this.applyRotation();
|
||||
this.applyTranslation(deltaTime);
|
||||
};
|
||||
|
@ -202,7 +202,7 @@ GameLib.D3.Input.Fly.prototype.update = function(deltaTime) {
|
|||
* Rotate on mouse move
|
||||
* @param event
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.onMouseMove = function ( event ) {
|
||||
R3.D3.Input.Fly.prototype.onMouseMove = function ( event ) {
|
||||
if (this.canRotate) {
|
||||
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
|
||||
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
|
||||
|
@ -216,7 +216,7 @@ GameLib.D3.Input.Fly.prototype.onMouseMove = function ( event ) {
|
|||
* Keyboard controls
|
||||
* @param event
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.onKeyDown = function ( event ) {
|
||||
R3.D3.Input.Fly.prototype.onKeyDown = function ( event ) {
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case 87: // w
|
||||
|
@ -249,7 +249,7 @@ GameLib.D3.Input.Fly.prototype.onKeyDown = function ( event ) {
|
|||
* Keyboard controls
|
||||
* @param event
|
||||
*/
|
||||
GameLib.D3.Input.Fly.prototype.onKeyUp = function ( event ) {
|
||||
R3.D3.Input.Fly.prototype.onKeyUp = function ( event ) {
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case 38: // up
|
|
@ -1,25 +1,25 @@
|
|||
/**
|
||||
* Entities with LookAt component looks to targetPosition (default up is 0,1,0)
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* @param apiLookAt GameLib.D3.API.LookAt
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param apiLookAt R3.D3.API.LookAt
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.LookAt = function (
|
||||
R3.D3.LookAt = function (
|
||||
graphics,
|
||||
apiLookAt
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiLookAt)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiLookAt)) {
|
||||
apiLookAt = {};
|
||||
}
|
||||
|
||||
if (apiLookAt instanceof GameLib.D3.LookAt) {
|
||||
if (apiLookAt instanceof R3.D3.LookAt) {
|
||||
return apiLookAt;
|
||||
}
|
||||
|
||||
GameLib.D3.API.LookAt.call(
|
||||
R3.D3.API.LookAt.call(
|
||||
this,
|
||||
apiLookAt.id,
|
||||
apiLookAt.name,
|
||||
|
@ -30,81 +30,81 @@ GameLib.D3.LookAt = function (
|
|||
apiLookAt.parentEntity
|
||||
);
|
||||
|
||||
this.targetPositionOffset = new GameLib.Vector3(
|
||||
this.targetPositionOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.targetPositionOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.lookAtMatrix = new GameLib.Matrix4(
|
||||
this.lookAtMatrix = new R3.Matrix4(
|
||||
this.graphics,
|
||||
this.lookAtMatrix,
|
||||
this
|
||||
);
|
||||
|
||||
this.up = new GameLib.Vector3(
|
||||
this.up = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.up,
|
||||
this
|
||||
);
|
||||
|
||||
this.currentRotation = new GameLib.Quaternion(
|
||||
this.currentRotation = new R3.Quaternion(
|
||||
this.graphics,
|
||||
this.currentRotation,
|
||||
this
|
||||
);
|
||||
|
||||
this.targetPosition = new GameLib.Vector3(
|
||||
this.targetPosition = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.targetPosition,
|
||||
this
|
||||
);
|
||||
|
||||
GameLib.Component.call(
|
||||
R3.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_LOOK_AT,
|
||||
R3.Component.COMPONENT_LOOK_AT,
|
||||
{
|
||||
'currentComponent' : GameLib.Component,
|
||||
'targetComponent' : GameLib.Component
|
||||
'currentComponent' : R3.Component,
|
||||
'targetComponent' : R3.Component
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype);
|
||||
GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt;
|
||||
R3.D3.LookAt.prototype = Object.create(R3.D3.API.LookAt.prototype);
|
||||
R3.D3.LookAt.prototype.constructor = R3.D3.LookAt;
|
||||
|
||||
GameLib.D3.LookAt.prototype.createInstance = function() {
|
||||
R3.D3.LookAt.prototype.createInstance = function() {
|
||||
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
|
||||
* @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.name,
|
||||
GameLib.Utils.IdOrNull(this.currentComponent),
|
||||
GameLib.Utils.IdOrNull(this.targetComponent),
|
||||
R3.Utils.IdOrNull(this.currentComponent),
|
||||
R3.Utils.IdOrNull(this.targetComponent),
|
||||
this.targetPositionOffset.toApiObject(),
|
||||
this.rotationSpeed,
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
|
||||
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,
|
||||
apiLookAt
|
||||
);
|
||||
|
@ -114,7 +114,7 @@ GameLib.D3.LookAt.FromObject = function(graphics, objectComponent) {
|
|||
* Looks at using time
|
||||
* @param deltaTime
|
||||
*/
|
||||
GameLib.D3.LookAt.prototype.update = function(deltaTime) {
|
||||
R3.D3.LookAt.prototype.update = function(deltaTime) {
|
||||
|
||||
if (this.currentComponent && this.targetComponent) {
|
||||
|
||||
|
@ -130,7 +130,7 @@ GameLib.D3.LookAt.prototype.update = function(deltaTime) {
|
|||
// 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);
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* GameLib.D3.Mesh.Box
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* R3.D3.Mesh.Box
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param apiMeshBox
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Box = function (
|
||||
R3.D3.Mesh.Box = function (
|
||||
graphics,
|
||||
apiMeshBox
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMeshBox)) {
|
||||
if (R3.Utils.UndefinedOrNull(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,
|
||||
apiMeshBox,
|
||||
apiMeshBox.width,
|
||||
|
@ -25,17 +25,17 @@ GameLib.D3.Mesh.Box = function (
|
|||
apiMeshBox.depth
|
||||
);
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
R3.D3.Mesh.call(
|
||||
this,
|
||||
this.graphics,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Box.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Box.prototype.constructor = GameLib.D3.Mesh.Box;
|
||||
R3.D3.Mesh.Box.prototype = Object.create(R3.D3.Mesh.prototype);
|
||||
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;
|
||||
|
||||
|
@ -50,10 +50,10 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
|
|||
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 (
|
||||
property === 'width' ||
|
||||
|
@ -75,18 +75,18 @@ GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
|
|||
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
|
||||
* @returns {GameLib.D3.API.Mesh.Box}
|
||||
* Converts a R3.D3.Mesh.Box to a R3.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,
|
||||
this.width,
|
||||
this.height,
|
|
@ -1,40 +1,40 @@
|
|||
/**
|
||||
* GameLib.D3.Mesh.Curve
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* R3.D3.Mesh.Curve
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param apiMeshCurve
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Curve = function (
|
||||
R3.D3.Mesh.Curve = function (
|
||||
graphics,
|
||||
apiMeshCurve
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMeshCurve)) {
|
||||
if (R3.Utils.UndefinedOrNull(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,
|
||||
apiMeshCurve,
|
||||
apiMeshCurve.pointSize
|
||||
);
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
R3.D3.Mesh.call(
|
||||
this,
|
||||
this.graphics,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Curve.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Curve.prototype.constructor = GameLib.D3.Mesh.Curve;
|
||||
R3.D3.Mesh.Curve.prototype = Object.create(R3.D3.Mesh.prototype);
|
||||
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');
|
||||
|
||||
|
@ -57,14 +57,14 @@ GameLib.D3.Mesh.Curve.prototype.createInstance = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* Converts a GameLib.D3.Mesh.Curve to a GameLib.D3.API.Mesh.Curve
|
||||
* @returns {GameLib.D3.API.Mesh.Curve}
|
||||
* Converts a R3.D3.Mesh.Curve to a R3.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,
|
||||
this.pointSize
|
||||
);
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* 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
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Cylinder = function (
|
||||
R3.D3.Mesh.Cylinder = function (
|
||||
graphics,
|
||||
apiMeshCylinder
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMeshCylinder)) {
|
||||
if (R3.Utils.UndefinedOrNull(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,
|
||||
apiMeshCylinder,
|
||||
apiMeshCylinder.radiusTop,
|
||||
|
@ -30,17 +30,17 @@ GameLib.D3.Mesh.Cylinder = function (
|
|||
apiMeshCylinder.thetaLength
|
||||
);
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
R3.D3.Mesh.call(
|
||||
this,
|
||||
graphics,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Cylinder.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Cylinder.prototype.constructor = GameLib.D3.Mesh.Cylinder;
|
||||
R3.D3.Mesh.Cylinder.prototype = Object.create(R3.D3.Mesh.prototype);
|
||||
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;
|
||||
|
||||
|
@ -58,10 +58,10 @@ GameLib.D3.Mesh.Cylinder.prototype.createInstance = function() {
|
|||
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 (
|
||||
property === 'radiusTop' ||
|
||||
|
@ -90,18 +90,18 @@ GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function(property) {
|
|||
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
|
||||
* @returns {GameLib.D3.API.Mesh.Cylinder}
|
||||
* Converts a R3.D3.Mesh.Cylinder to a R3.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,
|
||||
this.radiusTop,
|
||||
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
|
||||
*/
|
||||
GameLib.D3.Mesh.Cylinder.prototype.turnIntoDisplay = function() {
|
||||
R3.D3.Mesh.Cylinder.prototype.turnIntoDisplay = function() {
|
||||
|
||||
this.heightSegments = 1;
|
||||
this.updateInstance('heightSegments');
|
||||
|
@ -137,7 +137,7 @@ GameLib.D3.Mesh.Cylinder.prototype.turnIntoDisplay = function() {
|
|||
|
||||
for (var i = 0; i < this.radiusSegments; i++) {
|
||||
this.materials.push(
|
||||
new GameLib.D3.Material(this.graphics)
|
||||
new R3.D3.Material(this.graphics)
|
||||
)
|
||||
}
|
||||
|
|
@ -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;
|
||||
};
|
|
@ -1,10 +1,10 @@
|
|||
/**
|
||||
* 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
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Plane = function (
|
||||
R3.D3.Mesh.Plane = function (
|
||||
graphics,
|
||||
apiMeshPlane
|
||||
) {
|
||||
|
@ -12,13 +12,13 @@ GameLib.D3.Mesh.Plane = function (
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMeshPlane)) {
|
||||
if (R3.Utils.UndefinedOrNull(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,
|
||||
apiMeshPlane,
|
||||
apiMeshPlane.width,
|
||||
|
@ -34,19 +34,19 @@ GameLib.D3.Mesh.Plane = function (
|
|||
apiMeshPlane.dotObject
|
||||
);
|
||||
|
||||
this.dotMapScale = new GameLib.Vector3(
|
||||
this.dotMapScale = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.dotMapScale,
|
||||
this
|
||||
);
|
||||
|
||||
this.dotMapOffset = new GameLib.Vector3(
|
||||
this.dotMapOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.dotMapOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.dotMapWeight = new GameLib.Vector3(
|
||||
this.dotMapWeight = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.dotMapWeight,
|
||||
this
|
||||
|
@ -54,7 +54,7 @@ GameLib.D3.Mesh.Plane = function (
|
|||
|
||||
this.dots = [];
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
R3.D3.Mesh.call(
|
||||
this,
|
||||
graphics,
|
||||
apiMeshPlane
|
||||
|
@ -62,10 +62,10 @@ GameLib.D3.Mesh.Plane = function (
|
|||
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Plane.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Plane.prototype.constructor = GameLib.D3.Mesh.Plane;
|
||||
R3.D3.Mesh.Plane.prototype = Object.create(R3.D3.Mesh.prototype);
|
||||
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;
|
||||
|
||||
|
@ -94,7 +94,7 @@ GameLib.D3.Mesh.Plane.prototype.createInstance = function() {
|
|||
/**
|
||||
* Now construct the mesh instance
|
||||
*/
|
||||
GameLib.D3.Mesh.prototype.createInstance.call(this);
|
||||
R3.D3.Mesh.prototype.createInstance.call(this);
|
||||
|
||||
if (this.isDotMap && this.dotObject) {
|
||||
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;
|
||||
|
||||
|
@ -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
|
||||
* @returns {GameLib.D3.API.Mesh.Plane}
|
||||
* Converts a R3.D3.Mesh.Plane to a R3.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,
|
||||
this.width,
|
||||
this.height,
|
||||
|
@ -179,7 +179,7 @@ GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
|
|||
this.dotMapScale.toApiObject(),
|
||||
this.dotMapOffset.toApiObject(),
|
||||
this.dotMapWeight.toApiObject(),
|
||||
GameLib.Utils.IdOrNull(this.dotObject)
|
||||
R3.Utils.IdOrNull(this.dotObject)
|
||||
);
|
||||
|
||||
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 = [];
|
||||
|
||||
|
@ -239,7 +239,7 @@ GameLib.D3.Mesh.Plane.prototype.generateDotMap = function() {
|
|||
*
|
||||
* @returns {THREE.PlaneGeometry}
|
||||
*/
|
||||
GameLib.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() {
|
||||
R3.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() {
|
||||
|
||||
var data = this.getHeightData();
|
||||
|
||||
|
@ -267,45 +267,45 @@ GameLib.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() {
|
|||
// this.updateInstance();
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Plane.prototype.createPhysicsObjects = function() {
|
||||
R3.D3.Mesh.Plane.prototype.createPhysicsObjects = function() {
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GET_PHYSICS_RUNTIME,
|
||||
R3.Event.Emit(
|
||||
R3.Event.GET_PHYSICS_RUNTIME,
|
||||
null,
|
||||
function(physics){
|
||||
|
||||
/**
|
||||
* 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,
|
||||
'Shape Plane (' + this.name + ')'
|
||||
);
|
||||
|
||||
apiShapePlane.parentMesh = this;
|
||||
|
||||
var shapePlane = new GameLib.D3.Shape.Plane(
|
||||
var shapePlane = new R3.D3.Shape.Plane(
|
||||
physics,
|
||||
apiShapePlane
|
||||
);
|
||||
|
||||
var apiRigidBody = new GameLib.D3.API.RigidBody(
|
||||
var apiRigidBody = new R3.D3.API.RigidBody(
|
||||
null,
|
||||
'Rigid Body (' + this.name + ')',
|
||||
0,
|
||||
null,
|
||||
new GameLib.API.Vector3(
|
||||
new R3.API.Vector3(
|
||||
this.position.x,
|
||||
this.position.y,
|
||||
this.position.z
|
||||
),
|
||||
new GameLib.API.Quaternion(
|
||||
new R3.API.Quaternion(
|
||||
this.quaternion.x,
|
||||
this.quaternion.y,
|
||||
this.quaternion.z,
|
||||
this.quaternion.w,
|
||||
new GameLib.API.Vector3(
|
||||
new R3.API.Vector3(
|
||||
this.quaternion.axis.x,
|
||||
this.quaternion.axis.y,
|
||||
this.quaternion.axis.z
|
||||
|
@ -320,14 +320,14 @@ GameLib.D3.Mesh.Plane.prototype.createPhysicsObjects = function() {
|
|||
|
||||
/**
|
||||
* 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,
|
||||
apiRigidBody
|
||||
);
|
||||
|
||||
if (this.parentEntity instanceof GameLib.Entity) {
|
||||
if (this.parentEntity instanceof R3.Entity) {
|
||||
this.parentEntity.addComponent(shapePlane);
|
||||
this.parentEntity.addComponent(rigidBody);
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* GameLib.D3.Mesh.Sphere
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* R3.D3.Mesh.Sphere
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param apiMeshSphere
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Sphere = function (
|
||||
R3.D3.Mesh.Sphere = function (
|
||||
graphics,
|
||||
apiMeshSphere
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMeshSphere)) {
|
||||
if (R3.Utils.UndefinedOrNull(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,
|
||||
apiMeshSphere,
|
||||
apiMeshSphere.radius,
|
||||
|
@ -25,17 +25,17 @@ GameLib.D3.Mesh.Sphere = function (
|
|||
apiMeshSphere.heightSegments
|
||||
);
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
R3.D3.Mesh.call(
|
||||
this,
|
||||
this.graphics,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Sphere.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Sphere.prototype.constructor = GameLib.D3.Mesh.Sphere;
|
||||
R3.D3.Mesh.Sphere.prototype = Object.create(R3.D3.Mesh.prototype);
|
||||
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;
|
||||
|
||||
|
@ -48,10 +48,10 @@ GameLib.D3.Mesh.Sphere.prototype.createInstance = function() {
|
|||
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 (
|
||||
property === 'radius' ||
|
||||
|
@ -74,18 +74,18 @@ GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
|
|||
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
|
||||
* @returns {GameLib.D3.API.Mesh.Sphere}
|
||||
* Converts a R3.D3.Mesh.Sphere to a R3.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,
|
||||
this.radius,
|
||||
this.widthSegments,
|
||||
|
@ -95,41 +95,41 @@ GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() {
|
|||
return apiMeshSphere;
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
|
||||
R3.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GET_PHYSICS_RUNTIME,
|
||||
R3.Event.Emit(
|
||||
R3.Event.GET_PHYSICS_RUNTIME,
|
||||
null,
|
||||
function(physics){
|
||||
var apiShapeSphere = new GameLib.D3.API.Shape(
|
||||
var apiShapeSphere = new R3.D3.API.Shape(
|
||||
null,
|
||||
'Sphere Shape (' + this.name + ')'
|
||||
);
|
||||
|
||||
apiShapeSphere.parentMesh = this;
|
||||
|
||||
var shapeSphere = new GameLib.D3.Shape.Sphere(
|
||||
var shapeSphere = new R3.D3.Shape.Sphere(
|
||||
physics,
|
||||
apiShapeSphere,
|
||||
this.radius
|
||||
);
|
||||
|
||||
var apiRigidBody = new GameLib.D3.API.RigidBody(
|
||||
var apiRigidBody = new R3.D3.API.RigidBody(
|
||||
null,
|
||||
'Rigid Body (' + this.name + ')',
|
||||
1,
|
||||
null,
|
||||
new GameLib.API.Vector3(
|
||||
new R3.API.Vector3(
|
||||
this.position.x,
|
||||
this.position.y,
|
||||
this.position.z
|
||||
),
|
||||
new GameLib.API.Quaternion(
|
||||
new R3.API.Quaternion(
|
||||
this.quaternion.x,
|
||||
this.quaternion.y,
|
||||
this.quaternion.z,
|
||||
this.quaternion.w,
|
||||
new GameLib.API.Vector3(
|
||||
new R3.API.Vector3(
|
||||
this.quaternion.axis.x,
|
||||
this.quaternion.axis.y,
|
||||
this.quaternion.axis.z
|
||||
|
@ -142,12 +142,12 @@ GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
|
|||
|
||||
apiRigidBody.shapes.push(shapeSphere);
|
||||
|
||||
var rigidBody = new GameLib.D3.RigidBody(
|
||||
var rigidBody = new R3.D3.RigidBody(
|
||||
physics,
|
||||
apiRigidBody
|
||||
);
|
||||
|
||||
if (this.parentEntity instanceof GameLib.Entity) {
|
||||
if (this.parentEntity instanceof R3.Entity) {
|
||||
this.parentEntity.addComponent(shapeSphere);
|
||||
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
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* Converts a standard object mesh to a R3.D3.Mesh
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param objectMesh {Object}
|
||||
* @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,
|
||||
apiMesh,
|
||||
objectMesh.radius,
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* GameLib.D3.Mesh.Text
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* R3.D3.Mesh.Text
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param apiMeshText
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Text = function (
|
||||
R3.D3.Mesh.Text = function (
|
||||
graphics,
|
||||
apiMeshText
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiMeshText)) {
|
||||
if (R3.Utils.UndefinedOrNull(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,
|
||||
apiMeshText,
|
||||
apiMeshText.text,
|
||||
|
@ -31,24 +31,24 @@ GameLib.D3.Mesh.Text = function (
|
|||
apiMeshText.bevelSegments
|
||||
);
|
||||
|
||||
if (this.font instanceof GameLib.D3.API.Font) {
|
||||
this.font = new GameLib.D3.Font(
|
||||
if (this.font instanceof R3.D3.API.Font) {
|
||||
this.font = new R3.D3.Font(
|
||||
this.graphics,
|
||||
this.font
|
||||
)
|
||||
}
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
R3.D3.Mesh.call(
|
||||
this,
|
||||
this.graphics,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Text.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Text.prototype.constructor = GameLib.D3.Mesh.Text;
|
||||
R3.D3.Mesh.Text.prototype = Object.create(R3.D3.Mesh.prototype);
|
||||
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;
|
||||
|
||||
|
@ -71,10 +71,10 @@ GameLib.D3.Mesh.Text.prototype.createInstance = function() {
|
|||
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 (
|
||||
property === 'text' ||
|
||||
|
@ -111,19 +111,19 @@ GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
|
|||
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
|
||||
* @returns {GameLib.D3.API.Mesh.Text}
|
||||
* Converts a R3.D3.Mesh.Text to a R3.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,
|
||||
this.text,
|
||||
this.font,
|
|
@ -1,10 +1,10 @@
|
|||
/**
|
||||
* This component makes the parentEntity (ex. car) follow the path provided by the spline
|
||||
* @param graphics GameLib.GraphicsRuntime
|
||||
* @param apiPathFollowing GameLib.D3.API.PathFollowing
|
||||
* @param graphics R3.GraphicsRuntime
|
||||
* @param apiPathFollowing R3.D3.API.PathFollowing
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.PathFollowing = function (
|
||||
R3.D3.PathFollowing = function (
|
||||
graphics,
|
||||
apiPathFollowing
|
||||
) {
|
||||
|
@ -12,15 +12,15 @@ GameLib.D3.PathFollowing = function (
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(apiPathFollowing)) {
|
||||
if (R3.Utils.UndefinedOrNull(apiPathFollowing)) {
|
||||
apiPathFollowing = {};
|
||||
}
|
||||
|
||||
if (apiPathFollowing instanceof GameLib.D3.PathFollowing) {
|
||||
if (apiPathFollowing instanceof R3.D3.PathFollowing) {
|
||||
return apiPathFollowing;
|
||||
}
|
||||
|
||||
GameLib.D3.API.PathFollowing.call(
|
||||
R3.D3.API.PathFollowing.call(
|
||||
this,
|
||||
apiPathFollowing.id,
|
||||
apiPathFollowing.name,
|
||||
|
@ -46,99 +46,99 @@ GameLib.D3.PathFollowing = function (
|
|||
apiPathFollowing.parentEntity
|
||||
);
|
||||
|
||||
this.baseOffset = new GameLib.Vector3(
|
||||
this.baseOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.baseOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.maxOffset = new GameLib.Vector3(
|
||||
this.maxOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.maxOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.targetOffset = new GameLib.Vector3(
|
||||
this.targetOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.targetOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.currentOffset = new GameLib.Vector3(
|
||||
this.currentOffset = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.currentOffset,
|
||||
this
|
||||
);
|
||||
|
||||
this.raycaster = new GameLib.D3.Raycaster(
|
||||
this.raycaster = new R3.D3.Raycaster(
|
||||
this.graphics,
|
||||
this.raycaster
|
||||
);
|
||||
|
||||
this.currentPosition = new GameLib.Vector3(
|
||||
this.currentPosition = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.currentPosition,
|
||||
this
|
||||
);
|
||||
|
||||
this.futurePosition = new GameLib.Vector3(
|
||||
this.futurePosition = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.futurePosition,
|
||||
this
|
||||
);
|
||||
|
||||
this.up = new GameLib.Vector3(
|
||||
this.up = new R3.Vector3(
|
||||
this.graphics,
|
||||
this.up,
|
||||
this
|
||||
);
|
||||
|
||||
this.rotationMatrix = new GameLib.Matrix4(
|
||||
this.rotationMatrix = new R3.Matrix4(
|
||||
this.graphics,
|
||||
this.rotationMatrix,
|
||||
this
|
||||
);
|
||||
|
||||
this.rotationVector = new GameLib.Quaternion(
|
||||
this.rotationVector = new R3.Quaternion(
|
||||
this.graphics,
|
||||
this.rotationVector,
|
||||
this
|
||||
);
|
||||
|
||||
this.mx = new GameLib.Utils.MovingAverage(10);
|
||||
this.my = new GameLib.Utils.MovingAverage(10);
|
||||
this.mz = new GameLib.Utils.MovingAverage(10);
|
||||
this.mx = new R3.Utils.MovingAverage(10);
|
||||
this.my = new R3.Utils.MovingAverage(10);
|
||||
this.mz = new R3.Utils.MovingAverage(10);
|
||||
|
||||
GameLib.Component.call(
|
||||
R3.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_PATH_FOLLOWING,
|
||||
R3.Component.COMPONENT_PATH_FOLLOWING,
|
||||
{
|
||||
'spline': GameLib.D3.Spline,
|
||||
'mesh' : GameLib.D3.Mesh,
|
||||
'raytraceMesh' : GameLib.D3.Mesh
|
||||
'spline': R3.D3.Spline,
|
||||
'mesh' : R3.D3.Mesh,
|
||||
'raytraceMesh' : R3.D3.Mesh
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
GameLib.D3.PathFollowing.prototype = Object.create(GameLib.D3.API.PathFollowing.prototype);
|
||||
GameLib.D3.PathFollowing.prototype.constructor = GameLib.D3.PathFollowing;
|
||||
R3.D3.PathFollowing.prototype = Object.create(R3.D3.API.PathFollowing.prototype);
|
||||
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.name,
|
||||
GameLib.Utils.IdOrNull(this.spline),
|
||||
GameLib.Utils.IdOrNull(this.mesh),
|
||||
GameLib.Utils.IdOrNull(this.raytraceMesh),
|
||||
R3.Utils.IdOrNull(this.spline),
|
||||
R3.Utils.IdOrNull(this.mesh),
|
||||
R3.Utils.IdOrNull(this.raytraceMesh),
|
||||
this.accelleration,
|
||||
this.maxSpeed,
|
||||
this.baseOffset.toApiObject(),
|
||||
|
@ -155,24 +155,24 @@ GameLib.D3.PathFollowing.prototype.toApiObject = function() {
|
|||
this.up.toApiObject(),
|
||||
this.rotationMatrix.toApiObject(),
|
||||
this.rotationVector.toApiObject(),
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
R3.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
|
||||
return apiPathFollowing;
|
||||
};
|
||||
|
||||
/**
|
||||
* Object path following to GameLib.D3.PathFollowing
|
||||
* Object path following to R3.D3.PathFollowing
|
||||
* @param graphics
|
||||
* @param objectComponent
|
||||
* @returns {GameLib.D3.PathFollowing}
|
||||
* @returns {R3.D3.PathFollowing}
|
||||
* @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,
|
||||
apiPathFollowing
|
||||
);
|
||||
|
@ -182,7 +182,7 @@ GameLib.D3.PathFollowing.FromObject = function(graphics, objectComponent) {
|
|||
* Updates the component
|
||||
* @param deltaTime
|
||||
*/
|
||||
GameLib.D3.PathFollowing.prototype.update = function(deltaTime) {
|
||||
R3.D3.PathFollowing.prototype.update = function(deltaTime) {
|
||||
|
||||
if (this.spline && this.mesh && this.raytraceMesh) {
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
* Physics SuperSet Namespace Object
|
||||
* @param id
|
||||
* @param name
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param engine R3.D3.Engine
|
||||
* @param worlds
|
||||
* @returns {{World: World}}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Physics = function(
|
||||
R3.D3.Physics = function(
|
||||
id,
|
||||
name,
|
||||
engine,
|
||||
|
@ -28,5 +28,5 @@ GameLib.D3.Physics = function(
|
|||
* Solver Types
|
||||
* @type {number}
|
||||
*/
|
||||
GameLib.D3.Physics.SPLIT_SOLVER = 0x1;
|
||||
GameLib.D3.Physics.GS_SOLVER = 0x2;
|
||||
R3.D3.Physics.SPLIT_SOLVER = 0x1;
|
||||
R3.D3.Physics.GS_SOLVER = 0x2;
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* Raycast Vehicles :)
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param chassisBody GameLib.D3.RigidBody
|
||||
* @param wheels GameLib.D3.RaycastWheel[]
|
||||
* @param engine R3.D3.Engine
|
||||
* @param chassisBody R3.D3.RigidBody
|
||||
* @param wheels R3.D3.RaycastWheel[]
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.RaycastVehicle = function(
|
||||
R3.D3.RaycastVehicle = function(
|
||||
engine,
|
||||
chassisBody,
|
||||
wheels,
|
||||
|
@ -14,7 +14,7 @@ GameLib.D3.RaycastVehicle = function(
|
|||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
this.id = GameLib.Utils.RandomId();
|
||||
this.id = R3.Utils.RandomId();
|
||||
|
||||
this.chassisBody = chassisBody;
|
||||
|
||||
|
@ -23,21 +23,21 @@ GameLib.D3.RaycastVehicle = function(
|
|||
}
|
||||
this.wheels = wheels;
|
||||
|
||||
if(GameLib.Utils.UndefinedOrNull(wheelBodies)) {
|
||||
if(R3.Utils.UndefinedOrNull(wheelBodies)) {
|
||||
wheelBodies = [];
|
||||
}
|
||||
this.wheelBodies = wheelBodies;
|
||||
|
||||
this.instance = this.createInstance();
|
||||
|
||||
GameLib.Utils.Extend(GameLib.D3.RaycastVehicle, GameLib.Component);
|
||||
R3.Utils.Extend(R3.D3.RaycastVehicle, R3.Component);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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({
|
||||
chassisBody: this.chassisBody.instance
|
||||
});
|
||||
|
@ -45,10 +45,10 @@ GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
|
|||
|
||||
/**
|
||||
* Adds a raycast wheel to this vehicle
|
||||
* @param wheel GameLib.D3.RaycastWheel
|
||||
* @param wheelRigidBody GameLib.D3.RigidBody
|
||||
* @param wheel R3.D3.RaycastWheel
|
||||
* @param wheelRigidBody R3.D3.RigidBody
|
||||
*/
|
||||
GameLib.D3.RaycastVehicle.prototype.addWheel = function (
|
||||
R3.D3.RaycastVehicle.prototype.addWheel = function (
|
||||
wheel,
|
||||
wheelRigidBody
|
||||
) {
|
||||
|
@ -62,14 +62,14 @@ GameLib.D3.RaycastVehicle.prototype.addWheel = function (
|
|||
* @returns {*}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() {
|
||||
R3.D3.RaycastVehicle.prototype.getWheelInfo = function() {
|
||||
return this.instance.wheelInfos;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Override component methods //
|
||||
GameLib.D3.RaycastVehicle.prototype.onUpdate = function(
|
||||
R3.D3.RaycastVehicle.prototype.onUpdate = function(
|
||||
deltaTime,
|
||||
parentEntity
|
||||
) {
|
||||
|
@ -82,7 +82,7 @@ GameLib.D3.RaycastVehicle.prototype.onUpdate = function(
|
|||
}
|
||||
};
|
||||
|
||||
GameLib.D3.RaycastVehicle.prototype.onRegistered = function(
|
||||
R3.D3.RaycastVehicle.prototype.onRegistered = function(
|
||||
parentScene
|
||||
) {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
GameLib.D3.RaycastWheel = function(
|
||||
R3.D3.RaycastWheel = function(
|
||||
engine,
|
||||
chassisConnectionPointLocal,
|
||||
chassisConnectionPointWorld,
|
||||
|
@ -30,7 +30,7 @@ GameLib.D3.RaycastWheel = function(
|
|||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
this.id = GameLib.Utils.RandomId();
|
||||
this.id = R3.Utils.RandomId();
|
||||
|
||||
if(typeof chassisConnectionPointLocal == 'undefined' || chassisConnectionPointLocal == null) {
|
||||
chassisConnectionPointLocal = new this.engine.instance.Vec3();
|
||||
|
@ -168,7 +168,7 @@ GameLib.D3.RaycastWheel = function(
|
|||
this.wheelIndex = -1;
|
||||
};
|
||||
|
||||
GameLib.D3.RaycastWheel.prototype.createInstance = function() {
|
||||
R3.D3.RaycastWheel.prototype.createInstance = function() {
|
||||
return {
|
||||
chassisConnectionPointLocal : this.chassisConnectionPointLocal,
|
||||
chassisConnectionPointWorld : this.chassisConnectionPointWorld,
|
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* Physics Rigid Body Vehicle Superset
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param chassisBody GameLib.D3.RigidBody
|
||||
* @param wheels GameLib.D3.RigidWheel[]
|
||||
* @param engine R3.D3.Engine
|
||||
* @param chassisBody R3.D3.RigidBody
|
||||
* @param wheels R3.D3.RigidWheel[]
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.RigidBodyVehicle = function(
|
||||
R3.D3.RigidBodyVehicle = function(
|
||||
engine,
|
||||
chassisBody,
|
||||
wheels
|
||||
) {
|
||||
this.id = GameLib.Utils.RandomId();
|
||||
this.id = R3.Utils.RandomId();
|
||||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
|
@ -28,15 +28,15 @@ GameLib.D3.RigidBodyVehicle = function(
|
|||
* Returns physics wheelbody info (for updates)
|
||||
* @returns {Array}
|
||||
*/
|
||||
GameLib.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
|
||||
R3.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
|
||||
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({
|
||||
chassisBody: this.chassisBody.instance
|
||||
});
|
||||
|
@ -44,9 +44,9 @@ GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
|
|||
|
||||
/**
|
||||
* 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);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* RigidBody Superset
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param engine R3.D3.Engine
|
||||
* @param mass
|
||||
* @param friction
|
||||
* @param position
|
||||
|
@ -15,12 +15,12 @@
|
|||
* @param collisionFilterGroup
|
||||
* @param collisionFilterMask
|
||||
* @param fixedRotation
|
||||
* @param shape GameLib.D3.Shape
|
||||
* @param shape R3.D3.Shape
|
||||
* @param kinematic Boolean
|
||||
* @returns {GameLib.D3.Physics.RigidBody}
|
||||
* @returns {R3.D3.Physics.RigidBody}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.RigidBody = function(
|
||||
R3.D3.RigidBody = function(
|
||||
engine,
|
||||
mass,
|
||||
friction,
|
||||
|
@ -39,11 +39,11 @@ GameLib.D3.RigidBody = function(
|
|||
shape,
|
||||
kinematic
|
||||
) {
|
||||
this.id = GameLib.Utils.RandomId();
|
||||
this.position = position || new GameLib.API.Vector3();
|
||||
this.velocity = velocity || new GameLib.API.Vector3();
|
||||
this.angularVelocity = angularVelocity || new GameLib.API.Vector3();
|
||||
this.quaternion = quaternion || new GameLib.API.Quaternion(0, 0, 0, 1);
|
||||
this.id = R3.Utils.RandomId();
|
||||
this.position = position || new R3.API.Vector3();
|
||||
this.velocity = velocity || new R3.API.Vector3();
|
||||
this.angularVelocity = angularVelocity || new R3.API.Vector3();
|
||||
this.quaternion = quaternion || new R3.API.Quaternion(0, 0, 0, 1);
|
||||
this.mass = typeof mass == "undefined" ? 0 : mass;
|
||||
this.friction = typeof friction == "undefined" ? 5 : friction;
|
||||
this.linearDamping = typeof linearDamping == "undefined" ? 0.01 : linearDamping;
|
||||
|
@ -62,14 +62,14 @@ GameLib.D3.RigidBody = function(
|
|||
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.
|
||||
GameLib.Utils.Extend(GameLib.D3.RigidBody, GameLib.Component);
|
||||
R3.Utils.Extend(R3.D3.RigidBody, R3.Component);
|
||||
};
|
||||
|
||||
/**
|
||||
* private function
|
||||
* @returns {*}
|
||||
*/
|
||||
GameLib.D3.RigidBody.prototype.createInstance = function() {
|
||||
R3.D3.RigidBody.prototype.createInstance = function() {
|
||||
|
||||
var instance = new this.engine.instance.Body({
|
||||
mass: this.mass,
|
||||
|
@ -111,28 +111,28 @@ GameLib.D3.RigidBody.prototype.createInstance = function() {
|
|||
return instance;
|
||||
};
|
||||
|
||||
GameLib.D3.RigidBody.prototype.toApiRigidBody = function() {
|
||||
R3.D3.RigidBody.prototype.toApiRigidBody = function() {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a shape to this rigid body
|
||||
* @param shape GameLib.D3.Shape
|
||||
* @param offset GameLib.API.Vector3
|
||||
* @param orientation GameLib.API.Quaternion
|
||||
* @param shape R3.D3.Shape
|
||||
* @param offset R3.API.Vector3
|
||||
* @param orientation R3.API.Quaternion
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.RigidBody.prototype.addShape = function(
|
||||
R3.D3.RigidBody.prototype.addShape = function(
|
||||
shape,
|
||||
offset,
|
||||
orientation
|
||||
) {
|
||||
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') {
|
||||
orientation = new GameLib.API.Quaternion(0,0,0,1);
|
||||
orientation = new R3.API.Quaternion(0,0,0,1);
|
||||
}
|
||||
|
||||
this.instance.addShape(
|
||||
|
@ -152,7 +152,7 @@ GameLib.D3.RigidBody.prototype.addShape = function(
|
|||
};
|
||||
|
||||
///////////////////////// Methods to override //////////////////////////
|
||||
GameLib.D3.RigidBody.prototype.onUpdate = function(
|
||||
R3.D3.RigidBody.prototype.onUpdate = function(
|
||||
deltaTime,
|
||||
parentEntity
|
||||
) {
|
|
@ -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;
|
||||
};
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* Selected Objects
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param object
|
||||
* @param helper
|
||||
* @param lastUpdate
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.SelectedObject = function SelectedObject(
|
||||
R3.D3.SelectedObject = function SelectedObject(
|
||||
graphics,
|
||||
object,
|
||||
helper,
|
||||
|
@ -15,14 +15,14 @@ GameLib.D3.SelectedObject = function SelectedObject(
|
|||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(object)) {
|
||||
if (R3.Utils.UndefinedOrNull(object)) {
|
||||
console.warn('Cannot select no object');
|
||||
throw new Error('Cannot select no object');
|
||||
}
|
||||
this.object = object;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(helper)) {
|
||||
helper = new GameLib.D3.Helper(
|
||||
if (R3.Utils.UndefinedOrNull(helper)) {
|
||||
helper = new R3.D3.Helper(
|
||||
this.graphics,
|
||||
null,
|
||||
null,
|
||||
|
@ -31,7 +31,7 @@ GameLib.D3.SelectedObject = function SelectedObject(
|
|||
}
|
||||
this.helper = helper;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(lastUpdate)) {
|
||||
if (R3.Utils.UndefinedOrNull(lastUpdate)) {
|
||||
lastUpdate = Date.now();
|
||||
}
|
||||
this.lastUpdate = lastUpdate;
|
|
@ -1,21 +1,21 @@
|
|||
/**
|
||||
* Physics Shape Superset
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param engine R3.D3.Engine
|
||||
* @param shapeType
|
||||
* @param scale GameLib.API.Vector3
|
||||
* @param scale R3.API.Vector3
|
||||
* @param vertices Number[]
|
||||
* @param indices Number[]
|
||||
* @param radius Number
|
||||
* @param halfExtensions GameLib.API.Vector3
|
||||
* @param halfExtensions R3.API.Vector3
|
||||
* @param radiusTop Number
|
||||
* @param radiusBottom Number
|
||||
* @param height Number
|
||||
* @param numSegments Number
|
||||
* @param heightmap GameLib.D3.Heightmap
|
||||
* @param heightmap R3.D3.Heightmap
|
||||
* @param elementSize
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Shape = function(
|
||||
R3.D3.Shape = function(
|
||||
engine,
|
||||
shapeType,
|
||||
scale,
|
||||
|
@ -37,7 +37,7 @@ GameLib.D3.Shape = function(
|
|||
this.shapeType = shapeType;
|
||||
|
||||
if (typeof scale == 'undefined') {
|
||||
scale = new GameLib.API.Vector3(1, 1, 1)
|
||||
scale = new R3.API.Vector3(1, 1, 1)
|
||||
}
|
||||
this.scale = scale;
|
||||
|
||||
|
@ -57,7 +57,7 @@ GameLib.D3.Shape = function(
|
|||
this.radius = radius;
|
||||
|
||||
if (typeof halfExtensions == 'undefined') {
|
||||
halfExtensions = new GameLib.API.Vector3(1,1,1);
|
||||
halfExtensions = new R3.API.Vector3(1,1,1);
|
||||
}
|
||||
this.halfExtensions = halfExtensions;
|
||||
|
||||
|
@ -82,7 +82,7 @@ GameLib.D3.Shape = function(
|
|||
this.numSegments = numSegments;
|
||||
|
||||
if (typeof heightmap == 'undefined') {
|
||||
heightmap = new GameLib.D3.Heightmap();
|
||||
heightmap = new R3.D3.Heightmap();
|
||||
}
|
||||
this.heightmap = heightmap;
|
||||
|
||||
|
@ -93,37 +93,37 @@ GameLib.D3.Shape = function(
|
|||
* Shape constants
|
||||
* @type {number}
|
||||
*/
|
||||
GameLib.D3.Shape.SHAPE_TYPE_SPHERE = 1;
|
||||
GameLib.D3.Shape.SHAPE_TYPE_BOX = 2;
|
||||
GameLib.D3.Shape.SHAPE_TYPE_TRIMESH = 3;
|
||||
GameLib.D3.Shape.SHAPE_TYPE_CYLINDER = 4;
|
||||
GameLib.D3.Shape.SHAPE_TYPE_HEIGHT_MAP = 5;
|
||||
GameLib.D3.Shape.SHAPE_TYPE_CONVEX_HULL = 6;
|
||||
GameLib.D3.Shape.SHAPE_TYPE_PLANE = 7;
|
||||
R3.D3.Shape.SHAPE_TYPE_SPHERE = 1;
|
||||
R3.D3.Shape.SHAPE_TYPE_BOX = 2;
|
||||
R3.D3.Shape.SHAPE_TYPE_TRIMESH = 3;
|
||||
R3.D3.Shape.SHAPE_TYPE_CYLINDER = 4;
|
||||
R3.D3.Shape.SHAPE_TYPE_HEIGHT_MAP = 5;
|
||||
R3.D3.Shape.SHAPE_TYPE_CONVEX_HULL = 6;
|
||||
R3.D3.Shape.SHAPE_TYPE_PLANE = 7;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
GameLib.D3.Shape.prototype.createInstance = function() {
|
||||
R3.D3.Shape.prototype.createInstance = function() {
|
||||
|
||||
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 == GameLib.D3.Shape.SHAPE_TYPE_BOX) {
|
||||
} else if (this.shapeType == R3.D3.Shape.SHAPE_TYPE_SPHERE) {;
|
||||
} 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(
|
||||
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();
|
||||
} else {
|
||||
console.warn('Shape type not implemented: ' + this.shapeType);
|
||||
|
@ -139,12 +139,12 @@ GameLib.D3.Shape.prototype.createInstance = function() {
|
|||
/**
|
||||
* update
|
||||
*/
|
||||
GameLib.D3.Shape.prototype.update = function(
|
||||
R3.D3.Shape.prototype.update = function(
|
||||
engine
|
||||
) {
|
||||
engine.isNotCannonThrow();
|
||||
|
||||
if(this.shapeType === GameLib.D3.Shape.SHAPE_TYPE_TRIMESH) {
|
||||
if(this.shapeType === R3.D3.Shape.SHAPE_TYPE_TRIMESH) {
|
||||
this.instance.setScale(
|
||||
new engine.instance.Vec3(
|
||||
this.scale.x,
|
||||
|
@ -161,12 +161,12 @@ GameLib.D3.Shape.prototype.update = function(
|
|||
};
|
||||
|
||||
/**
|
||||
* Converts a GameLib.D3.Shape to a GameLib.D3.API.Shape
|
||||
* @returns {GameLib.D3.API.Shape}
|
||||
* Converts a R3.D3.Shape to a R3.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.shapeType,
|
||||
this.scale.toApiVector(),
|
||||
|
@ -185,11 +185,11 @@ GameLib.D3.Shape.prototype.toApiShape = function() {
|
|||
|
||||
/**
|
||||
* Converts from an Object to a Shape
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param objectShape Object
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Shape.FromObjectShape = function(graphics, objectShape) {
|
||||
R3.D3.Shape.FromObjectShape = function(graphics, objectShape) {
|
||||
//todo: implement this still
|
||||
return null;
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
GameLib.D3.SkyBox = function (
|
||||
R3.D3.SkyBox = function (
|
||||
graphics
|
||||
) {
|
||||
this.id = null;
|
||||
|
@ -9,7 +9,7 @@ GameLib.D3.SkyBox = function (
|
|||
this.texturesFolder = null;
|
||||
};
|
||||
|
||||
GameLib.D3.SkyBox.prototype.load = function (
|
||||
R3.D3.SkyBox.prototype.load = function (
|
||||
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,
|
||||
threeCamera
|
||||
) {
|
|
@ -9,7 +9,7 @@
|
|||
* @param rigidBodies
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World = function(
|
||||
R3.D3.World = function(
|
||||
id,
|
||||
name,
|
||||
engine,
|
||||
|
@ -24,25 +24,25 @@ GameLib.D3.World = function(
|
|||
this.name = name;
|
||||
|
||||
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;
|
||||
|
||||
if (typeof broadphase == 'undefined') {
|
||||
broadphase = new GameLib.D3.Broadphase(
|
||||
broadphase = new R3.D3.Broadphase(
|
||||
null,
|
||||
'broadPhaseNaive',
|
||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
||||
R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
||||
engine
|
||||
);
|
||||
}
|
||||
this.broadphase = broadphase;
|
||||
|
||||
if (typeof solver == 'undefined') {
|
||||
solver = new GameLib.D3.Solver(
|
||||
solver = new R3.D3.Solver(
|
||||
null,
|
||||
engine,
|
||||
GameLib.D3.Solver.GS_SOLVER
|
||||
R3.D3.Solver.GS_SOLVER
|
||||
);
|
||||
}
|
||||
this.solver = solver;
|
||||
|
@ -61,9 +61,9 @@ GameLib.D3.World = function(
|
|||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -80,7 +80,7 @@ GameLib.D3.World.prototype.createInstance = function() {
|
|||
return instance;
|
||||
};
|
||||
|
||||
GameLib.D3.World.prototype.toApiWorld = function() {
|
||||
R3.D3.World.prototype.toApiWorld = function() {
|
||||
//TODO: create API.World someday
|
||||
return {
|
||||
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
|
||||
return new GameLib.D3.World(
|
||||
return new R3.D3.World(
|
||||
objectWorld.id,
|
||||
objectWorld.name,
|
||||
engine,
|
||||
|
@ -110,10 +110,10 @@ GameLib.D3.World.FromObjectWorld = function(engine, objectWorld) {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param rigidBody GameLib.D3.RigidBody
|
||||
* @param rigidBody R3.D3.RigidBody
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.addRigidBody = function(
|
||||
R3.D3.World.prototype.addRigidBody = function(
|
||||
rigidBody
|
||||
) {
|
||||
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
|
||||
*/
|
||||
GameLib.D3.World.prototype.addVehicle = function(
|
||||
R3.D3.World.prototype.addVehicle = function(
|
||||
vehicle
|
||||
) {
|
||||
vehicle.instance.addToWorld(this.instance);
|
||||
};
|
||||
|
||||
GameLib.D3.World.prototype.step = function(
|
||||
R3.D3.World.prototype.step = function(
|
||||
fixedStep,
|
||||
dtStep
|
||||
) {
|
||||
|
@ -153,11 +153,11 @@ GameLib.D3.World.prototype.step = function(
|
|||
this.lastCallTime = now;
|
||||
};
|
||||
|
||||
GameLib.D3.World.prototype.GetIndexedVertices = function(
|
||||
R3.D3.World.prototype.GetIndexedVertices = function(
|
||||
triangleMeshShape
|
||||
) {
|
||||
|
||||
if(this.engine.engineType == GameLib.D3.Physics.TYPE_CANNON) {
|
||||
if(this.engine.engineType == R3.D3.Physics.TYPE_CANNON) {
|
||||
|
||||
return {
|
||||
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 scale GameLib.API.Vector3
|
||||
* @param scale R3.API.Vector3
|
||||
* @param opacity Number
|
||||
* @param wireframeColor HexCode
|
||||
* @param graphics THREE
|
||||
* @returns {THREE.Mesh|this.meshes}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.generateWireframeViewTriangleMesh = function(
|
||||
R3.D3.World.prototype.generateWireframeViewTriangleMesh = function(
|
||||
graphics,
|
||||
triangleMeshShape,
|
||||
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 scale GameLib.API.Vector3
|
||||
* @param scale R3.API.Vector3
|
||||
* @param opacity Number
|
||||
* @param wireframeColor HexCode
|
||||
* @param graphics THREE
|
||||
* @returns {THREE.Mesh|this.meshes}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.generateWireframeViewConvexPolyMesh = function(
|
||||
R3.D3.World.prototype.generateWireframeViewConvexPolyMesh = function(
|
||||
graphics,
|
||||
convexPolyMeshShape,
|
||||
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 mass Number
|
||||
* @param friction Number
|
||||
|
@ -386,7 +386,7 @@ GameLib.D3.World.prototype.generateWireframeViewConvexPolyMesh = function(
|
|||
* @returns {Object}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
|
||||
R3.D3.World.prototype.generateTriangleMeshShapeDivided = function(
|
||||
graphics,
|
||||
graphicsMesh,
|
||||
mass,
|
||||
|
@ -477,7 +477,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
|
|||
}
|
||||
};
|
||||
|
||||
GameLib.D3.World.prototype.generateConvexPolyShape = function(
|
||||
R3.D3.World.prototype.generateConvexPolyShape = function(
|
||||
graphics,
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
* @returns {GameLib.D3.Shape}
|
||||
* @returns {R3.D3.Shape}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||
R3.D3.World.prototype.generateTriangleMeshShape = function(
|
||||
graphics,
|
||||
graphicsMesh
|
||||
) {
|
||||
|
@ -618,21 +618,21 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
|||
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 maxTriangleDistance Number
|
||||
* @param createCompoundShape Boolean
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param triangleMeshShapes GameLib.D3.Shape[]
|
||||
* @param graphics R3.D3.Graphics
|
||||
* @param triangleMeshShapes R3.D3.Shape[]
|
||||
* @param createDebugView Boolean
|
||||
* @returns {GameLib.D3.RigidBody}
|
||||
* @returns {R3.D3.RigidBody}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||
R3.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||
triangleMeshBody,
|
||||
triangleMeshShapes,
|
||||
rayscale,
|
||||
|
@ -870,13 +870,13 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
|||
for(var e in bFaceIndexed) {
|
||||
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) {
|
||||
triangleMeshBody.addShape(shape);
|
||||
} 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.
|
||||
body.instance.collisionFilterGroup = 1 | 2; // puts this body in two groups.
|
|
@ -4,7 +4,7 @@
|
|||
* @param document DOM Document
|
||||
* @param window DOM Window
|
||||
*/
|
||||
GameLib.Dom = function(
|
||||
R3.Dom = function(
|
||||
document,
|
||||
window
|
||||
) {
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* Matrix 3 Maths
|
||||
* @param row0 GameLib.API.Vector3
|
||||
* @param row1 GameLib.API.Vector3
|
||||
* @param row2 GameLib.API.Vector3
|
||||
* @param row0 R3.API.Vector3
|
||||
* @param row1 R3.API.Vector3
|
||||
* @param row2 R3.API.Vector3
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.Matrix3 = function(
|
||||
R3.Matrix3 = function(
|
||||
row0,
|
||||
row1,
|
||||
row2
|
||||
|
@ -28,10 +28,10 @@ GameLib.Matrix3 = function(
|
|||
/**
|
||||
* Set matrix to identity
|
||||
*/
|
||||
GameLib.Matrix3.prototype.identity = function () {
|
||||
R3.Matrix3.prototype.identity = function () {
|
||||
this.rows = [
|
||||
new GameLib.API.Vector3(1, 0, 0),
|
||||
new GameLib.API.Vector3(0, 1, 0),
|
||||
new GameLib.API.Vector3(0, 0, 1)
|
||||
new R3.API.Vector3(1, 0, 0),
|
||||
new R3.API.Vector3(0, 1, 0),
|
||||
new R3.API.Vector3(0, 0, 1)
|
||||
];
|
||||
};
|
|
@ -30,7 +30,7 @@ gulp.task(
|
|||
)
|
||||
)
|
||||
.pipe(
|
||||
replace(new RegExp('GameLib.D3.Utils.Extend\\(.*?\\);', 'g'), function (replacement) {
|
||||
replace(new RegExp('R3.D3.Utils.Extend\\(.*?\\);', 'g'), function (replacement) {
|
||||
__EXTENDS__ += replacement + "\n";
|
||||
return "//" + replacement;
|
||||
})
|
||||
|
|
|
@ -3,13 +3,13 @@ var chai = require('chai'),
|
|||
sinonChai = require("sinon-chai"),
|
||||
config = require('../config.js'),
|
||||
assert = chai.assert,
|
||||
GameLib = require('../build/r3'),
|
||||
R3 = require('../build/r3'),
|
||||
CANNON = require('cannon'),
|
||||
THREE = require('three');
|
||||
|
||||
chai.use(sinonChai);
|
||||
|
||||
describe('GameLib object creation', function(){
|
||||
describe('R3 object creation', function(){
|
||||
|
||||
this.timeout(0);
|
||||
|
||||
|
@ -38,18 +38,18 @@ describe('GameLib object creation', function(){
|
|||
|
||||
it('Should create a Bone object', function (done) {
|
||||
|
||||
var bone = new GameLib.D3.Bone(
|
||||
var bone = new R3.D3.Bone(
|
||||
null,
|
||||
1,
|
||||
'test bone 1',
|
||||
[2, 3, 4]
|
||||
);
|
||||
|
||||
assert(bone.position instanceof GameLib.D3.Vector3);
|
||||
assert(bone.rotation instanceof GameLib.D3.Vector3);
|
||||
assert(bone.scale instanceof GameLib.D3.Vector3);
|
||||
assert(bone.up instanceof GameLib.D3.Vector3);
|
||||
assert(bone.quaternion instanceof GameLib.D3.Vector4);
|
||||
assert(bone.position instanceof R3.D3.Vector3);
|
||||
assert(bone.rotation instanceof R3.D3.Vector3);
|
||||
assert(bone.scale instanceof R3.D3.Vector3);
|
||||
assert(bone.up instanceof R3.D3.Vector3);
|
||||
assert(bone.quaternion instanceof R3.D3.Vector4);
|
||||
assert(bone.parentBoneId == null);
|
||||
assert.deepEqual(bone.childBoneIds, [2,3,4]);
|
||||
|
||||
|
@ -58,7 +58,7 @@ describe('GameLib object creation', function(){
|
|||
|
||||
it('Should create a BoneWeight object', function (done) {
|
||||
|
||||
var boneWeight = new GameLib.D3.BoneWeight(
|
||||
var boneWeight = new R3.D3.BoneWeight(
|
||||
1,
|
||||
0.5
|
||||
);
|
||||
|
@ -71,34 +71,34 @@ describe('GameLib object creation', function(){
|
|||
|
||||
it('Should create a Broadphase object', function (done) {
|
||||
|
||||
var engine = new GameLib.D3.Engine(
|
||||
GameLib.D3.Engine.ENGINE_TYPE_CANNON,
|
||||
var engine = new R3.D3.Engine(
|
||||
R3.D3.Engine.ENGINE_TYPE_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);
|
||||
|
||||
var broadphase = new GameLib.D3.Broadphase(
|
||||
var broadphase = new R3.D3.Broadphase(
|
||||
null,
|
||||
'broad-phase',
|
||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
||||
R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
||||
engine,
|
||||
true
|
||||
);
|
||||
|
||||
assert(broadphase.id == null);
|
||||
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.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE);
|
||||
assert(broadphase.broadphaseType == R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Should create a Color object', function (done) {
|
||||
|
||||
var color = new GameLib.D3.Color(
|
||||
var color = new R3.D3.Color(
|
||||
0.1,
|
||||
0.2,
|
||||
0.3,
|
||||
|
@ -115,7 +115,7 @@ describe('GameLib object creation', function(){
|
|||
|
||||
it('Should create a Color object', function (done) {
|
||||
|
||||
var color = new GameLib.D3.Color(
|
||||
var color = new R3.D3.Color(
|
||||
0.1,
|
||||
0.2,
|
||||
0.3,
|
||||
|
@ -133,12 +133,12 @@ describe('GameLib object creation', function(){
|
|||
|
||||
it('Should create an Engine object', function (done) {
|
||||
|
||||
var engine = new GameLib.D3.Engine(
|
||||
GameLib.D3.Engine.ENGINE_TYPE_CANNON,
|
||||
var engine = new R3.D3.Engine(
|
||||
R3.D3.Engine.ENGINE_TYPE_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);
|
||||
|
||||
done();
|
||||
|
@ -151,18 +151,18 @@ describe('GameLib object creation', function(){
|
|||
|
||||
it('Should load the scene via API', function(done) {
|
||||
|
||||
var scene = new GameLib.D3.Scene(
|
||||
var scene = new R3.D3.Scene(
|
||||
null,
|
||||
'/gamewheel/root/root/test',
|
||||
'test'
|
||||
);
|
||||
|
||||
var graphics = new GameLib.D3.Graphics(
|
||||
GameLib.D3.Graphics.GRAPHICS_TYPE_THREE,
|
||||
var graphics = new R3.D3.Graphics(
|
||||
R3.D3.Graphics.GRAPHICS_TYPE_THREE,
|
||||
THREE
|
||||
);
|
||||
|
||||
GameLib.D3.Scene.LoadSceneFromApi(
|
||||
R3.D3.Scene.LoadSceneFromApi(
|
||||
scene,
|
||||
function(stuff){
|
||||
done();
|
||||
|
|
Loading…
Reference in New Issue