TileMap2D
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:48
Main tilemap class for rendering 2D tile-based maps.
Supports:
- Multiple tile layers
- Animated tiles
- Chunked rendering for large maps
- Collision data extraction
- Object layer access (spawn points, triggers, etc.)
Follows R3F-compatible constructor pattern with optional parameters.
Examples
// Vanilla Three.jsconst mapData = await TiledLoader.load('/maps/level1.json')const tilemap = new TileMap2D({ data: mapData })scene.add(tilemap)
// In update looptilemap.update(deltaMs)// React Three Fiber (after extending)extend({ TileMap2D })
function Level() { const mapData = use(TiledLoader.load('/maps/level1.json')) return <tileMap2D data={mapData} />}Extends
Constructors
Constructor
new TileMap2D(
options?):TileMap2D
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:91
Create a new TileMap2D.
Parameters
options?
Optional configuration. If not provided (R3F path),
the tilemap will be initialized when data is set.
Returns
TileMap2D
Overrides
Group.constructor
Properties
animations
animations:
AnimationClip[]
Defined in: three.js/core/Object3D:animations
Array with object’s animation clips.
Default Value
[]
Inherited from
Group.animations
castShadow
castShadow:
boolean
Defined in: three.js/core/Object3D:castShadow
Whether the object gets rendered into shadow map.
Default Value
false
Inherited from
Group.castShadow
children
children:
Object3D<Object3DEventMap>[]
Defined in: three.js/core/Object3D:children
Array with object’s children.
See
THREE.Object3DGroup | Group for info on manually grouping objects.
Default Value
[]
Inherited from
Group.children
count?
optionalcount:number
Defined in: three.js/renderers/common/Backend:count
Inherited from
Group.count
customDepthMaterial?
optionalcustomDepthMaterial:Material
Defined in: three.js/core/Object3D:customDepthMaterial
Custom depth material to be used when rendering to the depth map.
Remarks
Can only be used in context of meshes. When shadow-casting with a THREE.DirectionalLight | DirectionalLight or THREE.SpotLight | SpotLight, if you are modifying vertex positions in the vertex shader you must specify a customDepthMaterial for proper shadows.
Default Value
undefined
Inherited from
Group.customDepthMaterial
customDistanceMaterial?
optionalcustomDistanceMaterial:Material
Defined in: three.js/core/Object3D:customDistanceMaterial
Same as customDepthMaterial, but used with THREE.Object3DPointLight | PointLight.
Default Value
undefined
Inherited from
Group.customDistanceMaterial
frustumCulled
frustumCulled:
boolean
Defined in: three.js/core/Object3D:frustumCulled
When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object.
If set to false the object gets rendered every frame even if it is not in the frustum of the camera.
Default Value
true
Inherited from
Group.frustumCulled
id
readonlyid:number
Defined in: three.js/core/Object3D:id
Unique number for this Object3D instance.
Remarks
Note that ids are assigned in chronological order: 1, 2, 3, …, incrementing by one for each new object.
Expects a Integer
Inherited from
Group.id
isGroup
readonlyisGroup:true
Defined in: three.js/objects/Group:isGroup
Read-only flag to check if a given object is of type Group.
Remarks
This is a constant value
Default Value
true
Inherited from
Group.isGroup
isObject3D
readonlyisObject3D:true
Defined in: three.js/core/Object3D:isObject3D
Flag to check if a given object is of type Object3D.
Remarks
This is a constant value
Default Value
true
Inherited from
Group.isObject3D
layers
layers:
Layers
Defined in: three.js/core/Object3D:layers
The layer membership of the object.
Remarks
The object is only visible if it has at least one layer in common with the THREE.Object3DCamera | Camera in use. This property can also be used to filter out unwanted objects in ray-intersection tests when using THREE.Raycaster | Raycaster.
Default Value
new THREE.Layers()
Inherited from
Group.layers
matrix
matrix:
Matrix4
Defined in: three.js/core/Object3D:matrix
The local transform matrix.
Default Value
new THREE.Matrix4()
Inherited from
Group.matrix
matrixAutoUpdate
matrixAutoUpdate:
boolean
Defined in: three.js/core/Object3D:matrixAutoUpdate
When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property.
Default Value
DEFAULT_MATRIX_AUTO_UPDATE - that is (true).
Inherited from
Group.matrixAutoUpdate
matrixWorld
matrixWorld:
Matrix4
Defined in: three.js/core/Object3D:matrixWorld
The global transform of the object.
Remarks
If the Object3D has no parent, then it’s identical to the local transform THREE.Object3D.matrix | .matrix.
Default Value
new THREE.Matrix4()
Inherited from
Group.matrixWorld
matrixWorldAutoUpdate
matrixWorldAutoUpdate:
boolean
Defined in: three.js/core/Object3D:matrixWorldAutoUpdate
If set, then the renderer checks every frame if the object and its children need matrix updates. When it isn’t, then you have to maintain all matrices in the object and its children yourself.
Default Value
DEFAULT_MATRIX_WORLD_AUTO_UPDATE - that is (true).
Inherited from
Group.matrixWorldAutoUpdate
matrixWorldNeedsUpdate
matrixWorldNeedsUpdate:
boolean
Defined in: three.js/core/Object3D:matrixWorldNeedsUpdate
When this is set, it calculates the matrixWorld in that frame and resets this property to false.
Default Value
false
Inherited from
Group.matrixWorldNeedsUpdate
modelViewMatrix
readonlymodelViewMatrix:Matrix4
Defined in: three.js/core/Object3D:modelViewMatrix
Default Value
new THREE.Matrix4()
Inherited from
Group.modelViewMatrix
name
name:
string
Defined in: three.js/core/Object3D:name
Optional name of the object
Remarks
(doesn’t need to be unique).
Default Value
""
Inherited from
Group.name
normalMatrix
readonlynormalMatrix:Matrix3
Defined in: three.js/core/Object3D:normalMatrix
Default Value
new THREE.Matrix3()
Inherited from
Group.normalMatrix
occlusionTest?
optionalocclusionTest:boolean
Defined in: three.js/renderers/common/Backend:occlusionTest
Inherited from
Group.occlusionTest
parent
parent:
Object3D<Object3DEventMap> |null
Defined in: three.js/core/Object3D:parent
Object’s parent in the scene graph.
Remarks
An object can have at most one parent.
Default Value
null
Inherited from
Group.parent
pivot
pivot:
Vector3|null
Defined in: three.js/core/Object3D:pivot
The pivot point for rotation and scale transformations. When set, rotation and scale are applied around this point instead of the object’s origin.
Default
nullInherited from
Group.pivot
position
readonlyposition:Vector3
Defined in: three.js/core/Object3D:position
Object’s local position.
Default Value
new THREE.Vector3() - that is (0, 0, 0).
Inherited from
Group.position
quaternion
readonlyquaternion:Quaternion
Defined in: three.js/core/Object3D:quaternion
Object’s local rotation as a THREE.Quaternion | Quaternion.
Default Value
new THREE.Quaternion() - that is (0, 0, 0, 1).
Inherited from
Group.quaternion
receiveShadow
receiveShadow:
boolean
Defined in: three.js/core/Object3D:receiveShadow
Whether the material receives shadows.
Default Value
false
Inherited from
Group.receiveShadow
renderOrder
renderOrder:
number
Defined in: three.js/core/Object3D:renderOrder
This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently.
Remarks
When this property is set for an instance of Group, all descendants objects will be sorted and rendered together. Sorting is from lowest to highest renderOrder.
Default Value
0
Inherited from
Group.renderOrder
rotation
readonlyrotation:Euler
Defined in: three.js/core/Object3D:rotation
Object’s local rotation (Euler angles), in radians.
Default Value
new THREE.Euler() - that is (0, 0, 0, Euler.DEFAULT_ORDER).
Inherited from
Group.rotation
scale
readonlyscale:Vector3
Defined in: three.js/core/Object3D:scale
The object’s local scale.
Default Value
new THREE.Vector3( 1, 1, 1 )
Inherited from
Group.scale
static
static:
boolean
Defined in: three.js/core/Object3D:static
Whether the 3D object is supposed to be static or not. If set to true, it means
the 3D object is not going to be changed after the initial renderer. This includes
geometry and material settings. A static 3D object can be processed by the renderer
slightly faster since certain state checks can be bypassed.
Only relevant in context of WebGPURenderer.
Default
falseInherited from
Group.static
type
readonlytype:string
Defined in: three.js/core/Object3D:type
A Read-only string to check this object type.
Remarks
This can be used to find a specific type of Object3D in a scene. Sub-classes will update this value.
Default Value
Object3D
Inherited from
Group.type
up
up:
Vector3
Defined in: three.js/core/Object3D:up
This is used by the lookAt method, for example, to determine the orientation of the result.
Default Value
Object3D.DEFAULT_UP - that is (0, 1, 0).
Inherited from
Group.up
userData
userData:
Record<string,any>
Defined in: three.js/core/Object3D:userData
An object that can be used to store custom data about the Object3D.
Remarks
It should not hold references to functions as these will not be cloned.
Default
{}
Inherited from
Group.userData
uuid
uuid:
string
Defined in: three.js/core/Object3D:uuid
UUID of this object instance.
Remarks
This gets automatically assigned and shouldn’t be edited.
Inherited from
Group.uuid
visible
visible:
boolean
Defined in: three.js/core/Object3D:visible
Object gets rendered if true.
Default Value
true
Inherited from
Group.visible
DEFAULT_MATRIX_AUTO_UPDATE
staticDEFAULT_MATRIX_AUTO_UPDATE:boolean
Defined in: three.js/core/Object3D:DEFAULT_MATRIX_AUTO_UPDATE
The default setting for matrixAutoUpdate for newly created Object3Ds.
Default Value
true
Inherited from
Group.DEFAULT_MATRIX_AUTO_UPDATE
DEFAULT_MATRIX_WORLD_AUTO_UPDATE
staticDEFAULT_MATRIX_WORLD_AUTO_UPDATE:boolean
Defined in: three.js/core/Object3D:DEFAULT_MATRIX_WORLD_AUTO_UPDATE
The default setting for matrixWorldAutoUpdate for newly created Object3Ds.
Default Value
true
Inherited from
Group.DEFAULT_MATRIX_WORLD_AUTO_UPDATE
DEFAULT_UP
staticDEFAULT_UP:Vector3
Defined in: three.js/core/Object3D:DEFAULT_UP
The default up direction for objects, also used as the default position for THREE.DirectionalLight | DirectionalLight, THREE.HemisphereLight | HemisphereLight and THREE.Spotlight | Spotlight (which creates lights shining from the top down).
Default Value
new THREE.Vector3( 0, 1, 0)
Inherited from
Group.DEFAULT_UP
Accessors
bounds
Get Signature
get bounds():
Box3
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:505
Get map bounds.
Returns
chunkSize
Get Signature
get chunkSize():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:132
Get/set chunk size in tiles (default: 512). Each layer is split into chunks of chunkSize×chunkSize tiles for frustum culling. Maps smaller than chunkSize naturally use a single chunk per layer.
Returns
number
Set Signature
set chunkSize(
value):void
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:136
Parameters
value
number
Returns
void
data
Get Signature
get data():
TileMapData|null
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:107
Get the tilemap data.
Returns
TileMapData | null
Set Signature
set data(
value):void
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:114
Set the tilemap data and rebuild the map.
Parameters
value
TileMapData | null
Returns
void
enableCollision
Get Signature
get enableCollision():
boolean
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:149
Get/set collision extraction flag.
Returns
boolean
Set Signature
set enableCollision(
value):void
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:153
Parameters
value
boolean
Returns
void
heightInPixels
Get Signature
get heightInPixels():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:179
Returns
number
heightInTiles
Get Signature
get heightInTiles():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:167
Returns
number
layerCount
Get Signature
get layerCount():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:439
Get layer count.
Returns
number
tileHeight
Get Signature
get tileHeight():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:173
Returns
number
tileWidth
Get Signature
get tileWidth():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:170
Returns
number
totalChunkCount
Get Signature
get totalChunkCount():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:526
Get total chunk count across all layers (equals total draw calls for tiles).
Returns
number
totalTileCount
Get Signature
get totalTileCount():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:533
Get total tile count across all layers.
Returns
number
widthInPixels
Get Signature
get widthInPixels():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:176
Returns
number
widthInTiles
Get Signature
get widthInTiles():
number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:164
Returns
number
Methods
add()
add(…
object):this
Defined in: three.js/core/Object3D:add
Adds another Object3D as child of this Object3D.
Parameters
object
Returns
this
Remarks
An arbitrary number of objects may be added Any current parent on an object passed in here will be removed, since an Object3D can have at most one parent.
See
- attach
- THREE.Group | Group for info on manually grouping objects.
Inherited from
Group.add
addEventListener()
addEventListener<
T>(type,listener):void
Defined in: three.js/core/EventDispatcher:addEventListener
Adds a listener to an event type.
Type Parameters
T
T extends keyof Object3DEventMap
Parameters
type
T
The type of event to listen to.
listener
EventListener<Object3DEventMap[T], T, TileMap2D>
The function that gets called when the event is fired.
Returns
void
Inherited from
Group.addEventListener
applyMatrix4()
applyMatrix4(
matrix):void
Defined in: three.js/core/Object3D:applyMatrix4
Applies the matrix transform to the object and updates the object’s position, rotation and scale.
Parameters
matrix
Returns
void
Inherited from
Group.applyMatrix4
applyQuaternion()
applyQuaternion(
quaternion):this
Defined in: three.js/core/Object3D:applyQuaternion
Applies the rotation represented by the quaternion to the object.
Parameters
quaternion
Returns
this
Inherited from
Group.applyQuaternion
attach()
attach(
object):this
Defined in: three.js/core/Object3D:attach
Adds a Object3D as a child of this, while maintaining the object’s world transform.
Parameters
object
Returns
this
Remarks
Note: This method does not support scene graphs having non-uniformly-scaled nodes(s).
See
Inherited from
Group.attach
clear()
clear():
this
Defined in: three.js/core/Object3D:clear
Removes all child objects.
Returns
this
Inherited from
Group.clear
clone()
clone(
recursive?):this
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:557
Clone for devtools/serialization compatibility. Returns a Group containing cloned child layers for visual inspection.
Parameters
recursive?
boolean
Returns
this
Overrides
Group.clone
copy()
copy(
object,recursive?):this
Defined in: three.js/core/Object3D:copy
Copies the given object into this object.
Parameters
object
recursive?
boolean
If set to true, descendants of the object are copied next to the existing ones. If set to
false, descendants are left unchanged. Default is true.
Returns
this
Remarks
Event listeners and user-defined callbacks (.onAfterRender and .onBeforeRender) are not copied.
Inherited from
Group.copy
dispatchEvent()
dispatchEvent<
T>(event):void
Defined in: three.js/core/EventDispatcher:dispatchEvent
Fire an event type.
Type Parameters
T
T extends keyof Object3DEventMap
Parameters
event
BaseEvent<T> & Object3DEventMap[T]
The event that gets fired.
Returns
void
Inherited from
Group.dispatchEvent
dispose()
dispose():
void
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:592
Dispose of all resources.
Returns
void
getCollisionShapes()
getCollisionShapes(): readonly
CollisionShape[]
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:498
Get collision shapes.
Returns
readonly CollisionShape[]
getLayer()
getLayer(
name):TileLayer|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:418
Get tile layer by name.
Parameters
name
string
Returns
TileLayer | undefined
getLayerAt()
getLayerAt(
index):TileLayer|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:425
Get tile layer by index.
Parameters
index
number
Returns
TileLayer | undefined
getLayerMaterial()
getLayerMaterial(
name):Sprite2DMaterial|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:541
Get the Sprite2DMaterial for a tile layer by name. Use this to apply TSL effects or lighting to specific layers.
Parameters
name
string
Returns
Sprite2DMaterial | undefined
getLayerMaterialAt()
getLayerMaterialAt(
index):Sprite2DMaterial|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:549
Get the Sprite2DMaterial for a tile layer by index. Use this to apply TSL effects or lighting to specific layers.
Parameters
index
number
Returns
Sprite2DMaterial | undefined
getLayers()
getLayers(): readonly
TileLayer[]
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:432
Get all tile layers.
Returns
readonly TileLayer[]
getObjectById()
getObjectById(
id):Object3D<Object3DEventMap> |undefined
Defined in: three.js/core/Object3D:getObjectById
Searches through an object and its children, starting with the object itself, and returns the first with a matching id.
Parameters
id
number
Unique number of the object instance. Expects a Integer
Returns
Object3D<Object3DEventMap> | undefined
Remarks
Note that ids are assigned in chronological order: 1, 2, 3, …, incrementing by one for each new object.
See
id
Inherited from
Group.getObjectById
getObjectByName()
getObjectByName(
name):Object3D<Object3DEventMap> |undefined
Defined in: three.js/core/Object3D:getObjectByName
Searches through an object and its children, starting with the object itself, and returns the first with a matching name.
Parameters
name
string
String to match to the children’s Object3D.name property.
Returns
Object3D<Object3DEventMap> | undefined
Remarks
Note that for most objects the name is an empty string by default You will have to set it manually to make use of this method.
Inherited from
Group.getObjectByName
getObjectByProperty()
getObjectByProperty(
name,value):Object3D<Object3DEventMap> |undefined
Defined in: three.js/core/Object3D:getObjectByProperty
Searches through an object and its children, starting with the object itself, and returns the first with a property that matches the value given.
Parameters
name
string
the property name to search for.
value
any
value of the given property.
Returns
Object3D<Object3DEventMap> | undefined
Inherited from
Group.getObjectByProperty
getObjectLayer()
getObjectLayer(
name):ObjectLayerData|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:446
Get object layer by name.
Parameters
name
string
Returns
ObjectLayerData | undefined
getObjectsByProperty()
getObjectsByProperty(
name,value,optionalTarget?):Object3D<Object3DEventMap>[]
Defined in: three.js/core/Object3D:getObjectsByProperty
Searches through an object and its children, starting with the object itself, and returns the first with a property that matches the value given.
Parameters
name
string
The property name to search for.
value
any
Value of the given property.
optionalTarget?
target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
Returns
Inherited from
Group.getObjectsByProperty
getObjectsByType()
getObjectsByType(
type):TileMapObject[]
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:453
Get all objects of a specific type.
Parameters
type
string
Returns
getProperty()
getProperty<
T>(name):T|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:519
Get custom property from map data.
Type Parameters
T
T
Parameters
name
string
Returns
T | undefined
getTileAtWorld()
getTileAtWorld(
worldX,worldY,layerIndex):number
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:468
Get tile GID at world position.
Parameters
worldX
number
worldY
number
layerIndex
number = 0
Returns
number
getTileset()
getTileset(
name):Tileset|undefined
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:512
Get tileset by name.
Parameters
name
string
Returns
Tileset | undefined
getWorldDirection()
getWorldDirection(
target):Vector3
Defined in: three.js/core/Object3D:getWorldDirection
Returns a vector representing the direction of object’s positive z-axis in world space.
Parameters
target
The result will be copied into this Vector3.
Returns
Inherited from
Group.getWorldDirection
getWorldPosition()
getWorldPosition(
target):Vector3
Defined in: three.js/core/Object3D:getWorldPosition
Returns a vector representing the position of the object in world space.
Parameters
target
The result will be copied into this Vector3.
Returns
Inherited from
Group.getWorldPosition
getWorldQuaternion()
getWorldQuaternion(
target):Quaternion
Defined in: three.js/core/Object3D:getWorldQuaternion
Returns a quaternion representing the rotation of the object in world space.
Parameters
target
The result will be copied into this Quaternion.
Returns
Inherited from
Group.getWorldQuaternion
getWorldScale()
getWorldScale(
target):Vector3
Defined in: three.js/core/Object3D:getWorldScale
Returns a vector of the scaling factors applied to the object for each axis in world space.
Parameters
target
The result will be copied into this Vector3.
Returns
Inherited from
Group.getWorldScale
hasEventListener()
hasEventListener<
T>(type,listener):boolean
Defined in: three.js/core/EventDispatcher:hasEventListener
Checks if listener is added to an event type.
Type Parameters
T
T extends keyof Object3DEventMap
Parameters
type
T
The type of event to listen to.
listener
EventListener<Object3DEventMap[T], T, TileMap2D>
The function that gets called when the event is fired.
Returns
boolean
Inherited from
Group.hasEventListener
localToWorld()
localToWorld(
vector):Vector3
Defined in: three.js/core/Object3D:localToWorld
Converts the vector from this object’s local space to world space.
Parameters
vector
A vector representing a position in this object’s local space.
Returns
Inherited from
Group.localToWorld
lookAt()
Call Signature
lookAt(
vector):void
Defined in: three.js/core/Object3D:lookAt
Rotates the object to face a point in world space.
Parameters
vector
A vector representing a position in world space to look at.
Returns
void
Remarks
This method does not support objects having non-uniformly-scaled parent(s).
Inherited from
Group.lookAt
Call Signature
lookAt(
x,y,z):void
Defined in: three.js/core/Object3D:lookAt
Rotates the object to face a point in world space.
Parameters
x
number
Expects a Float
y
number
Expects a Float
z
number
Expects a Float
Returns
void
Remarks
This method does not support objects having non-uniformly-scaled parent(s).
Inherited from
Group.lookAt
onAfterRender()
onAfterRender(
renderer,scene,camera,geometry,material,group):void
Defined in: three.js/core/Object3D:onAfterRender
An optional callback that is executed immediately after a 3D object is rendered.
Parameters
renderer
scene
camera
geometry
material
group
Returns
void
Remarks
This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
Please notice that this callback is only executed for renderable 3D objects. Meaning 3D objects which
define their visual appearance with geometries and materials like instances of Mesh, Line,
Points or Sprite. Instances of Object3D, Group or Bone are not renderable
and thus this callback is not executed for such objects.
Inherited from
Group.onAfterRender
onAfterShadow()
onAfterShadow(
renderer,scene,camera,shadowCamera,geometry,depthMaterial,group):void
Defined in: three.js/core/Object3D:onAfterShadow
An optional callback that is executed immediately after a 3D object is rendered to a shadow map.
Parameters
renderer
scene
camera
shadowCamera
geometry
depthMaterial
group
Returns
void
Remarks
This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
depthMaterial, group.
Please notice that this callback is only executed for renderable 3D objects. Meaning 3D objects which
define their visual appearance with geometries and materials like instances of Mesh, Line,
Points or Sprite. Instances of Object3D, Group or Bone are not renderable
and thus this callback is not executed for such objects.
Inherited from
Group.onAfterShadow
onBeforeRender()
onBeforeRender(
renderer,scene,camera,geometry,material,group):void
Defined in: three.js/core/Object3D:onBeforeRender
An optional callback that is executed immediately before a 3D object is rendered.
Parameters
renderer
scene
camera
geometry
material
group
Returns
void
Remarks
This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
Please notice that this callback is only executed for renderable 3D objects. Meaning 3D objects which
define their visual appearance with geometries and materials like instances of Mesh, Line,
Points or Sprite. Instances of Object3D, Group or Bone are not renderable
and thus this callback is not executed for such objects.
Inherited from
Group.onBeforeRender
onBeforeShadow()
onBeforeShadow(
renderer,scene,camera,shadowCamera,geometry,depthMaterial,group):void
Defined in: three.js/core/Object3D:onBeforeShadow
An optional callback that is executed immediately before a 3D object is rendered to a shadow map.
Parameters
renderer
scene
camera
shadowCamera
geometry
depthMaterial
group
Returns
void
Remarks
This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
depthMaterial, group.
Please notice that this callback is only executed for renderable 3D objects. Meaning 3D objects which
define their visual appearance with geometries and materials like instances of Mesh, Line,
Points or Sprite. Instances of Object3D, Group or Bone are not renderable
and thus this callback is not executed for such objects.
Inherited from
Group.onBeforeShadow
raycast()
raycast(
raycaster,intersects):void
Defined in: three.js/core/Object3D:raycast
Abstract (empty) method to get intersections between a casted ray and this object
Parameters
raycaster
intersects
Intersection<Object3D<Object3DEventMap>>[]
Returns
void
Remarks
Subclasses such as THREE.Mesh | Mesh, THREE.Line | Line, and THREE.Points | Points implement this method in order to use raycasting.
See
THREE.Raycaster | Raycaster
Default Value
() => {}
Inherited from
Group.raycast
remove()
remove(…
object):this
Defined in: three.js/core/Object3D:remove
Removes a Object3D as child of this Object3D.
Parameters
object
Returns
this
Remarks
An arbitrary number of objects may be removed.
See
THREE.Group | Group for info on manually grouping objects.
Inherited from
Group.remove
removeEventListener()
removeEventListener<
T>(type,listener):void
Defined in: three.js/core/EventDispatcher:removeEventListener
Removes a listener from an event type.
Type Parameters
T
T extends keyof Object3DEventMap
Parameters
type
T
The type of the listener that gets removed.
listener
EventListener<Object3DEventMap[T], T, TileMap2D>
The listener function that gets removed.
Returns
void
Inherited from
Group.removeEventListener
removeFromParent()
removeFromParent():
this
Defined in: three.js/core/Object3D:removeFromParent
Removes this object from its current parent.
Returns
this
Inherited from
Group.removeFromParent
rotateOnAxis()
rotateOnAxis(
axis,angle):this
Defined in: three.js/core/Object3D:rotateOnAxis
Rotate an object along an axis in object space.
Parameters
axis
A normalized vector in object space.
angle
number
The angle in radians. Expects a Float
Returns
this
Remarks
The axis is assumed to be normalized.
Inherited from
Group.rotateOnAxis
rotateOnWorldAxis()
rotateOnWorldAxis(
axis,angle):this
Defined in: three.js/core/Object3D:rotateOnWorldAxis
Rotate an object along an axis in world space.
Parameters
axis
A normalized vector in world space.
angle
number
The angle in radians. Expects a Float
Returns
this
Remarks
The axis is assumed to be normalized Method Assumes no rotated parent.
Inherited from
Group.rotateOnWorldAxis
rotateX()
rotateX(
angle):this
Defined in: three.js/core/Object3D:rotateX
Rotates the object around x axis in local space.
Parameters
angle
number
Returns
this
Inherited from
Group.rotateX
rotateY()
rotateY(
angle):this
Defined in: three.js/core/Object3D:rotateY
Rotates the object around y axis in local space.
Parameters
angle
number
Returns
this
Inherited from
Group.rotateY
rotateZ()
rotateZ(
angle):this
Defined in: three.js/core/Object3D:rotateZ
Rotates the object around z axis in local space.
Parameters
angle
number
Returns
this
Inherited from
Group.rotateZ
setRotationFromAxisAngle()
setRotationFromAxisAngle(
axis,angle):void
Defined in: three.js/core/Object3D:setRotationFromAxisAngle
Calls THREE.Quaternion.setFromAxisAngle | setFromAxisAngle(axis, angle) on the .quaternion.
Parameters
axis
A normalized vector in object space.
angle
number
Angle in radians. Expects a Float
Returns
void
Inherited from
Group.setRotationFromAxisAngle
setRotationFromEuler()
setRotationFromEuler(
euler):void
Defined in: three.js/core/Object3D:setRotationFromEuler
Calls THREE.Quaternion.setFromEuler | setFromEuler(euler) on the .quaternion.
Parameters
euler
Euler angle specifying rotation amount.
Returns
void
Inherited from
Group.setRotationFromEuler
setRotationFromMatrix()
setRotationFromMatrix(
m):void
Defined in: three.js/core/Object3D:setRotationFromMatrix
Calls THREE.Quaternion.setFromRotationMatrix | setFromRotationMatrix(m) on the .quaternion.
Parameters
m
Rotate the quaternion by the rotation component of the matrix.
Returns
void
Remarks
Note that this assumes that the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).
Inherited from
Group.setRotationFromMatrix
setRotationFromQuaternion()
setRotationFromQuaternion(
q):void
Defined in: three.js/core/Object3D:setRotationFromQuaternion
Copy the given THREE.Quaternion | Quaternion into .quaternion.
Parameters
q
Normalized Quaternion.
Returns
void
Inherited from
Group.setRotationFromQuaternion
tileToWorld()
tileToWorld(
tileX,tileY):object
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:488
Convert tile coordinates to world position (center of tile).
Parameters
tileX
number
tileY
number
Returns
object
x
x:
number
y
y:
number
toJSON()
toJSON(
meta?):Object3DJSON
Defined in: three.js/core/Object3D:toJSON
Convert the object to three.js JSON Object/Scene format.
Parameters
meta?
Object containing metadata such as materials, textures or images for the object.
Returns
Inherited from
Group.toJSON
translateOnAxis()
translateOnAxis(
axis,distance):this
Defined in: three.js/core/Object3D:translateOnAxis
Translate an object by distance along an axis in object space
Parameters
axis
A normalized vector in object space.
distance
number
The distance to translate. Expects a Float
Returns
this
Remarks
The axis is assumed to be normalized.
Inherited from
Group.translateOnAxis
translateX()
translateX(
distance):this
Defined in: three.js/core/Object3D:translateX
Translates object along x axis in object space by distance units.
Parameters
distance
number
Expects a Float
Returns
this
Inherited from
Group.translateX
translateY()
translateY(
distance):this
Defined in: three.js/core/Object3D:translateY
Translates object along y axis in object space by distance units.
Parameters
distance
number
Expects a Float
Returns
this
Inherited from
Group.translateY
translateZ()
translateZ(
distance):this
Defined in: three.js/core/Object3D:translateZ
Translates object along z axis in object space by distance units.
Parameters
distance
number
Expects a Float
Returns
this
Inherited from
Group.translateZ
traverse()
traverse(
callback):void
Defined in: three.js/core/Object3D:traverse
Executes the callback on this object and all descendants.
Parameters
callback
(object) => any
A function with as first argument an Object3D object.
Returns
void
Remarks
Note: Modifying the scene graph inside the callback is discouraged.
Inherited from
Group.traverse
traverseAncestors()
traverseAncestors(
callback):void
Defined in: three.js/core/Object3D:traverseAncestors
Executes the callback on all ancestors.
Parameters
callback
(object) => any
A function with as first argument an Object3D object.
Returns
void
Remarks
Note: Modifying the scene graph inside the callback is discouraged.
Inherited from
Group.traverseAncestors
traverseVisible()
traverseVisible(
callback):void
Defined in: three.js/core/Object3D:traverseVisible
Like traverse, but the callback will only be executed for visible objects
Parameters
callback
(object) => any
A function with as first argument an Object3D object.
Returns
void
Remarks
Descendants of invisible objects are not traversed. Note: Modifying the scene graph inside the callback is discouraged.
Inherited from
Group.traverseVisible
update()
update(
deltaMs):void
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:409
Update animated tiles. Call this in your animation loop with delta time in milliseconds.
Parameters
deltaMs
number
Returns
void
updateMatrix()
updateMatrix():
void
Defined in: three.js/core/Object3D:updateMatrix
Updates local transform.
Returns
void
Inherited from
Group.updateMatrix
updateMatrixWorld()
updateMatrixWorld(
force?):void
Defined in: three.js/core/Object3D:updateMatrixWorld
Updates the global transform of the object.
And will update the object descendants if .matrixWorldNeedsUpdate is set to true or if the force parameter is set to true.
Parameters
force?
boolean
A boolean that can be used to bypass .matrixWorldAutoUpdate, to recalculate the world matrix of the object and descendants on the current frame.
Useful if you cannot wait for the renderer to update it on the next frame, assuming .matrixWorldAutoUpdate set to true.
Returns
void
Inherited from
Group.updateMatrixWorld
updateWorldMatrix()
updateWorldMatrix(
updateParents,updateChildren):void
Defined in: three.js/core/Object3D:updateWorldMatrix
Updates the global transform of the object.
Parameters
updateParents
boolean
Recursively updates global transform of ancestors.
updateChildren
boolean
Recursively updates global transform of descendants.
Returns
void
Inherited from
Group.updateWorldMatrix
worldToLocal()
worldToLocal(
vector):Vector3
Defined in: three.js/core/Object3D:worldToLocal
Converts the vector from world space to this object’s local space.
Parameters
vector
A vector representing a position in world space.
Returns
Inherited from
Group.worldToLocal
worldToTile()
worldToTile(
worldX,worldY):object
Defined in: packages/three-flatland/src/tilemap/TileMap2D.ts:478
Convert world position to tile coordinates (in Tiled’s Y-down system).
Parameters
worldX
number
worldY
number
Returns
object
x
x:
number
y
y:
number