@syhr/sy-three 1.0.0-rc.6 → 1.0.0-rc.7

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.
@@ -50,4 +50,4 @@
50
50
  uv *= 2.0 * ( cos(iTime * 2.0) -2.5);
51
51
  float anim = sin(iTime * 12.0) * 0.1 + 1.0;
52
52
  vec3 col = cheap_star(uv, anim) * vec3(0.35,0.2,0.15);
53
- `,key:"col",commonFinish:!0,render:"iTime+speed"}];let ne=null,U=null;const $e=r=>(r==null?void 0:r.name)||(r==null?void 0:r.label)||"",St=(r={})=>Object.values(r).filter(e=>e&&(e.label||e.name)),ir=St(tr),ar=St(nr),or=()=>({THREED_GUI_PARAMS:Ie,THREED_LOG_BUFFER:Nn,THREED_CURRSCENE:Bn,THREED_ACTIVE_MENU:Gn,THREED_PIXEL_RATIO:Kn,THREED_IMPORT_SIZE:qn,THREED_LIGHT_TYPES:Zn,THREED_EXPORT_BATCH:Et,THREED_RELOAD_DELAY:Wn,THREED_MODEL_DBNAME:le,THREED_MODEL_DBSTORE:we,THREED_SCENE_PREVIEW:zn,THREED_USER_DATA_KEYS:At,THREED_MODEL_LOAD_KEY:Se,THREED_PREVIEW_URL_KEY:re,THREED_ADDON_EDITOR_JSON:Vn,THREED_EXPORT_NODE_COUNT:jn,THREED_DEFAULT_SCENE_NAME:Xn,THREED_DEFAULT_ACTIVE_MENU:Yn,THREED_DEFAULT_PIXEL_RATIO:Qn,THREED_EXPORT_VERTEX_COUNT:Jn,THREED_SCENE_EXCLUDE_TYPES:er,THREED_EXPORT_EXCLUDE_TYPES:gt,THREED_EXPORT_RUNTIME_TYPES:wt,THREED_SCENE_STORAGE_SUFFIX:$n});function cr(){const{createInstance:r,dropInstance:e}=Fn(),t="/";let n=[];const s=i=>{let u=URL.createObjectURL(i);return n.push(u),u},a=()=>{n.forEach(i=>URL.revokeObjectURL(i)),n=[]},o=()=>m(this,null,function*(){return yield h(),{clearRequest:c,getAllRequest:k,getRequest:p,status:!0,message:"数据库打开成功",DATABASE:U}}),c=i=>m(this,null,function*(){if(!i)return{status:!1,message:"删除失败"};yield h(),yield U.removeItem(i);const u=yield G();return u.list=u.list.filter(d=>d.name!==i),{status:!0,message:"删除成功"}}),l=(...u)=>m(this,[...u],function*(i=le){U=null,ne=null,yield e({name:i,storeName:we})}),h=()=>m(this,null,function*(){return U||(ne||(ne=r({name:le,storeName:we}).then(i=>(U=i,i))),yield ne)}),S=i=>{if(!i)return!1;const u=String(i.message||"");return i.name==="DataError"||u.includes("in-line keys")},N=()=>m(this,null,function*(){U=null,ne=null,yield e({name:le}),yield h()});let K=null;const G=()=>m(this,null,function*(){return window.threeEditorDB?window.threeEditorDB:(K||(K=m(this,null,function*(){const i=yield o(),{data:u}=yield i.getAllRequest();return window.threeEditorDB={db:i,list:u},window.threeEditorDB})),yield K)}),p=i=>m(this,null,function*(){if(!i)return{status:!1,message:"获取失败"};yield h();const u=yield U.getItem(i);if(u!=null&&u.blob&&!i)return{status:!0,message:"获取成功",url:s(u.blob)};if(!i)return{status:!1,message:"获取失败"};const d=yield fetch(i).then(v=>v.blob()),f={blob:d};try{yield U.setItem(i,f)}catch(v){if(!S(v))throw v;yield N(),yield U.setItem(i,f)}const w=yield G(),H=M({name:i},f),D=w.list.findIndex(v=>v.name===i);return D>-1?w.list.splice(D,1,H):w.list.push(H),{status:!0,message:"文件缓存成功",url:s(d)}}),k=()=>m(this,null,function*(){yield h();const i=[];return U&&(yield U.iterate((u,d)=>{i.push(ae(M({},u||{}),{name:d}))})),window.threeEditorDB&&(window.threeEditorDB.list=i),{status:!0,message:"获取成功",data:i}}),Y=()=>m(this,null,function*(){var d;const{res:i}=yield B.getApi("/filehandle/scan",{path:lt.threeModelPath,extension:"glb,gltf"}),u=[];if(((d=i==null?void 0:i.children)==null?void 0:d.length)>0)for(const f of i.children)u.push({name:f.name,path:"/"+f.path});return u}),q=()=>window.GUI_PARAMS||Ie,_=()=>window.threeEditor||null,E=()=>window.editorJsons||[],T=()=>({width:window.innerWidth||0,height:window.innerHeight||0}),g=()=>ir,P=()=>rr||{},I=()=>window[re]||"",y=()=>ar,b=()=>window.devicePixelRatio||1,R=()=>window[re]||"",L=()=>{const i=g(),u=y();return{modelDesigns:i,componentDesigns:u,modelList:i.map(d=>d.label),componentList:u.map(d=>d.label)}},F=(i,u)=>{var d;return(d=i==null?void 0:i.__DESIGNS__)==null?void 0:d.find(f=>f.label===u)},W=(i=0)=>!Number.isFinite(i)||i<=0?"0 B":i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:i<1024*1024*1024?`${(i/1024/1024).toFixed(1)} MB`:`${(i/1024/1024/1024).toFixed(2)} GB`,Q=i=>{const u=window[Se];typeof u=="function"&&u(i)},j=i=>!!i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z),te=i=>{var u,d;return!i||!i.visible||(u=i.userData)!=null&&u.excludeFromExport||i.isTransformControls||i.isHelper||i.isLight||i.isPoints||(d=i.type)!=null&&d.includes("Helper")||gt.has(i.type)||wt.has(i.type)||i.isCSS2DObject||i.isCSS3DObject?!1:i.isMesh||i.isGroup||i.isObject3D||i.isLine},me=(i,u)=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)?i:u,Ct=i=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)&&Number.isFinite(i.w)?i:{x:0,y:0,z:0,w:1},Le=i=>{if(!(i!=null&&i.isObject3D))return;const u=me(i.position,{x:0,y:0,z:0});i.position.set(u.x,u.y,u.z);const d=me(i.scale,{x:1,y:1,z:1});i.scale.set(d.x===0?1:d.x,d.y===0?1:d.y,d.z===0?1:d.z);const f=me(i.up,{x:0,y:1,z:0});i.up.set(f.x,f.y,f.z);const w=Ct(i.quaternion);i.quaternion.set(w.x,w.y,w.z,w.w),i.pivot&&!j(i.pivot)&&delete i.pivot,i.updateMatrix(),i.updateMatrixWorld(!1)},Rt=(i,u="_blank")=>window.open(i,u),Dt=(i,u="")=>window.prompt(i,u),vt=()=>window.location.reload(),xt=()=>document.documentElement.classList.remove("dark"),Tt=i=>{if(!Array.isArray(i==null?void 0:i.__DESIGNS__))return L();const u=[...g(),...y()],d=new Set(i.__DESIGNS__.map(f=>$e(f)));return u.forEach(f=>{const w=$e(f);!w||d.has(w)||(d.add(w),i.__DESIGNS__.unshift(f))}),L()},Pt=i=>{if(!Array.isArray(i==null?void 0:i.__GLSLLIB__))return;const u=new Set(i.__GLSLLIB__.map(d=>d==null?void 0:d.name));sr.forEach(d=>{u.has(d.name)||(u.add(d.name),i.__GLSLLIB__.push(d))})},fe=(i={})=>{const u={};return Object.entries(i||{}).forEach(([d,f])=>{if(!(At.has(d)||typeof f=="function")){if(!f||["string","number","boolean"].includes(typeof f)){u[d]=f;return}if(Array.isArray(f)){try{u[d]=structuredClone(f)}catch(w){return}return}if(!(f.isObject3D||f.isMaterial||f.isTexture||f.nodeType))try{u[d]=structuredClone(f)}catch(w){return}}}),u},bt=(i=Ie)=>{window.GUI_PARAMS=i},Lt=i=>{window.threeEditor=i},Mt=i=>{window.threeEditorDB=i},Ot=i=>{window[Se]=i},Ht=(i="")=>{window[re]=i},Ut=(i="")=>{window[re]=i},Me=i=>{var d;const u=[];return(d=i==null?void 0:i.children)==null||d.forEach(f=>{te(f)&&u.push(f)}),u},Oe=(i=[])=>{const u={rootCount:i.length,nodeCount:0,meshCount:0,vertexCount:0,skippedCount:0};return i.forEach(d=>{d.traverse(f=>{var w,H,D;if(te(f)){u.nodeCount+=1,f.isMesh&&(u.meshCount+=1,u.vertexCount+=((D=(H=(w=f.geometry)==null?void 0:w.attributes)==null?void 0:H.position)==null?void 0:D.count)||0);return}f!==d&&(u.skippedCount+=1)})}),u},He=()=>new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0))),Ue=()=>new Promise(i=>{if(typeof window.requestIdleCallback=="function"){window.requestIdleCallback(()=>i(),{timeout:80});return}setTimeout(i,0)}),kt=(i,u)=>m(this,null,function*(){var w;if(!te(i))return null;const d=i.clone(!1);d.userData=fe(i.userData),j(i.pivot)?d.pivot=new O.THREE.Vector3(i.pivot.x,i.pivot.y,i.pivot.z):"pivot"in d&&delete d.pivot,Le(d);const f=[{source:i,clone:d}];for(;f.length;){const H=f.shift();for(const D of H.source.children){if(!te(D)){u.skippedCount+=1;continue}const v=D.clone(!1);v.userData=fe(D.userData),j(D.pivot)?v.pivot=new O.THREE.Vector3(D.pivot.x,D.pivot.y,D.pivot.z):"pivot"in v&&delete v.pivot,Le(v),H.clone.add(v),f.push({source:D,clone:v}),u.processedCount+=1,u.processedCount%Et===0&&(yield(w=u.onProgress)==null?void 0:w.call(u,{processedCount:u.processedCount,totalCount:u.totalCount,skippedCount:u.skippedCount,progress:18+Math.min(u.processedCount/Math.max(u.totalCount,1)*54,54)}),yield He())}}return d});return{baseUrl:t,getModels:Y,getRequest:p,reloadPage:vt,promptInput:Dt,waitForIdle:Ue,waitForPaint:He,clearRequest:c,getGuiParams:q,setGuiParams:bt,getAllRequest:k,getEditorJsons:E,getThreeEditor:_,formatFileSize:W,setThreeEditor:Lt,removeDarkClass:xt,openExternalUrl:Rt,getThreedModels:g,getViewportSize:T,buildExportScene:(d,...f)=>m(this,[d,...f],function*(i,u={}){const w=Me(i),H=Oe(w),D=new O.THREE.Scene,v={totalCount:H.nodeCount,processedCount:0,skippedCount:0,onProgress:u.onProgress};for(const Ft of w){const ke=yield kt(Ft,v);ke&&D.add(ke),yield Ue()}return D.updateMatrixWorld(!0),H.skippedCount+=v.skippedCount,{exportScene:D,exportObjects:w,stats:H}}),createModelDbApi:o,getEditorPreviewSceneUrl:R,sanitizeUserData:fe,setThreeEditorDB:Mt,findThreedDesign:F,getThreedLightMap:P,collectExportStats:Oe,getPreviewSceneUrl:I,setEditorPreviewSceneUrl:Ut,setPreviewSceneUrl:Ht,setModelLoadHander:Ot,isExportableObject:te,deleteThreeEditorDB:l,ensureThreeEditorDB:G,getDevicePixelRatio:b,getThreedComponents:y,collectExportObjects:Me,resetModelDbInstance:N,ensureModelDbInstance:h,getLocalDesignMenuData:L,invokeModelLoadHandler:Q,isLegacyInlineKeyError:S,ensureThreedShaderLibrary:Pt,ensureThreedDesignRegistry:Tt,createBlobUrl:s,revokeModelObjectUrls:a}}const{THREED_LOG_BUFFER:xe,THREED_CURRSCENE:ue,THREED_ACTIVE_MENU:Te,THREED_PIXEL_RATIO:Pe,THREED_SCENE_PREVIEW:be,THREED_ADDON_EDITOR_JSON:de,THREED_DEFAULT_SCENE_NAME:lr,THREED_DEFAULT_ACTIVE_MENU:ye,THREED_DEFAULT_PIXEL_RATIO:Ce,THREED_SCENE_STORAGE_SUFFIX:qe}=or(),ur=[xe,ue,Te,Pe,be,de],V=(r,e)=>{const t=ve.getLocal(r);return t==null?e:t},z=(r,e)=>{r&&ve.setLocal(r,e)},Ee=r=>{r&&ve.removeLocal(r)},dr=(r,e)=>{var n,s;const t=(n=r==null?void 0:r.trim)==null?void 0:n.call(r);return t&&e.some(a=>a.name===t)?t:((s=e[0])==null?void 0:s.name)||lr},Re=(r=[])=>Array.isArray(r)?r.filter(e=>typeof e=="string"&&e):[],We=()=>{const r=[],e=V(ue,{name:"",path:""}),t=Number.parseFloat(V(Pe,Ce));return{taskState:{busy:!1,type:"",title:"",message:"",description:"",progress:0},currScene:e,sceneList:r,previewScene:!!V(be,!1),activeMenuTitle:V(Te,ye)||ye,pixelRatio:Number.isFinite(t)&&t>0?t:Ce,logarithmicDepthBuffer:V(xe,!0)!==!1,addonEditorJson:Re(V(de,[]))}},It=De.defineStore("threed",{state:()=>We(),actions:{getSceneList(){return m(this,null,function*(){var e;const r=yield B.getCommonApi("threedfloorplan",{limit:1e4,ordering:"-create_time"});(e=r==null?void 0:r.data)!=null&&e.length?(this.sceneList=r.data,this.currScene.path?this.sceneList.find(n=>n.id===this.currScene.id)||this.setCurrScene({name:"",path:""}):this.setCurrScene(this.sceneList[0])):(this.sceneList=[],this.setCurrScene({name:"",path:""}))})},setSceneList(r){this.sceneList=r},setSceneName(r){this.sceneName=dr(r,this.sceneList),z(ue,this.sceneName)},createScene(r,e=""){return m(this,null,function*(){var c,l;const t=(c=r==null?void 0:r.trim)==null?void 0:c.call(r);if(!t||this.sceneList.some(h=>h.name===t))return!1;const n=lt.threeSavePath+"/"+ge()+".json",s=ge();if(!(yield B.postCommonApi("query/threedfloorplan/create",{data:[{name:t,path:n,guid:s}]})).success)return!1;if(yield On(n,e)){const h=yield B.postCommonApi("threedfloorplan",{guid:s});if((l=h==null?void 0:h.data)!=null&&l.length)return this.sceneList=[...this.sceneList,h.data[0]],h.data[0]}return!0})},deleteScene(r){return m(this,null,function*(){var n;if(!r)return;if(!(yield B.postCommonApi("query/threedfloorplan/delete",{data:[r]})).success)return!1;const t=this.sceneList.findIndex(s=>s.id===r);return t===-1?!1:(this.sceneList.splice(t,1),((n=this.currScene)==null?void 0:n.id)===r&&this.setCurrScene(this.sceneList[0]||{name:"",path:""}),!0)})},setCurrScene(r){return m(this,null,function*(){this.currScene=r,z(ue,this.currScene)})},setPreviewMode(r){this.previewScene=!!r,z(be,this.previewScene)},setActiveMenuTitle(r){this.activeMenuTitle=r||ye,z(Te,this.activeMenuTitle)},setPixelRatio(r){const e=Number.parseFloat(r);this.pixelRatio=Number.isFinite(e)&&e>0?e:Ce,z(Pe,this.pixelRatio)},setLogarithmicDepthBuffer(r){this.logarithmicDepthBuffer=!!r,z(xe,this.logarithmicDepthBuffer)},getSceneStorageKey(r){return`${r||this.sceneName}${qe}`},getSceneStorageParams(r,e=null){return V(this.getSceneStorageKey(r),e)},setSceneStorageParams(r,e){r&&z(this.getSceneStorageKey(r),e)},removeSceneStorageParams(r){r&&Ee(this.getSceneStorageKey(r))},resetTaskState(){return m(this,null,function*(){yield new Promise(r=>setTimeout(r,120)),this.taskState={busy:!1,type:"",title:"",message:"",description:"",progress:0}})},getAddonEditorJson(){return this.addonEditorJson=Re(V(de,this.addonEditorJson)),this.addonEditorJson},setAddonEditorJson(r){this.addonEditorJson=Re(r),z(de,this.addonEditorJson)},clearThreedStorage(){ur.forEach(e=>Ee(e)),Object.keys(window.localStorage).filter(e=>e.endsWith(qe)).forEach(e=>Ee(e));const r=We();this.currScene=r.currScene,this.sceneList=r.sceneList,this.previewScene=r.previewScene,this.activeMenuTitle=r.activeMenuTitle,this.pixelRatio=r.pixelRatio,this.logarithmicDepthBuffer=r.logarithmicDepthBuffer,this.addonEditorJson=r.addonEditorJson}}}),hr={backgroundBlurriness:0,backgroundIntensity:1,backgroundUrls:null,environmentEnabled:!1},mr={fov:50,near:.1,far:1e5,zoom:1,layers:{mask:1},filmOffset:0,filmGauge:35,position:{x:247.72931803058157,y:715.3890430349733,z:789.6794984861216}},fr={outputColorSpace:"srgb",toneMapping:0,toneMappingExposure:1,shadowMap:{enabled:!1,type:1},color:0,opacity:0,sortObjects:!0,localClippingEnabled:!1,autoClear:!0,autoClearColor:!0,renderListCompare:[{name:"stats",enabled:!0},{name:"controls",enabled:!0},{name:"scene",enabled:!0},{name:"css3DRender",enabled:!0},{name:"css2DRender",enabled:!0}]},pr={autoRotate:!1,autoRotateSpeed:2,enableDamping:!0,dampingFactor:.05,minDistance:.01,maxDistance:1e6,maxAzimuthAngle:null,minAzimuthAngle:null,maxPolarAngle:3.141592653589793,minPolarAngle:0,maxTargetRadius:null,minTargetRadius:0,enablePan:!0,panSpeed:1,enableRotate:!0,rotateSpeed:1,enableZoom:!0,zoomSpeed:1,zoomToCursor:!1,target:{x:-38.59603927643809,y:-48.97202695679889,z:-49.19814250541991}},_r={mode:"translate",space:"world",size:1,showX:!0,showY:!0,showZ:!0,translationSnap:null,rotationSnap:null,scaleSnap:null},Er={renderWay:"effectComposer",fxaaPass:{enabled:!0,order:60,multPixel:1},outlinePass:{enabled:!0,order:40,edgeStrength:3,edgeGlow:0,edgeThickness:1,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16449071,hiddenEdgeColor:16449071,overlayMaterial:{blending:5,blendEquation:100,blendSrc:201,blendDst:205}},outputPass:{enabled:!0,order:50},saoPass:{enabled:!1,order:10,saoBias:.5,saoIntensity:.01,saoScale:100,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},screenMaskPass:{enabled:!1,order:70,intensity:1,maskColor:16777215,R:.2,sr:1.2},ssrPass:{enabled:!1,order:30,maxDistance:.01,distanceAttenuation:!0,opacity:.5,thickness:.018,fresnel:!0,infiniteThick:!1,bouncing:!1},unrealBloomPass:{enabled:!1,order:20,strength:1.5,radius:.4,threshold:.85}},Ar={mode:"transform",openKeyEnable:!0,rightClickMenusEnable:!0,selectChildEnabled:!1,selectChildLevel:1,stats:{showStats:!1,statsMode:0},helpers:{axes:{showAxes:!0,axesLength:1e3},grid:{showGrid:!0,size:1e3,divisions:15,colorCenterLine:4473924,colorGrid:8947848},box3:{useBox3:!0,color:16776960}}},gr=[],wr=[],Sr=[],Ir=[],yr=[],Cr=[],Rr={},Dr=[],vr={viewAngleList:[],clipping:{size:20,clipList:[]}},xr={scene:hr,perspectiveCamera:mr,webglRenderer:fr,orbitControls:pr,transformControls:_r,effectComposer:Er,handler:Ar,lightCores:gr,innerCores:wr,modelCores:Sr,drawCores:Ir,textCores:yr,particleCores:Cr,geoCores:Rr,designCores:Dr,other:vr},yt=(r,e)=>{const t=r.__vccOpts||r;for(const[n,s]of e)t[n]=s;return t},Tr=Object.assign({name:"ThreedEditor"},{__name:"editor",props:{data:{type:Object,default:()=>({})},preview:{type:Boolean,default:!1}},emits:["emit-three-editor","graph-event"],setup(r,{expose:e,emit:t}){var P;const n=t,s=r,a=It(),{currScene:o}=De.storeToRefs(a),c=((P=window.meta.threed)==null?void 0:P.draco_path)||ct;O.ThreeEditor.dracoPath=c.endsWith("/")?c:`${c}/`;let l=null,h=null;const S=C.ref(null),{setGuiParams:N,getDevicePixelRatio:K,ensureThreeEditorDB:G,createBlobUrl:p,revokeModelObjectUrls:k,ensureThreedDesignRegistry:Y}=cr();Y(O.ThreeEditor),N({step:.1});const q=()=>{var I;return(I=l==null?void 0:l.renderSceneResize)==null?void 0:I.call(l)},_=()=>m(this,null,function*(){var y,b;let I=xr;try{if(s.data&&Object.keys(s.data).length)I=s.data;else if((y=o.value)!=null&&y.path){const R=yield B.getApi((b=o.value)==null?void 0:b.path).catch(()=>({}));console.log("初始化三维场景:",R),R.res&&(I=R.res)}l?l.resetEditorStorage(I):l=new O.ThreeEditor(S.value,{fps:null,pixelRatio:K()*a.pixelRatio,webglRenderParams:{antialias:!0,alpha:!0,logarithmicDepthBuffer:a.logarithmicDepthBuffer},sceneParams:yield E(I)})}catch(R){console.error("三维图纸初始化失败",R),l==null||l.resetEditorStorage(I)}finally{l&&setTimeout(()=>{s.preview&&(l.handler.mode="none",l.handler.helpers.axes.showAxes=!1,l.handler.helpers.box3.useBox3=!1,l.handler.helpers.grid.showGrid=!1)},200),T()}n("emit-three-editor",l),window.addEventListener("resize",q)}),E=I=>m(this,null,function*(){k(),I.designCores.forEach(L=>{L.preview=s.preview});const y=yield G(),b=y.list||[],R=structuredClone(I||{});return R.modelCores=(R.modelCores||[]).filter(L=>{const F=L.modelInfo.originPath;if(F){const W=b.find(j=>j.name===F);if(!W){const j=y.db.getRequest(F);L.modelInfo.url=j.url;return}const Q=p(W.blob);L.modelInfo.url=Q}return!0}),R}),T=()=>{l!=null&&l.renderer&&(h=new O.THREE.PMREMGenerator(l.renderer),h.compileEquirectangularShader(),l.scene.environment=h.fromScene(new Jt.RoomEnvironment).texture)},g=()=>l;return C.watch(()=>o.value.path,()=>m(this,null,function*(){_()})),C.watch(()=>s.data,()=>{_()},{deep:!0}),C.onMounted(()=>{_()}),C.onUnmounted(()=>{window.removeEventListener("resize",q),k(),l==null||l.destroySceneRender(),a.setCurrScene({name:"",path:""})}),e({getEditorInstance:g}),(I,y)=>(C.openBlock(),C.createElementBlock("div",{ref_key:"editorRef",ref:S,class:"threed-editor",onDragover:y[0]||(y[0]=C.withModifiers(()=>{},["prevent"])),onDrop:y[1]||(y[1]=C.withModifiers(()=>{},["prevent"]))},null,544))}}),Pr=yt(Tr,[["__scopeId","data-v-86a4ac97"]]),br={class:"threed-preview"},Lr=Object.assign({name:"ThreedPreview"},{__name:"preview",props:{data:{type:Object,default:null},url:{type:String,default:""},id:{type:String,default:""},token:{type:String,default:""},socketUrl:{type:String,default:""}},emits:["loaded","graph-event"],setup(r,{expose:e,emit:t}){const n=r,s=t;let a=C.shallowRef({});const o=C.ref(),c=It();let l={},h=null,S=null;const N=_=>{var T,g,P;if(!_)return;if((T=_==null?void 0:_.includes)!=null&&T.call(_,"token 必传"))return se({message:_,type:"warning"});const E=typeof _=="string"?JSON.parse(_):_;if((E==null?void 0:E.data)==="服务错误"||(P=(g=E==null?void 0:E.data)==null?void 0:g.includes)!=null&&P.call(g,"token is expired"))return se({message:E.data,type:"warning"});switch(E.action){case Ne.ACPOINT.YCVALUE:case Ne.ACPOINT.YXVALUE:console.warn("遥测信息");break}},K=()=>{try{S=new In({socketUrl:n.socketUrl,token:n.token,onMessage:N})}catch(_){console.warn("三维场景消息处理失败",_)}},G=()=>m(this,null,function*(){var _;if(l){const E=Object.keys(l);if(E.length){const T=yield B.postPDApi("querychannelstatus/",{data:E.map(g=>({ied_id:g,ln_list:l[g].map(P=>P.ln_id)}))});(_=T==null?void 0:T.data)!=null&&_.length&&E.forEach(g=>{const P=T.data.find(y=>y.ied_id===g),I=l[g];I!=null&&I.length&&I.forEach(y=>{const b=P.result.find(R=>R.ln_id===y.ln_id);if(b){const R=q();if(!(R!=null&&R.scene))return;const L=R.scene.getObjectsByProperty("dataId",y.guid);let F=L==null?void 0:L[0];if(F){const W=b.status==="告警"?2:b.status==="正常"?1:0;F.userData.params.state=W;const Q=Cn(b.amp_peak)?Rn(Number(b.amp_peak))?Number(b.amp_peak):0:b.amp_peak;F.userData.params.value=Q;debugger;F.changeState(W),F.changeValue(Q)}}})})}}}),p=_=>{s("graph-event",_)},k=_=>{_&&(n.socketUrl&&K(),setTimeout(()=>{const E=_.scene.getObjectsByProperty("designType","局放测点");E.forEach(T=>{const{ied_id:g,ln_id:P}=T.userData.params;l[g]||(l[g]=[]),l[g].push({guid:T.dataId,id:T.uuid,ied_id:g,ln_id:P})}),E!=null&&E.length&&(h&&clearInterval(h),G(),h=setInterval(()=>{G()},2e3)),s("loaded",_)},100))},Y=()=>m(this,null,function*(){if(a.value&&Object.keys(a.value).length)return;const _=Dn(),E=n.url||_.url;if(E){const P=yield B.getApi(E).catch(()=>({}));P.res&&(a.value=P.res);return}if(!(n.id||_.id)){console.warn("三维场景渲染失败,场景id为空!");return}const g=yield B.getCommonApi("threedfloorplan",{guid:n.id});g.data.length?c.setCurrScene(g.data[0]):console.warn("三维场景渲染失败,场景id为:"+n.id+"不存在!")}),q=()=>o.value?o.value.getEditorInstance():null;return C.watch(()=>n.data,_=>{a.value=_,Y()},{deep:!0,immediate:!0}),C.watch(()=>n.id,()=>{Y()},{deep:!0,immediate:!0}),C.onMounted(()=>{Ae.on("three-event",p)}),C.onUnmounted(()=>{S&&S.destroy(),Ae.off("three-event",p)}),e({getEditorInstance:q}),(_,E)=>(C.openBlock(),C.createElementBlock("div",br,[C.createVNode(Pr,{ref_key:"threedEditorRef",ref:o,data:C.unref(a),preview:"",onGraphEvent:p,onEmitThreeEditor:k},null,8,["data"])]))}}),ie=yt(Lr,[["__scopeId","data-v-1cef540a"]]);ie.name||(ie.name="SyThree");const Mr=r=>{r.component(ie.name||"SyThree",ie)},Or={install:Mr};exports.SyThree=ie;exports.default=Or;
53
+ `,key:"col",commonFinish:!0,render:"iTime+speed"}];let ne=null,U=null;const $e=r=>(r==null?void 0:r.name)||(r==null?void 0:r.label)||"",St=(r={})=>Object.values(r).filter(e=>e&&(e.label||e.name)),ir=St(tr),ar=St(nr),or=()=>({THREED_GUI_PARAMS:Ie,THREED_LOG_BUFFER:Nn,THREED_CURRSCENE:Bn,THREED_ACTIVE_MENU:Gn,THREED_PIXEL_RATIO:Kn,THREED_IMPORT_SIZE:qn,THREED_LIGHT_TYPES:Zn,THREED_EXPORT_BATCH:Et,THREED_RELOAD_DELAY:Wn,THREED_MODEL_DBNAME:le,THREED_MODEL_DBSTORE:we,THREED_SCENE_PREVIEW:zn,THREED_USER_DATA_KEYS:At,THREED_MODEL_LOAD_KEY:Se,THREED_PREVIEW_URL_KEY:re,THREED_ADDON_EDITOR_JSON:Vn,THREED_EXPORT_NODE_COUNT:jn,THREED_DEFAULT_SCENE_NAME:Xn,THREED_DEFAULT_ACTIVE_MENU:Yn,THREED_DEFAULT_PIXEL_RATIO:Qn,THREED_EXPORT_VERTEX_COUNT:Jn,THREED_SCENE_EXCLUDE_TYPES:er,THREED_EXPORT_EXCLUDE_TYPES:gt,THREED_EXPORT_RUNTIME_TYPES:wt,THREED_SCENE_STORAGE_SUFFIX:$n});function cr(){const{createInstance:r,dropInstance:e}=Fn(),t="/";let n=[];const s=i=>{let u=URL.createObjectURL(i);return n.push(u),u},a=()=>{n.forEach(i=>URL.revokeObjectURL(i)),n=[]},o=()=>m(this,null,function*(){return yield h(),{clearRequest:c,getAllRequest:k,getRequest:p,status:!0,message:"数据库打开成功",DATABASE:U}}),c=i=>m(this,null,function*(){if(!i)return{status:!1,message:"删除失败"};yield h(),yield U.removeItem(i);const u=yield G();return u.list=u.list.filter(d=>d.name!==i),{status:!0,message:"删除成功"}}),l=(...u)=>m(this,[...u],function*(i=le){U=null,ne=null,yield e({name:i,storeName:we})}),h=()=>m(this,null,function*(){return U||(ne||(ne=r({name:le,storeName:we}).then(i=>(U=i,i))),yield ne)}),S=i=>{if(!i)return!1;const u=String(i.message||"");return i.name==="DataError"||u.includes("in-line keys")},N=()=>m(this,null,function*(){U=null,ne=null,yield e({name:le}),yield h()});let K=null;const G=()=>m(this,null,function*(){return window.threeEditorDB?window.threeEditorDB:(K||(K=m(this,null,function*(){const i=yield o(),{data:u}=yield i.getAllRequest();return window.threeEditorDB={db:i,list:u},window.threeEditorDB})),yield K)}),p=i=>m(this,null,function*(){if(!i)return{status:!1,message:"获取失败"};yield h();const u=yield U.getItem(i);if(u!=null&&u.blob&&!i)return{status:!0,message:"获取成功",url:s(u.blob)};if(!i)return{status:!1,message:"获取失败"};const d=yield fetch(i).then(v=>v.blob()),f={blob:d};try{yield U.setItem(i,f)}catch(v){if(!S(v))throw v;yield N(),yield U.setItem(i,f)}const w=yield G(),H=M({name:i},f),D=w.list.findIndex(v=>v.name===i);return D>-1?w.list.splice(D,1,H):w.list.push(H),{status:!0,message:"文件缓存成功",url:s(d)}}),k=()=>m(this,null,function*(){yield h();const i=[];return U&&(yield U.iterate((u,d)=>{i.push(ae(M({},u||{}),{name:d}))})),window.threeEditorDB&&(window.threeEditorDB.list=i),{status:!0,message:"获取成功",data:i}}),Y=()=>m(this,null,function*(){var d;const{res:i}=yield B.getApi("/filehandle/scan",{path:lt.threeModelPath,extension:"glb,gltf"}),u=[];if(((d=i==null?void 0:i.children)==null?void 0:d.length)>0)for(const f of i.children)u.push({name:f.name,path:"/"+f.path});return u}),q=()=>window.GUI_PARAMS||Ie,_=()=>window.threeEditor||null,E=()=>window.editorJsons||[],T=()=>({width:window.innerWidth||0,height:window.innerHeight||0}),g=()=>ir,P=()=>rr||{},I=()=>window[re]||"",y=()=>ar,b=()=>window.devicePixelRatio||1,R=()=>window[re]||"",L=()=>{const i=g(),u=y();return{modelDesigns:i,componentDesigns:u,modelList:i.map(d=>d.label),componentList:u.map(d=>d.label)}},F=(i,u)=>{var d;return(d=i==null?void 0:i.__DESIGNS__)==null?void 0:d.find(f=>f.label===u)},W=(i=0)=>!Number.isFinite(i)||i<=0?"0 B":i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:i<1024*1024*1024?`${(i/1024/1024).toFixed(1)} MB`:`${(i/1024/1024/1024).toFixed(2)} GB`,Q=i=>{const u=window[Se];typeof u=="function"&&u(i)},j=i=>!!i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z),te=i=>{var u,d;return!i||!i.visible||(u=i.userData)!=null&&u.excludeFromExport||i.isTransformControls||i.isHelper||i.isLight||i.isPoints||(d=i.type)!=null&&d.includes("Helper")||gt.has(i.type)||wt.has(i.type)||i.isCSS2DObject||i.isCSS3DObject?!1:i.isMesh||i.isGroup||i.isObject3D||i.isLine},me=(i,u)=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)?i:u,Ct=i=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)&&Number.isFinite(i.w)?i:{x:0,y:0,z:0,w:1},Le=i=>{if(!(i!=null&&i.isObject3D))return;const u=me(i.position,{x:0,y:0,z:0});i.position.set(u.x,u.y,u.z);const d=me(i.scale,{x:1,y:1,z:1});i.scale.set(d.x===0?1:d.x,d.y===0?1:d.y,d.z===0?1:d.z);const f=me(i.up,{x:0,y:1,z:0});i.up.set(f.x,f.y,f.z);const w=Ct(i.quaternion);i.quaternion.set(w.x,w.y,w.z,w.w),i.pivot&&!j(i.pivot)&&delete i.pivot,i.updateMatrix(),i.updateMatrixWorld(!1)},Rt=(i,u="_blank")=>window.open(i,u),Dt=(i,u="")=>window.prompt(i,u),vt=()=>window.location.reload(),xt=()=>document.documentElement.classList.remove("dark"),Tt=i=>{if(!Array.isArray(i==null?void 0:i.__DESIGNS__))return L();const u=[...g(),...y()],d=new Set(i.__DESIGNS__.map(f=>$e(f)));return u.forEach(f=>{const w=$e(f);!w||d.has(w)||(d.add(w),i.__DESIGNS__.unshift(f))}),L()},Pt=i=>{if(!Array.isArray(i==null?void 0:i.__GLSLLIB__))return;const u=new Set(i.__GLSLLIB__.map(d=>d==null?void 0:d.name));sr.forEach(d=>{u.has(d.name)||(u.add(d.name),i.__GLSLLIB__.push(d))})},fe=(i={})=>{const u={};return Object.entries(i||{}).forEach(([d,f])=>{if(!(At.has(d)||typeof f=="function")){if(!f||["string","number","boolean"].includes(typeof f)){u[d]=f;return}if(Array.isArray(f)){try{u[d]=structuredClone(f)}catch(w){return}return}if(!(f.isObject3D||f.isMaterial||f.isTexture||f.nodeType))try{u[d]=structuredClone(f)}catch(w){return}}}),u},bt=(i=Ie)=>{window.GUI_PARAMS=i},Lt=i=>{window.threeEditor=i},Mt=i=>{window.threeEditorDB=i},Ot=i=>{window[Se]=i},Ht=(i="")=>{window[re]=i},Ut=(i="")=>{window[re]=i},Me=i=>{var d;const u=[];return(d=i==null?void 0:i.children)==null||d.forEach(f=>{te(f)&&u.push(f)}),u},Oe=(i=[])=>{const u={rootCount:i.length,nodeCount:0,meshCount:0,vertexCount:0,skippedCount:0};return i.forEach(d=>{d.traverse(f=>{var w,H,D;if(te(f)){u.nodeCount+=1,f.isMesh&&(u.meshCount+=1,u.vertexCount+=((D=(H=(w=f.geometry)==null?void 0:w.attributes)==null?void 0:H.position)==null?void 0:D.count)||0);return}f!==d&&(u.skippedCount+=1)})}),u},He=()=>new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0))),Ue=()=>new Promise(i=>{if(typeof window.requestIdleCallback=="function"){window.requestIdleCallback(()=>i(),{timeout:80});return}setTimeout(i,0)}),kt=(i,u)=>m(this,null,function*(){var w;if(!te(i))return null;const d=i.clone(!1);d.userData=fe(i.userData),j(i.pivot)?d.pivot=new O.THREE.Vector3(i.pivot.x,i.pivot.y,i.pivot.z):"pivot"in d&&delete d.pivot,Le(d);const f=[{source:i,clone:d}];for(;f.length;){const H=f.shift();for(const D of H.source.children){if(!te(D)){u.skippedCount+=1;continue}const v=D.clone(!1);v.userData=fe(D.userData),j(D.pivot)?v.pivot=new O.THREE.Vector3(D.pivot.x,D.pivot.y,D.pivot.z):"pivot"in v&&delete v.pivot,Le(v),H.clone.add(v),f.push({source:D,clone:v}),u.processedCount+=1,u.processedCount%Et===0&&(yield(w=u.onProgress)==null?void 0:w.call(u,{processedCount:u.processedCount,totalCount:u.totalCount,skippedCount:u.skippedCount,progress:18+Math.min(u.processedCount/Math.max(u.totalCount,1)*54,54)}),yield He())}}return d});return{baseUrl:t,getModels:Y,getRequest:p,reloadPage:vt,promptInput:Dt,waitForIdle:Ue,waitForPaint:He,clearRequest:c,getGuiParams:q,setGuiParams:bt,getAllRequest:k,getEditorJsons:E,getThreeEditor:_,formatFileSize:W,setThreeEditor:Lt,removeDarkClass:xt,openExternalUrl:Rt,getThreedModels:g,getViewportSize:T,buildExportScene:(d,...f)=>m(this,[d,...f],function*(i,u={}){const w=Me(i),H=Oe(w),D=new O.THREE.Scene,v={totalCount:H.nodeCount,processedCount:0,skippedCount:0,onProgress:u.onProgress};for(const Ft of w){const ke=yield kt(Ft,v);ke&&D.add(ke),yield Ue()}return D.updateMatrixWorld(!0),H.skippedCount+=v.skippedCount,{exportScene:D,exportObjects:w,stats:H}}),createModelDbApi:o,getEditorPreviewSceneUrl:R,sanitizeUserData:fe,setThreeEditorDB:Mt,findThreedDesign:F,getThreedLightMap:P,collectExportStats:Oe,getPreviewSceneUrl:I,setEditorPreviewSceneUrl:Ut,setPreviewSceneUrl:Ht,setModelLoadHander:Ot,isExportableObject:te,deleteThreeEditorDB:l,ensureThreeEditorDB:G,getDevicePixelRatio:b,getThreedComponents:y,collectExportObjects:Me,resetModelDbInstance:N,ensureModelDbInstance:h,getLocalDesignMenuData:L,invokeModelLoadHandler:Q,isLegacyInlineKeyError:S,ensureThreedShaderLibrary:Pt,ensureThreedDesignRegistry:Tt,createBlobUrl:s,revokeModelObjectUrls:a}}const{THREED_LOG_BUFFER:xe,THREED_CURRSCENE:ue,THREED_ACTIVE_MENU:Te,THREED_PIXEL_RATIO:Pe,THREED_SCENE_PREVIEW:be,THREED_ADDON_EDITOR_JSON:de,THREED_DEFAULT_SCENE_NAME:lr,THREED_DEFAULT_ACTIVE_MENU:ye,THREED_DEFAULT_PIXEL_RATIO:Ce,THREED_SCENE_STORAGE_SUFFIX:qe}=or(),ur=[xe,ue,Te,Pe,be,de],V=(r,e)=>{const t=ve.getLocal(r);return t==null?e:t},z=(r,e)=>{r&&ve.setLocal(r,e)},Ee=r=>{r&&ve.removeLocal(r)},dr=(r,e)=>{var n,s;const t=(n=r==null?void 0:r.trim)==null?void 0:n.call(r);return t&&e.some(a=>a.name===t)?t:((s=e[0])==null?void 0:s.name)||lr},Re=(r=[])=>Array.isArray(r)?r.filter(e=>typeof e=="string"&&e):[],We=()=>{const r=[],e=V(ue,{name:"",path:""}),t=Number.parseFloat(V(Pe,Ce));return{taskState:{busy:!1,type:"",title:"",message:"",description:"",progress:0},currScene:e,sceneList:r,previewScene:!!V(be,!1),activeMenuTitle:V(Te,ye)||ye,pixelRatio:Number.isFinite(t)&&t>0?t:Ce,logarithmicDepthBuffer:V(xe,!0)!==!1,addonEditorJson:Re(V(de,[]))}},It=De.defineStore("threed",{state:()=>We(),actions:{getSceneList(){return m(this,null,function*(){var e;const r=yield B.getCommonApi("threedfloorplan",{limit:1e4,ordering:"-create_time"});(e=r==null?void 0:r.data)!=null&&e.length?(this.sceneList=r.data,this.currScene.path?this.sceneList.find(n=>n.id===this.currScene.id)||this.setCurrScene({name:"",path:""}):this.setCurrScene(this.sceneList[0])):(this.sceneList=[],this.setCurrScene({name:"",path:""}))})},setSceneList(r){this.sceneList=r},setSceneName(r){this.sceneName=dr(r,this.sceneList),z(ue,this.sceneName)},createScene(r,e=""){return m(this,null,function*(){var c,l;const t=(c=r==null?void 0:r.trim)==null?void 0:c.call(r);if(!t||this.sceneList.some(h=>h.name===t))return!1;const n=lt.threeSavePath+"/"+ge()+".json",s=ge();if(!(yield B.postCommonApi("query/threedfloorplan/create",{data:[{name:t,path:n,guid:s}]})).success)return!1;if(yield On(n,e)){const h=yield B.postCommonApi("threedfloorplan",{guid:s});if((l=h==null?void 0:h.data)!=null&&l.length)return this.sceneList=[...this.sceneList,h.data[0]],h.data[0]}return!0})},deleteScene(r){return m(this,null,function*(){var n;if(!r)return;if(!(yield B.postCommonApi("query/threedfloorplan/delete",{data:[r]})).success)return!1;const t=this.sceneList.findIndex(s=>s.id===r);return t===-1?!1:(this.sceneList.splice(t,1),((n=this.currScene)==null?void 0:n.id)===r&&this.setCurrScene(this.sceneList[0]||{name:"",path:""}),!0)})},setCurrScene(r){return m(this,null,function*(){this.currScene=r,z(ue,this.currScene)})},setPreviewMode(r){this.previewScene=!!r,z(be,this.previewScene)},setActiveMenuTitle(r){this.activeMenuTitle=r||ye,z(Te,this.activeMenuTitle)},setPixelRatio(r){const e=Number.parseFloat(r);this.pixelRatio=Number.isFinite(e)&&e>0?e:Ce,z(Pe,this.pixelRatio)},setLogarithmicDepthBuffer(r){this.logarithmicDepthBuffer=!!r,z(xe,this.logarithmicDepthBuffer)},getSceneStorageKey(r){return`${r||this.sceneName}${qe}`},getSceneStorageParams(r,e=null){return V(this.getSceneStorageKey(r),e)},setSceneStorageParams(r,e){r&&z(this.getSceneStorageKey(r),e)},removeSceneStorageParams(r){r&&Ee(this.getSceneStorageKey(r))},resetTaskState(){return m(this,null,function*(){yield new Promise(r=>setTimeout(r,120)),this.taskState={busy:!1,type:"",title:"",message:"",description:"",progress:0}})},getAddonEditorJson(){return this.addonEditorJson=Re(V(de,this.addonEditorJson)),this.addonEditorJson},setAddonEditorJson(r){this.addonEditorJson=Re(r),z(de,this.addonEditorJson)},clearThreedStorage(){ur.forEach(e=>Ee(e)),Object.keys(window.localStorage).filter(e=>e.endsWith(qe)).forEach(e=>Ee(e));const r=We();this.currScene=r.currScene,this.sceneList=r.sceneList,this.previewScene=r.previewScene,this.activeMenuTitle=r.activeMenuTitle,this.pixelRatio=r.pixelRatio,this.logarithmicDepthBuffer=r.logarithmicDepthBuffer,this.addonEditorJson=r.addonEditorJson}}}),hr={backgroundBlurriness:0,backgroundIntensity:1,backgroundUrls:null,environmentEnabled:!1},mr={fov:50,near:.1,far:1e5,zoom:1,layers:{mask:1},filmOffset:0,filmGauge:35,position:{x:247.72931803058157,y:715.3890430349733,z:789.6794984861216}},fr={outputColorSpace:"srgb",toneMapping:0,toneMappingExposure:1,shadowMap:{enabled:!1,type:1},color:0,opacity:0,sortObjects:!0,localClippingEnabled:!1,autoClear:!0,autoClearColor:!0,renderListCompare:[{name:"stats",enabled:!0},{name:"controls",enabled:!0},{name:"scene",enabled:!0},{name:"css3DRender",enabled:!0},{name:"css2DRender",enabled:!0}]},pr={autoRotate:!1,autoRotateSpeed:2,enableDamping:!0,dampingFactor:.05,minDistance:.01,maxDistance:1e6,maxAzimuthAngle:null,minAzimuthAngle:null,maxPolarAngle:3.141592653589793,minPolarAngle:0,maxTargetRadius:null,minTargetRadius:0,enablePan:!0,panSpeed:1,enableRotate:!0,rotateSpeed:1,enableZoom:!0,zoomSpeed:1,zoomToCursor:!1,target:{x:-38.59603927643809,y:-48.97202695679889,z:-49.19814250541991}},_r={mode:"translate",space:"world",size:1,showX:!0,showY:!0,showZ:!0,translationSnap:null,rotationSnap:null,scaleSnap:null},Er={renderWay:"effectComposer",fxaaPass:{enabled:!0,order:60,multPixel:1},outlinePass:{enabled:!0,order:40,edgeStrength:3,edgeGlow:0,edgeThickness:1,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16449071,hiddenEdgeColor:16449071,overlayMaterial:{blending:5,blendEquation:100,blendSrc:201,blendDst:205}},outputPass:{enabled:!0,order:50},saoPass:{enabled:!1,order:10,saoBias:.5,saoIntensity:.01,saoScale:100,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},screenMaskPass:{enabled:!1,order:70,intensity:1,maskColor:16777215,R:.2,sr:1.2},ssrPass:{enabled:!1,order:30,maxDistance:.01,distanceAttenuation:!0,opacity:.5,thickness:.018,fresnel:!0,infiniteThick:!1,bouncing:!1},unrealBloomPass:{enabled:!1,order:20,strength:1.5,radius:.4,threshold:.85}},Ar={mode:"transform",openKeyEnable:!0,rightClickMenusEnable:!0,selectChildEnabled:!1,selectChildLevel:1,stats:{showStats:!1,statsMode:0},helpers:{axes:{showAxes:!0,axesLength:1e3},grid:{showGrid:!0,size:1e3,divisions:15,colorCenterLine:4473924,colorGrid:8947848},box3:{useBox3:!0,color:16776960}}},gr=[],wr=[],Sr=[],Ir=[],yr=[],Cr=[],Rr={},Dr=[],vr={viewAngleList:[],clipping:{size:20,clipList:[]}},xr={scene:hr,perspectiveCamera:mr,webglRenderer:fr,orbitControls:pr,transformControls:_r,effectComposer:Er,handler:Ar,lightCores:gr,innerCores:wr,modelCores:Sr,drawCores:Ir,textCores:yr,particleCores:Cr,geoCores:Rr,designCores:Dr,other:vr},yt=(r,e)=>{const t=r.__vccOpts||r;for(const[n,s]of e)t[n]=s;return t},Tr=Object.assign({name:"ThreedEditor"},{__name:"editor",props:{data:{type:Object,default:()=>({})},preview:{type:Boolean,default:!1}},emits:["emit-three-editor","graph-event"],setup(r,{expose:e,emit:t}){var P;const n=t,s=r,a=It(),{currScene:o}=De.storeToRefs(a),c=((P=window.meta.threed)==null?void 0:P.draco_path)||ct;O.ThreeEditor.dracoPath=c.endsWith("/")?c:`${c}/`;let l=null,h=null;const S=C.ref(null),{setGuiParams:N,getDevicePixelRatio:K,ensureThreeEditorDB:G,createBlobUrl:p,revokeModelObjectUrls:k,ensureThreedDesignRegistry:Y}=cr();Y(O.ThreeEditor),N({step:.1});const q=()=>{var I;return(I=l==null?void 0:l.renderSceneResize)==null?void 0:I.call(l)},_=()=>m(this,null,function*(){var y,b;let I=xr;try{if(s.data&&Object.keys(s.data).length)I=s.data;else if((y=o.value)!=null&&y.path){const R=yield B.getApi((b=o.value)==null?void 0:b.path).catch(()=>({}));console.log("初始化三维场景:",R),R.res&&(I=R.res)}l?l.resetEditorStorage(I):l=new O.ThreeEditor(S.value,{fps:null,pixelRatio:K()*a.pixelRatio,webglRenderParams:{antialias:!0,alpha:!0,logarithmicDepthBuffer:a.logarithmicDepthBuffer},sceneParams:yield E(I)})}catch(R){console.error("三维图纸初始化失败",R),l==null||l.resetEditorStorage(I)}finally{l&&setTimeout(()=>{s.preview&&(l.handler.mode="none",l.handler.helpers.axes.showAxes=!1,l.handler.helpers.box3.useBox3=!1,l.handler.helpers.grid.showGrid=!1)},200),T()}n("emit-three-editor",l),window.addEventListener("resize",q)}),E=I=>m(this,null,function*(){k(),I.designCores.forEach(L=>{L.preview=s.preview});const y=yield G(),b=y.list||[],R=structuredClone(I||{});return R.modelCores=(R.modelCores||[]).filter(L=>{const F=L.modelInfo.originPath;if(F){const W=b.find(j=>j.name===F);if(!W){const j=y.db.getRequest(F);L.modelInfo.url=j.url;return}const Q=p(W.blob);L.modelInfo.url=Q}return!0}),R}),T=()=>{l!=null&&l.renderer&&(h=new O.THREE.PMREMGenerator(l.renderer),h.compileEquirectangularShader(),l.scene.environment=h.fromScene(new Jt.RoomEnvironment).texture)},g=()=>l;return C.watch(()=>o.value.path,()=>m(this,null,function*(){_()})),C.watch(()=>s.data,()=>{_()},{deep:!0}),C.onMounted(()=>{_()}),C.onUnmounted(()=>{window.removeEventListener("resize",q),k(),l==null||l.destroySceneRender(),a.setCurrScene({name:"",path:""})}),e({getEditorInstance:g}),(I,y)=>(C.openBlock(),C.createElementBlock("div",{ref_key:"editorRef",ref:S,class:"threed-editor",onDragover:y[0]||(y[0]=C.withModifiers(()=>{},["prevent"])),onDrop:y[1]||(y[1]=C.withModifiers(()=>{},["prevent"]))},null,544))}}),Pr=yt(Tr,[["__scopeId","data-v-86a4ac97"]]),br={class:"threed-preview"},Lr=Object.assign({name:"ThreedPreview"},{__name:"preview",props:{data:{type:Object,default:null},url:{type:String,default:""},id:{type:String,default:""},token:{type:String,default:""},socketUrl:{type:String,default:""}},emits:["loaded","graph-event"],setup(r,{expose:e,emit:t}){const n=r,s=t;let a=C.shallowRef({});const o=C.ref(),c=It();let l={},h=null,S=null;const N=_=>{var T,g,P;if(!_)return;if((T=_==null?void 0:_.includes)!=null&&T.call(_,"token 必传"))return se({message:_,type:"warning"});const E=typeof _=="string"?JSON.parse(_):_;if((E==null?void 0:E.data)==="服务错误"||(P=(g=E==null?void 0:E.data)==null?void 0:g.includes)!=null&&P.call(g,"token is expired"))return se({message:E.data,type:"warning"});switch(E.action){case Ne.ACPOINT.YCVALUE:case Ne.ACPOINT.YXVALUE:console.warn("遥测信息");break}},K=()=>{try{S=new In({socketUrl:n.socketUrl,token:n.token,onMessage:N})}catch(_){console.warn("三维场景消息处理失败",_)}},G=()=>m(this,null,function*(){var _;if(l){const E=Object.keys(l);if(E.length){const T=yield B.postPDApi("querychannelstatus/",{data:E.map(g=>({ied_id:g,ln_list:l[g].map(P=>P.ln_id)}))});(_=T==null?void 0:T.data)!=null&&_.length&&E.forEach(g=>{const P=T.data.find(y=>y.ied_id===g),I=l[g];I!=null&&I.length&&I.forEach(y=>{const b=P.result.find(R=>R.ln_id===y.ln_id);if(b){const R=q();if(!(R!=null&&R.scene))return;const L=R.scene.getObjectsByProperty("dataId",y.guid);let F=L==null?void 0:L[0];if(F){const W=b.status==="告警"?2:b.status==="正常"?1:0;F.userData.params.state=W;const Q=Cn(b.amp_peak)?Rn(Number(b.amp_peak))?Number(b.amp_peak):0:b.amp_peak;F.userData.params.value=Q;debugger;F.changeState(W),F.changeValue(Q)}}})})}}}),p=_=>{s("graph-event",_)},k=_=>{_&&(n.socketUrl&&K(),setTimeout(()=>{const E=_.scene.getObjectsByProperty("designType","局放测点");E.forEach(T=>{const{ied_id:g,ln_id:P}=T.userData.params;l[g]||(l[g]=[]),l[g].push({guid:T.dataId,id:T.uuid,ied_id:g,ln_id:P})}),E!=null&&E.length&&(h&&clearInterval(h),G(),h=setInterval(()=>{G()},2e3)),s("loaded",_)},100))},Y=()=>m(this,null,function*(){if(a.value&&Object.keys(a.value).length)return;const _=Dn(),E=n.url||_.url;if(E){const P=yield B.getApi(E).catch(()=>({}));P.res&&(a.value=P.res);return}if(!(n.id||_.id)){console.warn("三维场景渲染失败,场景id为空!");return}const g=yield B.getCommonApi("threedfloorplan",{guid:n.id});g.data.length?c.setCurrScene(g.data[0]):console.warn("三维场景渲染失败,场景id为:"+n.id+"不存在!")}),q=()=>o.value?o.value.getEditorInstance():null;return C.watch(()=>n.data,_=>{a.value=_,Y()},{deep:!0,immediate:!0}),C.watch(()=>n.id,()=>{Y()},{deep:!0,immediate:!0}),C.onMounted(()=>{Ae.on("three-event",p)}),C.onUnmounted(()=>{S&&S.destroy(),h&&clearInterval(h),Ae.off("three-event",p)}),e({getEditorInstance:q}),(_,E)=>(C.openBlock(),C.createElementBlock("div",br,[C.createVNode(Pr,{ref_key:"threedEditorRef",ref:o,data:C.unref(a),preview:"",onGraphEvent:p,onEmitThreeEditor:k},null,8,["data"])]))}}),ie=yt(Lr,[["__scopeId","data-v-5a321d2f"]]);ie.name||(ie.name="SyThree");const Mr=r=>{r.component(ie.name||"SyThree",ie)},Or={install:Mr};exports.SyThree=ie;exports.default=Or;
@@ -1 +1 @@
1
- @charset "UTF-8";.threed-editor[data-v-86a4ac97]{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--sc-bg-color)}.threed-editor[data-v-86a4ac97] .top-info{z-index:9999!important}.threed-preview[data-v-1cef540a]{width:100%;height:100%}
1
+ @charset "UTF-8";.threed-editor[data-v-86a4ac97]{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--sc-bg-color)}.threed-editor[data-v-86a4ac97] .top-info{z-index:9999!important}.threed-preview[data-v-5a321d2f]{width:100%;height:100%}
@@ -2332,7 +2332,7 @@ const {
2332
2332
  ), lt(() => {
2333
2333
  ge.on("three-event", p);
2334
2334
  }), ut(() => {
2335
- I && I.destroy(), ge.off("three-event", p);
2335
+ I && I.destroy(), h && clearInterval(h), ge.off("three-event", p);
2336
2336
  }), e({
2337
2337
  getEditorInstance: $
2338
2338
  }), (_, E) => (dt(), ht("div", Vr, [
@@ -2346,7 +2346,7 @@ const {
2346
2346
  }, null, 8, ["data"])
2347
2347
  ]));
2348
2348
  }
2349
- }), de = /* @__PURE__ */ Tt($r, [["__scopeId", "data-v-1cef540a"]]);
2349
+ }), de = /* @__PURE__ */ Tt($r, [["__scopeId", "data-v-5a321d2f"]]);
2350
2350
  de.name || (de.name = "SyThree");
2351
2351
  const Wr = (r) => {
2352
2352
  r.component(de.name || "SyThree", de);
@@ -1,4 +1,4 @@
1
- (function(_,m){typeof exports=="object"&&typeof module!="undefined"?m(exports,require("vue"),require("qs"),require("axios"),require("mitt"),require("dayjs"),require("lodash-es"),require("crypto-js"),require("gm-crypto"),require("element-plus"),require("@element-plus/icons-vue"),require("pinia"),require("three/examples/jsm/renderers/CSS2DRenderer.js"),require("three-edit-cores"),require("localforage"),require("three/addons/environments/RoomEnvironment.js")):typeof define=="function"&&define.amd?define(["exports","vue","qs","axios","mitt","dayjs","lodash-es","crypto-js","gm-crypto","element-plus","@element-plus/icons-vue","pinia","three/examples/jsm/renderers/CSS2DRenderer.js","three-edit-cores","localforage","three/addons/environments/RoomEnvironment.js"],m):(_=typeof globalThis!="undefined"?globalThis:_||self,m(_.SyThree={},_.Vue,_.qs,_.axios,_.mitt,null,_._,null,_.gmCrypto,_.ElementPlus,_.ElementPlusIconsVue,_.Pinia,_.CSS2DRenderer_js,_.ThreeEditCores,_.localforage,_.RoomEnvironment_js))})(this,function(_,m,C,Ee,ce,Fe,Ae,le,M,F,gr,ge,Lt,U,T,Mt){"use strict";var fr=Object.defineProperty,pr=Object.defineProperties;var _r=Object.getOwnPropertyDescriptors;var bt=Object.getOwnPropertySymbols;var Er=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var ke=(_,m,C)=>m in _?fr(_,m,{enumerable:!0,configurable:!0,writable:!0,value:C}):_[m]=C,k=(_,m)=>{for(var C in m||(m={}))Er.call(m,C)&&ke(_,C,m[C]);if(bt)for(var C of bt(m))Ar.call(m,C)&&ke(_,C,m[C]);return _},_e=(_,m)=>pr(_,_r(m));var Q=(_,m,C)=>ke(_,typeof m!="symbol"?m+"":m,C);var f=(_,m,C)=>new Promise((Ee,ce)=>{var Fe=M=>{try{le(C.next(M))}catch(F){ce(F)}},Ae=M=>{try{le(C.throw(M))}catch(F){ce(F)}},le=M=>M.done?Ee(M.value):Promise.resolve(M.value).then(Fe,Ae);le((C=C.apply(_,m)).next())});var ht,mt,ft,pt,_t,Et,At,gt,wt,St,It,yt,Ct;var Ne=document.createElement("style");Ne.textContent=`@charset "UTF-8";.threed-editor[data-v-86a4ac97]{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--sc-bg-color)}.threed-editor[data-v-86a4ac97] .top-info{z-index:9999!important}.threed-preview[data-v-1cef540a]{width:100%;height:100%}
1
+ (function(_,m){typeof exports=="object"&&typeof module!="undefined"?m(exports,require("vue"),require("qs"),require("axios"),require("mitt"),require("dayjs"),require("lodash-es"),require("crypto-js"),require("gm-crypto"),require("element-plus"),require("@element-plus/icons-vue"),require("pinia"),require("three/examples/jsm/renderers/CSS2DRenderer.js"),require("three-edit-cores"),require("localforage"),require("three/addons/environments/RoomEnvironment.js")):typeof define=="function"&&define.amd?define(["exports","vue","qs","axios","mitt","dayjs","lodash-es","crypto-js","gm-crypto","element-plus","@element-plus/icons-vue","pinia","three/examples/jsm/renderers/CSS2DRenderer.js","three-edit-cores","localforage","three/addons/environments/RoomEnvironment.js"],m):(_=typeof globalThis!="undefined"?globalThis:_||self,m(_.SyThree={},_.Vue,_.qs,_.axios,_.mitt,null,_._,null,_.gmCrypto,_.ElementPlus,_.ElementPlusIconsVue,_.Pinia,_.CSS2DRenderer_js,_.ThreeEditCores,_.localforage,_.RoomEnvironment_js))})(this,function(_,m,C,Ee,ce,Fe,Ae,le,M,F,gr,ge,Lt,U,T,Mt){"use strict";var fr=Object.defineProperty,pr=Object.defineProperties;var _r=Object.getOwnPropertyDescriptors;var bt=Object.getOwnPropertySymbols;var Er=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var ke=(_,m,C)=>m in _?fr(_,m,{enumerable:!0,configurable:!0,writable:!0,value:C}):_[m]=C,k=(_,m)=>{for(var C in m||(m={}))Er.call(m,C)&&ke(_,C,m[C]);if(bt)for(var C of bt(m))Ar.call(m,C)&&ke(_,C,m[C]);return _},_e=(_,m)=>pr(_,_r(m));var Q=(_,m,C)=>ke(_,typeof m!="symbol"?m+"":m,C);var f=(_,m,C)=>new Promise((Ee,ce)=>{var Fe=M=>{try{le(C.next(M))}catch(F){ce(F)}},Ae=M=>{try{le(C.throw(M))}catch(F){ce(F)}},le=M=>M.done?Ee(M.value):Promise.resolve(M.value).then(Fe,Ae);le((C=C.apply(_,m)).next())});var ht,mt,ft,pt,_t,Et,At,gt,wt,St,It,yt,Ct;var Ne=document.createElement("style");Ne.textContent=`@charset "UTF-8";.threed-editor[data-v-86a4ac97]{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--sc-bg-color)}.threed-editor[data-v-86a4ac97] .top-info{z-index:9999!important}.threed-preview[data-v-5a321d2f]{width:100%;height:100%}
2
2
  /*$vite$:1*/`,document.head.appendChild(Ne);const ue={NONE:"none",WUJIE:"wujie",QIANKUN:"qiankun",MICROAPP:"microapp"},Be={ACPOINT:{YCVALUE:"status.platform.ycvalue",YXVALUE:"status.platform.yxvalue"}};var de={};/*!
3
3
  * vite-plugin-qiankun.js v1.0.14
4
4
  * (c) 2021-2022 Teng Mao Qing
@@ -51,4 +51,4 @@
51
51
  uv *= 2.0 * ( cos(iTime * 2.0) -2.5);
52
52
  float anim = sin(iTime * 12.0) * 0.1 + 1.0;
53
53
  vec3 col = cheap_star(uv, anim) * vec3(0.35,0.2,0.15);
54
- `,key:"col",commonFinish:!0,render:"iTime+speed"}];let ie=null,N=null;const at=r=>(r==null?void 0:r.name)||(r==null?void 0:r.label)||"",ot=(r={})=>Object.values(r).filter(e=>e&&(e.label||e.name)),Kn=ot(Fn),Vn=ot(Nn),zn=()=>({THREED_GUI_PARAMS:De,THREED_LOG_BUFFER:In,THREED_CURRSCENE:yn,THREED_ACTIVE_MENU:Cn,THREED_PIXEL_RATIO:Rn,THREED_IMPORT_SIZE:Tn,THREED_LIGHT_TYPES:Hn,THREED_EXPORT_BATCH:nt,THREED_RELOAD_DELAY:Pn,THREED_MODEL_DBNAME:me,THREED_MODEL_DBSTORE:Ce,THREED_SCENE_PREVIEW:Dn,THREED_USER_DATA_KEYS:rt,THREED_MODEL_LOAD_KEY:Re,THREED_PREVIEW_URL_KEY:se,THREED_ADDON_EDITOR_JSON:xn,THREED_EXPORT_NODE_COUNT:bn,THREED_DEFAULT_SCENE_NAME:Mn,THREED_DEFAULT_ACTIVE_MENU:On,THREED_DEFAULT_PIXEL_RATIO:Un,THREED_EXPORT_VERTEX_COUNT:Ln,THREED_SCENE_EXCLUDE_TYPES:kn,THREED_EXPORT_EXCLUDE_TYPES:st,THREED_EXPORT_RUNTIME_TYPES:it,THREED_SCENE_STORAGE_SUFFIX:vn});function $n(){const{createInstance:r,dropInstance:e}=Sn(),t="/";let n=[];const s=i=>{let l=URL.createObjectURL(i);return n.push(l),l},a=()=>{n.forEach(i=>URL.revokeObjectURL(i)),n=[]},o=()=>f(this,null,function*(){return yield h(),{clearRequest:c,getAllRequest:G,getRequest:E,status:!0,message:"数据库打开成功",DATABASE:N}}),c=i=>f(this,null,function*(){if(!i)return{status:!1,message:"删除失败"};yield h(),yield N.removeItem(i);const l=yield $();return l.list=l.list.filter(d=>d.name!==i),{status:!0,message:"删除成功"}}),u=(...l)=>f(this,[...l],function*(i=me){N=null,ie=null,yield e({name:i,storeName:Ce})}),h=()=>f(this,null,function*(){return N||(ie||(ie=r({name:me,storeName:Ce}).then(i=>(N=i,i))),yield ie)}),y=i=>{if(!i)return!1;const l=String(i.message||"");return i.name==="DataError"||l.includes("in-line keys")},z=()=>f(this,null,function*(){N=null,ie=null,yield e({name:me}),yield h()});let W=null;const $=()=>f(this,null,function*(){return window.threeEditorDB?window.threeEditorDB:(W||(W=f(this,null,function*(){const i=yield o(),{data:l}=yield i.getAllRequest();return window.threeEditorDB={db:i,list:l},window.threeEditorDB})),yield W)}),E=i=>f(this,null,function*(){if(!i)return{status:!1,message:"获取失败"};yield h();const l=yield N.getItem(i);if(l!=null&&l.blob&&!i)return{status:!0,message:"获取成功",url:s(l.blob)};if(!i)return{status:!1,message:"获取失败"};const d=yield fetch(i).then(P=>P.blob()),p={blob:d};try{yield N.setItem(i,p)}catch(P){if(!y(P))throw P;yield z(),yield N.setItem(i,p)}const I=yield $(),B=k({name:i},p),v=I.list.findIndex(P=>P.name===i);return v>-1?I.list.splice(v,1,B):I.list.push(B),{status:!0,message:"文件缓存成功",url:s(d)}}),G=()=>f(this,null,function*(){yield h();const i=[];return N&&(yield N.iterate((l,d)=>{i.push(_e(k({},l||{}),{name:d}))})),window.threeEditorDB&&(window.threeEditorDB.list=i),{status:!0,message:"获取成功",data:i}}),te=()=>f(this,null,function*(){var d;const{res:i}=yield V.getApi("/filehandle/scan",{path:Ve.threeModelPath,extension:"glb,gltf"}),l=[];if(((d=i==null?void 0:i.children)==null?void 0:d.length)>0)for(const p of i.children)l.push({name:p.name,path:"/"+p.path});return l}),J=()=>window.GUI_PARAMS||De,A=()=>window.threeEditor||null,w=()=>window.editorJsons||[],b=()=>({width:window.innerWidth||0,height:window.innerHeight||0}),S=()=>Kn,L=()=>Bn||{},R=()=>window[se]||"",D=()=>Vn,O=()=>window.devicePixelRatio||1,x=()=>window[se]||"",H=()=>{const i=S(),l=D();return{modelDesigns:i,componentDesigns:l,modelList:i.map(d=>d.label),componentList:l.map(d=>d.label)}},K=(i,l)=>{var d;return(d=i==null?void 0:i.__DESIGNS__)==null?void 0:d.find(p=>p.label===l)},X=(i=0)=>!Number.isFinite(i)||i<=0?"0 B":i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:i<1024*1024*1024?`${(i/1024/1024).toFixed(1)} MB`:`${(i/1024/1024/1024).toFixed(2)} GB`,ne=i=>{const l=window[Re];typeof l=="function"&&l(i)},Y=i=>!!i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z),oe=i=>{var l,d;return!i||!i.visible||(l=i.userData)!=null&&l.excludeFromExport||i.isTransformControls||i.isHelper||i.isLight||i.isPoints||(d=i.type)!=null&&d.includes("Helper")||st.has(i.type)||it.has(i.type)||i.isCSS2DObject||i.isCSS3DObject?!1:i.isMesh||i.isGroup||i.isObject3D||i.isLine},Ue=(i,l)=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)?i:l,Zn=i=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)&&Number.isFinite(i.w)?i:{x:0,y:0,z:0,w:1},Rt=i=>{if(!(i!=null&&i.isObject3D))return;const l=Ue(i.position,{x:0,y:0,z:0});i.position.set(l.x,l.y,l.z);const d=Ue(i.scale,{x:1,y:1,z:1});i.scale.set(d.x===0?1:d.x,d.y===0?1:d.y,d.z===0?1:d.z);const p=Ue(i.up,{x:0,y:1,z:0});i.up.set(p.x,p.y,p.z);const I=Zn(i.quaternion);i.quaternion.set(I.x,I.y,I.z,I.w),i.pivot&&!Y(i.pivot)&&delete i.pivot,i.updateMatrix(),i.updateMatrixWorld(!1)},er=(i,l="_blank")=>window.open(i,l),tr=(i,l="")=>window.prompt(i,l),nr=()=>window.location.reload(),rr=()=>document.documentElement.classList.remove("dark"),sr=i=>{if(!Array.isArray(i==null?void 0:i.__DESIGNS__))return H();const l=[...S(),...D()],d=new Set(i.__DESIGNS__.map(p=>at(p)));return l.forEach(p=>{const I=at(p);!I||d.has(I)||(d.add(I),i.__DESIGNS__.unshift(p))}),H()},ir=i=>{if(!Array.isArray(i==null?void 0:i.__GLSLLIB__))return;const l=new Set(i.__GLSLLIB__.map(d=>d==null?void 0:d.name));Gn.forEach(d=>{l.has(d.name)||(l.add(d.name),i.__GLSLLIB__.push(d))})},He=(i={})=>{const l={};return Object.entries(i||{}).forEach(([d,p])=>{if(!(rt.has(d)||typeof p=="function")){if(!p||["string","number","boolean"].includes(typeof p)){l[d]=p;return}if(Array.isArray(p)){try{l[d]=structuredClone(p)}catch(I){return}return}if(!(p.isObject3D||p.isMaterial||p.isTexture||p.nodeType))try{l[d]=structuredClone(p)}catch(I){return}}}),l},ar=(i=De)=>{window.GUI_PARAMS=i},or=i=>{window.threeEditor=i},cr=i=>{window.threeEditorDB=i},lr=i=>{window[Re]=i},ur=(i="")=>{window[se]=i},dr=(i="")=>{window[se]=i},Dt=i=>{var d;const l=[];return(d=i==null?void 0:i.children)==null||d.forEach(p=>{oe(p)&&l.push(p)}),l},xt=(i=[])=>{const l={rootCount:i.length,nodeCount:0,meshCount:0,vertexCount:0,skippedCount:0};return i.forEach(d=>{d.traverse(p=>{var I,B,v;if(oe(p)){l.nodeCount+=1,p.isMesh&&(l.meshCount+=1,l.vertexCount+=((v=(B=(I=p.geometry)==null?void 0:I.attributes)==null?void 0:B.position)==null?void 0:v.count)||0);return}p!==d&&(l.skippedCount+=1)})}),l},vt=()=>new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0))),Tt=()=>new Promise(i=>{if(typeof window.requestIdleCallback=="function"){window.requestIdleCallback(()=>i(),{timeout:80});return}setTimeout(i,0)}),hr=(i,l)=>f(this,null,function*(){var I;if(!oe(i))return null;const d=i.clone(!1);d.userData=He(i.userData),Y(i.pivot)?d.pivot=new U.THREE.Vector3(i.pivot.x,i.pivot.y,i.pivot.z):"pivot"in d&&delete d.pivot,Rt(d);const p=[{source:i,clone:d}];for(;p.length;){const B=p.shift();for(const v of B.source.children){if(!oe(v)){l.skippedCount+=1;continue}const P=v.clone(!1);P.userData=He(v.userData),Y(v.pivot)?P.pivot=new U.THREE.Vector3(v.pivot.x,v.pivot.y,v.pivot.z):"pivot"in P&&delete P.pivot,Rt(P),B.clone.add(P),p.push({source:v,clone:P}),l.processedCount+=1,l.processedCount%nt===0&&(yield(I=l.onProgress)==null?void 0:I.call(l,{processedCount:l.processedCount,totalCount:l.totalCount,skippedCount:l.skippedCount,progress:18+Math.min(l.processedCount/Math.max(l.totalCount,1)*54,54)}),yield vt())}}return d});return{baseUrl:t,getModels:te,getRequest:E,reloadPage:nr,promptInput:tr,waitForIdle:Tt,waitForPaint:vt,clearRequest:c,getGuiParams:J,setGuiParams:ar,getAllRequest:G,getEditorJsons:w,getThreeEditor:A,formatFileSize:X,setThreeEditor:or,removeDarkClass:rr,openExternalUrl:er,getThreedModels:S,getViewportSize:b,buildExportScene:(d,...p)=>f(this,[d,...p],function*(i,l={}){const I=Dt(i),B=xt(I),v=new U.THREE.Scene,P={totalCount:B.nodeCount,processedCount:0,skippedCount:0,onProgress:l.onProgress};for(const mr of I){const Pt=yield hr(mr,P);Pt&&v.add(Pt),yield Tt()}return v.updateMatrixWorld(!0),B.skippedCount+=P.skippedCount,{exportScene:v,exportObjects:I,stats:B}}),createModelDbApi:o,getEditorPreviewSceneUrl:x,sanitizeUserData:He,setThreeEditorDB:cr,findThreedDesign:K,getThreedLightMap:L,collectExportStats:xt,getPreviewSceneUrl:R,setEditorPreviewSceneUrl:dr,setPreviewSceneUrl:ur,setModelLoadHander:lr,isExportableObject:oe,deleteThreeEditorDB:u,ensureThreeEditorDB:$,getDevicePixelRatio:O,getThreedComponents:D,collectExportObjects:Dt,resetModelDbInstance:z,ensureModelDbInstance:h,getLocalDesignMenuData:H,invokeModelLoadHandler:ne,isLegacyInlineKeyError:y,ensureThreedShaderLibrary:ir,ensureThreedDesignRegistry:sr,createBlobUrl:s,revokeModelObjectUrls:a}}const{THREED_LOG_BUFFER:xe,THREED_CURRSCENE:fe,THREED_ACTIVE_MENU:ve,THREED_PIXEL_RATIO:Te,THREED_SCENE_PREVIEW:Pe,THREED_ADDON_EDITOR_JSON:pe,THREED_DEFAULT_SCENE_NAME:jn,THREED_DEFAULT_ACTIVE_MENU:be,THREED_DEFAULT_PIXEL_RATIO:Le,THREED_SCENE_STORAGE_SUFFIX:ct}=zn(),qn=[xe,fe,ve,Te,Pe,pe],j=(r,e)=>{const t=ye.getLocal(r);return t==null?e:t},q=(r,e)=>{r&&ye.setLocal(r,e)},Me=r=>{r&&ye.removeLocal(r)},Wn=(r,e)=>{var n,s;const t=(n=r==null?void 0:r.trim)==null?void 0:n.call(r);return t&&e.some(a=>a.name===t)?t:((s=e[0])==null?void 0:s.name)||jn},Oe=(r=[])=>Array.isArray(r)?r.filter(e=>typeof e=="string"&&e):[],lt=()=>{const r=[],e=j(fe,{name:"",path:""}),t=Number.parseFloat(j(Te,Le));return{taskState:{busy:!1,type:"",title:"",message:"",description:"",progress:0},currScene:e,sceneList:r,previewScene:!!j(Pe,!1),activeMenuTitle:j(ve,be)||be,pixelRatio:Number.isFinite(t)&&t>0?t:Le,logarithmicDepthBuffer:j(xe,!0)!==!1,addonEditorJson:Oe(j(pe,[]))}},ut=ge.defineStore("threed",{state:()=>lt(),actions:{getSceneList(){return f(this,null,function*(){var e;const r=yield V.getCommonApi("threedfloorplan",{limit:1e4,ordering:"-create_time"});(e=r==null?void 0:r.data)!=null&&e.length?(this.sceneList=r.data,this.currScene.path?this.sceneList.find(n=>n.id===this.currScene.id)||this.setCurrScene({name:"",path:""}):this.setCurrScene(this.sceneList[0])):(this.sceneList=[],this.setCurrScene({name:"",path:""}))})},setSceneList(r){this.sceneList=r},setSceneName(r){this.sceneName=Wn(r,this.sceneList),q(fe,this.sceneName)},createScene(r,e=""){return f(this,null,function*(){var c,u;const t=(c=r==null?void 0:r.trim)==null?void 0:c.call(r);if(!t||this.sceneList.some(h=>h.name===t))return!1;const n=Ve.threeSavePath+"/"+Ie()+".json",s=Ie();if(!(yield V.postCommonApi("query/threedfloorplan/create",{data:[{name:t,path:n,guid:s}]})).success)return!1;if(yield En(n,e)){const h=yield V.postCommonApi("threedfloorplan",{guid:s});if((u=h==null?void 0:h.data)!=null&&u.length)return this.sceneList=[...this.sceneList,h.data[0]],h.data[0]}return!0})},deleteScene(r){return f(this,null,function*(){var n;if(!r)return;if(!(yield V.postCommonApi("query/threedfloorplan/delete",{data:[r]})).success)return!1;const t=this.sceneList.findIndex(s=>s.id===r);return t===-1?!1:(this.sceneList.splice(t,1),((n=this.currScene)==null?void 0:n.id)===r&&this.setCurrScene(this.sceneList[0]||{name:"",path:""}),!0)})},setCurrScene(r){return f(this,null,function*(){this.currScene=r,q(fe,this.currScene)})},setPreviewMode(r){this.previewScene=!!r,q(Pe,this.previewScene)},setActiveMenuTitle(r){this.activeMenuTitle=r||be,q(ve,this.activeMenuTitle)},setPixelRatio(r){const e=Number.parseFloat(r);this.pixelRatio=Number.isFinite(e)&&e>0?e:Le,q(Te,this.pixelRatio)},setLogarithmicDepthBuffer(r){this.logarithmicDepthBuffer=!!r,q(xe,this.logarithmicDepthBuffer)},getSceneStorageKey(r){return`${r||this.sceneName}${ct}`},getSceneStorageParams(r,e=null){return j(this.getSceneStorageKey(r),e)},setSceneStorageParams(r,e){r&&q(this.getSceneStorageKey(r),e)},removeSceneStorageParams(r){r&&Me(this.getSceneStorageKey(r))},resetTaskState(){return f(this,null,function*(){yield new Promise(r=>setTimeout(r,120)),this.taskState={busy:!1,type:"",title:"",message:"",description:"",progress:0}})},getAddonEditorJson(){return this.addonEditorJson=Oe(j(pe,this.addonEditorJson)),this.addonEditorJson},setAddonEditorJson(r){this.addonEditorJson=Oe(r),q(pe,this.addonEditorJson)},clearThreedStorage(){qn.forEach(e=>Me(e)),Object.keys(window.localStorage).filter(e=>e.endsWith(ct)).forEach(e=>Me(e));const r=lt();this.currScene=r.currScene,this.sceneList=r.sceneList,this.previewScene=r.previewScene,this.activeMenuTitle=r.activeMenuTitle,this.pixelRatio=r.pixelRatio,this.logarithmicDepthBuffer=r.logarithmicDepthBuffer,this.addonEditorJson=r.addonEditorJson}}}),Jn={scene:{backgroundBlurriness:0,backgroundIntensity:1,backgroundUrls:null,environmentEnabled:!1},perspectiveCamera:{fov:50,near:.1,far:1e5,zoom:1,layers:{mask:1},filmOffset:0,filmGauge:35,position:{x:247.72931803058157,y:715.3890430349733,z:789.6794984861216}},webglRenderer:{outputColorSpace:"srgb",toneMapping:0,toneMappingExposure:1,shadowMap:{enabled:!1,type:1},color:0,opacity:0,sortObjects:!0,localClippingEnabled:!1,autoClear:!0,autoClearColor:!0,renderListCompare:[{name:"stats",enabled:!0},{name:"controls",enabled:!0},{name:"scene",enabled:!0},{name:"css3DRender",enabled:!0},{name:"css2DRender",enabled:!0}]},orbitControls:{autoRotate:!1,autoRotateSpeed:2,enableDamping:!0,dampingFactor:.05,minDistance:.01,maxDistance:1e6,maxAzimuthAngle:null,minAzimuthAngle:null,maxPolarAngle:3.141592653589793,minPolarAngle:0,maxTargetRadius:null,minTargetRadius:0,enablePan:!0,panSpeed:1,enableRotate:!0,rotateSpeed:1,enableZoom:!0,zoomSpeed:1,zoomToCursor:!1,target:{x:-38.59603927643809,y:-48.97202695679889,z:-49.19814250541991}},transformControls:{mode:"translate",space:"world",size:1,showX:!0,showY:!0,showZ:!0,translationSnap:null,rotationSnap:null,scaleSnap:null},effectComposer:{renderWay:"effectComposer",fxaaPass:{enabled:!0,order:60,multPixel:1},outlinePass:{enabled:!0,order:40,edgeStrength:3,edgeGlow:0,edgeThickness:1,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16449071,hiddenEdgeColor:16449071,overlayMaterial:{blending:5,blendEquation:100,blendSrc:201,blendDst:205}},outputPass:{enabled:!0,order:50},saoPass:{enabled:!1,order:10,saoBias:.5,saoIntensity:.01,saoScale:100,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},screenMaskPass:{enabled:!1,order:70,intensity:1,maskColor:16777215,R:.2,sr:1.2},ssrPass:{enabled:!1,order:30,maxDistance:.01,distanceAttenuation:!0,opacity:.5,thickness:.018,fresnel:!0,infiniteThick:!1,bouncing:!1},unrealBloomPass:{enabled:!1,order:20,strength:1.5,radius:.4,threshold:.85}},handler:{mode:"transform",openKeyEnable:!0,rightClickMenusEnable:!0,selectChildEnabled:!1,selectChildLevel:1,stats:{showStats:!1,statsMode:0},helpers:{axes:{showAxes:!0,axesLength:1e3},grid:{showGrid:!0,size:1e3,divisions:15,colorCenterLine:4473924,colorGrid:8947848},box3:{useBox3:!0,color:16776960}}},lightCores:[],innerCores:[],modelCores:[],drawCores:[],textCores:[],particleCores:[],geoCores:{},designCores:[],other:{viewAngleList:[],clipping:{size:20,clipList:[]}}},dt=(r,e)=>{const t=r.__vccOpts||r;for(const[n,s]of e)t[n]=s;return t},Xn=dt(Object.assign({name:"ThreedEditor"},{__name:"editor",props:{data:{type:Object,default:()=>({})},preview:{type:Boolean,default:!1}},emits:["emit-three-editor","graph-event"],setup(r,{expose:e,emit:t}){var L;const n=t,s=r,a=ut(),{currScene:o}=ge.storeToRefs(a),c=((L=window.meta.threed)==null?void 0:L.draco_path)||Ke;U.ThreeEditor.dracoPath=c.endsWith("/")?c:`${c}/`;let u=null,h=null;const y=m.ref(null),{setGuiParams:z,getDevicePixelRatio:W,ensureThreeEditorDB:$,createBlobUrl:E,revokeModelObjectUrls:G,ensureThreedDesignRegistry:te}=$n();te(U.ThreeEditor),z({step:.1});const J=()=>{var R;return(R=u==null?void 0:u.renderSceneResize)==null?void 0:R.call(u)},A=()=>f(this,null,function*(){var D,O;let R=Jn;try{if(s.data&&Object.keys(s.data).length)R=s.data;else if((D=o.value)!=null&&D.path){const x=yield V.getApi((O=o.value)==null?void 0:O.path).catch(()=>({}));console.log("初始化三维场景:",x),x.res&&(R=x.res)}u?u.resetEditorStorage(R):u=new U.ThreeEditor(y.value,{fps:null,pixelRatio:W()*a.pixelRatio,webglRenderParams:{antialias:!0,alpha:!0,logarithmicDepthBuffer:a.logarithmicDepthBuffer},sceneParams:yield w(R)})}catch(x){console.error("三维图纸初始化失败",x),u==null||u.resetEditorStorage(R)}finally{u&&setTimeout(()=>{s.preview&&(u.handler.mode="none",u.handler.helpers.axes.showAxes=!1,u.handler.helpers.box3.useBox3=!1,u.handler.helpers.grid.showGrid=!1)},200),b()}n("emit-three-editor",u),window.addEventListener("resize",J)}),w=R=>f(this,null,function*(){G(),R.designCores.forEach(H=>{H.preview=s.preview});const D=yield $(),O=D.list||[],x=structuredClone(R||{});return x.modelCores=(x.modelCores||[]).filter(H=>{const K=H.modelInfo.originPath;if(K){const X=O.find(Y=>Y.name===K);if(!X){const Y=D.db.getRequest(K);H.modelInfo.url=Y.url;return}const ne=E(X.blob);H.modelInfo.url=ne}return!0}),x}),b=()=>{u!=null&&u.renderer&&(h=new U.THREE.PMREMGenerator(u.renderer),h.compileEquirectangularShader(),u.scene.environment=h.fromScene(new Mt.RoomEnvironment).texture)},S=()=>u;return m.watch(()=>o.value.path,()=>f(this,null,function*(){A()})),m.watch(()=>s.data,()=>{A()},{deep:!0}),m.onMounted(()=>{A()}),m.onUnmounted(()=>{window.removeEventListener("resize",J),G(),u==null||u.destroySceneRender(),a.setCurrScene({name:"",path:""})}),e({getEditorInstance:S}),(R,D)=>(m.openBlock(),m.createElementBlock("div",{ref_key:"editorRef",ref:y,class:"threed-editor",onDragover:D[0]||(D[0]=m.withModifiers(()=>{},["prevent"])),onDrop:D[1]||(D[1]=m.withModifiers(()=>{},["prevent"]))},null,544))}}),[["__scopeId","data-v-86a4ac97"]]),Yn={class:"threed-preview"},ae=dt(Object.assign({name:"ThreedPreview"},{__name:"preview",props:{data:{type:Object,default:null},url:{type:String,default:""},id:{type:String,default:""},token:{type:String,default:""},socketUrl:{type:String,default:""}},emits:["loaded","graph-event"],setup(r,{expose:e,emit:t}){const n=r,s=t;let a=m.shallowRef({});const o=m.ref(),c=ut();let u={},h=null,y=null;const z=A=>{var b,S,L;if(!A)return;if((b=A==null?void 0:A.includes)!=null&&b.call(A,"token 必传"))return re({message:A,type:"warning"});const w=typeof A=="string"?JSON.parse(A):A;if((w==null?void 0:w.data)==="服务错误"||(L=(S=w==null?void 0:w.data)==null?void 0:S.includes)!=null&&L.call(S,"token is expired"))return re({message:w.data,type:"warning"});switch(w.action){case Be.ACPOINT.YCVALUE:case Be.ACPOINT.YXVALUE:console.warn("遥测信息");break}},W=()=>{try{y=new an({socketUrl:n.socketUrl,token:n.token,onMessage:z})}catch(A){console.warn("三维场景消息处理失败",A)}},$=()=>f(this,null,function*(){var A;if(u){const w=Object.keys(u);if(w.length){const b=yield V.postPDApi("querychannelstatus/",{data:w.map(S=>({ied_id:S,ln_list:u[S].map(L=>L.ln_id)}))});(A=b==null?void 0:b.data)!=null&&A.length&&w.forEach(S=>{const L=b.data.find(D=>D.ied_id===S),R=u[S];R!=null&&R.length&&R.forEach(D=>{const O=L.result.find(x=>x.ln_id===D.ln_id);if(O){const x=J();if(!(x!=null&&x.scene))return;const H=x.scene.getObjectsByProperty("dataId",D.guid);let K=H==null?void 0:H[0];if(K){const X=O.status==="告警"?2:O.status==="正常"?1:0;K.userData.params.state=X;const ne=cn(O.amp_peak)?ln(Number(O.amp_peak))?Number(O.amp_peak):0:O.amp_peak;K.userData.params.value=ne;debugger;K.changeState(X),K.changeValue(ne)}}})})}}}),E=A=>{s("graph-event",A)},G=A=>{A&&(n.socketUrl&&W(),setTimeout(()=>{const w=A.scene.getObjectsByProperty("designType","局放测点");w.forEach(b=>{const{ied_id:S,ln_id:L}=b.userData.params;u[S]||(u[S]=[]),u[S].push({guid:b.dataId,id:b.uuid,ied_id:S,ln_id:L})}),w!=null&&w.length&&(h&&clearInterval(h),$(),h=setInterval(()=>{$()},2e3)),s("loaded",A)},100))},te=()=>f(this,null,function*(){if(a.value&&Object.keys(a.value).length)return;const A=un(),w=n.url||A.url;if(w){const L=yield V.getApi(w).catch(()=>({}));L.res&&(a.value=L.res);return}if(!(n.id||A.id)){console.warn("三维场景渲染失败,场景id为空!");return}const S=yield V.getCommonApi("threedfloorplan",{guid:n.id});S.data.length?c.setCurrScene(S.data[0]):console.warn("三维场景渲染失败,场景id为:"+n.id+"不存在!")}),J=()=>o.value?o.value.getEditorInstance():null;return m.watch(()=>n.data,A=>{a.value=A,te()},{deep:!0,immediate:!0}),m.watch(()=>n.id,()=>{te()},{deep:!0,immediate:!0}),m.onMounted(()=>{Se.on("three-event",E)}),m.onUnmounted(()=>{y&&y.destroy(),Se.off("three-event",E)}),e({getEditorInstance:J}),(A,w)=>(m.openBlock(),m.createElementBlock("div",Yn,[m.createVNode(Xn,{ref_key:"threedEditorRef",ref:o,data:m.unref(a),preview:"",onGraphEvent:E,onEmitThreeEditor:G},null,8,["data"])]))}}),[["__scopeId","data-v-1cef540a"]]);ae.name||(ae.name="SyThree");const Qn={install:r=>{r.component(ae.name||"SyThree",ae)}};_.SyThree=ae,_.default=Qn,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
54
+ `,key:"col",commonFinish:!0,render:"iTime+speed"}];let ie=null,N=null;const at=r=>(r==null?void 0:r.name)||(r==null?void 0:r.label)||"",ot=(r={})=>Object.values(r).filter(e=>e&&(e.label||e.name)),Kn=ot(Fn),Vn=ot(Nn),zn=()=>({THREED_GUI_PARAMS:De,THREED_LOG_BUFFER:In,THREED_CURRSCENE:yn,THREED_ACTIVE_MENU:Cn,THREED_PIXEL_RATIO:Rn,THREED_IMPORT_SIZE:Tn,THREED_LIGHT_TYPES:Hn,THREED_EXPORT_BATCH:nt,THREED_RELOAD_DELAY:Pn,THREED_MODEL_DBNAME:me,THREED_MODEL_DBSTORE:Ce,THREED_SCENE_PREVIEW:Dn,THREED_USER_DATA_KEYS:rt,THREED_MODEL_LOAD_KEY:Re,THREED_PREVIEW_URL_KEY:se,THREED_ADDON_EDITOR_JSON:xn,THREED_EXPORT_NODE_COUNT:bn,THREED_DEFAULT_SCENE_NAME:Mn,THREED_DEFAULT_ACTIVE_MENU:On,THREED_DEFAULT_PIXEL_RATIO:Un,THREED_EXPORT_VERTEX_COUNT:Ln,THREED_SCENE_EXCLUDE_TYPES:kn,THREED_EXPORT_EXCLUDE_TYPES:st,THREED_EXPORT_RUNTIME_TYPES:it,THREED_SCENE_STORAGE_SUFFIX:vn});function $n(){const{createInstance:r,dropInstance:e}=Sn(),t="/";let n=[];const s=i=>{let l=URL.createObjectURL(i);return n.push(l),l},a=()=>{n.forEach(i=>URL.revokeObjectURL(i)),n=[]},o=()=>f(this,null,function*(){return yield h(),{clearRequest:c,getAllRequest:G,getRequest:E,status:!0,message:"数据库打开成功",DATABASE:N}}),c=i=>f(this,null,function*(){if(!i)return{status:!1,message:"删除失败"};yield h(),yield N.removeItem(i);const l=yield $();return l.list=l.list.filter(d=>d.name!==i),{status:!0,message:"删除成功"}}),u=(...l)=>f(this,[...l],function*(i=me){N=null,ie=null,yield e({name:i,storeName:Ce})}),h=()=>f(this,null,function*(){return N||(ie||(ie=r({name:me,storeName:Ce}).then(i=>(N=i,i))),yield ie)}),y=i=>{if(!i)return!1;const l=String(i.message||"");return i.name==="DataError"||l.includes("in-line keys")},z=()=>f(this,null,function*(){N=null,ie=null,yield e({name:me}),yield h()});let W=null;const $=()=>f(this,null,function*(){return window.threeEditorDB?window.threeEditorDB:(W||(W=f(this,null,function*(){const i=yield o(),{data:l}=yield i.getAllRequest();return window.threeEditorDB={db:i,list:l},window.threeEditorDB})),yield W)}),E=i=>f(this,null,function*(){if(!i)return{status:!1,message:"获取失败"};yield h();const l=yield N.getItem(i);if(l!=null&&l.blob&&!i)return{status:!0,message:"获取成功",url:s(l.blob)};if(!i)return{status:!1,message:"获取失败"};const d=yield fetch(i).then(P=>P.blob()),p={blob:d};try{yield N.setItem(i,p)}catch(P){if(!y(P))throw P;yield z(),yield N.setItem(i,p)}const I=yield $(),B=k({name:i},p),v=I.list.findIndex(P=>P.name===i);return v>-1?I.list.splice(v,1,B):I.list.push(B),{status:!0,message:"文件缓存成功",url:s(d)}}),G=()=>f(this,null,function*(){yield h();const i=[];return N&&(yield N.iterate((l,d)=>{i.push(_e(k({},l||{}),{name:d}))})),window.threeEditorDB&&(window.threeEditorDB.list=i),{status:!0,message:"获取成功",data:i}}),te=()=>f(this,null,function*(){var d;const{res:i}=yield V.getApi("/filehandle/scan",{path:Ve.threeModelPath,extension:"glb,gltf"}),l=[];if(((d=i==null?void 0:i.children)==null?void 0:d.length)>0)for(const p of i.children)l.push({name:p.name,path:"/"+p.path});return l}),J=()=>window.GUI_PARAMS||De,A=()=>window.threeEditor||null,w=()=>window.editorJsons||[],b=()=>({width:window.innerWidth||0,height:window.innerHeight||0}),S=()=>Kn,L=()=>Bn||{},R=()=>window[se]||"",D=()=>Vn,O=()=>window.devicePixelRatio||1,x=()=>window[se]||"",H=()=>{const i=S(),l=D();return{modelDesigns:i,componentDesigns:l,modelList:i.map(d=>d.label),componentList:l.map(d=>d.label)}},K=(i,l)=>{var d;return(d=i==null?void 0:i.__DESIGNS__)==null?void 0:d.find(p=>p.label===l)},X=(i=0)=>!Number.isFinite(i)||i<=0?"0 B":i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:i<1024*1024*1024?`${(i/1024/1024).toFixed(1)} MB`:`${(i/1024/1024/1024).toFixed(2)} GB`,ne=i=>{const l=window[Re];typeof l=="function"&&l(i)},Y=i=>!!i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z),oe=i=>{var l,d;return!i||!i.visible||(l=i.userData)!=null&&l.excludeFromExport||i.isTransformControls||i.isHelper||i.isLight||i.isPoints||(d=i.type)!=null&&d.includes("Helper")||st.has(i.type)||it.has(i.type)||i.isCSS2DObject||i.isCSS3DObject?!1:i.isMesh||i.isGroup||i.isObject3D||i.isLine},Ue=(i,l)=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)?i:l,Zn=i=>i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)&&Number.isFinite(i.w)?i:{x:0,y:0,z:0,w:1},Rt=i=>{if(!(i!=null&&i.isObject3D))return;const l=Ue(i.position,{x:0,y:0,z:0});i.position.set(l.x,l.y,l.z);const d=Ue(i.scale,{x:1,y:1,z:1});i.scale.set(d.x===0?1:d.x,d.y===0?1:d.y,d.z===0?1:d.z);const p=Ue(i.up,{x:0,y:1,z:0});i.up.set(p.x,p.y,p.z);const I=Zn(i.quaternion);i.quaternion.set(I.x,I.y,I.z,I.w),i.pivot&&!Y(i.pivot)&&delete i.pivot,i.updateMatrix(),i.updateMatrixWorld(!1)},er=(i,l="_blank")=>window.open(i,l),tr=(i,l="")=>window.prompt(i,l),nr=()=>window.location.reload(),rr=()=>document.documentElement.classList.remove("dark"),sr=i=>{if(!Array.isArray(i==null?void 0:i.__DESIGNS__))return H();const l=[...S(),...D()],d=new Set(i.__DESIGNS__.map(p=>at(p)));return l.forEach(p=>{const I=at(p);!I||d.has(I)||(d.add(I),i.__DESIGNS__.unshift(p))}),H()},ir=i=>{if(!Array.isArray(i==null?void 0:i.__GLSLLIB__))return;const l=new Set(i.__GLSLLIB__.map(d=>d==null?void 0:d.name));Gn.forEach(d=>{l.has(d.name)||(l.add(d.name),i.__GLSLLIB__.push(d))})},He=(i={})=>{const l={};return Object.entries(i||{}).forEach(([d,p])=>{if(!(rt.has(d)||typeof p=="function")){if(!p||["string","number","boolean"].includes(typeof p)){l[d]=p;return}if(Array.isArray(p)){try{l[d]=structuredClone(p)}catch(I){return}return}if(!(p.isObject3D||p.isMaterial||p.isTexture||p.nodeType))try{l[d]=structuredClone(p)}catch(I){return}}}),l},ar=(i=De)=>{window.GUI_PARAMS=i},or=i=>{window.threeEditor=i},cr=i=>{window.threeEditorDB=i},lr=i=>{window[Re]=i},ur=(i="")=>{window[se]=i},dr=(i="")=>{window[se]=i},Dt=i=>{var d;const l=[];return(d=i==null?void 0:i.children)==null||d.forEach(p=>{oe(p)&&l.push(p)}),l},xt=(i=[])=>{const l={rootCount:i.length,nodeCount:0,meshCount:0,vertexCount:0,skippedCount:0};return i.forEach(d=>{d.traverse(p=>{var I,B,v;if(oe(p)){l.nodeCount+=1,p.isMesh&&(l.meshCount+=1,l.vertexCount+=((v=(B=(I=p.geometry)==null?void 0:I.attributes)==null?void 0:B.position)==null?void 0:v.count)||0);return}p!==d&&(l.skippedCount+=1)})}),l},vt=()=>new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0))),Tt=()=>new Promise(i=>{if(typeof window.requestIdleCallback=="function"){window.requestIdleCallback(()=>i(),{timeout:80});return}setTimeout(i,0)}),hr=(i,l)=>f(this,null,function*(){var I;if(!oe(i))return null;const d=i.clone(!1);d.userData=He(i.userData),Y(i.pivot)?d.pivot=new U.THREE.Vector3(i.pivot.x,i.pivot.y,i.pivot.z):"pivot"in d&&delete d.pivot,Rt(d);const p=[{source:i,clone:d}];for(;p.length;){const B=p.shift();for(const v of B.source.children){if(!oe(v)){l.skippedCount+=1;continue}const P=v.clone(!1);P.userData=He(v.userData),Y(v.pivot)?P.pivot=new U.THREE.Vector3(v.pivot.x,v.pivot.y,v.pivot.z):"pivot"in P&&delete P.pivot,Rt(P),B.clone.add(P),p.push({source:v,clone:P}),l.processedCount+=1,l.processedCount%nt===0&&(yield(I=l.onProgress)==null?void 0:I.call(l,{processedCount:l.processedCount,totalCount:l.totalCount,skippedCount:l.skippedCount,progress:18+Math.min(l.processedCount/Math.max(l.totalCount,1)*54,54)}),yield vt())}}return d});return{baseUrl:t,getModels:te,getRequest:E,reloadPage:nr,promptInput:tr,waitForIdle:Tt,waitForPaint:vt,clearRequest:c,getGuiParams:J,setGuiParams:ar,getAllRequest:G,getEditorJsons:w,getThreeEditor:A,formatFileSize:X,setThreeEditor:or,removeDarkClass:rr,openExternalUrl:er,getThreedModels:S,getViewportSize:b,buildExportScene:(d,...p)=>f(this,[d,...p],function*(i,l={}){const I=Dt(i),B=xt(I),v=new U.THREE.Scene,P={totalCount:B.nodeCount,processedCount:0,skippedCount:0,onProgress:l.onProgress};for(const mr of I){const Pt=yield hr(mr,P);Pt&&v.add(Pt),yield Tt()}return v.updateMatrixWorld(!0),B.skippedCount+=P.skippedCount,{exportScene:v,exportObjects:I,stats:B}}),createModelDbApi:o,getEditorPreviewSceneUrl:x,sanitizeUserData:He,setThreeEditorDB:cr,findThreedDesign:K,getThreedLightMap:L,collectExportStats:xt,getPreviewSceneUrl:R,setEditorPreviewSceneUrl:dr,setPreviewSceneUrl:ur,setModelLoadHander:lr,isExportableObject:oe,deleteThreeEditorDB:u,ensureThreeEditorDB:$,getDevicePixelRatio:O,getThreedComponents:D,collectExportObjects:Dt,resetModelDbInstance:z,ensureModelDbInstance:h,getLocalDesignMenuData:H,invokeModelLoadHandler:ne,isLegacyInlineKeyError:y,ensureThreedShaderLibrary:ir,ensureThreedDesignRegistry:sr,createBlobUrl:s,revokeModelObjectUrls:a}}const{THREED_LOG_BUFFER:xe,THREED_CURRSCENE:fe,THREED_ACTIVE_MENU:ve,THREED_PIXEL_RATIO:Te,THREED_SCENE_PREVIEW:Pe,THREED_ADDON_EDITOR_JSON:pe,THREED_DEFAULT_SCENE_NAME:jn,THREED_DEFAULT_ACTIVE_MENU:be,THREED_DEFAULT_PIXEL_RATIO:Le,THREED_SCENE_STORAGE_SUFFIX:ct}=zn(),qn=[xe,fe,ve,Te,Pe,pe],j=(r,e)=>{const t=ye.getLocal(r);return t==null?e:t},q=(r,e)=>{r&&ye.setLocal(r,e)},Me=r=>{r&&ye.removeLocal(r)},Wn=(r,e)=>{var n,s;const t=(n=r==null?void 0:r.trim)==null?void 0:n.call(r);return t&&e.some(a=>a.name===t)?t:((s=e[0])==null?void 0:s.name)||jn},Oe=(r=[])=>Array.isArray(r)?r.filter(e=>typeof e=="string"&&e):[],lt=()=>{const r=[],e=j(fe,{name:"",path:""}),t=Number.parseFloat(j(Te,Le));return{taskState:{busy:!1,type:"",title:"",message:"",description:"",progress:0},currScene:e,sceneList:r,previewScene:!!j(Pe,!1),activeMenuTitle:j(ve,be)||be,pixelRatio:Number.isFinite(t)&&t>0?t:Le,logarithmicDepthBuffer:j(xe,!0)!==!1,addonEditorJson:Oe(j(pe,[]))}},ut=ge.defineStore("threed",{state:()=>lt(),actions:{getSceneList(){return f(this,null,function*(){var e;const r=yield V.getCommonApi("threedfloorplan",{limit:1e4,ordering:"-create_time"});(e=r==null?void 0:r.data)!=null&&e.length?(this.sceneList=r.data,this.currScene.path?this.sceneList.find(n=>n.id===this.currScene.id)||this.setCurrScene({name:"",path:""}):this.setCurrScene(this.sceneList[0])):(this.sceneList=[],this.setCurrScene({name:"",path:""}))})},setSceneList(r){this.sceneList=r},setSceneName(r){this.sceneName=Wn(r,this.sceneList),q(fe,this.sceneName)},createScene(r,e=""){return f(this,null,function*(){var c,u;const t=(c=r==null?void 0:r.trim)==null?void 0:c.call(r);if(!t||this.sceneList.some(h=>h.name===t))return!1;const n=Ve.threeSavePath+"/"+Ie()+".json",s=Ie();if(!(yield V.postCommonApi("query/threedfloorplan/create",{data:[{name:t,path:n,guid:s}]})).success)return!1;if(yield En(n,e)){const h=yield V.postCommonApi("threedfloorplan",{guid:s});if((u=h==null?void 0:h.data)!=null&&u.length)return this.sceneList=[...this.sceneList,h.data[0]],h.data[0]}return!0})},deleteScene(r){return f(this,null,function*(){var n;if(!r)return;if(!(yield V.postCommonApi("query/threedfloorplan/delete",{data:[r]})).success)return!1;const t=this.sceneList.findIndex(s=>s.id===r);return t===-1?!1:(this.sceneList.splice(t,1),((n=this.currScene)==null?void 0:n.id)===r&&this.setCurrScene(this.sceneList[0]||{name:"",path:""}),!0)})},setCurrScene(r){return f(this,null,function*(){this.currScene=r,q(fe,this.currScene)})},setPreviewMode(r){this.previewScene=!!r,q(Pe,this.previewScene)},setActiveMenuTitle(r){this.activeMenuTitle=r||be,q(ve,this.activeMenuTitle)},setPixelRatio(r){const e=Number.parseFloat(r);this.pixelRatio=Number.isFinite(e)&&e>0?e:Le,q(Te,this.pixelRatio)},setLogarithmicDepthBuffer(r){this.logarithmicDepthBuffer=!!r,q(xe,this.logarithmicDepthBuffer)},getSceneStorageKey(r){return`${r||this.sceneName}${ct}`},getSceneStorageParams(r,e=null){return j(this.getSceneStorageKey(r),e)},setSceneStorageParams(r,e){r&&q(this.getSceneStorageKey(r),e)},removeSceneStorageParams(r){r&&Me(this.getSceneStorageKey(r))},resetTaskState(){return f(this,null,function*(){yield new Promise(r=>setTimeout(r,120)),this.taskState={busy:!1,type:"",title:"",message:"",description:"",progress:0}})},getAddonEditorJson(){return this.addonEditorJson=Oe(j(pe,this.addonEditorJson)),this.addonEditorJson},setAddonEditorJson(r){this.addonEditorJson=Oe(r),q(pe,this.addonEditorJson)},clearThreedStorage(){qn.forEach(e=>Me(e)),Object.keys(window.localStorage).filter(e=>e.endsWith(ct)).forEach(e=>Me(e));const r=lt();this.currScene=r.currScene,this.sceneList=r.sceneList,this.previewScene=r.previewScene,this.activeMenuTitle=r.activeMenuTitle,this.pixelRatio=r.pixelRatio,this.logarithmicDepthBuffer=r.logarithmicDepthBuffer,this.addonEditorJson=r.addonEditorJson}}}),Jn={scene:{backgroundBlurriness:0,backgroundIntensity:1,backgroundUrls:null,environmentEnabled:!1},perspectiveCamera:{fov:50,near:.1,far:1e5,zoom:1,layers:{mask:1},filmOffset:0,filmGauge:35,position:{x:247.72931803058157,y:715.3890430349733,z:789.6794984861216}},webglRenderer:{outputColorSpace:"srgb",toneMapping:0,toneMappingExposure:1,shadowMap:{enabled:!1,type:1},color:0,opacity:0,sortObjects:!0,localClippingEnabled:!1,autoClear:!0,autoClearColor:!0,renderListCompare:[{name:"stats",enabled:!0},{name:"controls",enabled:!0},{name:"scene",enabled:!0},{name:"css3DRender",enabled:!0},{name:"css2DRender",enabled:!0}]},orbitControls:{autoRotate:!1,autoRotateSpeed:2,enableDamping:!0,dampingFactor:.05,minDistance:.01,maxDistance:1e6,maxAzimuthAngle:null,minAzimuthAngle:null,maxPolarAngle:3.141592653589793,minPolarAngle:0,maxTargetRadius:null,minTargetRadius:0,enablePan:!0,panSpeed:1,enableRotate:!0,rotateSpeed:1,enableZoom:!0,zoomSpeed:1,zoomToCursor:!1,target:{x:-38.59603927643809,y:-48.97202695679889,z:-49.19814250541991}},transformControls:{mode:"translate",space:"world",size:1,showX:!0,showY:!0,showZ:!0,translationSnap:null,rotationSnap:null,scaleSnap:null},effectComposer:{renderWay:"effectComposer",fxaaPass:{enabled:!0,order:60,multPixel:1},outlinePass:{enabled:!0,order:40,edgeStrength:3,edgeGlow:0,edgeThickness:1,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16449071,hiddenEdgeColor:16449071,overlayMaterial:{blending:5,blendEquation:100,blendSrc:201,blendDst:205}},outputPass:{enabled:!0,order:50},saoPass:{enabled:!1,order:10,saoBias:.5,saoIntensity:.01,saoScale:100,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},screenMaskPass:{enabled:!1,order:70,intensity:1,maskColor:16777215,R:.2,sr:1.2},ssrPass:{enabled:!1,order:30,maxDistance:.01,distanceAttenuation:!0,opacity:.5,thickness:.018,fresnel:!0,infiniteThick:!1,bouncing:!1},unrealBloomPass:{enabled:!1,order:20,strength:1.5,radius:.4,threshold:.85}},handler:{mode:"transform",openKeyEnable:!0,rightClickMenusEnable:!0,selectChildEnabled:!1,selectChildLevel:1,stats:{showStats:!1,statsMode:0},helpers:{axes:{showAxes:!0,axesLength:1e3},grid:{showGrid:!0,size:1e3,divisions:15,colorCenterLine:4473924,colorGrid:8947848},box3:{useBox3:!0,color:16776960}}},lightCores:[],innerCores:[],modelCores:[],drawCores:[],textCores:[],particleCores:[],geoCores:{},designCores:[],other:{viewAngleList:[],clipping:{size:20,clipList:[]}}},dt=(r,e)=>{const t=r.__vccOpts||r;for(const[n,s]of e)t[n]=s;return t},Xn=dt(Object.assign({name:"ThreedEditor"},{__name:"editor",props:{data:{type:Object,default:()=>({})},preview:{type:Boolean,default:!1}},emits:["emit-three-editor","graph-event"],setup(r,{expose:e,emit:t}){var L;const n=t,s=r,a=ut(),{currScene:o}=ge.storeToRefs(a),c=((L=window.meta.threed)==null?void 0:L.draco_path)||Ke;U.ThreeEditor.dracoPath=c.endsWith("/")?c:`${c}/`;let u=null,h=null;const y=m.ref(null),{setGuiParams:z,getDevicePixelRatio:W,ensureThreeEditorDB:$,createBlobUrl:E,revokeModelObjectUrls:G,ensureThreedDesignRegistry:te}=$n();te(U.ThreeEditor),z({step:.1});const J=()=>{var R;return(R=u==null?void 0:u.renderSceneResize)==null?void 0:R.call(u)},A=()=>f(this,null,function*(){var D,O;let R=Jn;try{if(s.data&&Object.keys(s.data).length)R=s.data;else if((D=o.value)!=null&&D.path){const x=yield V.getApi((O=o.value)==null?void 0:O.path).catch(()=>({}));console.log("初始化三维场景:",x),x.res&&(R=x.res)}u?u.resetEditorStorage(R):u=new U.ThreeEditor(y.value,{fps:null,pixelRatio:W()*a.pixelRatio,webglRenderParams:{antialias:!0,alpha:!0,logarithmicDepthBuffer:a.logarithmicDepthBuffer},sceneParams:yield w(R)})}catch(x){console.error("三维图纸初始化失败",x),u==null||u.resetEditorStorage(R)}finally{u&&setTimeout(()=>{s.preview&&(u.handler.mode="none",u.handler.helpers.axes.showAxes=!1,u.handler.helpers.box3.useBox3=!1,u.handler.helpers.grid.showGrid=!1)},200),b()}n("emit-three-editor",u),window.addEventListener("resize",J)}),w=R=>f(this,null,function*(){G(),R.designCores.forEach(H=>{H.preview=s.preview});const D=yield $(),O=D.list||[],x=structuredClone(R||{});return x.modelCores=(x.modelCores||[]).filter(H=>{const K=H.modelInfo.originPath;if(K){const X=O.find(Y=>Y.name===K);if(!X){const Y=D.db.getRequest(K);H.modelInfo.url=Y.url;return}const ne=E(X.blob);H.modelInfo.url=ne}return!0}),x}),b=()=>{u!=null&&u.renderer&&(h=new U.THREE.PMREMGenerator(u.renderer),h.compileEquirectangularShader(),u.scene.environment=h.fromScene(new Mt.RoomEnvironment).texture)},S=()=>u;return m.watch(()=>o.value.path,()=>f(this,null,function*(){A()})),m.watch(()=>s.data,()=>{A()},{deep:!0}),m.onMounted(()=>{A()}),m.onUnmounted(()=>{window.removeEventListener("resize",J),G(),u==null||u.destroySceneRender(),a.setCurrScene({name:"",path:""})}),e({getEditorInstance:S}),(R,D)=>(m.openBlock(),m.createElementBlock("div",{ref_key:"editorRef",ref:y,class:"threed-editor",onDragover:D[0]||(D[0]=m.withModifiers(()=>{},["prevent"])),onDrop:D[1]||(D[1]=m.withModifiers(()=>{},["prevent"]))},null,544))}}),[["__scopeId","data-v-86a4ac97"]]),Yn={class:"threed-preview"},ae=dt(Object.assign({name:"ThreedPreview"},{__name:"preview",props:{data:{type:Object,default:null},url:{type:String,default:""},id:{type:String,default:""},token:{type:String,default:""},socketUrl:{type:String,default:""}},emits:["loaded","graph-event"],setup(r,{expose:e,emit:t}){const n=r,s=t;let a=m.shallowRef({});const o=m.ref(),c=ut();let u={},h=null,y=null;const z=A=>{var b,S,L;if(!A)return;if((b=A==null?void 0:A.includes)!=null&&b.call(A,"token 必传"))return re({message:A,type:"warning"});const w=typeof A=="string"?JSON.parse(A):A;if((w==null?void 0:w.data)==="服务错误"||(L=(S=w==null?void 0:w.data)==null?void 0:S.includes)!=null&&L.call(S,"token is expired"))return re({message:w.data,type:"warning"});switch(w.action){case Be.ACPOINT.YCVALUE:case Be.ACPOINT.YXVALUE:console.warn("遥测信息");break}},W=()=>{try{y=new an({socketUrl:n.socketUrl,token:n.token,onMessage:z})}catch(A){console.warn("三维场景消息处理失败",A)}},$=()=>f(this,null,function*(){var A;if(u){const w=Object.keys(u);if(w.length){const b=yield V.postPDApi("querychannelstatus/",{data:w.map(S=>({ied_id:S,ln_list:u[S].map(L=>L.ln_id)}))});(A=b==null?void 0:b.data)!=null&&A.length&&w.forEach(S=>{const L=b.data.find(D=>D.ied_id===S),R=u[S];R!=null&&R.length&&R.forEach(D=>{const O=L.result.find(x=>x.ln_id===D.ln_id);if(O){const x=J();if(!(x!=null&&x.scene))return;const H=x.scene.getObjectsByProperty("dataId",D.guid);let K=H==null?void 0:H[0];if(K){const X=O.status==="告警"?2:O.status==="正常"?1:0;K.userData.params.state=X;const ne=cn(O.amp_peak)?ln(Number(O.amp_peak))?Number(O.amp_peak):0:O.amp_peak;K.userData.params.value=ne;debugger;K.changeState(X),K.changeValue(ne)}}})})}}}),E=A=>{s("graph-event",A)},G=A=>{A&&(n.socketUrl&&W(),setTimeout(()=>{const w=A.scene.getObjectsByProperty("designType","局放测点");w.forEach(b=>{const{ied_id:S,ln_id:L}=b.userData.params;u[S]||(u[S]=[]),u[S].push({guid:b.dataId,id:b.uuid,ied_id:S,ln_id:L})}),w!=null&&w.length&&(h&&clearInterval(h),$(),h=setInterval(()=>{$()},2e3)),s("loaded",A)},100))},te=()=>f(this,null,function*(){if(a.value&&Object.keys(a.value).length)return;const A=un(),w=n.url||A.url;if(w){const L=yield V.getApi(w).catch(()=>({}));L.res&&(a.value=L.res);return}if(!(n.id||A.id)){console.warn("三维场景渲染失败,场景id为空!");return}const S=yield V.getCommonApi("threedfloorplan",{guid:n.id});S.data.length?c.setCurrScene(S.data[0]):console.warn("三维场景渲染失败,场景id为:"+n.id+"不存在!")}),J=()=>o.value?o.value.getEditorInstance():null;return m.watch(()=>n.data,A=>{a.value=A,te()},{deep:!0,immediate:!0}),m.watch(()=>n.id,()=>{te()},{deep:!0,immediate:!0}),m.onMounted(()=>{Se.on("three-event",E)}),m.onUnmounted(()=>{y&&y.destroy(),h&&clearInterval(h),Se.off("three-event",E)}),e({getEditorInstance:J}),(A,w)=>(m.openBlock(),m.createElementBlock("div",Yn,[m.createVNode(Xn,{ref_key:"threedEditorRef",ref:o,data:m.unref(a),preview:"",onGraphEvent:E,onEmitThreeEditor:G},null,8,["data"])]))}}),[["__scopeId","data-v-5a321d2f"]]);ae.name||(ae.name="SyThree");const Qn={install:r=>{r.component(ae.name||"SyThree",ae)}};_.SyThree=ae,_.default=Qn,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syhr/sy-three",
3
- "version": "1.0.0-rc.6",
3
+ "version": "1.0.0-rc.7",
4
4
  "author": "syhr <aiops.sieyuan@gmail.com>",
5
5
  "description": "Planar graphic config tool based on @meta2d.",
6
6
  "license": "MIT",