@soonspacejs/plugin-clipping-controls 2.4.1 → 2.4.4
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
class e{constructor(e){this.ssp=e,this.scenePlaneHelpers={x:null,y:null,z:null}}addPlaneHelper(e,s,n){const i=this.ssp.addPlaneHelper({...s,opacity:.3});this.scenePlaneHelpers[e]=i,n&&this.ssp.addObject(i,n)}sceneClipping(e){var s,n,i;const{axis:t,clipPoint:a,isForward:l=!0,openHelper:r=!0}=e,p=l?a-1:1-a,c=`scene_clippingPlaneHelper_${t}`;if(r)if(this.scenePlaneHelpers[t])switch(t){case"x":null===(s=this.scenePlaneHelpers[t])||void 0===s||s.position.setX(p);break;case"y":null===(n=this.scenePlaneHelpers[t])||void 0===n||n.position.setY(p);break;case"z":null===(i=this.scenePlaneHelpers[t])||void 0===i||i.position.setZ(p)}else{const e=(new this.ssp.THREE.Box3).setFromObject(this.ssp.manager.store.sbmManager.scene),s=(new this.ssp.THREE.Box3).setFromObject(this.ssp.manager.store.modelManager.scene),n=e.clone().union(s.clone()),i=n.getSize(new this.ssp.THREE.Vector3);let a=0,l=0,r="green";const o=n.getCenter(new this.ssp.THREE.Vector3).clone(),h={x:0,y:0,z:0};switch(t){case"x":a=i.z,l=i.y,r="green",o.x=p,h.y=Math.PI/2;break;case"y":a=i.x,l=i.z,r="blue",o.y=p,h.x=Math.PI/2;break;case"z":a=i.x,l=i.y,o.z=p,r="red"}this.addPlaneHelper(t,{id:c,width:a,height:l,color:r,position:o,rotation:h})}else this.scenePlaneHelpers[t]&&(this.ssp.removeHelperById(c),this.scenePlaneHelpers[t]=null);const o={x:new this.ssp.THREE.Vector3(l?-1:1,0,0),y:new this.ssp.THREE.Vector3(0,l?-1:1,0),z:new this.ssp.THREE.Vector3(0,0,l?-1:1)},h=this.ssp.viewport.renderer.clippingPlanes.find((e=>1===Math.abs(e.normal[t])));h?(h.normal=o[t],h.constant=a):this.ssp.viewport.renderer.clippingPlanes.push(new this.ssp.THREE.Plane(o[t],a)),this.ssp.signals.sceneChanged.dispatch()}removeSceneClipping(e){if(e){const s=this.ssp.viewport.renderer.clippingPlanes.findIndex((s=>1===Math.abs(s.normal[e])));this.ssp.viewport.renderer.clippingPlanes.splice(s,1)}else this.ssp.viewport.renderer.clippingPlanes=[];this.ssp.signals.sceneChanged.dispatch()}modelClipping(e,s){const{axis:n,clipPercent:i,isForward:t=!0,openHelper:a=!0}=s,l=(new this.ssp.THREE.Box3).setFromObject(e);l.max.add(new this.ssp.THREE.Vector3(2,2,2)),l.min.sub(new this.ssp.THREE.Vector3(2,2,2));const r=l.getSize(new this.ssp.THREE.Vector3),p=t?l.max[n]-i/100*r[n]+1:l.min[n]+i/100*r[n]-1,c=t?p+1:p-1,o=`model_${e.sid}_clippingPlaneHelper_${n}`,h=this.ssp.getObjectById(o);if(a)if(h)switch(n){case"x":null==h||h.position.setX(c);break;case"y":null==h||h.position.setY(c);break;case"z":null==h||h.position.setZ(c)}else{const e=l.getSize(new this.ssp.THREE.Vector3);let s=0,i=0,t="green";const a=l.getCenter(new this.ssp.THREE.Vector3).clone(),r={x:0,y:0,z:0};switch(n){case"x":s=e.z,i=e.y,t="green",a.x=c,r.y=Math.PI/2;break;case"y":s=e.x,i=e.z,t="blue",a.y=c,r.x=Math.PI/2;break;case"z":s=e.x,i=e.y,a.z=c,t="red"}this.addPlaneHelper(n,{id:o,width:s,height:i,color:t,position:a,rotation:r})}else h&&this.ssp.removeObjectById(o);const d={x:new this.ssp.THREE.Vector3(t?-1:1,0,0),y:new this.ssp.THREE.Vector3(0,t?-1:1,0),z:new this.ssp.THREE.Vector3(0,0,t?-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[n])));if(s)s.normal=d[n],s.constant=p,t||s.negate();else{const s=new this.ssp.THREE.Plane(d[n],p);t||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=null};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{e as default};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(e="undefined"!=typeof globalThis?globalThis:e||self).ClippingControlsPlugin=s()}(this,(function(){"use strict";return class{constructor(e){this.ssp=e,this.scenePlaneHelpers={x:null,y:null,z:null}}addPlaneHelper(e,s,n){const i=this.ssp.addPlaneHelper({...s,opacity:.3});this.scenePlaneHelpers[e]=i,n&&this.ssp.addObject(i,n)}sceneClipping(e){var s,n,i;const{axis:t,clipPoint:l,isForward:a=!0,openHelper:r=!0}=e,p=a?l-1:1-l,o=`scene_clippingPlaneHelper_${t}`;if(r)if(this.scenePlaneHelpers[t])switch(t){case"x":null===(s=this.scenePlaneHelpers[t])||void 0===s||s.position.setX(p);break;case"y":null===(n=this.scenePlaneHelpers[t])||void 0===n||n.position.setY(p);break;case"z":null===(i=this.scenePlaneHelpers[t])||void 0===i||i.position.setZ(p)}else{const e=(new this.ssp.THREE.Box3).setFromObject(this.ssp.manager.store.sbmManager.scene),s=(new this.ssp.THREE.Box3).setFromObject(this.ssp.manager.store.modelManager.scene),n=e.clone().union(s.clone()),i=n.getSize(new this.ssp.THREE.Vector3);let l=0,a=0,r="green";const c=n.getCenter(new this.ssp.THREE.Vector3).clone(),h={x:0,y:0,z:0};switch(t){case"x":l=i.z,a=i.y,r="green",c.x=p,h.y=Math.PI/2;break;case"y":l=i.x,a=i.z,r="blue",c.y=p,h.x=Math.PI/2;break;case"z":l=i.x,a=i.y,c.z=p,r="red"}this.addPlaneHelper(t,{id:o,width:l,height:a,color:r,position:c,rotation:h})}else this.scenePlaneHelpers[t]&&(this.ssp.removeHelperById(o),this.scenePlaneHelpers[t]=null);const c={x:new this.ssp.THREE.Vector3(a?-1:1,0,0),y:new this.ssp.THREE.Vector3(0,a?-1:1,0),z:new this.ssp.THREE.Vector3(0,0,a?-1:1)},h=this.ssp.viewport.renderer.clippingPlanes.find((e=>1===Math.abs(e.normal[t])));h?(h.normal=c[t],h.constant=l):this.ssp.viewport.renderer.clippingPlanes.push(new this.ssp.THREE.Plane(c[t],l)),this.ssp.signals.sceneChanged.dispatch()}removeSceneClipping(e){if(e){const s=this.ssp.viewport.renderer.clippingPlanes.findIndex((s=>1===Math.abs(s.normal[e])));this.ssp.viewport.renderer.clippingPlanes.splice(s,1)}else this.ssp.viewport.renderer.clippingPlanes=[];this.ssp.signals.sceneChanged.dispatch()}modelClipping(e,s){const{axis:n,clipPercent:i,isForward:t=!0,openHelper:l=!0}=s,a=(new this.ssp.THREE.Box3).setFromObject(e);a.max.add(new this.ssp.THREE.Vector3(2,2,2)),a.min.sub(new this.ssp.THREE.Vector3(2,2,2));const r=a.getSize(new this.ssp.THREE.Vector3),p=t?a.max[n]-i/100*r[n]+1:a.min[n]+i/100*r[n]-1,o=t?p+1:p-1,c=`model_${e.sid}_clippingPlaneHelper_${n}`,h=this.ssp.
|
|
1
|
+
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(e="undefined"!=typeof globalThis?globalThis:e||self).ClippingControlsPlugin=s()}(this,(function(){"use strict";return class{constructor(e){this.ssp=e,this.scenePlaneHelpers={x:null,y:null,z:null}}addPlaneHelper(e,s,n){const i=this.ssp.addPlaneHelper({...s,opacity:.3});this.scenePlaneHelpers[e]=i,n&&this.ssp.addObject(i,n)}sceneClipping(e){var s,n,i;const{axis:t,clipPoint:l,isForward:a=!0,openHelper:r=!0}=e,p=a?l-1:1-l,o=`scene_clippingPlaneHelper_${t}`;if(r)if(this.scenePlaneHelpers[t])switch(t){case"x":null===(s=this.scenePlaneHelpers[t])||void 0===s||s.position.setX(p);break;case"y":null===(n=this.scenePlaneHelpers[t])||void 0===n||n.position.setY(p);break;case"z":null===(i=this.scenePlaneHelpers[t])||void 0===i||i.position.setZ(p)}else{const e=(new this.ssp.THREE.Box3).setFromObject(this.ssp.manager.store.sbmManager.scene),s=(new this.ssp.THREE.Box3).setFromObject(this.ssp.manager.store.modelManager.scene),n=e.clone().union(s.clone()),i=n.getSize(new this.ssp.THREE.Vector3);let l=0,a=0,r="green";const c=n.getCenter(new this.ssp.THREE.Vector3).clone(),h={x:0,y:0,z:0};switch(t){case"x":l=i.z,a=i.y,r="green",c.x=p,h.y=Math.PI/2;break;case"y":l=i.x,a=i.z,r="blue",c.y=p,h.x=Math.PI/2;break;case"z":l=i.x,a=i.y,c.z=p,r="red"}this.addPlaneHelper(t,{id:o,width:l,height:a,color:r,position:c,rotation:h})}else this.scenePlaneHelpers[t]&&(this.ssp.removeHelperById(o),this.scenePlaneHelpers[t]=null);const c={x:new this.ssp.THREE.Vector3(a?-1:1,0,0),y:new this.ssp.THREE.Vector3(0,a?-1:1,0),z:new this.ssp.THREE.Vector3(0,0,a?-1:1)},h=this.ssp.viewport.renderer.clippingPlanes.find((e=>1===Math.abs(e.normal[t])));h?(h.normal=c[t],h.constant=l):this.ssp.viewport.renderer.clippingPlanes.push(new this.ssp.THREE.Plane(c[t],l)),this.ssp.signals.sceneChanged.dispatch()}removeSceneClipping(e){if(e){const s=this.ssp.viewport.renderer.clippingPlanes.findIndex((s=>1===Math.abs(s.normal[e])));this.ssp.viewport.renderer.clippingPlanes.splice(s,1)}else this.ssp.viewport.renderer.clippingPlanes=[];this.ssp.signals.sceneChanged.dispatch()}modelClipping(e,s){const{axis:n,clipPercent:i,isForward:t=!0,openHelper:l=!0}=s,a=(new this.ssp.THREE.Box3).setFromObject(e);a.max.add(new this.ssp.THREE.Vector3(2,2,2)),a.min.sub(new this.ssp.THREE.Vector3(2,2,2));const r=a.getSize(new this.ssp.THREE.Vector3),p=t?a.max[n]-i/100*r[n]+1:a.min[n]+i/100*r[n]-1,o=t?p+1:p-1,c=`model_${e.sid}_clippingPlaneHelper_${n}`,h=this.ssp.getObjectById(c);if(l)if(h)switch(n){case"x":null==h||h.position.setX(o);break;case"y":null==h||h.position.setY(o);break;case"z":null==h||h.position.setZ(o)}else{const e=a.getSize(new this.ssp.THREE.Vector3);let s=0,i=0,t="green";const l=a.getCenter(new this.ssp.THREE.Vector3).clone(),r={x:0,y:0,z:0};switch(n){case"x":s=e.z,i=e.y,t="green",l.x=o,r.y=Math.PI/2;break;case"y":s=e.x,i=e.z,t="blue",l.y=o,r.x=Math.PI/2;break;case"z":s=e.x,i=e.y,l.z=o,t="red"}this.addPlaneHelper(n,{id:c,width:s,height:i,color:t,position:l,rotation:r})}else h&&this.ssp.removeObjectById(c);const d={x:new this.ssp.THREE.Vector3(t?-1:1,0,0),y:new this.ssp.THREE.Vector3(0,t?-1:1,0),z:new this.ssp.THREE.Vector3(0,0,t?-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[n])));if(s)s.normal=d[n],s.constant=p,t||s.negate();else{const s=new this.ssp.THREE.Plane(d[n],p);t||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=null};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()}}}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-clipping-controls",
|
|
3
3
|
"pluginName": "ClippingControlsPlugin",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.4",
|
|
5
5
|
"description": "Clipping controls plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xuek",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "73b20b95e4b94f6634bfde269b1a983f3f2db6f9"
|
|
17
17
|
}
|