cbim-render-webgl-sdk
Version:
渲染SDK-WebGL版本
1 lines • 1.46 kB
JavaScript
!function(){var e="_feature_id_0",t=function(t,r){if(!t.index||!t.attributes[e])return"";var a=t.index.array;return t.attributes[e].getX(a[3*r])},r=self;self.onmessage=function(a){var n=a.data,s=n.bvh1,i=n.bvh2,o=n.m1to2,c=n.matrix,u=n.self,d=n.libPath;try{!r.THREE_MESH_BVH&&importScripts("".concat(d,"/mesh-bvh.js"))}catch(e){console.error("依赖库[mesh-bvh]地址不正确,请检查: ".concat(d,"/mesh-bvh.js")),postMessage({error:e})}var f=r.THREE_MESH_BVH,v=f.MeshBVH,h=f.BufferGeometry,p=f.BufferAttribute,b=f.Line3,l=f.Vector3,x=new Set,w={},I=new b;try{var g=new h;g.setAttribute("position",new p(s.position,3,!1)),s.featureId&&g.setAttribute(e,new p(s.featureId,1,!1)),s.index&&g.setIndex(new p(s.index,1,!1));var m,y=v.deserialize(s,g,{setIndex:!1});if(u&&!i)m=y;else{var M=new h;M.setAttribute("position",new p(i.position,3,!1)),i.featureId&&M.setAttribute(e,new p(i.featureId,1,!1)),i.index&&M.setIndex(new p(i.index,1,!1)),m=v.deserialize(i,M,{setIndex:!1,cloneBuffers:!1})}y.bvhcast(m,o,{intersectsTriangles:function(e,t){if(e.intersectsTriangle(t,I)){var r=e.featureId||s.uuid,a=t.featureId||i.uuid;if(r!==a&&!x.has("".concat(r,";").concat(a))&&!x.has("".concat(a,";").concat(r))){var n="".concat(r,";").concat(a);x.add(n);var o=(new l).copy(I.start),u=(new l).copy(I.end);o.applyMatrix4(c),u.applyMatrix4(c),w[n]={start:o,end:u}}}}},{self:u&&!i,getFeatureId:t}),postMessage({uuids:x,edges:w,tris:{}})}catch(e){postMessage({error:e})}}}();