Capítulo 630 de 859

Chapter 630: XRControllerModelFactory

Core Idea

Allows to create controller models for WebXR controllers that can be added as a visual representation to your scene. XRControllerModelFactory will automatically fetch controller models that match what the user is holding as closely as possible. The models should be attached to the object returned from getControllerGrip in order to match the orientation of the held device.

This module depends on the motion-controllers third-part library.

Key Concepts

  • gltfLoader : GLTFLoader: A glTF loader that is used to load controller models.
  • onLoad : function: A callback that is executed when a controller model has been loaded.
  • path : string: The path to the model repository.

Code Examples

const controllerModelFactory = new XRControllerModelFactory();
const controllerGrip = renderer.xr.getControllerGrip( 0 );
controllerGrip.add( controllerModelFactory.createControllerModel( controllerGrip ) );
scene.add( controllerGrip );
  • What it demonstrates: Typical usage of XRControllerModelFactory.

Reference Tables

Constructor

Signature
new XRControllerModelFactory( gltfLoader : GLTFLoader, onLoad : function )

Properties

PropertyDescription
.gltfLoader : GLTFLoaderA glTF loader that is used to load controller models.
.onLoad : functionA callback that is executed when a controller model has been loaded.
.path : stringThe path to the model repository.

Methods

MethodDescription
.createControllerModel( controller : Group ) : XRControllerModelCreates a controller model for the given WebXR controller.
.setPath( path : string ) : XRControllerModelFactorySets the path to the model repository.

Key Takeaways

  1. Most relevant properties: gltfLoader, onLoad, path.
  2. Key methods: createControllerModel, setPath.

Connects To