import { OpenPlans, Vector3 } from 'openplans';
async function createDrawing() {
const container = document.getElementById('app');
const openPlans = new OpenPlans(container);
await openPlans.setupOpenGeometry();
// Create a rectangular boundary
const boundary = openPlans.rectangle({
center: [5, 0, 5],
width: 10,
breadth: 10,
color: 0x000000
});
// Add a diagonal line
const diagonal = openPlans.line({
startPoint: [0, 0, 0],
endPoint: [10, 0, 10],
color: 0xFF0000
});
// Create a curved element
const curve = openPlans.arc({
center: [5, 0, 5],
radius: 3,
startAngle: 0,
endAngle: Math.PI,
segments: 32,
color: 0x0000FF
});
// Add an irregular shape
const customShape = openPlans.polyline({
points: [
[1, 0, 1],
[3, 0, 1],
[3, 0, 2],
[2, 0, 3],
[1, 0, 2],
[1, 0, 1]
],
color: 0x00FF00
});
// Get all primitives
const allEntities = [
...openPlans.getEntitiesByType('LinePrimitive'),
...openPlans.getEntitiesByType('RectanglePrimitive'),
...openPlans.getEntitiesByType('PolylinePrimitive'),
...openPlans.getEntitiesByType('ArcPrimitive')
];
console.log(`Created ${allEntities.length} primitives`);
}
createDrawing();