ss-component-new 1.2.12 → 1.2.13
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/OrbitControls-BoyGapft.js +419 -0
- package/dist/OrbitControls-D1lM0xvz.cjs +1 -0
- package/dist/STLLoader-BBRISxpD.js +609 -0
- package/dist/STLLoader-KxFIlfhN.cjs +6 -0
- package/dist/{animationData-CyP8-u7i.cjs → animationData-82Fw-zug.cjs} +1 -1
- package/dist/{animationData-C_gV7XAN.js → animationData-CVzu3q7-.js} +2 -2
- package/dist/{iconfont-pt17sMx3.js → iconfont-B9HCA4uh.js} +2 -2
- package/dist/{iconfont-t5epssvu.cjs → iconfont-CsuwJCas.cjs} +1 -1
- package/dist/{index-Dwr4RHei.cjs → index-6tUa2D9P.cjs} +1 -1
- package/dist/{index-DJMHw-xb.js → index-6zoxugAS.js} +7 -7
- package/dist/{index-C40ofXP7.cjs → index-B6h8Kdsz.cjs} +1 -1
- package/dist/{index-BQ4Rjf8F.js → index-B6t23GGZ.js} +3 -3
- package/dist/{index-7eyGTvr0.cjs → index-BZJCScX4.cjs} +1 -1
- package/dist/{index-DQZ_oAyj.js → index-Bafw9B9F.js} +3 -3
- package/dist/{index-ESNVepXU.js → index-BlNTaxba.js} +3 -3
- package/dist/{index-CAewC69j.cjs → index-C85eyyuX.cjs} +1 -1
- package/dist/{index-BMYtLkw8.js → index-CA_ygidl.js} +3 -3
- package/dist/{index-CVDv-Zz-.js → index-CCA-lJNu.js} +14 -14
- package/dist/{index-CApZYDIm.cjs → index-CEi2ZplO.cjs} +1 -1
- package/dist/{index-H_3u1NA_.js → index-CG28BBGh.js} +1 -1
- package/dist/{index-DGBDGLOK.cjs → index-CTOqmp6o.cjs} +1 -1
- package/dist/{index-CoVAbxHN.js → index-CU2AYT-o.js} +1 -1
- package/dist/{index-BAOnUk_J.cjs → index-CXT_ri7C.cjs} +1 -1
- package/dist/{index-CN29uy_G.js → index-CZrlCt19.js} +6 -6
- package/dist/{index-DTkAIcvV.js → index-Cas62aFl.js} +1 -1
- package/dist/{index-CTRmgnKQ.js → index-ChlZgZzn.js} +5 -5
- package/dist/{index-DHQH1rlQ.js → index-Cne-8ofR.js} +1 -1
- package/dist/{index-B7g38Yte.js → index-Cq2pDYGK.js} +1 -1
- package/dist/{index-i50hp6po.cjs → index-CrD_T8_i.cjs} +1 -1
- package/dist/{index-DnU2slQv.cjs → index-CrH5xDEc.cjs} +1 -1
- package/dist/{index-DfKkN76b.js → index-CsOVkfJs.js} +150 -150
- package/dist/{index-D5ShC3zu.cjs → index-CuPtpGC-.cjs} +1 -1
- package/dist/{index-2nEz-J89.js → index-D2puM6vk.js} +2 -2
- package/dist/{index-DDhAMgrO.js → index-D6_JNPhy.js} +1 -1
- package/dist/{index-ecVCII_e.js → index-D7tU_Vmu.js} +1 -1
- package/dist/{index-D9l1Z4TO.cjs → index-D8NHvYsq.cjs} +1 -1
- package/dist/{index-CkA2IZJB.js → index-D9MBiU6x.js} +1 -1
- package/dist/{index-QkDZ18PI.cjs → index-DR5VU4-m.cjs} +1 -1
- package/dist/{index-B9OZcnHm.cjs → index-DvYKkz_M.cjs} +1 -1
- package/dist/{index-B_ZGJtId.js → index-Dvaz3uPH.js} +1 -1
- package/dist/{index-BJBNtx2b.cjs → index-Dy5yN3zf.cjs} +1 -1
- package/dist/{index-CKLBlQoK.js → index-DzopeJWR.js} +3 -3
- package/dist/{index-C5gPrwPs.cjs → index-Ez9VvZ1_.cjs} +1 -1
- package/dist/{index-CVadHkfS.cjs → index-JyPuO9N5.cjs} +1 -1
- package/dist/{index-BUUEqGRN.cjs → index-NU04ABjS.cjs} +1 -1
- package/dist/{index-BDaeo6qO.js → index-YWDxEpkt.js} +1 -1
- package/dist/{index-B_mFQujY.cjs → index-Yc43ZpIg.cjs} +1 -1
- package/dist/{index-DP7rcz4I.cjs → index-d5IX5LQw.cjs} +1 -1
- package/dist/{index-DsQ-qtQ9.cjs → index-dPS3R0YJ.cjs} +1 -1
- package/dist/{index-DkG4A3iE.cjs → index-hKtCBiTZ.cjs} +1 -1
- package/dist/{index-Adqs5vHH.cjs → index-iXcYsTKr.cjs} +1 -1
- package/dist/{index-D4CVC2Sk.js → index-nmkuI4hH.js} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dwdjsitu.cjs → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-BKTlb5a7.cjs} +56 -56
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-BRxOMo6y.js → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dkl1cH-C.js} +1713 -1718
- package/dist/{index.vue_vue_type_style_index_0_scoped_92477073_lang-e_PTrAf6.js → index.vue_vue_type_style_index_0_scoped_92477073_lang-BeE2rxjq.js} +3 -3
- package/dist/{index.vue_vue_type_style_index_0_scoped_92477073_lang-DfqsvuRy.cjs → index.vue_vue_type_style_index_0_scoped_92477073_lang-RjUkBHAd.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-BqmMCEyN.js → index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-B1G9k32g.js} +6 -6
- package/dist/{index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-7HSISF9c.cjs → index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-CBxXCho0.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_1_lang-CsY5rIO4.js → index.vue_vue_type_style_index_1_lang-Cl6e-PP2.js} +5012 -5100
- package/dist/{index.vue_vue_type_style_index_1_lang-DOjFqzi3.cjs → index.vue_vue_type_style_index_1_lang-NCxR30Hn.cjs} +45 -46
- package/dist/{main-DIbH2rlN.js → main-BZIvGaGC.js} +2 -2
- package/dist/{main-CVaemyhm.cjs → main-Bmym9xf7.cjs} +1 -1
- package/dist/ss-component.cjs +1 -1
- package/dist/ss-component.css +1 -1
- package/dist/ss-component.js +9 -9
- package/dist/ss-component2.cjs +1 -1
- package/dist/ss-component2.js +11 -11
- package/dist/three-viewport-gizmo-BlxFLyPm.js +18587 -0
- package/dist/three-viewport-gizmo-CwaL5sMV.cjs +4195 -0
- package/dist/{threeLatheView-CZdorls1.cjs → threeLatheView-BsuPsR7B.cjs} +1 -1
- package/dist/{threeLatheView-Bp0kjo_V.js → threeLatheView-DZZ-1LxL.js} +3 -3
- package/dist/{threeModel-C0Jdw2O3.cjs → threeModel-C7W6Z6bA.cjs} +1 -1
- package/dist/{threeModel-27sl0tTS.js → threeModel-WY_j9cKP.js} +4 -4
- package/dist/threePreview-Cy7NY-gw.cjs +1 -0
- package/dist/threePreview-DKlyIJKv.js +1873 -0
- package/dist/{threeSceneView-CEpBvJSV.cjs → threeSceneView-BfpO8VDG.cjs} +1 -1
- package/dist/{threeSceneView-ZDXqO8ZA.js → threeSceneView-L7mPphX4.js} +23 -23
- package/dist/{threeSceneViewForCPMPIP-BPPWM68P.js → threeSceneViewForCPMPIP-K0nm7l_H.js} +26 -26
- package/dist/{threeSceneViewForCPMPIP-B0VPmBWd.cjs → threeSceneViewForCPMPIP-zkgB6OW3.cjs} +2 -2
- package/dist/{threeViewerHost-CKE2a4PV.js → threeViewerHost-Wcy-3BQ6.js} +2 -2
- package/dist/{threeViewerHost-yHvsk7TK.cjs → threeViewerHost-pddFZ8Z9.cjs} +1 -1
- package/dist/{urdfTree-BuTtRGdl.js → urdfTree-Dnh2rJyF.js} +2 -2
- package/dist/urdfTree-bbDs2Fhg.cjs +1 -0
- package/dist/{useRayCaster-BM9XKGKx.js → useRayCaster-O1MYiDpT.js} +12 -12
- package/dist/{useRayCaster-1DNcSYPR.cjs → useRayCaster-h-sWQwPj.cjs} +1 -1
- package/package.json +1 -1
- package/dist/OrbitControls-C0QRmW6_.js +0 -458
- package/dist/OrbitControls-Co_9huz0.cjs +0 -1
- package/dist/STLLoader-CiUjaQtA.js +0 -657
- package/dist/STLLoader-RU7KqloS.cjs +0 -6
- package/dist/obj/model.mtl +0 -42
- package/dist/obj/model.obj +0 -26110
- package/dist/three-viewport-gizmo-BV37JzRa.cjs +0 -4197
- package/dist/three-viewport-gizmo-CkQ98n-T.js +0 -26015
- package/dist/threePreview-C_mY_TBC.cjs +0 -1
- package/dist/threePreview-DFFjm93P.js +0 -1972
- package/dist/urdfTree-CCktg0FK.cjs +0 -1
- package/public/obj/model.mtl +0 -42
- package/public/obj/model.obj +0 -26110
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var oe=(r,i,o)=>i in r?te(r,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[i]=o;var D=(r,i,o)=>oe(r,typeof i!="symbol"?i+"":i,o);const se=require("./index.vue_vue_type_style_index_1_lang-DOjFqzi3.cjs"),C=require("./STLLoader-RU7KqloS.cjs"),R=require("./three-viewport-gizmo-BV37JzRa.cjs"),e=require("vue"),ie=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),le={SINGLE:"单机",DOUBLE:"双机"},ne={ROBOT:1,PIPECOMPARSION:2},re="http://222.92.178.198:60000/chfs/shared/Insofrobot/urdf";function x(r){if(r==null||!isFinite(r))return"";const i=r/(1024*1024);if(i>=1)return`${i.toFixed(1)} MB`;const o=r/1024;return o>=1?`${o.toFixed(1)} KB`:`${r} B`}function ee(r){try{const i=r.split("?")[0].split("#")[0];return i.substring(i.lastIndexOf("/")+1)||i}catch{return r}}function ae(r){const{manager:i,baseFolderUrl:o,onFileProgress:l}=r,m=new se.URDFLoader(i);return m.packages=n=>`${o.endsWith("/")?o:o+"/"}${n}/`,m.loadMeshCb=(n,N,h)=>{const g=(()=>{const _=n.split("?")[0].split("#")[0],u=_.lastIndexOf(".");return u>=0?_.slice(u+1).toLowerCase():void 0})();switch(g){case"obj":{const _=(()=>{try{return new URL(".",n).toString()}catch{const c=n.lastIndexOf("/");return c>=0?n.slice(0,c+1):n}})(),u=(()=>{var v;return(((v=n.split("/").pop())==null?void 0:v.split("?")[0].split("#")[0])??"").replace(/\.[^/.?#]+$/,"")})(),f=`${_}${u}.mtl`,E=c=>{const v=new C.OBJLoader(N);c&&v.setMaterials(c),v.load(n,b=>h(b),b=>l==null?void 0:l(n,b==null?void 0:b.loaded,b==null?void 0:b.total),b=>{console.error(`[URDF 资源加载失败,已跳过] 无法加载 OBJ 模型: ${n}`,b),h(new R.Group)})},w=new C.MTLLoader(N);w.setResourcePath(_),w.load(f,c=>{try{c.preload()}catch{}E(c)},c=>l==null?void 0:l(f,c==null?void 0:c.loaded,c==null?void 0:c.total),c=>{console.warn(`[URDF 资源警告] 未找到或加载材质失败: ${f}。将尝试无材质加载。`),E(void 0)});break}case"stl":{new C.STLLoader(N).load(n,u=>{const f=new R.MeshPhongMaterial({color:12303291,shininess:30}),E=new R.Mesh(u,f);E.castShadow=!0,E.receiveShadow=!0,h(E)},u=>l==null?void 0:l(n,u==null?void 0:u.loaded,u==null?void 0:u.total),u=>{console.error(`[URDF 资源加载失败,已跳过] 无法加载 STL 模型: ${n}`,u),h(new R.Group)});break}default:console.error(`[URDF 资源加载失败,已跳过] 不支持的网格格式: .${g} (路径: ${n})`),h(new R.Group)}},m}function ce(r,i,o,l){return{loadSceneFromFile:n=>new Promise((N,h)=>{o.value=!0,l.value="正在初始化 URDF 加载器...";let g=0,_=0,u=null;const f=new R.LoadingManager;f.onStart=(w,c,v)=>{g=v||0,_=c||0,l.value=g>0?`开始下载资源: 0 / ${g}`:"开始下载资源...",o.value=!0},f.onProgress=(w,c,v)=>{_=c,g=v;const b=`正在加载 ${c} / ${v} 个文件: ${ee(w)}`;l.value=b,c===v&&(l.value="资源加载完成,正在处理模型...",setTimeout(()=>{if(u){u.updateMatrixWorld(!0);const p=new R.Box3().setFromObject(u);p.isEmpty()&&console.warn("模型加载完成,但所有可视化网格均加载失败,模型将不可见。"),u.userData.boundingBox=p,u.traverse(d=>{d.isMesh&&(d.castShadow=!0,d.receiveShadow=!0)}),N(u)}else h(new Error("URDF 文件本身加载失败。"));l.value="模型加载完成",setTimeout(()=>{l.value==="模型加载完成"&&(o.value=!1,l.value="")},500)},100))},f.onError=w=>{console.warn(`LoadingManager 报告一个资源加载失败: ${w}。加载流程将继续。`)};const E=(w,c,v)=>{const b=ee(w);let p;v&&v>0?p=`${b}(${x(c)} / ${x(v)})`:c&&c>0?p=`${b}(已下载 ${x(c)})`:p=`${b}`,l.value=`正在下载第 ${_+1} / ${g} 个文件: ${p}`};try{const w=URL.createObjectURL(n);ae({manager:f,baseFolderUrl:re,onFileProgress:E}).load(w,v=>{u=v},void 0,v=>{console.error(`加载 URDF 文件 (${n.name}) 时发生致命错误:`,v),l.value="URDF 文件解析失败",o.value=!1,h(new Error(`加载 URDF 文件失败: ${n.name}`,{cause:v}))})}catch(w){console.error("初始化 URDF 加载时发生致命错误:",w),l.value="模型加载失败",o.value=!1,h(w)}})}}class ue{constructor(i){D(this,"robot");D(this,"movableJoints");this.robot=i,this.movableJoints=this.getMovableJoints()}getMovableJoints(){return Object.values(this.robot.joints).filter(i=>i.jointType!=="fixed")}getMovableJointNames(){return this.movableJoints.map(i=>i.name)}setJointAngle(i,o){const l=this.robot.joints[i];if(!l||l.jointType==="fixed")return console.warn(`关节 ${i} 不存在或不可动`),!1;if(l.limit){const m=Math.max(l.limit.lower,Math.min(l.limit.upper,o));m!==o&&console.warn(`关节 ${i} 角度被限制在 [${l.limit.lower}, ${l.limit.upper}]`),l.setJointValue(m)}else l.setJointValue(o);return!0}setJointAngles(i){Object.entries(i).forEach(([o,l])=>{typeof l=="number"&&!isNaN(l)&&this.setJointAngle(o,l)})}getCurrentJointStates(){const i={};return this.movableJoints.forEach(o=>{i[o.name]=o.angle||0}),i}resetToZero(){this.movableJoints.forEach(i=>{i.setJointValue(0)})}getJointLimits(i){const o=this.robot.joints[i];return!o||!o.limit?null:{lower:o.limit.lower,upper:o.limit.upper}}async animateToState(i,o=1e3,l){const m=this.getCurrentJointStates(),n=Date.now();return new Promise(N=>{const h=()=>{const g=Date.now()-n,_=Math.min(g/o,1),u=this.easeInOutCubic(_),f={};Object.keys(i).forEach(E=>{const w=m[E]||0,c=i[E];f[E]=w+(c-w)*u}),this.setJointAngles(f),l&&l(_),_<1?requestAnimationFrame(h):N()};h()})}easeInOutCubic(i){return i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2}async playSequence(i,o=1e3,l){for(let m=0;m<i.length;m++)await this.animateToState(i[m],o,n=>{l&&l(m,n)})}}const de=(r,i="YZX")=>{const o=new R.Vector3,l=new R.Quaternion,m=new R.Vector3,n=new R.Euler;r.getWorldPosition(o),r.getWorldQuaternion(l),r.getWorldScale(m),n.setFromQuaternion(l,i);const N={x:r.rotation.x*180/Math.PI,y:r.rotation.y*180/Math.PI,z:r.rotation.z*180/Math.PI},h={x:n.x*180/Math.PI,y:n.y*180/Math.PI,z:n.z*180/Math.PI};return{position:r.position,rotation:N,scale:r.scale,worldPosition:o,worldRotation:h,worldScale:m}},me=(r,i,o)=>{const l=parseFloat(o);isNaN(l)||(r.position[i]=l,r.updateMatrixWorld(!0))},pe=(r,i,o)=>{const l=parseFloat(o);isNaN(l)||(r.rotation[i]=l*Math.PI/180,r.updateMatrixWorld(!0))},ve={class:"panel-content"},fe={class:"obj"},we={key:0,class:"obj-base"},be=["title"],he=["title"],Ve={key:1},_e={class:"obj-position"},Ee={class:"coord-item"},Ne={class:"coord-item"},ge={class:"coord-item"},ye={class:"obj-rotation"},Re={class:"coord-item"},Se={class:"coord-item"},Me={class:"coord-item"},De={class:"world"},Ce={class:"coord-line"},xe={class:"coord-text"},Fe={class:"world-position-item"},$e={class:"world-position-item"},Le={class:"world-position-item"},Oe={class:"coord-line"},Ue={class:"coord-text"},je={class:"world-rotation-item"},Je={class:"world-rotation-item"},ke={class:"world-rotation-item"},Ie=e.defineComponent({__name:"workpieceTreePanel",props:{model:{},maxExpandCount:{default:10},expandStrategy:{default:"breadth"}},emits:["nodeClick","visibleChange","updatePosition","updateRotation"],setup(r,{emit:i}){const o=r,l=i,m=e.ref([]),n=e.ref({}),N=(t,s=0)=>{const V=[];return Array.isArray(t)&&(t==null?void 0:t.length)>0&&t.forEach(a=>{if(!(a!=null&&a.isMesh)){const y={name:a==null?void 0:a.name,label:(a==null?void 0:a.name)||(a==null?void 0:a.type),show:!0,level:s+1,isPenultimate:!1,type:a==null?void 0:a.type,id:a==null?void 0:a.id,limit:(a==null?void 0:a.limit)??"",children:N(a==null?void 0:a.children,s+1),path:a==null?void 0:a.name};V.push(y)}}),V},h=t=>t?[{name:t==null?void 0:t.name,label:(t==null?void 0:t.name)||(t==null?void 0:t.type),show:!0,level:1,isPenultimate:!1,type:t==null?void 0:t.type,id:t==null?void 0:t.id,limit:(t==null?void 0:t.limit)??"",children:N(t==null?void 0:t.children,1),path:t==null?void 0:t.name}]:[],g=(t,s)=>{const V=[],a=[...t];for(;a.length>0&&V.length<s;){const y=a.shift();y.children&&y.children.length>0&&(V.push(y.id),a.push(...y.children))}return V},_=(t,s)=>{const V=[];return t.forEach(a=>{if(a.children&&a.children.length>0){V.push(a.id);const y=a.children.filter(M=>M.children&&M.children.length>0).slice(0,s).map(M=>M.id);V.push(...y)}}),V.slice(0,s+1)};e.computed(()=>!m.value||m.value.length===0?[]:o.expandStrategy==="firstLevel"?_(m.value,o.maxExpandCount):g(m.value,o.maxExpandCount));const u=t=>t?parseFloat(t.toFixed(3)):0,f=t=>t?parseFloat(t.toFixed(1)):0,E=(t,s)=>{l("updatePosition",{obj:o.model,axis:s,value:(t==null?void 0:t.toString())||"0"})},w=(t,s)=>{l("updateRotation",{obj:o.model,axis:s,value:(t==null?void 0:t.toString())||"0"})},c=t=>{l("visibleChange",t)},v=e.computed(()=>o!=null&&o.model?h(o.model):[]),b=e.computed(()=>{var t,s;return((t=o==null?void 0:o.model)==null?void 0:t.name)||((s=o==null?void 0:o.model)==null?void 0:s.type)}),p=e.computed(()=>{var t;return(t=o==null?void 0:o.model)==null?void 0:t.type}),d=e.computed(()=>{var t;return(t=o==null?void 0:o.model)==null?void 0:t.visible});return e.watch(()=>o.model,()=>{o.model&&(n.value=de(o.model))},{deep:!0,immediate:!0}),e.watch(v,t=>{m.value=JSON.parse(JSON.stringify(t))},{immediate:!0}),(t,s)=>{var M,F,$,L,O,U,j,J,k,I,T,P,z,B,A,W,q,G,Q,X,Y,Z,K,H;const V=e.resolveComponent("el-divider"),a=e.resolveComponent("el-switch"),y=e.resolveComponent("el-input-number");return e.openBlock(),e.createElementBlock("div",ve,[e.createVNode(V,null,{default:e.withCtx(()=>s[6]||(s[6]=[e.createTextVNode("对象")])),_:1,__:[6]}),e.createElementVNode("div",fe,[o.model?(e.openBlock(),e.createElementBlock("div",we,[e.createElementVNode("div",{class:"obj-name",title:b.value},e.toDisplayString(b.value),9,be),e.createElementVNode("div",{class:"obj-type",title:p.value},"["+e.toDisplayString(p.value)+"]",9,he)])):(e.openBlock(),e.createElementBlock("div",Ve,"空")),e.createVNode(a,{"model-value":d.value,onChange:c},null,8,["model-value"])]),e.createVNode(V,null,{default:e.withCtx(()=>s[7]||(s[7]=[e.createTextVNode("相对位置")])),_:1,__:[7]}),e.createElementVNode("div",_e,[e.createElementVNode("div",Ee,[s[8]||(s[8]=e.createElementVNode("span",{class:"axis-label"},"X",-1)),e.createVNode(y,{"model-value":u((F=(M=n.value)==null?void 0:M.position)==null?void 0:F.x),onChange:s[0]||(s[0]=S=>E(S,"x")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",Ne,[s[9]||(s[9]=e.createElementVNode("span",{class:"axis-label"},"Y",-1)),e.createVNode(y,{"model-value":u((L=($=n.value)==null?void 0:$.position)==null?void 0:L.y),onChange:s[1]||(s[1]=S=>E(S,"y")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",ge,[s[10]||(s[10]=e.createElementVNode("span",{class:"axis-label"},"Z",-1)),e.createVNode(y,{"model-value":u((U=(O=n.value)==null?void 0:O.position)==null?void 0:U.z),onChange:s[2]||(s[2]=S=>E(S,"z")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])])]),e.createVNode(V,null,{default:e.withCtx(()=>s[11]||(s[11]=[e.createTextVNode("相对旋转")])),_:1,__:[11]}),e.createElementVNode("div",ye,[e.createElementVNode("div",Re,[s[12]||(s[12]=e.createElementVNode("span",{class:"axis-label"},"X°",-1)),e.createVNode(y,{"model-value":f((J=(j=n.value)==null?void 0:j.rotation)==null?void 0:J.x),onChange:s[3]||(s[3]=S=>w(S,"x")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",Se,[s[13]||(s[13]=e.createElementVNode("span",{class:"axis-label"},"Y°",-1)),e.createVNode(y,{"model-value":f((I=(k=n.value)==null?void 0:k.rotation)==null?void 0:I.y),onChange:s[4]||(s[4]=S=>w(S,"y")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",Me,[s[14]||(s[14]=e.createElementVNode("span",{class:"axis-label"},"Z°",-1)),e.createVNode(y,{"model-value":f((P=(T=n.value)==null?void 0:T.rotation)==null?void 0:P.z),onChange:s[5]||(s[5]=S=>w(S,"z")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])])]),e.createVNode(V,null,{default:e.withCtx(()=>s[15]||(s[15]=[e.createTextVNode("世界信息")])),_:1,__:[15]}),e.createElementVNode("div",De,[e.createElementVNode("div",Ce,[s[16]||(s[16]=e.createElementVNode("span",{class:"coord-label"},"世界位置:",-1)),e.createElementVNode("span",xe,[e.createElementVNode("div",Fe,e.toDisplayString(u((B=(z=n.value)==null?void 0:z.worldPosition)==null?void 0:B.x))+", ",1),e.createElementVNode("div",$e,e.toDisplayString(u((W=(A=n.value)==null?void 0:A.worldPosition)==null?void 0:W.y))+", ",1),e.createElementVNode("div",Le,e.toDisplayString(u((G=(q=n.value)==null?void 0:q.worldPosition)==null?void 0:G.z)),1)])]),e.createElementVNode("div",Oe,[s[17]||(s[17]=e.createElementVNode("span",{class:"coord-label"},"世界旋转:",-1)),e.createElementVNode("span",Ue,[e.createElementVNode("div",je,e.toDisplayString(f((X=(Q=n.value)==null?void 0:Q.worldRotation)==null?void 0:X.x))+"°, ",1),e.createElementVNode("div",Je,e.toDisplayString(f((Z=(Y=n.value)==null?void 0:Y.worldRotation)==null?void 0:Z.y))+"°, ",1),e.createElementVNode("div",ke,e.toDisplayString(f((H=(K=n.value)==null?void 0:K.worldRotation)==null?void 0:H.z))+"° ",1)])])])])}}}),Te=ie._export_sfc(Ie,[["__scopeId","data-v-00d48931"]]);function Pe(r,i,o,l=["URDFVisual"]){let m=null;const n=e.ref(null),N=new R.Raycaster,h=new R.Vector2,g=new Map;function _(){o.value.forEach(p=>{p.traverse(d=>{l!=null&&l.includes(d.type)&&g.set(d.id,{obj:d,axis:d.axis||new R.Vector3(1,0,0),limits:d.limits})})})}function u(p){n.value&&n.value.obj.traverse(d=>{var t;d.material&&((t=d.material.emissive)==null||t.set(0))}),n.value=p,p.obj.traverse(d=>{var t;d.material&&((t=d.material.emissive)==null||t.set(65280))})}function f(p){const d=r.value.getBoundingClientRect();h.x=(p.clientX-d.left)/d.width*2-1,h.y=-((p.clientY-d.top)/d.height)*2+1,N.setFromCamera(h,m);const t=N.intersectObjects(o.value,!0);if(t.length===0)return;let s=t[0].object,V=null;for(;s;){if(g.has(s.id)){V=g.get(s.id);break}s=s.parent}V&&u(V)}function E(){r.value&&r.value.removeEventListener("click",f,!1)}function w(){const{scene:p,camera:d}=i();m=d,_(),r.value&&r.value.addEventListener("click",f,!1)}function c(p){n.value&&(n.value.obj.visible=p)}function v(p){var s;const{axis:d,value:t}=p;me((s=n.value)==null?void 0:s.obj,d,t)}function b(p){var s;const{axis:d,value:t}=p;pe((s=n.value)==null?void 0:s.obj,d,t)}return{initRaycaster:w,dispose:E,selectedObject3D:n,setSelectedObjVisible:c,updatePosition:v,updateRotation:b}}exports.URDFRobotController=ue;exports.WorkpieceTreePanel=Te;exports.robotMode=le;exports.sceneType=ne;exports.useRaycaster=Pe;exports.useUrdfLoader=ce;
|
|
1
|
+
"use strict";var te=Object.defineProperty;var oe=(r,i,o)=>i in r?te(r,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[i]=o;var D=(r,i,o)=>oe(r,typeof i!="symbol"?i+"":i,o);const R=require("./three-viewport-gizmo-CwaL5sMV.cjs"),se=require("./index.vue_vue_type_style_index_1_lang-NCxR30Hn.cjs"),C=require("./STLLoader-KxFIlfhN.cjs"),e=require("vue"),ie=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),le={SINGLE:"单机",DOUBLE:"双机"},ne={ROBOT:1,PIPECOMPARSION:2},re="http://222.92.178.198:60000/chfs/shared/Insofrobot/urdf";function x(r){if(r==null||!isFinite(r))return"";const i=r/(1024*1024);if(i>=1)return`${i.toFixed(1)} MB`;const o=r/1024;return o>=1?`${o.toFixed(1)} KB`:`${r} B`}function ee(r){try{const i=r.split("?")[0].split("#")[0];return i.substring(i.lastIndexOf("/")+1)||i}catch{return r}}function ae(r){const{manager:i,baseFolderUrl:o,onFileProgress:l}=r,m=new se.URDFLoader(i);return m.packages=n=>`${o.endsWith("/")?o:o+"/"}${n}/`,m.loadMeshCb=(n,N,h)=>{const g=(()=>{const _=n.split("?")[0].split("#")[0],u=_.lastIndexOf(".");return u>=0?_.slice(u+1).toLowerCase():void 0})();switch(g){case"obj":{const _=(()=>{try{return new URL(".",n).toString()}catch{const c=n.lastIndexOf("/");return c>=0?n.slice(0,c+1):n}})(),u=(()=>{var v;return(((v=n.split("/").pop())==null?void 0:v.split("?")[0].split("#")[0])??"").replace(/\.[^/.?#]+$/,"")})(),f=`${_}${u}.mtl`,E=c=>{const v=new C.OBJLoader(N);c&&v.setMaterials(c),v.load(n,b=>h(b),b=>l==null?void 0:l(n,b==null?void 0:b.loaded,b==null?void 0:b.total),b=>{console.error(`[URDF 资源加载失败,已跳过] 无法加载 OBJ 模型: ${n}`,b),h(new R.Group)})},w=new C.MTLLoader(N);w.setResourcePath(_),w.load(f,c=>{try{c.preload()}catch{}E(c)},c=>l==null?void 0:l(f,c==null?void 0:c.loaded,c==null?void 0:c.total),c=>{console.warn(`[URDF 资源警告] 未找到或加载材质失败: ${f}。将尝试无材质加载。`),E(void 0)});break}case"stl":{new C.STLLoader(N).load(n,u=>{const f=new R.MeshPhongMaterial({color:12303291,shininess:30}),E=new R.Mesh(u,f);E.castShadow=!0,E.receiveShadow=!0,h(E)},u=>l==null?void 0:l(n,u==null?void 0:u.loaded,u==null?void 0:u.total),u=>{console.error(`[URDF 资源加载失败,已跳过] 无法加载 STL 模型: ${n}`,u),h(new R.Group)});break}default:console.error(`[URDF 资源加载失败,已跳过] 不支持的网格格式: .${g} (路径: ${n})`),h(new R.Group)}},m}function ce(r,i,o,l){return{loadSceneFromFile:n=>new Promise((N,h)=>{o.value=!0,l.value="正在初始化 URDF 加载器...";let g=0,_=0,u=null;const f=new R.LoadingManager;f.onStart=(w,c,v)=>{g=v||0,_=c||0,l.value=g>0?`开始下载资源: 0 / ${g}`:"开始下载资源...",o.value=!0},f.onProgress=(w,c,v)=>{_=c,g=v;const b=`正在加载 ${c} / ${v} 个文件: ${ee(w)}`;l.value=b,c===v&&(l.value="资源加载完成,正在处理模型...",setTimeout(()=>{if(u){u.updateMatrixWorld(!0);const p=new R.Box3().setFromObject(u);p.isEmpty()&&console.warn("模型加载完成,但所有可视化网格均加载失败,模型将不可见。"),u.userData.boundingBox=p,u.traverse(d=>{d.isMesh&&(d.castShadow=!0,d.receiveShadow=!0)}),N(u)}else h(new Error("URDF 文件本身加载失败。"));l.value="模型加载完成",setTimeout(()=>{l.value==="模型加载完成"&&(o.value=!1,l.value="")},500)},100))},f.onError=w=>{console.warn(`LoadingManager 报告一个资源加载失败: ${w}。加载流程将继续。`)};const E=(w,c,v)=>{const b=ee(w);let p;v&&v>0?p=`${b}(${x(c)} / ${x(v)})`:c&&c>0?p=`${b}(已下载 ${x(c)})`:p=`${b}`,l.value=`正在下载第 ${_+1} / ${g} 个文件: ${p}`};try{const w=URL.createObjectURL(n);ae({manager:f,baseFolderUrl:re,onFileProgress:E}).load(w,v=>{u=v},void 0,v=>{console.error(`加载 URDF 文件 (${n.name}) 时发生致命错误:`,v),l.value="URDF 文件解析失败",o.value=!1,h(new Error(`加载 URDF 文件失败: ${n.name}`,{cause:v}))})}catch(w){console.error("初始化 URDF 加载时发生致命错误:",w),l.value="模型加载失败",o.value=!1,h(w)}})}}class ue{constructor(i){D(this,"robot");D(this,"movableJoints");this.robot=i,this.movableJoints=this.getMovableJoints()}getMovableJoints(){return Object.values(this.robot.joints).filter(i=>i.jointType!=="fixed")}getMovableJointNames(){return this.movableJoints.map(i=>i.name)}setJointAngle(i,o){const l=this.robot.joints[i];if(!l||l.jointType==="fixed")return console.warn(`关节 ${i} 不存在或不可动`),!1;if(l.limit){const m=Math.max(l.limit.lower,Math.min(l.limit.upper,o));m!==o&&console.warn(`关节 ${i} 角度被限制在 [${l.limit.lower}, ${l.limit.upper}]`),l.setJointValue(m)}else l.setJointValue(o);return!0}setJointAngles(i){Object.entries(i).forEach(([o,l])=>{typeof l=="number"&&!isNaN(l)&&this.setJointAngle(o,l)})}getCurrentJointStates(){const i={};return this.movableJoints.forEach(o=>{i[o.name]=o.angle||0}),i}resetToZero(){this.movableJoints.forEach(i=>{i.setJointValue(0)})}getJointLimits(i){const o=this.robot.joints[i];return!o||!o.limit?null:{lower:o.limit.lower,upper:o.limit.upper}}async animateToState(i,o=1e3,l){const m=this.getCurrentJointStates(),n=Date.now();return new Promise(N=>{const h=()=>{const g=Date.now()-n,_=Math.min(g/o,1),u=this.easeInOutCubic(_),f={};Object.keys(i).forEach(E=>{const w=m[E]||0,c=i[E];f[E]=w+(c-w)*u}),this.setJointAngles(f),l&&l(_),_<1?requestAnimationFrame(h):N()};h()})}easeInOutCubic(i){return i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2}async playSequence(i,o=1e3,l){for(let m=0;m<i.length;m++)await this.animateToState(i[m],o,n=>{l&&l(m,n)})}}const de=(r,i="YZX")=>{const o=new R.Vector3,l=new R.Quaternion,m=new R.Vector3,n=new R.Euler;r.getWorldPosition(o),r.getWorldQuaternion(l),r.getWorldScale(m),n.setFromQuaternion(l,i);const N={x:r.rotation.x*180/Math.PI,y:r.rotation.y*180/Math.PI,z:r.rotation.z*180/Math.PI},h={x:n.x*180/Math.PI,y:n.y*180/Math.PI,z:n.z*180/Math.PI};return{position:r.position,rotation:N,scale:r.scale,worldPosition:o,worldRotation:h,worldScale:m}},me=(r,i,o)=>{const l=parseFloat(o);isNaN(l)||(r.position[i]=l,r.updateMatrixWorld(!0))},pe=(r,i,o)=>{const l=parseFloat(o);isNaN(l)||(r.rotation[i]=l*Math.PI/180,r.updateMatrixWorld(!0))},ve={class:"panel-content"},fe={class:"obj"},we={key:0,class:"obj-base"},be=["title"],he=["title"],Ve={key:1},_e={class:"obj-position"},Ee={class:"coord-item"},Ne={class:"coord-item"},ge={class:"coord-item"},ye={class:"obj-rotation"},Re={class:"coord-item"},Se={class:"coord-item"},Me={class:"coord-item"},De={class:"world"},Ce={class:"coord-line"},xe={class:"coord-text"},Fe={class:"world-position-item"},$e={class:"world-position-item"},Le={class:"world-position-item"},Oe={class:"coord-line"},Ue={class:"coord-text"},je={class:"world-rotation-item"},Je={class:"world-rotation-item"},ke={class:"world-rotation-item"},Ie=e.defineComponent({__name:"workpieceTreePanel",props:{model:{},maxExpandCount:{default:10},expandStrategy:{default:"breadth"}},emits:["nodeClick","visibleChange","updatePosition","updateRotation"],setup(r,{emit:i}){const o=r,l=i,m=e.ref([]),n=e.ref({}),N=(t,s=0)=>{const V=[];return Array.isArray(t)&&(t==null?void 0:t.length)>0&&t.forEach(a=>{if(!(a!=null&&a.isMesh)){const y={name:a==null?void 0:a.name,label:(a==null?void 0:a.name)||(a==null?void 0:a.type),show:!0,level:s+1,isPenultimate:!1,type:a==null?void 0:a.type,id:a==null?void 0:a.id,limit:(a==null?void 0:a.limit)??"",children:N(a==null?void 0:a.children,s+1),path:a==null?void 0:a.name};V.push(y)}}),V},h=t=>t?[{name:t==null?void 0:t.name,label:(t==null?void 0:t.name)||(t==null?void 0:t.type),show:!0,level:1,isPenultimate:!1,type:t==null?void 0:t.type,id:t==null?void 0:t.id,limit:(t==null?void 0:t.limit)??"",children:N(t==null?void 0:t.children,1),path:t==null?void 0:t.name}]:[],g=(t,s)=>{const V=[],a=[...t];for(;a.length>0&&V.length<s;){const y=a.shift();y.children&&y.children.length>0&&(V.push(y.id),a.push(...y.children))}return V},_=(t,s)=>{const V=[];return t.forEach(a=>{if(a.children&&a.children.length>0){V.push(a.id);const y=a.children.filter(M=>M.children&&M.children.length>0).slice(0,s).map(M=>M.id);V.push(...y)}}),V.slice(0,s+1)};e.computed(()=>!m.value||m.value.length===0?[]:o.expandStrategy==="firstLevel"?_(m.value,o.maxExpandCount):g(m.value,o.maxExpandCount));const u=t=>t?parseFloat(t.toFixed(3)):0,f=t=>t?parseFloat(t.toFixed(1)):0,E=(t,s)=>{l("updatePosition",{obj:o.model,axis:s,value:(t==null?void 0:t.toString())||"0"})},w=(t,s)=>{l("updateRotation",{obj:o.model,axis:s,value:(t==null?void 0:t.toString())||"0"})},c=t=>{l("visibleChange",t)},v=e.computed(()=>o!=null&&o.model?h(o.model):[]),b=e.computed(()=>{var t,s;return((t=o==null?void 0:o.model)==null?void 0:t.name)||((s=o==null?void 0:o.model)==null?void 0:s.type)}),p=e.computed(()=>{var t;return(t=o==null?void 0:o.model)==null?void 0:t.type}),d=e.computed(()=>{var t;return(t=o==null?void 0:o.model)==null?void 0:t.visible});return e.watch(()=>o.model,()=>{o.model&&(n.value=de(o.model))},{deep:!0,immediate:!0}),e.watch(v,t=>{m.value=JSON.parse(JSON.stringify(t))},{immediate:!0}),(t,s)=>{var M,F,$,L,O,U,j,J,k,I,T,P,z,B,A,W,q,G,Q,X,Y,Z,K,H;const V=e.resolveComponent("el-divider"),a=e.resolveComponent("el-switch"),y=e.resolveComponent("el-input-number");return e.openBlock(),e.createElementBlock("div",ve,[e.createVNode(V,null,{default:e.withCtx(()=>s[6]||(s[6]=[e.createTextVNode("对象")])),_:1,__:[6]}),e.createElementVNode("div",fe,[o.model?(e.openBlock(),e.createElementBlock("div",we,[e.createElementVNode("div",{class:"obj-name",title:b.value},e.toDisplayString(b.value),9,be),e.createElementVNode("div",{class:"obj-type",title:p.value},"["+e.toDisplayString(p.value)+"]",9,he)])):(e.openBlock(),e.createElementBlock("div",Ve,"空")),e.createVNode(a,{"model-value":d.value,onChange:c},null,8,["model-value"])]),e.createVNode(V,null,{default:e.withCtx(()=>s[7]||(s[7]=[e.createTextVNode("相对位置")])),_:1,__:[7]}),e.createElementVNode("div",_e,[e.createElementVNode("div",Ee,[s[8]||(s[8]=e.createElementVNode("span",{class:"axis-label"},"X",-1)),e.createVNode(y,{"model-value":u((F=(M=n.value)==null?void 0:M.position)==null?void 0:F.x),onChange:s[0]||(s[0]=S=>E(S,"x")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",Ne,[s[9]||(s[9]=e.createElementVNode("span",{class:"axis-label"},"Y",-1)),e.createVNode(y,{"model-value":u((L=($=n.value)==null?void 0:$.position)==null?void 0:L.y),onChange:s[1]||(s[1]=S=>E(S,"y")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",ge,[s[10]||(s[10]=e.createElementVNode("span",{class:"axis-label"},"Z",-1)),e.createVNode(y,{"model-value":u((U=(O=n.value)==null?void 0:O.position)==null?void 0:U.z),onChange:s[2]||(s[2]=S=>E(S,"z")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])])]),e.createVNode(V,null,{default:e.withCtx(()=>s[11]||(s[11]=[e.createTextVNode("相对旋转")])),_:1,__:[11]}),e.createElementVNode("div",ye,[e.createElementVNode("div",Re,[s[12]||(s[12]=e.createElementVNode("span",{class:"axis-label"},"X°",-1)),e.createVNode(y,{"model-value":f((J=(j=n.value)==null?void 0:j.rotation)==null?void 0:J.x),onChange:s[3]||(s[3]=S=>w(S,"x")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",Se,[s[13]||(s[13]=e.createElementVNode("span",{class:"axis-label"},"Y°",-1)),e.createVNode(y,{"model-value":f((I=(k=n.value)==null?void 0:k.rotation)==null?void 0:I.y),onChange:s[4]||(s[4]=S=>w(S,"y")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])]),e.createElementVNode("div",Me,[s[14]||(s[14]=e.createElementVNode("span",{class:"axis-label"},"Z°",-1)),e.createVNode(y,{"model-value":f((P=(T=n.value)==null?void 0:T.rotation)==null?void 0:P.z),onChange:s[5]||(s[5]=S=>w(S,"z")),size:"small",class:"coord-input-compact",precision:3,step:.1,controls:!0,"controls-position":"right"},null,8,["model-value"])])]),e.createVNode(V,null,{default:e.withCtx(()=>s[15]||(s[15]=[e.createTextVNode("世界信息")])),_:1,__:[15]}),e.createElementVNode("div",De,[e.createElementVNode("div",Ce,[s[16]||(s[16]=e.createElementVNode("span",{class:"coord-label"},"世界位置:",-1)),e.createElementVNode("span",xe,[e.createElementVNode("div",Fe,e.toDisplayString(u((B=(z=n.value)==null?void 0:z.worldPosition)==null?void 0:B.x))+", ",1),e.createElementVNode("div",$e,e.toDisplayString(u((W=(A=n.value)==null?void 0:A.worldPosition)==null?void 0:W.y))+", ",1),e.createElementVNode("div",Le,e.toDisplayString(u((G=(q=n.value)==null?void 0:q.worldPosition)==null?void 0:G.z)),1)])]),e.createElementVNode("div",Oe,[s[17]||(s[17]=e.createElementVNode("span",{class:"coord-label"},"世界旋转:",-1)),e.createElementVNode("span",Ue,[e.createElementVNode("div",je,e.toDisplayString(f((X=(Q=n.value)==null?void 0:Q.worldRotation)==null?void 0:X.x))+"°, ",1),e.createElementVNode("div",Je,e.toDisplayString(f((Z=(Y=n.value)==null?void 0:Y.worldRotation)==null?void 0:Z.y))+"°, ",1),e.createElementVNode("div",ke,e.toDisplayString(f((H=(K=n.value)==null?void 0:K.worldRotation)==null?void 0:H.z))+"° ",1)])])])])}}}),Te=ie._export_sfc(Ie,[["__scopeId","data-v-00d48931"]]);function Pe(r,i,o,l=["URDFVisual"]){let m=null;const n=e.ref(null),N=new R.Raycaster,h=new R.Vector2,g=new Map;function _(){o.value.forEach(p=>{p.traverse(d=>{l!=null&&l.includes(d.type)&&g.set(d.id,{obj:d,axis:d.axis||new R.Vector3(1,0,0),limits:d.limits})})})}function u(p){n.value&&n.value.obj.traverse(d=>{var t;d.material&&((t=d.material.emissive)==null||t.set(0))}),n.value=p,p.obj.traverse(d=>{var t;d.material&&((t=d.material.emissive)==null||t.set(65280))})}function f(p){const d=r.value.getBoundingClientRect();h.x=(p.clientX-d.left)/d.width*2-1,h.y=-((p.clientY-d.top)/d.height)*2+1,N.setFromCamera(h,m);const t=N.intersectObjects(o.value,!0);if(t.length===0)return;let s=t[0].object,V=null;for(;s;){if(g.has(s.id)){V=g.get(s.id);break}s=s.parent}V&&u(V)}function E(){r.value&&r.value.removeEventListener("click",f,!1)}function w(){const{scene:p,camera:d}=i();m=d,_(),r.value&&r.value.addEventListener("click",f,!1)}function c(p){n.value&&(n.value.obj.visible=p)}function v(p){var s;const{axis:d,value:t}=p;me((s=n.value)==null?void 0:s.obj,d,t)}function b(p){var s;const{axis:d,value:t}=p;pe((s=n.value)==null?void 0:s.obj,d,t)}return{initRaycaster:w,dispose:E,selectedObject3D:n,setSelectedObjVisible:c,updatePosition:v,updateRotation:b}}exports.URDFRobotController=ue;exports.WorkpieceTreePanel=Te;exports.robotMode=le;exports.sceneType=ne;exports.useRaycaster=Pe;exports.useUrdfLoader=ce;
|
package/package.json
CHANGED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { aJ as S, V as p, M as u, aK as _, Q as E, aL as P, J as c, aM as w, j as O, l as R } from "./three-viewport-gizmo-CkQ98n-T.js";
|
|
2
|
-
const D = { type: "change" }, b = { type: "start" }, M = { type: "end" }, f = new w(), T = new O(), j = Math.cos(70 * R.DEG2RAD), n = new p(), r = 2 * Math.PI, o = {
|
|
3
|
-
NONE: -1,
|
|
4
|
-
ROTATE: 0,
|
|
5
|
-
DOLLY: 1,
|
|
6
|
-
PAN: 2,
|
|
7
|
-
TOUCH_ROTATE: 3,
|
|
8
|
-
TOUCH_PAN: 4,
|
|
9
|
-
TOUCH_DOLLY_PAN: 5,
|
|
10
|
-
TOUCH_DOLLY_ROTATE: 6
|
|
11
|
-
}, y = 1e-6;
|
|
12
|
-
class X extends S {
|
|
13
|
-
/**
|
|
14
|
-
* Constructs a new controls instance.
|
|
15
|
-
*
|
|
16
|
-
* @param {Object3D} object - The object that is managed by the controls.
|
|
17
|
-
* @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
|
|
18
|
-
*/
|
|
19
|
-
constructor(t, e = null) {
|
|
20
|
-
super(t, e), this.state = o.NONE, this.target = new p(), this.cursor = new p(), 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 = 0.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: u.ROTATE, MIDDLE: u.DOLLY, RIGHT: u.PAN }, this.touches = { ONE: _.ROTATE, TWO: _.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new p(), this._lastQuaternion = new E(), this._lastTargetPosition = new p(), this._quat = new E().setFromUnitVectors(t.up, new p(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new P(), this._sphericalDelta = new P(), this._scale = 1, this._panOffset = new p(), this._rotateStart = new c(), this._rotateEnd = new c(), this._rotateDelta = new c(), this._panStart = new c(), this._panEnd = new c(), this._panDelta = new c(), this._dollyStart = new c(), this._dollyEnd = new c(), this._dollyDelta = new c(), this._dollyDirection = new p(), this._mouse = new c(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = L.bind(this), this._onPointerDown = A.bind(this), this._onPointerUp = k.bind(this), this._onContextMenu = Z.bind(this), this._onMouseWheel = N.bind(this), this._onKeyDown = Y.bind(this), this._onTouchStart = I.bind(this), this._onTouchMove = U.bind(this), this._onMouseDown = x.bind(this), this._onMouseMove = C.bind(this), this._interceptControlDown = z.bind(this), this._interceptControlUp = K.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
|
|
21
|
-
}
|
|
22
|
-
connect(t) {
|
|
23
|
-
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";
|
|
24
|
-
}
|
|
25
|
-
disconnect() {
|
|
26
|
-
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";
|
|
27
|
-
}
|
|
28
|
-
dispose() {
|
|
29
|
-
this.disconnect();
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Get the current vertical rotation, in radians.
|
|
33
|
-
*
|
|
34
|
-
* @return {number} The current vertical rotation, in radians.
|
|
35
|
-
*/
|
|
36
|
-
getPolarAngle() {
|
|
37
|
-
return this._spherical.phi;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get the current horizontal rotation, in radians.
|
|
41
|
-
*
|
|
42
|
-
* @return {number} The current horizontal rotation, in radians.
|
|
43
|
-
*/
|
|
44
|
-
getAzimuthalAngle() {
|
|
45
|
-
return this._spherical.theta;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns the distance from the camera to the target.
|
|
49
|
-
*
|
|
50
|
-
* @return {number} The distance from the camera to the target.
|
|
51
|
-
*/
|
|
52
|
-
getDistance() {
|
|
53
|
-
return this.object.position.distanceTo(this.target);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Adds key event listeners to the given DOM element.
|
|
57
|
-
* `window` is a recommended argument for using this method.
|
|
58
|
-
*
|
|
59
|
-
* @param {HTMLDOMElement} domElement - The DOM element
|
|
60
|
-
*/
|
|
61
|
-
listenToKeyEvents(t) {
|
|
62
|
-
t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Removes the key event listener previously defined with `listenToKeyEvents()`.
|
|
66
|
-
*/
|
|
67
|
-
stopListenToKeyEvents() {
|
|
68
|
-
this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Save the current state of the controls. This can later be recovered with `reset()`.
|
|
72
|
-
*/
|
|
73
|
-
saveState() {
|
|
74
|
-
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Reset the controls to their state from either the last time the `saveState()`
|
|
78
|
-
* was called, or the initial state.
|
|
79
|
-
*/
|
|
80
|
-
reset() {
|
|
81
|
-
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(D), this.update(), this.state = o.NONE;
|
|
82
|
-
}
|
|
83
|
-
update(t = null) {
|
|
84
|
-
const e = this.object.position;
|
|
85
|
-
n.copy(e).sub(this.target), n.applyQuaternion(this._quat), this._spherical.setFromVector3(n), this.autoRotate && this.state === o.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);
|
|
86
|
-
let s = this.minAzimuthAngle, a = this.maxAzimuthAngle;
|
|
87
|
-
isFinite(s) && isFinite(a) && (s < -Math.PI ? s += r : s > Math.PI && (s -= r), a < -Math.PI ? a += r : a > Math.PI && (a -= r), s <= a ? this._spherical.theta = Math.max(s, Math.min(a, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (s + a) / 2 ? Math.max(s, this._spherical.theta) : Math.min(a, 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);
|
|
88
|
-
let h = !1;
|
|
89
|
-
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
|
|
90
|
-
this._spherical.radius = this._clampDistance(this._spherical.radius);
|
|
91
|
-
else {
|
|
92
|
-
const l = this._spherical.radius;
|
|
93
|
-
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), h = l != this._spherical.radius;
|
|
94
|
-
}
|
|
95
|
-
if (n.setFromSpherical(this._spherical), n.applyQuaternion(this._quatInverse), e.copy(this.target).add(n), 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) {
|
|
96
|
-
let l = null;
|
|
97
|
-
if (this.object.isPerspectiveCamera) {
|
|
98
|
-
const d = n.length();
|
|
99
|
-
l = this._clampDistance(d * this._scale);
|
|
100
|
-
const m = d - l;
|
|
101
|
-
this.object.position.addScaledVector(this._dollyDirection, m), this.object.updateMatrixWorld(), h = !!m;
|
|
102
|
-
} else if (this.object.isOrthographicCamera) {
|
|
103
|
-
const d = new p(this._mouse.x, this._mouse.y, 0);
|
|
104
|
-
d.unproject(this.object);
|
|
105
|
-
const m = this.object.zoom;
|
|
106
|
-
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), h = m !== this.object.zoom;
|
|
107
|
-
const g = new p(this._mouse.x, this._mouse.y, 0);
|
|
108
|
-
g.unproject(this.object), this.object.position.sub(g).add(d), this.object.updateMatrixWorld(), l = n.length();
|
|
109
|
-
} else
|
|
110
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
|
|
111
|
-
l !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(l).add(this.object.position) : (f.origin.copy(this.object.position), f.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(f.direction)) < j ? this.object.lookAt(this.target) : (T.setFromNormalAndCoplanarPoint(this.object.up, this.target), f.intersectPlane(T, this.target))));
|
|
112
|
-
} else if (this.object.isOrthographicCamera) {
|
|
113
|
-
const l = this.object.zoom;
|
|
114
|
-
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), l !== this.object.zoom && (this.object.updateProjectionMatrix(), h = !0);
|
|
115
|
-
}
|
|
116
|
-
return this._scale = 1, this._performCursorZoom = !1, h || this._lastPosition.distanceToSquared(this.object.position) > y || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > y || this._lastTargetPosition.distanceToSquared(this.target) > y ? (this.dispatchEvent(D), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
|
|
117
|
-
}
|
|
118
|
-
_getAutoRotationAngle(t) {
|
|
119
|
-
return t !== null ? r / 60 * this.autoRotateSpeed * t : r / 60 / 60 * this.autoRotateSpeed;
|
|
120
|
-
}
|
|
121
|
-
_getZoomScale(t) {
|
|
122
|
-
const e = Math.abs(t * 0.01);
|
|
123
|
-
return Math.pow(0.95, this.zoomSpeed * e);
|
|
124
|
-
}
|
|
125
|
-
_rotateLeft(t) {
|
|
126
|
-
this._sphericalDelta.theta -= t;
|
|
127
|
-
}
|
|
128
|
-
_rotateUp(t) {
|
|
129
|
-
this._sphericalDelta.phi -= t;
|
|
130
|
-
}
|
|
131
|
-
_panLeft(t, e) {
|
|
132
|
-
n.setFromMatrixColumn(e, 0), n.multiplyScalar(-t), this._panOffset.add(n);
|
|
133
|
-
}
|
|
134
|
-
_panUp(t, e) {
|
|
135
|
-
this.screenSpacePanning === !0 ? n.setFromMatrixColumn(e, 1) : (n.setFromMatrixColumn(e, 0), n.crossVectors(this.object.up, n)), n.multiplyScalar(t), this._panOffset.add(n);
|
|
136
|
-
}
|
|
137
|
-
// deltaX and deltaY are in pixels; right and down are positive
|
|
138
|
-
_pan(t, e) {
|
|
139
|
-
const s = this.domElement;
|
|
140
|
-
if (this.object.isPerspectiveCamera) {
|
|
141
|
-
const a = this.object.position;
|
|
142
|
-
n.copy(a).sub(this.target);
|
|
143
|
-
let h = n.length();
|
|
144
|
-
h *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * h / s.clientHeight, this.object.matrix), this._panUp(2 * e * h / s.clientHeight, this.object.matrix);
|
|
145
|
-
} else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / s.clientWidth, this.object.matrix), this._panUp(e * (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);
|
|
146
|
-
}
|
|
147
|
-
_dollyOut(t) {
|
|
148
|
-
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);
|
|
149
|
-
}
|
|
150
|
-
_dollyIn(t) {
|
|
151
|
-
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);
|
|
152
|
-
}
|
|
153
|
-
_updateZoomParameters(t, e) {
|
|
154
|
-
if (!this.zoomToCursor)
|
|
155
|
-
return;
|
|
156
|
-
this._performCursorZoom = !0;
|
|
157
|
-
const s = this.domElement.getBoundingClientRect(), a = t - s.left, h = e - s.top, l = s.width, d = s.height;
|
|
158
|
-
this._mouse.x = a / l * 2 - 1, this._mouse.y = -(h / d) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
|
|
159
|
-
}
|
|
160
|
-
_clampDistance(t) {
|
|
161
|
-
return Math.max(this.minDistance, Math.min(this.maxDistance, t));
|
|
162
|
-
}
|
|
163
|
-
//
|
|
164
|
-
// event callbacks - update the object state
|
|
165
|
-
//
|
|
166
|
-
_handleMouseDownRotate(t) {
|
|
167
|
-
this._rotateStart.set(t.clientX, t.clientY);
|
|
168
|
-
}
|
|
169
|
-
_handleMouseDownDolly(t) {
|
|
170
|
-
this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
|
|
171
|
-
}
|
|
172
|
-
_handleMouseDownPan(t) {
|
|
173
|
-
this._panStart.set(t.clientX, t.clientY);
|
|
174
|
-
}
|
|
175
|
-
_handleMouseMoveRotate(t) {
|
|
176
|
-
this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
177
|
-
const e = this.domElement;
|
|
178
|
-
this._rotateLeft(r * this._rotateDelta.x / e.clientHeight), this._rotateUp(r * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
|
|
179
|
-
}
|
|
180
|
-
_handleMouseMoveDolly(t) {
|
|
181
|
-
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();
|
|
182
|
-
}
|
|
183
|
-
_handleMouseMovePan(t) {
|
|
184
|
-
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();
|
|
185
|
-
}
|
|
186
|
-
_handleMouseWheel(t) {
|
|
187
|
-
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();
|
|
188
|
-
}
|
|
189
|
-
_handleKeyDown(t) {
|
|
190
|
-
let e = !1;
|
|
191
|
-
switch (t.code) {
|
|
192
|
-
case this.keys.UP:
|
|
193
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), e = !0;
|
|
194
|
-
break;
|
|
195
|
-
case this.keys.BOTTOM:
|
|
196
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), e = !0;
|
|
197
|
-
break;
|
|
198
|
-
case this.keys.LEFT:
|
|
199
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), e = !0;
|
|
200
|
-
break;
|
|
201
|
-
case this.keys.RIGHT:
|
|
202
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), e = !0;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
e && (t.preventDefault(), this.update());
|
|
206
|
-
}
|
|
207
|
-
_handleTouchStartRotate(t) {
|
|
208
|
-
if (this._pointers.length === 1)
|
|
209
|
-
this._rotateStart.set(t.pageX, t.pageY);
|
|
210
|
-
else {
|
|
211
|
-
const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), a = 0.5 * (t.pageY + e.y);
|
|
212
|
-
this._rotateStart.set(s, a);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
_handleTouchStartPan(t) {
|
|
216
|
-
if (this._pointers.length === 1)
|
|
217
|
-
this._panStart.set(t.pageX, t.pageY);
|
|
218
|
-
else {
|
|
219
|
-
const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), a = 0.5 * (t.pageY + e.y);
|
|
220
|
-
this._panStart.set(s, a);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
_handleTouchStartDolly(t) {
|
|
224
|
-
const e = this._getSecondPointerPosition(t), s = t.pageX - e.x, a = t.pageY - e.y, h = Math.sqrt(s * s + a * a);
|
|
225
|
-
this._dollyStart.set(0, h);
|
|
226
|
-
}
|
|
227
|
-
_handleTouchStartDollyPan(t) {
|
|
228
|
-
this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
|
|
229
|
-
}
|
|
230
|
-
_handleTouchStartDollyRotate(t) {
|
|
231
|
-
this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
|
|
232
|
-
}
|
|
233
|
-
_handleTouchMoveRotate(t) {
|
|
234
|
-
if (this._pointers.length == 1)
|
|
235
|
-
this._rotateEnd.set(t.pageX, t.pageY);
|
|
236
|
-
else {
|
|
237
|
-
const s = this._getSecondPointerPosition(t), a = 0.5 * (t.pageX + s.x), h = 0.5 * (t.pageY + s.y);
|
|
238
|
-
this._rotateEnd.set(a, h);
|
|
239
|
-
}
|
|
240
|
-
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
241
|
-
const e = this.domElement;
|
|
242
|
-
this._rotateLeft(r * this._rotateDelta.x / e.clientHeight), this._rotateUp(r * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd);
|
|
243
|
-
}
|
|
244
|
-
_handleTouchMovePan(t) {
|
|
245
|
-
if (this._pointers.length === 1)
|
|
246
|
-
this._panEnd.set(t.pageX, t.pageY);
|
|
247
|
-
else {
|
|
248
|
-
const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), a = 0.5 * (t.pageY + e.y);
|
|
249
|
-
this._panEnd.set(s, a);
|
|
250
|
-
}
|
|
251
|
-
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
|
|
252
|
-
}
|
|
253
|
-
_handleTouchMoveDolly(t) {
|
|
254
|
-
const e = this._getSecondPointerPosition(t), s = t.pageX - e.x, a = t.pageY - e.y, h = Math.sqrt(s * s + a * a);
|
|
255
|
-
this._dollyEnd.set(0, h), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
|
|
256
|
-
const l = (t.pageX + e.x) * 0.5, d = (t.pageY + e.y) * 0.5;
|
|
257
|
-
this._updateZoomParameters(l, d);
|
|
258
|
-
}
|
|
259
|
-
_handleTouchMoveDollyPan(t) {
|
|
260
|
-
this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
|
|
261
|
-
}
|
|
262
|
-
_handleTouchMoveDollyRotate(t) {
|
|
263
|
-
this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
|
|
264
|
-
}
|
|
265
|
-
// pointers
|
|
266
|
-
_addPointer(t) {
|
|
267
|
-
this._pointers.push(t.pointerId);
|
|
268
|
-
}
|
|
269
|
-
_removePointer(t) {
|
|
270
|
-
delete this._pointerPositions[t.pointerId];
|
|
271
|
-
for (let e = 0; e < this._pointers.length; e++)
|
|
272
|
-
if (this._pointers[e] == t.pointerId) {
|
|
273
|
-
this._pointers.splice(e, 1);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
_isTrackingPointer(t) {
|
|
278
|
-
for (let e = 0; e < this._pointers.length; e++)
|
|
279
|
-
if (this._pointers[e] == t.pointerId) return !0;
|
|
280
|
-
return !1;
|
|
281
|
-
}
|
|
282
|
-
_trackPointer(t) {
|
|
283
|
-
let e = this._pointerPositions[t.pointerId];
|
|
284
|
-
e === void 0 && (e = new c(), this._pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
|
|
285
|
-
}
|
|
286
|
-
_getSecondPointerPosition(t) {
|
|
287
|
-
const e = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
|
|
288
|
-
return this._pointerPositions[e];
|
|
289
|
-
}
|
|
290
|
-
//
|
|
291
|
-
_customWheelEvent(t) {
|
|
292
|
-
const e = t.deltaMode, s = {
|
|
293
|
-
clientX: t.clientX,
|
|
294
|
-
clientY: t.clientY,
|
|
295
|
-
deltaY: t.deltaY
|
|
296
|
-
};
|
|
297
|
-
switch (e) {
|
|
298
|
-
case 1:
|
|
299
|
-
s.deltaY *= 16;
|
|
300
|
-
break;
|
|
301
|
-
case 2:
|
|
302
|
-
s.deltaY *= 100;
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
return t.ctrlKey && !this._controlActive && (s.deltaY *= 10), s;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function A(i) {
|
|
309
|
-
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(i.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(i) && (this._addPointer(i), i.pointerType === "touch" ? this._onTouchStart(i) : this._onMouseDown(i)));
|
|
310
|
-
}
|
|
311
|
-
function L(i) {
|
|
312
|
-
this.enabled !== !1 && (i.pointerType === "touch" ? this._onTouchMove(i) : this._onMouseMove(i));
|
|
313
|
-
}
|
|
314
|
-
function k(i) {
|
|
315
|
-
switch (this._removePointer(i), this._pointers.length) {
|
|
316
|
-
case 0:
|
|
317
|
-
this.domElement.releasePointerCapture(i.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(M), this.state = o.NONE;
|
|
318
|
-
break;
|
|
319
|
-
case 1:
|
|
320
|
-
const t = this._pointers[0], e = this._pointerPositions[t];
|
|
321
|
-
this._onTouchStart({ pointerId: t, pageX: e.x, pageY: e.y });
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
function x(i) {
|
|
326
|
-
let t;
|
|
327
|
-
switch (i.button) {
|
|
328
|
-
case 0:
|
|
329
|
-
t = this.mouseButtons.LEFT;
|
|
330
|
-
break;
|
|
331
|
-
case 1:
|
|
332
|
-
t = this.mouseButtons.MIDDLE;
|
|
333
|
-
break;
|
|
334
|
-
case 2:
|
|
335
|
-
t = this.mouseButtons.RIGHT;
|
|
336
|
-
break;
|
|
337
|
-
default:
|
|
338
|
-
t = -1;
|
|
339
|
-
}
|
|
340
|
-
switch (t) {
|
|
341
|
-
case u.DOLLY:
|
|
342
|
-
if (this.enableZoom === !1) return;
|
|
343
|
-
this._handleMouseDownDolly(i), this.state = o.DOLLY;
|
|
344
|
-
break;
|
|
345
|
-
case u.ROTATE:
|
|
346
|
-
if (i.ctrlKey || i.metaKey || i.shiftKey) {
|
|
347
|
-
if (this.enablePan === !1) return;
|
|
348
|
-
this._handleMouseDownPan(i), this.state = o.PAN;
|
|
349
|
-
} else {
|
|
350
|
-
if (this.enableRotate === !1) return;
|
|
351
|
-
this._handleMouseDownRotate(i), this.state = o.ROTATE;
|
|
352
|
-
}
|
|
353
|
-
break;
|
|
354
|
-
case u.PAN:
|
|
355
|
-
if (i.ctrlKey || i.metaKey || i.shiftKey) {
|
|
356
|
-
if (this.enableRotate === !1) return;
|
|
357
|
-
this._handleMouseDownRotate(i), this.state = o.ROTATE;
|
|
358
|
-
} else {
|
|
359
|
-
if (this.enablePan === !1) return;
|
|
360
|
-
this._handleMouseDownPan(i), this.state = o.PAN;
|
|
361
|
-
}
|
|
362
|
-
break;
|
|
363
|
-
default:
|
|
364
|
-
this.state = o.NONE;
|
|
365
|
-
}
|
|
366
|
-
this.state !== o.NONE && this.dispatchEvent(b);
|
|
367
|
-
}
|
|
368
|
-
function C(i) {
|
|
369
|
-
switch (this.state) {
|
|
370
|
-
case o.ROTATE:
|
|
371
|
-
if (this.enableRotate === !1) return;
|
|
372
|
-
this._handleMouseMoveRotate(i);
|
|
373
|
-
break;
|
|
374
|
-
case o.DOLLY:
|
|
375
|
-
if (this.enableZoom === !1) return;
|
|
376
|
-
this._handleMouseMoveDolly(i);
|
|
377
|
-
break;
|
|
378
|
-
case o.PAN:
|
|
379
|
-
if (this.enablePan === !1) return;
|
|
380
|
-
this._handleMouseMovePan(i);
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
function N(i) {
|
|
385
|
-
this.enabled === !1 || this.enableZoom === !1 || this.state !== o.NONE || (i.preventDefault(), this.dispatchEvent(b), this._handleMouseWheel(this._customWheelEvent(i)), this.dispatchEvent(M));
|
|
386
|
-
}
|
|
387
|
-
function Y(i) {
|
|
388
|
-
this.enabled !== !1 && this._handleKeyDown(i);
|
|
389
|
-
}
|
|
390
|
-
function I(i) {
|
|
391
|
-
switch (this._trackPointer(i), this._pointers.length) {
|
|
392
|
-
case 1:
|
|
393
|
-
switch (this.touches.ONE) {
|
|
394
|
-
case _.ROTATE:
|
|
395
|
-
if (this.enableRotate === !1) return;
|
|
396
|
-
this._handleTouchStartRotate(i), this.state = o.TOUCH_ROTATE;
|
|
397
|
-
break;
|
|
398
|
-
case _.PAN:
|
|
399
|
-
if (this.enablePan === !1) return;
|
|
400
|
-
this._handleTouchStartPan(i), this.state = o.TOUCH_PAN;
|
|
401
|
-
break;
|
|
402
|
-
default:
|
|
403
|
-
this.state = o.NONE;
|
|
404
|
-
}
|
|
405
|
-
break;
|
|
406
|
-
case 2:
|
|
407
|
-
switch (this.touches.TWO) {
|
|
408
|
-
case _.DOLLY_PAN:
|
|
409
|
-
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
410
|
-
this._handleTouchStartDollyPan(i), this.state = o.TOUCH_DOLLY_PAN;
|
|
411
|
-
break;
|
|
412
|
-
case _.DOLLY_ROTATE:
|
|
413
|
-
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
414
|
-
this._handleTouchStartDollyRotate(i), this.state = o.TOUCH_DOLLY_ROTATE;
|
|
415
|
-
break;
|
|
416
|
-
default:
|
|
417
|
-
this.state = o.NONE;
|
|
418
|
-
}
|
|
419
|
-
break;
|
|
420
|
-
default:
|
|
421
|
-
this.state = o.NONE;
|
|
422
|
-
}
|
|
423
|
-
this.state !== o.NONE && this.dispatchEvent(b);
|
|
424
|
-
}
|
|
425
|
-
function U(i) {
|
|
426
|
-
switch (this._trackPointer(i), this.state) {
|
|
427
|
-
case o.TOUCH_ROTATE:
|
|
428
|
-
if (this.enableRotate === !1) return;
|
|
429
|
-
this._handleTouchMoveRotate(i), this.update();
|
|
430
|
-
break;
|
|
431
|
-
case o.TOUCH_PAN:
|
|
432
|
-
if (this.enablePan === !1) return;
|
|
433
|
-
this._handleTouchMovePan(i), this.update();
|
|
434
|
-
break;
|
|
435
|
-
case o.TOUCH_DOLLY_PAN:
|
|
436
|
-
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
437
|
-
this._handleTouchMoveDollyPan(i), this.update();
|
|
438
|
-
break;
|
|
439
|
-
case o.TOUCH_DOLLY_ROTATE:
|
|
440
|
-
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
441
|
-
this._handleTouchMoveDollyRotate(i), this.update();
|
|
442
|
-
break;
|
|
443
|
-
default:
|
|
444
|
-
this.state = o.NONE;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
function Z(i) {
|
|
448
|
-
this.enabled !== !1 && i.preventDefault();
|
|
449
|
-
}
|
|
450
|
-
function z(i) {
|
|
451
|
-
i.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
452
|
-
}
|
|
453
|
-
function K(i) {
|
|
454
|
-
i.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
455
|
-
}
|
|
456
|
-
export {
|
|
457
|
-
X as O
|
|
458
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("./three-viewport-gizmo-BV37JzRa.cjs"),y={type:"change"},m={type:"start"},g={type:"end"},_=new s.Ray,b=new s.Plane,E=Math.cos(70*s.MathUtils.DEG2RAD),h=new s.Vector3,l=2*Math.PI,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},u=1e-6;class P extends s.Controls{constructor(t,e=null){super(t,e),this.state=a.NONE,this.target=new s.Vector3,this.cursor=new s.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:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN},this.touches={ONE:s.TOUCH.ROTATE,TWO:s.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 s.Vector3,this._lastQuaternion=new s.Quaternion,this._lastTargetPosition=new s.Vector3,this._quat=new s.Quaternion().setFromUnitVectors(t.up,new s.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new s.Spherical,this._sphericalDelta=new s.Spherical,this._scale=1,this._panOffset=new s.Vector3,this._rotateStart=new s.Vector2,this._rotateEnd=new s.Vector2,this._rotateDelta=new s.Vector2,this._panStart=new s.Vector2,this._panEnd=new s.Vector2,this._panDelta=new s.Vector2,this._dollyStart=new s.Vector2,this._dollyEnd=new s.Vector2,this._dollyDelta=new s.Vector2,this._dollyDirection=new s.Vector3,this._mouse=new s.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=D.bind(this),this._onPointerDown=T.bind(this),this._onPointerUp=M.bind(this),this._onContextMenu=L.bind(this),this._onMouseWheel=w.bind(this),this._onKeyDown=R.bind(this),this._onTouchStart=j.bind(this),this._onTouchMove=A.bind(this),this._onMouseDown=S.bind(this),this._onMouseMove=O.bind(this),this._interceptControlDown=C.bind(this),this._interceptControlUp=k.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(y),this.update(),this.state=a.NONE}update(t=null){const e=this.object.position;h.copy(e).sub(this.target),h.applyQuaternion(this._quat),this._spherical.setFromVector3(h),this.autoRotate&&this.state===a.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 o=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(o)&&isFinite(n)&&(o<-Math.PI?o+=l:o>Math.PI&&(o-=l),n<-Math.PI?n+=l:n>Math.PI&&(n-=l),o<=n?this._spherical.theta=Math.max(o,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(o+n)/2?Math.max(o,this._spherical.theta):Math.min(n,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 c=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=c!=this._spherical.radius}if(h.setFromSpherical(this._spherical),h.applyQuaternion(this._quatInverse),e.copy(this.target).add(h),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 c=null;if(this.object.isPerspectiveCamera){const p=h.length();c=this._clampDistance(p*this._scale);const d=p-c;this.object.position.addScaledVector(this._dollyDirection,d),this.object.updateMatrixWorld(),r=!!d}else if(this.object.isOrthographicCamera){const p=new s.Vector3(this._mouse.x,this._mouse.y,0);p.unproject(this.object);const d=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=d!==this.object.zoom;const f=new s.Vector3(this._mouse.x,this._mouse.y,0);f.unproject(this.object),this.object.position.sub(f).add(p),this.object.updateMatrixWorld(),c=h.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;c!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(c).add(this.object.position):(_.origin.copy(this.object.position),_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_.direction))<E?this.object.lookAt(this.target):(b.setFromNormalAndCoplanarPoint(this.object.up,this.target),_.intersectPlane(b,this.target))))}else if(this.object.isOrthographicCamera){const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),c!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>u||8*(1-this._lastQuaternion.dot(this.object.quaternion))>u||this._lastTargetPosition.distanceToSquared(this.target)>u?(this.dispatchEvent(y),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?l/60*this.autoRotateSpeed*t:l/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){h.setFromMatrixColumn(e,0),h.multiplyScalar(-t),this._panOffset.add(h)}_panUp(t,e){this.screenSpacePanning===!0?h.setFromMatrixColumn(e,1):(h.setFromMatrixColumn(e,0),h.crossVectors(this.object.up,h)),h.multiplyScalar(t),this._panOffset.add(h)}_pan(t,e){const o=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;h.copy(n).sub(this.target);let r=h.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/o.clientHeight,this.object.matrix),this._panUp(2*e*r/o.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/o.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/o.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,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const o=this.domElement.getBoundingClientRect(),n=t-o.left,r=e-o.top,c=o.width,p=o.height;this._mouse.x=n/c*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 e=this.domElement;this._rotateLeft(l*this._rotateDelta.x/e.clientHeight),this._rotateUp(l*this._rotateDelta.y/e.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 e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(l*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-l*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(l*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-l*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),o=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._rotateStart.set(o,n)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),o=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._panStart.set(o,n)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),o=t.pageX-e.x,n=t.pageY-e.y,r=Math.sqrt(o*o+n*n);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 o=this._getSecondPointerPosition(t),n=.5*(t.pageX+o.x),r=.5*(t.pageY+o.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(l*this._rotateDelta.x/e.clientHeight),this._rotateUp(l*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),o=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._panEnd.set(o,n)}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 e=this._getSecondPointerPosition(t),o=t.pageX-e.x,n=t.pageY-e.y,r=Math.sqrt(o*o+n*n);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 c=(t.pageX+e.x)*.5,p=(t.pageY+e.y)*.5;this._updateZoomParameters(c,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 e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new s.Vector2,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,o={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:o.deltaY*=16;break;case 2:o.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(o.deltaY*=10),o}}function T(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function D(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function M(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(g),this.state=a.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function S(i){let t;switch(i.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 s.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=a.DOLLY;break;case s.MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=a.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=a.ROTATE}break;case s.MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=a.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=a.PAN}break;default:this.state=a.NONE}this.state!==a.NONE&&this.dispatchEvent(m)}function O(i){switch(this.state){case a.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case a.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case a.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function w(i){this.enabled===!1||this.enableZoom===!1||this.state!==a.NONE||(i.preventDefault(),this.dispatchEvent(m),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(g))}function R(i){this.enabled!==!1&&this._handleKeyDown(i)}function j(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case s.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=a.TOUCH_ROTATE;break;case s.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=a.TOUCH_PAN;break;default:this.state=a.NONE}break;case 2:switch(this.touches.TWO){case s.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=a.TOUCH_DOLLY_PAN;break;case s.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=a.TOUCH_DOLLY_ROTATE;break;default:this.state=a.NONE}break;default:this.state=a.NONE}this.state!==a.NONE&&this.dispatchEvent(m)}function A(i){switch(this._trackPointer(i),this.state){case a.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case a.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case a.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case a.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=a.NONE}}function L(i){this.enabled!==!1&&i.preventDefault()}function C(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function k(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}exports.OrbitControls=P;
|