Scene | Matterport SDK
Usage of the SDK constitutes your agreement with the Matterport SDK Agreement. Email developers@matterport.com with any questions.

The Scene namespace is currently only available for Bundle SDK distributions. Learn more about the Bundle SDK

Index

Types

EmitPathDescriptor

EmitPathDescriptor: object

A descriptor for an emit component property contained by a scene object.

Type declaration

  • component: Scene.IComponent

    The component with the property.

  • id: string

    The user defined id of the path. This id must be a unique string for the scene object.

  • node: Scene.INode

    The parent scene node of the component.

  • property: string

    The property name of the component.

  • type: Scene.PathType.EMIT

    The type of the path: PathType.EMIT

EventPathDescriptor

EventPathDescriptor: object

A descriptor for an event component property contained by a scene object.

Type declaration

  • component: Scene.IComponent

    The component with the property.

  • id: string

    The user defined id of the path. This id must be a unique string for the scene object.

  • node: Scene.INode

    The parent scene node of the component.

  • property: string

    The property name of the component.

  • type: Scene.PathType.EVENT

    The type of the path: PathType.EVENT

InputPathDescriptor

InputPathDescriptor: object

A descriptor for an input component property contained by a scene object.

Type declaration

  • component: Scene.IComponent

    The component with the property.

  • id: string

    The user defined id of the path. This id must be a unique string for the scene object.

  • node: Scene.INode

    The parent scene node of the component.

  • property: string

    The property name of the component.

  • type: Scene.PathType.INPUT

    The type of the path: PathType.INPUT

InteractionEvent

InteractionEvent: object

The payload for a 3D interaction event.

Type declaration

  • collider: Object3D
  • Optional hover?: undefined | false | true
  • input: unknown
  • normal: Vector3 | null
  • point: Vector3 | null

OutputPathDescriptor

OutputPathDescriptor: object

A descriptor for an output component property contained by a scene object.

Type declaration

  • component: Scene.IComponent

    The component with the property.

  • id: string

    The user defined id of the path. This id must be a unique string for the scene object.

  • node: Scene.INode

    The parent scene node of the component.

  • property: string

    The property name of the component.

  • type: Scene.PathType.OUTPUT

    The type of the path: PathType.OUTPUT

PredefinedOutputs

PredefinedOutputs: object

Type declaration

  • collider: Object3D | null

    Set this to any Object3D and it will be interactable. See IComponent.onEvent

  • objectRoot: Object3D | null

    Set this to any Object3D and it will be added to the scene.

SceneComponentName

SceneComponentName: "mp.objLoader" | "mp.fbxLoader" | "mp.daeLoader" | "mp.gltfLoader" | "mp.scrollingTube" | "mp.transformControls" | "mp.lights" | "mp.pointLight" | "mp.directionalLight" | "mp.ambientLight" | "mp.camera" | "mp.input" | "mp.xr" | string & object

Methods

configure

  • configure(callback: function): Promise<void>
  • bundle

    This is a convenience function that provides access to three.js framework objects. Typically used to configure global properties on the renderer or effect composer.

    await sdk.Scene.configure(function(renderer, three, effectComposer){
      // configure PBR
      renderer.physicallyCorrectLights = true;
    
      // configure shadow mapping
      renderer.shadowMap.enabled = true;
      renderer.shadowMap.bias = 0.0001;
      renderer.shadowMap.type = three.PCFSoftShadowMap;
    
      if (effectComposer) {
        // add a custom pass here
      }
    });
    

    Parameters

    • callback: function
        • (renderer: WebGLRenderer, three: typeof THREE, effectComposer: EffectComposer | null): void
        • Parameters

          • renderer: WebGLRenderer

            Matterport's WebGLRenderer object.

          • three: typeof THREE

            three.js module.

          • effectComposer: EffectComposer | null

            Matterport's EffectComposer object. This value can be null. To enable the effect composer, you must set useEffectComposer: 1 in your application config. Please note that enabling effect composer disables renderer.antialias (&aa=1)

          Returns void

    Returns Promise<void>

createNode

  • bundle
    deprecated

    Use createObjects to create an object to then create nodes instead.

    Creates a scene node.

    Returns Promise<Scene.INode>

    A promise that resolves with the new scene node.

createNodes

  • bundle
    deprecated

    Use createObjects to create an object to then create nodes instead.

    Creates an array of scene nodes.

    Parameters

    • count: number

      The number of scene nodes to create.

    Returns Promise<Scene.INode[]>

    A promise that resolves with the array of scene nodes.

createObjects

  • bundle

    Creates an array of scene objects.

    Parameters

    • count: number

      The number of scene objects to create.

    Returns Promise<Scene.IObject[]>

    A promise that resolves with the array of scene objects.

    // create a single object and destructure it from the returned array
    const [sceneObject] = await sdk.Scene.createObjects(1);
    const node = sceneObject.createNode();
    // ...
    

deserialize

  • bundle

    This function returns a scene object with all of its scene nodes from a serialized scene. The returned scene object has not been started yet.

    Parameters

    • text: string

      The serialized scene.

    Returns Promise<Scene.IObject>

    A promise that resolves with a scene object.

register

  • register(name: string, factory: function): Promise<IDisposable | null>
  • bundle

    Register a component factory.

    Parameters

    • name: string

      A unique component name.

    • factory: function

      A function that returns a new instance of the component.

    Returns Promise<IDisposable | null>

    a disposable that can be used to unregister the component.

registerComponents

  • bundle

    Register an array of component factories all at once and return an array of disposables. Calling dispose on any of the returned disposables, unregisters the component.

    function myComponent1Factory() {
       return new MyComponent1();
    }
    
    function myComponent2Factory() {
       return new MyComponent2();
    }
    
    const disposables = await sdk.Scene.registerComponents([
      {
        name: 'myComponent1',
        factory: myComponent1Factory,
      },
      {
        name: 'myComponent2',
        factory: myComponent2Factory,
      },
    ]);
    
    // when you are done with the components, you can unregister the components by calling dispose on each item in the return result.
    for (const disposable of disposables) {
      disposable.dispose();
    }
    

    Parameters

    Returns Promise<IDisposable[] | null>

    an array of disposables that unregister the components when disposed.

serialize

  • bundle

    Serialize a scene object, its nodes, and their components to a string.

    Parameters

    Returns Promise<string>

    A promise that resolves with the serialized string.

  • bundle
    deprecated

    Prefer to serialize an array of Scene.INode through their containing Scene.IObject instead.

    This function serializes an array of scene nodes and their components to a string. This function is only provided to provide an upgrade path from nodes that were created before the introduction of IObjects.

    Parameters

    Returns Promise<string>

    A promise that resolves with the serialized string.

unregisterComponents