@soonspacejs/plugin-clipping-controls 2.10.11 → 2.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import e from"soonspacejs";import{Vector3 as s,Plane as n,Box3 as i}from"three";class t{constructor(e){this.ssp=e,this.scenePlaneHelpers={x:null,y:null,z:null}}addPlaneHelper(e,s,n){const i=this.ssp.addPlaneHelper(Object.assign(Object.assign({},s),{opacity:.3}));this.scenePlaneHelpers[e]=i,n&&this.ssp.addObject(i,n)}sceneClipping(i){var t,a,l;const{axis:r,clipPoint:p,isForward:c=!0,openHelper:o=!0}=i,h=c?p-1:1-p,d=`scene_clippingPlaneHelper_${r}`;if(o)if(this.scenePlaneHelpers[r])switch(r){case"x":null===(t=this.scenePlaneHelpers[r])||void 0===t||t.position.setX(h);break;case"y":null===(a=this.scenePlaneHelpers[r])||void 0===a||a.position.setY(h);break;case"z":null===(l=this.scenePlaneHelpers[r])||void 0===l||l.position.setZ(h)}else{const n=e.utils.getBoundingBox(this.ssp.viewport.scene),i=n.getSize(new s);let t=0,a=0,l="green";const p=n.getCenter(new s).clone(),c={x:0,y:0,z:0};switch(r){case"x":t=i.z,a=i.y,l="green",p.x=h,c.y=Math.PI/2;break;case"y":t=i.x,a=i.z,l="blue",p.y=h,c.x=Math.PI/2;break;case"z":t=i.x,a=i.y,p.z=h,l="red"}this.addPlaneHelper(r,{id:d,width:t,height:a,color:l,position:p,rotation:c})}else this.scenePlaneHelpers[r]&&(this.ssp.removeHelperById(d),this.scenePlaneHelpers[r]=null);const g={x:new s(c?-1:1,0,0),y:new s(0,c?-1:1,0),z:new s(0,0,c?-1:1)},P=this.ssp.viewport.renderer.clippingPlanes.find((e=>1===Math.abs(e.normal[r])));if(P)P.normal=g[r],P.constant=p;else{this.ssp.viewport.renderer.clippingPlanes.push(new n(g[r],p))}this.ssp.signals.sceneChanged.dispatch()}removeSceneClipping(e){if(e){const s=this.ssp.viewport.renderer.clippingPlanes,n=s.findIndex((s=>1===Math.abs(s.normal[e])));s.splice(n,1)}else this.ssp.viewport.renderer.clippingPlanes=[];this.ssp.signals.sceneChanged.dispatch()}modelClipping(e,t){const{axis:a,clipPercent:l,isForward:r=!0,openHelper:p=!0}=t,c=(new i).setFromObject(e);c.max.add(new s(2,2,2)),c.min.sub(new s(2,2,2));const o=c.getSize(new s),h=r?c.max[a]-l/100*o[a]+1:c.min[a]+l/100*o[a]-1,d=r?h+1:h-1,g=`model_${e.sid}_clippingPlaneHelper_${a}`,P=this.ssp.getObjectById(g);if(p)if(P)switch(a){case"x":null==P||P.position.setX(d);break;case"y":null==P||P.position.setY(d);break;case"z":null==P||P.position.setZ(d)}else{const e=c.getSize(new s);let n=0,i=0,t="green";const l=c.getCenter(new s).clone(),r={x:0,y:0,z:0};switch(a){case"x":n=e.z,i=e.y,t="green",l.x=d,r.y=Math.PI/2;break;case"y":n=e.x,i=e.z,t="blue",l.y=d,r.x=Math.PI/2;break;case"z":n=e.x,i=e.y,l.z=d,t="red"}this.addPlaneHelper(a,{id:g,width:n,height:i,color:t,position:l,rotation:r})}else P&&this.ssp.removeObjectById(g);const m={x:new s(r?-1:1,0,0),y:new s(0,r?-1:1,0),z:new s(0,0,r?-1:1)};e.traverse((e=>{if(e.material){const s=e,i=e=>{e.clippingPlanes||(e.clippingPlanes=[]);const s=e.clippingPlanes.find((e=>1===Math.abs(e.normal[a])));if(s)s.normal=m[a],s.constant=h,r||s.negate();else{const s=new n(m[a],h);r||s.negate(),e.clippingPlanes.push(s)}};Array.isArray(s.material)?s.material.forEach((e=>i(e))):i(s.material)}})),this.ssp.signals.sceneChanged.dispatch()}removeModelClipping(e,s){const n=e=>{if(s){const n=e.clippingPlanes.findIndex((e=>1===Math.abs(e.normal[s])));e.clippingPlanes.splice(n,1)}else e.clippingPlanes=[]};e.traverse((e=>{if(e.material){const s=e;Array.isArray(s.material)?s.material.forEach((e=>n(e))):n(s.material)}})),this.ssp.signals.sceneChanged.dispatch()}}export{t as default};
1
+ import e from"soonspacejs";import{Vector3 as s,Plane as n,Box3 as i}from"three";class t{constructor(e){this.ssp=e,this.scenePlaneHelpers={x:null,y:null,z:null}}addPlaneHelper(e,s,n){const i=this.ssp.addPlaneHelper(Object.assign(Object.assign({},s),{opacity:.3}));this.scenePlaneHelpers[e]=i,n&&this.ssp.addObject(i,n)}sceneClipping(i){var t,a,l;const{axis:r,clipPoint:p,isForward:c=!0,openHelper:o=!0}=i,h=c?p-1:1-p,d=`scene_clippingPlaneHelper_${r}`;if(o)if(this.scenePlaneHelpers[r])switch(r){case"x":null===(t=this.scenePlaneHelpers[r])||void 0===t||t.position.setX(h);break;case"y":null===(a=this.scenePlaneHelpers[r])||void 0===a||a.position.setY(h);break;case"z":null===(l=this.scenePlaneHelpers[r])||void 0===l||l.position.setZ(h)}else{const n=e.utils.getBoundingBox(this.ssp.viewport.scene),i=n.getSize(new s);let t=0,a=0,l="green";const p=n.getCenter(new s).clone(),c={x:0,y:0,z:0};switch(r){case"x":t=i.z,a=i.y,l="green",p.x=h,c.y=Math.PI/2;break;case"y":t=i.x,a=i.z,l="blue",p.y=h,c.x=Math.PI/2;break;case"z":t=i.x,a=i.y,p.z=h,l="red"}this.addPlaneHelper(r,{id:d,width:t,height:a,color:l,position:p,rotation:c})}else this.scenePlaneHelpers[r]&&(this.ssp.removeHelperById(d),this.scenePlaneHelpers[r]=null);const g={x:new s(c?-1:1,0,0),y:new s(0,c?-1:1,0),z:new s(0,0,c?-1:1)},P=this.ssp.viewport.renderer.clippingPlanes.find((e=>1===Math.abs(e.normal[r])));if(P)P.normal=g[r],P.constant=p;else{this.ssp.viewport.renderer.clippingPlanes.push(new n(g[r],p))}this.ssp.signals.sceneChanged.dispatch()}removeSceneClipping(e){if(e){const s=this.ssp.viewport.renderer.clippingPlanes,n=s.findIndex((s=>1===Math.abs(s.normal[e])));s.splice(n,1)}else this.ssp.viewport.renderer.clippingPlanes=[];this.ssp.signals.sceneChanged.dispatch()}modelClipping(e,t){const{axis:a,clipPercent:l,isForward:r=!0,openHelper:p=!0}=t,c=(new i).setFromObject(e);c.max.add(new s(2,2,2)),c.min.sub(new s(2,2,2));const o=c.getSize(new s),h=r?c.max[a]-l/100*o[a]+1:c.min[a]+l/100*o[a]-1,d=r?h+1:h-1,g=`model_${e.sid}_clippingPlaneHelper_${a}`,P=this.ssp.getObjectById(g);if(p)if(P)switch(a){case"x":null==P||P.position.setX(d);break;case"y":null==P||P.position.setY(d);break;case"z":null==P||P.position.setZ(d)}else{const e=c.getSize(new s);let n=0,i=0,t="green";const l=c.getCenter(new s).clone(),r={x:0,y:0,z:0};switch(a){case"x":n=e.z,i=e.y,t="green",l.x=d,r.y=Math.PI/2;break;case"y":n=e.x,i=e.z,t="blue",l.y=d,r.x=Math.PI/2;break;case"z":n=e.x,i=e.y,l.z=d,t="red"}this.addPlaneHelper(a,{id:g,width:n,height:i,color:t,position:l,rotation:r})}else P&&this.ssp.removeObjectById(g);const m={x:new s(r?-1:1,0,0),y:new s(0,r?-1:1,0),z:new s(0,0,r?-1:1)};e.traverse((e=>{if(e.material){const s=e,i=e=>{e.clippingPlanes||(e.clippingPlanes=[]);const s=e.clippingPlanes.find((e=>1===Math.abs(e.normal[a])));if(s)s.normal=m[a],s.constant=h,r||s.negate();else{const s=new n(m[a],h);r||s.negate(),e.clippingPlanes.push(s)}};Array.isArray(s.material)?s.material.forEach((e=>i(e))):i(s.material)}})),this.ssp.signals.sceneChanged.dispatch()}removeModelClipping(e,s){const n=e=>{if(s){if(e.clippingPlanes){const n=e.clippingPlanes.findIndex((e=>1===Math.abs(e.normal[s])));e.clippingPlanes.splice(n,1)}}else e.clippingPlanes=[]};e.traverse((e=>{if(e.material){const s=e;Array.isArray(s.material)?s.material.forEach((e=>n(e))):n(s.material)}})),this.ssp.signals.sceneChanged.dispatch()}}export{t as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-clipping-controls",
3
3
  "pluginName": "ClippingControlsPlugin",
4
- "version": "2.10.11",
4
+ "version": "2.10.12",
5
5
  "description": "Clipping controls plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,8 +13,8 @@
13
13
  ],
14
14
  "author": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "ae1c93fb5b93a5b26b3726a72b881a7c81d41aaf",
16
+ "gitHead": "28f8f552a3a8a0cea3d59ad6215396746d17bbd5",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.10.11"
18
+ "soonspacejs": "2.10.12"
19
19
  }
20
20
  }