Class: Gfx3JWM
The `Gfx3JWM` is a class that represents a walkmesh and provides methods for loading
data, updating and drawing, adding and moving walkers, and clearing walkers.
In collision case, the collision response sliding along the edges of the walkmesh to keep a good
feeling for the player.
- inherit from: Gfx3Transformable
Constructors
- new Gfx3JWM(): Gfx3JWM
The constructor.
Methods
- addWalker(id: string, x: number, z: number, radius: number): Walker
The "addWalker" function adds a new walker identified by a unique identifier of your choice.
A walker is the representation of a moving entity inside a walkmesh context. It is a square
of `radius` size moving along the floor.
- id: A unique identifier for the walker.
- x: The x-coordinate of the walker's starting position.
- z: The z-coordinate of the walker's starting position.
- radius: The radius parameter represents the size of the walker.
- clearWalkers(): void
The "clearWalkers" function remove all walker instances.
- draw(): void
The "draw" function.
- getLocalAxies()
The "getLocalAxies" function returns an array of three vectors representing the local axes of an
object based on its transformation matrix.
- getPosition(): vec3
The "getPosition" function returns the position.
- getPositionX(): number
The "getPositionX" function returns the x-coordinate of the position.
- getPositionY(): number
The "getPositionY" function returns the y-coordinate of the position.
- getPositionZ(): number
The "getPositionZ" function returns the z-coordinate of the position.
- getRotation(): vec3
The "getRotation" function returns the rotation as Euler angles.
- getRotationQuaternion(): vec4
The "getRotationQuaternion" function returns the Quaternion based on the Euler angles provided.
- getRotationX(): number
The "getRotationX" function returns the rotation angle on x-axis.
- getRotationY(): number
The "getRotationY" function returns the rotation angle on y-axis.
- getRotationZ(): number
The "getRotationZ" function returns the rotation angle on z-axis.
- getScale(): vec3
The "getScale" function returns the scale as a 3D vector.
- getScaleX(): number
The "getScaleX" function returns the scale factor on x-axis.
- getScaleY(): number
The "getScaleY" function returns the scale factor on y-axis.
- getScaleZ(): number
The "getScaleZ" function returns the scale factor on z-axis.
- getTransformMatrix(): mat4
The "getTransformMatrix" function returns the transform matrix from position, rotation and scale values.
- loadFromFile(path: string): Promise
The "loadFromFile" function asynchronously loads walkmesh data from a json file (jwm).
- path: The `path` parameter is the file path.
- moveWalker(id: string, mx: number, mz: number): vec3
The "moveWalker" function move the specified walker based on the provided movement values.
- id: The `id` parameter is a string that represents the unique identifier of the
walker.
- mx: The parameter `mx` represents the movement in the x-axis (horizontal movement)
for the walker.
- mz: The parameter `mz` represents the movement in the z-axis (vertical movement)
for the walker.
- rotate(x: number, y: number, z: number): void
The "rotate" function add rotation values to Euler angles.
- x: The rotation angle on x-axis in radians.
- y: The rotation angle on y-axis in radians.
- z: The rotation angle on z-axis in radians.
- setPosition(x: number, y: number, z: number): void
The "setPosition" function set the position with the given x, y and z coordinates.
- x: The X coordinate of the position.
- y: The Y coordinate of the position.
- z: The Z coordinate of the position.
- setRotation(x: number, y: number, z: number): void
The "setRotation" function sets rotation Euler angles (in radians).
- x: The rotation angle on x-axis in radians.
- y: The rotation angle on y-axis in radians.
- z: The rotation angle on z-axis in radians.
- setRotationQuaternion(quaternion: vec4): void
The "setRotationQuaternion" function sets the rotation using Quaternion.
- quaternion: The quaternion.
- setScale(x: number, y: number, z: number): void
The "setScale" function sets the scale with the given x, y and z factors.
- x: The x factor in the x-axis direction.
- y: The y factor in the y-axis direction.
- z: The z factor in the z-axis direction.
- translate(x: number, y: number, z: number): void
The "translate" function translate the position.
- x: The amount of translation in the x-axis direction.
- y: The amount of translation in the y-axis direction.
- z: The amount of translation in the z-axis direction.
- update(): void
The "update" function.
- zoom(x: number, y: number, z: number): void
The "zoom" function add scale values.
- x: The x factor in the x-axis direction.
- y: The y factor in the y-axis direction.
- z: The z factor in the z-axis direction.