ss-component-new 1.2.97 → 1.2.99
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/MTLLoader-B4z0XNO-.js +304 -0
- package/dist/MTLLoader-n_3HPhif.cjs +2 -0
- package/dist/OBJLoader-C_JaUegI.cjs +5 -0
- package/dist/OBJLoader-Dilcv9TL.js +356 -0
- package/dist/{OrbitControls-B85G8nPk.cjs → OrbitControls-8LBwRzcq.cjs} +1 -1
- package/dist/{OrbitControls-DFhYzlF3.js → OrbitControls-Cz47Q27N.js} +1 -1
- package/dist/{animationData-DfKVkFbz.js → animationData-C8lM4zZj.js} +1 -1
- package/dist/{animationData-DxBvEqB1.cjs → animationData-CKcPDmLp.cjs} +1 -1
- package/dist/{iconfont-C7kE-QbU.cjs → iconfont-B1cUqs_N.cjs} +1 -1
- package/dist/{iconfont-WOKNi2xx.js → iconfont-CUWS5tNH.js} +2 -2
- package/dist/{index-D0hovh9R.cjs → index-2hqZ_tND.cjs} +1 -1
- package/dist/{index-331j518H.cjs → index-AuEh0RiU.cjs} +1 -1
- package/dist/{index-D_igus4A.cjs → index-B2UPNwqJ.cjs} +1 -1
- package/dist/{index-BYk9Fb6p.js → index-BCvmfE-Q.js} +3 -3
- package/dist/{index-DeOwZgqL.js → index-BDw8DIQx.js} +130 -130
- package/dist/{index-CqI3frdZ.js → index-BPv8txj6.js} +6 -6
- package/dist/{index-DgZVeYqH.js → index-BQaejVqo.js} +1 -1
- package/dist/{index-DSPjcpWK.cjs → index-Ba16ouw0.cjs} +1 -1
- package/dist/{index-D_RGoDln.js → index-BaSO3EEl.js} +3 -3
- package/dist/{index-DHZMd8iK.cjs → index-BdSiNUC0.cjs} +1 -1
- package/dist/{index-BDxPlbe2.cjs → index-BfU8GMj1.cjs} +1 -1
- package/dist/{index-Cppt0AsF.cjs → index-BjKKDSDx.cjs} +1 -1
- package/dist/{index-C-dlFxRJ.cjs → index-BqgfejIC.cjs} +1 -1
- package/dist/{index-BODyH6MD.js → index-BxONUPjM.js} +1 -1
- package/dist/{index-BFzMf0GC.js → index-Byp3gJNW.js} +1 -1
- package/dist/{index-DJ6qg2Mo.js → index-C7ZsHeLt.js} +3 -3
- package/dist/{index-B-AhHUV1.js → index-C9p_wwJ7.js} +6 -6
- package/dist/{index-BoTiP0aV.js → index-CKlt750z.js} +1 -1
- package/dist/{index-CQRJ3pLh.cjs → index-CQwDw3-2.cjs} +1 -1
- package/dist/{index-hhS08X8b.js → index-CR1Ng5ip.js} +3 -3
- package/dist/{index-D6u590uA.cjs → index-CZIqVNof.cjs} +1 -1
- package/dist/{index-iErxMZBi.cjs → index-C_208RkZ.cjs} +1 -1
- package/dist/{index-S1LIIzCa.cjs → index-CqZ1E-Mt.cjs} +1 -1
- package/dist/{index-DHjtOySN.js → index-CrNsPd4D.js} +2 -2
- package/dist/{index-DrzK0O_g.cjs → index-CvQCAGWI.cjs} +1 -1
- package/dist/{index-Cnk_4Zz5.cjs → index-CyCcPnZb.cjs} +1 -1
- package/dist/{index-BI7g3c_u.js → index-CyE5qCBb.js} +13 -13
- package/dist/{index-DHBoRe9V.cjs → index-D32pAhQk.cjs} +1 -1
- package/dist/{index-DRfVnLTN.js → index-DAUjjqaD.js} +391 -391
- package/dist/{index-DbDM-XfB.cjs → index-DQTlc6Gq.cjs} +1 -1
- package/dist/{index-B_zjoT4m.js → index-DTilOAv_.js} +2 -2
- package/dist/{index-_PP-dSm3.cjs → index-D_22J0ok.cjs} +1 -1
- package/dist/{index-iZ9BRKg5.js → index-DboUMA_C.js} +1 -1
- package/dist/{index-BXv3aZ7v.js → index-DgMQpO6g.js} +1 -1
- package/dist/{index-CPAXrzNY.cjs → index-Dh6GqpZF.cjs} +1 -1
- package/dist/{index-CZPnP0uy.cjs → index-DhqEoDPT.cjs} +1 -1
- package/dist/{index-CeGM8aBH.js → index-DlwlGkyt.js} +2 -2
- package/dist/{index-6sZXjGGz.cjs → index-DtDmxPdD.cjs} +1 -1
- package/dist/{index-kLDMroPk.js → index-GxmJC9kr.js} +1 -1
- package/dist/{index-CLOUp_4j.cjs → index-XKn5AuYT.cjs} +1 -1
- package/dist/{index-Cr5if46q.js → index-mEKMjplD.js} +1 -1
- package/dist/{index-Bhha7SY3.js → index-vglZ0qjT.js} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_0b6f1a18_lang-DSlAeFA3.cjs → index.vue_vue_type_style_index_0_scoped_0b6f1a18_lang-DKwCF412.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_0b6f1a18_lang-ERjMISIK.js → index.vue_vue_type_style_index_0_scoped_0b6f1a18_lang-DqIuWlps.js} +6 -6
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-3GcG1eTD.js → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-CICG8Qah.js} +8908 -8949
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dzyqt2Z-.cjs → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-K6lh7Rrj.cjs} +302 -302
- package/dist/{index.vue_vue_type_style_index_0_scoped_92477073_lang-mJB_yl_P.js → index.vue_vue_type_style_index_0_scoped_92477073_lang-Cpyo5jke.js} +3 -3
- package/dist/{index.vue_vue_type_style_index_0_scoped_92477073_lang-DODc2KPN.cjs → index.vue_vue_type_style_index_0_scoped_92477073_lang-Cq8VF9uK.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_1_lang-BH0DRFVE.js → index.vue_vue_type_style_index_1_lang-B_HCEX9y.js} +6 -5
- package/dist/{index.vue_vue_type_style_index_1_lang-BRFs_L5R.cjs → index.vue_vue_type_style_index_1_lang-rTLLuvuo.cjs} +5 -5
- package/dist/loaderUtil-B0djdt91.js +5 -0
- package/dist/loaderUtil-CaWWb8db.cjs +1 -0
- package/dist/{main-Z5UMyCj6.js → main-DHx-3OSy.js} +2 -2
- package/dist/{main-B541MQH8.cjs → main-DS156sQ4.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 +10 -10
- package/dist/{threeModel-tKq0hvaK.cjs → threeModel-CfIK1rQB.cjs} +1 -1
- package/dist/{threeModel-BcjGbIJZ.js → threeModel-WYCdw_Ff.js} +4 -4
- package/dist/{threePreview-BnPMGQ2H.js → threePreview-C29AR7Mr.js} +310 -305
- package/dist/threePreview-Ci8TnUQ8.cjs +1 -0
- package/dist/{threeSceneView-DVUTlm6F.cjs → threeSceneView-C2MDCMux.cjs} +2 -2
- package/dist/{threeSceneView-BUD002PP.js → threeSceneView-F15mW1mm.js} +7 -7
- package/dist/threeSceneViewForCPMPIP-DK4G_ZpP.js +687 -0
- package/dist/threeSceneViewForCPMPIP-DuPZn_qv.cjs +5 -0
- package/dist/threeTrackPathView-C4eBUMef.cjs +370 -0
- package/dist/{threeTrackPathView-DDCEu3Gx.js → threeTrackPathView-DMj6YGxT.js} +436 -427
- package/dist/{threeViewerHost-BVeUteVd.js → threeViewerHost-C9ipsMff.js} +2 -2
- package/dist/{threeViewerHost-Sda_AoRw.cjs → threeViewerHost-CW6JmOUJ.cjs} +2 -2
- package/dist/{urdfTree-Br9VYqKp.cjs → urdfTree-CTiMB7ge.cjs} +1 -1
- package/dist/{urdfTree-DaWvX-6R.js → urdfTree-DGEACy9-.js} +1 -1
- package/dist/{workpieceTreePanel-BdRaFNRp.js → workpieceTreePanel-C1gy5a8r.js} +53 -52
- package/dist/workpieceTreePanel-Ded0Gqke.cjs +1 -0
- package/package.json +1 -1
- package/dist/MTLLoader-DnouUI-8.js +0 -657
- package/dist/MTLLoader-zZDM0NQh.cjs +0 -6
- package/dist/obj/model.mtl +0 -42
- package/dist/obj/model.obj +0 -26110
- package/dist/threePreview-DD0br2ae.cjs +0 -1
- package/dist/threeSceneViewForCPMPIP-BYYbyqD7.cjs +0 -5
- package/dist/threeSceneViewForCPMPIP-D4RC4BAo.js +0 -683
- package/dist/threeTrackPathView-BvUihuyk.cjs +0 -370
- package/dist/workpieceTreePanel-Z3aVdOWB.cjs +0 -1
- package/public/obj/model.mtl +0 -42
- package/public/obj/model.obj +0 -26110
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),Be=require("./index.vue_vue_type_style_index_1_lang-B8_elAaU.cjs"),R=require("./workpieceTreePanel-Ded0Gqke.cjs"),Q=require("./iconfont-B1cUqs_N.cjs"),f=require("./index-C8qRkCgn.cjs");require("./index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-K6lh7Rrj.cjs");const ee=require("./index-DhufphmT.cjs"),J=require("./urdfTree-CTiMB7ge.cjs"),re=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),N=require("./svgIcon-CUM54R6L.cjs"),Ue=require("./animationData-CKcPDmLp.cjs"),$e=require("./loaderUtil-CaWWb8db.cjs"),se=require("./index-D_22J0ok.cjs"),Re={class:"panel-content"},je={class:"action-bar"},Ae={key:0,class:"animation-controls"},Le={class:"control-row"},Ie={class:"control-row"},Oe={class:"frame-info"},Fe={class:"control-row"},qe={key:1,class:"empty-state"},Je={class:"dialog-footer"},He=e.defineComponent({__name:"urdfAnimationPanel",props:{model:{},scene:{},xyzbcList:{}},setup(j,{expose:H}){const _=j,o=e.ref([]),w=e.ref(!1),C=e.ref(""),i=e.ref("stopped"),d=e.ref(0),T=e.ref(0),U=e.ref(10),g=e.ref(null);let m=0;const A=e.ref([]),L=e.computed(()=>_.model?J.getNonFixedJoints(_.model).map(r=>r.name):[]),D=e.computed(()=>[...L.value]),X=e.computed(()=>D.value.length>0?`请按以下格式粘贴数据 (第一行为表头,使用 Tab 分隔):
|
|
2
|
+
${D.value.join(" ")}
|
|
3
|
+
0 0 0 ...
|
|
4
|
+
1 2 3 ...`:"请先加载模型。"),M=e.computed(()=>o.value[d.value]||{});e.watch(()=>_.model,s=>{s?(g.value=new R.URDFRobotController(s),A.value=J.getAllLinkName(s),d.value=0):(g.value=null,A.value=[])},{immediate:!0});const z=s=>{if(s<0||s>=o.value.length){console.error(`帧索引 ${s} 超出范围`);return}const n=o.value[s];if(g.value){const r={};L.value.forEach(V=>{const v=parseFloat(n[V]);isNaN(v)||(r[V]=v)}),g.value.setJointAngles(r)}d.value=s,T.value=o.value.length>1?s/(o.value.length-1)*100:100},W=async s=>{try{for(let n=d.value;n<o.value.length;n++){if(s!==m)return;const r=o.value[n],V={};if(g.value)L.value.forEach(v=>{const p=parseFloat(r[v]);isNaN(p)||(V[v]=p)}),await g.value.animateToState(V,U.value,v=>{s===m&&(T.value=(n+v)/o.value.length*100)});else{if(await new Promise(v=>setTimeout(v,U.value)),s!==m)return;T.value=(n+1)/o.value.length*100}d.value=n}s===m&&(f.ElMessage.success("动画播放完成"),i.value="stopped",T.value=100)}catch(n){console.error("动画播放出错:",n),f.ElMessage.error("动画播放出错"),i.value="stopped"}},$=()=>{if(o.value.length===0){f.ElMessage.error("无动画数据");return}i.value==="stopped"&&(d.value=0,z(0)),i.value="playing",m++,W(m),f.ElMessage.info("动画播放中")},I=()=>{i.value==="playing"&&(m++,i.value="paused",f.ElMessage.info("动画已暂停"))},O=()=>{m++,i.value="stopped",d.value=0,T.value=0,z(0),f.ElMessage.info("动画已停止并重置")},P=()=>{i.value==="playing"?I():$()},y=s=>{m++,i.value="paused",z(s)},B=()=>{if(!C.value.trim()){f.ElMessage.warning("导入内容不能为空");return}const s=C.value.trim().split(`
|
|
5
|
+
`).filter(p=>p.trim()!=="");if(s.length<2){f.ElMessage.error("导入数据至少需要包含表头行和一行数据");return}const n=s[0].split(" ").map(p=>p.trim()),r={};if(n.forEach((p,u)=>{D.value.includes(p)&&(r[u]=p)}),Object.keys(r).length===0){f.ElMessage.error("没有找到匹配的表头,请检查表头名称是否正确");return}const v=s.slice(1).map(p=>{const u=p.split(" "),E={};return D.value.forEach(S=>{E[S]="0"}),Object.entries(r).forEach(([S,Y])=>{const F=u[parseInt(S)];F!==void 0&&F.trim()!==""&&(E[Y]=F.trim())}),E});v.length>0?(o.value=v,f.ElMessage.success(`成功导入 ${v.length} 行数据!`),w.value=!1,C.value="",O()):f.ElMessage.error("未能解析到有效数据,请检查格式。")};e.watch(()=>_.xyzbcList,()=>{_.xyzbcList&&(o.value=f.cloneDeep(_.xyzbcList))},{immediate:!0});const k=s=>`第 ${s+1} 帧`;return H({handlePlayPause:P,playAnimation:$,pauseAnimation:I,stopAnimation:O}),e.onUnmounted(()=>{m++}),(s,n)=>{const r=e.resolveComponent("el-input-number"),V=e.resolveComponent("el-slider"),v=e.resolveComponent("el-input"),p=e.resolveComponent("el-dialog");return e.openBlock(),e.createElementBlock("div",Re,[e.createElementVNode("div",je,[e.createVNode(ee._sfc_main,{onClick:n[0]||(n[0]=u=>w.value=!0),disabled:D.value.length===0,modelValue:"导入数据"},null,8,["disabled"])]),o.value.length>0?(e.openBlock(),e.createElementBlock("div",Ae,[e.createElementVNode("div",Le,[n[6]||(n[6]=e.createElementVNode("label",null,"帧间隔 (ms):",-1)),e.createVNode(r,{modelValue:U.value,"onUpdate:modelValue":n[1]||(n[1]=u=>U.value=u),min:10,max:5e3,step:100,size:"small",style:{width:"120px"}},null,8,["modelValue"])]),e.createElementVNode("div",Ie,[n[7]||(n[7]=e.createElementVNode("label",null,"当前帧:",-1)),e.createElementVNode("span",Oe,e.toDisplayString(d.value+1)+" / "+e.toDisplayString(o.value.length),1)]),e.createElementVNode("div",Fe,[n[8]||(n[8]=e.createElementVNode("label",null,"动画进度:",-1)),e.createVNode(V,{modelValue:d.value,"onUpdate:modelValue":n[2]||(n[2]=u=>d.value=u),min:0,max:o.value.length>0?o.value.length-1:0,step:1,"format-tooltip":k,onInput:y,disabled:o.value.length===0||i.value==="playing",style:{"flex-grow":"1",margin:"0 10px"}},null,8,["modelValue","max","disabled"])]),e.createElementVNode("div",null,[n[9]||(n[9]=e.createElementVNode("label",null,"当前帧数据:",-1)),e.createElementVNode("div",null,[M.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(M.value,(u,E)=>(e.openBlock(),e.createElementBlock("div",{key:E},e.toDisplayString(E)+": "+e.toDisplayString(u),1))),128)):e.createCommentVNode("",!0)])])])):e.createCommentVNode("",!0),o.value.length===0?(e.openBlock(),e.createElementBlock("div",qe,n[10]||(n[10]=[e.createElementVNode("p",null,"请先导入数据",-1)]))):e.createCommentVNode("",!0),e.createVNode(p,{modelValue:w.value,"onUpdate:modelValue":n[5]||(n[5]=u=>w.value=u),title:"导入数据",width:"500px"},{footer:e.withCtx(()=>[e.createElementVNode("span",Je,[e.createVNode(ee._sfc_main,{modelValue:"取消",onClick:n[4]||(n[4]=u=>w.value=!1)}),e.createVNode(ee._sfc_main,{modelValue:"确认导入",onClick:B,type:"primary"})])]),default:e.withCtx(()=>[n[11]||(n[11]=e.createElementVNode("p",{class:"import-instructions"}," 请从Excel或CSV中复制数据 (首行为表头, Tab分隔) ",-1)),e.createVNode(v,{modelValue:C.value,"onUpdate:modelValue":n[3]||(n[3]=u=>C.value=u),type:"textarea",rows:10,placeholder:X.value},null,8,["modelValue","placeholder"])]),_:1,__:[11]},8,["modelValue"])])}}}),ie=re._export_sfc(He,[["__scopeId","data-v-06bc34b3"]]),Xe=async j=>await $e.loadObjByUrl(j),Ge={class:"obj-viewer-container"},Ke={class:"buttonGroup-topLeft"},We={class:"buttonGroup-left"},Ye={class:"buttonGroup-right"},Ze={class:"buttonGroup-bottom"},Qe={class:"top-panel"},et={class:"panel-header"},tt={class:"panel-body"},lt={class:"left-panel"},nt={class:"panel-header"},ot={class:"panel-body"},at={key:1,class:"clipping-content"},st={class:"radio-group"},it={class:"radio-label"},rt={class:"radio-label"},ut={class:"radio-label"},ct={class:"radio-label"},dt={class:"right-panel"},vt={class:"panel-header"},mt={class:"panel-body"},pt={key:0,class:"loading-overlay"},ft={key:1,class:"brand"},gt={class:"brand-item"},ht={class:"item-value"},Nt={class:"brand-item"},Vt={class:"item-value"},bt={class:"brand-item"},yt={class:"item-value"},Et=e.defineComponent({__name:"threeSceneViewForCPMPIP",props:{fileBlobs:{default:()=>[]},threeData:{}},emits:["getAnimationData","getThreeData"],setup(j,{emit:H}){const _=H,o=j,w=e.inject("setManagementPageTitle"),C=e.inject("setManagementPageVisible"),i=e.computed(()=>{var t,a;return(a=(t=o==null?void 0:o.threeData)==null?void 0:t.data)==null?void 0:a.machine}),d=e.computed(()=>{var t;return(t=i==null?void 0:i.value)==null?void 0:t.产品型号}),T=e.computed(()=>{var t;return(t=i==null?void 0:i.value)==null?void 0:t.编号}),U=e.computed(()=>{var t;return(t=i==null?void 0:i.value)==null?void 0:t.厂家}),g=e.computed(()=>{var t,a;return(a=(t=o==null?void 0:o.threeData)==null?void 0:t.data)==null?void 0:a.workpieceInfo}),m=e.computed(()=>{var t,a;return(a=(t=o==null?void 0:o.threeData)==null?void 0:t.data)==null?void 0:a.knife}),A=e.ref([]),L=async l=>{!l||!l.isExtra||(await D(l),w==null||w(l==null?void 0:l.pageName),C==null||C(!0))},D=se.debounce(async l=>{await se.onPageBack();const{mainKey:t,baseMenuPath:a}=l||{};Be.copyAdd(a,t)},500);e.watch(()=>[d.value,g.value,m.value],()=>{var h,c,oe,ae;const l=[],t={pageName:"机床",name:"机床",label:"机床",type:"机床",id:"机床",path:"机床",baseMenuPath:"设备库/机床",children:[],show:!0,isPenultimate:!1};d.value&&t.children.push({isExtra:!0,pageName:"机床",mainKey:d.value,label:d.value,baseMenuPath:"设备库/机床"});const a={pageName:"工件",name:"工件",label:"工件",type:"工件",id:"工件",path:"工件",baseMenuPath:"设备库/机床",children:[],show:!0,isPenultimate:!1};g.value&&a.children.push({isExtra:!0,type:(h=g.value)==null?void 0:h.type,pageName:"工件",mainKey:(c=g.value)==null?void 0:c.name,label:(oe=g.value)==null?void 0:oe.name,baseMenuPath:`工件库/${(ae=g.value)==null?void 0:ae.type}`});const K={pageName:"刀具",name:"刀具",label:"刀具",type:"刀具",id:"刀具",path:"刀具",children:[],show:!0,isPenultimate:!1};m.value&&K.children.push({isExtra:!0,pageName:"刀具",mainKey:m.value,label:m.value,baseMenuPath:"设备库/刀具"}),l.push(t,a,K),A.value=l},{immediate:!0});const X=e.ref([]),M=e.computed(()=>{var t,a;return(a=(t=o==null?void 0:o.threeData)==null?void 0:t.data)==null?void 0:a.csvUrl});e.watch(()=>M.value,async()=>{if(console.log("three data",o==null?void 0:o.threeData),console.log("csvUrl",M.value),M.value){const l=await Ue.initXYZBCList(M.value);X.value=l}},{immediate:!0});const z=e.computed(()=>{var t,a;return(a=(t=o==null?void 0:o.threeData)==null?void 0:t.data)==null?void 0:a.bladeObjUrl}),W=e.ref(R.sceneType.ROBOT),$=e.ref(null),I=e.ref(!1),O=e.ref(""),P=e.ref(!1),y=e.ref(""),B=e.ref(!1),k=e.ref(""),s=e.ref(!1),n=e.ref(""),r=e.shallowRef(null),V=e.ref("叶片模型"),v=e.shallowRef(null),p=e.shallowRef(null),u=e.shallowRef(null),E=e.ref(ie),{currentModels:S,resetView:Y,initThreeJS:F,handleResize:te,getThreeJSObjects:q,cleanup:ue,setModels:le,axesHelperVisible:ce,toggleAxesVisibility:de,zoomIn:ve,zoomOut:me}=Q.useThreeJS($),{loadSceneFromFile:pe}=R.useUrdfLoader(q,S,I,O),{isAnimating:ne,toggleAnimation:fe,stopAnimation:ge}=Q.useAnimation(q,S),{isClipping:he,activeClippingAxis:b,toggleClipping:Ne,updateClippingPlanes:x}=Q.useClipping(q,S),{initRaycaster:Ve,selectedObject3D:be,setSelectedObjVisible:ye,updatePosition:Ee,updateRotation:ke,dispose:we}=R.useRaycaster($,q,S),Ce=()=>{de()},_e=e.computed(()=>W.value===R.sceneType.ROBOT),G=l=>{P.value=!0,y.value=l,l==="剖面视图"&&!he.value&&Ne()},Z=l=>{B.value=!0,k.value=l,l==="动画仿真"&&_("getAnimationData")},Pe=()=>{var l;(l=E.value)==null||l.handlePlayPause()},Se=()=>{var l;(l=E.value)==null||l.pauseAnimation()},xe=()=>{var l;(l=E.value)==null||l.stopAnimation()},Te=(l,t)=>J.getMeshFromLink(l,t),De=async l=>{const t=Te(l,V.value);if(p.value=t,console.log("bladeObjUrl",z.value),t&&t.parent&&z.value){const a=await Xe(z.value);a.name="blade_clone",t.parent.add(a),a.position.copy(t.position),a.rotation.copy(t.rotation),a.scale.copy(t.scale),t.visible=!1,v.value=a}else V.value&&console.warn(`在 Blade '${V.value}' 中未找到可替换的网格或其没有父级。`)};e.watch(()=>o.fileBlobs,l=>{if(l&&l.length>0){const t=l[0];if(!t.name.toLowerCase().endsWith(".urdf"))return;pe(t).then(a=>{r.value=a,a&&De(a)}).catch(a=>{console.error("加载URDF文件时发生错误:",a),f.ElMessage.error("加载urdf模型失败"),r.value=null})}else r.value=null},{immediate:!0,deep:!0}),e.watch(r,l=>{le(l?[l]:[]),Ve()});const Me=()=>{F(),window.addEventListener("resize",te);const l=q();u.value=l.scene},ze=()=>{y.value="",k.value="",window.removeEventListener("resize",te),ne.value&&ge(),ue(),we()};return e.onMounted(async()=>{await e.nextTick();try{Me()}catch(l){console.error("Three.js 初始化失败:",l),f.ElMessage.error("渲染引擎初始化失败!")}}),e.onBeforeUnmount(()=>{ze()}),(l,t)=>{const a=e.resolveComponent("el-scrollbar"),K=e.resolveComponent("PipeAnalysisPanel");return e.openBlock(),e.createElementBlock("div",Ge,[e.withDirectives(e.createElementVNode("div",{ref_key:"threejsContainer",ref:$,class:"threejs-container"},null,512),[[e.vShow,_e.value]]),e.createElementVNode("div",Ke,[e.createVNode(N.ThreeSvgIcon,{name:"viewReset",size:"24",onClick:e.unref(Y),title:"重置"},null,8,["onClick"]),e.createVNode(N.ThreeSvgIcon,{name:"fangda",size:"24",title:"放大",onClick:e.unref(ve)},null,8,["onClick"]),e.createVNode(N.ThreeSvgIcon,{name:"suoxiao",size:"24",title:"缩小",onClick:e.unref(me)},null,8,["onClick"]),e.createVNode(N.ThreeSvgIcon,{name:"lookAround",size:"24",onClick:e.unref(fe),title:e.unref(ne)?"停止动画":"动画视图"},null,8,["onClick","title"]),e.createVNode(N.ThreeSvgIcon,{name:"zuobiaoxi",size:"24",active:e.unref(ce),onClick:Ce,title:"显隐坐标轴"},null,8,["active"])]),e.createElementVNode("div",We,[e.renderSlot(l.$slots,"button-left",{switchRightPanel:G},void 0,!0),e.createVNode(N.ThreeSvgIcon,{name:"jiegoushu",size:"24",onClick:t[0]||(t[0]=h=>G("场景树")),active:P.value&&y.value==="场景树",title:"场景树"},null,8,["active"]),e.createVNode(N.ThreeSvgIcon,{name:"clipping",size:"24",onClick:t[1]||(t[1]=h=>G("剖面视图")),active:P.value&&y.value==="剖面视图",title:"剖面视图"},null,8,["active"]),e.createVNode(N.ThreeSvgIcon,{name:"donghuafangzhen",size:"24",onClick:t[2]||(t[2]=h=>G("工件树")),active:P.value&&y.value==="工件树"},null,8,["active"])]),e.createElementVNode("div",Ye,[e.renderSlot(l.$slots,"button-right",{switchRightPanel:Z},void 0,!0),e.createVNode(N.ThreeSvgIcon,{name:"jichuangxuanze",size:"24",onClick:t[3]||(t[3]=h=>Z("机床控制")),active:B.value&&k.value==="机床控制",title:"机床控制"},null,8,["active"]),e.createVNode(N.ThreeSvgIcon,{name:"donghuafangzhen",size:"24",title:"动画仿真",onClick:t[4]||(t[4]=h=>Z("动画仿真")),active:B.value&&k.value==="动画仿真"},null,8,["active"])]),e.createElementVNode("div",Ze,[e.createVNode(N.ThreeSvgIcon,{name:"bofang",size:"24",backgroundColor:"#ffffff",title:"播放",onClick:Pe}),e.createVNode(N.ThreeSvgIcon,{name:"zanting",size:"24",backgroundColor:"#ffffff",title:"暂停",onClick:Se}),e.createVNode(N.ThreeSvgIcon,{name:"zhongzhi",size:"24",backgroundColor:"#ffffff",title:"停止",onClick:xe})]),e.withDirectives(e.createElementVNode("div",Qe,[e.createElementVNode("div",et,[e.createElementVNode("span",null,e.toDisplayString(n.value),1),e.createElementVNode("span",{class:"close",onClick:t[5]||(t[5]=h=>s.value=!1)}," X ")]),e.createElementVNode("div",tt,[e.createVNode(a,{height:"100%"},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"top-panel",{topPanelType:n.value},void 0,!0)]),_:3})])],512),[[e.vShow,s.value]]),e.withDirectives(e.createElementVNode("div",lt,[e.createElementVNode("div",nt,[e.createElementVNode("span",null,e.toDisplayString(y.value),1),e.createElementVNode("span",{class:"close",onClick:t[6]||(t[6]=h=>P.value=!1)}," X ")]),e.createElementVNode("div",ot,[e.createVNode(a,{height:"100%"},{default:e.withCtx(()=>{var h;return[y.value==="场景树"?(e.openBlock(),e.createBlock(J.UrdfTree,{key:0,model:r.value,extraNodes:A.value,onNodeClick:L},null,8,["model","extraNodes"])):e.createCommentVNode("",!0),y.value==="剖面视图"?(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",st,[e.createElementVNode("label",it,[e.withDirectives(e.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"none","onUpdate:modelValue":t[7]||(t[7]=c=>e.isRef(b)?b.value=c:null),onChange:t[8]||(t[8]=(...c)=>e.unref(x)&&e.unref(x)(...c))},null,544),[[e.vModelRadio,e.unref(b)]]),t[16]||(t[16]=e.createElementVNode("span",{class:"radio-text"},"无切割",-1))]),e.createElementVNode("label",rt,[e.withDirectives(e.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"x","onUpdate:modelValue":t[9]||(t[9]=c=>e.isRef(b)?b.value=c:null),onChange:t[10]||(t[10]=(...c)=>e.unref(x)&&e.unref(x)(...c))},null,544),[[e.vModelRadio,e.unref(b)]]),t[17]||(t[17]=e.createElementVNode("span",{class:"radio-text"},"X轴切割",-1))]),e.createElementVNode("label",ut,[e.withDirectives(e.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"y","onUpdate:modelValue":t[11]||(t[11]=c=>e.isRef(b)?b.value=c:null),onChange:t[12]||(t[12]=(...c)=>e.unref(x)&&e.unref(x)(...c))},null,544),[[e.vModelRadio,e.unref(b)]]),t[18]||(t[18]=e.createElementVNode("span",{class:"radio-text"},"Y轴切割",-1))]),e.createElementVNode("label",ct,[e.withDirectives(e.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"z","onUpdate:modelValue":t[13]||(t[13]=c=>e.isRef(b)?b.value=c:null),onChange:t[14]||(t[14]=(...c)=>e.unref(x)&&e.unref(x)(...c))},null,544),[[e.vModelRadio,e.unref(b)]]),t[19]||(t[19]=e.createElementVNode("span",{class:"radio-text"},"Z轴切割",-1))])])])):e.createCommentVNode("",!0),y.value==="工件树"?(e.openBlock(),e.createBlock(R.WorkpieceTreePanel,{key:2,model:(h=e.unref(be))==null?void 0:h.obj,onVisibleChange:e.unref(ye),onUpdatePosition:e.unref(Ee),onUpdateRotation:e.unref(ke)},null,8,["model","onVisibleChange","onUpdatePosition","onUpdateRotation"])):e.createCommentVNode("",!0)]}),_:1})])],512),[[e.vShow,P.value]]),e.withDirectives(e.createElementVNode("div",dt,[e.createElementVNode("div",vt,[e.createElementVNode("span",null,e.toDisplayString(k.value),1),e.createElementVNode("span",{class:"close",onClick:t[15]||(t[15]=h=>B.value=!1)}," X ")]),e.createElementVNode("div",mt,[e.createVNode(a,{height:"100%"},{default:e.withCtx(()=>[e.withDirectives(e.createVNode(J.JointPanel,{model:r.value},null,8,["model"]),[[e.vShow,k.value==="机床控制"]]),e.withDirectives(e.createVNode(ie,{model:r.value,scene:u.value,xyzbcList:X.value,ref_key:"urdfAnimationPanelRef",ref:E},null,8,["model","scene","xyzbcList"]),[[e.vShow,k.value==="动画仿真"]]),e.renderSlot(l.$slots,"right-panel",{rightPanelType:k.value},void 0,!0)]),_:3})])],512),[[e.vShow,B.value]]),I.value?(e.openBlock(),e.createElementBlock("div",pt,[t[20]||(t[20]=e.createElementVNode("div",{class:"loading-spinner"},null,-1)),e.createElementVNode("p",null,e.toDisplayString(O.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",ft,[e.createElementVNode("div",gt,[t[21]||(t[21]=e.createElementVNode("div",{class:"item-label"},"厂家:",-1)),e.createElementVNode("div",ht,e.toDisplayString(U.value),1)]),e.createElementVNode("div",Nt,[t[22]||(t[22]=e.createElementVNode("div",{class:"item-label"},"型号:",-1)),e.createElementVNode("div",Vt,e.toDisplayString(d.value),1)]),e.createElementVNode("div",bt,[t[23]||(t[23]=e.createElementVNode("div",{class:"item-label"},"编号:",-1)),e.createElementVNode("div",yt,e.toDisplayString(T.value),1)])])):e.createCommentVNode("",!0),e.createVNode(K,{ref:"pipeAnalysisPanelRef"},null,512)])}}}),kt=re._export_sfc(Et,[["__scopeId","data-v-8cfdaf24"]]);exports.default=kt;
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),F=require("./iconfont-B1cUqs_N.cjs"),c=require("./index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-K6lh7Rrj.cjs"),Pe=require("./threeViewerHost-CW6JmOUJ.cjs"),$=require("./index-C8qRkCgn.cjs"),le=require("./urdfTree-CTiMB7ge.cjs"),De=require("./loaderUtil-CaWWb8db.cjs"),pe=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),V=require("./svgIcon-CUM54R6L.cjs"),Ie=require("./isString--eJE54G5.cjs"),ce=new c.Box3,G=new c.Vector3;class ve extends c.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],n=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],o=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(o),this.setAttribute("position",new c.Float32BufferAttribute(e,3)),this.setAttribute("uv",new c.Float32BufferAttribute(n,2))}applyMatrix4(e){const n=this.attributes.instanceStart,o=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),o.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const o=new c.InstancedInterleavedBuffer(n,6,1);return this.setAttribute("instanceStart",new c.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceEnd",new c.InterleavedBufferAttribute(o,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const o=new c.InstancedInterleavedBuffer(n,6,1);return this.setAttribute("instanceColorStart",new c.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceColorEnd",new c.InterleavedBufferAttribute(o,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new c.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new c.Box3);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),ce.setFromBufferAttribute(n),this.boundingBox.union(ce))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new c.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const o=this.boundingSphere.center;this.boundingBox.getCenter(o);let i=0;for(let s=0,l=e.count;s<l;s++)G.fromBufferAttribute(e,s),i=Math.max(i,o.distanceToSquared(G)),G.fromBufferAttribute(n,s),i=Math.max(i,o.distanceToSquared(G));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}c.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:`
|
|
2
|
+
#include <common>
|
|
3
|
+
#include <color_pars_vertex>
|
|
4
|
+
#include <fog_pars_vertex>
|
|
5
|
+
#include <logdepthbuf_pars_vertex>
|
|
6
|
+
#include <clipping_planes_pars_vertex>
|
|
7
|
+
|
|
8
|
+
uniform float linewidth;
|
|
9
|
+
uniform vec2 resolution;
|
|
10
|
+
|
|
11
|
+
attribute vec3 instanceStart;
|
|
12
|
+
attribute vec3 instanceEnd;
|
|
13
|
+
|
|
14
|
+
attribute vec3 instanceColorStart;
|
|
15
|
+
attribute vec3 instanceColorEnd;
|
|
16
|
+
|
|
17
|
+
#ifdef WORLD_UNITS
|
|
18
|
+
|
|
19
|
+
varying vec4 worldPos;
|
|
20
|
+
varying vec3 worldStart;
|
|
21
|
+
varying vec3 worldEnd;
|
|
22
|
+
|
|
23
|
+
#ifdef USE_DASH
|
|
24
|
+
|
|
25
|
+
varying vec2 vUv;
|
|
26
|
+
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#else
|
|
30
|
+
|
|
31
|
+
varying vec2 vUv;
|
|
32
|
+
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
#ifdef USE_DASH
|
|
36
|
+
|
|
37
|
+
uniform float dashScale;
|
|
38
|
+
attribute float instanceDistanceStart;
|
|
39
|
+
attribute float instanceDistanceEnd;
|
|
40
|
+
varying float vLineDistance;
|
|
41
|
+
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
45
|
+
|
|
46
|
+
// trim end segment so it terminates between the camera plane and the near plane
|
|
47
|
+
|
|
48
|
+
// conservative estimate of the near plane
|
|
49
|
+
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
50
|
+
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
51
|
+
float nearEstimate = - 0.5 * b / a;
|
|
52
|
+
|
|
53
|
+
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
54
|
+
|
|
55
|
+
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void main() {
|
|
60
|
+
|
|
61
|
+
#ifdef USE_COLOR
|
|
62
|
+
|
|
63
|
+
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
64
|
+
|
|
65
|
+
#endif
|
|
66
|
+
|
|
67
|
+
#ifdef USE_DASH
|
|
68
|
+
|
|
69
|
+
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
70
|
+
vUv = uv;
|
|
71
|
+
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
float aspect = resolution.x / resolution.y;
|
|
75
|
+
|
|
76
|
+
// camera space
|
|
77
|
+
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
78
|
+
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
79
|
+
|
|
80
|
+
#ifdef WORLD_UNITS
|
|
81
|
+
|
|
82
|
+
worldStart = start.xyz;
|
|
83
|
+
worldEnd = end.xyz;
|
|
84
|
+
|
|
85
|
+
#else
|
|
86
|
+
|
|
87
|
+
vUv = uv;
|
|
88
|
+
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
92
|
+
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
93
|
+
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
94
|
+
// perhaps there is a more elegant solution -- WestLangley
|
|
95
|
+
|
|
96
|
+
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
97
|
+
|
|
98
|
+
if ( perspective ) {
|
|
99
|
+
|
|
100
|
+
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
101
|
+
|
|
102
|
+
trimSegment( start, end );
|
|
103
|
+
|
|
104
|
+
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
105
|
+
|
|
106
|
+
trimSegment( end, start );
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// clip space
|
|
113
|
+
vec4 clipStart = projectionMatrix * start;
|
|
114
|
+
vec4 clipEnd = projectionMatrix * end;
|
|
115
|
+
|
|
116
|
+
// ndc space
|
|
117
|
+
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
118
|
+
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
119
|
+
|
|
120
|
+
// direction
|
|
121
|
+
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
122
|
+
|
|
123
|
+
// account for clip-space aspect ratio
|
|
124
|
+
dir.x *= aspect;
|
|
125
|
+
dir = normalize( dir );
|
|
126
|
+
|
|
127
|
+
#ifdef WORLD_UNITS
|
|
128
|
+
|
|
129
|
+
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
130
|
+
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
131
|
+
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
132
|
+
vec3 worldFwd = cross( worldDir, worldUp );
|
|
133
|
+
worldPos = position.y < 0.5 ? start: end;
|
|
134
|
+
|
|
135
|
+
// height offset
|
|
136
|
+
float hw = linewidth * 0.5;
|
|
137
|
+
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
138
|
+
|
|
139
|
+
// don't extend the line if we're rendering dashes because we
|
|
140
|
+
// won't be rendering the endcaps
|
|
141
|
+
#ifndef USE_DASH
|
|
142
|
+
|
|
143
|
+
// cap extension
|
|
144
|
+
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
145
|
+
|
|
146
|
+
// add width to the box
|
|
147
|
+
worldPos.xyz += worldFwd * hw;
|
|
148
|
+
|
|
149
|
+
// endcaps
|
|
150
|
+
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
151
|
+
|
|
152
|
+
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#endif
|
|
157
|
+
|
|
158
|
+
// project the worldpos
|
|
159
|
+
vec4 clip = projectionMatrix * worldPos;
|
|
160
|
+
|
|
161
|
+
// shift the depth of the projected points so the line
|
|
162
|
+
// segments overlap neatly
|
|
163
|
+
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
164
|
+
clip.z = clipPose.z * clip.w;
|
|
165
|
+
|
|
166
|
+
#else
|
|
167
|
+
|
|
168
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
|
169
|
+
// undo aspect ratio adjustment
|
|
170
|
+
dir.x /= aspect;
|
|
171
|
+
offset.x /= aspect;
|
|
172
|
+
|
|
173
|
+
// sign flip
|
|
174
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
175
|
+
|
|
176
|
+
// endcaps
|
|
177
|
+
if ( position.y < 0.0 ) {
|
|
178
|
+
|
|
179
|
+
offset += - dir;
|
|
180
|
+
|
|
181
|
+
} else if ( position.y > 1.0 ) {
|
|
182
|
+
|
|
183
|
+
offset += dir;
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// adjust for linewidth
|
|
188
|
+
offset *= linewidth;
|
|
189
|
+
|
|
190
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
191
|
+
offset /= resolution.y;
|
|
192
|
+
|
|
193
|
+
// select end
|
|
194
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
195
|
+
|
|
196
|
+
// back to clip space
|
|
197
|
+
offset *= clip.w;
|
|
198
|
+
|
|
199
|
+
clip.xy += offset;
|
|
200
|
+
|
|
201
|
+
#endif
|
|
202
|
+
|
|
203
|
+
gl_Position = clip;
|
|
204
|
+
|
|
205
|
+
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
206
|
+
|
|
207
|
+
#include <logdepthbuf_vertex>
|
|
208
|
+
#include <clipping_planes_vertex>
|
|
209
|
+
#include <fog_vertex>
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
`,fragmentShader:`
|
|
213
|
+
uniform vec3 diffuse;
|
|
214
|
+
uniform float opacity;
|
|
215
|
+
uniform float linewidth;
|
|
216
|
+
|
|
217
|
+
#ifdef USE_DASH
|
|
218
|
+
|
|
219
|
+
uniform float dashOffset;
|
|
220
|
+
uniform float dashSize;
|
|
221
|
+
uniform float gapSize;
|
|
222
|
+
|
|
223
|
+
#endif
|
|
224
|
+
|
|
225
|
+
varying float vLineDistance;
|
|
226
|
+
|
|
227
|
+
#ifdef WORLD_UNITS
|
|
228
|
+
|
|
229
|
+
varying vec4 worldPos;
|
|
230
|
+
varying vec3 worldStart;
|
|
231
|
+
varying vec3 worldEnd;
|
|
232
|
+
|
|
233
|
+
#ifdef USE_DASH
|
|
234
|
+
|
|
235
|
+
varying vec2 vUv;
|
|
236
|
+
|
|
237
|
+
#endif
|
|
238
|
+
|
|
239
|
+
#else
|
|
240
|
+
|
|
241
|
+
varying vec2 vUv;
|
|
242
|
+
|
|
243
|
+
#endif
|
|
244
|
+
|
|
245
|
+
#include <common>
|
|
246
|
+
#include <color_pars_fragment>
|
|
247
|
+
#include <fog_pars_fragment>
|
|
248
|
+
#include <logdepthbuf_pars_fragment>
|
|
249
|
+
#include <clipping_planes_pars_fragment>
|
|
250
|
+
|
|
251
|
+
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
252
|
+
|
|
253
|
+
float mua;
|
|
254
|
+
float mub;
|
|
255
|
+
|
|
256
|
+
vec3 p13 = p1 - p3;
|
|
257
|
+
vec3 p43 = p4 - p3;
|
|
258
|
+
|
|
259
|
+
vec3 p21 = p2 - p1;
|
|
260
|
+
|
|
261
|
+
float d1343 = dot( p13, p43 );
|
|
262
|
+
float d4321 = dot( p43, p21 );
|
|
263
|
+
float d1321 = dot( p13, p21 );
|
|
264
|
+
float d4343 = dot( p43, p43 );
|
|
265
|
+
float d2121 = dot( p21, p21 );
|
|
266
|
+
|
|
267
|
+
float denom = d2121 * d4343 - d4321 * d4321;
|
|
268
|
+
|
|
269
|
+
float numer = d1343 * d4321 - d1321 * d4343;
|
|
270
|
+
|
|
271
|
+
mua = numer / denom;
|
|
272
|
+
mua = clamp( mua, 0.0, 1.0 );
|
|
273
|
+
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
274
|
+
mub = clamp( mub, 0.0, 1.0 );
|
|
275
|
+
|
|
276
|
+
return vec2( mua, mub );
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
void main() {
|
|
281
|
+
|
|
282
|
+
float alpha = opacity;
|
|
283
|
+
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
284
|
+
|
|
285
|
+
#include <clipping_planes_fragment>
|
|
286
|
+
|
|
287
|
+
#ifdef USE_DASH
|
|
288
|
+
|
|
289
|
+
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
290
|
+
|
|
291
|
+
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
292
|
+
|
|
293
|
+
#endif
|
|
294
|
+
|
|
295
|
+
#ifdef WORLD_UNITS
|
|
296
|
+
|
|
297
|
+
// Find the closest points on the view ray and the line segment
|
|
298
|
+
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
299
|
+
vec3 lineDir = worldEnd - worldStart;
|
|
300
|
+
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
301
|
+
|
|
302
|
+
vec3 p1 = worldStart + lineDir * params.x;
|
|
303
|
+
vec3 p2 = rayEnd * params.y;
|
|
304
|
+
vec3 delta = p1 - p2;
|
|
305
|
+
float len = length( delta );
|
|
306
|
+
float norm = len / linewidth;
|
|
307
|
+
|
|
308
|
+
#ifndef USE_DASH
|
|
309
|
+
|
|
310
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
311
|
+
|
|
312
|
+
float dnorm = fwidth( norm );
|
|
313
|
+
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
314
|
+
|
|
315
|
+
#else
|
|
316
|
+
|
|
317
|
+
if ( norm > 0.5 ) {
|
|
318
|
+
|
|
319
|
+
discard;
|
|
320
|
+
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
#endif
|
|
324
|
+
|
|
325
|
+
#endif
|
|
326
|
+
|
|
327
|
+
#else
|
|
328
|
+
|
|
329
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
330
|
+
|
|
331
|
+
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
332
|
+
float a = vUv.x;
|
|
333
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
334
|
+
float len2 = a * a + b * b;
|
|
335
|
+
float dlen = fwidth( len2 );
|
|
336
|
+
|
|
337
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
338
|
+
|
|
339
|
+
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
340
|
+
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
#else
|
|
344
|
+
|
|
345
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
346
|
+
|
|
347
|
+
float a = vUv.x;
|
|
348
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
349
|
+
float len2 = a * a + b * b;
|
|
350
|
+
|
|
351
|
+
if ( len2 > 1.0 ) discard;
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
#endif
|
|
356
|
+
|
|
357
|
+
#endif
|
|
358
|
+
|
|
359
|
+
#include <logdepthbuf_fragment>
|
|
360
|
+
#include <color_fragment>
|
|
361
|
+
|
|
362
|
+
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
363
|
+
|
|
364
|
+
#include <tonemapping_fragment>
|
|
365
|
+
#include <colorspace_fragment>
|
|
366
|
+
#include <fog_fragment>
|
|
367
|
+
#include <premultiplied_alpha_fragment>
|
|
368
|
+
|
|
369
|
+
}
|
|
370
|
+
`};class ie extends c.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ee=new c.Vector4,ue=new c.Vector3,de=new c.Vector3,b=new c.Vector4,S=new c.Vector4,T=new c.Vector4,te=new c.Vector3,ne=new c.Matrix4,_=new c.Line3,fe=new c.Vector3,H=new c.Box3,q=new c.Sphere,M=new c.Vector4;let B,I;function me(r,e,n){return M.set(0,0,-e,1).applyMatrix4(r.projectionMatrix),M.multiplyScalar(1/M.w),M.x=I/n.width,M.y=I/n.height,M.applyMatrix4(r.projectionMatrixInverse),M.multiplyScalar(1/M.w),Math.abs(Math.max(M.x,M.y))}function Fe(r,e){const n=r.matrixWorld,o=r.geometry,i=o.attributes.instanceStart,s=o.attributes.instanceEnd,l=Math.min(o.instanceCount,i.count);for(let a=0,m=l;a<m;a++){_.start.fromBufferAttribute(i,a),_.end.fromBufferAttribute(s,a),_.applyMatrix4(n);const f=new c.Vector3,v=new c.Vector3;B.distanceSqToSegment(_.start,_.end,v,f),v.distanceTo(f)<I*.5&&e.push({point:v,pointOnLine:f,distance:B.origin.distanceTo(v),object:r,face:null,faceIndex:a,uv:null,uv1:null})}}function Oe(r,e,n){const o=e.projectionMatrix,s=r.material.resolution,l=r.matrixWorld,a=r.geometry,m=a.attributes.instanceStart,f=a.attributes.instanceEnd,v=Math.min(a.instanceCount,m.count),p=-e.near;B.at(1,T),T.w=1,T.applyMatrix4(e.matrixWorldInverse),T.applyMatrix4(o),T.multiplyScalar(1/T.w),T.x*=s.x/2,T.y*=s.y/2,T.z=0,te.copy(T),ne.multiplyMatrices(e.matrixWorldInverse,l);for(let h=0,C=v;h<C;h++){if(b.fromBufferAttribute(m,h),S.fromBufferAttribute(f,h),b.w=1,S.w=1,b.applyMatrix4(ne),S.applyMatrix4(ne),b.z>p&&S.z>p)continue;if(b.z>p){const g=b.z-S.z,z=(b.z-p)/g;b.lerp(S,z)}else if(S.z>p){const g=S.z-b.z,z=(S.z-p)/g;S.lerp(b,z)}b.applyMatrix4(o),S.applyMatrix4(o),b.multiplyScalar(1/b.w),S.multiplyScalar(1/S.w),b.x*=s.x/2,b.y*=s.y/2,S.x*=s.x/2,S.y*=s.y/2,_.start.copy(b),_.start.z=0,_.end.copy(S),_.end.z=0;const U=_.closestPointToPointParameter(te,!0);_.at(U,fe);const x=c.MathUtils.lerp(b.z,S.z,U),E=x>=-1&&x<=1,y=te.distanceTo(fe)<I*.5;if(E&&y){_.start.fromBufferAttribute(m,h),_.end.fromBufferAttribute(f,h),_.start.applyMatrix4(l),_.end.applyMatrix4(l);const g=new c.Vector3,z=new c.Vector3;B.distanceSqToSegment(_.start,_.end,z,g),n.push({point:z,pointOnLine:g,distance:B.origin.distanceTo(z),object:r,face:null,faceIndex:h,uv:null,uv1:null})}}}class je extends c.Mesh{constructor(e=new ve,n=new ie({color:Math.random()*16777215})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,o=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let l=0,a=0,m=n.count;l<m;l++,a+=2)ue.fromBufferAttribute(n,l),de.fromBufferAttribute(o,l),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+ue.distanceTo(de);const s=new c.InstancedInterleavedBuffer(i,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new c.InterleavedBufferAttribute(s,1,1)),this}raycast(e,n){const o=this.material.worldUnits,i=e.camera;i===null&&!o&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;B=e.ray;const l=this.matrixWorld,a=this.geometry,m=this.material;I=m.linewidth+s,a.boundingSphere===null&&a.computeBoundingSphere(),q.copy(a.boundingSphere).applyMatrix4(l);let f;if(o)f=I*.5;else{const p=Math.max(i.near,q.distanceToPoint(B.origin));f=me(i,p,m.resolution)}if(q.radius+=f,B.intersectsSphere(q)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),H.copy(a.boundingBox).applyMatrix4(l);let v;if(o)v=I*.5;else{const p=Math.max(i.near,H.distanceToPoint(B.origin));v=me(i,p,m.resolution)}H.expandByScalar(v),B.intersectsBox(H)!==!1&&(o?Fe(this,n):Oe(this,i,n))}onBeforeRender(e){const n=this.material.uniforms;n&&n.resolution&&(e.getViewport(ee),this.material.uniforms.resolution.value.set(ee.z,ee.w))}}class he extends ve{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const n=e.length-3,o=new Float32Array(2*n);for(let i=0;i<n;i+=3)o[2*i]=e[i],o[2*i+1]=e[i+1],o[2*i+2]=e[i+2],o[2*i+3]=e[i+3],o[2*i+4]=e[i+4],o[2*i+5]=e[i+5];return super.setPositions(o),this}setColors(e){const n=e.length-3,o=new Float32Array(2*n);for(let i=0;i<n;i+=3)o[2*i]=e[i],o[2*i+1]=e[i+1],o[2*i+2]=e[i+2],o[2*i+3]=e[i+3],o[2*i+4]=e[i+4],o[2*i+5]=e[i+5];return super.setColors(o),this}setFromPoints(e){const n=e.length-1,o=new Float32Array(6*n);for(let i=0;i<n;i++)o[6*i]=e[i].x,o[6*i+1]=e[i].y,o[6*i+2]=e[i].z||0,o[6*i+3]=e[i+1].x,o[6*i+4]=e[i+1].y,o[6*i+5]=e[i+1].z||0;return super.setPositions(o),this}fromLine(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}}class Re extends je{constructor(e=new he,n=new ie({color:Math.random()*16777215})){super(e,n),this.isLine2=!0,this.type="Line2"}}async function We(r){return await De.loadObjByUrl(r)}function Ge(r,e){debugger;r.position.copy(e)}function He(r,e,n=new c.Color(16711680)){const o=new c.Vector3;e.getWorldPosition(o);const i=r.geometry.attributes.position,s=r.geometry.attributes.color,l=new c.Color(55551);let a=1/0,m=-1;for(let f=0;f<i.count;f++){const p=new c.Vector3().fromBufferAttribute(i,f).distanceTo(o);p<a&&(a=p,m=f)}for(let f=0;f<s.count;f++)l.toArray(s.array,f*3);if(m!==-1){const f=n.toArray(),v=m*3+2;for(let p=0;p<v;p=p+3)s.array[p]=f[0],s.array[p+1]=f[1],s.array[p+2]=f[2]}s.needsUpdate=!0}function ge(r,e,n,o=new c.Color(16711680)){Ge(r,e),He(n,r,o)}const qe={class:"panel-content"},$e={class:"animation-controls"},Xe={class:"control-row"},Ye={class:"control-row"},Ze={class:"frame-info"},Ke={class:"control-row"},Je=t.defineComponent({__name:"trackAnimationPanel",props:{cloud:{},knife:{},vectors:{}},emits:["getThreeData"],setup(r,{expose:e,emit:n}){const o=r,i=t.computed(()=>o.vectors),s=t.ref(!1),l=t.ref(0),a=t.ref(100);let m=!1;const f=y=>`第 ${y+1} 帧`,v=y=>{if(y<0||y>=i.value.length){console.error(`帧索引 ${y} 超出范围`);return}const g=i.value[y];l.value=y,ge(o.knife,g,o.cloud)},p=async()=>{if(i.value.length===0){$.ElMessage.error("无法播放动画:无数据");return}if(!s.value){s.value=!0,m=!1,i.value.length-1===l.value&&(l.value=0);try{for(let y=l.value+1;y<i.value.length&&!m;y++)await new Promise(g=>setTimeout(g,a.value)),v(y);m||$.ElMessage.success("动画播放完成")}catch(y){console.error("动画播放出错:",y)}finally{s.value=!1}}},h=async()=>{s.value&&(m=!0,await new Promise(y=>{const g=t.watch(()=>s.value,z=>{g(),y()})}),$.ElMessage.info("动画已停止"))},C=async y=>{s.value&&await h(),v(y)},N=async()=>{s.value&&await h(),!(l.value+1>=i.value.length)&&v(l.value+1)},U=async()=>{s.value&&await h(),l.value!==0&&v(l.value-1)},x=()=>{l.value=0};return e({playAnimation:p,stopAnimation:h,forwardFrame:N,backwardFrame:U,resetAnimationFrame:x,reset:async()=>{await h(),x()}}),(y,g)=>{const z=t.resolveComponent("el-input-number"),Y=t.resolveComponent("el-form-item"),Z=t.resolveComponent("el-form"),W=t.resolveComponent("el-slider");return t.openBlock(),t.createElementBlock("div",qe,[t.createElementVNode("div",$e,[t.createElementVNode("div",Xe,[t.createVNode(Z,{"label-width":"auto",style:{width:"100%"}},{default:t.withCtx(()=>[t.createVNode(Y,{label:"帧间隔 (ms):",prop:"frameDuration"},{default:t.withCtx(()=>[t.createVNode(z,{modelValue:a.value,"onUpdate:modelValue":g[0]||(g[0]=O=>a.value=O),min:0,max:5e3,step:10,style:{width:"100%"}},null,8,["modelValue"])]),_:1})]),_:1})]),t.createElementVNode("div",Ye,[g[2]||(g[2]=t.createElementVNode("label",null,"当前帧:",-1)),t.createElementVNode("span",Ze,t.toDisplayString(l.value+1)+" / "+t.toDisplayString(i.value.length),1)]),t.createElementVNode("div",Ke,[g[3]||(g[3]=t.createElementVNode("label",null,"动画进度:",-1)),t.createVNode(W,{modelValue:l.value,"onUpdate:modelValue":g[1]||(g[1]=O=>l.value=O),min:0,max:i.value.length>0?i.value.length-1:0,step:1,"format-tooltip":f,onInput:C,disabled:i.value.length===0,style:{"flex-grow":"1",margin:"0 10px"}},null,8,["modelValue","max","disabled"])])])])}}}),Qe=pe._export_sfc(Je,[["__scopeId","data-v-b5665bfd"]]);function et(r){const e=[];return r.forEach(n=>{const[o,i,s]=n.trim().split(/\s+/);e.push(+o,+i,+s)}),e}function X(r,e,n){switch(r){case"X":e.x=+n||0;break;case"Y":e.y=+n||0;break;case"Z":e.z=+n||0;break}}function tt(r){const e=[],n=["X","Y","Z"];return r.forEach(o=>{const i={x:0,y:0,z:0},s=o.trim();if(!s)return;let l=null,a="";for(let m=0;m<(s==null?void 0:s.length);m++){const f=s[m],v=n.find(p=>p===f);if(v){l&&X(l,i,a),a="",l=v;continue}a=a+f}X(l,i,a),e.push(i.x,i.y,i.z)}),e}const nt=r=>r==null?void 0:r.filter(n=>n.includes("=")),it=r=>r.replace(/,/g,""),ot=r=>r==null?void 0:r.map(n=>it(n)),rt=r=>{const e=nt(r);return ot(e)};function st(r){const e=rt(r),n=[];return e.forEach(o=>{var p,h,C,N,U,x;let[i,s,l,a]=o.trim().split(/\s+/);s=(p=s==null?void 0:s.trim)==null?void 0:p.call(s),l=(h=l==null?void 0:l.trim)==null?void 0:h.call(l),a=(C=a==null?void 0:a.trim)==null?void 0:C.call(a);const[,m]=(N=s==null?void 0:s.split)==null?void 0:N.call(s,"="),[,f]=(U=l==null?void 0:l.split)==null?void 0:U.call(l,"="),[,v]=(x=a==null?void 0:a.split)==null?void 0:x.call(a,"=");n.push(+m,+f,+v)}),n}const at=r=>r>="0"&&r<="9",lt=r=>r==="+"||r==="-",ct=r=>r===".";function ut(r){return at(r)||lt(r)||ct(r)}function dt(r){const e=[],n=new Set(["X","Y","Z"]);return r.forEach(o=>{const i={x:0,y:0,z:0},s=o.trim();if(!s)return;let l=null,a="";for(let m=0;m<(s==null?void 0:s.length);m++){const f=s[m],v=n.has(f)?f:null,p=ut(f);if(v||!p){l&&X(l,i,a),l=v,a="";continue}a=a+f}l&&X(l,i,a),e.push(i.x,i.y,i.z)}),e}function ft(r){return r==null?void 0:r.includes("=")}async function mt(r){var i,s;const e=(i=r==null?void 0:r.trim())==null?void 0:i.split(/\r?\n/);if(ft(r))return st(e);const n=e==null?void 0:e[0],o=(s=n==null?void 0:n.trim())==null?void 0:s.split(/\s+/);if((o==null?void 0:o.length)>=3)return et(e);if((o==null?void 0:o.length)===1)return tt(e)}async function pt(r){const e=r.trim().split(/\r?\n/),n=[];return e.forEach(o=>{const i=o.trim().split(/\s+/);if(i.length!=3)return;const[s,l,a]=i;n.push(+s,+l,+a)}),n}async function vt(r){const e=r.trim().split(/\r?\n/),n=[];return e.forEach(o=>{const i=o.trim().split(/\s+/);if(i.length!=3)return;const[s,l,a]=i;n.push(+s,+l,+a)}),n}async function ht(r){let e=r.trim().split(/\r?\n/);return e=e.filter(o=>{const i=o.startsWith("X"),s=o.startsWith("G")&&o.includes("X");return i||s}),dt(e)}async function gt(r,e){const{isCyd:n,isUv:o,isCpt:i,isNc:s}=e;return o?mt(r):n?vt(r):i?pt(r):s?ht(r):[]}function yt(r){const e=[];for(let n=0;n<r.length;n+=3)e.push(new c.Vector3(r[n],r[n+1],r[n+2]));return e}function wt(r,e){if(!e||e.length<3)return;const{scene:n,camera:o,renderer:i,controls:s}=r();if(!n||!o||!i||!s)return;const l=[];for(let h=0;h<e.length;h+=3)l.push(new c.Vector3(e[h],e[h+1],e[h+2]));const m=new c.CatmullRomCurve3(l,!1,"catmullrom",.5).getPoints(150).flatMap(h=>[h.x,h.y,h.z]),f=new he;f.setPositions(m);const v=new ie({color:55551,linewidth:3,resolution:new c.Vector2(window.innerWidth,window.innerHeight)}),p=new Re(f,v);return p.name="轨迹路径",n.add(p),p}function xt(r,e,n,o=4,i=50){let s=1/0,l=-1/0,a=1/0,m=-1/0,f=1/0,v=-1/0;for(let x=0;x<r.length;x+=3){const E=r[x],y=r[x+1],g=r[x+2];s=Math.min(s,E),l=Math.max(l,E),a=Math.min(a,y),m=Math.max(m,y),f=Math.min(f,g),v=Math.max(v,g)}const h=Math.sqrt((l-s)**2+(m-a)**2+(v-f)**2)*.05,C=c.MathUtils.degToRad(e.fov),N=2*Math.tan(C/2)*i,U=h/N*n.domElement.height*(o/4);return Math.min(.4,U)}function bt(r){if(r.length%3!==0)return console.error("points array length is not a multiple of 3:",r),null;const e=new c.BufferGeometry;e.setAttribute("position",new c.Float32BufferAttribute(r,3));const n=new Float32Array(r.length);for(let s=0;s<r.length;s+=3)n[s]=0,n[s+1]=.847,n[s+2]=1;e.setAttribute("color",new c.BufferAttribute(n,3));const o=new c.PointsMaterial({vertexColors:!0,size:.4,sizeAttenuation:!0}),i=new c.Points(e,o);return o.needsUpdate=!0,i}function St(r,e){const n=new c.Box3().setFromArray(e),o=[new c.Vector3(n.min.x,n.min.y,n.min.z),new c.Vector3(n.max.x,n.min.y,n.min.z),new c.Vector3(n.min.x,n.max.y,n.min.z),new c.Vector3(n.min.x,n.min.y,n.max.z),new c.Vector3(n.max.x,n.max.y,n.min.z),new c.Vector3(n.max.x,n.min.y,n.max.z),new c.Vector3(n.min.x,n.max.y,n.max.z),new c.Vector3(n.max.x,n.max.y,n.max.z)];let i=0;for(const s of o)i=Math.max(i,s.distanceTo(r.position));return i}function _t(r,e){if(!e)return;const{scene:n,camera:o,renderer:i,controls:s}=r();if(!n||!o||!i||!s)return;const l=bt(e);if(!l)return;l.name="轨迹路径",n.add(l);const a=xt(e,o,i,.1,50);l.material.size=a;const m=St(o,e);return o.far=m*1.2,o.updateProjectionMatrix(),l}const Et={class:"obj-viewer-container"},Ct={class:"buttonGroup-topLeft"},Vt={class:"buttonGroup-left"},zt={class:"buttonGroup-right"},At={class:"buttonGroup-bottom"},Ut={class:"left-panel"},Nt={class:"panel-header"},Tt={class:"panel-body"},Mt={key:1,class:"clipping-content"},Bt={class:"radio-group"},Lt={class:"radio-label"},kt={class:"radio-label"},Pt={class:"radio-label"},Dt={class:"radio-label"},It={class:"right-panel"},Ft={class:"panel-header"},Ot={class:"panel-body"},jt={key:0,class:"loading-overlay"},Rt=t.defineComponent({__name:"threeTrackPathView",props:{fileBlobs:{},threeData:{default:()=>""},trackFileType:{}},emits:["getAnimationData","getThreeData"],setup(r,{emit:e}){const n=e,o=r,i=t.ref(null),s=t.ref(!1),l=t.ref(""),a=t.ref(),m=t.ref(!1),f=t.ref(""),v=t.ref(!1),p=t.ref(""),h=t.shallowRef(null),C=t.shallowRef(null),{currentModels:N,initThreeJS:U,handleResize:x,getThreeJSObjects:E,cleanup:y,axesHelperVisible:g,toggleAxesVisibility:z,zoomIn:Y,zoomOut:Z}=F.useThreeJS(i),{isAnimating:W,toggleAnimation:O,stopAnimation:ye}=F.useAnimation(E,N),{isClipping:we,activeClippingAxis:A,toggleClipping:xe,updateClippingPlanes:L}=F.useClipping(E,N),be=()=>{z()},K=d=>{m.value=!0,f.value=d,d==="剖面视图"&&!we.value&&xe()},J=d=>{v.value=!0,p.value=d,d==="动画仿真"&&n("getAnimationData")},Q=t.ref([]),j=t.ref([]),Se=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isUv}),_e=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isCyd}),Ee=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isCpt}),P=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isNc}),oe=t.computed(()=>{const d=o.fileBlobs||[];return d==null?void 0:d[0]});let k=t.shallowRef(),D=t.shallowRef();const Ce=()=>{const{scene:d}=E();k.value&&d&&(F.disposeObj(k.value,d),k.value=null)},Ve=()=>{const{scene:d}=E();D.value&&d&&(F.disposeObj(D.value,d),D.value=null)},re=()=>{Ce(),Ve()},ze=async d=>{const u=URL.createObjectURL(d),R=await Pe.readFileText(u);if(URL.revokeObjectURL(u),Ie.isString(R)){const w=await gt(R,o.trackFileType)||[];Q.value=w;const ae=Q.value;Se.value&&(k.value=wt(E,ae)),(_e.value||Ee.value||P.value)&&(k.value=_t(E,ae)),F.frameCameraToMesh(E,k.value)}},Ae=async()=>{var d,u;D.value=await We("http://222.92.178.198:55002/CPMPIP/Cut/1_4%20Single%20Flute%20End%20Mill-Cut002.obj"),j.value=yt(Q.value),j.value&&j.value.length&&(ge(D.value,j.value[0],k.value,new c.Color(16711680)),(u=(d=C.value)==null?void 0:d.add)==null||u.call(d,D.value))},Ue=async()=>{var d;await((d=a==null?void 0:a.value)==null?void 0:d.reset()),await se(oe.value)},se=async d=>{re(),await ze(d),P.value&&Ae()};t.watch(()=>oe.value,async d=>{d&&await se(d)},{immediate:!0,deep:!0});const Ne=()=>{var d;P.value&&((d=a==null?void 0:a.value)==null||d.playAnimation())},Te=()=>{var d;P.value&&((d=a==null?void 0:a.value)==null||d.stopAnimation())},Me=()=>{var d;P.value&&((d=a==null?void 0:a.value)==null||d.forwardFrame())},Be=()=>{var d;P.value&&((d=a==null?void 0:a.value)==null||d.backwardFrame())},Le=()=>{U(),window.addEventListener("resize",x);const d=E();C.value=d.scene,C.value&&(C.value.name="CPMPIP")},ke=()=>{window.removeEventListener("resize",x),W.value&&ye(),re(),y()};return t.onMounted(async()=>{try{Le()}catch(d){console.error("Three.js 初始化失败:",d),$.ElMessage.error("渲染引擎初始化失败!")}}),t.onBeforeUnmount(()=>{ke()}),(d,u)=>{const R=t.resolveComponent("el-scrollbar");return t.openBlock(),t.createElementBlock("div",Et,[t.createElementVNode("div",{ref_key:"threejsContainer",ref:i,class:"threejs-container"},null,512),t.createElementVNode("div",Ct,[t.createVNode(V.ThreeSvgIcon,{name:"viewReset",size:"24",onClick:Ue,title:"重置"}),t.createVNode(V.ThreeSvgIcon,{name:"fangda",size:"24",title:"放大",onClick:t.unref(Y)},null,8,["onClick"]),t.createVNode(V.ThreeSvgIcon,{name:"suoxiao",size:"24",title:"缩小",onClick:t.unref(Z)},null,8,["onClick"]),t.createVNode(V.ThreeSvgIcon,{name:"lookAround",size:"24",onClick:t.unref(O),title:t.unref(W)?"停止动画":"动画视图"},null,8,["onClick","title"]),t.createVNode(V.ThreeSvgIcon,{name:"zuobiaoxi",size:"24",active:t.unref(g),onClick:be,title:"显隐坐标轴"},null,8,["active"])]),t.createElementVNode("div",Vt,[t.renderSlot(d.$slots,"button-left",{switchRightPanel:K},void 0,!0),t.createVNode(V.ThreeSvgIcon,{name:"jiegoushu",size:"24",onClick:u[0]||(u[0]=w=>K("场景树")),active:m.value&&f.value==="场景树",title:"场景树"},null,8,["active"]),t.createVNode(V.ThreeSvgIcon,{name:"clipping",size:"24",onClick:u[1]||(u[1]=w=>K("剖面视图")),active:m.value&&f.value==="剖面视图",title:"剖面视图"},null,8,["active"])]),t.createElementVNode("div",zt,[t.renderSlot(d.$slots,"button-right",{switchRightPanel:J},void 0,!0),t.createVNode(V.ThreeSvgIcon,{name:"guanjiekongzhi",size:"24",onClick:u[2]||(u[2]=w=>J("关节控制")),active:v.value&&p.value==="关节控制",title:"关节控制"},null,8,["active"]),t.createVNode(V.ThreeSvgIcon,{name:"donghuafangzhen",size:"24",title:"动画仿真",onClick:u[3]||(u[3]=w=>J("动画仿真")),active:v.value&&p.value==="动画仿真"},null,8,["active"])]),t.createElementVNode("div",At,[t.createVNode(V.ThreeSvgIcon,{name:"kuaitui",size:"24",backgroundColor:"#ffffff",title:"快退",onClick:Be}),t.createVNode(V.ThreeSvgIcon,{name:"bofang",size:"24",backgroundColor:"#ffffff",title:"播放",onClick:Ne}),t.createVNode(V.ThreeSvgIcon,{name:"kuaijin",size:"24",backgroundColor:"#ffffff",title:"快进",onClick:Me}),t.createVNode(V.ThreeSvgIcon,{name:"zanting",size:"24",backgroundColor:"#ffffff",title:"暂停",onClick:Te})]),t.withDirectives(t.createElementVNode("div",Ut,[t.createElementVNode("div",Nt,[t.createElementVNode("span",null,t.toDisplayString(f.value),1),t.createElementVNode("span",{class:"close",onClick:u[4]||(u[4]=w=>m.value=!1)}," X ")]),t.createElementVNode("div",Tt,[t.createVNode(R,{height:"100%"},{default:t.withCtx(()=>[f.value==="场景树"?(t.openBlock(),t.createBlock(le.UrdfTree,{key:0,model:h.value},null,8,["model"])):t.createCommentVNode("",!0),f.value==="剖面视图"?(t.openBlock(),t.createElementBlock("div",Mt,[t.createElementVNode("div",Bt,[t.createElementVNode("label",Lt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"none","onUpdate:modelValue":u[5]||(u[5]=w=>t.isRef(A)?A.value=w:null),onChange:u[6]||(u[6]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(A)]]),u[14]||(u[14]=t.createElementVNode("span",{class:"radio-text"},"无切割",-1))]),t.createElementVNode("label",kt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"x","onUpdate:modelValue":u[7]||(u[7]=w=>t.isRef(A)?A.value=w:null),onChange:u[8]||(u[8]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(A)]]),u[15]||(u[15]=t.createElementVNode("span",{class:"radio-text"},"X轴切割",-1))]),t.createElementVNode("label",Pt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"y","onUpdate:modelValue":u[9]||(u[9]=w=>t.isRef(A)?A.value=w:null),onChange:u[10]||(u[10]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(A)]]),u[16]||(u[16]=t.createElementVNode("span",{class:"radio-text"},"Y轴切割",-1))]),t.createElementVNode("label",Dt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"z","onUpdate:modelValue":u[11]||(u[11]=w=>t.isRef(A)?A.value=w:null),onChange:u[12]||(u[12]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(A)]]),u[17]||(u[17]=t.createElementVNode("span",{class:"radio-text"},"Z轴切割",-1))])])])):t.createCommentVNode("",!0)]),_:1})])],512),[[t.vShow,m.value]]),t.withDirectives(t.createElementVNode("div",It,[t.createElementVNode("div",Ft,[t.createElementVNode("span",null,t.toDisplayString(p.value),1),t.createElementVNode("span",{class:"close",onClick:u[13]||(u[13]=w=>v.value=!1)}," X ")]),t.createElementVNode("div",Ot,[t.createVNode(R,{height:"100%"},{default:t.withCtx(()=>[t.withDirectives(t.createVNode(le.JointPanel,{model:h.value},null,8,["model"]),[[t.vShow,p.value==="关节控制"]]),t.withDirectives(t.createVNode(Qe,{ref_key:"animationPanelRef",ref:a,cloud:t.unref(k),knife:t.unref(D),vectors:j.value},null,8,["cloud","knife","vectors"]),[[t.vShow,p.value==="动画仿真"&&P.value]])]),_:1})])],512),[[t.vShow,v.value]]),s.value?(t.openBlock(),t.createElementBlock("div",jt,[u[18]||(u[18]=t.createElementVNode("div",{class:"loading-spinner"},null,-1)),t.createElementVNode("p",null,t.toDisplayString(l.value),1)])):t.createCommentVNode("",!0)])}}}),Wt=pe._export_sfc(Rt,[["__scopeId","data-v-14459d17"]]);exports.default=Wt;
|