Class SplatModel
Hierarchy (View Summary)
- Evented<SplatModelEvent>
- SplatModel
Index
Constructors
Properties
Methods
Constructors
constructor
Creates a new SplatModel instance.
Parameters
- options: SplatModelOptions
The options for the SplatModel.
Returns SplatModel
- options: SplatModelOptions
Methods
fit
Moves the camera such that the model is centered in the viewport. Sets pitch to 60 degrees while keeping current yaw.
Parameters
- cameraParams: CameraParams | null = null
Returns LngLat | null
The center of the SplatModel as LngLat, or null if not initialized.
getAltitude
Returns the current altitude of the model in meters.
Returns number
The altitude in meters, or NaN if not initialized.
getCenter
Returns the current center of the model as LngLat.
Returns LngLat | null
The center position, or null if not available.
getModel
Returns the model identifier (URL or UUID).
Returns string
The model string.
getOptions
Returns the options used to create this SplatModel.
Returns SplatModelOptions
The SplatModel options.
getRotationDegrees
Returns the current rotation of the model in degrees.
Returns SplatModelRotationDegree | null
The rotation object { xRot, yRot, zRot }, or null if not initialized.
getScale
Returns the model's scale.
Returns number
The scale factor, or NaN if not initialized.
hide
Hides the SplatModel, disables listeners, and sets opacity to 0.
Returns void
off
- off<
EventType extends
| "load"
| "error"
| "remove"
| "update"
| "mouseover"
| "mouseout"
| "click"
| "dragstart"
| "dragend",
>(
eventType: EventType,
handler: (
event:
| Extract<SplatModelLoadEvent, { type: EventType }>
| Extract<SplatModelErrorEvent, { type: EventType }>
| Extract<SplatModelRemoveEvent, { type: EventType }>
| Extract<SplatModelUpdateEvent, { type: EventType }>
| Extract<SplatModelMouseOverEvent, { type: EventType }>
| Extract<SplatModelMouseOutEvent, { type: EventType }>
| Extract<SplatModelClickEvent, { type: EventType }>
| Extract<SplatModelDragStartEvent, { type: EventType }>
| Extract<SplatModelDragEndEvent, { type: EventType }>,
) => void,
): voidRemoves a listener for a specific event type.
Type Parameters
- EventType extends
| "load"
| "error"
| "remove"
| "update"
| "mouseover"
| "mouseout"
| "click"
| "dragstart"
| "dragend"
Parameters
- eventType: EventType
The type of event to remove the listener from.
- handler: (
event:
| Extract<SplatModelLoadEvent, { type: EventType }>
| Extract<SplatModelErrorEvent, { type: EventType }>
| Extract<SplatModelRemoveEvent, { type: EventType }>
| Extract<SplatModelUpdateEvent, { type: EventType }>
| Extract<SplatModelMouseOverEvent, { type: EventType }>
| Extract<SplatModelMouseOutEvent, { type: EventType }>
| Extract<SplatModelClickEvent, { type: EventType }>
| Extract<SplatModelDragStartEvent, { type: EventType }>
| Extract<SplatModelDragEndEvent, { type: EventType }>,
) => voidThe listener function to remove.
Returns void
- EventType extends
on
- on<
EventType extends
| "load"
| "error"
| "remove"
| "update"
| "mouseover"
| "mouseout"
| "click"
| "dragstart"
| "dragend",
>(
eventType: EventType,
handler: (
event:
| Extract<SplatModelLoadEvent, { type: EventType }>
| Extract<SplatModelErrorEvent, { type: EventType }>
| Extract<SplatModelRemoveEvent, { type: EventType }>
| Extract<SplatModelUpdateEvent, { type: EventType }>
| Extract<SplatModelMouseOverEvent, { type: EventType }>
| Extract<SplatModelMouseOutEvent, { type: EventType }>
| Extract<SplatModelClickEvent, { type: EventType }>
| Extract<SplatModelDragStartEvent, { type: EventType }>
| Extract<SplatModelDragEndEvent, { type: EventType }>,
) => void,
): voidAdds a listener for a specific event type.
Type Parameters
- EventType extends
| "load"
| "error"
| "remove"
| "update"
| "mouseover"
| "mouseout"
| "click"
| "dragstart"
| "dragend"
Parameters
- eventType: EventType
The type of event to listen for.
- handler: (
event:
| Extract<SplatModelLoadEvent, { type: EventType }>
| Extract<SplatModelErrorEvent, { type: EventType }>
| Extract<SplatModelRemoveEvent, { type: EventType }>
| Extract<SplatModelUpdateEvent, { type: EventType }>
| Extract<SplatModelMouseOverEvent, { type: EventType }>
| Extract<SplatModelMouseOutEvent, { type: EventType }>
| Extract<SplatModelClickEvent, { type: EventType }>
| Extract<SplatModelDragStartEvent, { type: EventType }>
| Extract<SplatModelDragEndEvent, { type: EventType }>,
) => voidThe function to call when the event is fired.
Returns void
- EventType extends
once
- once<
EventType extends
| "load"
| "error"
| "remove"
| "update"
| "mouseover"
| "mouseout"
| "click"
| "dragstart"
| "dragend",
>(
eventType: EventType,
handler: (
event:
| Extract<SplatModelLoadEvent, { type: EventType }>
| Extract<SplatModelErrorEvent, { type: EventType }>
| Extract<SplatModelRemoveEvent, { type: EventType }>
| Extract<SplatModelUpdateEvent, { type: EventType }>
| Extract<SplatModelMouseOverEvent, { type: EventType }>
| Extract<SplatModelMouseOutEvent, { type: EventType }>
| Extract<SplatModelClickEvent, { type: EventType }>
| Extract<SplatModelDragStartEvent, { type: EventType }>
| Extract<SplatModelDragEndEvent, { type: EventType }>,
) => void,
): voidAdds a listener for a specific event type that will be called only once.
Type Parameters
- EventType extends
| "load"
| "error"
| "remove"
| "update"
| "mouseover"
| "mouseout"
| "click"
| "dragstart"
| "dragend"
Parameters
- eventType: EventType
The type of event to listen for.
- handler: (
event:
| Extract<SplatModelLoadEvent, { type: EventType }>
| Extract<SplatModelErrorEvent, { type: EventType }>
| Extract<SplatModelRemoveEvent, { type: EventType }>
| Extract<SplatModelUpdateEvent, { type: EventType }>
| Extract<SplatModelMouseOverEvent, { type: EventType }>
| Extract<SplatModelMouseOutEvent, { type: EventType }>
| Extract<SplatModelClickEvent, { type: EventType }>
| Extract<SplatModelDragStartEvent, { type: EventType }>
| Extract<SplatModelDragEndEvent, { type: EventType }>,
) => voidThe function to call when the event is fired.
Returns void
- EventType extends
setAltitude
Sets the altitude of the model in meters.
Parameters
- altitude: number
The new altitude in meters.
Returns void
- altitude: number
setBoundingBox
Sets the visibility and color of the model's bounding box.
Parameters
- visible: boolean
Whether the bounding box should be visible.
- color: Color | null = null
The color of the bounding box. Can be a string ("red", "#ff0000"), RGB(A) array, or object.
Returns void
- visible: boolean
setCenter
setDraggable
Sets whether the model is draggable.
Parameters
- draggable: boolean
Whether the model should be draggable.
Returns void
- draggable: boolean
setOpacity
Sets the opacity of the model.
Parameters
- opacity: number
The new opacity value (clamped between 0 and 1).
Returns void
- opacity: number
setRotationDegree
Sets the rotation of the model in degrees.
Parameters
- splatModelRotationDegree: SplatModelRotationDegree
The new rotation object { xRot, yRot, zRot }.
Returns void
- splatModelRotationDegree: SplatModelRotationDegree
setScale
Sets the scale of the model.
Parameters
- scale: number
The new scale factor.
Returns void
- scale: number
show
Shows the SplatModel and re-enables listeners.
Returns void
snapToTerrain
Snaps the model to the terrain and returns the new altitude.
Parameters
- callback: (elevation: number) => void
Function called with the snapped elevation.
Returns number
- callback: (elevation: number) => void
Represents a photorealistic 3D visualization (SplatModel) that can be positioned on the map.