Interface IScene<E, ET>

interface IScene<
    E extends ISceneEvent = ISceneEvent,
    ET extends ISceneEventTypes = ISceneEventTypes,
> {
    _currentGeometry?: null | IGeometry;
    _currentMaterial?: null | IMaterial | IMaterial[];
    _onGeometryUpdate?: (e: IGeometryEvent<"geometryUpdate">) => void;
    activeCamera: ICamera;
    assetType: "model" | "light" | "camera" | "widget";
    background: null | ITexture | Color | "environment";
    backgroundColor: null | Color;
    backgroundIntensity: number;
    children: IObject3D[];
    defaultCamera: ICamera;
    environment: null | ITexture;
    envMapIntensity: number;
    fixedEnvMapDirection: boolean;
    geometry?: IGeometry;
    isCamera?: boolean;
    isLight?: boolean;
    isLine?: boolean;
    isLineSegments?: boolean;
    isMesh?: boolean;
    isScene: true;
    isWidget?: boolean;
    mainCamera: ICamera;
    material?: IMaterial | IMaterial[];
    materials?: IMaterial[];
    modelObject: IScene<E, ET>;
    modelRoot: IObject3D;
    morphTargetDictionary?: Record<string, number>;
    morphTargetInfluences?: number[];
    objectProcessor?: IObjectProcessor;
    parent: null | IObject3D;
    parentRoot?: null | IObject3D;
    renderCamera: ICamera;
    type: "Scene";
    uiConfig?: UiObjectConfig;
    userData: IObject3DUserData;
    visible: boolean;
    add(...object: IObject3D[]): this;
    addObject<T extends IObject3D>(
        imported: T,
        options?: AddObjectOptions,
    ): T & IObject3D;
    autoCenter(setDirty?: boolean, undo?: boolean): this;
    autoScale(
        autoScaleRadius?: number,
        isCentered?: boolean,
        setDirty?: boolean,
        undo?: boolean,
    ): this;
    clone(recursive?: boolean): this;
    copy(source: this, recursive?: boolean): this;
    dispose(removeFromParent?: boolean): void;
    findObjectsByName(name: string, parent?: any): any[];
    getBounds(precise?: boolean, ignoreInvisible?: boolean): Box3B;
    getObjectById<T extends IObject3D = IObject3D>(id: number): undefined | T;
    getObjectByName<T extends IObject3D = IObject3D>(
        name: string,
    ): undefined | T;
    getObjectByProperty<T extends IObject3D = IObject3D>(
        name: string,
        value: string,
    ): undefined | T;
    pivotToBoundsCenter(setDirty?: boolean): () => void;
    pivotToPoint(point: Vector3, setDirty?: boolean): this;
    refreshUi(): void;
    remove(...object: IObject3D[]): this;
    setDirty(e?: IObjectSetDirtyOptions): void;
    toJSON(): any;
    traverse(callback: (object: IObject3D) => void): void;
    traverseAncestors(callback: (object: IObject3D) => void): void;
    traverseVisible(callback: (object: IObject3D) => void): void;
    updateMorphTargets(): void;
    updateShaderProperties(
        material: {
            defines: Record<string, undefined | string | number>;
            uniforms: { [name: string]: IUniform };
        },
    ): this;
}

Type Parameters

Hierarchy (View Summary)

Implemented by

Properties

_currentGeometry?: null | IGeometry
_currentMaterial?: null | IMaterial | IMaterial[]
_onGeometryUpdate?: (e: IGeometryEvent<"geometryUpdate">) => void
activeCamera: ICamera

renamed to mainCamera

assetType: "model" | "light" | "camera" | "widget"
background: null | ITexture | Color | "environment"

Defines the background of the scene.

Valid inputs are:

  • A Color for defining a uniform colored background.
  • A Texture for defining a (flat) textured background.
  • Texture cubes (CubeTexture) or equirectangular textures for defining a skybox.
  • A value 'environment' will force the background to be same as environment.

null

backgroundColor: null | Color

Custom property for background tint, or just background color rendered in the shader

backgroundIntensity: number

Attenuates the color of the background. Only applies to background textures.

1

Expects a Float

children: IObject3D[]

Array with object's children.

THREE.Object3DGroup | Group for info on manually grouping objects.

[]

defaultCamera: ICamera
environment: null | ITexture

Sets the environment map for all physical materials in the scene. However, it's not possible to overwrite an existing texture assigned to MeshStandardMaterial.envMap.

null

envMapIntensity: number
fixedEnvMapDirection: boolean
geometry?: IGeometry
isCamera?: boolean
isLight?: boolean
isLine?: boolean
isLineSegments?: boolean
isMesh?: boolean
isScene: true

Read-only flag to check if a given object is of type Scene.

This is a constant value

true

isWidget?: boolean
mainCamera: ICamera

Main camera that the user controls

material?: IMaterial | IMaterial[]
materials?: IMaterial[]

Same as material but always returns an array. To set, just set material property

modelObject: IScene<E, ET>

use object directly

modelRoot: IObject3D
morphTargetDictionary?: Record<string, number>
morphTargetInfluences?: number[]
objectProcessor?: IObjectProcessor
parent: null | IObject3D

Object's parent in the scene graph.

An object can have at most one parent.

null

parentRoot?: null | IObject3D

Parent/Ancestor of this object to bubble events to. This is set internally by setupObject3D.

renderCamera: ICamera

Camera that in currently being rendered.

type: "Scene"

Scene

uiConfig?: UiObjectConfig

An object that can be used to store custom data about the Object3D.

It should not hold references to functions as these will not be cloned.

{}

visible: boolean

Object gets rendered if true.

true

Methods

  • Moves the bounding box center of the object to the center of the world

    Parameters

    • OptionalsetDirty: boolean

      calls setDirty

    • Optionalundo: boolean

      undo any previous autoCenter operation

    Returns this

    true
    
  • Scales the object to fit the given radius.

    Parameters

    • OptionalautoScaleRadius: number

      optional (taken from userData.autoScaleRadius by default)

    • OptionalisCentered: boolean

      optional (taken from userData.isCentered by default)

    • OptionalsetDirty: boolean

      true by default

    • Optionalundo: boolean

      undo any previous autoScale operation

    Returns this

  • Returns a clone of this object and optionally all descendants.

    Parameters

    • Optionalrecursive: boolean

      If true, descendants of the object are also cloned. Default true

    Returns this

  • Copy the given object into this object

    Parameters

    • source: this
    • Optionalrecursive: boolean

      If true, descendants of the object are also copied. Default true

    Returns this

    Note: event listeners and user-defined callbacks (.onAfterRender and .onBeforeRender) are not copied.

  • Parameters

    • OptionalremoveFromParent: boolean

      remove from parent. Default true

    Returns void

  • Parameters

    • Optionalprecise: boolean
    • OptionalignoreInvisible: boolean

    Returns Box3B

  • Searches through an object and its children, starting with the object itself, and returns the first with a matching id.

    Type Parameters

    Parameters

    • id: number

      Unique number of the object instance. Expects a Integer

    Returns undefined | T

    Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.

    id

  • Searches through an object and its children, starting with the object itself, and returns the first with a property that matches the value given.

    Type Parameters

    Parameters

    • name: string

      the property name to search for.

    • value: string

      value of the given property.

    Returns undefined | T

  • Moves the object pivot to the center of the bounding box.

    The object will rotate around the new pivot.

    Parameters

    • OptionalsetDirty: boolean

      calls setDirty

    Returns () => void

    undo function

    true
    
  • Moves the object pivot to the given point

    The object will rotate around the new pivot.

    Parameters

    • point: Vector3

      point to move the pivot to

    • OptionalsetDirty: boolean

      calls setDirty

    Returns this

    undo function

    true
    
  • Executes the callback on this object and all descendants.

    Parameters

    • callback: (object: IObject3D) => void

      A function with as first argument an Object3D object.

    Returns void

    Note: Modifying the scene graph inside the callback is discouraged.

  • Like traverse, but the callback will only be executed for visible objects

    Parameters

    • callback: (object: IObject3D) => void

      A function with as first argument an Object3D object.

    Returns void

    Descendants of invisible objects are not traversed.