import { OpenPlans, Vector3 } from 'openplans';
async function create3DRoom() {
const container = document.getElementById('app');
const openPlans = new OpenPlans(container);
await openPlans.setupOpenGeometry();
const roomWidth = 6;
const roomDepth = 5;
const roomHeight = 3;
const wallThickness = 0.2;
// Floor
const floor = openPlans.cuboid({
center: new Vector3(roomWidth/2, -0.1, roomDepth/2),
width: roomWidth,
height: 0.2,
depth: roomDepth,
color: 0xCCCCCC
});
// Walls
const walls = [
// Front wall
openPlans.cuboid({
center: new Vector3(roomWidth/2, roomHeight/2, 0),
width: roomWidth,
height: roomHeight,
depth: wallThickness,
color: 0xF5F5F5
}),
// Back wall
openPlans.cuboid({
center: new Vector3(roomWidth/2, roomHeight/2, roomDepth),
width: roomWidth,
height: roomHeight,
depth: wallThickness,
color: 0xF5F5F5
}),
// Left wall
openPlans.cuboid({
center: new Vector3(0, roomHeight/2, roomDepth/2),
width: wallThickness,
height: roomHeight,
depth: roomDepth,
color: 0xF5F5F5
}),
// Right wall
openPlans.cuboid({
center: new Vector3(roomWidth, roomHeight/2, roomDepth/2),
width: wallThickness,
height: roomHeight,
depth: roomDepth,
color: 0xF5F5F5
})
];
// Ceiling
const ceiling = openPlans.cuboid({
center: new Vector3(roomWidth/2, roomHeight, roomDepth/2),
width: roomWidth,
height: 0.2,
depth: roomDepth,
color: 0xFFFFFF
});
// Column in corner
const column = openPlans.cylinder({
center: new Vector3(1, roomHeight/2, 1),
radius: 0.2,
height: roomHeight,
segments: 32,
color: 0x888888
});
console.log('3D room created successfully');
}
create3DRoom();