/** * Raw RigidBody API object - should always correspond with the RigidBody Schema * @param id * @param name * @param mass * @param friction * @param position * @param quaternion * @param velocity * @param angularVelocity * @param linearDamping * @param angularDamping * @param allowSleep * @param sleepSpeedLimit * @param sleepTimeLimit * @param collisionFilterGroup * @param collisionFilterMask * @param fixedRotation * @param shape * @param kinematic * @param parentEntity * @constructor */ GameLib.D3.API.RigidBody = function( id, name, mass, friction, position, quaternion, velocity, angularVelocity, linearDamping, angularDamping, allowSleep, sleepSpeedLimit, sleepTimeLimit, collisionFilterGroup, collisionFilterMask, fixedRotation, shape, kinematic, parentEntity ) { if (GameLib.Utils.UndefinedOrNull(id)) { id = GameLib.Utils.RandomId(); } this.id = id; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'RigidBody (' + this.id + ')'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(mass)) { mass = 0; } this.mass = mass; if (GameLib.Utils.UndefinedOrNull(friction)) { friction = 5; } this.friction = friction; if (GameLib.Utils.UndefinedOrNull(position)) { position = new GameLib.API.Vector3(0,0,0); } this.position = position; if (GameLib.Utils.UndefinedOrNull(quaternion)) { quaternion = new GameLib.API.Quaternion(); } this.quaternion = quaternion; if (GameLib.Utils.UndefinedOrNull(velocity)) { velocity = new GameLib.API.Vector3(); } this.velocity = velocity; if (GameLib.Utils.UndefinedOrNull(angularVelocity)) { angularVelocity = new GameLib.API.Vector3(); } this.angularVelocity = angularVelocity; if (GameLib.Utils.UndefinedOrNull(linearDamping)) { linearDamping = 0.01; } this.linearDamping = linearDamping; if (GameLib.Utils.UndefinedOrNull(angularDamping)) { angularDamping = 0.01; } this.angularDamping = angularDamping; if (GameLib.Utils.UndefinedOrNull(allowSleep)) { allowSleep = true; } this.allowSleep = allowSleep; if (GameLib.Utils.UndefinedOrNull(sleepSpeedLimit)) { sleepSpeedLimit = 0.1; } this.sleepSpeedLimit = sleepSpeedLimit; if (GameLib.Utils.UndefinedOrNull(sleepTimeLimit)) { sleepTimeLimit = 1.0; } this.sleepTimeLimit = sleepTimeLimit; if (GameLib.Utils.UndefinedOrNull(collisionFilterGroup)) { collisionFilterGroup = 1; } this.collisionFilterGroup = collisionFilterGroup; if (GameLib.Utils.UndefinedOrNull(collisionFilterMask)) { collisionFilterMask = 1; } this.collisionFilterMask = collisionFilterMask; if (GameLib.Utils.UndefinedOrNull(fixedRotation)) { fixedRotation = false; } this.fixedRotation = fixedRotation; if (GameLib.Utils.UndefinedOrNull(shape)) { shape = null; } this.shape = shape; if (GameLib.Utils.UndefinedOrNull(kinematic)) { kinematic = false; } this.kinematic = kinematic; if (GameLib.Utils.UndefinedOrNull(parentEntity)) { parentEntity = null; } this.parentEntity = parentEntity; }; GameLib.D3.API.RigidBody.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.RigidBody.prototype.constructor = GameLib.D3.API.RigidBody; /** * Creates an API RigidBody from an Object RigidBody * @param objectRigidBody * @constructor */ GameLib.D3.API.RigidBody.FromObject = function(objectRigidBody) { return new GameLib.D3.API.RigidBody( objectRigidBody.id, objectRigidBody.name, objectRigidBody.mass, objectRigidBody.friction, objectRigidBody.position, objectRigidBody.quaternion, objectRigidBody.velocity, objectRigidBody.angularVelocity, objectRigidBody.linearDamping, objectRigidBody.angularDamping, objectRigidBody.allowSleep, objectRigidBody.sleepSpeedLimit, objectRigidBody.sleepTimeLimit, objectRigidBody.collisionFilterGroup, objectRigidBody.collisionFilterMask, objectRigidBody.fixedRotation, objectRigidBody.shape, objectRigidBody.kinematic, objectRigidBody.parentEntity ); };