new Vehicle()
Constructs a new vehicle.
Extends
Members
-
active :Boolean
-
Whether this game entity is active or not.
- Overrides:
- Default Value:
- true
-
boundingRadius :Number
-
The bounding radius of this game entity in world units.
- Overrides:
- Default Value:
- 0
-
canActivateTrigger :Boolean
-
Whether the entity can activate a trigger or not.
- Overrides:
- Default Value:
- true
-
children :Array.<GameEntity>
-
The child entities of this game entity.
- Overrides:
-
forward :Vector3
-
The default forward vector of this game entity.
- Overrides:
- Default Value:
- (0,0,1)
-
readonly manager :EntityManager
-
A reference to the entity manager of this game entity. Automatically set when added to an EntityManager.
- Overrides:
- Default Value:
- null
-
mass :Number
-
The mass of the vehicle in kilogram.
- Default Value:
- 1
-
maxForce :Number
-
The maximum force this entity can produce to power itself.
- Default Value:
- 100
-
maxSpeed :Number
-
The maximum speed at which this game entity may travel.
- Overrides:
- Default Value:
- 1
-
maxTurnRate :Number
-
The maximum turn rate of this game entity in radians per seconds. The only method that uses this property right now is GameEntity#rotateTo.
- Overrides:
- Default Value:
- π
-
name :String
-
The name of this game entity.
- Overrides:
-
neighborhoodRadius :Number
-
Game entities within this radius are considered as neighbors of this entity.
- Overrides:
- Default Value:
- 1
-
readonly neighbors :Array.<GameEntity>
-
A list of neighbors of this game entity.
- Overrides:
-
readonly, nullable parent :GameEntity
-
A reference to the parent entity of this game entity. Automatically set when added to a GameEntity.
- Overrides:
- Default Value:
- null
-
position :Vector3
-
The position of this game entity.
- Overrides:
-
rotation :Quaternion
-
The rotation of this game entity.
- Overrides:
-
scale :Vector3
-
The scaling of this game entity.
- Overrides:
-
nullable smoother :Smoother
-
An optional smoother to avoid shakiness due to conflicting steering behaviors.
- Default Value:
- null
-
steering :SteeringManager
-
The steering manager of this vehicle.
-
up :Vector3
-
The default up vector of this game entity.
- Overrides:
- Default Value:
- (0,1,0)
-
updateNeighborhood :Boolean
-
Whether the neighborhood of this game entity is updated or not.
- Overrides:
- Default Value:
- false
-
updateOrientation :Boolean
-
Whether the orientation of this game entity will be updated based on the velocity or not.
- Overrides:
- Default Value:
- true
-
readonly uuid :String
-
Unique ID, primarily used in context of serialization/deserialization.
- Overrides:
-
velocity :Vector3
-
The velocity of this game entity.
- Overrides:
-
readonly worldMatrix :Matrix4
-
A transformation matrix representing the world space of this game entity.
- Overrides:
Methods
-
add(entity) → {GameEntity}
-
Adds a game entity as a child to this game entity.
Parameters:
Name Type Description entity
GameEntity The game entity to add.
- Overrides:
-
fromJSON(json) → {Vehicle}
-
Restores this instance from the given JSON object.
Parameters:
Name Type Description json
Object The JSON object.
- Overrides:
-
getDirection(result) → {Vector3}
-
Computes the current direction (forward) vector of this game entity and stores the result in the given vector.
Parameters:
Name Type Description result
Vector3 The direction vector of this game entity.
- Overrides:
-
getSpeed() → {Number}
-
Returns the current speed of this game entity.
Returns:
Number -The current speed.
- Overrides:
-
getSpeedSquared() → {Number}
-
Returns the current speed in squared space of this game entity.
Returns:
Number -The current speed in squared space.
- Overrides:
-
getWorldDirection(result) → {Vector3}
-
Computes the current direction (forward) vector of this game entity in world space and stores the result in the given vector.
Parameters:
Name Type Description result
Vector3 The direction vector of this game entity in world space.
- Overrides:
-
getWorldPosition(result) → {Vector3}
-
Computes the current position of this game entity in world space and stores the result in the given vector.
Parameters:
Name Type Description result
Vector3 The position of this game entity in world space.
- Overrides:
-
handleMessage(telegram) → {Boolean}
-
Holds the implementation for the message handling of this game entity.
Parameters:
Name Type Description telegram
Telegram The telegram with the message data.
Returns:
Boolean -Whether the message was processed or not.
- Overrides:
-
lineOfSightTest(ray, intersectionPoint) → {Vector3}
-
Holds the implementation for the line of sight test of this game entity. This method is used by Vision#visible in order to determine whether this game entity blocks the given line of sight or not. Implement this method when your game entity acts as an obstacle.
Parameters:
Name Type Description ray
Ray The ray that represents the line of sight.
intersectionPoint
Vector3 The intersection point.
- Overrides:
-
lookAt(target) → {GameEntity}
-
Directly rotates the entity so it faces the given target position.
Parameters:
Name Type Description target
Vector3 The target position.
- Overrides:
-
remove(entity) → {GameEntity}
-
Removes a game entity as a child from this game entity.
Parameters:
Name Type Description entity
GameEntity The game entity to remove.
- Overrides:
-
resolveReferences(entities) → {Vehicle}
-
Restores UUIDs with references to GameEntity objects.
Parameters:
Name Type Description entities
Map.<String, GameEntity> Maps game entities to UUIDs.
- Overrides:
-
rotateTo(target, delta, tolerance) → {Boolean}
-
Given a target position, this method rotates the entity by an amount not greater than GameEntity#maxTurnRate until it directly faces the target.
Parameters:
Name Type Default Description target
Vector3 The target position.
delta
Number The time delta.
tolerance
Number 0.0001 A tolerance value in radians to tweak the result when a game entity is considered to face a target.
Returns:
Boolean -Whether the entity is faced to the target or not.
- Overrides:
-
sendMessage(receiver, message, delay, data) → {GameEntity}
-
Sends a message with the given data to the specified receiver.
Parameters:
Name Type Default Description receiver
GameEntity The receiver.
message
String The actual message.
delay
Number 0 A time value in millisecond used to delay the message dispatching.
data
Object null An object for custom data.
- Overrides:
-
setRenderComponent(renderComponent, callback) → {GameEntity}
-
Sets a renderable component of a 3D engine with a sync callback for this game entity.
Parameters:
Name Type Description renderComponent
Object A renderable component of a 3D engine.
callback
function A callback that can be used to sync this game entity with the renderable component.
- Overrides:
-
start() → {GameEntity}
-
Executed when this game entity is updated for the first time by its EntityManager.
- Overrides:
-
toJSON() → {Object}
-
Transforms this instance into a JSON object.
Returns:
Object -The JSON object.
- Overrides:
-
update(delta) → {Vehicle}
-
This method is responsible for updating the position based on the force produced by the internal steering manager.
Parameters:
Name Type Description delta
Number The time delta.
- Overrides: