ss-component-new 1.2.97 → 1.2.98
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-DnouUI-8.js → MTLLoader-CCS24gLm.js} +1 -1
- package/dist/{MTLLoader-zZDM0NQh.cjs → MTLLoader-DlcJK6vT.cjs} +1 -1
- package/dist/{OrbitControls-B85G8nPk.cjs → OrbitControls-BLs9AYBY.cjs} +1 -1
- package/dist/{OrbitControls-DFhYzlF3.js → OrbitControls-KkyEKP5M.js} +1 -1
- package/dist/{animationData-DfKVkFbz.js → animationData-Btgynl98.js} +1 -1
- package/dist/{animationData-DxBvEqB1.cjs → animationData-CCImpyvS.cjs} +1 -1
- package/dist/{iconfont-WOKNi2xx.js → iconfont-B8CQB3CO.js} +2 -2
- package/dist/{iconfont-C7kE-QbU.cjs → iconfont-BXzhYF5A.cjs} +1 -1
- package/dist/{index-DgZVeYqH.js → index--JyaPE1g.js} +1 -1
- package/dist/{index-DHZMd8iK.cjs → index-1TxthiQw.cjs} +1 -1
- package/dist/{index-CLOUp_4j.cjs → index-2wJBzGa-.cjs} +1 -1
- package/dist/{index-D0hovh9R.cjs → index-6sDAnob5.cjs} +1 -1
- package/dist/{index-_PP-dSm3.cjs → index-7ZZHuv4d.cjs} +1 -1
- package/dist/{index-Cr5if46q.js → index-B4YN6ElV.js} +1 -1
- package/dist/{index-Cnk_4Zz5.cjs → index-B8XDW6Ly.cjs} +1 -1
- package/dist/{index-BFzMf0GC.js → index-BCNDy7LZ.js} +1 -1
- package/dist/{index-DSPjcpWK.cjs → index-BMSOMrGq.cjs} +1 -1
- package/dist/{index-Cppt0AsF.cjs → index-B_WRw_3s.cjs} +1 -1
- package/dist/{index-D_igus4A.cjs → index-BaXxrBtb.cjs} +1 -1
- package/dist/{index-DeOwZgqL.js → index-Bk8CKDbz.js} +4 -4
- package/dist/{index-BXv3aZ7v.js → index-BkPXyAKD.js} +1 -1
- package/dist/{index-D_RGoDln.js → index-C9U9aO2Y.js} +3 -3
- package/dist/{index-BI7g3c_u.js → index-CAAOZFSQ.js} +13 -13
- package/dist/{index-hhS08X8b.js → index-CLddyFrz.js} +3 -3
- package/dist/{index-kLDMroPk.js → index-CUAM_spJ.js} +1 -1
- package/dist/{index-CZPnP0uy.cjs → index-CWJuJJYp.cjs} +1 -1
- package/dist/{index-BDxPlbe2.cjs → index-CYmbZuJq.cjs} +1 -1
- package/dist/{index-CQRJ3pLh.cjs → index-C_rjTaFu.cjs} +1 -1
- package/dist/{index-DHjtOySN.js → index-Cmlus98m.js} +2 -2
- package/dist/{index-331j518H.cjs → index-CnBVZu9x.cjs} +1 -1
- package/dist/{index-CqI3frdZ.js → index-Cz7uQ_eD.js} +6 -6
- package/dist/{index-D6u590uA.cjs → index-DMTBVsgY.cjs} +1 -1
- package/dist/{index-DrzK0O_g.cjs → index-DRjN9mko.cjs} +1 -1
- package/dist/{index-C-dlFxRJ.cjs → index-DThE5nRZ.cjs} +1 -1
- package/dist/{index-BYk9Fb6p.js → index-DXrBVvWh.js} +3 -3
- package/dist/{index-DRfVnLTN.js → index-DZf4BLpR.js} +6 -6
- package/dist/{index-DHBoRe9V.cjs → index-DcxUbnrO.cjs} +1 -1
- package/dist/{index-Bhha7SY3.js → index-DdQjdsrn.js} +1 -1
- package/dist/{index-BODyH6MD.js → index-Dggo7EaF.js} +1 -1
- package/dist/{index-DbDM-XfB.cjs → index-DvQRFx9T.cjs} +1 -1
- package/dist/{index-CPAXrzNY.cjs → index-FnJX1FLR.cjs} +1 -1
- package/dist/{index-iZ9BRKg5.js → index-JQ_SaJ0O.js} +1 -1
- package/dist/{index-B_zjoT4m.js → index-blVMOcaF.js} +2 -2
- package/dist/{index-DJ6qg2Mo.js → index-hbpC0O70.js} +3 -3
- package/dist/{index-S1LIIzCa.cjs → index-k579sq5M.cjs} +1 -1
- package/dist/{index-6sZXjGGz.cjs → index-nSLXu4eq.cjs} +1 -1
- package/dist/{index-B-AhHUV1.js → index-tUUpniUl.js} +1 -1
- package/dist/{index-CeGM8aBH.js → index-uWijQ8Cy.js} +2 -2
- package/dist/{index-iErxMZBi.cjs → index-yWC1EX2L.cjs} +1 -1
- package/dist/{index-BoTiP0aV.js → index-zsvDrZxo.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-BKdUW522.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-DPDuWtDv.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-CmofVWvn.js} +1642 -1647
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dzyqt2Z-.cjs → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Y4oIHCVM.cjs} +58 -58
- 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-D0zznqn6.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-YB8ip9Xh.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_1_lang-BRFs_L5R.cjs → index.vue_vue_type_style_index_1_lang-BB0IwRdP.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_1_lang-BH0DRFVE.js → index.vue_vue_type_style_index_1_lang-CT8c_mLo.js} +3 -3
- package/dist/{main-B541MQH8.cjs → main-BOuiQUiL.cjs} +1 -1
- package/dist/{main-Z5UMyCj6.js → main-CbZLyXuF.js} +2 -2
- 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-BcjGbIJZ.js → threeModel-BJ6MrCa-.js} +4 -4
- package/dist/{threeModel-tKq0hvaK.cjs → threeModel-i87HG3Ck.cjs} +1 -1
- package/dist/{threePreview-DD0br2ae.cjs → threePreview-B3v9SadK.cjs} +1 -1
- package/dist/{threePreview-BnPMGQ2H.js → threePreview-D3wObBZq.js} +309 -305
- package/dist/{threeSceneView-BUD002PP.js → threeSceneView-DDpjEIgl.js} +7 -7
- package/dist/{threeSceneView-DVUTlm6F.cjs → threeSceneView-DQpyKixe.cjs} +2 -2
- package/dist/{threeSceneViewForCPMPIP-D4RC4BAo.js → threeSceneViewForCPMPIP-DV_aOUU5.js} +202 -198
- package/dist/threeSceneViewForCPMPIP-iaIkud0j.cjs +5 -0
- package/dist/{threeTrackPathView-DDCEu3Gx.js → threeTrackPathView-D6aAG4g8.js} +375 -359
- package/dist/threeTrackPathView-nPb7Tgdd.cjs +370 -0
- package/dist/{threeViewerHost-Sda_AoRw.cjs → threeViewerHost-I50ZyvKF.cjs} +2 -2
- package/dist/{threeViewerHost-BVeUteVd.js → threeViewerHost-XR9tepbY.js} +2 -2
- package/dist/{urdfTree-Br9VYqKp.cjs → urdfTree-B19ebCHj.cjs} +1 -1
- package/dist/{urdfTree-DaWvX-6R.js → urdfTree-CjxhpnRl.js} +1 -1
- package/dist/{workpieceTreePanel-Z3aVdOWB.cjs → workpieceTreePanel-0L7tkycK.cjs} +1 -1
- package/dist/{workpieceTreePanel-BdRaFNRp.js → workpieceTreePanel-DAnMGvlX.js} +5 -5
- package/package.json +1 -1
- package/dist/obj/model.mtl +0 -42
- package/dist/obj/model.obj +0 -26110
- package/dist/threeSceneViewForCPMPIP-BYYbyqD7.cjs +0 -5
- package/dist/threeTrackPathView-BvUihuyk.cjs +0 -370
- package/public/obj/model.mtl +0 -42
- package/public/obj/model.obj +0 -26110
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),Me=require("./index.vue_vue_type_style_index_1_lang-B8_elAaU.cjs"),U=require("./workpieceTreePanel-Z3aVdOWB.cjs"),Q=require("./iconfont-C7kE-QbU.cjs"),f=require("./index-C8qRkCgn.cjs");require("./index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dzyqt2Z-.cjs");const ee=require("./index-DhufphmT.cjs"),H=require("./urdfTree-Br9VYqKp.cjs"),re=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),N=require("./svgIcon-CUM54R6L.cjs"),Be=require("./animationData-DxBvEqB1.cjs"),ze=require("./MTLLoader-zZDM0NQh.cjs"),se=require("./index-_PP-dSm3.cjs"),$e={class:"panel-content"},Le={class:"action-bar"},Re={key:0,class:"animation-controls"},Ue={class:"control-row"},je={class:"control-row"},Ae={class:"frame-info"},Ie={class:"control-row"},Oe={key:1,class:"empty-state"},Fe={class:"dialog-footer"},qe=e.defineComponent({__name:"urdfAnimationPanel",props:{model:{},scene:{},xyzbcList:{}},setup(T,{expose:j}){const w=T,o=e.ref([]),C=e.ref(!1),_=e.ref(""),i=e.ref("stopped"),d=e.ref(0),D=e.ref(0),L=e.ref(10),g=e.ref(null);let m=0;const A=e.ref([]),I=e.computed(()=>w.model?H.getNonFixedJoints(w.model).map(r=>r.name):[]),M=e.computed(()=>[...I.value]),X=e.computed(()=>M.value.length>0?`请按以下格式粘贴数据 (第一行为表头,使用 Tab 分隔):
|
|
2
|
-
${M.value.join(" ")}
|
|
3
|
-
0 0 0 ...
|
|
4
|
-
1 2 3 ...`:"请先加载模型。"),B=e.computed(()=>o.value[d.value]||{});e.watch(()=>w.model,s=>{s?(g.value=new U.URDFRobotController(s),A.value=H.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={};I.value.forEach(V=>{const v=parseFloat(n[V]);isNaN(v)||(r[V]=v)}),g.value.setJointAngles(r)}d.value=s,D.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)I.value.forEach(v=>{const p=parseFloat(r[v]);isNaN(p)||(V[v]=p)}),await g.value.animateToState(V,L.value,v=>{s===m&&(D.value=(n+v)/o.value.length*100)});else{if(await new Promise(v=>setTimeout(v,L.value)),s!==m)return;D.value=(n+1)/o.value.length*100}d.value=n}s===m&&(f.ElMessage.success("动画播放完成"),i.value="stopped",D.value=100)}catch(n){console.error("动画播放出错:",n),f.ElMessage.error("动画播放出错"),i.value="stopped"}},R=()=>{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("动画播放中")},O=()=>{i.value==="playing"&&(m++,i.value="paused",f.ElMessage.info("动画已暂停"))},F=()=>{m++,i.value="stopped",d.value=0,D.value=0,z(0),f.ElMessage.info("动画已停止并重置")},P=()=>{i.value==="playing"?O():R()},y=s=>{m++,i.value="paused",z(s)},$=()=>{if(!_.value.trim()){f.ElMessage.warning("导入内容不能为空");return}const s=_.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)=>{M.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 M.value.forEach(S=>{E[S]="0"}),Object.entries(r).forEach(([S,Y])=>{const q=u[parseInt(S)];q!==void 0&&q.trim()!==""&&(E[Y]=q.trim())}),E});v.length>0?(o.value=v,f.ElMessage.success(`成功导入 ${v.length} 行数据!`),C.value=!1,_.value="",F()):f.ElMessage.error("未能解析到有效数据,请检查格式。")};e.watch(()=>w.xyzbcList,()=>{w.xyzbcList&&(o.value=f.cloneDeep(w.xyzbcList))},{immediate:!0});const k=s=>`第 ${s+1} 帧`;return j({handlePlayPause:P,playAnimation:R,pauseAnimation:O,stopAnimation:F}),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",$e,[e.createElementVNode("div",Le,[e.createVNode(ee._sfc_main,{onClick:n[0]||(n[0]=u=>C.value=!0),disabled:M.value.length===0,modelValue:"导入数据"},null,8,["disabled"])]),o.value.length>0?(e.openBlock(),e.createElementBlock("div",Re,[e.createElementVNode("div",Ue,[n[6]||(n[6]=e.createElementVNode("label",null,"帧间隔 (ms):",-1)),e.createVNode(r,{modelValue:L.value,"onUpdate:modelValue":n[1]||(n[1]=u=>L.value=u),min:10,max:5e3,step:100,size:"small",style:{width:"120px"}},null,8,["modelValue"])]),e.createElementVNode("div",je,[n[7]||(n[7]=e.createElementVNode("label",null,"当前帧:",-1)),e.createElementVNode("span",Ae,e.toDisplayString(d.value+1)+" / "+e.toDisplayString(o.value.length),1)]),e.createElementVNode("div",Ie,[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,[B.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(B.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",Oe,n[10]||(n[10]=[e.createElementVNode("p",null,"请先导入数据",-1)]))):e.createCommentVNode("",!0),e.createVNode(p,{modelValue:C.value,"onUpdate:modelValue":n[5]||(n[5]=u=>C.value=u),title:"导入数据",width:"500px"},{footer:e.withCtx(()=>[e.createElementVNode("span",Fe,[e.createVNode(ee._sfc_main,{modelValue:"取消",onClick:n[4]||(n[4]=u=>C.value=!1)}),e.createVNode(ee._sfc_main,{modelValue:"确认导入",onClick:$,type:"primary"})])]),default:e.withCtx(()=>[n[11]||(n[11]=e.createElementVNode("p",{class:"import-instructions"}," 请从Excel或CSV中复制数据 (首行为表头, Tab分隔) ",-1)),e.createVNode(v,{modelValue:_.value,"onUpdate:modelValue":n[3]||(n[3]=u=>_.value=u),type:"textarea",rows:10,placeholder:X.value},null,8,["modelValue","placeholder"])]),_:1,__:[11]},8,["modelValue"])])}}}),ie=re._export_sfc(qe,[["__scopeId","data-v-06bc34b3"]]),Je=async T=>await new ze.OBJLoader().loadAsync(T),He=async T=>await Je(T),Xe={class:"obj-viewer-container"},Ge={class:"buttonGroup-topLeft"},Ke={class:"buttonGroup-left"},We={class:"buttonGroup-right"},Ye={class:"buttonGroup-bottom"},Ze={class:"top-panel"},Qe={class:"panel-header"},et={class:"panel-body"},tt={class:"left-panel"},lt={class:"panel-header"},nt={class:"panel-body"},ot={key:1,class:"clipping-content"},at={class:"radio-group"},st={class:"radio-label"},it={class:"radio-label"},rt={class:"radio-label"},ut={class:"radio-label"},ct={class:"right-panel"},dt={class:"panel-header"},vt={class:"panel-body"},mt={key:0,class:"loading-overlay"},pt={key:1,class:"brand"},ft={class:"brand-item"},gt={class:"item-value"},ht={class:"brand-item"},Nt={class:"item-value"},Vt={class:"brand-item"},bt={class:"item-value"},yt=e.defineComponent({__name:"threeSceneViewForCPMPIP",props:{fileBlobs:{default:()=>[]},threeData:{}},emits:["getAnimationData","getThreeData"],setup(T,{emit:j}){const w=j,o=T,C=e.inject("setManagementPageTitle"),_=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.产品型号}),D=e.computed(()=>{var t;return(t=i==null?void 0:i.value)==null?void 0:t.编号}),L=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([]),I=async l=>{!l||!l.isExtra||(await M(l),C==null||C(l==null?void 0:l.pageName),_==null||_(!0))},M=se.debounce(async l=>{await se.onPageBack();const{mainKey:t,baseMenuPath:a}=l||{};Me.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([]),B=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(()=>B.value,async()=>{if(console.log("three data",o==null?void 0:o.threeData),console.log("csvUrl",B.value),B.value){const l=await Be.initXYZBCList(B.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(U.sceneType.ROBOT),R=e.ref(null),O=e.ref(!1),F=e.ref(""),P=e.ref(!1),y=e.ref(""),$=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:q,handleResize:te,getThreeJSObjects:J,cleanup:ue,setModels:le,axesHelperVisible:ce,toggleAxesVisibility:de}=Q.useThreeJS(R),{loadSceneFromFile:ve}=U.useUrdfLoader(J,S,O,F),{isAnimating:ne,toggleAnimation:me,stopAnimation:pe}=Q.useAnimation(J,S),{isClipping:fe,activeClippingAxis:b,toggleClipping:ge,updateClippingPlanes:x}=Q.useClipping(J,S),{initRaycaster:he,selectedObject3D:Ne,setSelectedObjVisible:Ve,updatePosition:be,updateRotation:ye,dispose:Ee}=U.useRaycaster(R,J,S),ke=()=>{de()},we=e.computed(()=>W.value===U.sceneType.ROBOT),G=l=>{P.value=!0,y.value=l,l==="剖面视图"&&!fe.value&&ge()},Z=l=>{$.value=!0,k.value=l,l==="动画仿真"&&w("getAnimationData")},Ce=()=>{var l;(l=E.value)==null||l.handlePlayPause()},_e=()=>{var l;(l=E.value)==null||l.pauseAnimation()},Pe=()=>{var l;(l=E.value)==null||l.stopAnimation()},Se=(l,t)=>H.getMeshFromLink(l,t),xe=async l=>{const t=Se(l,V.value);if(p.value=t,console.log("bladeObjUrl",z.value),t&&t.parent&&z.value){const a=await He(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;ve(t).then(a=>{r.value=a,a&&xe(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]:[]),he()});const Te=()=>{q(),window.addEventListener("resize",te);const l=J();u.value=l.scene},De=()=>{y.value="",k.value="",window.removeEventListener("resize",te),ne.value&&pe(),ue(),Ee()};return e.onMounted(async()=>{await e.nextTick();try{Te()}catch(l){console.error("Three.js 初始化失败:",l),f.ElMessage.error("渲染引擎初始化失败!")}}),e.onBeforeUnmount(()=>{De()}),(l,t)=>{const a=e.resolveComponent("el-scrollbar"),K=e.resolveComponent("PipeAnalysisPanel");return e.openBlock(),e.createElementBlock("div",Xe,[e.withDirectives(e.createElementVNode("div",{ref_key:"threejsContainer",ref:R,class:"threejs-container"},null,512),[[e.vShow,we.value]]),e.createElementVNode("div",Ge,[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:"放大"}),e.createVNode(N.ThreeSvgIcon,{name:"suoxiao",size:"24",title:"缩小"}),e.createVNode(N.ThreeSvgIcon,{name:"lookAround",size:"24",onClick:e.unref(me),title:e.unref(ne)?"停止动画":"动画视图"},null,8,["onClick","title"]),e.createVNode(N.ThreeSvgIcon,{name:"zuobiaoxi",size:"24",active:e.unref(ce),onClick:ke,title:"显隐坐标轴"},null,8,["active"])]),e.createElementVNode("div",Ke,[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",We,[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:$.value&&k.value==="机床控制",title:"机床控制"},null,8,["active"]),e.createVNode(N.ThreeSvgIcon,{name:"donghuafangzhen",size:"24",title:"动画仿真",onClick:t[4]||(t[4]=h=>Z("动画仿真")),active:$.value&&k.value==="动画仿真"},null,8,["active"])]),e.createElementVNode("div",Ye,[e.createVNode(N.ThreeSvgIcon,{name:"bofang",size:"24",backgroundColor:"#ffffff",title:"播放",onClick:Ce}),e.createVNode(N.ThreeSvgIcon,{name:"zanting",size:"24",backgroundColor:"#ffffff",title:"暂停",onClick:_e}),e.createVNode(N.ThreeSvgIcon,{name:"zhongzhi",size:"24",backgroundColor:"#ffffff",title:"停止",onClick:Pe})]),e.withDirectives(e.createElementVNode("div",Ze,[e.createElementVNode("div",Qe,[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",et,[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",tt,[e.createElementVNode("div",lt,[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",nt,[e.createVNode(a,{height:"100%"},{default:e.withCtx(()=>{var h;return[y.value==="场景树"?(e.openBlock(),e.createBlock(H.UrdfTree,{key:0,model:r.value,extraNodes:A.value,onNodeClick:I},null,8,["model","extraNodes"])):e.createCommentVNode("",!0),y.value==="剖面视图"?(e.openBlock(),e.createElementBlock("div",ot,[e.createElementVNode("div",at,[e.createElementVNode("label",st,[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",it,[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",rt,[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",ut,[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(U.WorkpieceTreePanel,{key:2,model:(h=e.unref(Ne))==null?void 0:h.obj,onVisibleChange:e.unref(Ve),onUpdatePosition:e.unref(be),onUpdateRotation:e.unref(ye)},null,8,["model","onVisibleChange","onUpdatePosition","onUpdateRotation"])):e.createCommentVNode("",!0)]}),_:1})])],512),[[e.vShow,P.value]]),e.withDirectives(e.createElementVNode("div",ct,[e.createElementVNode("div",dt,[e.createElementVNode("span",null,e.toDisplayString(k.value),1),e.createElementVNode("span",{class:"close",onClick:t[15]||(t[15]=h=>$.value=!1)}," X ")]),e.createElementVNode("div",vt,[e.createVNode(a,{height:"100%"},{default:e.withCtx(()=>[e.withDirectives(e.createVNode(H.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,$.value]]),O.value?(e.openBlock(),e.createElementBlock("div",mt,[t[20]||(t[20]=e.createElementVNode("div",{class:"loading-spinner"},null,-1)),e.createElementVNode("p",null,e.toDisplayString(F.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",pt,[e.createElementVNode("div",ft,[t[21]||(t[21]=e.createElementVNode("div",{class:"item-label"},"厂家:",-1)),e.createElementVNode("div",gt,e.toDisplayString(L.value),1)]),e.createElementVNode("div",ht,[t[22]||(t[22]=e.createElementVNode("div",{class:"item-label"},"型号:",-1)),e.createElementVNode("div",Nt,e.toDisplayString(d.value),1)]),e.createElementVNode("div",Vt,[t[23]||(t[23]=e.createElementVNode("div",{class:"item-label"},"编号:",-1)),e.createElementVNode("div",bt,e.toDisplayString(D.value),1)])])):e.createCommentVNode("",!0),e.createVNode(K,{ref:"pipeAnalysisPanelRef"},null,512)])}}}),Et=re._export_sfc(yt,[["__scopeId","data-v-eef66dd4"]]);exports.default=Et;
|
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),O=require("./iconfont-C7kE-QbU.cjs"),l=require("./index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dzyqt2Z-.cjs"),Be=require("./threeViewerHost-Sda_AoRw.cjs"),W=require("./index-C8qRkCgn.cjs"),oe=require("./urdfTree-Br9VYqKp.cjs"),ue=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),V=require("./svgIcon-CUM54R6L.cjs"),Le=require("./isString--eJE54G5.cjs");function ke(r=.5,e=4){const n=new l.Mesh(new l.ConeGeometry(r,e,32),new l.MeshStandardMaterial({color:"#919191ff",metalness:.3,roughness:.6})),o=n.geometry.parameters.height;return n.geometry.translate(0,-o/2,0),n.rotation.set(-90,0,0,"XYZ"),n}function De(r,e){r.position.copy(e)}function Pe(r,e,n=new l.Color(16711680)){const o=new l.Vector3;e.getWorldPosition(o);const i=r.geometry.attributes.position,s=r.geometry.attributes.color,c=new l.Color(55551);let a=1/0,m=-1;for(let d=0;d<i.count;d++){const p=new l.Vector3().fromBufferAttribute(i,d).distanceTo(o);p<a&&(a=p,m=d)}for(let d=0;d<s.count;d++)c.toArray(s.array,d*3);if(m!==-1){const d=n.toArray(),h=m*3+2;for(let p=0;p<h;p=p+3)s.array[p]=d[0],s.array[p+1]=d[1],s.array[p+2]=d[2]}s.needsUpdate=!0}function de(r,e,n,o=new l.Color(16711680)){De(r,e),Pe(n,r,o)}const Ie={class:"panel-content"},Fe={class:"animation-controls"},Oe={class:"control-row"},je={class:"control-row"},Re={class:"frame-info"},We={class:"control-row"},Ge=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),c=t.ref(0),a=t.ref(50);let m=!1;const d=g=>`第 ${g+1} 帧`,h=g=>{if(g<0||g>=i.value.length){console.error(`帧索引 ${g} 超出范围`);return}const y=i.value[g];c.value=g,de(o.knife,y,o.cloud)},p=async()=>{if(i.value.length===0){W.ElMessage.error("无法播放动画:无数据");return}if(!s.value){s.value=!0,m=!1,i.value.length-1===c.value&&(c.value=0);try{for(let g=c.value+1;g<i.value.length&&!m;g++)await new Promise(y=>setTimeout(y,a.value)),h(g);m||W.ElMessage.success("动画播放完成")}catch(g){console.error("动画播放出错:",g),W.ElMessage.error("动画播放出错")}finally{s.value=!1}}},v=()=>{m=!0,s.value=!1,W.ElMessage.info("动画已停止")},E=g=>{s.value&&v(),h(g)};return e({playAnimation:p,stopAnimation:v,forwardFrame:()=>{s.value&&v(),!(c.value+1>=i.value.length)&&h(c.value+1)},backwardFrame:()=>{s.value&&v(),c.value!==0&&h(c.value-1)}}),(g,y)=>{const _=t.resolveComponent("el-input-number"),C=t.resolveComponent("el-form-item"),A=t.resolveComponent("el-form"),X=t.resolveComponent("el-slider");return t.openBlock(),t.createElementBlock("div",Ie,[t.createElementVNode("div",Fe,[t.createElementVNode("div",Oe,[t.createVNode(A,{"label-width":"auto",style:{width:"100%"}},{default:t.withCtx(()=>[t.createVNode(C,{label:"帧间隔 (ms):",prop:"frameDuration"},{default:t.withCtx(()=>[t.createVNode(_,{modelValue:a.value,"onUpdate:modelValue":y[0]||(y[0]=F=>a.value=F),min:0,max:5e3,step:10,style:{width:"100%"}},null,8,["modelValue"])]),_:1})]),_:1})]),t.createElementVNode("div",je,[y[2]||(y[2]=t.createElementVNode("label",null,"当前帧:",-1)),t.createElementVNode("span",Re,t.toDisplayString(c.value+1)+" / "+t.toDisplayString(i.value.length),1)]),t.createElementVNode("div",We,[y[3]||(y[3]=t.createElementVNode("label",null,"动画进度:",-1)),t.createVNode(X,{modelValue:c.value,"onUpdate:modelValue":y[1]||(y[1]=F=>c.value=F),min:0,max:i.value.length>0?i.value.length-1:0,step:1,"format-tooltip":d,onInput:E,disabled:i.value.length===0,style:{"flex-grow":"1",margin:"0 10px"}},null,8,["modelValue","max","disabled"])])])])}}}),He=ue._export_sfc(Ge,[["__scopeId","data-v-93cde733"]]),re=new l.Box3,G=new l.Vector3;class fe extends l.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 l.Float32BufferAttribute(e,3)),this.setAttribute("uv",new l.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 l.InstancedInterleavedBuffer(n,6,1);return this.setAttribute("instanceStart",new l.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceEnd",new l.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 l.InstancedInterleavedBuffer(n,6,1);return this.setAttribute("instanceColorStart",new l.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceColorEnd",new l.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 l.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 l.Box3);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),re.setFromBufferAttribute(n),this.boundingBox.union(re))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new l.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,c=e.count;s<c;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(){}}l.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new l.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};l.ShaderLib.line={uniforms:l.UniformsUtils.merge([l.UniformsLib.common,l.UniformsLib.fog,l.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 te extends l.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:l.UniformsUtils.clone(l.ShaderLib.line.uniforms),vertexShader:l.ShaderLib.line.vertexShader,fragmentShader:l.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 J=new l.Vector4,se=new l.Vector3,ae=new l.Vector3,x=new l.Vector4,b=new l.Vector4,N=new l.Vector4,Q=new l.Vector3,ee=new l.Matrix4,S=new l.Line3,le=new l.Vector3,H=new l.Box3,q=new l.Sphere,M=new l.Vector4;let T,I;function ce(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 qe(r,e){const n=r.matrixWorld,o=r.geometry,i=o.attributes.instanceStart,s=o.attributes.instanceEnd,c=Math.min(o.instanceCount,i.count);for(let a=0,m=c;a<m;a++){S.start.fromBufferAttribute(i,a),S.end.fromBufferAttribute(s,a),S.applyMatrix4(n);const d=new l.Vector3,h=new l.Vector3;T.distanceSqToSegment(S.start,S.end,h,d),h.distanceTo(d)<I*.5&&e.push({point:h,pointOnLine:d,distance:T.origin.distanceTo(h),object:r,face:null,faceIndex:a,uv:null,uv1:null})}}function $e(r,e,n){const o=e.projectionMatrix,s=r.material.resolution,c=r.matrixWorld,a=r.geometry,m=a.attributes.instanceStart,d=a.attributes.instanceEnd,h=Math.min(a.instanceCount,m.count),p=-e.near;T.at(1,N),N.w=1,N.applyMatrix4(e.matrixWorldInverse),N.applyMatrix4(o),N.multiplyScalar(1/N.w),N.x*=s.x/2,N.y*=s.y/2,N.z=0,Q.copy(N),ee.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,E=h;v<E;v++){if(x.fromBufferAttribute(m,v),b.fromBufferAttribute(d,v),x.w=1,b.w=1,x.applyMatrix4(ee),b.applyMatrix4(ee),x.z>p&&b.z>p)continue;if(x.z>p){const C=x.z-b.z,A=(x.z-p)/C;x.lerp(b,A)}else if(b.z>p){const C=b.z-x.z,A=(b.z-p)/C;b.lerp(x,A)}x.applyMatrix4(o),b.applyMatrix4(o),x.multiplyScalar(1/x.w),b.multiplyScalar(1/b.w),x.x*=s.x/2,x.y*=s.y/2,b.x*=s.x/2,b.y*=s.y/2,S.start.copy(x),S.start.z=0,S.end.copy(b),S.end.z=0;const U=S.closestPointToPointParameter(Q,!0);S.at(U,le);const g=l.MathUtils.lerp(x.z,b.z,U),y=g>=-1&&g<=1,_=Q.distanceTo(le)<I*.5;if(y&&_){S.start.fromBufferAttribute(m,v),S.end.fromBufferAttribute(d,v),S.start.applyMatrix4(c),S.end.applyMatrix4(c);const C=new l.Vector3,A=new l.Vector3;T.distanceSqToSegment(S.start,S.end,A,C),n.push({point:A,pointOnLine:C,distance:T.origin.distanceTo(A),object:r,face:null,faceIndex:v,uv:null,uv1:null})}}}class Xe extends l.Mesh{constructor(e=new fe,n=new te({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 c=0,a=0,m=n.count;c<m;c++,a+=2)se.fromBufferAttribute(n,c),ae.fromBufferAttribute(o,c),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+se.distanceTo(ae);const s=new l.InstancedInterleavedBuffer(i,2,1);return e.setAttribute("instanceDistanceStart",new l.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new l.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;T=e.ray;const c=this.matrixWorld,a=this.geometry,m=this.material;I=m.linewidth+s,a.boundingSphere===null&&a.computeBoundingSphere(),q.copy(a.boundingSphere).applyMatrix4(c);let d;if(o)d=I*.5;else{const p=Math.max(i.near,q.distanceToPoint(T.origin));d=ce(i,p,m.resolution)}if(q.radius+=d,T.intersectsSphere(q)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),H.copy(a.boundingBox).applyMatrix4(c);let h;if(o)h=I*.5;else{const p=Math.max(i.near,H.distanceToPoint(T.origin));h=ce(i,p,m.resolution)}H.expandByScalar(h),T.intersectsBox(H)!==!1&&(o?qe(this,n):$e(this,i,n))}onBeforeRender(e){const n=this.material.uniforms;n&&n.resolution&&(e.getViewport(J),this.material.uniforms.resolution.value.set(J.z,J.w))}}class me extends fe{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 Ye extends Xe{constructor(e=new me,n=new te({color:Math.random()*16777215})){super(e,n),this.isLine2=!0,this.type="Line2"}}function Ze(r){const e=[];return r.forEach(n=>{const[o,i,s]=n.trim().split(/\s+/);e.push(+o,+i,+s)}),e}function $(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 Ke(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 c=null,a="";for(let m=0;m<(s==null?void 0:s.length);m++){const d=s[m],h=n.find(p=>p===d);if(h){c&&$(c,i,a),a="",c=h;continue}a=a+d}$(c,i,a),e.push(i.x,i.y,i.z)}),e}const Je=r=>r==null?void 0:r.filter(n=>n.includes("=")),Qe=r=>r.replace(/,/g,""),et=r=>r==null?void 0:r.map(n=>Qe(n)),tt=r=>{const e=Je(r);return et(e)};function nt(r){const e=tt(r),n=[];return e.forEach(o=>{var p,v,E,B,U,g;let[i,s,c,a]=o.trim().split(/\s+/);s=(p=s==null?void 0:s.trim)==null?void 0:p.call(s),c=(v=c==null?void 0:c.trim)==null?void 0:v.call(c),a=(E=a==null?void 0:a.trim)==null?void 0:E.call(a);const[,m]=(B=s==null?void 0:s.split)==null?void 0:B.call(s,"="),[,d]=(U=c==null?void 0:c.split)==null?void 0:U.call(c,"="),[,h]=(g=a==null?void 0:a.split)==null?void 0:g.call(a,"=");n.push(+m,+d,+h)}),n}const it=r=>r>="0"&&r<="9",ot=r=>r==="+"||r==="-",rt=r=>r===".";function st(r){return it(r)||ot(r)||rt(r)}function at(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 c=null,a="";for(let m=0;m<(s==null?void 0:s.length);m++){const d=s[m],h=n.has(d)?d:null,p=st(d);if(h||!p){c&&$(c,i,a),h?c=h:c=null,a="";continue}a=a+d}c&&$(c,i,a),e.push(i.x,i.y,i.z)}),e}function lt(r){return r==null?void 0:r.includes("=")}async function ct(r){var i,s;const e=(i=r==null?void 0:r.trim())==null?void 0:i.split(/\r?\n/);if(lt(r))return nt(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 Ze(e);if((o==null?void 0:o.length)===1)return Ke(e)}async function ut(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,c,a]=i;n.push(+s,+c,+a)}),n}async function dt(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,c,a]=i;n.push(+s,+c,+a)}),n}async function ft(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}),at(e)}async function mt(r,e){const{isCyd:n,isUv:o,isCpt:i,isNc:s}=e;return o?ct(r):n?dt(r):i?ut(r):s?ft(r):[]}function pt(r){const e=[];for(let n=0;n<r.length;n+=3)e.push(new l.Vector3(r[n],r[n+1],r[n+2]));return e}function ht(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 c=[];for(let v=0;v<e.length;v+=3)c.push(new l.Vector3(e[v],e[v+1],e[v+2]));const m=new l.CatmullRomCurve3(c,!1,"catmullrom",.5).getPoints(150).flatMap(v=>[v.x,v.y,v.z]),d=new me;d.setPositions(m);const h=new te({color:55551,linewidth:3,resolution:new l.Vector2(window.innerWidth,window.innerHeight)}),p=new Ye(d,h);return p.name="轨迹路径",n.add(p),p}function vt(r,e,n,o=4,i=50){let s=1/0,c=-1/0,a=1/0,m=-1/0,d=1/0,h=-1/0;for(let g=0;g<r.length;g+=3){const y=r[g],_=r[g+1],C=r[g+2];s=Math.min(s,y),c=Math.max(c,y),a=Math.min(a,_),m=Math.max(m,_),d=Math.min(d,C),h=Math.max(h,C)}const v=Math.sqrt((c-s)**2+(m-a)**2+(h-d)**2)*.05,E=l.MathUtils.degToRad(e.fov),B=2*Math.tan(E/2)*i,U=v/B*n.domElement.height*(o/4);return Math.min(.4,U)}function gt(r){if(r.length%3!==0)return console.error("points array length is not a multiple of 3:",r),null;const e=new l.BufferGeometry;e.setAttribute("position",new l.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 l.BufferAttribute(n,3));const o=new l.PointsMaterial({vertexColors:!0,size:.4,sizeAttenuation:!0}),i=new l.Points(e,o);return o.needsUpdate=!0,i}function wt(r,e){const n=new l.Box3().setFromArray(e),o=[new l.Vector3(n.min.x,n.min.y,n.min.z),new l.Vector3(n.max.x,n.min.y,n.min.z),new l.Vector3(n.min.x,n.max.y,n.min.z),new l.Vector3(n.min.x,n.min.y,n.max.z),new l.Vector3(n.max.x,n.max.y,n.min.z),new l.Vector3(n.max.x,n.min.y,n.max.z),new l.Vector3(n.min.x,n.max.y,n.max.z),new l.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 yt(r,e){if(!e)return;const{scene:n,camera:o,renderer:i,controls:s}=r();if(!n||!o||!i||!s)return;const c=gt(e);if(!c)return;c.name="轨迹路径",n.add(c);const a=vt(e,o,i,.1,50);c.material.size=a;const m=wt(o,e);return o.far=m*1.2,o.updateProjectionMatrix(),c}const xt={class:"obj-viewer-container"},bt={class:"buttonGroup-topLeft"},St={class:"buttonGroup-left"},_t={class:"buttonGroup-right"},Et={class:"buttonGroup-bottom"},Ct={class:"left-panel"},Vt={class:"panel-header"},zt={class:"panel-body"},At={key:1,class:"clipping-content"},Ut={class:"radio-group"},Nt={class:"radio-label"},Mt={class:"radio-label"},Tt={class:"radio-label"},Bt={class:"radio-label"},Lt={class:"right-panel"},kt={class:"panel-header"},Dt={class:"panel-body"},Pt={key:0,class:"loading-overlay"},It=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),c=t.ref(""),a=t.ref(),m=t.ref(!1),d=t.ref(""),h=t.ref(!1),p=t.ref(""),v=t.shallowRef(null),E=t.shallowRef(null),{currentModels:B,resetView:U,initThreeJS:g,handleResize:y,getThreeJSObjects:_,cleanup:C,axesHelperVisible:A,toggleAxesVisibility:X}=O.useThreeJS(i),{isAnimating:F,toggleAnimation:pe,stopAnimation:he}=O.useAnimation(_,B),{isClipping:ve,activeClippingAxis:z,toggleClipping:ge,updateClippingPlanes:L}=O.useClipping(_,B),we=()=>{X()},Y=f=>{m.value=!0,d.value=f,f==="剖面视图"&&!ve.value&&ge()},Z=f=>{h.value=!0,p.value=f,f==="动画仿真"&&n("getAnimationData")},K=t.ref([]),j=t.ref([]),ye=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isUv}),xe=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isCyd}),be=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isCpt}),D=t.computed(()=>{var u;return(u=o.trackFileType)==null?void 0:u.isNc}),Se=t.computed(()=>{const f=o.fileBlobs||[];return f==null?void 0:f[0]});let k=t.shallowRef(),P=t.shallowRef();const _e=()=>{const{scene:f}=_();k.value&&f&&(O.disposeObj(k.value,f),k.value=null)},Ee=()=>{const{scene:f}=_();P.value&&f&&(O.disposeObj(P.value,f),P.value=null)},ne=()=>{_e(),Ee()},Ce=async f=>{const u=URL.createObjectURL(f),R=await Be.readFileText(u);if(URL.revokeObjectURL(u),Le.isString(R)){const w=await mt(R,o.trackFileType)||[];K.value=w;const ie=K.value;ye.value&&(k.value=ht(_,ie)),(xe.value||be.value||D.value)&&(k.value=yt(_,ie)),O.frameCameraToMesh(_,k.value)}},Ve=()=>{var f,u;P.value=ke(),j.value=pt(K.value),j.value&&j.value.length&&(de(P.value,j.value[0],k.value,new l.Color(16711680)),(u=(f=E.value)==null?void 0:f.add)==null||u.call(f,P.value))};t.watch(()=>Se.value,async f=>{f&&(ne(),await Ce(f),D.value&&Ve())},{immediate:!0,deep:!0});const ze=()=>{var f;D.value&&((f=a==null?void 0:a.value)==null||f.playAnimation())},Ae=()=>{var f;D.value&&((f=a==null?void 0:a.value)==null||f.stopAnimation())},Ue=()=>{var f;D.value&&((f=a==null?void 0:a.value)==null||f.forwardFrame())},Ne=()=>{var f;D.value&&((f=a==null?void 0:a.value)==null||f.backwardFrame())},Me=()=>{g(),window.addEventListener("resize",y);const f=_();E.value=f.scene,E.value&&(E.value.name="CPMPIP")},Te=()=>{window.removeEventListener("resize",y),F.value&&he(),ne(),C()};return t.onMounted(async()=>{try{Me()}catch(f){console.error("Three.js 初始化失败:",f),W.ElMessage.error("渲染引擎初始化失败!")}}),t.onBeforeUnmount(()=>{Te()}),(f,u)=>{const R=t.resolveComponent("el-scrollbar");return t.openBlock(),t.createElementBlock("div",xt,[t.createElementVNode("div",{ref_key:"threejsContainer",ref:i,class:"threejs-container"},null,512),t.createElementVNode("div",bt,[t.createVNode(V.ThreeSvgIcon,{name:"viewReset",size:"24",onClick:t.unref(U),title:"重置"},null,8,["onClick"]),t.createVNode(V.ThreeSvgIcon,{name:"fangda",size:"24",title:"放大"}),t.createVNode(V.ThreeSvgIcon,{name:"suoxiao",size:"24",title:"缩小"}),t.createVNode(V.ThreeSvgIcon,{name:"lookAround",size:"24",onClick:t.unref(pe),title:t.unref(F)?"停止动画":"动画视图"},null,8,["onClick","title"]),t.createVNode(V.ThreeSvgIcon,{name:"zuobiaoxi",size:"24",active:t.unref(A),onClick:we,title:"显隐坐标轴"},null,8,["active"])]),t.createElementVNode("div",St,[t.renderSlot(f.$slots,"button-left",{switchRightPanel:Y},void 0,!0),t.createVNode(V.ThreeSvgIcon,{name:"jiegoushu",size:"24",onClick:u[0]||(u[0]=w=>Y("场景树")),active:m.value&&d.value==="场景树",title:"场景树"},null,8,["active"]),t.createVNode(V.ThreeSvgIcon,{name:"clipping",size:"24",onClick:u[1]||(u[1]=w=>Y("剖面视图")),active:m.value&&d.value==="剖面视图",title:"剖面视图"},null,8,["active"])]),t.createElementVNode("div",_t,[t.renderSlot(f.$slots,"button-right",{switchRightPanel:Z},void 0,!0),t.createVNode(V.ThreeSvgIcon,{name:"guanjiekongzhi",size:"24",onClick:u[2]||(u[2]=w=>Z("关节控制")),active:h.value&&p.value==="关节控制",title:"关节控制"},null,8,["active"]),t.createVNode(V.ThreeSvgIcon,{name:"donghuafangzhen",size:"24",title:"动画仿真",onClick:u[3]||(u[3]=w=>Z("动画仿真")),active:h.value&&p.value==="动画仿真"},null,8,["active"])]),t.createElementVNode("div",Et,[t.createVNode(V.ThreeSvgIcon,{name:"kuaitui",size:"24",backgroundColor:"#ffffff",title:"快退",onClick:Ne}),t.createVNode(V.ThreeSvgIcon,{name:"bofang",size:"24",backgroundColor:"#ffffff",title:"播放",onClick:ze}),t.createVNode(V.ThreeSvgIcon,{name:"kuaijin",size:"24",backgroundColor:"#ffffff",title:"快进",onClick:Ue}),t.createVNode(V.ThreeSvgIcon,{name:"zanting",size:"24",backgroundColor:"#ffffff",title:"暂停",onClick:Ae})]),t.withDirectives(t.createElementVNode("div",Ct,[t.createElementVNode("div",Vt,[t.createElementVNode("span",null,t.toDisplayString(d.value),1),t.createElementVNode("span",{class:"close",onClick:u[4]||(u[4]=w=>m.value=!1)}," X ")]),t.createElementVNode("div",zt,[t.createVNode(R,{height:"100%"},{default:t.withCtx(()=>[d.value==="场景树"?(t.openBlock(),t.createBlock(oe.UrdfTree,{key:0,model:v.value},null,8,["model"])):t.createCommentVNode("",!0),d.value==="剖面视图"?(t.openBlock(),t.createElementBlock("div",At,[t.createElementVNode("div",Ut,[t.createElementVNode("label",Nt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"none","onUpdate:modelValue":u[5]||(u[5]=w=>t.isRef(z)?z.value=w:null),onChange:u[6]||(u[6]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(z)]]),u[14]||(u[14]=t.createElementVNode("span",{class:"radio-text"},"无切割",-1))]),t.createElementVNode("label",Mt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"x","onUpdate:modelValue":u[7]||(u[7]=w=>t.isRef(z)?z.value=w:null),onChange:u[8]||(u[8]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(z)]]),u[15]||(u[15]=t.createElementVNode("span",{class:"radio-text"},"X轴切割",-1))]),t.createElementVNode("label",Tt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"y","onUpdate:modelValue":u[9]||(u[9]=w=>t.isRef(z)?z.value=w:null),onChange:u[10]||(u[10]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(z)]]),u[16]||(u[16]=t.createElementVNode("span",{class:"radio-text"},"Y轴切割",-1))]),t.createElementVNode("label",Bt,[t.withDirectives(t.createElementVNode("input",{type:"radio",name:"clipping-axis",value:"z","onUpdate:modelValue":u[11]||(u[11]=w=>t.isRef(z)?z.value=w:null),onChange:u[12]||(u[12]=(...w)=>t.unref(L)&&t.unref(L)(...w))},null,544),[[t.vModelRadio,t.unref(z)]]),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",Lt,[t.createElementVNode("div",kt,[t.createElementVNode("span",null,t.toDisplayString(p.value),1),t.createElementVNode("span",{class:"close",onClick:u[13]||(u[13]=w=>h.value=!1)}," X ")]),t.createElementVNode("div",Dt,[t.createVNode(R,{height:"100%"},{default:t.withCtx(()=>[t.withDirectives(t.createVNode(oe.JointPanel,{model:v.value},null,8,["model"]),[[t.vShow,p.value==="关节控制"]]),t.withDirectives(t.createVNode(He,{ref_key:"animationPanelRef",ref:a,cloud:t.unref(k),knife:t.unref(P),vectors:j.value},null,8,["cloud","knife","vectors"]),[[t.vShow,p.value==="动画仿真"&&D.value]])]),_:1})])],512),[[t.vShow,h.value]]),s.value?(t.openBlock(),t.createElementBlock("div",Pt,[u[18]||(u[18]=t.createElementVNode("div",{class:"loading-spinner"},null,-1)),t.createElementVNode("p",null,t.toDisplayString(c.value),1)])):t.createCommentVNode("",!0)])}}}),Ft=ue._export_sfc(It,[["__scopeId","data-v-48ba356f"]]);exports.default=Ft;
|
package/public/obj/model.mtl
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# CAD Exchanger 3.24.0 (cadexchanger.com)
|
|
2
|
-
# Material Count: 5
|
|
3
|
-
|
|
4
|
-
newmtl Material_1
|
|
5
|
-
Ns 0.000000
|
|
6
|
-
Ka 0.200000 0.200000 0.200000
|
|
7
|
-
Kd 0.666667 0.666667 0.666667
|
|
8
|
-
Ks 0.000000 0.000000 0.000000
|
|
9
|
-
Ke 0.000000 0.000000 0.000000
|
|
10
|
-
d 1.000000
|
|
11
|
-
|
|
12
|
-
newmtl Material_2
|
|
13
|
-
Ns 0.000000
|
|
14
|
-
Ka 0.200000 0.200000 0.200000
|
|
15
|
-
Kd 0.133333 0.133333 0.133333
|
|
16
|
-
Ks 0.000000 0.000000 0.000000
|
|
17
|
-
Ke 0.000000 0.000000 0.000000
|
|
18
|
-
d 1.000000
|
|
19
|
-
|
|
20
|
-
newmtl Material_3
|
|
21
|
-
Ns 0.000000
|
|
22
|
-
Ka 0.200000 0.200000 0.200000
|
|
23
|
-
Kd 0.733333 0.733333 0.733333
|
|
24
|
-
Ks 0.000000 0.000000 0.000000
|
|
25
|
-
Ke 0.000000 0.000000 0.000000
|
|
26
|
-
d 1.000000
|
|
27
|
-
|
|
28
|
-
newmtl Material_5
|
|
29
|
-
Ns 0.000000
|
|
30
|
-
Ka 0.200000 0.200000 0.200000
|
|
31
|
-
Kd 0.396078 0.941176 0.450980
|
|
32
|
-
Ks 0.000000 0.000000 0.000000
|
|
33
|
-
Ke 0.000000 0.000000 0.000000
|
|
34
|
-
d 1.000000
|
|
35
|
-
|
|
36
|
-
newmtl Material_4
|
|
37
|
-
Ns 0.000000
|
|
38
|
-
Ka 0.200000 0.200000 0.200000
|
|
39
|
-
Kd 1.000000 1.000000 0.000000
|
|
40
|
-
Ks 0.000000 0.000000 0.000000
|
|
41
|
-
Ke 0.000000 0.000000 0.000000
|
|
42
|
-
d 1.000000
|