KloradDocs

Space

Every scene is anchored on Earth. Positions are real places, and renderers still work in metres.

A Klorad scene cannot exist without a coordinate system, and createScene refuses to create one without it. The coordinate system is an East, North, Up frame in metres, anchored at a point on the WGS84 ellipsoid, the same model GPS uses.

That gives you both things a twin needs: positions that are real places (you can hand them to a map, a survey or a GPS) and a flat local frame in metres that a renderer can draw without thinking about the curvature of the Earth.

create-scene.ts
import { createScene } from "@klorad/api/world";

const scene = createScene({
  name: "Waterfront",
  coordinateSystem: { origin: { lat: 40.62637, lon: 22.94838, height: 0 } },
});

const cs = scene.coordinateSystem;
const tower = cs.toLocal({ lat: 40.62637, lon: 22.94838, height: 0 }); // { east: 0, north: 0, up: 0 }
const rotunda = cs.toLocal({ lat: 40.63333, lon: 22.95278, height: 0 }); // about 372 m east, 773 m north
const back = cs.toGeo({ east: 100, north: 50, up: 0 }); // a GeoPoint again

export { scene, tower, rotunda, back };

Two ways to give a position

Every position may be given either way, and both are stored on Earth:

FormFieldsUse it when
On Earthlat, lon, heightThe position comes from GPS, a map or a survey.
Localeast, north, up (metres from the origin)You are laying out a site by hand or from a drawing.

height and up are optional and default to zero. Heights are metres above the ellipsoid, not above sea level.

How accurate it is

The conversion goes through Earth centred coordinates and back, so it holds over the whole globe, not only near the origin. Round trips are accurate well below a millimetre; the Space sandbox measures it live on landmarks spread over two kilometres.

Choose an origin near the middle of your site. The local frame is flat, so distances measured in it drift slowly from true distances on the ground as you move away from the origin; across a campus or a district the difference does not matter.

Run it liveSandbox: SpaceA scene anchored on Earth: real places placed by latitude and longitude, shown in metres around the origin.

Something wrong or unclear? Tell your contact at Prieston Technologies.