PageSourceSearch

https://www.chngmkr.com/assets/OrbitControls-Dj_MsPMo.js

js chngmkr.com collected 2026-10-05 01:21:43 UTC 13,217 bytes, 1 lines download raw bytes

1import{EventDispatcher as Ze,Vector3 as u,MOUSE as N,TOUCH as S,Spherical as ge,Quaternion as Ee,Vector2 as d,Ray as Fe,Plane as Ve,MathUtils as We}from"./three.module-CUzX9mi6.js";const Pe={type:"change"},J={type:"start"},Te={type:"end"},Z=new Fe,Oe=new Ve,Ge=Math.cos(70*We.DEG2RAD);class $e extends Ze{constructor(F,we){super(),this.object=F,this.domElement=we,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new u,this.cursor=new u,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.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:N.ROTATE,MIDDLE:N.DOLLY,RIGHT:N.PAN},this.touches={ONE:S.ROTATE,TWO:S.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",Q),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Q),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(Pe),e.update(),s=a.NONE},this.update=function(){const t=new u,o=new Ee().setFromUnitVectors(F.up,new u(0,1,0)),n=o.clone().invert(),i=new u,l=new Ee,g=new u,p=2*Math.PI;return function(Xe=null){const ye=e.object.position;t.copy(ye).sub(e.target),t.applyQuaternion(o),r.setFromVector3(t),e.autoRotate&&s===a.NONE&&I(Me(Xe)),e.enableDamping?(r.theta+=m.theta*e.dampingFactor,r.phi+=m.phi*e.dampingFactor):(r.theta+=m.theta,r.phi+=m.phi);let h=e.minAzimuthAngle,f=e.maxAzimuthAngle;isFinite(h)&&isFinite(f)&&(h<-Math.PI?h+=p:h>Math.PI&&(h-=p),f<-Math.PI?f+=p:f>Math.PI&&(f-=p),h<=f?r.theta=Math.max(h,Math.min(f,r.theta)):r.theta=r.theta>(h+f)/2?Math.max(h,r.theta):Math.min(f,r.theta)),r.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,r.phi)),r.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(M,e.dampingFactor):e.target.add(M),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&z||e.object.isOrthographicCamera?r.radius=q(r.radius):r.radius=q(r.radius*b),t.setFromSpherical(r),t.applyQuaternion(n),ye.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(m.theta*=1-e.dampingFactor,m.phi*=1-e.dampingFactor,M.multiplyScalar(1-e.dampingFactor)):(m.set(0,0,0),M.set(0,0,0));let U=!1;if(e.zoomToCursor&&z){let Y=null;if(e.object.isPerspectiveCamera){const _=t.length();Y=q(_*b);const X=_-Y;e.object.position.addScaledVector(v,X),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const _=new u(y.x,y.y,0);_.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/b)),e.object.updateProjectionMatrix(),U=!0;const X=new u(y.x,y.y,0);X.unproject(e.object),e.object.position.sub(X).add(_),e.object.updateMatrixWorld(),Y=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Y!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Y).add(e.object.position):(Z.origin.copy(e.object.position),Z.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(Z.direction))<Ge?F.lookAt(e.target):(Oe.setFromNormalAndCoplanarPoint(e.object.up,e.target),Z.intersectPlane(Oe,e.target))))}else e.object.isOrthographicCamera&&(U=b!==1,U&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/b)),e.object.updateProjectionMatrix()));return b=1,z=!1,U||i.distanceToSquared(e.object.position)>$||8*(1-l.dot(e.object.quaternion))>$||g.distanceToSquared(e.target)>0?(e.dispatchEvent(Pe),i.copy(e.object.position),l.copy(e.object.quaternion),g.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",fe),e.domElement.removeEventListener("pointerdown",pe),e.domElement.removeEventListener("pointercancel",C),e.domElement.removeEventListener("wheel",de),e.domElement.removeEventListener("pointermove",B),e.domElement.removeEventListener("pointerup",C),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",Q),e._domElementKeyEvents=null)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=a.NONE;const $=1e-6,r=new ge,m=new ge;let b=1;const M=new u,E=new d,P=new d,j=new d,T=new d,O=new d,A=new d,L=new d,D=new d,w=new d,v=new u,y=new d;let z=!1;const c=[],k={};let V=!1;function Me(t){return t!==null?2*Math.PI/60*e.autoRotateSpeed*t:2*Math.PI/60/60*e.autoRotateSpeed}function K(t){const o=Math.abs(t*.01);return Math.pow(.95,e.zoomSpeed*o)}function I(t){m.theta-=t}function H(t){m.phi-=t}const ee=function(){const t=new u;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),M.add(t)}}(),te=function(){const t=new u;return function(n,i){e.screenSpacePanning===!0?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(n),M.add(t)}}(),x=function(){const t=new u;return function(n,i){const l=e.domElement;if(e.object.isPerspectiveCamera){const g=e.object.position;t.copy(g).sub(e.target);let p=t.length();p*=Math.tan(e.object.fov/2*Math.PI/180),ee(2*n*p/l.clientHeight,e.object.matrix),te(2*i*p/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(ee(n*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),te(i*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function W(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?b/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function oe(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?b*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}
1function G(t,o){if(!e.zoomToCursor)return;z=!0;const n=e.domElement.getBoundingClientRect(),i=t-n.left,l=o-n.top,g=n.width,p=n.height;y.x=i/g*2-1,y.y=-(l/p)*2+1,v.set(y.x,y.y,1).unproject(e.object).sub(e.object.position).normalize()}function q(t){return Math.max(e.minDistance,Math.min(e.maxDistance,t))}function ne(t){E.set(t.clientX,t.clientY)}function je(t){G(t.clientX,t.clientX),L.set(t.clientX,t.clientY)}function ae(t){T.set(t.clientX,t.clientY)}function Ae(t){P.set(t.clientX,t.clientY),j.subVectors(P,E).multiplyScalar(e.rotateSpeed);const o=e.domElement;I(2*Math.PI*j.x/o.clientHeight),H(2*Math.PI*j.y/o.clientHeight),E.copy(P),e.update()}function Le(t){D.set(t.clientX,t.clientY),w.subVectors(D,L),w.y>0?W(K(w.y)):w.y<0&&oe(K(w.y)),L.copy(D),e.update()}function De(t){O.set(t.clientX,t.clientY),A.subVectors(O,T).multiplyScalar(e.panSpeed),x(A.x,A.y),T.copy(O),e.update()}function xe(t){G(t.clientX,t.clientY),t.deltaY<0?oe(K(t.deltaY)):t.deltaY>0&&W(K(t.deltaY)),e.update()}function Re(t){let o=!1;switch(t.code){case e.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(0,e.keyPanSpeed),o=!0;break;case e.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(0,-e.keyPanSpeed),o=!0;break;case e.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?I(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(e.keyPanSpeed,0),o=!0;break;case e.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?I(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(-e.keyPanSpeed,0),o=!0;break}
1o&&(t.preventDefault(),e.update())}function ie(t){if(c.length===1)E.set(t.pageX,t.pageY);else{const o=R(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);E.set(n,i)}}function se(t){if(c.length===1)T.set(t.pageX,t.pageY);else{const o=R(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);T.set(n,i)}}function re(t){const o=R(t),n=t.pageX-o.x,i=t.pageY-o.y,l=Math.sqrt(n*n+i*i);L.set(0,l)}function Ne(t){e.enableZoom&&re(t),e.enablePan&&se(t)}function Se(t){e.enableZoom&&re(t),e.enableRotate&&ie(t)}function ce(t){if(c.length==1)P.set(t.pageX,t.pageY);else{const n=R(t),i=.5*(t.pageX+n.x),l=.5*(t.pageY+n.y);P.set(i,l)}j.subVectors(P,E).multiplyScalar(e.rotateSpeed);const o=e.domElement;I(2*Math.PI*j.x/o.clientHeight),H(2*Math.PI*j.y/o.clientHeight),E.copy(P)}function le(t){if(c.length===1)O.set(t.pageX,t.pageY);else{const o=R(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);O.set(n,i)}A.subVectors(O,T).multiplyScalar(e.panSpeed),x(A.x,A.y),T.copy(O)}function ue(t){const o=R(t),n=t.pageX-o.x,i=t.pageY-o.y,l=Math.sqrt(n*n+i*i);D.set(0,l),w.set(0,Math.pow(D.y/L.y,e.zoomSpeed)),W(w.y),L.copy(D);const g=(t.pageX+o.x)*.5,p=(t.pageY+o.y)*.5;G(g,p)}function ke(t){e.enableZoom&&ue(t),e.enablePan&&le(t)}function Ie(t){e.enableZoom&&ue(t),e.enableRotate&&ce(t)}function pe(t){e.enabled!==!1&&(c.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",B),e.domElement.addEventListener("pointerup",C)),He(t),t.pointerType==="touch"?he(t):Ce(t))}function B(t){e.enabled!==!1&&(t.pointerType==="touch"?Ke(t):Ye(t))}function C(t){switch(Ue(t),c.length){case 0:e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",B),e.domElement.removeEventListener("pointerup",C),e.dispatchEvent(Te),s=a.NONE;break;case 1:const o=c[0],n=k[o];he({pointerId:o,pageX:n.x,pageY:n.y});break}}function Ce(t){let o;switch(t.button){case 0:o=e.mouseButtons.LEFT;break;case 1:o=e.mouseButtons.MIDDLE;break;case 2:o=e.mouseButtons.RIGHT;break;default:o=-1}switch(o){case N.DOLLY:if(e.enableZoom===!1)return;je(t),s=a.DOLLY;break;case N.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;ae(t),s=a.PAN}else{if(e.enableRotate===!1)return;ne(t),s=a.ROTATE}break;case N.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;ne(t),s=a.ROTATE}else{if(e.enablePan===!1)return;ae(t),s=a.PAN}break;default:s=a.NONE}s!==a.NONE&&e.dispatchEvent(J)}function Ye(t){switch(s){case a.ROTATE:if(e.enableRotate===!1)return;Ae(t);break;case a.DOLLY:if(e.enableZoom===!1)return;Le(t);break;case a.PAN:if(e.enablePan===!1)return;De(t);break}}function de(t){e.enabled===!1||e.enableZoom===!1||s!==a.NONE||(t.preventDefault(),e.dispatchEvent(J),xe(_e(t)),e.dispatchEvent(Te))}function _e(t){const o=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(o){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!V&&(n.deltaY*=10),n}function ze(t){t.key==="Control"&&(V=!0,e.domElement.getRootNode().addEventListener("keyup",me,{passive:!0,capture:!0}))}function me(t){t.key==="Control"&&(V=!1,e.domElement.getRootNode().removeEventListener("keyup",me,{passive:!0,capture:!0}))}function Q(t){e.enabled===!1||e.enablePan===!1||Re(t)}function he(t){switch(be(t),c.length){case 1:switch(e.touches.ONE){case S.ROTATE:if(e.enableRotate===!1)return;ie(t),s=a.TOUCH_ROTATE;break;case S.PAN:if(e.enablePan===!1)return;se(t),s=a.TOUCH_PAN;break;default:s=a.NONE}break;case 2:switch(e.touches.TWO){case S.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ne(t),s=a.TOUCH_DOLLY_PAN;break;case S.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Se(t),s=a.TOUCH_DOLLY_ROTATE;break;default:s=a.NONE}break;default:s=a.NONE}s!==a.NONE&&e.dispatchEvent(J)}function Ke(t){switch(be(t),s){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;ce(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;le(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ke(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ie(t),e.update();break;default:s=a.NONE}}function fe(t){e.enabled!==!1&&t.preventDefault()}function He(t){c.push(t.pointerId)}function Ue(t){delete k[t.pointerId];for(let o=0;o<c.length;o++)if(c[o]==t.pointerId){c.splice(o,1);return}}function be(t){let o=k[t.pointerId];o===void 0&&(o=new d,k[t.pointerId]=o),o.set(t.pageX,t.pageY)}function R(t){const o=t.pointerId===c[0]?c[1]:c[0];return k[o]}e.domElement.addEventListener("contextmenu",fe),e.domElement.addEventListener("pointerdown",pe),e.domElement.addEventListener("pointercancel",C),e.domElement.addEventListener("wheel",de,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",ze,{passive:!0,capture:!0}),this.update()}}export{$e as OrbitControls};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.