async function getMousePointer({event}){
markupMouse.x = ( (event.clientX-viewer.context.getDomElement().getBoundingClientRect().x) / viewer.context.getDomElement().clientWidth ) * 2 - 1;
markupMouse.y = -( (event.clientY-viewer.context.getDomElement().getBoundingClientRect().y) / viewer.context.getDomElement().clientHeight ) * 2 + 1;
markupPoint.set(markupMouse.x,markupMouse.y,0);
}
async function createRectangle({start,end}){
const camera = viewer.context.ifcCamera.activeCamera;
const shape = new Shape();
shape.moveTo(start.x, start.y);
shape.lineTo(start.x, end.y);
shape.lineTo(end.x, end.y);
shape.lineTo(end.x, start.y);
const geometry = new ShapeGeometry(shape);
const material = new MeshBasicMaterial({
color: randomcolor,
// color: "rgb(255,0,0)",
side: DoubleSide,
depthWrite: false
});
const mesh = new Mesh(geometry, material);
mesh.position.copy(camera.position);
mesh.quaternion.copy(camera.quaternion);
mesh.updateMatrix();
return mesh;
}
draw rectangle with mouse.
It’s too close and off camera.
how do i fix it?