vicowa-web-components
Version:
2 lines • 19.9 kB
JavaScript
import{CAP_TYPES as a}from"./vicowa-webgl-definitions.js";import{vectorLength as t,angleToPoint as i,pointToAngle as e,vectorSubtract as n,vectorAdd as r,toRadians as o}from"../utilities/mathHelpers.js";const l=Object.freeze({MOVE:"MOVE",SCALE:"SCALE",ROTATE:"ROTATE"});export const MANIPULATOR_TYPES=Object.freeze({MOVE_X:"MOVE_X",MOVE_Y:"MOVE_Y",MOVE_Z:"MOVE_Z",MOVE_PLANE:"MOVE_PLANE",SCALE:"SCALE",SCALE_X:"SCALE_X",SCALE_Y:"SCALE_Y",SCALE_Z:"SCALE_Z",ROTATE_X:"ROTATE_X",ROTATE_Y:"ROTATE_Y",ROTATE_Z:"ROTATE_Z"});const g=Symbol("privateData"),d=Symbol("manipulation"),p=1;function u(t){const i=t[g];i.manipulators[MANIPULATOR_TYPES.MOVE_X]=i.manipulators[MANIPULATOR_TYPES.MOVE_Y]=i.manipulators[MANIPULATOR_TYPES.MOVE_Z]=function(a,t){const i=t.webglIF.createGroup(a);return i.addChild(t.webglIF.createSphere({diameter:.2,rotation:{x:90,y:0,z:0},material:"move-manipulator-unselected",renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.15,position:{y:-.2},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{y:-.3},rotation:{x:0,y:0,z:180},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.15,position:{y:.2},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{y:.3},renderingGroupId:p})),i.visible=!1,i}("move-manipulator",i),i.manipulators[MANIPULATOR_TYPES.MOVE_PLANE]=function(a,t){const i=t.webglIF.createGroup(a);return i.addChild(t.webglIF.createSphere({diameter:.2,rotation:{x:90,y:0,z:0},material:"move-manipulator-unselected",renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.15,position:{y:-.2},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{y:-.3},rotation:{z:180},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.15,position:{y:.2},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{y:.3},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.15,position:{z:-.2},rotation:{x:90},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{z:-.3},rotation:{x:90,z:180},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.15,position:{z:.2},rotation:{x:-90},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{z:.3},rotation:{x:-90,z:180},renderingGroupId:p})),i.visible=!1,i}("move-manipulator",i),i.manipulators[MANIPULATOR_TYPES.SCALE_X]=i.manipulators[MANIPULATOR_TYPES.SCALE_Y]=i.manipulators[MANIPULATOR_TYPES.SCALE_Z]=i.manipulators[MANIPULATOR_TYPES.SCALE]=function(a,t){const i=t.webglIF.createGroup(a);return i.addChild(t.webglIF.createSphere({diameter:.15,diameterZ:.3,rotation:{x:90,y:0,z:0},material:"scale-manipulator-unselected",renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{y:-.3},rotation:{x:0,y:0,z:180},renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameter:.05,height:.6,renderingGroupId:p})),i.addChild(t.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{y:.3},renderingGroupId:p})),i.visible=!1,i}("scale-manipulator",i),i.manipulators[MANIPULATOR_TYPES.ROTATE_X]=i.manipulators[MANIPULATOR_TYPES.ROTATE_Y]=i.manipulators[MANIPULATOR_TYPES.ROTATE_Z]=function(t,i){const e=i.webglIF.createGroup(t);e.addChild(i.webglIF.createSphere({diameter:.2,rotation:{x:90,y:0,z:0},material:"rotate-manipulator-unselected",renderingGroupId:p}));const n=[],r=o(270),l=o(0),g=r/16;for(let a=l;a<l+r;a+=g)n.push([.2*Math.sin(a),.2*Math.cos(a),0]);return e.addChild(i.webglIF.createTube({radius:.025,cap:a.CAP_ALL,path:n,renderingGroupId:p})),e.addChild(i.webglIF.createCylinder({diameterTop:0,diameterBottom:.1,height:.1,position:{x:-.2},rotation:{x:0,y:0,z:0},renderingGroupId:p})),e.visible=!1,e}("rotate-manipulator",i)}function s(a,t,i,e){const n=t[g],r=`${a}-${i.name}`;i.getChildren((a=>a.name===r)).forEach((a=>i.removeChild(a)));const o=n.manipulators[a].clone(r);n.webglIF.applySettings(Object.assign({collisions:!0,visible:!0},e),o),o.manipulatorType=a,i.addChild(o)}function c(a,i,r){const o=a[g],p=i[d].allowed,u=i[d].activeGroup,c=i[d].manipulatorPlane;if(a.removeManipulators(i.name),p&&Object.keys(p).find((a=>MANIPULATOR_TYPES[a]&&p[a]))){const g=i.center,d=i.boundingVectors,M=o.webglIF.createGroup(`manipulator-for-${i.name}`);o.activeManipulationObjects[M.name]=M,M.manipulatedObject=i,M.manipulatedObject.onRemove=t=>{a.removeManipulators(t.name)};const A=(a,l)=>{const d=o.webglIF.pointToScreenPoint(r||g),p=o.webglIF.screenPointToBoundingProjection(d,i),u=t(n(p.intersection,p.start)),s=1/u,c={x:p.intersection.x-(p.intersection.x-p.start.x)*s,y:p.intersection.y-(p.intersection.y-p.start.y)*s,z:p.intersection.z-(p.intersection.z-p.start.z)*s},M=n(p.intersection,p.start),A=90-e({x:M.x,y:M.z}),T=M.z>0?-e({x:M.z,y:M.y}):e({x:M.z,y:M.y}),P=o.webglIF.createPlane({width:1e4/o.webgl.unitMultiplier,height:1e4/o.webgl.unitMultiplier,position:c,rotation:{x:T,y:A,z:0},collisions:!0,sideOrientation:2,visible:!0});P.updateCoordinates();const O=o.webglIF.screenToObjectPoint({x:d.x+a,y:d.y+l},P);return P.remove(),{position:O,scale:{x:u/5,y:u/5,z:u/5}}};if(u===l.MOVE)if(p[MANIPULATOR_TYPES.MOVE_PLANE]){if(c){const t=A(0,0);!function(a,t,i){s(MANIPULATOR_TYPES.MOVE_PLANE,a,t,i)}(a,M,{position:t.position,scale:t.scale,rotation:{x:0,y:c.rotation.y+90,z:c.rotation.x}}),M.getChildren()[0].manipulatorPlane=c}}else{if(p[MANIPULATOR_TYPES.MOVE_X]){const t=A(60,60);!function(a,t,i){s(MANIPULATOR_TYPES.MOVE_X,a,t,i)}(a,M,{position:t.position,scale:t.scale,rotation:{x:0,y:0,z:90}})}if(p[MANIPULATOR_TYPES.MOVE_Y]){const t=A(-60,-60);!function(a,t,i){s(MANIPULATOR_TYPES.MOVE_Y,a,t,i)}(a,M,{position:t.position,scale:t.scale,rotation:{x:0,y:0,z:0}})}if(p[MANIPULATOR_TYPES.MOVE_Z]){const t=A(-60,60);!function(a,t,i){s(MANIPULATOR_TYPES.MOVE_Z,a,t,i)}(a,M,{position:t.position,scale:t.scale,rotation:{x:90,y:0,z:0}})}}else if(u===l.SCALE)if(p[MANIPULATOR_TYPES.SCALE]){const t=A(60,-60);!function(a,t,i){s(MANIPULATOR_TYPES.SCALE,a,t,i)}(a,M,{position:t.position,scale:t.scale,rotation:{x:-45,y:-45,z:0}})}else{if(p[MANIPULATOR_TYPES.SCALE_X]){const t=A(60,60);!function(a,t,i){s(MANIPULATOR_TYPES.SCALE_X,a,t,i)}(a,M,{position:d[0],scale:t.scale,rotation:{x:0,y:0,z:90}})}if(p[MANIPULATOR_TYPES.SCALE_Y]){const t=A(-60,-60);!function(a,t,i){s(MANIPULATOR_TYPES.SCALE_Y,a,t,i)}(a,M,{position:d[1],scale:t.scale,rotation:{x:0,y:0,z:0}})}if(p[MANIPULATOR_TYPES.SCALE_Z]){const t=A(-60,60);!function(a,t,i){s(MANIPULATOR_TYPES.SCALE_Z,a,t,i)}(a,M,{position:d[2],scale:t.scale,rotation:{x:90,y:0,z:0}})}}else if(u===l.ROTATE){if(p[MANIPULATOR_TYPES.ROTATE_X]){const t=A(60,60);!function(a,t,i){s(MANIPULATOR_TYPES.ROTATE_X,a,t,i)}(a,M,{position:d[0],scale:t.scale,rotation:{x:180,y:270,z:-90}})}if(p[MANIPULATOR_TYPES.ROTATE_Y]){const t=A(-60,-60);!function(a,t,i){s(MANIPULATOR_TYPES.ROTATE_Y,a,t,i)}(a,M,{position:d[1],scale:t.scale,rotation:{x:90,y:270,z:0}})}if(p[MANIPULATOR_TYPES.ROTATE_Z]){const t=A(-60,60);!function(a,t,i){s(MANIPULATOR_TYPES.ROTATE_Z,a,t,i)}(a,M,{position:d[2],scale:t.scale,rotation:{x:0,y:0,z:90}})}}}}function M(a,t){t[d].activeGroup?t[d].activeGroup===l.ROTATE?t[d].allowed[MANIPULATOR_TYPES.MOVE_X]||t[d].allowed[MANIPULATOR_TYPES.MOVE_Y]||t[d].allowed[MANIPULATOR_TYPES.MOVE_Z]||t[d].allowed[MANIPULATOR_TYPES.MOVE_PLANE]?t[d].activeGroup=l.MOVE:(t[d].allowed[MANIPULATOR_TYPES.SCALE_X]||t[d].allowed[MANIPULATOR_TYPES.SCALE_Y]||t[d].allowed[MANIPULATOR_TYPES.SCALE_Z]||t[d].allowed[MANIPULATOR_TYPES.SCALE])&&(t[d].activeGroup=l.SCALE):t[d].activeGroup===l.MOVE?t[d].allowed[MANIPULATOR_TYPES.SCALE_X]||t[d].allowed[MANIPULATOR_TYPES.SCALE_Y]||t[d].allowed[MANIPULATOR_TYPES.SCALE_Z]||t[d].allowed[MANIPULATOR_TYPES.SCALE]?t[d].activeGroup=l.SCALE:(t[d].allowed[MANIPULATOR_TYPES.ROTATE_X]||t[d].allowed[MANIPULATOR_TYPES.ROTATE_Y]||t[d].allowed[MANIPULATOR_TYPES.ROTATE_Z])&&(t[d].activeGroup=l.ROTATE):t[d].activeGroup===l.SCALE&&(t[d].allowed[MANIPULATOR_TYPES.ROTATE_X]||t[d].allowed[MANIPULATOR_TYPES.ROTATE_Y]||t[d].allowed[MANIPULATOR_TYPES.ROTATE_Z]?t[d].activeGroup=l.ROTATE:(t[d].allowed[MANIPULATOR_TYPES.MOVE_X]||t[d].allowed[MANIPULATOR_TYPES.MOVE_Y]||t[d].allowed[MANIPULATOR_TYPES.MOVE_Z]||t[d].allowed[MANIPULATOR_TYPES.MOVE_PLANE])&&(t[d].activeGroup=l.MOVE)):t[d].allowed[MANIPULATOR_TYPES.MOVE_X]||t[d].allowed[MANIPULATOR_TYPES.MOVE_Y]||t[d].allowed[MANIPULATOR_TYPES.MOVE_Z]||t[d].allowed[MANIPULATOR_TYPES.MOVE_PLANE]?t[d].activeGroup=l.MOVE:t[d].allowed[MANIPULATOR_TYPES.SCALE_X]||t[d].allowed[MANIPULATOR_TYPES.SCALE_Y]||t[d].allowed[MANIPULATOR_TYPES.SCALE_Z]||t[d].allowed[MANIPULATOR_TYPES.SCALE]?t[d].activeGroup=l.SCALE:(t[d].allowed[MANIPULATOR_TYPES.ROTATE_X]||t[d].allowed[MANIPULATOR_TYPES.ROTATE_Y]||t[d].allowed[MANIPULATOR_TYPES.ROTATE_Z])&&(t[d].activeGroup=l.ROTATE)}export default class VicowaWebGLManipulationExtension{static getAllManipulatorsAllowed(){return Object.keys(MANIPULATOR_TYPES).reduce(((a,t)=>(a[t]=!0,a)),{})}constructor(){this[g]={webgl:null,webglIF:null,manipulators:{},activeManipulationObjects:{},draggingManipulator:null}}attach(a,o){const p=this[g];p.webgl=a,p.webglIF=o,p.webgl.addMaterial("move-manipulator-unselected",{diffuse:{r:.6,g:.6,b:1}}),p.webgl.addMaterial("move-manipulator-selected",{diffuse:{r:0,g:0,b:1}}),p.webgl.addMaterial("scale-manipulator-unselected",{diffuse:{r:.6,g:1,b:1}}),p.webgl.addMaterial("scale-manipulator-selected",{diffuse:{r:0,g:1,b:1}}),p.webgl.addMaterial("rotate-manipulator-unselected",{diffuse:{r:1,g:.6,b:1}}),p.webgl.addMaterial("rotate-manipulator-selected",{diffuse:{r:1,g:0,b:1}});const s=()=>p.draggingManipulator&&p.draggingManipulator.manipulatorPlane?p.webglIF.screenToObjectPoint(p.webglIF.pointerPos,p.draggingManipulator.manipulatorPlane):null;p.webglIF.addPointerClickListener((a=>{let t=a.hitObject;for(;t&&!MANIPULATOR_TYPES[t.manipulatorType];)t=t.parent;if(t&&(!p.draggingManipulator||!p.draggingManipulator.hasMoved)){let a=t;for(;a&&!a.manipulatedObject;)a=a.parent;a&&(M(0,a.manipulatedObject),c(this,a.manipulatedObject))}})),p.webglIF.addPointerDownListener((a=>{let t=a.hitObject;for(;t&&!MANIPULATOR_TYPES[t.manipulatorType];)t=t.parent;if(t){p.draggingManipulator={manipulatorType:t.manipulatorType,activeManipulator:t},p.draggingManipulator.hasMoved=!1;let a=t;for(;a&&!a.manipulatedObject;)a=a.parent;if(a){switch(p.draggingManipulator.activeManipulator.activeGroup=a.manipulatedObject[d].activeGroup,t.manipulatorType){case MANIPULATOR_TYPES.MOVE_X:case MANIPULATOR_TYPES.SCALE_X:case MANIPULATOR_TYPES.ROTATE_Z:p.draggingManipulator.manipulatorPlane=p.webglIF.createPlane({width:1e4/p.webgl.unitMultiplier,height:1e4/p.webgl.unitMultiplier,position:t.center,collisions:!0,visible:!1}),p.draggingManipulator.manipulatorPlane.updateCoordinates(),p.draggingManipulator.startPoint=s(),p.draggingManipulator.startHandlerRotation=e(n(p.draggingManipulator.startPoint,a.manipulatedObject.center));break;case MANIPULATOR_TYPES.SCALE:p.draggingManipulator.manipulatorPlane=p.webglIF.createPlane({width:1e4/p.webgl.unitMultiplier,height:1e4/p.webgl.unitMultiplier,position:t.center,collisions:!0,visible:!1}),p.draggingManipulator.manipulatorPlane.applySettings({rotation:{x:0,y:45,z:0}}),p.draggingManipulator.manipulatorPlane.updateCoordinates(),p.draggingManipulator.startPoint=s();break;case MANIPULATOR_TYPES.MOVE_Y:case MANIPULATOR_TYPES.SCALE_Y:p.draggingManipulator.manipulatorPlane=p.webglIF.createPlane({width:1e4/p.webgl.unitMultiplier,height:1e4/p.webgl.unitMultiplier,position:t.center,collisions:!0,visible:!1}),p.draggingManipulator.manipulatorPlane.updateCoordinates(),p.draggingManipulator.startPoint=s();break;case MANIPULATOR_TYPES.ROTATE_X:p.draggingManipulator.manipulatorPlane=p.webglIF.createPlane({width:1e4/p.webgl.unitMultiplier,height:1e4/p.webgl.unitMultiplier,position:t.center,collisions:!0,visible:!1,rotation:{x:0,y:90,z:0}}),p.draggingManipulator.manipulatorPlane.updateCoordinates(),p.draggingManipulator.startPoint=s(),p.draggingManipulator.startHandlerRotation=e(n({x:p.draggingManipulator.startPoint.z,y:p.draggingManipulator.startPoint.y},{x:a.manipulatedObject.center.z,y:a.manipulatedObject.center.y}));break;case MANIPULATOR_TYPES.MOVE_Z:case MANIPULATOR_TYPES.SCALE_Z:case MANIPULATOR_TYPES.ROTATE_Y:p.draggingManipulator.manipulatorPlane=p.webglIF.createPlane({width:1e4/p.webgl.unitMultiplier,height:1e4/p.webgl.unitMultiplier,position:t.center,collisions:!0,visible:!1,rotation:{x:90,y:0,z:0}}),p.draggingManipulator.manipulatorPlane.updateCoordinates(),p.draggingManipulator.startPoint=s(),p.draggingManipulator.startHandlerRotation=e(n({x:p.draggingManipulator.startPoint.x,y:p.draggingManipulator.startPoint.z},{x:a.manipulatedObject.center.x,y:a.manipulatedObject.center.z}));break;case MANIPULATOR_TYPES.MOVE_PLANE:p.draggingManipulator.manipulatorPlane=t.manipulatorPlane,p.draggingManipulator.startPoint=s()}p.draggingManipulator.startPosition=p.draggingManipulator.activeManipulator.position,p.draggingManipulator.startScale=a.manipulatedObject.scale,p.draggingManipulator.startRotation=a.manipulatedObject.rotation,p.draggingManipulator.startPoint?(p.draggingManipulator.manipulatorsObject=a,p.draggingManipulator.activeManipulator.getChildren()[0].applySettings({material:p.draggingManipulator.activeManipulator.activeGroup===l.SCALE?"scale-manipulator-selected":p.draggingManipulator.activeManipulator.activeGroup===l.ROTATE?"rotate-manipulator-selected":"move-manipulator-selected"}),p.webglIF.detachCameraControl()):(p.draggingManipulator.manipulatorType!==MANIPULATOR_TYPES.MOVE_PLANE&&p.draggingManipulator.manipulatorPlane.remove(),p.draggingManipulator=null)}else p.draggingManipulator.manipulatorPlane.remove(),p.draggingManipulator=null}})),p.webglIF.addPointerUpListener((()=>{p.draggingManipulator&&(p.draggingManipulator.manipulatorType!==MANIPULATOR_TYPES.MOVE_PLANE&&p.draggingManipulator.manipulatorPlane.remove(),p.draggingManipulator.activeManipulator.isRemoved()||p.draggingManipulator.activeManipulator.getChildren()[0].applySettings({material:p.draggingManipulator.activeManipulator.activeGroup===l.SCALE?"scale-manipulator-unselected":p.draggingManipulator.activeManipulator.activeGroup===l.ROTATE?"rotate-manipulator-unselected":"move-manipulator-unselected"})),p.draggingManipulator=null,p.webglIF.attachCameraControl()})),p.webglIF.addPointerMoveListener((()=>{if(p.draggingManipulator&&p.draggingManipulator.startPoint){const a=s();if(a){p.draggingManipulator.hasMoved=!0;const o=p.draggingManipulator.manipulatorsObject.manipulatedObject.center,l={x:Math.round(1e3*(a.x-p.draggingManipulator.startPoint.x))/1e3,y:Math.round(1e3*(a.y-p.draggingManipulator.startPoint.y))/1e3,z:Math.round(1e3*(a.z-p.draggingManipulator.startPoint.z))/1e3};switch(p.draggingManipulator.manipulatorType){case MANIPULATOR_TYPES.MOVE_X:l.y=0,l.z=0,p.draggingManipulator.manipulatorsObject.offset(l),p.draggingManipulator.manipulatorsObject.manipulatedObject.offset(l),p.draggingManipulator.startPoint=a;break;case MANIPULATOR_TYPES.MOVE_Y:l.x=0,l.z=0,p.draggingManipulator.manipulatorsObject.offset(l),p.draggingManipulator.manipulatorsObject.manipulatedObject.offset(l),p.draggingManipulator.startPoint=a;break;case MANIPULATOR_TYPES.MOVE_Z:l.x=0,l.y=0,p.draggingManipulator.manipulatorsObject.offset(l),p.draggingManipulator.manipulatorsObject.manipulatedObject.offset(l),p.draggingManipulator.startPoint=a;break;case MANIPULATOR_TYPES.MOVE_PLANE:p.draggingManipulator.manipulatorsObject.offset(l),p.draggingManipulator.manipulatorsObject.manipulatedObject.offset(l),p.draggingManipulator.startPoint=a;break;case MANIPULATOR_TYPES.SCALE:{const t={x:p.draggingManipulator.startPoint.x-o.x,y:p.draggingManipulator.startPoint.y-o.y,z:p.draggingManipulator.startPoint.z-o.z},i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z),e={x:a.x-o.x,y:a.y-o.y,z:a.z-o.z},n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);p.draggingManipulator.activeManipulator.position={x:p.draggingManipulator.startPosition.x+a.x-p.draggingManipulator.startPoint.x,y:p.draggingManipulator.startPosition.y+a.y-p.draggingManipulator.startPoint.y,z:p.draggingManipulator.startPosition.z+a.z-p.draggingManipulator.startPoint.z},p.draggingManipulator.manipulatorsObject.manipulatedObject.scale={x:p.draggingManipulator.startScale.x*n/i,y:p.draggingManipulator.startScale.y*n/i,z:p.draggingManipulator.startScale.z*n/i}}break;case MANIPULATOR_TYPES.SCALE_X:{const t=p.draggingManipulator.startPoint.x-o.x,i=a.x-o.x;p.draggingManipulator.activeManipulator.position={x:p.draggingManipulator.startPosition.x+a.x-p.draggingManipulator.startPoint.x},p.draggingManipulator.manipulatorsObject.manipulatedObject.scale={x:p.draggingManipulator.startScale.x*i/t}}break;case MANIPULATOR_TYPES.SCALE_Y:{const t=p.draggingManipulator.startPoint.y-o.y,i=a.y-o.y;p.draggingManipulator.activeManipulator.position={y:p.draggingManipulator.startPosition.y+a.y-p.draggingManipulator.startPoint.y},p.draggingManipulator.manipulatorsObject.manipulatedObject.scale={y:p.draggingManipulator.startScale.y*i/t}}break;case MANIPULATOR_TYPES.SCALE_Z:{const t=p.draggingManipulator.startPoint.z-o.z,i=a.z-o.z;p.draggingManipulator.activeManipulator.position={z:p.draggingManipulator.startPosition.z+a.z-p.draggingManipulator.startPoint.z},p.draggingManipulator.manipulatorsObject.manipulatedObject.scale={z:p.draggingManipulator.startScale.z*i/t}}break;case MANIPULATOR_TYPES.ROTATE_X:{const o={x:p.draggingManipulator.manipulatorsObject.manipulatedObject.center.z,y:p.draggingManipulator.manipulatorsObject.manipulatedObject.center.y},l={x:p.draggingManipulator.startPoint.z,y:p.draggingManipulator.startPoint.y},g=e(n({x:a.z,y:a.y},o)),d=i(g,t(n(l,o))),u=r({x:d.x,y:d.y},o);p.draggingManipulator.activeManipulator.position={z:u.x,y:u.y},p.draggingManipulator.manipulatorsObject.manipulatedObject.rotation={x:p.draggingManipulator.startRotation.x-(g-p.draggingManipulator.startHandlerRotation)}}break;case MANIPULATOR_TYPES.ROTATE_Y:{const o={x:p.draggingManipulator.manipulatorsObject.manipulatedObject.center.x,y:p.draggingManipulator.manipulatorsObject.manipulatedObject.center.z},l={x:p.draggingManipulator.startPoint.x,y:p.draggingManipulator.startPoint.z},g=e(n({x:a.x,y:a.z},o)),d=i(g,t(n(l,o))),u=r({x:d.x,y:d.y},o);p.draggingManipulator.activeManipulator.position={x:u.x,z:u.y},p.draggingManipulator.manipulatorsObject.manipulatedObject.rotation={y:p.draggingManipulator.startRotation.y-(g-p.draggingManipulator.startHandlerRotation)}}break;case MANIPULATOR_TYPES.ROTATE_Z:{const o={x:p.draggingManipulator.manipulatorsObject.manipulatedObject.center.x,y:p.draggingManipulator.manipulatorsObject.manipulatedObject.center.y},l={x:p.draggingManipulator.startPoint.x,y:p.draggingManipulator.startPoint.y},g=e(n(a,o)),d=i(g,t(n(l,o))),u=r({x:d.x,y:d.y},o);p.draggingManipulator.activeManipulator.position={x:u.x,y:u.y},p.draggingManipulator.manipulatorsObject.manipulatedObject.rotation={z:p.draggingManipulator.startRotation.z+(g-p.draggingManipulator.startHandlerRotation)}}}}}})),u(this)}setAllowedManipulators(a,t){const i=this[g].webglIF.getObject(a);i[d]=i[d]||{allowed:{},manipulatorPlane:null},Object.keys(t).forEach((a=>{MANIPULATOR_TYPES[a]&&(i[d].allowed[a]=t[a],a===MANIPULATOR_TYPES.MOVE_PLANE&&(i[d].manipulatorPlane=t.movePlane))}))}removeManipulators(a){const t=this[g],i=`manipulator-for-${t.webglIF.getObject(a).name}`;t.activeManipulationObjects[i]&&(t.activeManipulationObjects[i].remove(),delete t.activeManipulationObjects[i])}attachManipulators(a,t){const i=this[g].webglIF.getObject(a);i&&i[d]&&(i[d].activeGroup||M(0,i),c(this,i,t))}}
//# sourceMappingURL=manipulation-extension.js.map