Skip to main content

Positioning Methods

setCoords
function
Places the object on the map at the given longitude, latitude, and altitude coordinates.Parameters:
  • lnglat (Array): Coordinates as [lng, lat] or [lng, lat, altitude] in meters
Returns: The object itself for method chaining
obj.setCoords([-122.4194, 37.7749, 100]);
setTranslate
function
Translates the object by the given offset coordinates.Parameters:
  • lnglat (Array): Translation offset as [lng, lat, altitude]
Returns: The object itself for method chaining
obj.setTranslate([0.001, 0.001, 10]);

Rotation Methods

setRotation
function
Sets the rotation of the object along the x, y, and z axes.Parameters:
  • xyz (Object | number): Rotation in degrees. Can be a number (applies to z-axis only) or object with {x, y, z} properties
// Rotate on z-axis only
obj.setRotation(45);

// Rotate on multiple axes
obj.setRotation({ x: 90, y: 0, z: 45 });
setRotationAxis
function
Rotates the object on an axis instead of around its center.Parameters:
  • xyz (Object | number): Rotation in degrees. Can be a number (applies to z-axis) or object with {x, y, z} properties
obj.setRotationAxis({ x: 0, y: 0, z: 90 });

Scale Methods

setScale
function
Sets the scale of the object based on units and fixedZoom settings.Parameters:
  • scale (number): Optional map scale value
obj.setScale();
setFixedZoom
function
Adjusts the object scale based on its fixedZoom property relative to map scale.Parameters:
  • scale (number): Optional map scale value. Uses obj.userData.mapScale if not provided
obj.setFixedZoom(mapScale);
setObjectScale
function
Sets the scale and updates shadow positions.Parameters:
  • scale (number): Map scale value
obj.setObjectScale(mapScale);

Anchor & Positioning Methods

setAnchor
function
Sets the positional and pivotal anchor point automatically from a string parameter.Parameters:
  • anchor (string): Anchor position - 'center', 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'auto', or 'none'
Default: 'bottom-left'
obj.setAnchor('center');
setCenter
function
Adjusts the center position based on size unit offsets.Parameters:
  • center (Object): Offset as {x, y, z} where each value represents a proportion of the object size
obj.setCenter({ x: 0.5, y: 0.5, z: 0 });
calculateAdjustedPosition
function
Calculates an adjusted position for the object accounting for model size and adjustment parameters.Parameters:
  • lnglat (Array): Base coordinates as [lng, lat, altitude]
  • xyz (Object): Adjustment factors as {x, y, z}
  • inverse (boolean): Whether to subtract (true) or add (false) the adjustment
Returns: Adjusted coordinates as [lng, lat, altitude]
const adjusted = obj.calculateAdjustedPosition(
  [-122.4194, 37.7749, 0],
  { x: 2, y: 2, z: 0 },
  false
);

Bounding Box Methods

drawBoundingBox
function
Creates wireframe bounding boxes for the object - one for the object itself and one projected on the ground.
obj.drawBoundingBox();
setBoundingBoxShadowFloor
function
Positions the shadow bounding box on the ground based on object height and rotation.
obj.setBoundingBoxShadowFloor();
box3
function
Gets the object’s bounding box in runtime.Returns: THREE.Box3 - The object’s bounding box
const bbox = obj.box3();
modelBox
function
Alias for box3(). Returns the object’s bounding box.Returns: THREE.Box3
const bbox = obj.modelBox();
getSize
function
Gets the size of the object’s bounding box.Returns: THREE.Vector3 - Size as vector with x, y, z dimensions
const size = obj.getSize();
console.log(size.x, size.y, size.z);

Label & Tooltip Methods

addLabel
function
Adds a CSS2D label to the object.Parameters:
  • HTMLElement (HTMLElement | string): HTML element or string to display
  • visible (boolean): Whether label is always visible. Default: false
  • center (Object): Position offset. Default: obj.anchor
  • height (number): Vertical position multiplier. Default: 0.5
obj.addLabel('<div>My Label</div>', true);
removeLabel
function
Removes the CSS2D label from the object.
obj.removeLabel();
drawLabelHTML
function
Creates and attaches a CSS2D HTML label to the object.Parameters:
  • HTMLElement (HTMLElement | string): HTML content
  • visible (boolean): Always visible flag. Default: false
  • center (Object): Position offset. Default: obj.anchor
  • height (number): Vertical position multiplier. Default: 0.5
Returns: The created CSS2DObject label
const label = obj.drawLabelHTML('<span>Label</span>', true, obj.center, 1);
addTooltip
function
Adds a tooltip to the object.Parameters:
  • tooltipText (string): Text to display in tooltip
  • mapboxStyle (boolean): Whether to use Mapbox styling. Default: false
  • center (Object): Position offset. Default: obj.anchor
  • custom (boolean): Whether tooltip is custom. Default: true
  • height (number): Vertical position multiplier. Default: 1
obj.addTooltip('Object info', true);
removeTooltip
function
Removes the tooltip from the object.
obj.removeTooltip();
addHelp
function
Adds a help element to the object.Parameters:
  • helpText (string): Help text to display
  • objName (string): Name for the CSS2D object. Default: 'help'
  • mapboxStyle (boolean): Use Mapbox styling. Default: false
  • center (Object): Position offset. Default: obj.anchor
  • height (number): Vertical position multiplier. Default: 0
Returns: The created CSS2DObject
const helpElement = obj.addHelp('Press SHIFT to move', 'help', false);
removeHelp
function
Removes the help element from the object.
obj.removeHelp();
addCSS2D
function
Adds a CSS2D element to the object.Parameters:
  • element (HTMLElement): DOM element to add
  • objName (string): Name for the CSS2D object
  • center (Object): Position offset. Default: obj.anchor
  • height (number): Vertical position multiplier. Default: 1
Returns: The created CSS2DObject
const div = document.createElement('div');
const css2d = obj.addCSS2D(div, 'customElement', obj.center, 0.5);
removeCSS2D
function
Removes a CSS2D element by name.Parameters:
  • objName (string): Name of the CSS2D object to remove
obj.removeCSS2D('customElement');

Shadow Methods

setReceiveShadowFloor
function
Positions the shadow plane on the ground based on object height and rotation.
obj.setReceiveShadowFloor();

Object Management Methods

add
function
Adds a child object to the scaleGroup.Parameters:
  • o (THREE.Object3D): Object to add
Returns: The added object
const child = new THREE.Mesh(geometry, material);
obj.add(child);
remove
function
Removes a child object and disposes its resources.Parameters:
  • o (THREE.Object3D): Object to remove
obj.remove(childObject);
duplicate
function
Creates a clone of the object with all attributes and methods.Parameters:
  • options (Object): Optional configuration to override cloned object properties
Returns: Duplicated Object3D instance
const clone = obj.duplicate();

// Duplicate with different scale
const scaled = obj.duplicate({ scale: { x: 2, y: 2, z: 2 } });
copyAnchor
function
Copies anchor values from another object.Parameters:
  • o (Object3D): Source object to copy anchors from
obj.copyAnchor(sourceObject);
dispose
function
Disposes the object and all its resources (geometries, materials, textures).
obj.dispose();

Build docs developers (and LLMs) love