import { OGSceneManager, OGCuboid, OGCylinder, OGSphere } from 'opengeometry';
// Create scene manager and new scene
const manager = new OGSceneManager();
const sceneId = manager.createScene("Building Components");
// Add foundation (cuboid)
const foundation = OGCuboid.new("origin", 20.0, 1.0, 15.0);
manager.addCuboidToScene(sceneId, "foundation", foundation);
// Add columns (cylinders)
for (let i = 0; i < 4; i++) {
const x = (i % 2) * 18 - 9;
const z = Math.floor(i / 2) * 13 - 6.5;
const origin = `${x},1.5,${z}`;
const direction = "0,1,0";
const column = OGCylinder.new(origin, direction, 0.5, 3.0);
manager.addCylinderToScene(sceneId, `column-${i}`, column);
}
// Add decorative sphere
const sphere = OGSphere.new("0,5,0", 1.5);
manager.addSphereToScene(sceneId, "dome", sphere);
// Get scene info
const scenesJson = manager.listScenes();
const scenes = JSON.parse(scenesJson);
console.log(`Scene contains ${scenes[0].entity_count} entities`);
// Project to 2D for technical drawing
const cameraJson = JSON.stringify({
position: { x: 30, y: 20, z: 25 },
target: { x: 0, y: 2, z: 0 },
up: { x: 0, y: 1, z: 0 },
near: 0.1,
projection_mode: "Orthographic"
});
const hlrJson = JSON.stringify({ hide_hidden_edges: true });
const scene2dJson = manager.projectTo2DCamera(sceneId, cameraJson, hlrJson);
const scene2d = JSON.parse(scene2dJson);
console.log(`Projected scene has ${scene2d.paths.length} paths`);