Choose what visitors can see
Build the filtered package a public view shows, through a declared filter. The package is local; hosting and publishing it is a separate step.
A public World is never the internal World. A declared filter names which objects,
properties, readings and alarms are public; publicPackage keeps only those and is the only
thing a public World is made from: the public view visitors see of your scene.
A package, not a website
publicPackage builds a filtered package in your code. It does not publish a hosted world or
create a public URL; serving the package is your application's job, or Klorad One's. To put
a world inside another site, see Embed a published world.
import { createScene, packScene, publicPackage, type PublicationFilter } from "@klorad/api/world";
const scene = createScene({ name: "Northgate", coordinateSystem: { origin: { lat: 40.66, lon: 22.865 } } });
scene.add({ id: "office", name: "Operations office", position: { east: 0, north: -35 }, properties: { kind: "building", tenant: "Northgate SA" } });
scene.add({ id: "gate-cam", name: "Gate camera", position: { east: 0, north: -75 }, properties: { kind: "camera" } });
scene.add({ id: "crac", name: "Server room cooling", position: { east: 5, north: -33 }, correspondence: "twin", binding: { source: "bms", entity: "p:northgate:r:crac" }, properties: { kind: "equipment" } });
scene.observe({ objectId: "crac", quantity: "temperature", value: 22.5, observedAt: Date.now(), source: "bms" });
scene.observe({ objectId: "crac", quantity: "setpoint", value: 21, observedAt: Date.now(), source: "bms" });
// Nothing is public that the filter does not name.
const filter: PublicationFilter = {
exclude: { kind: ["camera"] },
properties: ["kind"],
quantities: ["temperature"],
alarms: ["server-room-hot"],
};
export async function publicView() {
const pub = await publicPackage(await packScene(scene), filter, "Northgate, public view");
const objects = pub.chunks.flatMap((c) => c.objects);
objects.map((o) => o.id); // ["office", "crac"]: the camera stays inside
objects.find((o) => o.id === "office")?.properties; // { kind: "building" }: the tenant stays inside
JSON.stringify(pub).includes("p:northgate"); // false: no source or device id leaves
return pub;
}What the projection does
- Keeps the objects the filter admits: by layer, by class, by id, and never one whose
properties match
exclude. - Keeps only the properties named in
properties. - Turns a shadow or a twin into a shadow bound to an anonymous source, so no source or device id leaves and nothing public can be actuated.
- Keeps the readings of the quantities named in
quantities, and drops relations to objects that are not public, provenance and extensions. - Keeps the scene's 3D Tiles context only when
externalSpacesistrue. - Keeps the model files public objects are drawn from only when
modelsistrue, and lists only those files among its assets; otherwise a model shows as a marker where it stands. - Keeps the scene's named views, or the
viewsyou pass as the fourth argument, in order: a viewer starts at the first.checkPublicViews(views)gives their problems. - Carries
immersiveas it is: whether the World may be walked in a VR headset. The projection is the same either way; a viewer reads it from the filter.
In Klorad One
This section is about the platform, not the SDK. Klorad One publishes
each projection as an immutable version at /p/<slug>, with an installable app, and hides every
version at once when the World is unpublished.
Something wrong or unclear? Tell us.
Give a team its own view
A district crew sees and acts on its own bins only, the city sees everything, and every Action is audited.
Embed a published world
Whether you need a published Klorad One world inside your site or the scene inside your own application, what each takes today, and what is not available yet.