glTF scene.

At the opposite of Scene, glTF scenes can be instantiated in other scenes but can’t:

  • Be activated
  • Be the destination of an instantiation


1const prefab = await engine.loadGLTF('Zombie.glb');
3const scene = engine.scene;
4for (let i = 0; i < 100; ++i) {
5    scene.instantiate(prefab);

Since this class inherits from Prefab, you can use the shared API to modify the glTF before an instantiation:

 1const prefab = await engine.loadGLTF('Zombie.glb');
 2const zombie = prefab.findByName('Zombie')[0];
 4// The mesh is too small, we scale the root
 5zombie.setScalingWorld([2, 2, 2]);
 6// Add a custom js 'health' component to the root
 7zombie.addComponent('health', {value: 100});
 9// 'Zombie' is wrapped in a new root added during instantiation
10const {root} = engine.scene.instantiate(prefab);
11const instanceZombie = root.children[0];
12console.log(instanceZombie.getScalingWorld()); // Prints '[2, 2, 2]'

.extensions: null | GLTFExtensions 

Raw extensions read from the glTF file.

The extensions will be mapped to the hierarchy upon instantiation. For more information, have a look at the InstantiateGltfResult type.

Note: The glTF must be loaded with extensions enabled. If not, this field will be set to null. For more information, have a look at the GLTFOptions type.