class Scene
Represents a scene to be rendered by the engine.
@see http://doc.babylonjs.com/page.php?p=21911
@constructor
Name | Type | Description | |
---|---|---|---|
engine | Engine |
Texture used in all pbr material as the reflection texture.
As in the majority of the scene they are the same (exception for multi room and so on),
this is easier to reference from here than from all the materials.
Texture used in all pbr material as the reflection texture.
As in the majority of the scene they are the same (exception for multi room and so on),
this is easier to set here than in all the materials.
Default image processing configuration used either in the rendering
Forward main pass or through the imageProcessingPostProcess if present.
As in the majority of the scene they are the same (exception for multi camera),
this is easier to reference from here than from all the materials and post process.
* No setter as we it is a shared configuration, you can set the values instead.
This is used to call preventDefault() on pointer down
in order to block unwanted artifacts like system double clicks
An event triggered when the scene is disposed.
@type {BABYLON.Observable}
An event triggered before rendering the scene (right after animations and physics)
@type {BABYLON.Observable}
An event triggered after rendering the scene
@type {BABYLON.Observable}
An event triggered before animating the scene
@type {BABYLON.Observable}
An event triggered after animations processing
@type {BABYLON.Observable}
An event triggered before draw calls are ready to be sent
@type {BABYLON.Observable}
An event triggered after draw calls have been sent
@type {BABYLON.Observable}
An event triggered when physic simulation is about to be run
@type {BABYLON.Observable}
An event triggered when physic simulation has been done
@type {BABYLON.Observable}
An event triggered when the scene is ready
@type {BABYLON.Observable}
An event triggered before rendering a camera
@type {BABYLON.Observable}
An event triggered after rendering a camera
@type {BABYLON.Observable}
An event triggered when active meshes evaluation is about to start
@type {BABYLON.Observable}
An event triggered when active meshes evaluation is done
@type {BABYLON.Observable}
An event triggered when particles rendering is about to start
Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
@type {BABYLON.Observable}
An event triggered when particles rendering is done
Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
@type {BABYLON.Observable}
An event triggered when sprites rendering is about to start
Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
@type {BABYLON.Observable}
An event triggered when sprites rendering is done
Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
@type {BABYLON.Observable}
An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
@type {BABYLON.Observable}
An event triggered when a camera is created
@type {BABYLON.Observable}
An event triggered when a camera is removed
@type {BABYLON.Observable}
An event triggered when a light is created
@type {BABYLON.Observable}
An event triggered when a light is removed
@type {BABYLON.Observable}
An event triggered when a geometry is created
@type {BABYLON.Observable}
An event triggered when a geometry is removed
@type {BABYLON.Observable}
An event triggered when a transform node is created
@type {BABYLON.Observable}
An event triggered when a transform node is removed
@type {BABYLON.Observable}
An event triggered when a mesh is created
@type {BABYLON.Observable}
An event triggered when a mesh is removed
@type {BABYLON.Observable}
An event triggered when render targets are about to be rendered
Can happen multiple times per frame.
@type {BABYLON.Observable}
An event triggered when render targets were rendered.
Can happen multiple times per frame.
@type {BABYLON.Observable}
An event triggered before calculating deterministic simulation step
@type {BABYLON.Observable}
An event triggered after calculating deterministic simulation step
@type {BABYLON.Observable}
This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
The RenderinGroupInfo class contains all the information about the context in which the observable is called
If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
Name | Type | Description | |
---|---|---|---|
Mesh | AbstractMesh |
Name | Type | Description | |
---|---|---|---|
Mesh | AbstractMesh |
Name | Type | Description | |
---|---|---|---|
Mesh | AbstractMesh |
Name | Type | Description | |
---|---|---|---|
evt | PointerEvent | ||
pickInfo | PickingInfo |
Name | Type | Description | |
---|---|---|---|
evt | PointerEvent | ||
pickInfo | PickingInfo |
Name | Type | Description | |
---|---|---|---|
evt | PointerEvent | ||
pickInfo | Nullable<PickingInfo> |
Name | Type | Description | |
---|---|---|---|
evt | PointerEvent | ||
pickInfo | PickingInfo |
This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
Observable event triggered each time an input event is received from the rendering canvas
This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
Observable event triggered each time an keyboard event is received from the hosting window
is fog enabled on this scene.
All of the lights added to this scene.
@see BABYLON.Light
@type {BABYLON.Light[]}
All of the tranform nodes added to this scene.
@see BABYLON.TransformNode
@type {BABYLON.TransformNode[]}
All of the (abstract) meshes added to this scene.
@see BABYLON.AbstractMesh
@type {BABYLON.AbstractMesh[]}
This scene's action manager
@type {BABYLON.ActionManager}
The mesh that is currently under the pointer.
@return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
Current on-screen X position of the pointer
@return {number} X position of the pointer
Current on-screen Y position of the pointer
@return {number} Y position of the pointer
Return a unique id as a string which can serve as an identifier for the scene
Name | Type | Description | |
---|---|---|---|
newStepId | number |
Name | Type | Description | |
---|---|---|---|
material | Material | ||
effect | Effect | ||
optional | visibility | number |
Use this method to simulate a pointer move on a mesh
The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
Name | Type | Description | |
---|---|---|---|
pickResult | PickingInfo |
Use this method to simulate a pointer down on a mesh
The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
Name | Type | Description | |
---|---|---|---|
pickResult | PickingInfo |
Use this method to simulate a pointer up on a mesh
The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
Name | Type | Description | |
---|---|---|---|
pickResult | PickingInfo |
Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
Name | Type | Description | |
---|---|---|---|
optional | attachUp | boolean | defines if you want to attach events to pointerup |
optional | attachDown | boolean | defines if you want to attach events to pointerdown |
optional | attachMove | boolean | defines if you want to attach events to pointermove |
Name | Type | Description | |
---|---|---|---|
func |
Name | Type | Description | |
---|---|---|---|
func |
Name | Type | Description | |
---|---|---|---|
func |
Name | Type | Description | |
---|---|---|---|
func |
Registers a function to be executed when the scene is ready.
Name | Type | Description | |
---|---|---|---|
func |
Will start the animation sequence of a given target
Returns {BABYLON.Animatable} the animatable object created for this animation
See BABYLON.Animatable
Name | Type | Description | |
---|---|---|---|
target | any | - the target | |
from | number | ||
to | number | ||
optional | loop | boolean | |
optional | speedRatio | number | |
optional | onAnimationEnd |
Name | Type | Description | |
---|---|---|---|
target | any | ||
animations | Animation[] | ||
from | number | ||
to | number | ||
optional | loop | boolean | |
optional | speedRatio | number |
Name | Type | Description | |
---|---|---|---|
target | any |
Will stop the animation of the given target
@see beginAnimation
Name | Type | Description | |
---|---|---|---|
target | any | - the target | |
optional | animationName | string | - the name of the animation to stop (all animations will be stopped is empty) |
Stops and removes all animations that have been applied to the scene
Name | Type | Description | |
---|---|---|---|
view | Matrix | ||
projection | Matrix |
Name | Type | Description | |
---|---|---|---|
newMesh | AbstractMesh |
Name | Type | Description | |
---|---|---|---|
toRemove | AbstractMesh |
Name | Type | Description | |
---|---|---|---|
newTransformNode | TransformNode |
Name | Type | Description | |
---|---|---|---|
toRemove | TransformNode |
Name | Type | Description | |
---|---|---|---|
toRemove | Skeleton |
Name | Type | Description | |
---|---|---|---|
toRemove | MorphTargetManager |
Name | Type | Description | |
---|---|---|---|
toRemove | Light |
Name | Type | Description | |
---|---|---|---|
toRemove | Camera |
Name | Type | Description | |
---|---|---|---|
newLight | Light |
Name | Type | Description | |
---|---|---|---|
newCamera | Camera |
Switch active camera
Name | Type | Description | |
---|---|---|---|
newCamera | Camera | ||
optional | attachControl | boolean |
sets the active camera of the scene using its ID
@return {BABYLON.Camera|null} the new active camera or null if none found.
@see activeCamera
Name | Type | Description | |
---|---|---|---|
id | string |
sets the active camera of the scene using its name
@return {BABYLON.Camera|null} the new active camera or null if none found.
@see activeCamera
Name | Type | Description | |
---|---|---|---|
name | string |
get a material using its id
@return {BABYLON.Material|null} the material or null if none found.
Name | Type | Description | |
---|---|---|---|
id | string |
get a material using its name
@return {BABYLON.Material|null} the material or null if none found.
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
uniqueId | number |
get a camera using its name
@return {BABYLON.Camera|null} the camera or null if none found.
Name | Type | Description | |
---|---|---|---|
name | string |
get a bone using its id
@return {BABYLON.Bone|null} the bone or null if not found
Name | Type | Description | |
---|---|---|---|
id | string |
get a bone using its id
@return {BABYLON.Bone|null} the bone or null if not found
Name | Type | Description | |
---|---|---|---|
name | string |
get a light node using its name
@return {BABYLON.Light|null} the light or null if none found.
Name | Type | Description | |
---|---|---|---|
name | string |
get a light node using its ID
@return {BABYLON.Light|null} the light or null if none found.
Name | Type | Description | |
---|---|---|---|
id | string |
get a light node using its scene-generated unique ID
@return {BABYLON.Light|null} the light or null if none found.
Name | Type | Description | |
---|---|---|---|
uniqueId | number |
get a particle system by id
@return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
Name | Type | Description | |
---|---|---|---|
id | string | {number} the particle system id |
get a geometry using its ID
@return {BABYLON.Geometry|null} the geometry or null if none found.
Name | Type | Description | |
---|---|---|---|
id | string |
add a new geometry to this scene.
@return {boolean} was the geometry added or not
Name | Type | Description | |
---|---|---|---|
geometry | Geometry | ||
optional | force | boolean |
Removes an existing geometry
@return {boolean} was the geometry removed or not
Name | Type | Description | |
---|---|---|---|
geometry | Geometry |
Get the first added mesh found of a given ID
@return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Get the first added transform node found of a given ID
@return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Get a mesh with its auto-generated unique id
@return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
Name | Type | Description | |
---|---|---|---|
uniqueId | number |
Get a the last added mesh found of a given ID
@return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
Name | Type | Description | |
---|---|---|---|
id | string |
Get a the last added node (Mesh, Camera, Light) found of a given ID
@return {BABYLON.Node|null} the node found or null if not found at all.
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
id | string |
Name | Type | Description | |
---|---|---|---|
name | string |
Name | Type | Description | |
---|---|---|---|
id | number |
Name | Type | Description | |
---|---|---|---|
mesh | AbstractMesh |
Return a the first highlight layer of the scene with a given name.
@return The highlight layer if found otherwise null.
Name | Type | Description | |
---|---|---|---|
name | string | The name of the highlight layer to look for. |
Add an externaly attached data from its key.
This method call will fail and return false, if such key already exists.
If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
@return true if no such key were already present and the data was added successfully, false otherwise
Name | Type | Description | |
---|---|---|---|
key | string | the unique key that identifies the data | |
data | T | the data object to associate to the key for this Engine instance |
Get an externaly attached data from its key
@return the associated data, if present (can be null), or undefined if not present
Name | Type | Description | |
---|---|---|---|
key | string | the unique key that identifies the data |
Get an externaly attached data from its key, create it using a factory if it's not already present
@return the associated data, can be null if the factory returned null.
Name | Type | Description | |||
---|---|---|---|---|---|
key | string | the unique key that identifies the data | |||
factory | k | string |
Remove an externaly attached data from the Engine instance
@return true if the data was successfully removed, false if it doesn't exist
Name | Type | Description | |
---|---|---|---|
key | string | the unique key that identifies the data |
Use this function to stop evaluating active meshes. The current list will be keep alive between frames
Use this function to restart evaluating active meshes on every frame
Name | Type | Description | |
---|---|---|---|
optional | force | boolean |
Name | Type | Description | |
---|---|---|---|
alternateCamera | Camera |
Name | Type | Description | |
---|---|---|---|
optional | ratio | number |
Name | Type | Description | |
---|---|---|---|
optional | maxCapacity | number | |
optional | maxDepth | number |
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number | ||
world | Matrix | ||
camera | Nullable<Camera> |
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number | ||
world | Matrix | ||
result | Ray | ||
camera | Nullable<Camera> |
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number | ||
optional | camera | Camera |
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number | ||
result | Ray |
Name | Type | Description | |||
---|---|---|---|---|---|
x | number | position on screen | |||
y | number | position on screen | |||
optional | predicate | mesh | AbstractMesh |
| Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true optional | fastCheck | boolean | Launch a fast check only using the bounding boxes. Can be set to null.
Name | Type | Description | |||
---|---|---|---|---|---|
x | number | position on screen | |||
y | number | position on screen | |||
optional | predicate | sprite | Sprite |
| Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true optional | fastCheck | boolean | Launch a fast check only using the bounding boxes. Can be set to null.
Name | Type | Description | |||
---|---|---|---|---|---|
ray | Ray | The ray to use to pick meshes | |||
predicate | mesh | AbstractMesh |
| Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
Launch a ray to try to pick a mesh in the scene
Name | Type | Description | |||
---|---|---|---|---|---|
x | number | X position on screen | |||
y | number | Y position on screen | |||
optional | predicate | mesh | AbstractMesh |
| Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
Launch a ray to try to pick a mesh in the scene
Name | Type | Description | |||
---|---|---|---|---|---|
ray | Ray | Ray to use | |||
predicate | mesh | AbstractMesh |
Name | Type | Description | |
---|---|---|---|
mesh | Nullable<AbstractMesh> |
Name | Type | Description | |
---|---|---|---|
sprite | Nullable<Sprite> |
Enables physics to the current scene
@return {boolean} was the physics engine initialized
Name | Type | Description | |
---|---|---|---|
optional | gravity | Nullable<Vector3> | |
optional | plugin | IPhysicsEnginePlugin |
Name | Type | Description | |
---|---|---|---|
compound | any |
Name | Type | Description | |
---|---|---|---|
optional | createArcRotateCamera | boolean | |
optional | replace | boolean | |
optional | attachCameraControls | boolean |
Name | Type | Description | |
---|---|---|---|
optional | environmentTexture | BaseTexture | |
optional | pbr | boolean | |
optional | scale | number |
Name | Type | Description | |
---|---|---|---|
options | Partial<IEnvironmentHelperOptions> |
Name | Type | Description | |
---|---|---|---|
optional | webVROptions | VRExperienceHelperOptions |
Name | Type | Description | |||
---|---|---|---|---|---|
tagsQuery | string | ||||
optional | forEach | mesh | AbstractMesh |
Name | Type | Description | |||
---|---|---|---|---|---|
tagsQuery | string | ||||
optional | forEach | camera | Camera |
Name | Type | Description | |||
---|---|---|---|---|---|
tagsQuery | string | ||||
optional | forEach | light | Light |
Name | Type | Description | |||
---|---|---|---|---|---|
tagsQuery | string | ||||
optional | forEach | material | Material |
Overrides the default sort function applied in the renderging group to prepare the meshes.
This allowed control for front to back rendering or reversly depending of the special needs.
* @param renderingGroupId The rendering group id corresponding to its index
Name | Type | Description | |
---|---|---|---|
renderingGroupId | number | The rendering group id corresponding to its index | |
optional | opaqueSortCompareFn | Nullable<(a: SubMesh, b: SubMesh) => number> | The opaque queue comparison function use to sort. |
optional | alphaTestSortCompareFn | Nullable<(a: SubMesh, b: SubMesh) => number> | The alpha test queue comparison function use to sort. |
Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
* @param renderingGroupId The rendering group id corresponding to its index
Name | Type | Description | |
---|---|---|---|
renderingGroupId | number | The rendering group id corresponding to its index | |
autoClearDepthStencil | boolean | Automatically clears depth and stencil between groups if true. | |
optional | depth | boolean | Automatically clears depth between groups if true and autoClear is true. |
Will flag all materials as dirty to trigger new shader compilation
Name | Type | Description | |||
---|---|---|---|---|---|
flag | number | ||||
optional | predicate | mat | Material |