Overview
The Glyphs system provides text rendering and annotation capabilities in OpenPlans. It allows you to add text labels, annotations, and dynamic text elements that can be positioned, rotated, and scaled in your 3D scene. Glyphs are powered by the@opengeometry/openglyph package and integrate seamlessly with the OpenPlans rendering pipeline.
Setup
The Glyphs system is automatically initialized when you callsetupOpenGeometry():
Creating Glyphs
glyph()
Create a new text glyph and add it to the scene.The text content to display.
The font size of the text.
The color of the text as a hexadecimal value (e.g.,
0x000000 for black, 0xFF0000 for red).When
true, the glyph maintains a consistent size regardless of camera zoom level. When false, the glyph scales with the scene.GlyphNode - A glyph node object that can be positioned and manipulated.
Managing Glyphs
getGlyph()
Retrieve a glyph by its unique identifier.The unique identifier of the glyph to retrieve.
GlyphNode - The glyph node object.
Throws: Error if the glyph is not found.
glyphNodes
Access all glyph nodes in the scene.Map<string, GlyphNode> - A map of all glyph nodes indexed by their IDs.
Manipulating Glyphs
updateGlyphText()
Update the text content of an existing glyph.The unique identifier of the glyph to update.
The new text content to display.
rotateGlyph()
Rotate a glyph by a specified angle.The unique identifier of the glyph to rotate.
The rotation angle in radians.
selectGlyph()
Select a glyph for editing or highlighting.The unique identifier of the glyph to select.
clearGlyphSelection()
Clear the current glyph selection.Positioning Glyphs
Glyph nodes are Three.js Object3D instances, so you can position and transform them using standard Three.js methods:Complete Example
Camera Integration
The Glyphs system automatically updates when the camera moves to maintain proper orientation and scale (whenstaticZoom is enabled):
Font Customization
The default font is ‘Source_Code_Pro_Regular’. The font is loaded during initialization:Best Practices
- Use
staticZoom: truefor labels and annotations that should remain readable at any zoom level - Use
staticZoom: falsefor text that should scale with the scene - Keep glyph IDs for labels you need to update dynamically
- Position glyphs slightly above (y-axis) geometry to prevent z-fighting
- Use consistent text sizes for related annotations (e.g., all room labels at size 18)
Notes
- Glyphs are rendered as part of the main scene
- The Glyphs system uses the
@opengeometry/openglyphpackage internally - Text rendering performance is optimized for real-time applications
- Glyphs automatically update when camera changes occur