t3d. Scene

Scenes allow you to set up what and where is to be rendered by t3d. This is where you place objects, lights and cameras.

Constructor

new Scene()

Create a scene.

Extends

Members

anchorMatrix :t3d.Matrix4

The anchor matrix of the world coordinate system. If it is not an identity matrix, the actual lighting calculating and the world position in the shader, will be in the anchor coordinate system. By setting this property, you can solve the floating point precision problem caused by the rendering object far away from the origin of the world coordinate system. In addition, by setting the rotation, it can also repair the direction of the reflection.

castShadow :Boolean

Whether the object gets rendered into shadow map.
Type:
  • Boolean
Default Value
  • false

children :Array.<t3d.Object3D>

Object's parent in the scene graph. An object can have at most one parent.
Type:

clippingPlanes :Array.<t3d.Plane>

User-defined clipping planes specified as t3d.Plane objects in world space. These planes apply to the scene. Points in space whose dot product with the plane is negative are cut away.
Type:
Default Value
  • []

disableShadowSampler :Boolean

Defines whether disable shadow sampler feature. Shader with sampler2DShadow uniforms may cause unknown error on some android phones, set disableShadowSampler to true to avoid these bugs. When this property is set to true, soft shadow types will fallback to POISSON_SOFT without warning.
Type:
  • Boolean
Default Value
  • false

envDiffuseIntensity :Number

The diffuse intensity of the environment map.
Type:
  • Number
Default Value
  • 1

envSpecularIntensity :Number

The specular intensity of the environment map. This value is multiplied with the envMapIntensity of the material to get the final intensity.
Type:
  • Number
Default Value
  • 1

environment :t3d.TextureCube|Null

Sets the environment map for all materials in the scene. However, it's not possible to overwrite an existing texture assigned to Material.envMap.
Type:
Default Value
  • null

euler :t3d.Euler

Object's local rotation as an t3d.Euler, in radians.
Default Value
  • Euler(0, 0, 0)

fog :t3d.Fog

A t3d.Fog instance defining the type of fog that affects everything rendered in the scene.
Type:
Default Value
  • null

frustumCulled :Boolean

When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object. Otherwise the object gets rendered every frame even if it isn't visible.
Type:
  • Boolean
Default Value
  • true

(readonly) id :Number

Unique number for this object instance.
Type:
  • Number

(readonly) isScene :Boolean

Type:
  • Boolean
Default Value
  • true

logarithmicDepthBuffer :Boolean

whether to use a logarithmic depth buffer. It may be neccesary to use this if dealing with huge differences in scale in a single scene. Note that this setting uses gl_FragDepth if available which disables the Early Fragment Test optimization and can cause a decrease in performance.
Type:
  • Boolean
Default Value
  • false

matrix :t3d.Matrix4

The local transform matrix.

matrixAutoUpdate :Boolean

When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the worldMatrix property.
Type:
  • Boolean
Default Value
  • true

matrixNeedsUpdate :Boolean

When this is set, it calculates the matrix in that frame and resets this property to false.
Type:
  • Boolean
Default Value
  • true

name :String

Optional name of the object (doesn't need to be unique).
Type:
  • String
Default Value
  • ""

parent :t3d.Object3D

Object's parent in the scene graph. An object can have at most one parent.

position :t3d.Vector3

A Vector3 representing the object's local position.
Default Value
  • Vector3(0, 0, 0)

quaternion :t3d.Quaternion

Object's local rotation as a t3d.Quaternion.
Default Value
  • Quaternion(0, 0, 0, 1)

receiveShadow :Boolean

Whether the material receives shadows.
Type:
  • Boolean
Default Value
  • false

renderLayer :Number

Render layer of this object. RenderQueue will dispatch all renderable objects to the corresponding RenderQueueLayer according to object.renderLayer.
Type:
  • Number
Default Value
  • 0

renderOrder :Number

This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently. Sorting is from lowest to highest renderOrder.
Type:
  • Number
Default Value
  • 0

renderable :Boolean

Whether it can be collected into the Render Queue.
Type:
  • Boolean
Default Value
  • true

scale :t3d.Vector3

The object's local scale.
Default Value
  • Vector3(1, 1, 1)

shadowType :t3d.SHADOW_TYPE

Defines shadow map type. Note: In webgl1 or t3d.Scene#disableShadowSampler is true, soft shadow types will fallback to POISSON_SOFT without warning. Note: Point light only support POISSON_SOFT for now.
Default Value
  • SHADOW_TYPE.PCF3_SOFT

userData :Object

An object that can be used to store custom data about the t3d.Object3D. It should not hold references to functions as these will not be cloned.
Type:
  • Object
Default Value
  • {}

uuid :String

UUID of this object instance. This gets automatically assigned, so this shouldn't be edited.
Type:
  • String

visible :Boolean

Object gets rendered if true.
Type:
  • Boolean
Default Value
  • true

worldMatrix :t3d.Matrix4

The global transform of the object. If the Object3D has no parent, then it's identical to the local transform t3d.Object3D#matrix.

worldMatrixNeedsUpdate :Boolean

When this is set, it calculates the world matrix in that frame and resets this property to false.
Type:
  • Boolean
Default Value
  • true

Methods

add(object)

Add object as child of this object.
Parameters:
NameTypeDescription
objectt3d.Object3D

clone(recursiveopt) → {t3d.Object3D}

Returns a clone of this object and optionally all descendants.
Parameters:
NameTypeAttributesDefaultDescription
recursivefunction<optional>
trueif true, descendants of the object are also cloned.
Returns:
Type: 
t3d.Object3D

copy(source, recursiveopt) → {t3d.Object3D}

Copy the given object into this object.
Parameters:
NameTypeAttributesDefaultDescription
sourcet3d.Object3DThe object to be copied.
recursiveBoolean<optional>
trueif true, descendants of the object are also copied.
Returns:
Type: 
t3d.Object3D

getObjectByName(name) → {t3d.Object3D}

Searches through the object's children and returns the first with a matching name. 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.
Parameters:
NameTypeDescription
nameStringString to match to the children's t3d.Object3D#name property.
Returns:
Type: 
t3d.Object3D

getObjectByProperty(name, value) → {t3d.Object3D}

Searches through the object's children and returns the first with a property that matches the value given.
Parameters:
NameTypeDescription
nameStringthe property name to search for.
valueNumbervalue of the given property.
Returns:
Type: 
t3d.Object3D

getRenderQueue(camera) → {t3d.RenderQueue}

Get t3d.RenderQueue for the scene and camera. The RenderQueue will be updated by calling t3d.Scene#updateRenderQueue.
Parameters:
NameTypeDescription
camerat3d.CameraThe camera.
Returns:
- The target render queue.
Type: 
t3d.RenderQueue

getRenderStates(camera) → {t3d.RenderQueue}

Get t3d.RenderStates for the scene and camera. The RenderStates will be updated by calling t3d.Scene#updateRenderStates. The light data in RenderStates will be empty unless calling t3d.Scene#updateRenderQueue.
Parameters:
NameTypeDescription
camerat3d.CameraThe camera.
Returns:
- The target render queue.
Type: 
t3d.RenderQueue

getWorldDirection(optionalTarget=opt) → {Vector3}

Returns a vector representing the direction of object's positive z-axis in world space. This call must be after t3d.Object3D#updateMatrix.
Parameters:
NameTypeAttributesDescription
optionalTarget=Vector3<optional>
— the result will be copied into this Vector3.
Returns:
- the result.
Type: 
Vector3

lookAt(target, up)

Rotates the object to face a point in local space.
Parameters:
NameTypeDescription
targetVector3A vector representing a position in local space.
upVector3— A vector representing the up direction in local space.

onAfterRender()

An optional callback that is executed immediately after the Object3D is rendered.

onBeforeRender()

An optional callback that is executed immediately before the Object3D is rendered.

(abstract) raycast(ray, intersects)

Method to get intersections between a casted ray and this object.
Parameters:
NameTypeDescription
rayRayThe t3d.Ray instance.
intersectsArrayoutput intersects array.

remove(object)

Remove object as child of this object.
Parameters:
NameTypeDescription
objectt3d.Object3D

traverse(callback)

Executes the callback on this object and all descendants.
Parameters:
NameTypeDescription
callbackfunctionA function with as first argument an object3D object.

updateMatrix()

Update the local transform.

updateRenderQueue(camera, collectLightsopt, updateSkeletonsopt) → {t3d.RenderQueue}

Update t3d.RenderQueue for the scene and camera. Collect all visible meshes (and lights) from scene graph, and push meshes to render queue. Light data will be stored in RenderStates.
Parameters:
NameTypeAttributesDefaultDescription
camerat3d.CameraThe camera.
collectLightsBoolean<optional>
trueWhether to collect light data.
updateSkeletonsBoolean<optional>
trueWhether to update skeletons.
Returns:
- The result render queue.
Type: 
t3d.RenderQueue

updateRenderStates(camera, updateSceneopt) → {t3d.RenderStates}

Update t3d.RenderStates for the scene and camera. The light data in RenderStates will be empty unless calling t3d.Scene#updateRenderQueue.
Parameters:
NameTypeAttributesDefaultDescription
camerat3d.CameraThe camera.
updateSceneBoolean<optional>
trueWhether to update scene data.
Returns:
- The result render states.
Type: 
t3d.RenderStates