Class: Sprite

Sprite

A sprite in the map

new Sprite (json)

Name Type Description
json Object optional Json object describing the sprite
Properties:
Name Type Argument Default Description
Sprite.Y_AXIS THREE.Vector3 <optional>
new THREE.Vector3(0, 1, 0) The unit Y axis vector
Sprite.X_AXIS THREE.Vector3 <optional>
new THREE.Vector3(1, 0, 0) The unit X axis vector
Sprite.Z_AXIS THREE.Vector3 <optional>
new THREE.Vector3(0, 0, 1) The unit Z axis vector
front boolean Indicate if the sprite is in front (for layers)
kind ElementMapKind The element map kind
textureRect Array.<number> Texture UV coords

Extends

Methods

Sprite.create (kind, texture) static

Create a new sprite
Name Type Description
kind ElementMapKind The element map kind
texture Array.<number> Texture UV coords

Sprite.rotateVertex (vec, center, angle, axis) static

Rotate a vertex around a specified center
Name Type Description
vec THREE.Vector3 The vertex to rotate
center THREE.Vector3 The center to rotate around
angle number The angle in degree
axis THREE.Vector3 The vector axis

Sprite.rotateSprite (vecA, vecB, vecC, vecD, center, angle, axis) static

Rotate the four vertices of a sprite around a specified center
Name Type Description
vecA THREE.Vector3 The A vertex to rotate
vecB THREE.Vector3 The B vertex to rotate
vecC THREE.Vector3 The C vertex to rotate
vecD THREE.Vector3 The D vertex to rotate
center THREE.Vector3 The center to rotate around
angle number The angle in degree
axis THREE.Vector3 The vector axis

Sprite.addStaticSpriteToGeometry (geometry, vecA, vecB, vecC, vecD, texFaceA, texFaceB, count)number static

Add a static sprite to the geometry
Name Type Description
geometry THREE.Geometry The geometry
vecA THREE.Vector3 The A vertex
vecB THREE.Vector3 The B vertex
vecC THREE.Vector3 The C vertex
vecD THREE.Vector3 The D vertex
texFaceA THREE.Vector2 The texture face A
texFaceB THREE.Vector2 The texture face B
count number The faces count
Returns:
Type Description
number

read (json) overrides

Read the JSON associated to the sprite
Name Type Description
json Object Json object describing the sprite

updateGeometry (geometry, width, height, position, count, tileset, localPosition)Array.<any>

Update the geometry associated to this
Name Type Description
geometry THREE.Geometry The geometry
width number The total texture width
height number The total texture height
position Array.<number> The json position
count number The faces count
tileset boolean Indicate if the texture is tileset
localPosition THREE.Vector3 The local position
Returns:
Type Description
Array.<any>

createGeometry (width, height, tileset, position)Array.<any>

Create the geometry associated to this sprite
Name Type Description
width number The texture total width
height number The texture total height
tileset boolean Indicate if the texture is tileset
position Array.<number> The json position
Returns:
Type Description
Array.<any>

scale (vecA, vecB, vecC, vecD, center, position, size, kind) inherited overrides

Scale the vertices correctly
Name Type Description
vecA THREE.Vector3 The A vertex to rotate
vecB THREE.Vector3 The B vertex to rotate
vecC THREE.Vector3 The C vertex to rotate
vecD THREE.Vector3 The D vertex to rotate
center THREE.Vector3 The center to rotate around
position Array.<number> The json position
size THREE.Vector3 The scale size
kind ElementMapKind The element map kind