import { OpenPlans } from 'openplans';
async function createRoom() {
const container = document.getElementById('app');
const openPlans = new OpenPlans(container);
await openPlans.setupOpenGeometry();
// Create room boundary
const roomOutline = openPlans.rectangle({
center: [5, 0, 4],
width: 10,
breadth: 8,
color: 0x000000
});
// Add floor slab
const floor = openPlans.baseSlab({
labelName: 'Floor',
slabPosition: [5, -0.1, 4],
slabWidth: 10,
slabDepth: 8,
slabThickness: 0.2,
slabColor: 0xDDDDDD
});
// Add entrance door
const entranceDoor = openPlans.baseDoor({
labelName: 'Entrance',
doorPosition: [5, 0, 0],
doorLength: 2,
doorHeight: 2.1,
doorThickness: 0.1,
doorQuadrant: 1,
doorColor: 0x8B4513,
frameColor: 0x000000
});
// Add windows
const leftWindow = openPlans.baseSingleWindow({
labelName: 'Left Window',
windowPosition: [0, 0, 4],
windowLength: 1.5,
windowHeight: 1.2
});
const rightWindow = openPlans.baseSingleWindow({
labelName: 'Right Window',
windowPosition: [10, 0, 4],
windowLength: 1.5,
windowHeight: 1.2
});
// Add back double window
const backWindow = openPlans.baseDoubleWindow({
labelName: 'Back Windows',
windowPosition: [5, 0, 8],
windowLength: 2.5,
windowHeight: 1.5,
spacing: 0.2
});
// Log all elements
const elements = [
...openPlans.getEntitiesByType('baseDoor'),
...openPlans.getEntitiesByType('baseSingleWindow'),
...openPlans.getEntitiesByType('baseDoubleWindow'),
...openPlans.getEntitiesByType('baseSlab')
];
console.log(`Created room with ${elements.length} elements`);
// Fit camera to view all
openPlans.fit('RectanglePrimitive');
}
createRoom();