Skip to main content

Class: RootScene<TCamera>

Core-API.RootScene

Type parameters​

NameType
TCameraextends CameraController = CameraController

Hierarchy​

Implements​

Properties​

isRootScene​

• isRootScene: boolean = true


assetType​

• assetType: "model"

Implementation of​

IScene.assetType


boxHelper​

• Readonly boxHelper: Box3Helper

For visualizing the scene bounds. API incomplete.


modelRoot​

• Readonly modelRoot: IModel<Group<Object3DEventMap>, IObject3DEventMap> & Group<Object3DEventMap>

The root object where all imported objects are added.

Implementation of​

IScene.modelRoot


defaultCamera​

• Readonly defaultCamera: TCamera

The default camera in the scene

Implementation of​

IScene.defaultCamera


envMapIntensity​

• envMapIntensity: number = 1

The intensity for the environment light.

Implementation of​

IScene.envMapIntensity


fixedEnvMapDirection​

• fixedEnvMapDirection: boolean = false

Fixed direction environment reflections irrespective of camera position.


backgroundIntensity​

• backgroundIntensity: number = 1

Overrides​

Scene.backgroundIntensity


deleteImportedViewerConfigOnLoad​

• deleteImportedViewerConfigOnLoad: boolean = true


autoDisposeSceneMaps​

• autoDisposeSceneMaps: boolean = true


environment​

• environment: null | Texture<TextureEventMap> = null

Overrides​

Scene.environment


textureSlots​

• textureSlots: Record<string, Texture<TextureEventMap>> = {}

Extra textures/envmaps that can be used by objects/materials/plugins and will be serialized. These can be set per material in material.userData.envMapSlotKey


background​

• background: null | Color | Texture<TextureEventMap> | "environment" = null

Overrides​

Scene.background


backgroundColor​

• backgroundColor: null | Color = null

Overrides​

Scene.backgroundColor


_stablePoses​

• Optional _stablePoses: { distance: number ; faceNormal: Vector3 ; area: number ; face: Face ; maxEdgeLength: number ; xform: Matrix4 ; edgePoint: Vector3 }[]

Inherited from​

Scene._stablePoses


_poseIndex​

• Optional _poseIndex: number

Inherited from​

Scene._poseIndex


_originalXform​

• Optional _originalXform: Matrix4

Inherited from​

Scene._originalXform

Accessors​

activeCamera​

• get activeCamera(): TCamera

The current active camera in the scene.

Returns​

TCamera

Implementation of​

IScene.activeCamera

• set activeCamera(camera): void

The current active camera in the scene.

Parameters​

NameType
cameraundefined | TCamera

Returns​

void

Implementation of​

IScene.activeCamera


renderCamera​

• get renderCamera(): ICamera<ICameraOptions, any, any>

Returns​

ICamera<ICameraOptions, any, any>

Implementation of​

IScene.renderCamera

• set renderCamera(camera): void

Parameters​

NameType
cameraICamera<ICameraOptions, any, any>

Returns​

void

Implementation of​

IScene.renderCamera


modelObject​

• get modelObject(): Scene<Object3DEventMap>

Get the threejs scene object

Returns​

Scene<Object3DEventMap>

Implementation of​

IScene.modelObject


minNearDistance​

• get minNearDistance(): number

Minimum Camera near plane

deprecated - use camera.userData.minNearPlane instead

Returns​

number

• set minNearDistance(value): void

Minimum Camera near plane

deprecated - use camera.userData.minNearPlane instead

Parameters​

NameType
valuenumber

Returns​

void

Constructors​

constructor​

• new RootScene<TCamera>(camera)

Create a scene instance. This is done automatically in the ViewerApp and must not be created separately.

Type parameters​

NameType
TCameraextends CameraController<CameraControllerEventMap, TCamera> = CameraController<CameraControllerEventMap>

Parameters​

NameType
cameraTCamera

Overrides​

Scene<ISceneEventMap\>.constructor

Methods​

addModel​

▸ addModel(model, options?): IModel<any, IObject3DEventMap>

Add a processed model to the scene.

Parameters​

NameType
modelIModel<Object3D<Object3DEventMap>, IObject3DEventMap>
optionsAddModelOptions

Returns​

IModel<any, IObject3DEventMap>

Implementation of​

IScene.addModel


addWidget​

▸ addWidget(model, options?): void

Add a widget (non-physical/interactive) object to the scene. like gizmos, ui components etc.

Parameters​

NameType
modelIWidget<any, IObject3DEventMap>
optionsAnyOptions

Returns​

void

Implementation of​

IScene.addWidget


addSceneObject​

▸ addSceneObject<T>(imported, options?): T

Add any processed scene object to the scene.

Type parameters​

NameType
Textends ISceneObject<any> = ISceneObject<any>

Parameters​

NameType
importedT
options?AddObjectOptions & AddModelOptions & { allImported?: any }

Returns​

T

Implementation of​

IScene.addSceneObject


removeSceneModels​

▸ removeSceneModels(): void

Returns​

void


disposeSceneModels​

▸ disposeSceneModels(): void

Returns​

void


add​

▸ add(...object): RootScene<TCamera>

deprecated Use addSceneObject

Parameters​

NameType
...objectObject3D<Object3DEventMap>[]

Returns​

RootScene<TCamera>

Overrides​

Scene.add


setEnvironment​

▸ setEnvironment(asset): void

Set the scene environment map, this will be processed with PMREM automatically later.

deprecated set the environment directly.

Parameters​

NameType
assetundefined | null | ITexture<any>

Returns​

void

Implementation of​

IScene.setEnvironment


getEnvironment​

▸ getEnvironment(): ITexture<Texture<TextureEventMap>>

Get the current scene environment map

deprecated get the environment directly.

Returns​

ITexture<Texture<TextureEventMap>>

Implementation of​

IScene.getEnvironment


setBackground​

▸ setBackground(asset): void

Set the scene background. To set a color use {@see setBackgroundColor} instead.

Parameters​

NameType
assetnull | string | number | ITexture<any> | Color

Returns​

void

Implementation of​

IScene.setBackground


setBackgroundColor​

▸ setBackgroundColor(color): void

Sets the backgroundColor property from a string, number or Color, and updates the scene.

Parameters​

NameType
colornull | string | number | Color

Returns​

void


getBackground​

▸ getBackground(): null | ITexture<any> | Color | Vector4

deprecated get the background directly.

Returns​

null | ITexture<any> | Color | Vector4

Implementation of​

IScene.getBackground


setDirty​

▸ setDirty(options?): RootScene<TCamera>

Mark the scene dirty, and force render in the next frame.

Parameters​

NameTypeDescription
options?{ sceneUpdate?: boolean } & AnyOptionsset sceneUpdate to true to mark that any object transformations have changed. It might trigger effects like frame fade depening on plugins.

Returns​

RootScene<TCamera>

Implementation of​

IScene.setDirty


updateScene​

▸ updateScene(options?): RootScene<TCamera>

Equivalent to setDirty({sceneUpdate: true}), dispatches 'sceneUpdate' event with the specified options.

Parameters​

NameType
options?AnyOptions

Returns​

RootScene<TCamera>


dispose​

▸ dispose(): void

Dispose the scene and clear all resources.

warn Not fully implemented yet, just clears the scene.

Returns​

void

Implementation of​

IScene.dispose


findObjectsByName​

▸ findObjectsByName(name, parent?): Object3D<Object3DEventMap> & IModel<Object3D<Object3DEventMap>, IObject3DEventMap>[]

Find objects by name exact match in the complete hierarchy.

Parameters​

NameTypeDescription
namestringname
parent?Object3D<Object3DEventMap>optional root node to start search from

Returns​

Object3D<Object3DEventMap> & IModel<Object3D<Object3DEventMap>, IObject3DEventMap>[]

Array of found objects

Implementation of​

IScene.findObjectsByName


addLight​

▸ addLight(light, options?): void

Add a processed light to the scene.

Parameters​

NameType
lightILight<any>
optionsAddObjectOptions

Returns​

void

Implementation of​

IScene.addLight


getBounds​

▸ getBounds(precise?, ignoreInvisible?, ignoreWidgets?, ignoreObject?): Box3B

Returns the bounding box of the scene. this includes the ground

Parameters​

NameTypeDefault value
precisebooleanfalse
ignoreInvisiblebooleantrue
ignoreWidgetsbooleantrue
ignoreObject?(obj: Object3D<Object3DEventMap>) => booleanundefined

Returns​

Box3B

Implementation of​

IScene.getBounds


getModelBounds​

▸ getModelBounds(precise?, ignoreInvisible?, ignoreWidgets?, ignoreObject?): Box3B

Returns the bounding box of the scene model root.

Parameters​

NameTypeDefault value
precisebooleanfalse
ignoreInvisiblebooleantrue
ignoreWidgetsbooleantrue
ignoreObject?(obj: Object3D<Object3DEventMap>) => booleanundefined

Returns​

Box3B


refreshActiveCameraNearFar​

▸ refreshActiveCameraNearFar(): void

Refreshes the scene active camera near far values, based on the scene bounding box. This is called automatically every time the camera is updated.

Returns​

void


updateShaderProperties​

▸ updateShaderProperties(material): RootScene<TCamera>

Parameters​

NameType
materialObject
material.definesRecord<string, undefined | string | number>
material.uniformsObject

Returns​

RootScene<TCamera>

Implementation of​

IScene.updateShaderProperties


toJSON​

▸ toJSON(meta?): any

Serialize the scene properties

Parameters​

NameType
meta?any

Returns​

any

Overrides​

Scene.toJSON


fromJSON​

▸ fromJSON(json, meta?): RootScene<TCamera>

Deserialize the scene properties

Parameters​

NameTypeDescription
jsonanyobject from toJSON
meta?any

Returns​

RootScene<TCamera>


_addModel​

▸ Protected _addModel(model, options?): void

Parameters​

NameType
modelIModel<any, IObject3DEventMap>
optionsAddObjectOptions & AddModelOptions

Returns​

void