Scene

Scene

Description

class Scene

Represents a scene to be rendered by the engine.

@see http://doc.babylonjs.com/page.php?p=21911

Constructor

new Scene(engine)

@constructor

Parameters

Name Type Description
engine Engine

Members

static MinDeltaTime : number

static MaxDeltaTime : number

static FOGMODE_NONE : number

static FOGMODE_EXP : number

static FOGMODE_EXP2 : number

static FOGMODE_LINEAR : number

autoClear : boolean

autoClearDepthAndStencil : boolean

clearColor : Color4

ambientColor : Color3

environmentTexture : BaseTexture

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.

imageProcessingConfiguration : ImageProcessingConfiguration

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.

forceWireframe : boolean

forcePointsCloud : boolean

forceShowBoundingBoxes : boolean

clipPlane : Nullable<Plane>

animationsEnabled : boolean

useConstantAnimationDeltaTime : boolean

constantlyUpdateMeshUnderPointer : boolean

hoverCursor : string

defaultCursor : string

preventDefaultOnPointerDown : boolean

This is used to call preventDefault() on pointer down

in order to block unwanted artifacts like system double clicks

metadata : any

loadingPluginName : string

onDisposeObservable : Observable<Scene>

An event triggered when the scene is disposed.

@type {BABYLON.Observable}

onDispose : () => void

onBeforeRenderObservable : Observable<Scene>

An event triggered before rendering the scene (right after animations and physics)

@type {BABYLON.Observable}

beforeRender : Nullable<() => void>

onAfterRenderObservable : Observable<Scene>

An event triggered after rendering the scene

@type {BABYLON.Observable}

afterRender : Nullable<() => void>

onBeforeAnimationsObservable : Observable<Scene>

An event triggered before animating the scene

@type {BABYLON.Observable}

onAfterAnimationsObservable : Observable<Scene>

An event triggered after animations processing

@type {BABYLON.Observable}

onBeforeDrawPhaseObservable : Observable<Scene>

An event triggered before draw calls are ready to be sent

@type {BABYLON.Observable}

onAfterDrawPhaseObservable : Observable<Scene>

An event triggered after draw calls have been sent

@type {BABYLON.Observable}

onBeforePhysicsObservable : Observable<Scene>

An event triggered when physic simulation is about to be run

@type {BABYLON.Observable}

onAfterPhysicsObservable : Observable<Scene>

An event triggered when physic simulation has been done

@type {BABYLON.Observable}

onReadyObservable : Observable<Scene>

An event triggered when the scene is ready

@type {BABYLON.Observable}

onBeforeCameraRenderObservable : Observable<Camera>

An event triggered before rendering a camera

@type {BABYLON.Observable}

beforeCameraRender : () => void

onAfterCameraRenderObservable : Observable<Camera>

An event triggered after rendering a camera

@type {BABYLON.Observable}

afterCameraRender : () => void

onBeforeActiveMeshesEvaluationObservable : Observable<Scene>

An event triggered when active meshes evaluation is about to start

@type {BABYLON.Observable}

onAfterActiveMeshesEvaluationObservable : Observable<Scene>

An event triggered when active meshes evaluation is done

@type {BABYLON.Observable}

onBeforeParticlesRenderingObservable : Observable<Scene>

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}

onAfterParticlesRenderingObservable : Observable<Scene>

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}

onBeforeSpritesRenderingObservable : Observable<Scene>

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}

onAfterSpritesRenderingObservable : Observable<Scene>

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}

onDataLoadedObservable : Observable<Scene>

An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed

@type {BABYLON.Observable}

onNewCameraAddedObservable : Observable<Camera>

An event triggered when a camera is created

@type {BABYLON.Observable}

onCameraRemovedObservable : Observable<Camera>

An event triggered when a camera is removed

@type {BABYLON.Observable}

onNewLightAddedObservable : Observable<Light>

An event triggered when a light is created

@type {BABYLON.Observable}

onLightRemovedObservable : Observable<Light>

An event triggered when a light is removed

@type {BABYLON.Observable}

onNewGeometryAddedObservable : Observable<Geometry>

An event triggered when a geometry is created

@type {BABYLON.Observable}

onGeometryRemovedObservable : Observable<Geometry>

An event triggered when a geometry is removed

@type {BABYLON.Observable}

onNewTransformNodeAddedObservable : Observable<TransformNode>

An event triggered when a transform node is created

@type {BABYLON.Observable}

onTransformNodeRemovedObservable : Observable<TransformNode>

An event triggered when a transform node is removed

@type {BABYLON.Observable}

onNewMeshAddedObservable : Observable<AbstractMesh>

An event triggered when a mesh is created

@type {BABYLON.Observable}

onMeshRemovedObservable : Observable<AbstractMesh>

An event triggered when a mesh is removed

@type {BABYLON.Observable}

OnBeforeRenderTargetsRenderObservable : Observable<Scene>

An event triggered when render targets are about to be rendered

Can happen multiple times per frame.

@type {BABYLON.Observable}

OnAfterRenderTargetsRenderObservable : Observable<Scene>

An event triggered when render targets were rendered.

Can happen multiple times per frame.

@type {BABYLON.Observable}

onBeforeStepObservable : Observable<Scene>

An event triggered before calculating deterministic simulation step

@type {BABYLON.Observable}

onAfterStepObservable : Observable<Scene>

An event triggered after calculating deterministic simulation step

@type {BABYLON.Observable}

onRenderingGroupObservable : Observable<RenderingGroupInfo>

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)

animations : Animation[]

pointerDownPredicate : (Mesh: AbstractMesh) => boolean

Parameters

Name Type Description
Mesh AbstractMesh

pointerUpPredicate : (Mesh: AbstractMesh) => boolean

Parameters

Name Type Description
Mesh AbstractMesh

pointerMovePredicate : (Mesh: AbstractMesh) => boolean

Parameters

Name Type Description
Mesh AbstractMesh

onPointerMove : (evt: PointerEvent, pickInfo: PickingInfo) => void

Parameters

Name Type Description
evt PointerEvent
pickInfo PickingInfo

onPointerDown : (evt: PointerEvent, pickInfo: PickingInfo) => void

Parameters

Name Type Description
evt PointerEvent
pickInfo PickingInfo

onPointerUp : (evt: PointerEvent, pickInfo: Nullable<PickingInfo>) => void

Parameters

Name Type Description
evt PointerEvent
pickInfo Nullable<PickingInfo>

onPointerPick : (evt: PointerEvent, pickInfo: PickingInfo) => void

Parameters

Name Type Description
evt PointerEvent
pickInfo PickingInfo

gamepadManager : GamepadManager

onPrePointerObservable : Observable<PointerInfoPre>

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

onPointerObservable : Observable<PointerInfo>

Observable event triggered each time an input event is received from the rendering canvas

unTranslatedPointer : Vector2

static DragMovementThreshold : number

static LongPressDelay : number

static DoubleClickDelay : number

static ExclusiveDoubleClickMode : boolean

cameraToUseForPointers : Nullable<Camera>

onPreKeyboardObservable : Observable<KeyboardInfoPre>

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

onKeyboardObservable : Observable<KeyboardInfo>

Observable event triggered each time an keyboard event is received from the hosting window

useRightHandedSystem : boolean

fogEnabled : boolean

is fog enabled on this scene.

fogMode : number

fogColor : Color3

fogDensity : number

fogStart : number

fogEnd : number

shadowsEnabled : boolean

lightsEnabled : boolean

lights : Light[]

All of the lights added to this scene.

@see BABYLON.Light

@type {BABYLON.Light[]}

cameras : Camera[]

activeCameras : Camera[]

activeCamera : Nullable<Camera>

transformNodes : TransformNode[]

All of the tranform nodes added to this scene.

@see BABYLON.TransformNode

@type {BABYLON.TransformNode[]}

meshes : AbstractMesh[]

All of the (abstract) meshes added to this scene.

@see BABYLON.AbstractMesh

@type {BABYLON.AbstractMesh[]}

materials : Material[]

multiMaterials : MultiMaterial[]

defaultMaterial : Material

texturesEnabled : boolean

textures : BaseTexture[]

particlesEnabled : boolean

particleSystems : IParticleSystem[]

spritesEnabled : boolean

spriteManagers : SpriteManager[]

layers : Layer[]

highlightLayers : HighlightLayer[]

skeletonsEnabled : boolean

skeletons : Skeleton[]

morphTargetManagers : MorphTargetManager[]

lensFlaresEnabled : boolean

lensFlareSystems : LensFlareSystem[]

collisionsEnabled : boolean

collisionCoordinator : ICollisionCoordinator

gravity : Vector3

postProcesses : PostProcess[]

postProcessesEnabled : boolean

postProcessManager : PostProcessManager

postProcessRenderPipelineManager : PostProcessRenderPipelineManager

renderTargetsEnabled : boolean

dumpNextRenderTargets : boolean

customRenderTargets : RenderTargetTexture[]

useDelayedTextureLoading : boolean

importedMeshesFiles : String[]

probesEnabled : boolean

reflectionProbes : ReflectionProbe[]

database : Database

actionManager : ActionManager

This scene's action manager

@type {BABYLON.ActionManager}

proceduralTexturesEnabled : boolean

soundTracks : SoundTrack[]

mainSoundTrack : SoundTrack

VRHelper : VRExperienceHelper

simplificationQueue : SimplificationQueue

animationTimeScale : number

frustumPlanes : Plane[]

requireLightSorting : boolean

debugLayer : DebugLayer

workerCollisions : boolean

selectionOctree : Octree<AbstractMesh>

meshUnderPointer : Nullable<AbstractMesh>

The mesh that is currently under the pointer.

@return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.

pointerX : number

Current on-screen X position of the pointer

@return {number} X position of the pointer

pointerY : number

Current on-screen Y position of the pointer

@return {number} Y position of the pointer

totalVerticesPerfCounter : PerfCounter

totalActiveIndicesPerfCounter : PerfCounter

activeParticlesPerfCounter : PerfCounter

activeBonesPerfCounter : PerfCounter

interFramePerfCounter : Nullable<PerfCounter>

lastFramePerfCounter : Nullable<PerfCounter>

evaluateActiveMeshesDurationPerfCounter : Nullable<PerfCounter>

renderDurationPerfCounter : Nullable<PerfCounter>

particlesDurationPerfCounter : Nullable<PerfCounter>

spriteDuractionPerfCounter : Nullable<PerfCounter>

isLoading : boolean

Animatables : Animatable[]

uid : string

Return a unique id as a string which can serve as an identifier for the scene

this : ()

audioEnabled : boolean

headphone : boolean

isDisposed : boolean

Methods

setStepId(newStepId) void

Parameters

Name Type Description
newStepId number

getStepId() number

getInternalStep() number

getCachedMaterial() Nullable<Material>

getCachedEffect() Nullable<Effect>

getCachedVisibility() Nullable<number>

isCachedMaterialInvalid(material, effect, visibility) boolean

Parameters

Name Type Description
material Material
effect Effect
optional visibility number

getBoundingBoxRenderer() BoundingBoxRenderer

getOutlineRenderer() OutlineRenderer

getEngine() Engine

getTotalVertices() number

getActiveIndices() number

getActiveParticles() number

getActiveBones() number

getInterFramePerfCounter() number

getLastFrameDuration() number

getEvaluateActiveMeshesDuration() number

getActiveMeshes() SmartArray<AbstractMesh>

getRenderTargetsDuration() number

getRenderDuration() number

getParticlesDuration() number

getSpritesDuration() number

getAnimationRatio() number

getRenderId() number

incrementRenderId() void

simulatePointerMove(pickResult) Scene

Use this method to simulate a pointer move on a mesh

The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay

Parameters

Name Type Description
pickResult PickingInfo

simulatePointerDown(pickResult) Scene

Use this method to simulate a pointer down on a mesh

The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay

Parameters

Name Type Description
pickResult PickingInfo

simulatePointerUp(pickResult) Scene

Use this method to simulate a pointer up on a mesh

The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay

Parameters

Name Type Description
pickResult PickingInfo

attachControl(attachUp, attachDown, attachMove) void

Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp

Parameters

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

detachControl() void

isReady() boolean

resetCachedMaterial() void

registerBeforeRender(func) void

Parameters

Name Type Description
func

unregisterBeforeRender(func) void

Parameters

Name Type Description
func

registerAfterRender(func) void

Parameters

Name Type Description
func

unregisterAfterRender(func) void

Parameters

Name Type Description
func

getWaitingItemsCount() number

executeWhenReady(func) void

Registers a function to be executed when the scene is ready.

Parameters

Name Type Description
func

beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable) Animatable

Will start the animation sequence of a given target

Returns {BABYLON.Animatable} the animatable object created for this animation

See BABYLON.Animatable

Parameters

Name Type Description
target any - the target
from number
to number
optional loop boolean
optional speedRatio number
optional onAnimationEnd

beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd) Animatable

Parameters

Name Type Description
target any
animations Animation[]
from number
to number
optional loop boolean
optional speedRatio number

getAnimatableByTarget(target) Nullable<Animatable>

Parameters

Name Type Description
target any

stopAnimation(target, animationName) void

Will stop the animation of the given target

@see beginAnimation

Parameters

Name Type Description
target any - the target
optional animationName string - the name of the animation to stop (all animations will be stopped is empty)

stopAllAnimations() void

Stops and removes all animations that have been applied to the scene

getViewMatrix() Matrix

getProjectionMatrix() Matrix

getTransformMatrix() Matrix

setTransformMatrix(view, projection) void

Parameters

Name Type Description
view Matrix
projection Matrix

getSceneUniformBuffer() UniformBuffer

getUniqueId() number

addMesh(newMesh) void

Parameters

Name Type Description
newMesh AbstractMesh

removeMesh(toRemove) number

Parameters

Name Type Description
toRemove AbstractMesh

addTransformNode(newTransformNode) void

Parameters

Name Type Description
newTransformNode TransformNode

removeTransformNode(toRemove) number

Parameters

Name Type Description
toRemove TransformNode

removeSkeleton(toRemove) number

Parameters

Name Type Description
toRemove Skeleton

removeMorphTargetManager(toRemove) number

Parameters

Name Type Description
toRemove MorphTargetManager

removeLight(toRemove) number

Parameters

Name Type Description
toRemove Light

removeCamera(toRemove) number

Parameters

Name Type Description
toRemove Camera

addLight(newLight) void

Parameters

Name Type Description
newLight Light

sortLightsByPriority() void

addCamera(newCamera) void

Parameters

Name Type Description
newCamera Camera

switchActiveCamera(newCamera, attachControl) void

Switch active camera

Parameters

Name Type Description
newCamera Camera
optional attachControl boolean

setActiveCameraByID(id) Nullable<Camera>

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

Parameters

Name Type Description
id string

setActiveCameraByName(name) Nullable<Camera>

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

Parameters

Name Type Description
name string

getMaterialByID(id) Nullable<Material>

get a material using its id

@return {BABYLON.Material|null} the material or null if none found.

Parameters

Name Type Description
id string

getMaterialByName(name) Nullable<Material>

get a material using its name

@return {BABYLON.Material|null} the material or null if none found.

Parameters

Name Type Description
name string

getLensFlareSystemByName(name) Nullable<LensFlareSystem>

Parameters

Name Type Description
name string

getLensFlareSystemByID(id) Nullable<LensFlareSystem>

Parameters

Name Type Description
id string

getCameraByID(id) Nullable<Camera>

Parameters

Name Type Description
id string

getCameraByUniqueID(uniqueId) Nullable<Camera>

Parameters

Name Type Description
uniqueId number

getCameraByName(name) Nullable<Camera>

get a camera using its name

@return {BABYLON.Camera|null} the camera or null if none found.

Parameters

Name Type Description
name string

getBoneByID(id) Nullable<Bone>

get a bone using its id

@return {BABYLON.Bone|null} the bone or null if not found

Parameters

Name Type Description
id string

getBoneByName(name) Nullable<Bone>

get a bone using its id

@return {BABYLON.Bone|null} the bone or null if not found

Parameters

Name Type Description
name string

getLightByName(name) Nullable<Light>

get a light node using its name

@return {BABYLON.Light|null} the light or null if none found.

Parameters

Name Type Description
name string

getLightByID(id) Nullable<Light>

get a light node using its ID

@return {BABYLON.Light|null} the light or null if none found.

Parameters

Name Type Description
id string

getLightByUniqueID(uniqueId) Nullable<Light>

get a light node using its scene-generated unique ID

@return {BABYLON.Light|null} the light or null if none found.

Parameters

Name Type Description
uniqueId number

getParticleSystemByID(id) Nullable<IParticleSystem>

get a particle system by id

@return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.

Parameters

Name Type Description
id string {number} the particle system id

getGeometryByID(id) Nullable<Geometry>

get a geometry using its ID

@return {BABYLON.Geometry|null} the geometry or null if none found.

Parameters

Name Type Description
id string

pushGeometry(geometry, force) boolean

add a new geometry to this scene.

@return {boolean} was the geometry added or not

Parameters

Name Type Description
geometry Geometry
optional force boolean

removeGeometry(geometry) boolean

Removes an existing geometry

@return {boolean} was the geometry removed or not

Parameters

Name Type Description
geometry Geometry

getGeometries() Geometry[]

getMeshByID(id) Nullable<AbstractMesh>

Get the first added mesh found of a given ID

@return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.

Parameters

Name Type Description
id string

getMeshesByID(id) Array<AbstractMesh>

Parameters

Name Type Description
id string

getTransformNodeByID(id) Nullable<TransformNode>

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.

Parameters

Name Type Description
id string

getTransformNodesByID(id) Array<TransformNode>

Parameters

Name Type Description
id string

getMeshByUniqueID(uniqueId) Nullable<AbstractMesh>

Get a mesh with its auto-generated unique id

@return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.

Parameters

Name Type Description
uniqueId number

getLastMeshByID(id) Nullable<AbstractMesh>

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.

Parameters

Name Type Description
id string

getLastEntryByID(id) Nullable<Node>

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.

Parameters

Name Type Description
id string

getNodeByID(id) Nullable<Node>

Parameters

Name Type Description
id string

getNodeByName(name) Nullable<Node>

Parameters

Name Type Description
name string

getMeshByName(name) Nullable<AbstractMesh>

Parameters

Name Type Description
name string

getTransformNodeByName(name) Nullable<TransformNode>

Parameters

Name Type Description
name string

getSoundByName(name) Nullable<Sound>

Parameters

Name Type Description
name string

getLastSkeletonByID(id) Nullable<Skeleton>

Parameters

Name Type Description
id string

getSkeletonById(id) Nullable<Skeleton>

Parameters

Name Type Description
id string

getSkeletonByName(name) Nullable<Skeleton>

Parameters

Name Type Description
name string

getMorphTargetManagerById(id) Nullable<MorphTargetManager>

Parameters

Name Type Description
id number

isActiveMesh(mesh) boolean

Parameters

Name Type Description
mesh AbstractMesh

getHighlightLayerByName(name) Nullable<HighlightLayer>

Return a the first highlight layer of the scene with a given name.

@return The highlight layer if found otherwise null.

Parameters

Name Type Description
name string The name of the highlight layer to look for.

addExternalData(key, data) boolean

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

Parameters

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

getExternalData(key) Nullable<T>

Get an externaly attached data from its key

@return the associated data, if present (can be null), or undefined if not present

Parameters

Name Type Description
key string the unique key that identifies the data

getOrAddExternalDataWithFactory(key, factory) T

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.

Parameters

Name Type Description
key string the unique key that identifies the data
factory k string

removeExternalData(key) boolean

Remove an externaly attached data from the Engine instance

@return true if the data was successfully removed, false if it doesn't exist

Parameters

Name Type Description
key string the unique key that identifies the data

freezeActiveMeshes() Scene

Use this function to stop evaluating active meshes. The current list will be keep alive between frames

unfreezeActiveMeshes()

Use this function to restart evaluating active meshes on every frame

updateTransformMatrix(force) void

Parameters

Name Type Description
optional force boolean

updateAlternateTransformMatrix(alternateCamera) void

Parameters

Name Type Description
alternateCamera Camera

render() void

enableDepthRenderer() DepthRenderer

disableDepthRenderer() void

enableGeometryBufferRenderer(ratio) Nullable<GeometryBufferRenderer>

Parameters

Name Type Description
optional ratio number

disableGeometryBufferRenderer() void

freezeMaterials() void

unfreezeMaterials() void

dispose() void

disposeSounds() void

getWorldExtends() { min: Vector3, max: Vector3 }

createOrUpdateSelectionOctree(maxCapacity, maxDepth) Octree<AbstractMesh>

Parameters

Name Type Description
optional maxCapacity number
optional maxDepth number

createPickingRay(x, y, world, camera, cameraViewSpace) Ray

Parameters

Name Type Description
x number
y number
world Matrix
camera Nullable<Camera>

createPickingRayToRef(x, y, world, result, camera, cameraViewSpace) Scene

Parameters

Name Type Description
x number
y number
world Matrix
result Ray
camera Nullable<Camera>

createPickingRayInCameraSpace(x, y, camera) Ray

Parameters

Name Type Description
x number
y number
optional camera Camera

createPickingRayInCameraSpaceToRef(x, y, result, camera) Scene

Parameters

Name Type Description
x number
y number
result Ray

pick(x, y, predicate, fastCheck, camera) Nullable<PickingInfo>

Parameters

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.

pickSprite(x, y, predicate, fastCheck, camera) Nullable<PickingInfo>

Parameters

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.

pickWithRay(ray, predicate, fastCheck) Nullable<PickingInfo>

Parameters

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

multiPick(x, y, predicate, camera) Nullable<PickingInfo[]>

Launch a ray to try to pick a mesh in the scene

Parameters

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

multiPickWithRay(ray, predicate) Nullable<PickingInfo[]>

Launch a ray to try to pick a mesh in the scene

Parameters

Name Type Description
ray Ray Ray to use
predicate mesh AbstractMesh

setPointerOverMesh(mesh) void

Parameters

Name Type Description
mesh Nullable<AbstractMesh>

getPointerOverMesh() Nullable<AbstractMesh>

setPointerOverSprite(sprite) void

Parameters

Name Type Description
sprite Nullable<Sprite>

getPointerOverSprite() Nullable<Sprite>

getPhysicsEngine() Nullable<PhysicsEngine>

enablePhysics(gravity, plugin) boolean

Enables physics to the current scene

@return {boolean} was the physics engine initialized

Parameters

Name Type Description
optional gravity Nullable<Vector3>
optional plugin IPhysicsEnginePlugin

disablePhysicsEngine() void

isPhysicsEnabled() boolean

deleteCompoundImpostor(compound) void

Parameters

Name Type Description
compound any

createDefaultCameraOrLight(createArcRotateCamera, replace, attachCameraControls) void

Parameters

Name Type Description
optional createArcRotateCamera boolean
optional replace boolean
optional attachCameraControls boolean

createDefaultSkybox(environmentTexture, pbr, scale, blur) Nullable<Mesh>

Parameters

Name Type Description
optional environmentTexture BaseTexture
optional pbr boolean
optional scale number

createDefaultEnvironment(options) Nullable<EnvironmentHelper>

Parameters

Name Type Description
options Partial<IEnvironmentHelperOptions>

createDefaultVRExperience(webVROptions) VRExperienceHelper

Parameters

Name Type Description
optional webVROptions VRExperienceHelperOptions

getMeshesByTags(tagsQuery, forEach) Mesh[]

Parameters

Name Type Description
tagsQuery string
optional forEach mesh AbstractMesh

getCamerasByTags(tagsQuery, forEach) Camera[]

Parameters

Name Type Description
tagsQuery string
optional forEach camera Camera

getLightsByTags(tagsQuery, forEach) Light[]

Parameters

Name Type Description
tagsQuery string
optional forEach light Light

getMaterialByTags(tagsQuery, forEach) Material[]

Parameters

Name Type Description
tagsQuery string
optional forEach material Material

setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) void

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

Parameters

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.

setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil) void

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

Parameters

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.

markAllMaterialsAsDirty(flag, predicate) void

Will flag all materials as dirty to trigger new shader compilation

Parameters

Name Type Description
flag number
optional predicate mat Material