Methods¶
The 270 Annotations plugin adds the following methods to the Viewer. These are available after the Viewer is done initialising, ie on onLoadComplete().
Annotation methods are accessible via the Annotations namespace, for example: el.Annotations.getPins().
addPin¶
Adds a pin at the passed point in 3D space. x (horizontal), y (vertical) and z (depth) coordinates are in meters from the center of the model.
The pin's label contents will be wrapped in div.TSD-pin-label.
el.Annotations.addPin({name:'pin1', class: 'highlight', content: 'A point' , x: 1.2, y: 0.4, z: -0.3, debug: false, render: true});
Parameters:
- name:
- Type:
string - Default:
pin
The name of the Pin. This is also used as the element'sid, sanitised. In case of a duplicate, the name will be suffixed with the next available number.
- Type:
- class:
- Type:
string - Default:
pin
Optional classnames for the Pin's HTML elementTSD-pin-container.
- Type:
- content:
- Type:
string|HTMLElement
The content of the Pin label. This can be a a text string, inline html or an HTMLElement.
- Type:
- x:
- Type:
Float - Default:
centerPoint.x|0
The x (horizontal) position of the pin in the 3d worldspace, in meters from the center.
- Type:
- y:
- Type:
Float - Default:
centerPoint.y|0
The y (vertical) position of the pin in the 3d worldspace, in meters from the center
- Type:
- z:
- Type:
Float - Default:
centerPoint.z|0
The z (depth) position of the pin in the 3d worldspace, in meters from the center.
- Type:
- debug:
- Type:
Boolean - Default:
falseAdds a visible point in the space at the passedx,y,z.
- Type:
- render:
- Type:
Boolean - Default:
true
Immediately renders a new frame whentrue. If you are adding multiple Annotations to the Viewer, consider setting this tofalseand callel.Annotations.requestRender()manually to prevent unneeded frames.
- Type:
Returns:
Object: The created pin
{ content: 'A point',id: 'pin1', name: 'pin1', class: 'pin highlight', visible: true, x: 1.2, y: 0.4, z: -0.3, debug: false, visible: true }
getPin¶
Returns a single pin by name.
el.Annotations.getPin('pin1');
Parameters:
- name: Type:
string
Name of the pin to get.
Returns:
Object | undefined: The pin object or undefined if not found.
{ content: 'First pin', id: 'pin1', name: 'pin1', class: 'pin', visible: true, x: -0.007013648137886747, y: -0.00016835335983691677, z: 0.005849377919588963, debug: false},
getPins¶
Returns all pins.
el.Annotations.getPins();
Returns:
[
{ content: 'First pin', id: 'pin1', name: 'pin1', class: 'pin', visible: true, x: -0.007013648137886747, y: -0.00016835335983691677, z: 0.005849377919588963, debug: false},
{ content: 'Second pin', id: 'pin2', name: 'pin2', class: 'pin', visible: true, x: 0.00921308896370392, y: 0.0016515359896780157, z: 0.0006273469956638439, debug: false}
]
getPinNames¶
Returns an array of all pin names.
el.Annotations.getPinNames();
Returns:
['pin1', 'pin2', 'another pin'],
removePin¶
Removes a pin by name.
el.Annotations.removePin('pin1');
Parameters:
- name: Type:
string
The name of the pin to remove.
removePins¶
Removes all pins.
el.Annotations.removePins();
showPin¶
Shows or hides a pin by name.
Identical to hidePin({ name: 'pin1', visible: false }).
el.Annotations.showPin({ name: 'pin1' });
Parameters:
-
name: Type:
string
The name of the pin to show. -
visible:
- Type:
Boolean - Default:
true
- Type:
-
render:
- Type:
Boolean - Default:
trueImmediately renders a new frame whentrue. If you are changing multiple Annotations in the Viewer, consider setting this tofalseand callel.Annotations.requestRender()manually to prevent unneeded frames.
- Type:
hidePin¶
Hides or shows a pin by name.
Identical to showPin({ name: 'pin1', visible: true }).
el.Annotations.showPin({ name: 'pin1' });
Parameters:
-
name: Type:
string
The name of the pin to hide. -
visible:
- Type:
Boolean - Default:
true
- Type:
-
render:
- Type:
Boolean - Default:
trueImmediately renders a new frame whentrue. If you are changing multiple Annotations in the Viewer, consider setting this tofalseand callel.Annotations.requestRender()manually to prevent unneeded frames.
- Type:
requestRender¶
Requests a re-render of the Annotation layer.
el.Annotations.requestRender();