@ridp/threejs 1.3.1 → 1.3.2
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/{common-D1_IztgM.js → common-C8KE_lHC.js} +1 -1
- package/dist/{common-C1rNPPkt.cjs → common-lRDriwln.cjs} +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +1 -1
- package/dist/modelSerialize-BJf_M0Ys.cjs +5 -0
- package/dist/{modelSerialize-5oJb1ka7.js → modelSerialize-BybDeWER.js} +453 -335
- package/dist/threejs.cjs +1 -1
- package/dist/threejs.js +26 -24
- package/dist/{useGLTFLoader-kuE8ICl_.js → useGLTFLoader-C73cebsn.js} +4 -3
- package/dist/{useGLTFLoader-B6Cm6xQg.cjs → useGLTFLoader-Csew3AhP.cjs} +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +12 -10
- package/package.json +1 -1
- package/dist/modelSerialize-Ds_2KBaA.cjs +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const c=require("./modelSerialize-
|
|
1
|
+
"use strict";const c=require("./modelSerialize-BJf_M0Ys.cjs");function i(o,t=[.3,.3,.3]){const e=document.querySelector(`#${o}`);if(!e){console.log(" 获取 infoPlane 元素失败 (id) =====> :",o);return}const n=e.cloneNode(!0);n.style.display="block";const r=new c.CSS3DSprite(n);return r.visible=!1,r.scale.set(...t),r}function s(o,t){const e=u(o);e.style.display="block";const n=new c.CSS3DSprite(e);return n.visible=!1,n.scale.set(t,t,t),n}const u=o=>{const t=document.createElement("div");t.style.cssText=`
|
|
2
2
|
border-radius: 50px;
|
|
3
3
|
border: 2px solid rgba(255, 255, 255, 0.5);
|
|
4
4
|
background-color: rgba(15, 20, 22, 0.562);
|
package/dist/hooks.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-Csew3AhP.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useGLTFLoader=e.useGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;
|
package/dist/hooks.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const a=require("three");function dt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const O=dt(a);var z=function(){var e=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(_){_.preventDefault(),s(++e%t.children.length)},!1);function i(_){return t.appendChild(_.dom),_}function s(_){for(var c=0;c<t.children.length;c++)t.children[c].style.display=c===_?"block":"none";e=_}var l=(performance||Date).now(),r=l,n=0,p=i(new z.Panel("FPS","#0ff","#002")),u=i(new z.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var b=i(new z.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:t,addPanel:i,showPanel:s,begin:function(){l=(performance||Date).now()},end:function(){n++;var _=(performance||Date).now();if(u.update(_-l,200),_>=r+1e3&&(p.update(n*1e3/(_-r),100),r=_,n=0,b)){var c=performance.memory;b.update(c.usedJSHeapSize/1048576,c.jsHeapSizeLimit/1048576)}return _},update:function(){l=this.end()},domElement:t,setMode:s}};z.Panel=function(e,t,i){var s=1/0,l=0,r=Math.round,n=r(window.devicePixelRatio||1),p=80*n,u=48*n,b=3*n,_=2*n,c=3*n,v=15*n,L=74*n,C=30*n,k=document.createElement("canvas");k.width=p,k.height=u,k.style.cssText="width:80px;height:48px";var h=k.getContext("2d");return h.font="bold "+9*n+"px Helvetica,Arial,sans-serif",h.textBaseline="top",h.fillStyle=i,h.fillRect(0,0,p,u),h.fillStyle=t,h.fillText(e,b,_),h.fillRect(c,v,L,C),h.fillStyle=i,h.globalAlpha=.9,h.fillRect(c,v,L,C),{dom:k,update:function(o,P){s=Math.min(s,o),l=Math.max(l,o),h.fillStyle=i,h.globalAlpha=1,h.fillRect(0,0,p,v),h.fillStyle=t,h.fillText(r(o)+" "+e+" ("+r(s)+"-"+r(l)+")",b,_),h.drawImage(k,c+n,v,L-n,C,c,v,L-n,C),h.fillRect(c+L-n,v,n,C),h.fillStyle=i,h.globalAlpha=.9,h.fillRect(c+L-n,v,n,r((1-o/P)*C))}}};const it=new a.Vector3,ut=new a.Quaternion,st=new a.Vector3;class mt extends a.Object3D{constructor(t=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=t,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(i){i.element instanceof i.element.ownerDocument.defaultView.Element&&i.element.parentNode!==null&&i.element.remove()})})}copy(t,i){return super.copy(t,i),this.element=t.element.cloneNode(!0),this}}class _t extends mt{constructor(t){super(t),this.isCSS3DSprite=!0,this.rotation2D=0}copy(t,i){return super.copy(t,i),this.rotation2D=t.rotation2D,this}}const I=new a.Matrix4,ft=new a.Matrix4;class yt{constructor(t={}){const i=this;let s,l,r,n;const p={camera:{style:""},objects:new WeakMap},u=t.element!==void 0?t.element:document.createElement("div");u.style.overflow="hidden",this.domElement=u;const b=document.createElement("div");b.style.transformOrigin="0 0",b.style.pointerEvents="none",u.appendChild(b);const _=document.createElement("div");_.style.transformStyle="preserve-3d",b.appendChild(_),this.getSize=function(){return{width:s,height:l}},this.render=function(h,o){const P=o.projectionMatrix.elements[5]*n;o.view&&o.view.enabled?(b.style.transform=`translate( ${-o.view.offsetX*(s/o.view.width)}px, ${-o.view.offsetY*(l/o.view.height)}px )`,b.style.transform+=`scale( ${o.view.fullWidth/o.view.width}, ${o.view.fullHeight/o.view.height} )`):b.style.transform="",h.matrixWorldAutoUpdate===!0&&h.updateMatrixWorld(),o.parent===null&&o.matrixWorldAutoUpdate===!0&&o.updateMatrixWorld();let F,A;o.isOrthographicCamera&&(F=-(o.right+o.left)/2,A=(o.top+o.bottom)/2);const x=o.view&&o.view.enabled?o.view.height/o.view.fullHeight:1,H=o.isOrthographicCamera?`scale( ${x} )scale(`+P+")translate("+c(F)+"px,"+c(A)+"px)"+v(o.matrixWorldInverse):`scale( ${x} )translateZ(`+P+"px)"+v(o.matrixWorldInverse),d=(o.isPerspectiveCamera?"perspective("+P+"px) ":"")+H+"translate("+r+"px,"+n+"px)";p.camera.style!==d&&(_.style.transform=d,p.camera.style=d),k(h,h,o)},this.setSize=function(h,o){s=h,l=o,r=s/2,n=l/2,u.style.width=h+"px",u.style.height=o+"px",b.style.width=h+"px",b.style.height=o+"px",_.style.width=h+"px",_.style.height=o+"px"};function c(h){return Math.abs(h)<1e-10?0:h}function v(h){const o=h.elements;return"matrix3d("+c(o[0])+","+c(-o[1])+","+c(o[2])+","+c(o[3])+","+c(o[4])+","+c(-o[5])+","+c(o[6])+","+c(o[7])+","+c(o[8])+","+c(-o[9])+","+c(o[10])+","+c(o[11])+","+c(o[12])+","+c(-o[13])+","+c(o[14])+","+c(o[15])+")"}function L(h){const o=h.elements;return"translate(-50%,-50%)"+("matrix3d("+c(o[0])+","+c(o[1])+","+c(o[2])+","+c(o[3])+","+c(-o[4])+","+c(-o[5])+","+c(-o[6])+","+c(-o[7])+","+c(o[8])+","+c(o[9])+","+c(o[10])+","+c(o[11])+","+c(o[12])+","+c(o[13])+","+c(o[14])+","+c(o[15])+")")}function C(h){h.isCSS3DObject&&(h.element.style.display="none");for(let o=0,P=h.children.length;o<P;o++)C(h.children[o])}function k(h,o,P,F){if(h.visible===!1){C(h);return}if(h.isCSS3DObject){const A=h.layers.test(P.layers)===!0,x=h.element;if(x.style.display=A===!0?"":"none",A===!0){h.onBeforeRender(i,o,P);let H;h.isCSS3DSprite?(I.copy(P.matrixWorldInverse),I.transpose(),h.rotation2D!==0&&I.multiply(ft.makeRotationZ(h.rotation2D)),h.matrixWorld.decompose(it,ut,st),I.setPosition(it),I.scale(st),I.elements[3]=0,I.elements[7]=0,I.elements[11]=0,I.elements[15]=1,H=L(I)):H=L(h.matrixWorld);const j=p.objects.get(h);if(j===void 0||j.style!==H){x.style.transform=H;const d={style:H};p.objects.set(h,d)}x.parentNode!==_&&_.appendChild(x),h.onAfterRender(i,o,P)}}for(let A=0,x=h.children.length;A<x;A++)k(h.children[A],o,P)}}}const ot={type:"change"},J={type:"start"},rt={type:"end"},B=new a.Ray,nt=new a.Plane,gt=Math.cos(70*a.MathUtils.DEG2RAD),M=new a.Vector3,R=2*Math.PI,f={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},q=1e-6;class lt extends a.Controls{constructor(t,i=null){super(t,i),this.state=f.NONE,this.target=new a.Vector3,this.cursor=new a.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:a.MOUSE.ROTATE,MIDDLE:a.MOUSE.DOLLY,RIGHT:a.MOUSE.PAN},this.touches={ONE:a.TOUCH.ROTATE,TWO:a.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new a.Vector3,this._lastQuaternion=new a.Quaternion,this._lastTargetPosition=new a.Vector3,this._quat=new a.Quaternion().setFromUnitVectors(t.up,new a.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new a.Spherical,this._sphericalDelta=new a.Spherical,this._scale=1,this._panOffset=new a.Vector3,this._rotateStart=new a.Vector2,this._rotateEnd=new a.Vector2,this._rotateDelta=new a.Vector2,this._panStart=new a.Vector2,this._panEnd=new a.Vector2,this._panDelta=new a.Vector2,this._dollyStart=new a.Vector2,this._dollyEnd=new a.Vector2,this._dollyDelta=new a.Vector2,this._dollyDirection=new a.Vector3,this._mouse=new a.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Et.bind(this),this._onPointerDown=bt.bind(this),this._onPointerUp=wt.bind(this),this._onContextMenu=At.bind(this),this._onMouseWheel=Tt.bind(this),this._onKeyDown=Mt.bind(this),this._onTouchStart=Pt.bind(this),this._onTouchMove=Ot.bind(this),this._onMouseDown=Dt.bind(this),this._onMouseMove=St.bind(this),this._interceptControlDown=Rt.bind(this),this._interceptControlUp=xt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ot),this.update(),this.state=f.NONE}update(t=null){const i=this.object.position;M.copy(i).sub(this.target),M.applyQuaternion(this._quat),this._spherical.setFromVector3(M),this.autoRotate&&this.state===f.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,l=this.maxAzimuthAngle;isFinite(s)&&isFinite(l)&&(s<-Math.PI?s+=R:s>Math.PI&&(s-=R),l<-Math.PI?l+=R:l>Math.PI&&(l-=R),s<=l?this._spherical.theta=Math.max(s,Math.min(l,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+l)/2?Math.max(s,this._spherical.theta):Math.min(l,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const n=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=n!=this._spherical.radius}if(M.setFromSpherical(this._spherical),M.applyQuaternion(this._quatInverse),i.copy(this.target).add(M),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let n=null;if(this.object.isPerspectiveCamera){const p=M.length();n=this._clampDistance(p*this._scale);const u=p-n;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),r=!!u}else if(this.object.isOrthographicCamera){const p=new a.Vector3(this._mouse.x,this._mouse.y,0);p.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=u!==this.object.zoom;const b=new a.Vector3(this._mouse.x,this._mouse.y,0);b.unproject(this.object),this.object.position.sub(b).add(p),this.object.updateMatrixWorld(),n=M.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;n!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(n).add(this.object.position):(B.origin.copy(this.object.position),B.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(B.direction))<gt?this.object.lookAt(this.target):(nt.setFromNormalAndCoplanarPoint(this.object.up,this.target),B.intersectPlane(nt,this.target))))}else if(this.object.isOrthographicCamera){const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),n!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>q||8*(1-this._lastQuaternion.dot(this.object.quaternion))>q||this._lastTargetPosition.distanceToSquared(this.target)>q?(this.dispatchEvent(ot),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?R/60*this.autoRotateSpeed*t:R/60/60*this.autoRotateSpeed}_getZoomScale(t){const i=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*i)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,i){M.setFromMatrixColumn(i,0),M.multiplyScalar(-t),this._panOffset.add(M)}_panUp(t,i){this.screenSpacePanning===!0?M.setFromMatrixColumn(i,1):(M.setFromMatrixColumn(i,0),M.crossVectors(this.object.up,M)),M.multiplyScalar(t),this._panOffset.add(M)}_pan(t,i){const s=this.domElement;if(this.object.isPerspectiveCamera){const l=this.object.position;M.copy(l).sub(this.target);let r=M.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/s.clientHeight,this.object.matrix),this._panUp(2*i*r/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(i*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,i){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),l=t-s.left,r=i-s.top,n=s.width,p=s.height;this._mouse.x=l/n*2-1,this._mouse.y=-(r/p)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const i=this.domElement;this._rotateLeft(R*this._rotateDelta.x/i.clientHeight),this._rotateUp(R*this._rotateDelta.y/i.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let i=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(R*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),i=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-R*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),i=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(R*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),i=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-R*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),i=!0;break}i&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),s=.5*(t.pageX+i.x),l=.5*(t.pageY+i.y);this._rotateStart.set(s,l)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),s=.5*(t.pageX+i.x),l=.5*(t.pageY+i.y);this._panStart.set(s,l)}}_handleTouchStartDolly(t){const i=this._getSecondPointerPosition(t),s=t.pageX-i.x,l=t.pageY-i.y,r=Math.sqrt(s*s+l*l);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const s=this._getSecondPointerPosition(t),l=.5*(t.pageX+s.x),r=.5*(t.pageY+s.y);this._rotateEnd.set(l,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const i=this.domElement;this._rotateLeft(R*this._rotateDelta.x/i.clientHeight),this._rotateUp(R*this._rotateDelta.y/i.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),s=.5*(t.pageX+i.x),l=.5*(t.pageY+i.y);this._panEnd.set(s,l)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const i=this._getSecondPointerPosition(t),s=t.pageX-i.x,l=t.pageY-i.y,r=Math.sqrt(s*s+l*l);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const n=(t.pageX+i.x)*.5,p=(t.pageY+i.y)*.5;this._updateZoomParameters(n,p)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let i=0;i<this._pointers.length;i++)if(this._pointers[i]==t.pointerId){this._pointers.splice(i,1);return}}_isTrackingPointer(t){for(let i=0;i<this._pointers.length;i++)if(this._pointers[i]==t.pointerId)return!0;return!1}_trackPointer(t){let i=this._pointerPositions[t.pointerId];i===void 0&&(i=new a.Vector2,this._pointerPositions[t.pointerId]=i),i.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const i=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[i]}_customWheelEvent(t){const i=t.deltaMode,s={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(i){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function bt(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType==="touch"?this._onTouchStart(e):this._onMouseDown(e)))}function Et(e){this.enabled!==!1&&(e.pointerType==="touch"?this._onTouchMove(e):this._onMouseMove(e))}function wt(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(rt),this.state=f.NONE;break;case 1:const t=this._pointers[0],i=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:i.x,pageY:i.y});break}}function Dt(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case a.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=f.DOLLY;break;case a.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=f.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=f.ROTATE}break;case a.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=f.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=f.PAN}break;default:this.state=f.NONE}this.state!==f.NONE&&this.dispatchEvent(J)}function St(e){switch(this.state){case f.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case f.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case f.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function Tt(e){this.enabled===!1||this.enableZoom===!1||this.state!==f.NONE||(e.preventDefault(),this.dispatchEvent(J),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(rt))}function Mt(e){this.enabled!==!1&&this._handleKeyDown(e)}function Pt(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case a.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=f.TOUCH_ROTATE;break;case a.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=f.TOUCH_PAN;break;default:this.state=f.NONE}break;case 2:switch(this.touches.TWO){case a.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=f.TOUCH_DOLLY_PAN;break;case a.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=f.TOUCH_DOLLY_ROTATE;break;default:this.state=f.NONE}break;default:this.state=f.NONE}this.state!==f.NONE&&this.dispatchEvent(J)}function Ot(e){switch(this._trackPointer(e),this.state){case f.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case f.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case f.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case f.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=f.NONE}}function At(e){this.enabled!==!1&&e.preventDefault()}function Rt(e){e.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function xt(e){e.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class vt extends lt{constructor(t,i){super(t,i),this.screenSpacePanning=!1,this.mouseButtons={LEFT:a.MOUSE.PAN,MIDDLE:a.MOUSE.DOLLY,RIGHT:a.MOUSE.ROTATE},this.touches={ONE:a.TOUCH.PAN,TWO:a.TOUCH.DOLLY_ROTATE}}}function Lt(e){return new a.CameraHelper(e)}function Ct(e=150,...t){return new a.GridHelper(e,e/10,...t)}function kt(e){return new a.BoxHelper(e,16776960)}function Ht(e,t){return new lt(e,t)}function jt(e,t){return new vt(e,t)}function It(){const e=new a.Raycaster,t=new a.Vector2(0,0);return{raycaster:e,pointer:t}}function Ut(e=10){return new a.AxesHelper(e)}function Nt(e=new a.Vector3(1,1,1),t=new a.Vector3(10,10,10),i=5,s=16776960){return e.normalize(),new a.ArrowHelper(e,t,i,s)}function Gt(){const e=new z;return e.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e}class Ft extends a.DataTextureLoader{constructor(t){super(t),this.type=a.HalfFloatType}parse(t){const n=function(d,y){switch(d){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(y||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(y||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(y||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(y||""))}},_=`
|
|
2
|
+
`,c=function(d,y,E){y=y||1024;let S=d.pos,D=-1,m=0,T="",g=String.fromCharCode.apply(null,new Uint16Array(d.subarray(S,S+128)));for(;0>(D=g.indexOf(_))&&m<y&&S<d.byteLength;)T+=g,m+=g.length,S+=128,g+=String.fromCharCode.apply(null,new Uint16Array(d.subarray(S,S+128)));return-1<D?(d.pos+=m+D+1,T+g.slice(0,D)):!1},v=function(d){const y=/^#\?(\S+)/,E=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,w=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*FORMAT=(\S+)\s*$/,D=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,m={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let T,g;for((d.pos>=d.byteLength||!(T=c(d)))&&n(1,"no header found"),(g=T.match(y))||n(3,"bad initial token"),m.valid|=1,m.programtype=g[1],m.string+=T+`
|
|
3
|
+
`;T=c(d),T!==!1;){if(m.string+=T+`
|
|
4
|
+
`,T.charAt(0)==="#"){m.comments+=T+`
|
|
5
|
+
`;continue}if((g=T.match(E))&&(m.gamma=parseFloat(g[1])),(g=T.match(w))&&(m.exposure=parseFloat(g[1])),(g=T.match(S))&&(m.valid|=2,m.format=g[1]),(g=T.match(D))&&(m.valid|=4,m.height=parseInt(g[1],10),m.width=parseInt(g[2],10)),m.valid&2&&m.valid&4)break}return m.valid&2||n(3,"missing format specifier"),m.valid&4||n(3,"missing image size specifier"),m},L=function(d,y,E){const w=y;if(w<8||w>32767||d[0]!==2||d[1]!==2||d[2]&128)return new Uint8Array(d);w!==(d[2]<<8|d[3])&&n(3,"wrong scanline width");const S=new Uint8Array(4*y*E);S.length||n(4,"unable to allocate buffer space");let D=0,m=0;const T=4*w,g=new Uint8Array(4),Y=new Uint8Array(T);let tt=E;for(;tt>0&&m<d.byteLength;){m+4>d.byteLength&&n(1),g[0]=d[m++],g[1]=d[m++],g[2]=d[m++],g[3]=d[m++],(g[0]!=2||g[1]!=2||(g[2]<<8|g[3])!=w)&&n(3,"bad rgbe scanline format");let V=0,U;for(;V<T&&m<d.byteLength;){U=d[m++];const N=U>128;if(N&&(U-=128),(U===0||V+U>T)&&n(3,"bad scanline data"),N){const G=d[m++];for(let et=0;et<U;et++)Y[V++]=G}else Y.set(d.subarray(m,m+U),V),V+=U,m+=U}const pt=w;for(let N=0;N<pt;N++){let G=0;S[D]=Y[N+G],G+=w,S[D+1]=Y[N+G],G+=w,S[D+2]=Y[N+G],G+=w,S[D+3]=Y[N+G],D+=4}tt--}return S},C=function(d,y,E,w){const S=d[y+3],D=Math.pow(2,S-128)/255;E[w+0]=d[y+0]*D,E[w+1]=d[y+1]*D,E[w+2]=d[y+2]*D,E[w+3]=1},k=function(d,y,E,w){const S=d[y+3],D=Math.pow(2,S-128)/255;E[w+0]=a.DataUtils.toHalfFloat(Math.min(d[y+0]*D,65504)),E[w+1]=a.DataUtils.toHalfFloat(Math.min(d[y+1]*D,65504)),E[w+2]=a.DataUtils.toHalfFloat(Math.min(d[y+2]*D,65504)),E[w+3]=a.DataUtils.toHalfFloat(1)},h=new Uint8Array(t);h.pos=0;const o=v(h),P=o.width,F=o.height,A=L(h.subarray(h.pos),P,F);let x,H,j;switch(this.type){case a.FloatType:j=A.length/4;const d=new Float32Array(j*4);for(let E=0;E<j;E++)C(A,E*4,d,E*4);x=d,H=a.FloatType;break;case a.HalfFloatType:j=A.length/4;const y=new Uint16Array(j*4);for(let E=0;E<j;E++)k(A,E*4,y,E*4);x=y,H=a.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:P,height:F,data:x,header:o.string,gamma:o.gamma,exposure:o.exposure,type:H}}setDataType(t){return this.type=t,this}load(t,i,s,l){function r(n,p){switch(n.type){case a.FloatType:case a.HalfFloatType:n.colorSpace=a.LinearSRGBColorSpace,n.minFilter=a.LinearFilter,n.magFilter=a.LinearFilter,n.generateMipmaps=!1,n.flipY=!0;break}i&&i(n,p)}return super.load(t,r,s,l)}}const ht=e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>{at(t)}):at(e.material)),e.children&&e.children.forEach(t=>ht(t))};function at(e){for(const t in e)e[t]&&e[t].isTexture&&e[t].dispose();e.dispose()}const $={},ct=new Ft;async function Yt(e,t){if(t){if($[t]){const i=$[t];e.environment=i;return}return new Promise((i,s)=>{ct.load(t,i,void 0,s)}).then(i=>{i.mapping=a.EquirectangularReflectionMapping,e.environment=i,$[t]=i}).catch(i=>{console.log(" =====> e:",i)})}}async function zt(e){return new Promise((t,i)=>{ct.load(e,t,void 0,i)})}const Q={};async function Vt(e,t=50){const i={type:e.type,name:e.name,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,children:[],geometry:null,material:null,userData:e.userData};e.isMesh&&(i.geometry=Z(e.geometry),i.material=K(e.material));const s=[{object:e,parentData:i}];let l=0;for(;s.length>0;){const{object:r,parentData:n}=s.pop();for(const p of r.children){const u={type:p.type,name:p.name,position:p.position.toArray(),rotation:p.rotation.toArray(),scale:p.scale.toArray(),visible:p.visible,children:[],geometry:null,material:null,userData:p.userData};p.isMesh&&(u.geometry=Z(p.geometry),u.material=K(p.material)),n.children.push(u),s.push({object:p,parentData:u}),l++,l%t===0&&await new Promise(b=>requestAnimationFrame(b))}}return i}function Bt(e){const t={type:e.type,name:e.name,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,children:[],geometry:null,material:null,userData:e.userData};e.isMesh&&(t.geometry=Z(e.geometry),t.material=K(e.material));const i=[{object:e,parentData:t}];for(;i.length>0;){const{object:s,parentData:l}=i.pop();for(const r of s.children){const n={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(n.geometry=Z(r.geometry),n.material=K(r.material)),l.children.push(n),i.push({object:r,parentData:n})}}return t}async function Zt(e,t=50){const i=[];let s;switch(e.type){case"Mesh":const r=W(e.geometry),n=X(e.material);s=new O.Mesh(r,n);break;case"Group":s=new O.Group;break;case"Object3D":s=new O.Object3D;break;default:return console.warn(`Unsupported object type: ${e.type}`),null}s.name=e.name,s.position.fromArray(e.position),s.rotation.fromArray(e.rotation),s.scale.fromArray(e.scale),s.visible=e.visible,s.userData=e.userData,i.push({data:e,object:s});let l=0;for(;i.length>0;){const{data:r,object:n}=i.pop();for(const p of[...r.children].reverse()){let u;switch(p.type){case"Mesh":const b=W(p.geometry),_=X(p.material);u=new O.Mesh(b,_);break;case"Group":u=new O.Group;break;case"Object3D":u=new O.Object3D;break;default:console.warn(`Unsupported object type: ${p.type}`);continue}u&&(u.name=p.name,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.visible=p.visible,u.userData=p.userData,n.add(u),i.push({data:p,object:u}),l++,l%t===0&&await new Promise(b=>requestAnimationFrame(b)))}}return s}function Wt(e){const t=[];let i;switch(e.type){case"Mesh":const s=W(e.geometry),l=X(e.material);i=new O.Mesh(s,l);break;case"Group":i=new O.Group;break;case"Object3D":i=new O.Object3D;break;default:return console.warn(`Unsupported object type: ${e.type}`),null}for(i.name=e.name,i.position.fromArray(e.position),i.rotation.fromArray(e.rotation),i.scale.fromArray(e.scale),i.visible=e.visible,i.userData=e.userData,t.push({data:e,object:i});t.length>0;){const{data:s,object:l}=t.pop();for(const r of[...s.children].reverse()){let n;switch(r.type){case"Mesh":const p=W(r.geometry),u=X(r.material);n=new O.Mesh(p,u);break;case"Group":n=new O.Group;break;case"Object3D":n=new O.Object3D;break;default:console.warn(`Unsupported object type: ${r.type}`);continue}n&&(n.name=r.name,n.position.fromArray(r.position),n.rotation.fromArray(r.rotation),n.scale.fromArray(r.scale),n.visible=r.visible,n.userData=r.userData,l.add(n),t.push({data:r,object:n}))}}return i}function Z(e){const t={},{attributes:i,index:s,type:l}=e;i.position&&(t.position={type:"Float32Array",array:Array.from(i.position.array),itemSize:3}),i.normal&&(t.normal={type:"Float32Array",array:Array.from(i.normal.array),itemSize:3}),i.uv&&(t.uv={type:"Float32Array",array:Array.from(i.uv.array),itemSize:2});const r={type:l,attributes:t};return s&&s.array&&(r.index={type:"Uint32Array",array:Array.from(s.array),itemSize:1}),r}function W(e){const{type:t,attributes:i,index:s}=e,l=new O.BufferGeometry;for(const r in i)if(i.hasOwnProperty(r)){const{type:n,array:p,itemSize:u}=i[r];l.setAttribute(r,new O.BufferAttribute(new Float32Array(p),u))}return s&&l.setIndex(s.array),l}function K(e){return{type:e.type,color:e.color.getHex(),map:e.map?e.map.image.src:null,opacity:e.opacity,name:e.name,depthTest:e.depthTest,depthWrite:e.depthWrite,transparent:e.transparent,side:e.side,roughness:e.roughness,metalness:e.metalness,emissive:e.emissive.getHex()}}function X(e){if(Q[e.name])return Q[e.name];const{type:t,...i}=e,s=t||"MeshStandardMaterial",l=new O[s]({...i});if(e.map){const r=new O.TextureLoader().load(e.map);l.map=r}return l.needsUpdate=!0,Q[e.name]=l,l}exports.CSS3DRenderer=yt;exports.CSS3DSprite=_t;exports.ImageLoader=zt;exports.Stats=z;exports.createArrowHelper=Nt;exports.createAxesHelper=Ut;exports.createBox3Helper=kt;exports.createCameraHelper=Lt;exports.createGridHelper=Ct;exports.createMapControls=jt;exports.createOrbitControl=Ht;exports.createRaycaster=It;exports.createStats=Gt;exports.dataToObject3D=Zt;exports.dataToObject3DSync=Wt;exports.disposeThreeObject=ht;exports.initEnvImage=Yt;exports.object3DToData=Vt;exports.object3DToDataSync=Bt;
|