Converts BufferGeometry to a JSON-serializable format for storage.
This is an alternative to WKT that preserves the exact triangle structure and can be stored in a JSON/JSONB column.
The Three.js BufferGeometry to convert
The geographic origin for coordinate conversion
An array of GeoTriangle objects that can be serialized to JSON
Error if geometry has no position attribute
import { bufferGeometryToGeoTriangles } from '@wendylabsinc/react-three-map/maplibre';const triangles = bufferGeometryToGeoTriangles(geometry, origin);const json = JSON.stringify(triangles);// Store in database JSONB column Copy
import { bufferGeometryToGeoTriangles } from '@wendylabsinc/react-three-map/maplibre';const triangles = bufferGeometryToGeoTriangles(geometry, origin);const json = JSON.stringify(triangles);// Store in database JSONB column
Converts BufferGeometry to a JSON-serializable format for storage.
This is an alternative to WKT that preserves the exact triangle structure and can be stored in a JSON/JSONB column.