Class: RootScene<TCamera>
Core-API.RootScene
Type parameters
| Name | Type |
|---|---|
TCamera | extends CameraController = CameraController |
Hierarchy
Scene<ISceneEventMap>↳
RootScene
Implements
IScene<Scene,TCamera,ISceneEventMap>
Properties
isRootScene
• isRootScene: boolean = true
assetType
• assetType: "model"
Implementation of
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
defaultCamera
• Readonly defaultCamera: TCamera
The default camera in the scene
Implementation of
envMapIntensity
• envMapIntensity: number = 1
The intensity for the environment light.
Implementation of
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
• set activeCamera(camera): void
The current active camera in the scene.
Parameters
| Name | Type |
|---|---|
camera | undefined | TCamera |
Returns
void
Implementation of
renderCamera
• get renderCamera(): ICamera<ICameraOptions, any, any>
Returns
ICamera<ICameraOptions, any, any>
Implementation of
• set renderCamera(camera): void
Parameters
| Name | Type |
|---|---|
camera | ICamera<ICameraOptions, any, any> |
Returns
void
Implementation of
modelObject
• get modelObject(): Scene<Object3DEventMap>
Get the threejs scene object
Returns
Scene<Object3DEventMap>
Implementation of
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
| Name | Type |
|---|---|
value | number |
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
| Name | Type |
|---|---|
TCamera | extends CameraController<CameraControllerEventMap, TCamera> = CameraController<CameraControllerEventMap> |
Parameters
| Name | Type |
|---|---|
camera | TCamera |
Overrides
Scene<ISceneEventMap\>.constructor
Methods
addModel
▸ addModel(model, options?): IModel<any, IObject3DEventMap>
Add a processed model to the scene.
Parameters
| Name | Type |
|---|---|
model | IModel<Object3D<Object3DEventMap>, IObject3DEventMap> |
options | AddModelOptions |
Returns
IModel<any, IObject3DEventMap>
Implementation of
addWidget
▸ addWidget(model, options?): void
Add a widget (non-physical/interactive) object to the scene. like gizmos, ui components etc.
Parameters
| Name | Type |
|---|---|
model | IWidget<any, IObject3DEventMap> |
options | AnyOptions |
Returns
void
Implementation of
addSceneObject
▸ addSceneObject<T>(imported, options?): T
Add any processed scene object to the scene.
Type parameters
| Name | Type |
|---|---|
T | extends ISceneObject<any> = ISceneObject<any> |
Parameters
| Name | Type |
|---|---|
imported | T |
options? | AddObjectOptions & AddModelOptions & { allImported?: any } |
Returns
T
Implementation of
removeSceneModels
▸ removeSceneModels(): void
Returns
void
disposeSceneModels
▸ disposeSceneModels(): void
Returns
void
add
▸ add(...object): RootScene<TCamera>
deprecated Use addSceneObject
Parameters
| Name | Type |
|---|---|
...object | Object3D<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
| Name | Type |
|---|---|
asset | undefined | null | ITexture<any> |
Returns
void
Implementation of
getEnvironment
▸ getEnvironment(): ITexture<Texture<TextureEventMap>>
Get the current scene environment map
deprecated get the environment directly.
Returns
ITexture<Texture<TextureEventMap>>
Implementation of
setBackground
▸ setBackground(asset): void
Set the scene background. To set a color use {@see setBackgroundColor} instead.
Parameters
| Name | Type |
|---|---|
asset | null | string | number | ITexture<any> | Color |
Returns
void
Implementation of
setBackgroundColor
▸ setBackgroundColor(color): void
Sets the backgroundColor property from a string, number or Color, and updates the scene.
Parameters
| Name | Type |
|---|---|
color | null | 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
setDirty
▸ setDirty(options?): RootScene<TCamera>
Mark the scene dirty, and force render in the next frame.
Parameters
| Name | Type | Description |
|---|---|---|
options? | { sceneUpdate?: boolean } & AnyOptions | set 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
updateScene
▸ updateScene(options?): RootScene<TCamera>
Equivalent to setDirty({sceneUpdate: true}), dispatches 'sceneUpdate' event with the specified options.
Parameters
| Name | Type |
|---|---|
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
| Name | Type | Description |
|---|---|---|
name | string | name |
parent? | Object3D<Object3DEventMap> | optional root node to start search from |
Returns
Object3D<Object3DEventMap> & IModel<Object3D<Object3DEventMap>, IObject3DEventMap>[]
Array of found objects
Implementation of
addLight
▸ addLight(light, options?): void
Add a processed light to the scene.
Parameters
| Name | Type |
|---|---|
light | ILight<any> |
options | AddObjectOptions |
Returns
void
Implementation of
getBounds
▸ getBounds(precise?, ignoreInvisible?, ignoreWidgets?, ignoreObject?): Box3B
Returns the bounding box of the scene. this includes the ground
Parameters
| Name | Type | Default value |
|---|---|---|
precise | boolean | false |
ignoreInvisible | boolean | true |
ignoreWidgets | boolean | true |
ignoreObject? | (obj: Object3D<Object3DEventMap>) => boolean | undefined |
Returns
Implementation of
getModelBounds
▸ getModelBounds(precise?, ignoreInvisible?, ignoreWidgets?, ignoreObject?): Box3B
Returns the bounding box of the scene model root.
Parameters
| Name | Type | Default value |
|---|---|---|
precise | boolean | false |
ignoreInvisible | boolean | true |
ignoreWidgets | boolean | true |
ignoreObject? | (obj: Object3D<Object3DEventMap>) => boolean | undefined |
Returns
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
| Name | Type |
|---|---|
material | Object |
material.defines | Record<string, undefined | string | number> |
material.uniforms | Object |
Returns
RootScene<TCamera>
Implementation of
toJSON
▸ toJSON(meta?): any
Serialize the scene properties
Parameters
| Name | Type |
|---|---|
meta? | any |
Returns
any
Overrides
Scene.toJSON
fromJSON
▸ fromJSON(json, meta?): RootScene<TCamera>
Deserialize the scene properties
Parameters
| Name | Type | Description |
|---|---|---|
json | any | object from toJSON |
meta? | any |
Returns
RootScene<TCamera>
_addModel
▸ Protected _addModel(model, options?): void
Parameters
| Name | Type |
|---|---|
model | IModel<any, IObject3DEventMap> |
options | AddObjectOptions & AddModelOptions |
Returns
void