Overview
The GLTF/GLB loader enables you to load 3D models in the GLTF (GL Transmission Format) or GLB (binary GLTF) format. This format supports animations, skeletal animations, and PBR (Physically Based Rendering) materials.Usage
Parameters
Loader type. Use
'gltf' for GLTF files or 'glb' for binary GLB files.URL or path to the GLTF/GLB model file.
Units for the model scale. Options:
'scene'- Scene units (default)'meters'- Meters
Scale factor for the model. Can be:
- A single number:
1(uniform scale) - An array:
[x, y, z]for per-axis scaling
scale: [2, 2, 2] or scale: 2Rotation for the model in degrees. Can be:
- A single number:
90(rotation around Y axis) - An object:
{ x: 90, y: 0, z: 0 } - An array:
[90, 0, 0](X, Y, Z rotation)
Anchor point for the model positioning. Options:
'center'- Center of the model'bottom-left'- Bottom-left corner'bottom-right'- Bottom-right corner'top-left'- Top-left corner'top-right'- Top-right corner'bottom-center'- Bottom center'top-center'- Top center'left'- Left center'right'- Right center
Manual adjustment to override the automatic center calculation.Example:
{ x: 0, y: 0, z: 0 }Normalize specular, metalness, and shininess properties for better rendering in Mapbox.GLTF/GLB models may have high specular values that require many lights. Setting this to
true reduces metalness and glossiness by 90% and 75% respectively.Index of the default animation to play from the model’s animation array.
Whether the model should be included in raycasting for mouse interactions.
Whether to calculate and display a bounding box for the model.
Whether to enable tooltips for the model.
Whether to clone the model when adding multiple instances.
Whether to send cookies and authorization headers with cross-origin requests.
Callback
The callback function receives the loaded model object with the following properties:Model Structure
GLTF/GLB models are loaded with the following structure:- The
sceneproperty becomes the root object animationsarray is preserved and accessible viamodel.animations- All child meshes and materials are included
- Skeletal animations are supported
/home/daytona/workspace/source/src/objects/loadObj.js:71-74:
Normalization
GLTF/GLB models often have high specular values that may appear too shiny in Mapbox. Use thenormalize option to reduce these values:
- Metalness by 90% (multiply by 0.1)
- Glossiness by 75% (multiply by 0.25)
- Sets specular color to
(12, 12, 12)for MeshStandardMaterial - Sets shininess to 0.1 for MeshPhongMaterial