gl-draw 0.4.7 → 0.4.9
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/objects/index.js
CHANGED
|
@@ -129,4 +129,4 @@ void main() {
|
|
|
129
129
|
gl_FragColor.a *= step(vCounters, visibility);
|
|
130
130
|
`).concat(c.ShaderChunk.fog_fragment,`
|
|
131
131
|
}
|
|
132
|
-
`),Ae=function(t){"use strict";C(r,t);var i=V(r);function r(){k(this,r);var n;return n=i.call(this),n.isMeshLine=!0,n.type="MeshLine",n.positions=[],n.previous=[],n.next=[],n.side=[],n.width=[],n.indices_array=[],n.uvs=[],n.counters=[],n._points=[],n._geom=null,n.widthCallback=null,n.matrixWorld=new c.Matrix4,Object.defineProperties(M(n),{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(e){this.setGeometry(e,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(e){this.setPoints(e,this.widthCallback)}}}),n}return r}(c.BufferGeometry);Ae.prototype.setMatrixWorld=function(t){this.matrixWorld=t},Ae.prototype.setGeometry=function(t,i){this._geometry=t,this.setPoints(t.getAttribute("position").array,i)},Ae.prototype.setPoints=function(t,i){if(!(t instanceof Float32Array)&&!(t instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=t,this.widthCallback=i,this.positions=[],this.counters=[],t.length&&t[0]instanceof c.Vector3)for(var r=0;r<t.length;r++){var n=t[r],a=r/t.length;this.positions.push(n.x,n.y,n.z),this.positions.push(n.x,n.y,n.z),this.counters.push(a),this.counters.push(a)}else for(var r=0;r<t.length;r+=3){var a=r/t.length;this.positions.push(t[r],t[r+1],t[r+2]),this.positions.push(t[r],t[r+1],t[r+2]),this.counters.push(a),this.counters.push(a)}this.process()};function Fe(t,i){var r=new c.Matrix4,n=new c.Ray,a=new c.Sphere,e=new c.Vector3,o=this.geometry;if(o.boundingSphere||o.computeBoundingSphere(),a.copy(o.boundingSphere),a.applyMatrix4(this.matrixWorld),t.ray.intersectSphere(a,e)!==!1){r.copy(this.matrixWorld).invert(),n.copy(t.ray).applyMatrix4(r);var s=new c.Vector3,h=new c.Vector3,p=new c.Vector3,d=this instanceof c.LineSegments?2:1,m=o.index,y=o.attributes;if(m!==null)for(var b=m.array,g=y.position.array,w=y.width.array,u=0,O=b.length-1;u<O;u+=d){var _=b[u],D=b[u+1];s.fromArray(g,_*3),h.fromArray(g,D*3);var x=w[Math.floor(u/3)]!==void 0?w[Math.floor(u/3)]:1,oe=t.params.Line.threshold+this.material.lineWidth*x/2,me=oe*oe,he=n.distanceSqToSegment(s,h,e,p);if(!(he>me)){e.applyMatrix4(this.matrixWorld);var fe=t.ray.origin.distanceTo(e);fe<t.near||fe>t.far||(i.push({distance:fe,point:p.clone().applyMatrix4(this.matrixWorld),index:u,face:null,faceIndex:null,object:this}),u=O)}}}}Ae.prototype.raycast=Fe,Ae.prototype.compareV3=function(t,i){var r=t*6,n=i*6;return this.positions[r]===this.positions[n]&&this.positions[r+1]===this.positions[n+1]&&this.positions[r+2]===this.positions[n+2]},Ae.prototype.copyV3=function(t){var i=t*6;return[this.positions[i],this.positions[i+1],this.positions[i+2]]},Ae.prototype.process=function(){var t=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var i,r;this.compareV3(0,t-1)?r=this.copyV3(t-2):r=this.copyV3(0),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(var n=0;n<t;n++){if(this.side.push(1),this.side.push(-1),this.widthCallback?i=this.widthCallback(n/(t-1)):i=1,this.width.push(i),this.width.push(i),this.uvs.push(n/(t-1),0),this.uvs.push(n/(t-1),1),n<t-1){r=this.copyV3(n),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);var a=n*2;this.indices_array.push(a,a+1,a+2),this.indices_array.push(a+2,a+1,a+3)}n>0&&(r=this.copyV3(n),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]))}this.compareV3(t-1,0)?r=this.copyV3(1):r=this.copyV3(t-1),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new c.BufferAttribute(new Float32Array(this.positions),3),previous:new c.BufferAttribute(new Float32Array(this.previous),3),next:new c.BufferAttribute(new Float32Array(this.next),3),side:new c.BufferAttribute(new Float32Array(this.side),1),width:new c.BufferAttribute(new Float32Array(this.width),1),uv:new c.BufferAttribute(new Float32Array(this.uvs),2),index:new c.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new c.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function Ge(t,i,r,n,a){var e;if(t=t.subarray||t.slice?t:t.buffer,r=r.subarray||r.slice?r:r.buffer,t=i?t.subarray?t.subarray(i,a&&i+a):t.slice(i,a&&i+a):t,r.set)r.set(t,n);else for(e=0;e<t.length;e++)r[e+n]=t[e];return r}Ae.prototype.advance=function(t){var i=this._attributes.position.array,r=this._attributes.previous.array,n=this._attributes.next.array,a=i.length;Ge(i,0,r,0,a),Ge(i,6,i,0,a-6),i[a-6]=t.x,i[a-5]=t.y,i[a-4]=t.z,i[a-3]=t.x,i[a-2]=t.y,i[a-1]=t.z,Ge(i,6,n,0,a-6),n[a-6]=t.x,n[a-5]=t.y,n[a-4]=t.z,n[a-3]=t.x,n[a-2]=t.y,n[a-1]=t.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0},c.ShaderChunk.meshline_vert=nt,c.ShaderChunk.meshline_frag=it;var Ve=function(t){"use strict";C(r,t);var i=V(r);function r(n){k(this,r);var a;return a=i.call(this,{uniforms:Object.assign({},c.UniformsLib.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new c.Color(16777215)},opacity:{value:1},resolution:{value:new c.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new c.Vector2(1,1)},offset:{value:new c.Vector2(1,1)},lineLightAnimation:{value:1},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new c.Vector2(0,0)},lightColor:{value:new c.Color(16777215)}}),vertexShader:c.ShaderChunk.meshline_vert,fragmentShader:c.ShaderChunk.meshline_frag}),a.isMeshLineMaterial=!0,a.type="MeshLineMaterial",Object.defineProperties(M(a),{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(o){this.uniforms.lineWidth.value=o}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(o){this.uniforms.lineLightAnimation.value=o}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(o){this.uniforms.map.value=o}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(o){this.uniforms.useMap.value=o}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(o){this.uniforms.alphaMap.value=o}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(o){this.uniforms.useAlphaMap.value=o}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(o){this.uniforms.color.value=o}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(o){this.uniforms.lightColor.value=o}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(o){this.uniforms.time.value=o}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(o){this.uniforms.uCenter.value=o}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(o){this.uniforms.size.value=o}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(o){this.uniforms.opacity.value=o}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(o){this.uniforms.resolution.value.copy(o)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(o){this.uniforms.sizeAttenuation.value=o}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(o){this.uniforms.dashArray.value=o,this.useDash=o!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(o){this.uniforms.dashOffset.value=o}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(o){this.uniforms.dashRatio.value=o}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(o){this.uniforms.useDash.value=o}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(o){this.uniforms.visibility.value=o}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(o){this.uniforms.alphaTest.value=o}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(o){this.uniforms.repeat.value.copy(o)}}}),a.setValues(n),a}return r}(c.ShaderMaterial);Ve.prototype.copy=function(t){return c.ShaderMaterial.prototype.copy.call(this,t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray.copy(t.dashArray),this.dashOffset.copy(t.dashOffset),this.dashRatio.copy(t.dashRatio),this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this};function at(t,i){if(t==null)return{};var r={},n=Object.keys(t),a,e;for(e=0;e<n.length;e++)a=n[e],!(i.indexOf(a)>=0)&&(r[a]=t[a]);return r}function ot(t,i){if(t==null)return{};var r=at(t,i),n,a;if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);for(a=0;a<e.length;a++)n=e[a],!(i.indexOf(n)>=0)&&(!Object.prototype.propertyIsEnumerable.call(t,n)||(r[n]=t[n]))}return r}var Ne=require("popmotion"),He=require("three/examples/jsm//utils/BufferGeometryUtils");function Ke(t){var i=t.setPointWidth,r=t.nodes,n=new c.BufferGeometry,a=new Ae;return n.setFromPoints(r),a.setGeometry(n,i),a}var st={color:new c.Color("#ffffff"),lineWidth:3,sizeAttenuation:0},ut=function(t){"use strict";C(r,t);var i=V(r);function r(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};k(this,r);var e;return e=i.call(this),e.options=(0,j.Z)({},st,a),e}var n=r.prototype;return n.create=function(){var e=this,o=this.options,s=o.duration,h=o.delay,p=o.onComplete,d=o.setPointWidth,m=o.key,y=o.nodes,b=o.nodesArr,g=o.coordinatesArr,w=o.projection,u=o.worker,O=o.workerKey,_=o.useGroups,D=ot(o,["duration","delay","onComplete","setPointWidth","key","nodes","nodesArr","coordinatesArr","projection","worker","workerKey","useGroups"]),x=this.pencil.getSize(),oe=x.width,me=x.height,he=new Ve(L((0,j.Z)({},D),{resolution:new c.Vector2(oe,me)}));if(this.material=he,y)this.createMesh(Ke({nodes:y,setPointWidth:d}),he);else if(b){var fe=He.mergeBufferGeometries(b.map(function(de){return Ke({nodes:de,setPointWidth:d})}),_!=null?_:!1);this.createMesh(fe,he)}else if(g&&u)return new Promise(function(de){u.postMessage({coordinatesArr:g,projection:w,useGroups:_,workerKey:O},function(se){var ge=new c.BufferGeometry;Object.keys(se).forEach(function(ye){ye==="index"?ge.setIndex(new c.BufferAttribute(se[ye].array,se[ye].itemSize)):ge.setAttribute(ye,new c.BufferAttribute(se[ye].array,se[ye].itemSize))}),e.createMesh(ge,he),de("")})})},n.resize=function(e,o){this.material.uniforms.resolution.value.set(e,o)},n.animate=function(){var e=this.options,o=e.duration,s=e.delay,h=e.onComplete,p=this.material.uniforms.offset,d=s!=null?s:0,m=(0,Ne.animate)({from:p.value,to:{x:0},duration:o!=null?o:1e3,elapsed:-d,repeat:1/0,onComplete:h,ease:Ne.linear,onUpdate:function(y){p.value.x=y.x}});this.tween=m},n.dispose=function(){var e;re(G(r.prototype),"dispose",this).call(this),(e=this.tween)===null||e===void 0||e.stop()},r}(ve);function ct(t){if(Array.isArray(t))return t}function lt(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Pe(t,i){return ct(t)||ue(t,i)||F(t,i)||lt()}var je=require("d3-array"),ft=require("earcut"),We=Y.n(ft),ht=require("@turf/boolean-clockwise"),pt=Y.n(ht);function vt(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,a=(90-t)*Math.PI/180;return[r*Math.sin(n)*Math.cos(a),r*Math.cos(n),r*Math.sin(n)*Math.sin(a)]}var dt=require("delaunator"),mt=Y.n(dt),gt=require("@turf/boolean-point-in-polygon"),yt=Y.n(gt),Le=require("d3-geo"),bt=require("d3-geo-voronoi"),$e=require("d3-scale");function wt(t,i){return t.map(function(r){var n=[],a;return r.forEach(function(e){if(a){var o=(0,Le.geoDistance)(e,a)*180/Math.PI;if(o>i)for(var s=(0,Le.geoInterpolate)(a,e),h=1/Math.ceil(o/i),p=h;p<1;)n.push(s(p)),p+=h}n.push(a=e)}),n})}function _t(t){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=i.minLng,n=i.maxLng,a=i.minLat,e=i.maxLat,o=Math.round(Math.pow(360/t,2)/Math.PI),s=(1+Math.sqrt(5))/2,h=function(u){return u/s*360%360-180},p=function(u){return Math.acos(2*u/o-1)/Math.PI*180-90},d=function(u){return o*(Math.cos((u+90)*Math.PI/180)+1)/2},m=[e!==void 0?Math.ceil(d(e)):0,a!==void 0?Math.floor(d(a)):o-1],y=r===void 0&&n===void 0?function(){return!0}:r===void 0?function(u){return u<=n}:n===void 0?function(u){return u>=r}:n>=r?function(u){return u>=r&&u<=n}:function(u){return u>=r||u<=n},b=[],g=m[0];g<=m[1];g++){var w=h(g);y(w)&&b.push([w,p(g)])}return b}function De(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return r?(0,Le.geoContains)(i,t):yt()(t,i)}function Mt(t,i){var r={type:"Polygon",coordinates:t},n=Pe((0,Le.geoBounds)(r),2),a=Pe(n[0],2),e=a[0],o=a[1],s=Pe(n[1],2),h=s[0],p=s[1];if(Math.min(Math.abs(h-e),Math.abs(p-o))<i)return[];var d=e>h||p>=89||o<=-89;return _t(i,{minLng:e,maxLng:h,minLat:o,maxLat:p}).filter(function(m){return De(m,r,d)})}function xt(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=i.resolution,n=r===void 0?1/0:r,a=wt(t,n),e=(0,je.merge)(a),o=Mt(t,n),s=I(e).concat(I(o)),h={type:"Polygon",coordinates:t},p=Pe((0,Le.geoBounds)(h),2),d=Pe(p[0],2),m=d[0],y=d[1],b=Pe(p[1],2),g=b[0],w=b[1],u=m>g||w>=89||y<=-89,O=[];if(u){var _=(0,bt.geoVoronoi)(s).triangles(),D=new Map(s.map(function(ne,Me){var be=Pe(ne,2),_e=be[0],Ee=be[1];return["".concat(_e,"-").concat(Ee),Me]}));_.features.forEach(function(ne){var Me,be=ne.geometry.coordinates[0].slice(0,3).reverse(),_e=[];if(be.forEach(function(Te){var Se=Pe(Te,2),Ie=Se[0],Ct=Se[1],tt="".concat(Ie,"-").concat(Ct);D.has(tt)&&_e.push(D.get(tt))}),_e.length===3){if(_e.some(function(Te){return Te<e.length})){var Ee=ne.properties.circumcenter;if(!De(Ee,h,u))return}(Me=O).push.apply(Me,I(_e))}})}else if(o.length)for(var fe=function(ne,Me){var be,_e=[2,1,0].map(function(Se){return de.triangles[ne+Se]}),Ee=_e.map(function(Se){return s[Se]});if(_e.some(function(Se){return Se<e.length})){var Te=[0,1].map(function(Se){return(0,je.mean)(Ee,function(Ie){return Ie[Se]})});if(!De(Te,h,u))return"continue"}(be=O).push.apply(be,I(_e))},de=mt().from(s),se=0,ge=de.triangles.length;se<ge;se+=3)fe(se,ge);else{var x=We().flatten(a),oe=x.vertices,me=x.holes,he=me===void 0?[]:me;O=We()(oe,he,2)}var ye=(0,$e.scaleLinear)((0,je.extent)(s,function(ne){return ne[0]}),[0,1]),et=(0,$e.scaleLinear)((0,je.extent)(s,function(ne){return ne[1]}),[0,1]),K=s.map(function(ne){var Me=Pe(ne,2),be=Me[0],_e=Me[1];return[ye(be),et(_e)]}),Re={points:s,indices:O,uvs:K};return{contour:a,triangles:Re}}var At=xt,qe=new c.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function Ue(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=t.map(function(a){return a.map(function(e){var o=Pe(e,2),s=o[0],h=o[1];return r?vt(s,h,i):[s,h,i]})});return We().flatten(n)}function Xe(t,i,r){for(var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=Ue(t,i,n),e=a.vertices,o=a.holes,s=Ue(t,r,n),h=s.vertices,p=(0,je.merge)([h,e]),d=Math.round(h.length/3),m=new Set(o),y=0,b=[],g=0;g<d;g++){var w=g+1;if(w===d)w=y;else if(m.has(w)){var u=w;w=y,y=u}b.push(g,g+d,w+d),b.push(w+d,w,g)}for(var O=[],_=1;_>=0;_--)for(var D=0;D<d;D+=1)O.push(D/(d-1),_);return{indices:b,vertices:p,uvs:O,topVerts:h}}function Ye(t,i,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return{indices:n?t.indices:t.indices.slice().reverse(),vertices:Ue([t.points],i,a).vertices,uvs:r}}var Pt=function(t){"use strict";C(r,t);var i=V(r);function r(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};k(this,r);var e;e=i.call(this),e.type="PolygonBufferGeometry",e.parameters=(0,j.Z)({},{polygonGeoJson:n,startHeight:0,endHeight:1,closedBottom:!0,closedTop:!0,includeSides:!0,curvatureResolution:5,cartesian:!0,userDataRsoOffset:0},a);var o=e.parameters,s=o.startHeight,h=o.endHeight,p=o.closedBottom,d=o.closedTop,m=o.includeSides,y=o.curvatureResolution,b=o.cartesian,g=o.userDataRsoOffset;pt()(n[0])||n[0].reverse();var w=At(n,{resolution:y}),u=w.contour,O=w.triangles,_=(0,je.merge)(O.uvs),D=[],x=[],oe=[],me=0,he=function(de){var se=Math.round(D.length/3),ge=oe.length;D=D.concat(de.vertices),x=x.concat(de.uvs),oe=oe.concat(se?de.indices.map(function(ye){return ye+se}):de.indices),e.addGroup(ge,oe.length-ge,me++)};if(m){var fe=Xe(u,s,h,b);he(fe),e.userData.rso=g?Xe(u,s,h+g,b):fe}return p&&he(Ye(O,s,_,!1,b)),d&&he(Ye(O,h,_,!0,b)),e.setIndex(oe),e[qe]("position",new c.Float32BufferAttribute(D,3)),e[qe]("uv",new c.Float32BufferAttribute(x,2)),e.computeVertexNormals(),e}return r}(c.BufferGeometry),St=function(t){"use strict";C(r,t);var i=V(r);function r(a){k(this,r);var e;return e=i.call(this),e.options=(0,j.Z)({},{geojson:[[[]]],startHeight:0,height:5,closedBottom:!0,closedTop:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},a),e}var n=r.prototype;return n.create=function(){var e=this.options,o=e.startHeight,s=e.height,h=e.closedBottom,p=e.closedTop,d=e.curvatureResolution,m=e.userDataRsoOffset,y=e.cartesian,b=new Pt(this.options.geojson,{startHeight:o,endHeight:o+s,closedBottom:h,closedTop:p,curvatureResolution:d,cartesian:y,userDataRsoOffset:m});this.createMesh(b,this.options.material)},r}(ve),Qe=Y(705);function Je(t){var i=t.split,r=t.depth,n=t.points,a=new c[P](new c.Shape(n),{depth:r,bevelEnabled:!1,UVGenerator:(0,Qe.y)({split:i})});return(0,Qe.C)(),a}var Ot=function(t){"use strict";C(r,t);var i=V(r);function r(a){k(this,r);var e;return e=i.call(this),e.options=L((0,j.Z)({},a),{materialOptions:(0,j.Z)({},{split:.1},a.materialOptions||{})}),e}var n=r.prototype;return n.create=function(){var e=this;return(0,f.Z)(v().mark(function o(){var s,h,p,d,m,y,b,g,w,u,O,_,D,x,oe,me,he,fe,de,se,ge,ye;return v().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(s=e.options,h=s.points,p=s.pointsArr,d=s.coordinatesArr,m=s.useGroups,y=s.depth,b=s.material,g=s.materialOptions,w=s.worker,u=s.workerKey,O=s.projection,_=s.cache,D=0,x=b,!(!b&&g)){K.next=23;break}if(D=g.split,oe=g.topColor,me=g.sideColor,he=g.sideMap,fe="ExtrudePolygonMaterial:".concat(me||he).concat(oe||""),!(_&&!_.get(fe))){K.next=13;break}return _.init(fe),K.next=11,e.getMaterial(g);case 11:de=K.sent,_.set(fe,de);case 13:if(!_){K.next=19;break}return K.next=16,_.get(fe);case 16:K.t0=K.sent,K.next=22;break;case 19:return K.next=21,e.getMaterial(g);case 21:K.t0=K.sent;case 22:x=K.t0;case 23:if(se=Array.isArray(y)?y:[y],!h){K.next=28;break}e.createMesh(Je({points:h,depth:se[0],split:D}),b),K.next=34;break;case 28:if(!p){K.next=32;break}ye=He.mergeBufferGeometries(p.map(function(Re,ne){return Je({points:Re,depth:(ge=se[ne])!==null&&ge!==void 0?ge:se[0],split:D})}),m!=null?m:!1),e.createMesh(ye,b),K.next=34;break;case 32:if(!(d&&w)){K.next=34;break}return K.abrupt("return",new Promise(function(Re){w.postMessage({coordinatesArr:d,depth:y,split:D,useGroups:m,projection:O,workerKey:u},function(ne){var Me=new c.BufferGeometry;Object.keys(ne).forEach(function(be){Me.setAttribute(be,new c.BufferAttribute(ne[be].array,ne[be].itemSize))}),e.createMesh(Me,x),Re("")})}));case 34:case"end":return K.stop()}},o)}))()},n.getMaterial=function(e){var o=this,s=e.topColor,h=e.sideColor,p=e.sideMap,d=e.type,m=e.parameters,y=e.createCanvasObjectURL,b=e.split,g=e.maxAnisotropy;return new Promise(function(w){var u=p?document.createElement("img"):{src:"",onload:function(){},width:1024,height:1024};u.onload=function(){var O=b,_=document.createElement("canvas"),D=_.getContext("2d");_.height=u.height/(1-O),_.width=u.width,O&&s&&(D.fillStyle=s,D.fillRect(0,0,u.width,_.height*O)),p&&u instanceof HTMLImageElement?D.drawImage(u,0,_.height*O,u.width,u.height):h&&(D.fillStyle=h,D.fillRect(0,_.height*O,u.width,u.height)),y&&_.toBlob(function(me){console.log(URL.createObjectURL(me))});var x=new c.CanvasTexture(_);x.anisotropy=g||o.pencil.renderer.capabilities.getMaxAnisotropy();var oe=new c[d||"MeshBasicMaterial"]((0,j.Z)({map:x},m||{}));w(oe)},p?u.src=p:u instanceof HTMLImageElement||u.onload()})},n.setMaterialColor=function(e){var o=this;return(0,f.Z)(v().mark(function s(){var h,p,d,m,y,b,g,w,u,O,_;return v().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(h=o.options,p=h.materialOptions,d=h.cache,m=p.sideColor,y=p.sideMap,b=p.topColor,g=e.sideColor,w=e.topColor,!(w||g)){x.next=22;break}if(u="ExtrudePolygonMaterial:".concat(g||m||y||"").concat(w||b||""),!(d&&!d.get(u))){x.next=11;break}return d.init(u),x.next=9,o.getMaterial((0,j.Z)({},p,e));case 9:O=x.sent,d.set(u,O);case 11:if(!d){x.next=17;break}return x.next=14,d.get(u);case 14:x.t0=x.sent,x.next=20;break;case 17:return x.next=19,o.getMaterial((0,j.Z)({},p,e));case 19:x.t0=x.sent;case 20:_=x.t0,o.object3d.material=_;case 22:case"end":return x.stop()}},s)}))()},r}(ve)})(),module.exports=Be})();
|
|
132
|
+
`),Ae=function(t){"use strict";C(r,t);var i=V(r);function r(){k(this,r);var n;return n=i.call(this),n.isMeshLine=!0,n.type="MeshLine",n.positions=[],n.previous=[],n.next=[],n.side=[],n.width=[],n.indices_array=[],n.uvs=[],n.counters=[],n._points=[],n._geom=null,n.widthCallback=null,n.matrixWorld=new c.Matrix4,Object.defineProperties(M(n),{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(e){this.setGeometry(e,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(e){this.setPoints(e,this.widthCallback)}}}),n}return r}(c.BufferGeometry);Ae.prototype.setMatrixWorld=function(t){this.matrixWorld=t},Ae.prototype.setGeometry=function(t,i){this._geometry=t,this.setPoints(t.getAttribute("position").array,i)},Ae.prototype.setPoints=function(t,i){if(!(t instanceof Float32Array)&&!(t instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=t,this.widthCallback=i,this.positions=[],this.counters=[],t.length&&t[0]instanceof c.Vector3)for(var r=0;r<t.length;r++){var n=t[r],a=r/t.length;this.positions.push(n.x,n.y,n.z),this.positions.push(n.x,n.y,n.z),this.counters.push(a),this.counters.push(a)}else for(var r=0;r<t.length;r+=3){var a=r/t.length;this.positions.push(t[r],t[r+1],t[r+2]),this.positions.push(t[r],t[r+1],t[r+2]),this.counters.push(a),this.counters.push(a)}this.process()};function Fe(t,i){var r=new c.Matrix4,n=new c.Ray,a=new c.Sphere,e=new c.Vector3,o=this.geometry;if(o.boundingSphere||o.computeBoundingSphere(),a.copy(o.boundingSphere),a.applyMatrix4(this.matrixWorld),t.ray.intersectSphere(a,e)!==!1){r.copy(this.matrixWorld).invert(),n.copy(t.ray).applyMatrix4(r);var s=new c.Vector3,h=new c.Vector3,p=new c.Vector3,d=this instanceof c.LineSegments?2:1,m=o.index,y=o.attributes;if(m!==null)for(var b=m.array,g=y.position.array,w=y.width.array,u=0,O=b.length-1;u<O;u+=d){var _=b[u],D=b[u+1];s.fromArray(g,_*3),h.fromArray(g,D*3);var x=w[Math.floor(u/3)]!==void 0?w[Math.floor(u/3)]:1,oe=t.params.Line.threshold+this.material.lineWidth*x/2,ge=oe*oe,he=n.distanceSqToSegment(s,h,e,p);if(!(he>ge)){e.applyMatrix4(this.matrixWorld);var fe=t.ray.origin.distanceTo(e);fe<t.near||fe>t.far||(i.push({distance:fe,point:p.clone().applyMatrix4(this.matrixWorld),index:u,face:null,faceIndex:null,object:this}),u=O)}}}}Ae.prototype.raycast=Fe,Ae.prototype.compareV3=function(t,i){var r=t*6,n=i*6;return this.positions[r]===this.positions[n]&&this.positions[r+1]===this.positions[n+1]&&this.positions[r+2]===this.positions[n+2]},Ae.prototype.copyV3=function(t){var i=t*6;return[this.positions[i],this.positions[i+1],this.positions[i+2]]},Ae.prototype.process=function(){var t=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var i,r;this.compareV3(0,t-1)?r=this.copyV3(t-2):r=this.copyV3(0),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(var n=0;n<t;n++){if(this.side.push(1),this.side.push(-1),this.widthCallback?i=this.widthCallback(n/(t-1)):i=1,this.width.push(i),this.width.push(i),this.uvs.push(n/(t-1),0),this.uvs.push(n/(t-1),1),n<t-1){r=this.copyV3(n),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);var a=n*2;this.indices_array.push(a,a+1,a+2),this.indices_array.push(a+2,a+1,a+3)}n>0&&(r=this.copyV3(n),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]))}this.compareV3(t-1,0)?r=this.copyV3(1):r=this.copyV3(t-1),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new c.BufferAttribute(new Float32Array(this.positions),3),previous:new c.BufferAttribute(new Float32Array(this.previous),3),next:new c.BufferAttribute(new Float32Array(this.next),3),side:new c.BufferAttribute(new Float32Array(this.side),1),width:new c.BufferAttribute(new Float32Array(this.width),1),uv:new c.BufferAttribute(new Float32Array(this.uvs),2),index:new c.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new c.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function Ge(t,i,r,n,a){var e;if(t=t.subarray||t.slice?t:t.buffer,r=r.subarray||r.slice?r:r.buffer,t=i?t.subarray?t.subarray(i,a&&i+a):t.slice(i,a&&i+a):t,r.set)r.set(t,n);else for(e=0;e<t.length;e++)r[e+n]=t[e];return r}Ae.prototype.advance=function(t){var i=this._attributes.position.array,r=this._attributes.previous.array,n=this._attributes.next.array,a=i.length;Ge(i,0,r,0,a),Ge(i,6,i,0,a-6),i[a-6]=t.x,i[a-5]=t.y,i[a-4]=t.z,i[a-3]=t.x,i[a-2]=t.y,i[a-1]=t.z,Ge(i,6,n,0,a-6),n[a-6]=t.x,n[a-5]=t.y,n[a-4]=t.z,n[a-3]=t.x,n[a-2]=t.y,n[a-1]=t.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0},c.ShaderChunk.meshline_vert=nt,c.ShaderChunk.meshline_frag=it;var Ve=function(t){"use strict";C(r,t);var i=V(r);function r(n){k(this,r);var a;return a=i.call(this,{uniforms:Object.assign({},c.UniformsLib.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new c.Color(16777215)},opacity:{value:1},resolution:{value:new c.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new c.Vector2(1,1)},offset:{value:new c.Vector2(1,1)},lineLightAnimation:{value:1},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new c.Vector2(0,0)},lightColor:{value:new c.Color(16777215)}}),vertexShader:c.ShaderChunk.meshline_vert,fragmentShader:c.ShaderChunk.meshline_frag}),a.isMeshLineMaterial=!0,a.type="MeshLineMaterial",Object.defineProperties(M(a),{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(o){this.uniforms.lineWidth.value=o}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(o){this.uniforms.lineLightAnimation.value=o}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(o){this.uniforms.map.value=o}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(o){this.uniforms.useMap.value=o}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(o){this.uniforms.alphaMap.value=o}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(o){this.uniforms.useAlphaMap.value=o}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(o){this.uniforms.color.value=o}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(o){this.uniforms.lightColor.value=o}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(o){this.uniforms.time.value=o}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(o){this.uniforms.uCenter.value=o}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(o){this.uniforms.size.value=o}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(o){this.uniforms.opacity.value=o}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(o){this.uniforms.resolution.value.copy(o)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(o){this.uniforms.sizeAttenuation.value=o}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(o){this.uniforms.dashArray.value=o,this.useDash=o!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(o){this.uniforms.dashOffset.value=o}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(o){this.uniforms.dashRatio.value=o}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(o){this.uniforms.useDash.value=o}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(o){this.uniforms.visibility.value=o}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(o){this.uniforms.alphaTest.value=o}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(o){this.uniforms.repeat.value.copy(o)}}}),a.setValues(n),a}return r}(c.ShaderMaterial);Ve.prototype.copy=function(t){return c.ShaderMaterial.prototype.copy.call(this,t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray.copy(t.dashArray),this.dashOffset.copy(t.dashOffset),this.dashRatio.copy(t.dashRatio),this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this};function at(t,i){if(t==null)return{};var r={},n=Object.keys(t),a,e;for(e=0;e<n.length;e++)a=n[e],!(i.indexOf(a)>=0)&&(r[a]=t[a]);return r}function ot(t,i){if(t==null)return{};var r=at(t,i),n,a;if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);for(a=0;a<e.length;a++)n=e[a],!(i.indexOf(n)>=0)&&(!Object.prototype.propertyIsEnumerable.call(t,n)||(r[n]=t[n]))}return r}var Ne=require("popmotion"),He=require("three/examples/jsm//utils/BufferGeometryUtils");function Ke(t){var i=t.setPointWidth,r=t.nodes,n=new c.BufferGeometry,a=new Ae;return n.setFromPoints(r),a.setGeometry(n,i),a}var st={color:new c.Color("#ffffff"),lineWidth:3,sizeAttenuation:0},ut=function(t){"use strict";C(r,t);var i=V(r);function r(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};k(this,r);var e;return e=i.call(this),e.options=(0,j.Z)({},st,a),e}var n=r.prototype;return n.create=function(){var e=this,o=this.options,s=o.duration,h=o.delay,p=o.onComplete,d=o.setPointWidth,m=o.key,y=o.nodes,b=o.nodesArr,g=o.coordinatesArr,w=o.projection,u=o.worker,O=o.workerKey,_=o.useGroups,D=ot(o,["duration","delay","onComplete","setPointWidth","key","nodes","nodesArr","coordinatesArr","projection","worker","workerKey","useGroups"]),x=this.pencil.getSize(),oe=x.width,ge=x.height,he=new Ve(L((0,j.Z)({},D),{resolution:new c.Vector2(oe,ge)}));if(this.material=he,y)this.createMesh(Ke({nodes:y,setPointWidth:d}),he);else if(b){var fe=He.mergeBufferGeometries(b.map(function(de){return Ke({nodes:de,setPointWidth:d})}),_!=null?_:!1);this.createMesh(fe,he)}else if(g&&u)return new Promise(function(de){u.postMessage({coordinatesArr:g,projection:w,useGroups:_,workerKey:O},function(se){var ye=new c.BufferGeometry;Object.keys(se).forEach(function(be){be==="index"?ye.setIndex(new c.BufferAttribute(se[be].array,se[be].itemSize)):ye.setAttribute(be,new c.BufferAttribute(se[be].array,se[be].itemSize))}),e.createMesh(ye,he),de("")})})},n.resize=function(e,o){this.material.uniforms.resolution.value.set(e,o)},n.animate=function(){var e=this.options,o=e.duration,s=e.delay,h=e.onComplete,p=this.material.uniforms.offset,d=s!=null?s:0,m=(0,Ne.animate)({from:p.value,to:{x:0},duration:o!=null?o:1e3,elapsed:-d,repeat:1/0,onComplete:h,ease:Ne.linear,onUpdate:function(y){p.value.x=y.x}});this.tween=m},n.dispose=function(){var e;re(G(r.prototype),"dispose",this).call(this),(e=this.tween)===null||e===void 0||e.stop()},r}(ve);function ct(t){if(Array.isArray(t))return t}function lt(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Pe(t,i){return ct(t)||ue(t,i)||F(t,i)||lt()}var je=require("d3-array"),ft=require("earcut"),We=Y.n(ft),ht=require("@turf/boolean-clockwise"),pt=Y.n(ht);function vt(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,a=(90-t)*Math.PI/180;return[r*Math.sin(n)*Math.cos(a),r*Math.cos(n),r*Math.sin(n)*Math.sin(a)]}var dt=require("delaunator"),mt=Y.n(dt),gt=require("@turf/boolean-point-in-polygon"),yt=Y.n(gt),Le=require("d3-geo"),bt=require("d3-geo-voronoi"),$e=require("d3-scale");function wt(t,i){return t.map(function(r){var n=[],a;return r.forEach(function(e){if(a){var o=(0,Le.geoDistance)(e,a)*180/Math.PI;if(o>i)for(var s=(0,Le.geoInterpolate)(a,e),h=1/Math.ceil(o/i),p=h;p<1;)n.push(s(p)),p+=h}n.push(a=e)}),n})}function _t(t){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=i.minLng,n=i.maxLng,a=i.minLat,e=i.maxLat,o=Math.round(Math.pow(360/t,2)/Math.PI),s=(1+Math.sqrt(5))/2,h=function(u){return u/s*360%360-180},p=function(u){return Math.acos(2*u/o-1)/Math.PI*180-90},d=function(u){return o*(Math.cos((u+90)*Math.PI/180)+1)/2},m=[e!==void 0?Math.ceil(d(e)):0,a!==void 0?Math.floor(d(a)):o-1],y=r===void 0&&n===void 0?function(){return!0}:r===void 0?function(u){return u<=n}:n===void 0?function(u){return u>=r}:n>=r?function(u){return u>=r&&u<=n}:function(u){return u>=r||u<=n},b=[],g=m[0];g<=m[1];g++){var w=h(g);y(w)&&b.push([w,p(g)])}return b}function De(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return r?(0,Le.geoContains)(i,t):yt()(t,i)}function Mt(t,i){var r={type:"Polygon",coordinates:t},n=Pe((0,Le.geoBounds)(r),2),a=Pe(n[0],2),e=a[0],o=a[1],s=Pe(n[1],2),h=s[0],p=s[1];if(Math.min(Math.abs(h-e),Math.abs(p-o))<i)return[];var d=e>h||p>=89||o<=-89;return _t(i,{minLng:e,maxLng:h,minLat:o,maxLat:p}).filter(function(m){return De(m,r,d)})}function xt(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=i.resolution,n=r===void 0?1/0:r,a=wt(t,n),e=(0,je.merge)(a),o=Mt(t,n),s=I(e).concat(I(o)),h={type:"Polygon",coordinates:t},p=Pe((0,Le.geoBounds)(h),2),d=Pe(p[0],2),m=d[0],y=d[1],b=Pe(p[1],2),g=b[0],w=b[1],u=m>g||w>=89||y<=-89,O=[];if(u){var _=(0,bt.geoVoronoi)(s).triangles(),D=new Map(s.map(function(ne,Me){var me=Pe(ne,2),_e=me[0],Ee=me[1];return["".concat(_e,"-").concat(Ee),Me]}));_.features.forEach(function(ne){var Me,me=ne.geometry.coordinates[0].slice(0,3).reverse(),_e=[];if(me.forEach(function(Te){var Se=Pe(Te,2),Ie=Se[0],Ct=Se[1],tt="".concat(Ie,"-").concat(Ct);D.has(tt)&&_e.push(D.get(tt))}),_e.length===3){if(_e.some(function(Te){return Te<e.length})){var Ee=ne.properties.circumcenter;if(!De(Ee,h,u))return}(Me=O).push.apply(Me,I(_e))}})}else if(o.length)for(var fe=function(ne,Me){var me,_e=[2,1,0].map(function(Se){return de.triangles[ne+Se]}),Ee=_e.map(function(Se){return s[Se]});if(_e.some(function(Se){return Se<e.length})){var Te=[0,1].map(function(Se){return(0,je.mean)(Ee,function(Ie){return Ie[Se]})});if(!De(Te,h,u))return"continue"}(me=O).push.apply(me,I(_e))},de=mt().from(s),se=0,ye=de.triangles.length;se<ye;se+=3)fe(se,ye);else{var x=We().flatten(a),oe=x.vertices,ge=x.holes,he=ge===void 0?[]:ge;O=We()(oe,he,2)}var be=(0,$e.scaleLinear)((0,je.extent)(s,function(ne){return ne[0]}),[0,1]),et=(0,$e.scaleLinear)((0,je.extent)(s,function(ne){return ne[1]}),[0,1]),K=s.map(function(ne){var Me=Pe(ne,2),me=Me[0],_e=Me[1];return[be(me),et(_e)]}),Re={points:s,indices:O,uvs:K};return{contour:a,triangles:Re}}var At=xt,qe=new c.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function Ue(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=t.map(function(a){return a.map(function(e){var o=Pe(e,2),s=o[0],h=o[1];return r?vt(s,h,i):[s,h,i]})});return We().flatten(n)}function Xe(t,i,r){for(var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=Ue(t,i,n),e=a.vertices,o=a.holes,s=Ue(t,r,n),h=s.vertices,p=(0,je.merge)([h,e]),d=Math.round(h.length/3),m=new Set(o),y=0,b=[],g=0;g<d;g++){var w=g+1;if(w===d)w=y;else if(m.has(w)){var u=w;w=y,y=u}b.push(g,g+d,w+d),b.push(w+d,w,g)}for(var O=[],_=1;_>=0;_--)for(var D=0;D<d;D+=1)O.push(D/(d-1),_);return{indices:b,vertices:p,uvs:O,topVerts:h}}function Ye(t,i,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return{indices:n?t.indices:t.indices.slice().reverse(),vertices:Ue([t.points],i,a).vertices,uvs:r}}var Pt=function(t){"use strict";C(r,t);var i=V(r);function r(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};k(this,r);var e;e=i.call(this),e.type="PolygonBufferGeometry",e.parameters=(0,j.Z)({},{polygonGeoJson:n,startHeight:0,endHeight:1,closedBottom:!0,closedTop:!0,includeSides:!0,curvatureResolution:5,cartesian:!0,userDataRsoOffset:0},a);var o=e.parameters,s=o.startHeight,h=o.endHeight,p=o.closedBottom,d=o.closedTop,m=o.includeSides,y=o.curvatureResolution,b=o.cartesian,g=o.userDataRsoOffset;pt()(n[0])||n[0].reverse();var w=At(n,{resolution:y}),u=w.contour,O=w.triangles,_=(0,je.merge)(O.uvs),D=[],x=[],oe=[],ge=0,he=function(de){var se=Math.round(D.length/3),ye=oe.length;D=D.concat(de.vertices),x=x.concat(de.uvs),oe=oe.concat(se?de.indices.map(function(be){return be+se}):de.indices),e.addGroup(ye,oe.length-ye,ge++)};if(m){var fe=Xe(u,s,h,b);he(fe),e.userData.rso=g?Xe(u,s,h+g,b):fe}return p&&he(Ye(O,s,_,!1,b)),d&&he(Ye(O,h,_,!0,b)),e.setIndex(oe),e[qe]("position",new c.Float32BufferAttribute(D,3)),e[qe]("uv",new c.Float32BufferAttribute(x,2)),e.computeVertexNormals(),e}return r}(c.BufferGeometry),St=function(t){"use strict";C(r,t);var i=V(r);function r(a){k(this,r);var e;return e=i.call(this),e.options=(0,j.Z)({},{geojson:[[[]]],startHeight:0,height:5,closedBottom:!0,closedTop:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},a),e}var n=r.prototype;return n.create=function(){var e=this.options,o=e.startHeight,s=e.height,h=e.closedBottom,p=e.closedTop,d=e.curvatureResolution,m=e.userDataRsoOffset,y=e.cartesian,b=new Pt(this.options.geojson,{startHeight:o,endHeight:o+s,closedBottom:h,closedTop:p,curvatureResolution:d,cartesian:y,userDataRsoOffset:m});this.createMesh(b,this.options.material)},r}(ve),Qe=Y(705);function Je(t){var i=t.split,r=t.depth,n=t.points,a=new c[P](new c.Shape(n),{depth:r,bevelEnabled:!1,UVGenerator:(0,Qe.y)({split:i})});return(0,Qe.C)(),a}var Ot=function(t){"use strict";C(r,t);var i=V(r);function r(a){k(this,r);var e;return e=i.call(this),e.options=L((0,j.Z)({},a),{materialOptions:(0,j.Z)({},{split:.1},a.materialOptions||{})}),e}var n=r.prototype;return n.create=function(){var e=this;return(0,f.Z)(v().mark(function o(){var s,h,p,d,m,y,b,g,w,u,O,_,D,x,oe,ge,he,fe,de,se,ye,be;return v().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(s=e.options,h=s.points,p=s.pointsArr,d=s.coordinatesArr,m=s.useGroups,y=s.depth,b=s.material,g=s.materialOptions,w=s.worker,u=s.workerKey,O=s.projection,_=s.cache,D=0,x=b,!(!b&&g)){K.next=23;break}if(D=g.split,oe=g.topColor,ge=g.sideColor,he=g.sideMap,fe="ExtrudePolygonMaterial:".concat(ge||he).concat(oe||""),!(_&&!_.get(fe))){K.next=13;break}return _.init(fe),K.next=11,e.getMaterial(g);case 11:de=K.sent,_.set(fe,de);case 13:if(!_){K.next=19;break}return K.next=16,_.get(fe);case 16:K.t0=K.sent,K.next=22;break;case 19:return K.next=21,e.getMaterial(g);case 21:K.t0=K.sent;case 22:x=K.t0;case 23:if(se=Array.isArray(y)?y:[y],!h){K.next=28;break}e.createMesh(Je({points:h,depth:se[0],split:D}),b),K.next=34;break;case 28:if(!p){K.next=32;break}be=He.mergeBufferGeometries(p.map(function(Re,ne){return Je({points:Re,depth:(ye=se[ne])!==null&&ye!==void 0?ye:se[0],split:D})}),m!=null?m:!1),e.createMesh(be,b),K.next=34;break;case 32:if(!(d&&w)){K.next=34;break}return K.abrupt("return",new Promise(function(Re){w.postMessage({coordinatesArr:d,depth:y,split:D,useGroups:m,projection:O,workerKey:u},function(ne){try{var Me=new c.BufferGeometry;Object.keys(ne).forEach(function(me){Me.setAttribute(me,new c.BufferAttribute(ne[me].array,ne[me].itemSize))}),e.createMesh(Me,x),Re("")}catch(me){w.postMessage({delCache:!0,workerKey:u},function(){})}})}));case 34:case"end":return K.stop()}},o)}))()},n.getMaterial=function(e){var o=this,s=e.topColor,h=e.sideColor,p=e.sideMap,d=e.type,m=e.parameters,y=e.createCanvasObjectURL,b=e.split,g=e.maxAnisotropy;return new Promise(function(w){var u=p?document.createElement("img"):{src:"",onload:function(){},width:1024,height:1024};u.onload=function(){var O=b,_=document.createElement("canvas"),D=_.getContext("2d");_.height=u.height/(1-O),_.width=u.width,O&&s&&(D.fillStyle=s,D.fillRect(0,0,u.width,_.height*O)),p&&u instanceof HTMLImageElement?D.drawImage(u,0,_.height*O,u.width,u.height):h&&(D.fillStyle=h,D.fillRect(0,_.height*O,u.width,u.height)),y&&_.toBlob(function(ge){console.log(URL.createObjectURL(ge))});var x=new c.CanvasTexture(_);x.anisotropy=g||o.pencil.renderer.capabilities.getMaxAnisotropy();var oe=new c[d||"MeshBasicMaterial"]((0,j.Z)({map:x},m||{}));w(oe)},p?u.src=p:u instanceof HTMLImageElement||u.onload()})},n.setMaterialColor=function(e){var o=this;return(0,f.Z)(v().mark(function s(){var h,p,d,m,y,b,g,w,u,O,_;return v().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(h=o.options,p=h.materialOptions,d=h.cache,m=p.sideColor,y=p.sideMap,b=p.topColor,g=e.sideColor,w=e.topColor,!(w||g)){x.next=22;break}if(u="ExtrudePolygonMaterial:".concat(g||m||y||"").concat(w||b||""),!(d&&!d.get(u))){x.next=11;break}return d.init(u),x.next=9,o.getMaterial((0,j.Z)({},p,e));case 9:O=x.sent,d.set(u,O);case 11:if(!d){x.next=17;break}return x.next=14,d.get(u);case 14:x.t0=x.sent,x.next=20;break;case 17:return x.next=19,o.getMaterial((0,j.Z)({},p,e));case 19:x.t0=x.sent;case 20:_=x.t0,o.object3d.material=_;case 22:case"end":return x.stop()}},s)}))()},r}(ve)})(),module.exports=Be})();
|
|
@@ -129,4 +129,4 @@ void main() {
|
|
|
129
129
|
gl_FragColor.a *= step(vCounters, visibility);
|
|
130
130
|
`).concat(c.ShaderChunk.fog_fragment,`
|
|
131
131
|
}
|
|
132
|
-
`),Pe=function(e){"use strict";O(r,e);var n=D(r);function r(){k(this,r);var i;return i=n.call(this),i.isMeshLine=!0,i.type="MeshLine",i.positions=[],i.previous=[],i.next=[],i.side=[],i.width=[],i.indices_array=[],i.uvs=[],i.counters=[],i._points=[],i._geom=null,i.widthCallback=null,i.matrixWorld=new c.Matrix4,Object.defineProperties(B(i),{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(t){this.setGeometry(t,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(t){this.setPoints(t,this.widthCallback)}}}),i}return r}(c.BufferGeometry);Pe.prototype.setMatrixWorld=function(e){this.matrixWorld=e},Pe.prototype.setGeometry=function(e,n){this._geometry=e,this.setPoints(e.getAttribute("position").array,n)},Pe.prototype.setPoints=function(e,n){if(!(e instanceof Float32Array)&&!(e instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=e,this.widthCallback=n,this.positions=[],this.counters=[],e.length&&e[0]instanceof c.Vector3)for(var r=0;r<e.length;r++){var i=e[r],a=r/e.length;this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(a),this.counters.push(a)}else for(var r=0;r<e.length;r+=3){var a=r/e.length;this.positions.push(e[r],e[r+1],e[r+2]),this.positions.push(e[r],e[r+1],e[r+2]),this.counters.push(a),this.counters.push(a)}this.process()};function Ke(e,n){var r=new c.Matrix4,i=new c.Ray,a=new c.Sphere,t=new c.Vector3,o=this.geometry;if(o.boundingSphere||o.computeBoundingSphere(),a.copy(o.boundingSphere),a.applyMatrix4(this.matrixWorld),e.ray.intersectSphere(a,t)!==!1){r.copy(this.matrixWorld).invert(),i.copy(e.ray).applyMatrix4(r);var s=new c.Vector3,f=new c.Vector3,p=new c.Vector3,d=this instanceof c.LineSegments?2:1,m=o.index,_=o.attributes;if(m!==null)for(var y=m.array,g=_.position.array,b=_.width.array,u=0,E=y.length-1;u<E;u+=d){var x=y[u],U=y[u+1];s.fromArray(g,x*3),f.fromArray(g,U*3);var P=b[Math.floor(u/3)]!==void 0?b[Math.floor(u/3)]:1,se=e.params.Line.threshold+this.material.lineWidth*P/2,de=se*se,fe=i.distanceSqToSegment(s,f,t,p);if(!(fe>de)){t.applyMatrix4(this.matrixWorld);var le=e.ray.origin.distanceTo(t);le<e.near||le>e.far||(n.push({distance:le,point:p.clone().applyMatrix4(this.matrixWorld),index:u,face:null,faceIndex:null,object:this}),u=E)}}}}Pe.prototype.raycast=Ke,Pe.prototype.compareV3=function(e,n){var r=e*6,i=n*6;return this.positions[r]===this.positions[i]&&this.positions[r+1]===this.positions[i+1]&&this.positions[r+2]===this.positions[i+2]},Pe.prototype.copyV3=function(e){var n=e*6;return[this.positions[n],this.positions[n+1],this.positions[n+2]]},Pe.prototype.process=function(){var e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var n,r;this.compareV3(0,e-1)?r=this.copyV3(e-2):r=this.copyV3(0),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(var i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?n=this.widthCallback(i/(e-1)):n=1,this.width.push(n),this.width.push(n),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){r=this.copyV3(i),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);var a=i*2;this.indices_array.push(a,a+1,a+2),this.indices_array.push(a+2,a+1,a+3)}i>0&&(r=this.copyV3(i),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]))}this.compareV3(e-1,0)?r=this.copyV3(1):r=this.copyV3(e-1),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new c.BufferAttribute(new Float32Array(this.positions),3),previous:new c.BufferAttribute(new Float32Array(this.previous),3),next:new c.BufferAttribute(new Float32Array(this.next),3),side:new c.BufferAttribute(new Float32Array(this.side),1),width:new c.BufferAttribute(new Float32Array(this.width),1),uv:new c.BufferAttribute(new Float32Array(this.uvs),2),index:new c.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new c.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function Ge(e,n,r,i,a){var t;if(e=e.subarray||e.slice?e:e.buffer,r=r.subarray||r.slice?r:r.buffer,e=n?e.subarray?e.subarray(n,a&&n+a):e.slice(n,a&&n+a):e,r.set)r.set(e,i);else for(t=0;t<e.length;t++)r[t+i]=e[t];return r}Pe.prototype.advance=function(e){var n=this._attributes.position.array,r=this._attributes.previous.array,i=this._attributes.next.array,a=n.length;Ge(n,0,r,0,a),Ge(n,6,n,0,a-6),n[a-6]=e.x,n[a-5]=e.y,n[a-4]=e.z,n[a-3]=e.x,n[a-2]=e.y,n[a-1]=e.z,Ge(n,6,i,0,a-6),i[a-6]=e.x,i[a-5]=e.y,i[a-4]=e.z,i[a-3]=e.x,i[a-2]=e.y,i[a-1]=e.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0},c.ShaderChunk.meshline_vert=ft,c.ShaderChunk.meshline_frag=ht;var Ve=function(e){"use strict";O(r,e);var n=D(r);function r(i){k(this,r);var a;return a=n.call(this,{uniforms:Object.assign({},c.UniformsLib.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new c.Color(16777215)},opacity:{value:1},resolution:{value:new c.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new c.Vector2(1,1)},offset:{value:new c.Vector2(1,1)},lineLightAnimation:{value:1},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new c.Vector2(0,0)},lightColor:{value:new c.Color(16777215)}}),vertexShader:c.ShaderChunk.meshline_vert,fragmentShader:c.ShaderChunk.meshline_frag}),a.isMeshLineMaterial=!0,a.type="MeshLineMaterial",Object.defineProperties(B(a),{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(o){this.uniforms.lineWidth.value=o}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(o){this.uniforms.lineLightAnimation.value=o}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(o){this.uniforms.map.value=o}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(o){this.uniforms.useMap.value=o}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(o){this.uniforms.alphaMap.value=o}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(o){this.uniforms.useAlphaMap.value=o}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(o){this.uniforms.color.value=o}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(o){this.uniforms.lightColor.value=o}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(o){this.uniforms.time.value=o}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(o){this.uniforms.uCenter.value=o}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(o){this.uniforms.size.value=o}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(o){this.uniforms.opacity.value=o}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(o){this.uniforms.resolution.value.copy(o)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(o){this.uniforms.sizeAttenuation.value=o}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(o){this.uniforms.dashArray.value=o,this.useDash=o!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(o){this.uniforms.dashOffset.value=o}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(o){this.uniforms.dashRatio.value=o}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(o){this.uniforms.useDash.value=o}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(o){this.uniforms.visibility.value=o}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(o){this.uniforms.alphaTest.value=o}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(o){this.uniforms.repeat.value.copy(o)}}}),a.setValues(i),a}return r}(c.ShaderMaterial);Ve.prototype.copy=function(e){return c.ShaderMaterial.prototype.copy.call(this,e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray.copy(e.dashArray),this.dashOffset.copy(e.dashOffset),this.dashRatio.copy(e.dashRatio),this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this};function pt(e,n){if(e==null)return{};var r={},i=Object.keys(e),a,t;for(t=0;t<i.length;t++)a=i[t],!(n.indexOf(a)>=0)&&(r[a]=e[a]);return r}function vt(e,n){if(e==null)return{};var r=pt(e,n),i,a;if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(a=0;a<t.length;a++)i=t[a],!(n.indexOf(i)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,i)||(r[i]=e[i]))}return r}var dt=e=>{var n={};return N.d(n,e),n},cr=e=>()=>e,Xe=dt({animate:()=>ot.animate,linear:()=>ot.linear}),mt=e=>{var n={};return N.d(n,e),n},lr=e=>()=>e,He=mt({mergeBufferGeometries:()=>Ft.mergeBufferGeometries});function $e(e){var n=e.setPointWidth,r=e.nodes,i=new c.BufferGeometry,a=new Pe;return i.setFromPoints(r),a.setGeometry(i,n),a}var gt={color:new c.Color("#ffffff"),lineWidth:3,sizeAttenuation:0},_t=function(e){"use strict";O(r,e);var n=D(r);function r(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};k(this,r);var t;return t=n.call(this),t.options=(0,M.Z)({},gt,a),t}var i=r.prototype;return i.create=function(){var t=this,o=this.options,s=o.duration,f=o.delay,p=o.onComplete,d=o.setPointWidth,m=o.key,_=o.nodes,y=o.nodesArr,g=o.coordinatesArr,b=o.projection,u=o.worker,E=o.workerKey,x=o.useGroups,U=vt(o,["duration","delay","onComplete","setPointWidth","key","nodes","nodesArr","coordinatesArr","projection","worker","workerKey","useGroups"]),P=this.pencil.getSize(),se=P.width,de=P.height,fe=new Ve(L((0,M.Z)({},U),{resolution:new c.Vector2(se,de)}));if(this.material=fe,_)this.createMesh($e({nodes:_,setPointWidth:d}),fe);else if(y){var le=He.mergeBufferGeometries(y.map(function(ve){return $e({nodes:ve,setPointWidth:d})}),x!=null?x:!1);this.createMesh(le,fe)}else if(g&&u)return new Promise(function(ve){u.postMessage({coordinatesArr:g,projection:b,useGroups:x,workerKey:E},function(ue){var me=new c.BufferGeometry;Object.keys(ue).forEach(function(ge){ge==="index"?me.setIndex(new c.BufferAttribute(ue[ge].array,ue[ge].itemSize)):me.setAttribute(ge,new c.BufferAttribute(ue[ge].array,ue[ge].itemSize))}),t.createMesh(me,fe),ve("")})})},i.resize=function(t,o){this.material.uniforms.resolution.value.set(t,o)},i.animate=function(){var t=this.options,o=t.duration,s=t.delay,f=t.onComplete,p=this.material.uniforms.offset,d=s!=null?s:0,m=(0,Xe.animate)({from:p.value,to:{x:0},duration:o!=null?o:1e3,elapsed:-d,repeat:1/0,onComplete:f,ease:Xe.linear,onUpdate:function(_){p.value.x=_.x}});this.tween=m},i.dispose=function(){var t;We(S(r.prototype),"dispose",this).call(this),(t=this.tween)===null||t===void 0||t.stop()},r}(v);function yt(e){if(Array.isArray(e))return e}function bt(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Se(e,n){return yt(e)||ne(e,n)||F(e,n)||bt()}var wt=e=>{var n={};return N.d(n,e),n},fr=e=>()=>e,Le=wt({extent:()=>Fe.extent,mean:()=>Fe.mean,merge:()=>Fe.merge}),xt=e=>{var n={};return N.d(n,e),n},hr=e=>()=>e,Ue=xt({default:()=>Kt.default}),Mt=e=>{var n={};return N.d(n,e),n},pr=e=>()=>e,At=Mt({default:()=>Xt.default});function Pt(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=(90-n)*Math.PI/180,a=(90-e)*Math.PI/180;return[r*Math.sin(i)*Math.cos(a),r*Math.cos(i),r*Math.sin(i)*Math.sin(a)]}var St=e=>{var n={};return N.d(n,e),n},vr=e=>()=>e,Ot=St({default:()=>Ht.default}),Ct=e=>{var n={};return N.d(n,e),n},dr=e=>()=>e,Et=Ct({default:()=>$t.default}),Lt=e=>{var n={};return N.d(n,e),n},mr=e=>()=>e,Re=Lt({geoBounds:()=>De.geoBounds,geoContains:()=>De.geoContains,geoDistance:()=>De.geoDistance,geoInterpolate:()=>De.geoInterpolate}),jt=e=>{var n={};return N.d(n,e),n},gr=e=>()=>e,kt=jt({geoVoronoi:()=>Yt.geoVoronoi}),Rt=e=>{var n={};return N.d(n,e),n},_r=e=>()=>e,Ye=Rt({scaleLinear:()=>Jt.scaleLinear});function Tt(e,n){return e.map(function(r){var i=[],a;return r.forEach(function(t){if(a){var o=(0,Re.geoDistance)(t,a)*180/Math.PI;if(o>n)for(var s=(0,Re.geoInterpolate)(a,t),f=1/Math.ceil(o/n),p=f;p<1;)i.push(s(p)),p+=f}i.push(a=t)}),i})}function Bt(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.minLng,i=n.maxLng,a=n.minLat,t=n.maxLat,o=Math.round(Math.pow(360/e,2)/Math.PI),s=(1+Math.sqrt(5))/2,f=function(u){return u/s*360%360-180},p=function(u){return Math.acos(2*u/o-1)/Math.PI*180-90},d=function(u){return o*(Math.cos((u+90)*Math.PI/180)+1)/2},m=[t!==void 0?Math.ceil(d(t)):0,a!==void 0?Math.floor(d(a)):o-1],_=r===void 0&&i===void 0?function(){return!0}:r===void 0?function(u){return u<=i}:i===void 0?function(u){return u>=r}:i>=r?function(u){return u>=r&&u<=i}:function(u){return u>=r||u<=i},y=[],g=m[0];g<=m[1];g++){var b=f(g);_(b)&&y.push([b,p(g)])}return y}function Ne(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return r?(0,Re.geoContains)(n,e):(0,Et.default)(e,n)}function zt(e,n){var r={type:"Polygon",coordinates:e},i=Se((0,Re.geoBounds)(r),2),a=Se(i[0],2),t=a[0],o=a[1],s=Se(i[1],2),f=s[0],p=s[1];if(Math.min(Math.abs(f-t),Math.abs(p-o))<n)return[];var d=t>f||p>=89||o<=-89;return Bt(n,{minLng:t,maxLng:f,minLat:o,maxLat:p}).filter(function(m){return Ne(m,r,d)})}function Dt(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.resolution,i=r===void 0?1/0:r,a=Tt(e,i),t=(0,Le.merge)(a),o=zt(e,i),s=I(t).concat(I(o)),f={type:"Polygon",coordinates:e},p=Se((0,Re.geoBounds)(f),2),d=Se(p[0],2),m=d[0],_=d[1],y=Se(p[1],2),g=y[0],b=y[1],u=m>g||b>=89||_<=-89,E=[];if(u){var x=(0,kt.geoVoronoi)(s).triangles(),U=new Map(s.map(function(ie,Me){var _e=Se(ie,2),we=_e[0],Be=_e[1];return["".concat(we,"-").concat(Be),Me]}));x.features.forEach(function(ie){var Me,_e=ie.geometry.coordinates[0].slice(0,3).reverse(),we=[];if(_e.forEach(function(ze){var Oe=Se(ze,2),Ze=Oe[0],Nt=Oe[1],nt="".concat(Ze,"-").concat(Nt);U.has(nt)&&we.push(U.get(nt))}),we.length===3){if(we.some(function(ze){return ze<t.length})){var Be=ie.properties.circumcenter;if(!Ne(Be,f,u))return}(Me=E).push.apply(Me,I(we))}})}else if(o.length)for(var le=function(ie,Me){var _e,we=[2,1,0].map(function(Oe){return ve.triangles[ie+Oe]}),Be=we.map(function(Oe){return s[Oe]});if(we.some(function(Oe){return Oe<t.length})){var ze=[0,1].map(function(Oe){return(0,Le.mean)(Be,function(Ze){return Ze[Oe]})});if(!Ne(ze,f,u))return"continue"}(_e=E).push.apply(_e,I(we))},ve=Ot.default.from(s),ue=0,me=ve.triangles.length;ue<me;ue+=3)le(ue,me);else{var P=Ue.default.flatten(a),se=P.vertices,de=P.holes,fe=de===void 0?[]:de;E=(0,Ue.default)(se,fe,2)}var ge=(0,Ye.scaleLinear)((0,Le.extent)(s,function(ie){return ie[0]}),[0,1]),rt=(0,Ye.scaleLinear)((0,Le.extent)(s,function(ie){return ie[1]}),[0,1]),H=s.map(function(ie){var Me=Se(ie,2),_e=Me[0],we=Me[1];return[ge(_e),rt(we)]}),Te={points:s,indices:E,uvs:H};return{contour:a,triangles:Te}}var Wt=Dt,Je=new c.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function Ie(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=e.map(function(a){return a.map(function(t){var o=Se(t,2),s=o[0],f=o[1];return r?Pt(s,f,n):[s,f,n]})});return Ue.default.flatten(i)}function Qe(e,n,r){for(var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=Ie(e,n,i),t=a.vertices,o=a.holes,s=Ie(e,r,i),f=s.vertices,p=(0,Le.merge)([f,t]),d=Math.round(f.length/3),m=new Set(o),_=0,y=[],g=0;g<d;g++){var b=g+1;if(b===d)b=_;else if(m.has(b)){var u=b;b=_,_=u}y.push(g,g+d,b+d),y.push(b+d,b,g)}for(var E=[],x=1;x>=0;x--)for(var U=0;U<d;U+=1)E.push(U/(d-1),x);return{indices:y,vertices:p,uvs:E,topVerts:f}}function qe(e,n,r){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return{indices:i?e.indices:e.indices.slice().reverse(),vertices:Ie([e.points],n,a).vertices,uvs:r}}var Gt=function(e){"use strict";O(r,e);var n=D(r);function r(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};k(this,r);var t;t=n.call(this),t.type="PolygonBufferGeometry",t.parameters=(0,M.Z)({},{polygonGeoJson:i,startHeight:0,endHeight:1,closedBottom:!0,closedTop:!0,includeSides:!0,curvatureResolution:5,cartesian:!0,userDataRsoOffset:0},a);var o=t.parameters,s=o.startHeight,f=o.endHeight,p=o.closedBottom,d=o.closedTop,m=o.includeSides,_=o.curvatureResolution,y=o.cartesian,g=o.userDataRsoOffset;(0,At.default)(i[0])||i[0].reverse();var b=Wt(i,{resolution:_}),u=b.contour,E=b.triangles,x=(0,Le.merge)(E.uvs),U=[],P=[],se=[],de=0,fe=function(ve){var ue=Math.round(U.length/3),me=se.length;U=U.concat(ve.vertices),P=P.concat(ve.uvs),se=se.concat(ue?ve.indices.map(function(ge){return ge+ue}):ve.indices),t.addGroup(me,se.length-me,de++)};if(m){var le=Qe(u,s,f,y);fe(le),t.userData.rso=g?Qe(u,s,f+g,y):le}return p&&fe(qe(E,s,x,!1,y)),d&&fe(qe(E,f,x,!0,y)),t.setIndex(se),t[Je]("position",new c.Float32BufferAttribute(U,3)),t[Je]("uv",new c.Float32BufferAttribute(P,2)),t.computeVertexNormals(),t}return r}(c.BufferGeometry),Vt=function(e){"use strict";O(r,e);var n=D(r);function r(a){k(this,r);var t;return t=n.call(this),t.options=(0,M.Z)({},{geojson:[[[]]],startHeight:0,height:5,closedBottom:!0,closedTop:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},a),t}var i=r.prototype;return i.create=function(){var t=this.options,o=t.startHeight,s=t.height,f=t.closedBottom,p=t.closedTop,d=t.curvatureResolution,m=t.userDataRsoOffset,_=t.cartesian,y=new Gt(this.options.geojson,{startHeight:o,endHeight:o+s,closedBottom:f,closedTop:p,curvatureResolution:d,cartesian:_,userDataRsoOffset:m});this.createMesh(y,this.options.material)},r}(v),et=N(705);function tt(e){var n=e.split,r=e.depth,i=e.points,a=new c[pe](new c.Shape(i),{depth:r,bevelEnabled:!1,UVGenerator:(0,et.y)({split:n})});return(0,et.C)(),a}var Ut=function(e){"use strict";O(r,e);var n=D(r);function r(a){k(this,r);var t;return t=n.call(this),t.options=L((0,M.Z)({},a),{materialOptions:(0,M.Z)({},{split:.1},a.materialOptions||{})}),t}var i=r.prototype;return i.create=function(){var t=this;return(0,w.Z)(V().mark(function o(){var s,f,p,d,m,_,y,g,b,u,E,x,U,P,se,de,fe,le,ve,ue,me,ge;return V().wrap(function(H){for(;;)switch(H.prev=H.next){case 0:if(s=t.options,f=s.points,p=s.pointsArr,d=s.coordinatesArr,m=s.useGroups,_=s.depth,y=s.material,g=s.materialOptions,b=s.worker,u=s.workerKey,E=s.projection,x=s.cache,U=0,P=y,!(!y&&g)){H.next=23;break}if(U=g.split,se=g.topColor,de=g.sideColor,fe=g.sideMap,le="ExtrudePolygonMaterial:".concat(de||fe).concat(se||""),!(x&&!x.get(le))){H.next=13;break}return x.init(le),H.next=11,t.getMaterial(g);case 11:ve=H.sent,x.set(le,ve);case 13:if(!x){H.next=19;break}return H.next=16,x.get(le);case 16:H.t0=H.sent,H.next=22;break;case 19:return H.next=21,t.getMaterial(g);case 21:H.t0=H.sent;case 22:P=H.t0;case 23:if(ue=Array.isArray(_)?_:[_],!f){H.next=28;break}t.createMesh(tt({points:f,depth:ue[0],split:U}),y),H.next=34;break;case 28:if(!p){H.next=32;break}ge=He.mergeBufferGeometries(p.map(function(Te,ie){return tt({points:Te,depth:(me=ue[ie])!==null&&me!==void 0?me:ue[0],split:U})}),m!=null?m:!1),t.createMesh(ge,y),H.next=34;break;case 32:if(!(d&&b)){H.next=34;break}return H.abrupt("return",new Promise(function(Te){b.postMessage({coordinatesArr:d,depth:_,split:U,useGroups:m,projection:E,workerKey:u},function(ie){var Me=new c.BufferGeometry;Object.keys(ie).forEach(function(_e){Me.setAttribute(_e,new c.BufferAttribute(ie[_e].array,ie[_e].itemSize))}),t.createMesh(Me,P),Te("")})}));case 34:case"end":return H.stop()}},o)}))()},i.getMaterial=function(t){var o=this,s=t.topColor,f=t.sideColor,p=t.sideMap,d=t.type,m=t.parameters,_=t.createCanvasObjectURL,y=t.split,g=t.maxAnisotropy;return new Promise(function(b){var u=p?document.createElement("img"):{src:"",onload:function(){},width:1024,height:1024};u.onload=function(){var E=y,x=document.createElement("canvas"),U=x.getContext("2d");x.height=u.height/(1-E),x.width=u.width,E&&s&&(U.fillStyle=s,U.fillRect(0,0,u.width,x.height*E)),p&&u instanceof HTMLImageElement?U.drawImage(u,0,x.height*E,u.width,u.height):f&&(U.fillStyle=f,U.fillRect(0,x.height*E,u.width,u.height)),_&&x.toBlob(function(de){console.log(URL.createObjectURL(de))});var P=new c.CanvasTexture(x);P.anisotropy=g||o.pencil.renderer.capabilities.getMaxAnisotropy();var se=new c[d||"MeshBasicMaterial"]((0,M.Z)({map:P},m||{}));b(se)},p?u.src=p:u instanceof HTMLImageElement||u.onload()})},i.setMaterialColor=function(t){var o=this;return(0,w.Z)(V().mark(function s(){var f,p,d,m,_,y,g,b,u,E,x;return V().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(f=o.options,p=f.materialOptions,d=f.cache,m=p.sideColor,_=p.sideMap,y=p.topColor,g=t.sideColor,b=t.topColor,!(b||g)){P.next=22;break}if(u="ExtrudePolygonMaterial:".concat(g||m||_||"").concat(b||y||""),!(d&&!d.get(u))){P.next=11;break}return d.init(u),P.next=9,o.getMaterial((0,M.Z)({},p,t));case 9:E=P.sent,d.set(u,E);case 11:if(!d){P.next=17;break}return P.next=14,d.get(u);case 14:P.t0=P.sent,P.next=20;break;case 17:return P.next=19,o.getMaterial((0,M.Z)({},p,t));case 19:P.t0=P.sent;case 20:x=P.t0,o.object3d.material=x;case 22:case"end":return P.stop()}},s)}))()},r}(v)})();var qt=Ae.Ei,er=Ae.Yo,tr=Ae.Ee,rr=Ae.x1,nr=Ae.VJ,ir=Ae.r7,ar=Ae.XA,or=Ae.NB,sr=Ae.xv,ur=Ae.nk;export{qt as ConicPolygon,er as ExtrudePolygon,tr as Image,rr as Line,nr as MeshLine,ir as MeshLineMaterial,ar as MeshLineRaycast,or as Node,sr as Text,ur as Video};
|
|
132
|
+
`),Pe=function(e){"use strict";O(r,e);var n=D(r);function r(){k(this,r);var i;return i=n.call(this),i.isMeshLine=!0,i.type="MeshLine",i.positions=[],i.previous=[],i.next=[],i.side=[],i.width=[],i.indices_array=[],i.uvs=[],i.counters=[],i._points=[],i._geom=null,i.widthCallback=null,i.matrixWorld=new c.Matrix4,Object.defineProperties(B(i),{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(t){this.setGeometry(t,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(t){this.setPoints(t,this.widthCallback)}}}),i}return r}(c.BufferGeometry);Pe.prototype.setMatrixWorld=function(e){this.matrixWorld=e},Pe.prototype.setGeometry=function(e,n){this._geometry=e,this.setPoints(e.getAttribute("position").array,n)},Pe.prototype.setPoints=function(e,n){if(!(e instanceof Float32Array)&&!(e instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=e,this.widthCallback=n,this.positions=[],this.counters=[],e.length&&e[0]instanceof c.Vector3)for(var r=0;r<e.length;r++){var i=e[r],a=r/e.length;this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(a),this.counters.push(a)}else for(var r=0;r<e.length;r+=3){var a=r/e.length;this.positions.push(e[r],e[r+1],e[r+2]),this.positions.push(e[r],e[r+1],e[r+2]),this.counters.push(a),this.counters.push(a)}this.process()};function Ke(e,n){var r=new c.Matrix4,i=new c.Ray,a=new c.Sphere,t=new c.Vector3,o=this.geometry;if(o.boundingSphere||o.computeBoundingSphere(),a.copy(o.boundingSphere),a.applyMatrix4(this.matrixWorld),e.ray.intersectSphere(a,t)!==!1){r.copy(this.matrixWorld).invert(),i.copy(e.ray).applyMatrix4(r);var s=new c.Vector3,f=new c.Vector3,p=new c.Vector3,d=this instanceof c.LineSegments?2:1,m=o.index,_=o.attributes;if(m!==null)for(var y=m.array,g=_.position.array,b=_.width.array,u=0,E=y.length-1;u<E;u+=d){var x=y[u],U=y[u+1];s.fromArray(g,x*3),f.fromArray(g,U*3);var P=b[Math.floor(u/3)]!==void 0?b[Math.floor(u/3)]:1,se=e.params.Line.threshold+this.material.lineWidth*P/2,me=se*se,fe=i.distanceSqToSegment(s,f,t,p);if(!(fe>me)){t.applyMatrix4(this.matrixWorld);var le=e.ray.origin.distanceTo(t);le<e.near||le>e.far||(n.push({distance:le,point:p.clone().applyMatrix4(this.matrixWorld),index:u,face:null,faceIndex:null,object:this}),u=E)}}}}Pe.prototype.raycast=Ke,Pe.prototype.compareV3=function(e,n){var r=e*6,i=n*6;return this.positions[r]===this.positions[i]&&this.positions[r+1]===this.positions[i+1]&&this.positions[r+2]===this.positions[i+2]},Pe.prototype.copyV3=function(e){var n=e*6;return[this.positions[n],this.positions[n+1],this.positions[n+2]]},Pe.prototype.process=function(){var e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var n,r;this.compareV3(0,e-1)?r=this.copyV3(e-2):r=this.copyV3(0),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(var i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?n=this.widthCallback(i/(e-1)):n=1,this.width.push(n),this.width.push(n),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){r=this.copyV3(i),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);var a=i*2;this.indices_array.push(a,a+1,a+2),this.indices_array.push(a+2,a+1,a+3)}i>0&&(r=this.copyV3(i),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]))}this.compareV3(e-1,0)?r=this.copyV3(1):r=this.copyV3(e-1),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new c.BufferAttribute(new Float32Array(this.positions),3),previous:new c.BufferAttribute(new Float32Array(this.previous),3),next:new c.BufferAttribute(new Float32Array(this.next),3),side:new c.BufferAttribute(new Float32Array(this.side),1),width:new c.BufferAttribute(new Float32Array(this.width),1),uv:new c.BufferAttribute(new Float32Array(this.uvs),2),index:new c.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new c.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function Ge(e,n,r,i,a){var t;if(e=e.subarray||e.slice?e:e.buffer,r=r.subarray||r.slice?r:r.buffer,e=n?e.subarray?e.subarray(n,a&&n+a):e.slice(n,a&&n+a):e,r.set)r.set(e,i);else for(t=0;t<e.length;t++)r[t+i]=e[t];return r}Pe.prototype.advance=function(e){var n=this._attributes.position.array,r=this._attributes.previous.array,i=this._attributes.next.array,a=n.length;Ge(n,0,r,0,a),Ge(n,6,n,0,a-6),n[a-6]=e.x,n[a-5]=e.y,n[a-4]=e.z,n[a-3]=e.x,n[a-2]=e.y,n[a-1]=e.z,Ge(n,6,i,0,a-6),i[a-6]=e.x,i[a-5]=e.y,i[a-4]=e.z,i[a-3]=e.x,i[a-2]=e.y,i[a-1]=e.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0},c.ShaderChunk.meshline_vert=ft,c.ShaderChunk.meshline_frag=ht;var Ve=function(e){"use strict";O(r,e);var n=D(r);function r(i){k(this,r);var a;return a=n.call(this,{uniforms:Object.assign({},c.UniformsLib.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new c.Color(16777215)},opacity:{value:1},resolution:{value:new c.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new c.Vector2(1,1)},offset:{value:new c.Vector2(1,1)},lineLightAnimation:{value:1},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new c.Vector2(0,0)},lightColor:{value:new c.Color(16777215)}}),vertexShader:c.ShaderChunk.meshline_vert,fragmentShader:c.ShaderChunk.meshline_frag}),a.isMeshLineMaterial=!0,a.type="MeshLineMaterial",Object.defineProperties(B(a),{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(o){this.uniforms.lineWidth.value=o}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(o){this.uniforms.lineLightAnimation.value=o}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(o){this.uniforms.map.value=o}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(o){this.uniforms.useMap.value=o}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(o){this.uniforms.alphaMap.value=o}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(o){this.uniforms.useAlphaMap.value=o}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(o){this.uniforms.color.value=o}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(o){this.uniforms.lightColor.value=o}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(o){this.uniforms.time.value=o}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(o){this.uniforms.uCenter.value=o}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(o){this.uniforms.size.value=o}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(o){this.uniforms.opacity.value=o}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(o){this.uniforms.resolution.value.copy(o)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(o){this.uniforms.sizeAttenuation.value=o}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(o){this.uniforms.dashArray.value=o,this.useDash=o!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(o){this.uniforms.dashOffset.value=o}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(o){this.uniforms.dashRatio.value=o}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(o){this.uniforms.useDash.value=o}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(o){this.uniforms.visibility.value=o}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(o){this.uniforms.alphaTest.value=o}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(o){this.uniforms.repeat.value.copy(o)}}}),a.setValues(i),a}return r}(c.ShaderMaterial);Ve.prototype.copy=function(e){return c.ShaderMaterial.prototype.copy.call(this,e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray.copy(e.dashArray),this.dashOffset.copy(e.dashOffset),this.dashRatio.copy(e.dashRatio),this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this};function pt(e,n){if(e==null)return{};var r={},i=Object.keys(e),a,t;for(t=0;t<i.length;t++)a=i[t],!(n.indexOf(a)>=0)&&(r[a]=e[a]);return r}function vt(e,n){if(e==null)return{};var r=pt(e,n),i,a;if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(a=0;a<t.length;a++)i=t[a],!(n.indexOf(i)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,i)||(r[i]=e[i]))}return r}var dt=e=>{var n={};return N.d(n,e),n},cr=e=>()=>e,Xe=dt({animate:()=>ot.animate,linear:()=>ot.linear}),mt=e=>{var n={};return N.d(n,e),n},lr=e=>()=>e,He=mt({mergeBufferGeometries:()=>Ft.mergeBufferGeometries});function $e(e){var n=e.setPointWidth,r=e.nodes,i=new c.BufferGeometry,a=new Pe;return i.setFromPoints(r),a.setGeometry(i,n),a}var gt={color:new c.Color("#ffffff"),lineWidth:3,sizeAttenuation:0},_t=function(e){"use strict";O(r,e);var n=D(r);function r(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};k(this,r);var t;return t=n.call(this),t.options=(0,M.Z)({},gt,a),t}var i=r.prototype;return i.create=function(){var t=this,o=this.options,s=o.duration,f=o.delay,p=o.onComplete,d=o.setPointWidth,m=o.key,_=o.nodes,y=o.nodesArr,g=o.coordinatesArr,b=o.projection,u=o.worker,E=o.workerKey,x=o.useGroups,U=vt(o,["duration","delay","onComplete","setPointWidth","key","nodes","nodesArr","coordinatesArr","projection","worker","workerKey","useGroups"]),P=this.pencil.getSize(),se=P.width,me=P.height,fe=new Ve(L((0,M.Z)({},U),{resolution:new c.Vector2(se,me)}));if(this.material=fe,_)this.createMesh($e({nodes:_,setPointWidth:d}),fe);else if(y){var le=He.mergeBufferGeometries(y.map(function(ve){return $e({nodes:ve,setPointWidth:d})}),x!=null?x:!1);this.createMesh(le,fe)}else if(g&&u)return new Promise(function(ve){u.postMessage({coordinatesArr:g,projection:b,useGroups:x,workerKey:E},function(ue){var ge=new c.BufferGeometry;Object.keys(ue).forEach(function(_e){_e==="index"?ge.setIndex(new c.BufferAttribute(ue[_e].array,ue[_e].itemSize)):ge.setAttribute(_e,new c.BufferAttribute(ue[_e].array,ue[_e].itemSize))}),t.createMesh(ge,fe),ve("")})})},i.resize=function(t,o){this.material.uniforms.resolution.value.set(t,o)},i.animate=function(){var t=this.options,o=t.duration,s=t.delay,f=t.onComplete,p=this.material.uniforms.offset,d=s!=null?s:0,m=(0,Xe.animate)({from:p.value,to:{x:0},duration:o!=null?o:1e3,elapsed:-d,repeat:1/0,onComplete:f,ease:Xe.linear,onUpdate:function(_){p.value.x=_.x}});this.tween=m},i.dispose=function(){var t;We(S(r.prototype),"dispose",this).call(this),(t=this.tween)===null||t===void 0||t.stop()},r}(v);function yt(e){if(Array.isArray(e))return e}function bt(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Se(e,n){return yt(e)||ne(e,n)||F(e,n)||bt()}var wt=e=>{var n={};return N.d(n,e),n},fr=e=>()=>e,Le=wt({extent:()=>Fe.extent,mean:()=>Fe.mean,merge:()=>Fe.merge}),xt=e=>{var n={};return N.d(n,e),n},hr=e=>()=>e,Ue=xt({default:()=>Kt.default}),Mt=e=>{var n={};return N.d(n,e),n},pr=e=>()=>e,At=Mt({default:()=>Xt.default});function Pt(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=(90-n)*Math.PI/180,a=(90-e)*Math.PI/180;return[r*Math.sin(i)*Math.cos(a),r*Math.cos(i),r*Math.sin(i)*Math.sin(a)]}var St=e=>{var n={};return N.d(n,e),n},vr=e=>()=>e,Ot=St({default:()=>Ht.default}),Ct=e=>{var n={};return N.d(n,e),n},dr=e=>()=>e,Et=Ct({default:()=>$t.default}),Lt=e=>{var n={};return N.d(n,e),n},mr=e=>()=>e,Re=Lt({geoBounds:()=>De.geoBounds,geoContains:()=>De.geoContains,geoDistance:()=>De.geoDistance,geoInterpolate:()=>De.geoInterpolate}),jt=e=>{var n={};return N.d(n,e),n},gr=e=>()=>e,kt=jt({geoVoronoi:()=>Yt.geoVoronoi}),Rt=e=>{var n={};return N.d(n,e),n},_r=e=>()=>e,Ye=Rt({scaleLinear:()=>Jt.scaleLinear});function Tt(e,n){return e.map(function(r){var i=[],a;return r.forEach(function(t){if(a){var o=(0,Re.geoDistance)(t,a)*180/Math.PI;if(o>n)for(var s=(0,Re.geoInterpolate)(a,t),f=1/Math.ceil(o/n),p=f;p<1;)i.push(s(p)),p+=f}i.push(a=t)}),i})}function Bt(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.minLng,i=n.maxLng,a=n.minLat,t=n.maxLat,o=Math.round(Math.pow(360/e,2)/Math.PI),s=(1+Math.sqrt(5))/2,f=function(u){return u/s*360%360-180},p=function(u){return Math.acos(2*u/o-1)/Math.PI*180-90},d=function(u){return o*(Math.cos((u+90)*Math.PI/180)+1)/2},m=[t!==void 0?Math.ceil(d(t)):0,a!==void 0?Math.floor(d(a)):o-1],_=r===void 0&&i===void 0?function(){return!0}:r===void 0?function(u){return u<=i}:i===void 0?function(u){return u>=r}:i>=r?function(u){return u>=r&&u<=i}:function(u){return u>=r||u<=i},y=[],g=m[0];g<=m[1];g++){var b=f(g);_(b)&&y.push([b,p(g)])}return y}function Ne(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return r?(0,Re.geoContains)(n,e):(0,Et.default)(e,n)}function zt(e,n){var r={type:"Polygon",coordinates:e},i=Se((0,Re.geoBounds)(r),2),a=Se(i[0],2),t=a[0],o=a[1],s=Se(i[1],2),f=s[0],p=s[1];if(Math.min(Math.abs(f-t),Math.abs(p-o))<n)return[];var d=t>f||p>=89||o<=-89;return Bt(n,{minLng:t,maxLng:f,minLat:o,maxLat:p}).filter(function(m){return Ne(m,r,d)})}function Dt(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.resolution,i=r===void 0?1/0:r,a=Tt(e,i),t=(0,Le.merge)(a),o=zt(e,i),s=I(t).concat(I(o)),f={type:"Polygon",coordinates:e},p=Se((0,Re.geoBounds)(f),2),d=Se(p[0],2),m=d[0],_=d[1],y=Se(p[1],2),g=y[0],b=y[1],u=m>g||b>=89||_<=-89,E=[];if(u){var x=(0,kt.geoVoronoi)(s).triangles(),U=new Map(s.map(function(ie,Me){var de=Se(ie,2),we=de[0],Be=de[1];return["".concat(we,"-").concat(Be),Me]}));x.features.forEach(function(ie){var Me,de=ie.geometry.coordinates[0].slice(0,3).reverse(),we=[];if(de.forEach(function(ze){var Oe=Se(ze,2),Ze=Oe[0],Nt=Oe[1],nt="".concat(Ze,"-").concat(Nt);U.has(nt)&&we.push(U.get(nt))}),we.length===3){if(we.some(function(ze){return ze<t.length})){var Be=ie.properties.circumcenter;if(!Ne(Be,f,u))return}(Me=E).push.apply(Me,I(we))}})}else if(o.length)for(var le=function(ie,Me){var de,we=[2,1,0].map(function(Oe){return ve.triangles[ie+Oe]}),Be=we.map(function(Oe){return s[Oe]});if(we.some(function(Oe){return Oe<t.length})){var ze=[0,1].map(function(Oe){return(0,Le.mean)(Be,function(Ze){return Ze[Oe]})});if(!Ne(ze,f,u))return"continue"}(de=E).push.apply(de,I(we))},ve=Ot.default.from(s),ue=0,ge=ve.triangles.length;ue<ge;ue+=3)le(ue,ge);else{var P=Ue.default.flatten(a),se=P.vertices,me=P.holes,fe=me===void 0?[]:me;E=(0,Ue.default)(se,fe,2)}var _e=(0,Ye.scaleLinear)((0,Le.extent)(s,function(ie){return ie[0]}),[0,1]),rt=(0,Ye.scaleLinear)((0,Le.extent)(s,function(ie){return ie[1]}),[0,1]),H=s.map(function(ie){var Me=Se(ie,2),de=Me[0],we=Me[1];return[_e(de),rt(we)]}),Te={points:s,indices:E,uvs:H};return{contour:a,triangles:Te}}var Wt=Dt,Je=new c.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function Ie(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=e.map(function(a){return a.map(function(t){var o=Se(t,2),s=o[0],f=o[1];return r?Pt(s,f,n):[s,f,n]})});return Ue.default.flatten(i)}function Qe(e,n,r){for(var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=Ie(e,n,i),t=a.vertices,o=a.holes,s=Ie(e,r,i),f=s.vertices,p=(0,Le.merge)([f,t]),d=Math.round(f.length/3),m=new Set(o),_=0,y=[],g=0;g<d;g++){var b=g+1;if(b===d)b=_;else if(m.has(b)){var u=b;b=_,_=u}y.push(g,g+d,b+d),y.push(b+d,b,g)}for(var E=[],x=1;x>=0;x--)for(var U=0;U<d;U+=1)E.push(U/(d-1),x);return{indices:y,vertices:p,uvs:E,topVerts:f}}function qe(e,n,r){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return{indices:i?e.indices:e.indices.slice().reverse(),vertices:Ie([e.points],n,a).vertices,uvs:r}}var Gt=function(e){"use strict";O(r,e);var n=D(r);function r(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};k(this,r);var t;t=n.call(this),t.type="PolygonBufferGeometry",t.parameters=(0,M.Z)({},{polygonGeoJson:i,startHeight:0,endHeight:1,closedBottom:!0,closedTop:!0,includeSides:!0,curvatureResolution:5,cartesian:!0,userDataRsoOffset:0},a);var o=t.parameters,s=o.startHeight,f=o.endHeight,p=o.closedBottom,d=o.closedTop,m=o.includeSides,_=o.curvatureResolution,y=o.cartesian,g=o.userDataRsoOffset;(0,At.default)(i[0])||i[0].reverse();var b=Wt(i,{resolution:_}),u=b.contour,E=b.triangles,x=(0,Le.merge)(E.uvs),U=[],P=[],se=[],me=0,fe=function(ve){var ue=Math.round(U.length/3),ge=se.length;U=U.concat(ve.vertices),P=P.concat(ve.uvs),se=se.concat(ue?ve.indices.map(function(_e){return _e+ue}):ve.indices),t.addGroup(ge,se.length-ge,me++)};if(m){var le=Qe(u,s,f,y);fe(le),t.userData.rso=g?Qe(u,s,f+g,y):le}return p&&fe(qe(E,s,x,!1,y)),d&&fe(qe(E,f,x,!0,y)),t.setIndex(se),t[Je]("position",new c.Float32BufferAttribute(U,3)),t[Je]("uv",new c.Float32BufferAttribute(P,2)),t.computeVertexNormals(),t}return r}(c.BufferGeometry),Vt=function(e){"use strict";O(r,e);var n=D(r);function r(a){k(this,r);var t;return t=n.call(this),t.options=(0,M.Z)({},{geojson:[[[]]],startHeight:0,height:5,closedBottom:!0,closedTop:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},a),t}var i=r.prototype;return i.create=function(){var t=this.options,o=t.startHeight,s=t.height,f=t.closedBottom,p=t.closedTop,d=t.curvatureResolution,m=t.userDataRsoOffset,_=t.cartesian,y=new Gt(this.options.geojson,{startHeight:o,endHeight:o+s,closedBottom:f,closedTop:p,curvatureResolution:d,cartesian:_,userDataRsoOffset:m});this.createMesh(y,this.options.material)},r}(v),et=N(705);function tt(e){var n=e.split,r=e.depth,i=e.points,a=new c[pe](new c.Shape(i),{depth:r,bevelEnabled:!1,UVGenerator:(0,et.y)({split:n})});return(0,et.C)(),a}var Ut=function(e){"use strict";O(r,e);var n=D(r);function r(a){k(this,r);var t;return t=n.call(this),t.options=L((0,M.Z)({},a),{materialOptions:(0,M.Z)({},{split:.1},a.materialOptions||{})}),t}var i=r.prototype;return i.create=function(){var t=this;return(0,w.Z)(V().mark(function o(){var s,f,p,d,m,_,y,g,b,u,E,x,U,P,se,me,fe,le,ve,ue,ge,_e;return V().wrap(function(H){for(;;)switch(H.prev=H.next){case 0:if(s=t.options,f=s.points,p=s.pointsArr,d=s.coordinatesArr,m=s.useGroups,_=s.depth,y=s.material,g=s.materialOptions,b=s.worker,u=s.workerKey,E=s.projection,x=s.cache,U=0,P=y,!(!y&&g)){H.next=23;break}if(U=g.split,se=g.topColor,me=g.sideColor,fe=g.sideMap,le="ExtrudePolygonMaterial:".concat(me||fe).concat(se||""),!(x&&!x.get(le))){H.next=13;break}return x.init(le),H.next=11,t.getMaterial(g);case 11:ve=H.sent,x.set(le,ve);case 13:if(!x){H.next=19;break}return H.next=16,x.get(le);case 16:H.t0=H.sent,H.next=22;break;case 19:return H.next=21,t.getMaterial(g);case 21:H.t0=H.sent;case 22:P=H.t0;case 23:if(ue=Array.isArray(_)?_:[_],!f){H.next=28;break}t.createMesh(tt({points:f,depth:ue[0],split:U}),y),H.next=34;break;case 28:if(!p){H.next=32;break}_e=He.mergeBufferGeometries(p.map(function(Te,ie){return tt({points:Te,depth:(ge=ue[ie])!==null&&ge!==void 0?ge:ue[0],split:U})}),m!=null?m:!1),t.createMesh(_e,y),H.next=34;break;case 32:if(!(d&&b)){H.next=34;break}return H.abrupt("return",new Promise(function(Te){b.postMessage({coordinatesArr:d,depth:_,split:U,useGroups:m,projection:E,workerKey:u},function(ie){try{var Me=new c.BufferGeometry;Object.keys(ie).forEach(function(de){Me.setAttribute(de,new c.BufferAttribute(ie[de].array,ie[de].itemSize))}),t.createMesh(Me,P),Te("")}catch(de){b.postMessage({delCache:!0,workerKey:u},function(){})}})}));case 34:case"end":return H.stop()}},o)}))()},i.getMaterial=function(t){var o=this,s=t.topColor,f=t.sideColor,p=t.sideMap,d=t.type,m=t.parameters,_=t.createCanvasObjectURL,y=t.split,g=t.maxAnisotropy;return new Promise(function(b){var u=p?document.createElement("img"):{src:"",onload:function(){},width:1024,height:1024};u.onload=function(){var E=y,x=document.createElement("canvas"),U=x.getContext("2d");x.height=u.height/(1-E),x.width=u.width,E&&s&&(U.fillStyle=s,U.fillRect(0,0,u.width,x.height*E)),p&&u instanceof HTMLImageElement?U.drawImage(u,0,x.height*E,u.width,u.height):f&&(U.fillStyle=f,U.fillRect(0,x.height*E,u.width,u.height)),_&&x.toBlob(function(me){console.log(URL.createObjectURL(me))});var P=new c.CanvasTexture(x);P.anisotropy=g||o.pencil.renderer.capabilities.getMaxAnisotropy();var se=new c[d||"MeshBasicMaterial"]((0,M.Z)({map:P},m||{}));b(se)},p?u.src=p:u instanceof HTMLImageElement||u.onload()})},i.setMaterialColor=function(t){var o=this;return(0,w.Z)(V().mark(function s(){var f,p,d,m,_,y,g,b,u,E,x;return V().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(f=o.options,p=f.materialOptions,d=f.cache,m=p.sideColor,_=p.sideMap,y=p.topColor,g=t.sideColor,b=t.topColor,!(b||g)){P.next=22;break}if(u="ExtrudePolygonMaterial:".concat(g||m||_||"").concat(b||y||""),!(d&&!d.get(u))){P.next=11;break}return d.init(u),P.next=9,o.getMaterial((0,M.Z)({},p,t));case 9:E=P.sent,d.set(u,E);case 11:if(!d){P.next=17;break}return P.next=14,d.get(u);case 14:P.t0=P.sent,P.next=20;break;case 17:return P.next=19,o.getMaterial((0,M.Z)({},p,t));case 19:P.t0=P.sent;case 20:x=P.t0,o.object3d.material=x;case 22:case"end":return P.stop()}},s)}))()},r}(v)})();var qt=Ae.Ei,er=Ae.Yo,tr=Ae.Ee,rr=Ae.x1,nr=Ae.VJ,ir=Ae.r7,ar=Ae.XA,or=Ae.NB,sr=Ae.xv,ur=Ae.nk;export{qt as ConicPolygon,er as ExtrudePolygon,tr as Image,rr as Line,nr as MeshLine,ir as MeshLineMaterial,ar as MeshLineRaycast,or as Node,sr as Text,ur as Video};
|
package/dist/plugins/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){var X={666:function(_){var g=function(v){"use strict";var S=Object.prototype,j=S.hasOwnProperty,d,T=typeof Symbol=="function"?Symbol:{},b=T.iterator||"@@iterator",O=T.asyncIterator||"@@asyncIterator",w=T.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(e){p=function(t,n,h){return t[n]=h}}function M(e,t,n,h){var c=t&&t.prototype instanceof G?t:G,L=Object.create(c.prototype),k=new f(h||[]);return L._invoke=r(e,n,k),L}v.wrap=M;function C(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(h){return{type:"throw",arg:h}}}var R="suspendedStart",Z="suspendedYield",W="executing",I="completed",E={};function G(){}function y(){}function m(){}var P={};p(P,b,function(){return this});var D=Object.getPrototypeOf,z=D&&D(D(A([])));z&&z!==S&&j.call(z,b)&&(P=z);var a=m.prototype=G.prototype=Object.create(P);y.prototype=m,p(a,"constructor",m),p(m,"constructor",y),y.displayName=p(m,w,"GeneratorFunction");function i(e){["next","throw","return"].forEach(function(t){p(e,t,function(n){return this._invoke(t,n)})})}v.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===y||(t.displayName||t.name)==="GeneratorFunction":!1},v.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,p(e,w,"GeneratorFunction")),e.prototype=Object.create(a),e},v.awrap=function(e){return{__await:e}};function o(e,t){function n(L,k,V,H){var N=C(e[L],e,k);if(N.type==="throw")H(N.arg);else{var $=N.arg,B=$.value;return B&&typeof B=="object"&&j.call(B,"__await")?t.resolve(B.__await).then(function(F){n("next",F,V,H)},function(F){n("throw",F,V,H)}):t.resolve(B).then(function(F){$.value=F,V($)},function(F){return n("throw",F,V,H)})}}var h;function c(L,k){function V(){return new t(function(H,N){n(L,k,H,N)})}return h=h?h.then(V,V):V()}this._invoke=c}i(o.prototype),p(o.prototype,O,function(){return this}),v.AsyncIterator=o,v.async=function(e,t,n,h,c){c===void 0&&(c=Promise);var L=new o(M(e,t,n,h),c);return v.isGeneratorFunction(t)?L:L.next().then(function(k){return k.done?k.value:L.next()})};function r(e,t,n){var h=R;return function(L,k){if(h===W)throw new Error("Generator is already running");if(h===I){if(L==="throw")throw k;return U()}for(n.method=L,n.arg=k;;){var V=n.delegate;if(V){var H=s(V,n);if(H){if(H===E)continue;return H}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(h===R)throw h=I,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);h=W;var N=C(e,t,n);if(N.type==="normal"){if(h=n.done?I:Z,N.arg===E)continue;return{value:N.arg,done:n.done}}else N.type==="throw"&&(h=I,n.method="throw",n.arg=N.arg)}}}function s(e,t){var n=e.iterator[t.method];if(n===d){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=d,s(e,t),t.method==="throw"))return E;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return E}var h=C(n,e.iterator,t.arg);if(h.type==="throw")return t.method="throw",t.arg=h.arg,t.delegate=null,E;var c=h.arg;if(!c)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,E;if(c.done)t[e.resultName]=c.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=d);else return c;return t.delegate=null,E}i(a),p(a,w,"Generator"),p(a,b,function(){return this}),p(a,"toString",function(){return"[object Generator]"});function l(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function u(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(l,this),this.reset(!0)}v.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function h(){for(;t.length;){var c=t.pop();if(c in e)return h.value=c,h.done=!1,h}return h.done=!0,h}};function A(e){if(e){var t=e[b];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,h=function c(){for(;++n<e.length;)if(j.call(e,n))return c.value=e[n],c.done=!1,c;return c.value=d,c.done=!0,c};return h.next=h}}return{next:U}}v.values=A;function U(){return{value:d,done:!0}}return f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=d,this.done=!1,this.delegate=null,this.method="next",this.arg=d,this.tryEntries.forEach(u),!e)for(var t in this)t.charAt(0)==="t"&&j.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=d)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(H,N){return L.type="throw",L.arg=e,t.next=H,N&&(t.method="next",t.arg=d),!!N}for(var h=this.tryEntries.length-1;h>=0;--h){var c=this.tryEntries[h],L=c.completion;if(c.tryLoc==="root")return n("end");if(c.tryLoc<=this.prev){var k=j.call(c,"catchLoc"),V=j.call(c,"finallyLoc");if(k&&V){if(this.prev<c.catchLoc)return n(c.catchLoc,!0);if(this.prev<c.finallyLoc)return n(c.finallyLoc)}else if(k){if(this.prev<c.catchLoc)return n(c.catchLoc,!0)}else if(V){if(this.prev<c.finallyLoc)return n(c.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n];if(h.tryLoc<=this.prev&&j.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var c=h;break}}c&&(e==="break"||e==="continue")&&c.tryLoc<=t&&t<=c.finallyLoc&&(c=null);var L=c?c.completion:{};return L.type=e,L.arg=t,c?(this.method="next",this.next=c.finallyLoc,E):this.complete(L)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),E},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),u(n),E}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var h=n.completion;if(h.type==="throw"){var c=h.arg;u(n)}return c}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=d),E}},v}(_.exports);try{regeneratorRuntime=g}catch(v){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(_,g,v){"use strict";v.d(g,{makePromiseCreator:function(){return S.Z}});var S=v(282),j=v(666),d=v.n(j),T=null,b=v(644);function O(E){if(E.material){var G=Array.isArray(E.material)?E.material:[E.material];G.forEach(function(y){var m,P;(m=y.color)===null||m===void 0||m.convertSRGBToLinear(),(P=y.emissive)===null||P===void 0||P.convertSRGBToLinear(),y.map&&(y.map.encoding=THREE.sRGBEncoding),y.emissiveMap&&(y.emissiveMap.encoding=THREE.sRGBEncoding)})}}var w=v(568),p=v(924),M=v(360),C=v(484),R=null,Z=null,W=function(){var E=(0,w.Z)(d().mark(function G(y,m){var P,D,z,a,i,o,r,s,l;return d().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return P=m.type,D=P===void 0?"blob":P,z=m.version,a=z===void 0?"1":z,f.next=4,(0,M.get)(y);case 4:if(o=f.sent,!(o&&o[a])){f.next=9;break}i=o[a],f.next=15;break;case 9:return f.next=11,(0,C.Z)(fetch(y).then(function(A){if(A.ok)return A[D]();throw new Error}));case 11:r=f.sent,s=r.res,l=r.err,l||(i=s,(0,M.set)(y,(0,p.Z)({},a,s)));case 15:return f.abrupt("return",i?{url:D==="json"?y:URL.createObjectURL(i),store:i}:{url:y});case 16:case"end":return f.stop()}},G)}));return function(y,m){return E.apply(this,arguments)}}(),I=v(705)},282:function(_,g,v){"use strict";v.d(g,{Z:function(){return j}});var S=v(484);function j(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b={};return b.promise=new Promise(function(O,w){b.resolve=O,b.reject=w}),d&&(b.promise=(0,S.Z)(b.promise,T)),b}},484:function(_,g,v){"use strict";v.d(g,{Z:function(){return j}});var S=v(42);function j(d){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return d.then(function(b){return(0,S.Z)({err:null,res:b},T)}).catch(function(b){return(0,S.Z)({err:b,res:void 0},T)})}},705:function(_,g,v){"use strict";var S=v(644),j=v.n(S),d=new Map,T=function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(w,p,M,C,R){var Z=p[M*3],W=p[M*3+1],I=p[C*3],E=p[C*3+1],G=p[R*3],y=p[R*3+1],m;if(d.has(w))m=d.get(w);else{var P=O.box3||new THREE.Box3;if(!O.box3){var D=w.parameters.shapes.getPoints();P.setFromArray(D.map(function(r){return[r.x,r.y,0]}).flat())}var z=P.getSize(new THREE.Vector3);O.split&&(z.y/=O.split),m={box:P,size:z},d.set(w,m)}var a=m.box,i=m.size,o=O.split?1-O.split:0;return[new THREE.Vector2((Z-a.min.x)/i.x,(W-a.min.y)/i.y+o),new THREE.Vector2((I-a.min.x)/i.x,(E-a.min.y)/i.y+o),new THREE.Vector2((G-a.min.x)/i.x,(y-a.min.y)/i.y+o)]},generateSideWallUV:function(w,p,M,C,R,Z){var W=p[M*3],I=p[M*3+1],E=p[M*3+2],G=p[C*3],y=p[C*3+1],m=p[C*3+2],P=p[R*3],D=p[R*3+1],z=p[R*3+2],a=p[Z*3],i=p[Z*3+1],o=p[Z*3+2],r;if(d.has(p))r=d.get(p);else{var s=new THREE.Box3;s.setFromArray(p);var l=s.getSize(new THREE.Vector3);O.split&&(l.z/=1-O.split),r={box:s,size:l},d.set(p,r)}var u=r.box,f=r.size;return Math.abs(I-y)<Math.abs(W-G)?[new THREE.Vector2((W-u.min.x)/f.x,(E-u.min.z)/f.z),new THREE.Vector2((G-u.min.x)/f.x,(m-u.min.z)/f.z),new THREE.Vector2((P-u.min.x)/f.x,(z-u.min.z)/f.z),new THREE.Vector2((a-u.min.x)/f.x,(o-u.min.z)/f.z)]:[new THREE.Vector2((I-u.min.y)/f.y,(E-u.min.z)/f.z),new THREE.Vector2((y-u.min.y)/f.y,(m-u.min.z)/f.z),new THREE.Vector2((D-u.min.y)/f.y,(z-u.min.z)/f.z),new THREE.Vector2((i-u.min.y)/f.y,(o-u.min.z)/f.z)]}}},b=function(){d.clear()}},360:function(_){"use strict";_.exports=require("idb-keyval")},644:function(_){"use strict";_.exports=require("three")},568:function(_,g,v){"use strict";v.d(g,{Z:function(){return j}});function S(d,T,b,O,w,p,M){try{var C=d[p](M),R=C.value}catch(Z){b(Z);return}C.done?T(R):Promise.resolve(R).then(O,w)}function j(d){return function(){var T=this,b=arguments;return new Promise(function(O,w){var p=d.apply(T,b);function M(R){S(p,O,w,M,C,"next",R)}function C(R){S(p,O,w,M,C,"throw",R)}M(void 0)})}}},924:function(_,g,v){"use strict";v.d(g,{Z:function(){return S}});function S(j,d,T){return d in j?Object.defineProperty(j,d,{value:T,enumerable:!0,configurable:!0,writable:!0}):j[d]=T,j}},42:function(_,g,v){"use strict";v.d(g,{Z:function(){return j}});var S=v(924);function j(d){for(var T=1;T<arguments.length;T++){var b=arguments[T]!=null?arguments[T]:{},O=Object.keys(b);typeof Object.getOwnPropertySymbols=="function"&&(O=O.concat(Object.getOwnPropertySymbols(b).filter(function(w){return Object.getOwnPropertyDescriptor(b,w).enumerable}))),O.forEach(function(w){(0,S.Z)(d,w,b[w])})}return d}}},Y={};function x(_){var g=Y[_];if(g!==void 0)return g.exports;var v=Y[_]={exports:{}};return X[_](v,v.exports,x),v.exports}(function(){x.n=function(_){var g=_&&_.__esModule?function(){return _.default}:function(){return _};return x.d(g,{a:g}),g}})(),function(){x.d=function(_,g){for(var v in g)x.o(g,v)&&!x.o(_,v)&&Object.defineProperty(_,v,{enumerable:!0,get:g[v]})}}(),function(){x.o=function(_,g){return Object.prototype.hasOwnProperty.call(_,g)}}(),function(){x.r=function(_){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})}}();var K={};(function(){"use strict";x.r(K),x.d(K,{Cache:function(){return v},Data:function(){return y},Draw:function(){return G},Wk:function(){return z}});function _(a,i){if(!(a instanceof i))throw new TypeError("Cannot call a class as a function")}var g=x(584),v=function(){"use strict";function a(){_(this,a),this.cache=new Map}var i=a.prototype;return i.install=function(){},i.init=function(r){var s=(0,g.makePromiseCreator)();this.cache.set(r,s)},i.get=function(r){var s;return(s=this.cache.get(r))===null||s===void 0?void 0:s.promise},i.set=function(r,s){var l=this.cache.get(r);l?l.resolve(s):console.warn("init cache first")},i.dispose=function(){this.cache.forEach(function(r,s){r.reject("stop set cache:".concat(s))}),this.cache.clear()},a}(),S=x(568);function j(a,i){for(var o=0;o<i.length;o++){var r=i[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function d(a,i,o){return i&&j(a.prototype,i),o&&j(a,o),a}function T(a){if(Array.isArray(a))return a}function b(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function O(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(a,i){(i==null||i>a.length)&&(i=a.length);for(var o=0,r=new Array(i);o<i;o++)r[o]=a[o];return r}function p(a,i){if(!!a){if(typeof a=="string")return w(a,i);var o=Object.prototype.toString.call(a).slice(8,-1);if(o==="Object"&&a.constructor&&(o=a.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return w(a,i)}}function M(a,i){return T(a)||b(a,i)||p(a,i)||O()}function C(a){if(Array.isArray(a))return w(a)}function R(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Z(a){return C(a)||b(a)||p(a)||R()}var W=x(666),I=x.n(W),E=x(644),G=function(){"use strict";function a(o){_(this,a),this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=o}var i=a.prototype;return i.install=function(r){this.pencil=r,this.initObjectFactories()},i.initObjectFactories=function(){var r=this,s=this.objects_;Object.keys(s).forEach(function(l){var u=function(){function f(){_(this,f)}var A=f.prototype;return A.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new s[l](e)},f}();r.objectNamesToFactories.set(l,u)})},i.getObject=function(r,s){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var l=(s||{}).key,u="".concat(r).concat(l?"#".concat(l):""),f=this.objects.get(u);return f},i.getAllObject=function(r,s){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var l=(s||{}).key,u="".concat(r).concat(l?"#".concat(l):""),f=[];return this.objects.forEach(function(A,U){(U.startsWith("".concat(u,"#"))||U===u)&&f.push(A)}),f},i.draw=function(r,s,l){var u=this;return(0,S.Z)(I().mark(function f(){var A,U,e,t,n,h,c;return I().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(A=u.objectNamesToFactories.get(r),!A){k.next=15;break}return U=(s||{}).key,e="".concat(r).concat(U?"#".concat(U):""),u.objects.has(e)&&(t=E.MathUtils.generateUUID(),e+="#".concat(t)),n=(s==null?void 0:s.target)||l,typeof n=="string"?h=u.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?h=n:h=u.pencil.scene,c=new A().create(s),c.pencil=u.pencil,c.key=e,u.objects.set(e,c),k.next=14,u.addMesh(c,h);case 14:return k.abrupt("return",c);case 15:throw new Error("Unrecognized:".concat(r));case 16:case"end":return k.stop()}},f)}))()},i.addMesh=function(r,s){return(0,S.Z)(I().mark(function l(){return I().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,s.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return f.stop()}},l)}))()},i.erase=function(){for(var r=arguments.length,s=new Array(r),l=0;l<r;l++)s[l]=arguments[l];var u=this;Z(s).forEach(function(f){var A=[];if(typeof f=="string"){var U,e=M(f.split("#"),2),t=e[0],n=e[1];(U=A).push.apply(U,Z(u.getAllObject(t,{key:n})))}else A.push(f);A.forEach(function(h){u.removeMesh(h)})})},i.removeMesh=function(r){var s=this,l=r.parent;r.object3d&&l.remove(r.object3d),r.traverse(function(u){u.visible=!1,u.dispose(),s.objects.delete(u.key)})},i.update=function(r,s){this.objects.forEach(function(l){l.update(r,s)})},i.setSize=function(r,s){this.objects.forEach(function(l){l.resize(r,s)})},i.dispose=function(){this.objects.forEach(function(r,s){r.dispose(),r.pm.reject("stop draw:".concat(s))}),this.objects.clear(),this.objectNamesToFactories.clear()},d(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(s){r.push(s.pm.promise)}),r}}]),a}(),y=function(){"use strict";function a(){_(this,a),this.data={}}var i=a.prototype;return i.install=function(){},i.setData=function(r,s){var l,u;this.data[r]=s,(u=(l=this).cb)===null||u===void 0||u.call(l,r)},i.runAll=function(){var r=this;Object.keys(this.data).forEach(function(s){var l,u;(u=(l=r).cb)===null||u===void 0||u.call(l,s)})},i.dispose=function(){this.data={},this.cb=void 0},a}(),m=x(924),P=x(42),D=x(360),z=function(){"use strict";function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_(this,a),this.messageList=[],this.options=(0,P.Z)({},{cache:!1,cacheVersion:"1"},o)}var i=a.prototype;return i.install=function(){},i.init=function(r,s){var l=this,u=this.options,f=u.cache,A=u.cacheVersion;this.workerList=Array.from({length:s},function(U,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var h=n.data,c=h.res,L=h.uuid,k=l.messageList.find(function(V){var H=V.uuid;return L===H});k==null||k.cb(c),l.workerList[e].inUse=!1,l.checkMessage(),f&&(0,D.set)(L,(0,m.Z)({},A,c))},{worker:t,inUse:!1}})},i.postMessage=function(r,s){var l=this,u=this.options,f=u.cache,A=u.cacheVersion;if(f&&!r.workerKey){console.warn("worker cache need workerKey");return}var U=r.workerKey||E.MathUtils.generateUUID();(f?(0,D.get)(U):Promise.resolve()).then(function(e){e&&e[A]?s(e[A]):(l.messageList.push({req:r,cb:s,uuid:U,inUse:!1}),l.checkMessage())})},i.checkMessage=function(){var r=this.workerList.find(function(l){var u=l.inUse;return!u});if(r){var s=this.messageList.find(function(l){var u=l.inUse;return!u});s&&(s.inUse=!0,r.inUse=!0,r.worker.postMessage({req:s.req,uuid:s.uuid}))}},i.dispose=function(){this.workerList.forEach(function(r){var s=r.worker;s.terminate()}),this.workerList=[],this.messageList=[]},a}()})(),module.exports=K})();
|
|
1
|
+
(function(){var X={666:function(_){var g=function(p){"use strict";var M=Object.prototype,j=M.hasOwnProperty,d,T=typeof Symbol=="function"?Symbol:{},b=T.iterator||"@@iterator",L=T.asyncIterator||"@@asyncIterator",w=T.toStringTag||"@@toStringTag";function v(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{v({},"")}catch(e){v=function(t,n,h){return t[n]=h}}function S(e,t,n,h){var c=t&&t.prototype instanceof D?t:D,O=Object.create(c.prototype),k=new f(h||[]);return O._invoke=r(e,n,k),O}p.wrap=S;function C(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(h){return{type:"throw",arg:h}}}var R="suspendedStart",Z="suspendedYield",W="executing",I="completed",E={};function D(){}function y(){}function m(){}var P={};v(P,b,function(){return this});var G=Object.getPrototypeOf,z=G&&G(G(A([])));z&&z!==M&&j.call(z,b)&&(P=z);var a=m.prototype=D.prototype=Object.create(P);y.prototype=m,v(a,"constructor",m),v(m,"constructor",y),y.displayName=v(m,w,"GeneratorFunction");function i(e){["next","throw","return"].forEach(function(t){v(e,t,function(n){return this._invoke(t,n)})})}p.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===y||(t.displayName||t.name)==="GeneratorFunction":!1},p.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,v(e,w,"GeneratorFunction")),e.prototype=Object.create(a),e},p.awrap=function(e){return{__await:e}};function o(e,t){function n(O,k,V,H){var N=C(e[O],e,k);if(N.type==="throw")H(N.arg);else{var $=N.arg,B=$.value;return B&&typeof B=="object"&&j.call(B,"__await")?t.resolve(B.__await).then(function(F){n("next",F,V,H)},function(F){n("throw",F,V,H)}):t.resolve(B).then(function(F){$.value=F,V($)},function(F){return n("throw",F,V,H)})}}var h;function c(O,k){function V(){return new t(function(H,N){n(O,k,H,N)})}return h=h?h.then(V,V):V()}this._invoke=c}i(o.prototype),v(o.prototype,L,function(){return this}),p.AsyncIterator=o,p.async=function(e,t,n,h,c){c===void 0&&(c=Promise);var O=new o(S(e,t,n,h),c);return p.isGeneratorFunction(t)?O:O.next().then(function(k){return k.done?k.value:O.next()})};function r(e,t,n){var h=R;return function(O,k){if(h===W)throw new Error("Generator is already running");if(h===I){if(O==="throw")throw k;return U()}for(n.method=O,n.arg=k;;){var V=n.delegate;if(V){var H=s(V,n);if(H){if(H===E)continue;return H}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(h===R)throw h=I,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);h=W;var N=C(e,t,n);if(N.type==="normal"){if(h=n.done?I:Z,N.arg===E)continue;return{value:N.arg,done:n.done}}else N.type==="throw"&&(h=I,n.method="throw",n.arg=N.arg)}}}function s(e,t){var n=e.iterator[t.method];if(n===d){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=d,s(e,t),t.method==="throw"))return E;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return E}var h=C(n,e.iterator,t.arg);if(h.type==="throw")return t.method="throw",t.arg=h.arg,t.delegate=null,E;var c=h.arg;if(!c)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,E;if(c.done)t[e.resultName]=c.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=d);else return c;return t.delegate=null,E}i(a),v(a,w,"Generator"),v(a,b,function(){return this}),v(a,"toString",function(){return"[object Generator]"});function l(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function u(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(l,this),this.reset(!0)}p.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function h(){for(;t.length;){var c=t.pop();if(c in e)return h.value=c,h.done=!1,h}return h.done=!0,h}};function A(e){if(e){var t=e[b];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,h=function c(){for(;++n<e.length;)if(j.call(e,n))return c.value=e[n],c.done=!1,c;return c.value=d,c.done=!0,c};return h.next=h}}return{next:U}}p.values=A;function U(){return{value:d,done:!0}}return f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=d,this.done=!1,this.delegate=null,this.method="next",this.arg=d,this.tryEntries.forEach(u),!e)for(var t in this)t.charAt(0)==="t"&&j.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=d)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(H,N){return O.type="throw",O.arg=e,t.next=H,N&&(t.method="next",t.arg=d),!!N}for(var h=this.tryEntries.length-1;h>=0;--h){var c=this.tryEntries[h],O=c.completion;if(c.tryLoc==="root")return n("end");if(c.tryLoc<=this.prev){var k=j.call(c,"catchLoc"),V=j.call(c,"finallyLoc");if(k&&V){if(this.prev<c.catchLoc)return n(c.catchLoc,!0);if(this.prev<c.finallyLoc)return n(c.finallyLoc)}else if(k){if(this.prev<c.catchLoc)return n(c.catchLoc,!0)}else if(V){if(this.prev<c.finallyLoc)return n(c.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n];if(h.tryLoc<=this.prev&&j.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var c=h;break}}c&&(e==="break"||e==="continue")&&c.tryLoc<=t&&t<=c.finallyLoc&&(c=null);var O=c?c.completion:{};return O.type=e,O.arg=t,c?(this.method="next",this.next=c.finallyLoc,E):this.complete(O)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),E},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),u(n),E}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var h=n.completion;if(h.type==="throw"){var c=h.arg;u(n)}return c}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=d),E}},p}(_.exports);try{regeneratorRuntime=g}catch(p){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(_,g,p){"use strict";p.d(g,{makePromiseCreator:function(){return M.Z}});var M=p(282),j=p(666),d=p.n(j),T=null,b=p(644);function L(E){if(E.material){var D=Array.isArray(E.material)?E.material:[E.material];D.forEach(function(y){var m,P;(m=y.color)===null||m===void 0||m.convertSRGBToLinear(),(P=y.emissive)===null||P===void 0||P.convertSRGBToLinear(),y.map&&(y.map.encoding=THREE.sRGBEncoding),y.emissiveMap&&(y.emissiveMap.encoding=THREE.sRGBEncoding)})}}var w=p(568),v=p(924),S=p(360),C=p(484),R=null,Z=null,W=function(){var E=(0,w.Z)(d().mark(function D(y,m){var P,G,z,a,i,o,r,s,l;return d().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return P=m.type,G=P===void 0?"blob":P,z=m.version,a=z===void 0?"1":z,f.next=4,(0,S.get)(y);case 4:if(o=f.sent,!(o&&o[a])){f.next=9;break}i=o[a],f.next=15;break;case 9:return f.next=11,(0,C.Z)(fetch(y).then(function(A){if(A.ok)return A[G]();throw new Error}));case 11:r=f.sent,s=r.res,l=r.err,l||(i=s,(0,S.set)(y,(0,v.Z)({},a,s)));case 15:return f.abrupt("return",i?{url:G==="json"?y:URL.createObjectURL(i),store:i}:{url:y});case 16:case"end":return f.stop()}},D)}));return function(y,m){return E.apply(this,arguments)}}(),I=p(705)},282:function(_,g,p){"use strict";p.d(g,{Z:function(){return j}});var M=p(484);function j(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b={};return b.promise=new Promise(function(L,w){b.resolve=L,b.reject=w}),d&&(b.promise=(0,M.Z)(b.promise,T)),b}},484:function(_,g,p){"use strict";p.d(g,{Z:function(){return j}});var M=p(42);function j(d){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return d.then(function(b){return(0,M.Z)({err:null,res:b},T)}).catch(function(b){return(0,M.Z)({err:b,res:void 0},T)})}},705:function(_,g,p){"use strict";var M=p(644),j=p.n(M),d=new Map,T=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(w,v,S,C,R){var Z=v[S*3],W=v[S*3+1],I=v[C*3],E=v[C*3+1],D=v[R*3],y=v[R*3+1],m;if(d.has(w))m=d.get(w);else{var P=L.box3||new THREE.Box3;if(!L.box3){var G=w.parameters.shapes.getPoints();P.setFromArray(G.map(function(r){return[r.x,r.y,0]}).flat())}var z=P.getSize(new THREE.Vector3);L.split&&(z.y/=L.split),m={box:P,size:z},d.set(w,m)}var a=m.box,i=m.size,o=L.split?1-L.split:0;return[new THREE.Vector2((Z-a.min.x)/i.x,(W-a.min.y)/i.y+o),new THREE.Vector2((I-a.min.x)/i.x,(E-a.min.y)/i.y+o),new THREE.Vector2((D-a.min.x)/i.x,(y-a.min.y)/i.y+o)]},generateSideWallUV:function(w,v,S,C,R,Z){var W=v[S*3],I=v[S*3+1],E=v[S*3+2],D=v[C*3],y=v[C*3+1],m=v[C*3+2],P=v[R*3],G=v[R*3+1],z=v[R*3+2],a=v[Z*3],i=v[Z*3+1],o=v[Z*3+2],r;if(d.has(v))r=d.get(v);else{var s=new THREE.Box3;s.setFromArray(v);var l=s.getSize(new THREE.Vector3);L.split&&(l.z/=1-L.split),r={box:s,size:l},d.set(v,r)}var u=r.box,f=r.size;return Math.abs(I-y)<Math.abs(W-D)?[new THREE.Vector2((W-u.min.x)/f.x,(E-u.min.z)/f.z),new THREE.Vector2((D-u.min.x)/f.x,(m-u.min.z)/f.z),new THREE.Vector2((P-u.min.x)/f.x,(z-u.min.z)/f.z),new THREE.Vector2((a-u.min.x)/f.x,(o-u.min.z)/f.z)]:[new THREE.Vector2((I-u.min.y)/f.y,(E-u.min.z)/f.z),new THREE.Vector2((y-u.min.y)/f.y,(m-u.min.z)/f.z),new THREE.Vector2((G-u.min.y)/f.y,(z-u.min.z)/f.z),new THREE.Vector2((i-u.min.y)/f.y,(o-u.min.z)/f.z)]}}},b=function(){d.clear()}},360:function(_){"use strict";_.exports=require("idb-keyval")},644:function(_){"use strict";_.exports=require("three")},568:function(_,g,p){"use strict";p.d(g,{Z:function(){return j}});function M(d,T,b,L,w,v,S){try{var C=d[v](S),R=C.value}catch(Z){b(Z);return}C.done?T(R):Promise.resolve(R).then(L,w)}function j(d){return function(){var T=this,b=arguments;return new Promise(function(L,w){var v=d.apply(T,b);function S(R){M(v,L,w,S,C,"next",R)}function C(R){M(v,L,w,S,C,"throw",R)}S(void 0)})}}},924:function(_,g,p){"use strict";p.d(g,{Z:function(){return M}});function M(j,d,T){return d in j?Object.defineProperty(j,d,{value:T,enumerable:!0,configurable:!0,writable:!0}):j[d]=T,j}},42:function(_,g,p){"use strict";p.d(g,{Z:function(){return j}});var M=p(924);function j(d){for(var T=1;T<arguments.length;T++){var b=arguments[T]!=null?arguments[T]:{},L=Object.keys(b);typeof Object.getOwnPropertySymbols=="function"&&(L=L.concat(Object.getOwnPropertySymbols(b).filter(function(w){return Object.getOwnPropertyDescriptor(b,w).enumerable}))),L.forEach(function(w){(0,M.Z)(d,w,b[w])})}return d}}},Y={};function x(_){var g=Y[_];if(g!==void 0)return g.exports;var p=Y[_]={exports:{}};return X[_](p,p.exports,x),p.exports}(function(){x.n=function(_){var g=_&&_.__esModule?function(){return _.default}:function(){return _};return x.d(g,{a:g}),g}})(),function(){x.d=function(_,g){for(var p in g)x.o(g,p)&&!x.o(_,p)&&Object.defineProperty(_,p,{enumerable:!0,get:g[p]})}}(),function(){x.o=function(_,g){return Object.prototype.hasOwnProperty.call(_,g)}}(),function(){x.r=function(_){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})}}();var K={};(function(){"use strict";x.r(K),x.d(K,{Cache:function(){return p},Data:function(){return y},Draw:function(){return D},Wk:function(){return z}});function _(a,i){if(!(a instanceof i))throw new TypeError("Cannot call a class as a function")}var g=x(584),p=function(){"use strict";function a(){_(this,a),this.cache=new Map}var i=a.prototype;return i.install=function(){},i.init=function(r){var s=(0,g.makePromiseCreator)();this.cache.set(r,s)},i.get=function(r){var s;return(s=this.cache.get(r))===null||s===void 0?void 0:s.promise},i.set=function(r,s){var l=this.cache.get(r);l?l.resolve(s):console.warn("init cache first")},i.dispose=function(){this.cache.forEach(function(r,s){r.reject("stop set cache:".concat(s))}),this.cache.clear()},a}(),M=x(568);function j(a,i){for(var o=0;o<i.length;o++){var r=i[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function d(a,i,o){return i&&j(a.prototype,i),o&&j(a,o),a}function T(a){if(Array.isArray(a))return a}function b(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function L(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(a,i){(i==null||i>a.length)&&(i=a.length);for(var o=0,r=new Array(i);o<i;o++)r[o]=a[o];return r}function v(a,i){if(!!a){if(typeof a=="string")return w(a,i);var o=Object.prototype.toString.call(a).slice(8,-1);if(o==="Object"&&a.constructor&&(o=a.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return w(a,i)}}function S(a,i){return T(a)||b(a,i)||v(a,i)||L()}function C(a){if(Array.isArray(a))return w(a)}function R(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Z(a){return C(a)||b(a)||v(a)||R()}var W=x(666),I=x.n(W),E=x(644),D=function(){"use strict";function a(o){_(this,a),this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=o}var i=a.prototype;return i.install=function(r){this.pencil=r,this.initObjectFactories()},i.initObjectFactories=function(){var r=this,s=this.objects_;Object.keys(s).forEach(function(l){var u=function(){function f(){_(this,f)}var A=f.prototype;return A.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new s[l](e)},f}();r.objectNamesToFactories.set(l,u)})},i.getObject=function(r,s){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var l=(s||{}).key,u="".concat(r).concat(l?"#".concat(l):""),f=this.objects.get(u);return f},i.getAllObject=function(r,s){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var l=(s||{}).key,u="".concat(r).concat(l?"#".concat(l):""),f=[];return this.objects.forEach(function(A,U){(U.startsWith("".concat(u,"#"))||U===u)&&f.push(A)}),f},i.draw=function(r,s,l){var u=this;return(0,M.Z)(I().mark(function f(){var A,U,e,t,n,h,c;return I().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(A=u.objectNamesToFactories.get(r),!A){k.next=15;break}return U=(s||{}).key,e="".concat(r).concat(U?"#".concat(U):""),u.objects.has(e)&&(t=E.MathUtils.generateUUID(),e+="#".concat(t)),n=(s==null?void 0:s.target)||l,typeof n=="string"?h=u.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?h=n:h=u.pencil.scene,c=new A().create(s),c.pencil=u.pencil,c.key=e,u.objects.set(e,c),k.next=14,u.addMesh(c,h);case 14:return k.abrupt("return",c);case 15:throw new Error("Unrecognized:".concat(r));case 16:case"end":return k.stop()}},f)}))()},i.addMesh=function(r,s){return(0,M.Z)(I().mark(function l(){return I().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,s.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return f.stop()}},l)}))()},i.erase=function(){for(var r=arguments.length,s=new Array(r),l=0;l<r;l++)s[l]=arguments[l];var u=this;Z(s).forEach(function(f){var A=[];if(typeof f=="string"){var U,e=S(f.split("#"),2),t=e[0],n=e[1];(U=A).push.apply(U,Z(u.getAllObject(t,{key:n})))}else A.push(f);A.forEach(function(h){u.removeMesh(h)})})},i.removeMesh=function(r){var s=this,l=r.parent;r.object3d&&l.remove(r.object3d),r.traverse(function(u){u.visible=!1,u.dispose(),s.objects.delete(u.key)})},i.update=function(r,s){this.objects.forEach(function(l){l.update(r,s)})},i.setSize=function(r,s){this.objects.forEach(function(l){l.resize(r,s)})},i.dispose=function(){this.objects.forEach(function(r,s){r.dispose(),r.pm.reject("stop draw:".concat(s))}),this.objects.clear(),this.objectNamesToFactories.clear()},d(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(s){r.push(s.pm.promise)}),r}}]),a}(),y=function(){"use strict";function a(){_(this,a),this.data={}}var i=a.prototype;return i.install=function(){},i.setData=function(r,s){var l,u;this.data[r]=s,(u=(l=this).cb)===null||u===void 0||u.call(l,r)},i.runAll=function(){var r=this;Object.keys(this.data).forEach(function(s){var l,u;(u=(l=r).cb)===null||u===void 0||u.call(l,s)})},i.dispose=function(){this.data={},this.cb=void 0},a}(),m=x(924),P=x(42),G=x(360),z=function(){"use strict";function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_(this,a),this.messageList=[],this.options=(0,P.Z)({},{cache:!1,cacheVersion:"1"},o)}var i=a.prototype;return i.install=function(){},i.init=function(r,s){var l=this,u=this.options,f=u.cache,A=u.cacheVersion;this.workerList=Array.from({length:s},function(U,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var h=n.data,c=h.res,O=h.uuid,k=l.messageList.find(function(V){var H=V.uuid;return O===H});k==null||k.cb(c),l.workerList[e].inUse=!1,l.checkMessage(),f&&(0,G.set)(O,(0,m.Z)({},A,c))},{worker:t,inUse:!1}})},i.postMessage=function(r,s){var l=this,u=this.options,f=u.cache,A=u.cacheVersion;if(f&&!r.workerKey){console.warn("worker cache need workerKey");return}if(f&&r.workerKey&&r.delCache){console.warn("worker cache del: ".concat(r.workerKey)),(0,G.del)(r.workerKey);return}var U=r.workerKey||E.MathUtils.generateUUID();(f?(0,G.get)(U):Promise.resolve()).then(function(e){e&&e[A]?s(e[A]):(l.messageList.push({req:r,cb:s,uuid:U,inUse:!1}),l.checkMessage())}).catch(function(){console.warn("err:worker cache"),l.messageList.push({req:r,cb:s,uuid:U,inUse:!1}),l.checkMessage()})},i.checkMessage=function(){var r=this.workerList.find(function(l){var u=l.inUse;return!u});if(r){var s=this.messageList.find(function(l){var u=l.inUse;return!u});s&&(s.inUse=!0,r.inUse=!0,r.worker.postMessage({req:s.req,uuid:s.uuid}))}},i.dispose=function(){this.workerList.forEach(function(r){var s=r.worker;s.terminate()}),this.workerList=[],this.messageList=[]},a}()})(),module.exports=K})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as X from"idb-keyval";import*as J from"three";var Q={666:function(b){var g=function(l){"use strict";var T=Object.prototype,m=T.hasOwnProperty,v,w=typeof Symbol=="function"?Symbol:{},y=w.iterator||"@@iterator",P=w.asyncIterator||"@@asyncIterator",p=w.toStringTag||"@@toStringTag";function E(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{E({},"")}catch(e){E=function(t,n,h){return t[n]=h}}function S(e,t,n,h){var f=t&&t.prototype instanceof G?t:G,O=Object.create(f.prototype),L=new d(h||[]);return O._invoke=r(e,n,L),O}l.wrap=S;function C(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(h){return{type:"throw",arg:h}}}var R="suspendedStart",W="suspendedYield",Z="executing",H="completed",j={};function G(){}function _(){}function k(){}var M={};E(M,y,function(){return this});var z=Object.getPrototypeOf,x=z&&z(z(A([])));x&&x!==T&&m.call(x,y)&&(M=x);var a=k.prototype=G.prototype=Object.create(M);_.prototype=k,E(a,"constructor",k),E(k,"constructor",_),_.displayName=E(k,p,"GeneratorFunction");function i(e){["next","throw","return"].forEach(function(t){E(e,t,function(n){return this._invoke(t,n)})})}l.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===_||(t.displayName||t.name)==="GeneratorFunction":!1},l.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,E(e,p,"GeneratorFunction")),e.prototype=Object.create(a),e},l.awrap=function(e){return{__await:e}};function o(e,t){function n(O,L,D,I){var N=C(e[O],e,L);if(N.type==="throw")I(N.arg);else{var $=N.arg,F=$.value;return F&&typeof F=="object"&&m.call(F,"__await")?t.resolve(F.__await).then(function(B){n("next",B,D,I)},function(B){n("throw",B,D,I)}):t.resolve(F).then(function(B){$.value=B,D($)},function(B){return n("throw",B,D,I)})}}var h;function f(O,L){function D(){return new t(function(I,N){n(O,L,I,N)})}return h=h?h.then(D,D):D()}this._invoke=f}i(o.prototype),E(o.prototype,P,function(){return this}),l.AsyncIterator=o,l.async=function(e,t,n,h,f){f===void 0&&(f=Promise);var O=new o(S(e,t,n,h),f);return l.isGeneratorFunction(t)?O:O.next().then(function(L){return L.done?L.value:O.next()})};function r(e,t,n){var h=R;return function(O,L){if(h===Z)throw new Error("Generator is already running");if(h===H){if(O==="throw")throw L;return U()}for(n.method=O,n.arg=L;;){var D=n.delegate;if(D){var I=c(D,n);if(I){if(I===j)continue;return I}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(h===R)throw h=H,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);h=Z;var N=C(e,t,n);if(N.type==="normal"){if(h=n.done?H:W,N.arg===j)continue;return{value:N.arg,done:n.done}}else N.type==="throw"&&(h=H,n.method="throw",n.arg=N.arg)}}}function c(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=v,c(e,t),t.method==="throw"))return j;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return j}var h=C(n,e.iterator,t.arg);if(h.type==="throw")return t.method="throw",t.arg=h.arg,t.delegate=null,j;var f=h.arg;if(!f)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,j;if(f.done)t[e.resultName]=f.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=v);else return f;return t.delegate=null,j}i(a),E(a,p,"Generator"),E(a,y,function(){return this}),E(a,"toString",function(){return"[object Generator]"});function s(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function u(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function d(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(s,this),this.reset(!0)}l.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function h(){for(;t.length;){var f=t.pop();if(f in e)return h.value=f,h.done=!1,h}return h.done=!0,h}};function A(e){if(e){var t=e[y];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,h=function f(){for(;++n<e.length;)if(m.call(e,n))return f.value=e[n],f.done=!1,f;return f.value=v,f.done=!0,f};return h.next=h}}return{next:U}}l.values=A;function U(){return{value:v,done:!0}}return d.prototype={constructor:d,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(u),!e)for(var t in this)t.charAt(0)==="t"&&m.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=v)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(I,N){return O.type="throw",O.arg=e,t.next=I,N&&(t.method="next",t.arg=v),!!N}for(var h=this.tryEntries.length-1;h>=0;--h){var f=this.tryEntries[h],O=f.completion;if(f.tryLoc==="root")return n("end");if(f.tryLoc<=this.prev){var L=m.call(f,"catchLoc"),D=m.call(f,"finallyLoc");if(L&&D){if(this.prev<f.catchLoc)return n(f.catchLoc,!0);if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else if(L){if(this.prev<f.catchLoc)return n(f.catchLoc,!0)}else if(D){if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n];if(h.tryLoc<=this.prev&&m.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var f=h;break}}f&&(e==="break"||e==="continue")&&f.tryLoc<=t&&t<=f.finallyLoc&&(f=null);var O=f?f.completion:{};return O.type=e,O.arg=t,f?(this.method="next",this.next=f.finallyLoc,j):this.complete(O)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),j},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),u(n),j}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var h=n.completion;if(h.type==="throw"){var f=h.arg;u(n)}return f}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=v),j}},l}(b.exports);try{regeneratorRuntime=g}catch(l){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(b,g,l){l.d(g,{Mf:function(){return T.Z}});var T=l(282),m=l(666),v=l.n(m),w=null,y=l(949);function P(j){if(j.material){var G=Array.isArray(j.material)?j.material:[j.material];G.forEach(function(_){var k,M;(k=_.color)===null||k===void 0||k.convertSRGBToLinear(),(M=_.emissive)===null||M===void 0||M.convertSRGBToLinear(),_.map&&(_.map.encoding=THREE.sRGBEncoding),_.emissiveMap&&(_.emissiveMap.encoding=THREE.sRGBEncoding)})}}var p=l(568),E=l(924),S=l(77),C=l(484),R=null,W=null,Z=function(){var j=(0,p.Z)(v().mark(function G(_,k){var M,z,x,a,i,o,r,c,s;return v().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return M=k.type,z=M===void 0?"blob":M,x=k.version,a=x===void 0?"1":x,d.next=4,(0,S.get)(_);case 4:if(o=d.sent,!(o&&o[a])){d.next=9;break}i=o[a],d.next=15;break;case 9:return d.next=11,(0,C.Z)(fetch(_).then(function(A){if(A.ok)return A[z]();throw new Error}));case 11:r=d.sent,c=r.res,s=r.err,s||(i=c,(0,S.set)(_,(0,E.Z)({},a,c)));case 15:return d.abrupt("return",i?{url:z==="json"?_:URL.createObjectURL(i),store:i}:{url:_});case 16:case"end":return d.stop()}},G)}));return function(_,k){return j.apply(this,arguments)}}(),H=l(705)},282:function(b,g,l){l.d(g,{Z:function(){return m}});var T=l(484);function m(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y={};return y.promise=new Promise(function(P,p){y.resolve=P,y.reject=p}),v&&(y.promise=(0,T.Z)(y.promise,w)),y}},484:function(b,g,l){l.d(g,{Z:function(){return m}});var T=l(42);function m(v){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return v.then(function(y){return(0,T.Z)({err:null,res:y},w)}).catch(function(y){return(0,T.Z)({err:y,res:void 0},w)})}},705:function(b,g,l){var T=l(949),m=new Map,v=function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(P,p,E,S,C){var R=p[E*3],W=p[E*3+1],Z=p[S*3],H=p[S*3+1],j=p[C*3],G=p[C*3+1],_;if(m.has(P))_=m.get(P);else{var k=y.box3||new THREE.Box3;if(!y.box3){var M=P.parameters.shapes.getPoints();k.setFromArray(M.map(function(o){return[o.x,o.y,0]}).flat())}var z=k.getSize(new THREE.Vector3);y.split&&(z.y/=y.split),_={box:k,size:z},m.set(P,_)}var x=_.box,a=_.size,i=y.split?1-y.split:0;return[new THREE.Vector2((R-x.min.x)/a.x,(W-x.min.y)/a.y+i),new THREE.Vector2((Z-x.min.x)/a.x,(H-x.min.y)/a.y+i),new THREE.Vector2((j-x.min.x)/a.x,(G-x.min.y)/a.y+i)]},generateSideWallUV:function(P,p,E,S,C,R){var W=p[E*3],Z=p[E*3+1],H=p[E*3+2],j=p[S*3],G=p[S*3+1],_=p[S*3+2],k=p[C*3],M=p[C*3+1],z=p[C*3+2],x=p[R*3],a=p[R*3+1],i=p[R*3+2],o;if(m.has(p))o=m.get(p);else{var r=new THREE.Box3;r.setFromArray(p);var c=r.getSize(new THREE.Vector3);y.split&&(c.z/=1-y.split),o={box:r,size:c},m.set(p,o)}var s=o.box,u=o.size;return Math.abs(Z-G)<Math.abs(W-j)?[new THREE.Vector2((W-s.min.x)/u.x,(H-s.min.z)/u.z),new THREE.Vector2((j-s.min.x)/u.x,(_-s.min.z)/u.z),new THREE.Vector2((k-s.min.x)/u.x,(z-s.min.z)/u.z),new THREE.Vector2((x-s.min.x)/u.x,(i-s.min.z)/u.z)]:[new THREE.Vector2((Z-s.min.y)/u.y,(H-s.min.z)/u.z),new THREE.Vector2((G-s.min.y)/u.y,(_-s.min.z)/u.z),new THREE.Vector2((M-s.min.y)/u.y,(z-s.min.z)/u.z),new THREE.Vector2((a-s.min.y)/u.y,(i-s.min.z)/u.z)]}}},w=function(){m.clear()}},77:function(b,g,l){var T=v=>{var w={};return l.d(w,v),w},m=v=>()=>v;b.exports=T({get:()=>X.get,set:()=>X.set})},949:function(b,g,l){var T=v=>{var w={};return l.d(w,v),w},m=v=>()=>v;b.exports=T({MathUtils:()=>J.MathUtils})},568:function(b,g,l){l.d(g,{Z:function(){return m}});function T(v,w,y,P,p,E,S){try{var C=v[E](S),R=C.value}catch(W){y(W);return}C.done?w(R):Promise.resolve(R).then(P,p)}function m(v){return function(){var w=this,y=arguments;return new Promise(function(P,p){var E=v.apply(w,y);function S(R){T(E,P,p,S,C,"next",R)}function C(R){T(E,P,p,S,C,"throw",R)}S(void 0)})}}},924:function(b,g,l){l.d(g,{Z:function(){return T}});function T(m,v,w){return v in m?Object.defineProperty(m,v,{value:w,enumerable:!0,configurable:!0,writable:!0}):m[v]=w,m}},42:function(b,g,l){l.d(g,{Z:function(){return m}});var T=l(924);function m(v){for(var w=1;w<arguments.length;w++){var y=arguments[w]!=null?arguments[w]:{},P=Object.keys(y);typeof Object.getOwnPropertySymbols=="function"&&(P=P.concat(Object.getOwnPropertySymbols(y).filter(function(p){return Object.getOwnPropertyDescriptor(y,p).enumerable}))),P.forEach(function(p){(0,T.Z)(v,p,y[p])})}return v}}},Y={};function V(b){var g=Y[b];if(g!==void 0)return g.exports;var l=Y[b]={exports:{}};return Q[b](l,l.exports,V),l.exports}(function(){V.n=function(b){var g=b&&b.__esModule?function(){return b.default}:function(){return b};return V.d(g,{a:g}),g}})(),function(){V.d=function(b,g){for(var l in g)V.o(g,l)&&!V.o(b,l)&&Object.defineProperty(b,l,{enumerable:!0,get:g[l]})}}(),function(){V.o=function(b,g){return Object.prototype.hasOwnProperty.call(b,g)}}();var K={};(function(){V.d(K,{Ct:function(){return l},Vw:function(){return _},hG:function(){return G},Wk:function(){return x}});function b(a,i){if(!(a instanceof i))throw new TypeError("Cannot call a class as a function")}var g=V(584),l=function(){"use strict";function a(){b(this,a),this.cache=new Map}var i=a.prototype;return i.install=function(){},i.init=function(r){var c=(0,g.Mf)();this.cache.set(r,c)},i.get=function(r){var c;return(c=this.cache.get(r))===null||c===void 0?void 0:c.promise},i.set=function(r,c){var s=this.cache.get(r);s?s.resolve(c):console.warn("init cache first")},i.dispose=function(){this.cache.forEach(function(r,c){r.reject("stop set cache:".concat(c))}),this.cache.clear()},a}(),T=V(568);function m(a,i){for(var o=0;o<i.length;o++){var r=i[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function v(a,i,o){return i&&m(a.prototype,i),o&&m(a,o),a}function w(a){if(Array.isArray(a))return a}function y(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function P(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(a,i){(i==null||i>a.length)&&(i=a.length);for(var o=0,r=new Array(i);o<i;o++)r[o]=a[o];return r}function E(a,i){if(!!a){if(typeof a=="string")return p(a,i);var o=Object.prototype.toString.call(a).slice(8,-1);if(o==="Object"&&a.constructor&&(o=a.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return p(a,i)}}function S(a,i){return w(a)||y(a,i)||E(a,i)||P()}function C(a){if(Array.isArray(a))return p(a)}function R(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function W(a){return C(a)||y(a)||E(a)||R()}var Z=V(666),H=V.n(Z),j=V(949),G=function(){"use strict";function a(o){b(this,a),this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=o}var i=a.prototype;return i.install=function(r){this.pencil=r,this.initObjectFactories()},i.initObjectFactories=function(){var r=this,c=this.objects_;Object.keys(c).forEach(function(s){var u=function(){function d(){b(this,d)}var A=d.prototype;return A.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new c[s](e)},d}();r.objectNamesToFactories.set(s,u)})},i.getObject=function(r,c){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var s=(c||{}).key,u="".concat(r).concat(s?"#".concat(s):""),d=this.objects.get(u);return d},i.getAllObject=function(r,c){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var s=(c||{}).key,u="".concat(r).concat(s?"#".concat(s):""),d=[];return this.objects.forEach(function(A,U){(U.startsWith("".concat(u,"#"))||U===u)&&d.push(A)}),d},i.draw=function(r,c,s){var u=this;return(0,T.Z)(H().mark(function d(){var A,U,e,t,n,h,f;return H().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(A=u.objectNamesToFactories.get(r),!A){L.next=15;break}return U=(c||{}).key,e="".concat(r).concat(U?"#".concat(U):""),u.objects.has(e)&&(t=j.MathUtils.generateUUID(),e+="#".concat(t)),n=(c==null?void 0:c.target)||s,typeof n=="string"?h=u.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?h=n:h=u.pencil.scene,f=new A().create(c),f.pencil=u.pencil,f.key=e,u.objects.set(e,f),L.next=14,u.addMesh(f,h);case 14:return L.abrupt("return",f);case 15:throw new Error("Unrecognized:".concat(r));case 16:case"end":return L.stop()}},d)}))()},i.addMesh=function(r,c){return(0,T.Z)(H().mark(function s(){return H().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,c.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return d.stop()}},s)}))()},i.erase=function(){for(var r=arguments.length,c=new Array(r),s=0;s<r;s++)c[s]=arguments[s];var u=this;W(c).forEach(function(d){var A=[];if(typeof d=="string"){var U,e=S(d.split("#"),2),t=e[0],n=e[1];(U=A).push.apply(U,W(u.getAllObject(t,{key:n})))}else A.push(d);A.forEach(function(h){u.removeMesh(h)})})},i.removeMesh=function(r){var c=this,s=r.parent;r.object3d&&s.remove(r.object3d),r.traverse(function(u){u.visible=!1,u.dispose(),c.objects.delete(u.key)})},i.update=function(r,c){this.objects.forEach(function(s){s.update(r,c)})},i.setSize=function(r,c){this.objects.forEach(function(s){s.resize(r,c)})},i.dispose=function(){this.objects.forEach(function(r,c){r.dispose(),r.pm.reject("stop draw:".concat(c))}),this.objects.clear(),this.objectNamesToFactories.clear()},v(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(c){r.push(c.pm.promise)}),r}}]),a}(),_=function(){"use strict";function a(){b(this,a),this.data={}}var i=a.prototype;return i.install=function(){},i.setData=function(r,c){var s,u;this.data[r]=c,(u=(s=this).cb)===null||u===void 0||u.call(s,r)},i.runAll=function(){var r=this;Object.keys(this.data).forEach(function(c){var s,u;(u=(s=r).cb)===null||u===void 0||u.call(s,c)})},i.dispose=function(){this.data={},this.cb=void 0},a}(),k=V(924),M=V(42),z=V(77),x=function(){"use strict";function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,a),this.messageList=[],this.options=(0,M.Z)({},{cache:!1,cacheVersion:"1"},o)}var i=a.prototype;return i.install=function(){},i.init=function(r,c){var s=this,u=this.options,d=u.cache,A=u.cacheVersion;this.workerList=Array.from({length:c},function(U,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var h=n.data,f=h.res,O=h.uuid,L=s.messageList.find(function(D){var I=D.uuid;return O===I});L==null||L.cb(f),s.workerList[e].inUse=!1,s.checkMessage(),d&&(0,z.set)(O,(0,k.Z)({},A,f))},{worker:t,inUse:!1}})},i.postMessage=function(r,c){var s=this,u=this.options,d=u.cache,A=u.cacheVersion;if(d&&!r.workerKey){console.warn("worker cache need workerKey");return}var U=r.workerKey||j.MathUtils.generateUUID();(d?(0,z.get)(U):Promise.resolve()).then(function(e){e&&e[A]?c(e[A]):(s.messageList.push({req:r,cb:c,uuid:U,inUse:!1}),s.checkMessage())})},i.checkMessage=function(){var r=this.workerList.find(function(s){var u=s.inUse;return!u});if(r){var c=this.messageList.find(function(s){var u=s.inUse;return!u});c&&(c.inUse=!0,r.inUse=!0,r.worker.postMessage({req:c.req,uuid:c.uuid}))}},i.dispose=function(){this.workerList.forEach(function(r){var c=r.worker;c.terminate()}),this.workerList=[],this.messageList=[]},a}()})();var q=K.Ct,tt=K.Vw,et=K.hG,rt=K.Wk;export{q as Cache,tt as Data,et as Draw,rt as Wk};
|
|
1
|
+
import*as X from"idb-keyval";import*as J from"three";var Q={666:function(b){var g=function(l){"use strict";var T=Object.prototype,m=T.hasOwnProperty,_,w=typeof Symbol=="function"?Symbol:{},y=w.iterator||"@@iterator",M=w.asyncIterator||"@@asyncIterator",p=w.toStringTag||"@@toStringTag";function E(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{E({},"")}catch(e){E=function(t,n,h){return t[n]=h}}function S(e,t,n,h){var f=t&&t.prototype instanceof G?t:G,O=Object.create(f.prototype),L=new v(h||[]);return O._invoke=r(e,n,L),O}l.wrap=S;function C(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(h){return{type:"throw",arg:h}}}var U="suspendedStart",W="suspendedYield",Z="executing",H="completed",j={};function G(){}function d(){}function k(){}var P={};E(P,y,function(){return this});var R=Object.getPrototypeOf,x=R&&R(R(A([])));x&&x!==T&&m.call(x,y)&&(P=x);var a=k.prototype=G.prototype=Object.create(P);d.prototype=k,E(a,"constructor",k),E(k,"constructor",d),d.displayName=E(k,p,"GeneratorFunction");function s(e){["next","throw","return"].forEach(function(t){E(e,t,function(n){return this._invoke(t,n)})})}l.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===d||(t.displayName||t.name)==="GeneratorFunction":!1},l.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,E(e,p,"GeneratorFunction")),e.prototype=Object.create(a),e},l.awrap=function(e){return{__await:e}};function o(e,t){function n(O,L,D,I){var N=C(e[O],e,L);if(N.type==="throw")I(N.arg);else{var $=N.arg,F=$.value;return F&&typeof F=="object"&&m.call(F,"__await")?t.resolve(F.__await).then(function(B){n("next",B,D,I)},function(B){n("throw",B,D,I)}):t.resolve(F).then(function(B){$.value=B,D($)},function(B){return n("throw",B,D,I)})}}var h;function f(O,L){function D(){return new t(function(I,N){n(O,L,I,N)})}return h=h?h.then(D,D):D()}this._invoke=f}s(o.prototype),E(o.prototype,M,function(){return this}),l.AsyncIterator=o,l.async=function(e,t,n,h,f){f===void 0&&(f=Promise);var O=new o(S(e,t,n,h),f);return l.isGeneratorFunction(t)?O:O.next().then(function(L){return L.done?L.value:O.next()})};function r(e,t,n){var h=U;return function(O,L){if(h===Z)throw new Error("Generator is already running");if(h===H){if(O==="throw")throw L;return z()}for(n.method=O,n.arg=L;;){var D=n.delegate;if(D){var I=c(D,n);if(I){if(I===j)continue;return I}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(h===U)throw h=H,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);h=Z;var N=C(e,t,n);if(N.type==="normal"){if(h=n.done?H:W,N.arg===j)continue;return{value:N.arg,done:n.done}}else N.type==="throw"&&(h=H,n.method="throw",n.arg=N.arg)}}}function c(e,t){var n=e.iterator[t.method];if(n===_){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=_,c(e,t),t.method==="throw"))return j;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return j}var h=C(n,e.iterator,t.arg);if(h.type==="throw")return t.method="throw",t.arg=h.arg,t.delegate=null,j;var f=h.arg;if(!f)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,j;if(f.done)t[e.resultName]=f.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=_);else return f;return t.delegate=null,j}s(a),E(a,p,"Generator"),E(a,y,function(){return this}),E(a,"toString",function(){return"[object Generator]"});function i(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function u(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function v(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(i,this),this.reset(!0)}l.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function h(){for(;t.length;){var f=t.pop();if(f in e)return h.value=f,h.done=!1,h}return h.done=!0,h}};function A(e){if(e){var t=e[y];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,h=function f(){for(;++n<e.length;)if(m.call(e,n))return f.value=e[n],f.done=!1,f;return f.value=_,f.done=!0,f};return h.next=h}}return{next:z}}l.values=A;function z(){return{value:_,done:!0}}return v.prototype={constructor:v,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=_,this.done=!1,this.delegate=null,this.method="next",this.arg=_,this.tryEntries.forEach(u),!e)for(var t in this)t.charAt(0)==="t"&&m.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=_)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(I,N){return O.type="throw",O.arg=e,t.next=I,N&&(t.method="next",t.arg=_),!!N}for(var h=this.tryEntries.length-1;h>=0;--h){var f=this.tryEntries[h],O=f.completion;if(f.tryLoc==="root")return n("end");if(f.tryLoc<=this.prev){var L=m.call(f,"catchLoc"),D=m.call(f,"finallyLoc");if(L&&D){if(this.prev<f.catchLoc)return n(f.catchLoc,!0);if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else if(L){if(this.prev<f.catchLoc)return n(f.catchLoc,!0)}else if(D){if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n];if(h.tryLoc<=this.prev&&m.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var f=h;break}}f&&(e==="break"||e==="continue")&&f.tryLoc<=t&&t<=f.finallyLoc&&(f=null);var O=f?f.completion:{};return O.type=e,O.arg=t,f?(this.method="next",this.next=f.finallyLoc,j):this.complete(O)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),j},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),u(n),j}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var h=n.completion;if(h.type==="throw"){var f=h.arg;u(n)}return f}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=_),j}},l}(b.exports);try{regeneratorRuntime=g}catch(l){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(b,g,l){l.d(g,{Mf:function(){return T.Z}});var T=l(282),m=l(666),_=l.n(m),w=null,y=l(949);function M(j){if(j.material){var G=Array.isArray(j.material)?j.material:[j.material];G.forEach(function(d){var k,P;(k=d.color)===null||k===void 0||k.convertSRGBToLinear(),(P=d.emissive)===null||P===void 0||P.convertSRGBToLinear(),d.map&&(d.map.encoding=THREE.sRGBEncoding),d.emissiveMap&&(d.emissiveMap.encoding=THREE.sRGBEncoding)})}}var p=l(568),E=l(924),S=l(77),C=l(484),U=null,W=null,Z=function(){var j=(0,p.Z)(_().mark(function G(d,k){var P,R,x,a,s,o,r,c,i;return _().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return P=k.type,R=P===void 0?"blob":P,x=k.version,a=x===void 0?"1":x,v.next=4,(0,S.get)(d);case 4:if(o=v.sent,!(o&&o[a])){v.next=9;break}s=o[a],v.next=15;break;case 9:return v.next=11,(0,C.Z)(fetch(d).then(function(A){if(A.ok)return A[R]();throw new Error}));case 11:r=v.sent,c=r.res,i=r.err,i||(s=c,(0,S.set)(d,(0,E.Z)({},a,c)));case 15:return v.abrupt("return",s?{url:R==="json"?d:URL.createObjectURL(s),store:s}:{url:d});case 16:case"end":return v.stop()}},G)}));return function(d,k){return j.apply(this,arguments)}}(),H=l(705)},282:function(b,g,l){l.d(g,{Z:function(){return m}});var T=l(484);function m(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y={};return y.promise=new Promise(function(M,p){y.resolve=M,y.reject=p}),_&&(y.promise=(0,T.Z)(y.promise,w)),y}},484:function(b,g,l){l.d(g,{Z:function(){return m}});var T=l(42);function m(_){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return _.then(function(y){return(0,T.Z)({err:null,res:y},w)}).catch(function(y){return(0,T.Z)({err:y,res:void 0},w)})}},705:function(b,g,l){var T=l(949),m=new Map,_=function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(M,p,E,S,C){var U=p[E*3],W=p[E*3+1],Z=p[S*3],H=p[S*3+1],j=p[C*3],G=p[C*3+1],d;if(m.has(M))d=m.get(M);else{var k=y.box3||new THREE.Box3;if(!y.box3){var P=M.parameters.shapes.getPoints();k.setFromArray(P.map(function(o){return[o.x,o.y,0]}).flat())}var R=k.getSize(new THREE.Vector3);y.split&&(R.y/=y.split),d={box:k,size:R},m.set(M,d)}var x=d.box,a=d.size,s=y.split?1-y.split:0;return[new THREE.Vector2((U-x.min.x)/a.x,(W-x.min.y)/a.y+s),new THREE.Vector2((Z-x.min.x)/a.x,(H-x.min.y)/a.y+s),new THREE.Vector2((j-x.min.x)/a.x,(G-x.min.y)/a.y+s)]},generateSideWallUV:function(M,p,E,S,C,U){var W=p[E*3],Z=p[E*3+1],H=p[E*3+2],j=p[S*3],G=p[S*3+1],d=p[S*3+2],k=p[C*3],P=p[C*3+1],R=p[C*3+2],x=p[U*3],a=p[U*3+1],s=p[U*3+2],o;if(m.has(p))o=m.get(p);else{var r=new THREE.Box3;r.setFromArray(p);var c=r.getSize(new THREE.Vector3);y.split&&(c.z/=1-y.split),o={box:r,size:c},m.set(p,o)}var i=o.box,u=o.size;return Math.abs(Z-G)<Math.abs(W-j)?[new THREE.Vector2((W-i.min.x)/u.x,(H-i.min.z)/u.z),new THREE.Vector2((j-i.min.x)/u.x,(d-i.min.z)/u.z),new THREE.Vector2((k-i.min.x)/u.x,(R-i.min.z)/u.z),new THREE.Vector2((x-i.min.x)/u.x,(s-i.min.z)/u.z)]:[new THREE.Vector2((Z-i.min.y)/u.y,(H-i.min.z)/u.z),new THREE.Vector2((G-i.min.y)/u.y,(d-i.min.z)/u.z),new THREE.Vector2((P-i.min.y)/u.y,(R-i.min.z)/u.z),new THREE.Vector2((a-i.min.y)/u.y,(s-i.min.z)/u.z)]}}},w=function(){m.clear()}},77:function(b,g,l){var T=_=>{var w={};return l.d(w,_),w},m=_=>()=>_;b.exports=T({del:()=>X.del,get:()=>X.get,set:()=>X.set})},949:function(b,g,l){var T=_=>{var w={};return l.d(w,_),w},m=_=>()=>_;b.exports=T({MathUtils:()=>J.MathUtils})},568:function(b,g,l){l.d(g,{Z:function(){return m}});function T(_,w,y,M,p,E,S){try{var C=_[E](S),U=C.value}catch(W){y(W);return}C.done?w(U):Promise.resolve(U).then(M,p)}function m(_){return function(){var w=this,y=arguments;return new Promise(function(M,p){var E=_.apply(w,y);function S(U){T(E,M,p,S,C,"next",U)}function C(U){T(E,M,p,S,C,"throw",U)}S(void 0)})}}},924:function(b,g,l){l.d(g,{Z:function(){return T}});function T(m,_,w){return _ in m?Object.defineProperty(m,_,{value:w,enumerable:!0,configurable:!0,writable:!0}):m[_]=w,m}},42:function(b,g,l){l.d(g,{Z:function(){return m}});var T=l(924);function m(_){for(var w=1;w<arguments.length;w++){var y=arguments[w]!=null?arguments[w]:{},M=Object.keys(y);typeof Object.getOwnPropertySymbols=="function"&&(M=M.concat(Object.getOwnPropertySymbols(y).filter(function(p){return Object.getOwnPropertyDescriptor(y,p).enumerable}))),M.forEach(function(p){(0,T.Z)(_,p,y[p])})}return _}}},Y={};function V(b){var g=Y[b];if(g!==void 0)return g.exports;var l=Y[b]={exports:{}};return Q[b](l,l.exports,V),l.exports}(function(){V.n=function(b){var g=b&&b.__esModule?function(){return b.default}:function(){return b};return V.d(g,{a:g}),g}})(),function(){V.d=function(b,g){for(var l in g)V.o(g,l)&&!V.o(b,l)&&Object.defineProperty(b,l,{enumerable:!0,get:g[l]})}}(),function(){V.o=function(b,g){return Object.prototype.hasOwnProperty.call(b,g)}}();var K={};(function(){V.d(K,{Ct:function(){return l},Vw:function(){return d},hG:function(){return G},Wk:function(){return x}});function b(a,s){if(!(a instanceof s))throw new TypeError("Cannot call a class as a function")}var g=V(584),l=function(){"use strict";function a(){b(this,a),this.cache=new Map}var s=a.prototype;return s.install=function(){},s.init=function(r){var c=(0,g.Mf)();this.cache.set(r,c)},s.get=function(r){var c;return(c=this.cache.get(r))===null||c===void 0?void 0:c.promise},s.set=function(r,c){var i=this.cache.get(r);i?i.resolve(c):console.warn("init cache first")},s.dispose=function(){this.cache.forEach(function(r,c){r.reject("stop set cache:".concat(c))}),this.cache.clear()},a}(),T=V(568);function m(a,s){for(var o=0;o<s.length;o++){var r=s[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function _(a,s,o){return s&&m(a.prototype,s),o&&m(a,o),a}function w(a){if(Array.isArray(a))return a}function y(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function M(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(a,s){(s==null||s>a.length)&&(s=a.length);for(var o=0,r=new Array(s);o<s;o++)r[o]=a[o];return r}function E(a,s){if(!!a){if(typeof a=="string")return p(a,s);var o=Object.prototype.toString.call(a).slice(8,-1);if(o==="Object"&&a.constructor&&(o=a.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return p(a,s)}}function S(a,s){return w(a)||y(a,s)||E(a,s)||M()}function C(a){if(Array.isArray(a))return p(a)}function U(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function W(a){return C(a)||y(a)||E(a)||U()}var Z=V(666),H=V.n(Z),j=V(949),G=function(){"use strict";function a(o){b(this,a),this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=o}var s=a.prototype;return s.install=function(r){this.pencil=r,this.initObjectFactories()},s.initObjectFactories=function(){var r=this,c=this.objects_;Object.keys(c).forEach(function(i){var u=function(){function v(){b(this,v)}var A=v.prototype;return A.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new c[i](e)},v}();r.objectNamesToFactories.set(i,u)})},s.getObject=function(r,c){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var i=(c||{}).key,u="".concat(r).concat(i?"#".concat(i):""),v=this.objects.get(u);return v},s.getAllObject=function(r,c){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var i=(c||{}).key,u="".concat(r).concat(i?"#".concat(i):""),v=[];return this.objects.forEach(function(A,z){(z.startsWith("".concat(u,"#"))||z===u)&&v.push(A)}),v},s.draw=function(r,c,i){var u=this;return(0,T.Z)(H().mark(function v(){var A,z,e,t,n,h,f;return H().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(A=u.objectNamesToFactories.get(r),!A){L.next=15;break}return z=(c||{}).key,e="".concat(r).concat(z?"#".concat(z):""),u.objects.has(e)&&(t=j.MathUtils.generateUUID(),e+="#".concat(t)),n=(c==null?void 0:c.target)||i,typeof n=="string"?h=u.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?h=n:h=u.pencil.scene,f=new A().create(c),f.pencil=u.pencil,f.key=e,u.objects.set(e,f),L.next=14,u.addMesh(f,h);case 14:return L.abrupt("return",f);case 15:throw new Error("Unrecognized:".concat(r));case 16:case"end":return L.stop()}},v)}))()},s.addMesh=function(r,c){return(0,T.Z)(H().mark(function i(){return H().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,c.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return v.stop()}},i)}))()},s.erase=function(){for(var r=arguments.length,c=new Array(r),i=0;i<r;i++)c[i]=arguments[i];var u=this;W(c).forEach(function(v){var A=[];if(typeof v=="string"){var z,e=S(v.split("#"),2),t=e[0],n=e[1];(z=A).push.apply(z,W(u.getAllObject(t,{key:n})))}else A.push(v);A.forEach(function(h){u.removeMesh(h)})})},s.removeMesh=function(r){var c=this,i=r.parent;r.object3d&&i.remove(r.object3d),r.traverse(function(u){u.visible=!1,u.dispose(),c.objects.delete(u.key)})},s.update=function(r,c){this.objects.forEach(function(i){i.update(r,c)})},s.setSize=function(r,c){this.objects.forEach(function(i){i.resize(r,c)})},s.dispose=function(){this.objects.forEach(function(r,c){r.dispose(),r.pm.reject("stop draw:".concat(c))}),this.objects.clear(),this.objectNamesToFactories.clear()},_(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(c){r.push(c.pm.promise)}),r}}]),a}(),d=function(){"use strict";function a(){b(this,a),this.data={}}var s=a.prototype;return s.install=function(){},s.setData=function(r,c){var i,u;this.data[r]=c,(u=(i=this).cb)===null||u===void 0||u.call(i,r)},s.runAll=function(){var r=this;Object.keys(this.data).forEach(function(c){var i,u;(u=(i=r).cb)===null||u===void 0||u.call(i,c)})},s.dispose=function(){this.data={},this.cb=void 0},a}(),k=V(924),P=V(42),R=V(77),x=function(){"use strict";function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,a),this.messageList=[],this.options=(0,P.Z)({},{cache:!1,cacheVersion:"1"},o)}var s=a.prototype;return s.install=function(){},s.init=function(r,c){var i=this,u=this.options,v=u.cache,A=u.cacheVersion;this.workerList=Array.from({length:c},function(z,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var h=n.data,f=h.res,O=h.uuid,L=i.messageList.find(function(D){var I=D.uuid;return O===I});L==null||L.cb(f),i.workerList[e].inUse=!1,i.checkMessage(),v&&(0,R.set)(O,(0,k.Z)({},A,f))},{worker:t,inUse:!1}})},s.postMessage=function(r,c){var i=this,u=this.options,v=u.cache,A=u.cacheVersion;if(v&&!r.workerKey){console.warn("worker cache need workerKey");return}if(v&&r.workerKey&&r.delCache){console.warn("worker cache del: ".concat(r.workerKey)),(0,R.del)(r.workerKey);return}var z=r.workerKey||j.MathUtils.generateUUID();(v?(0,R.get)(z):Promise.resolve()).then(function(e){e&&e[A]?c(e[A]):(i.messageList.push({req:r,cb:c,uuid:z,inUse:!1}),i.checkMessage())}).catch(function(){console.warn("err:worker cache"),i.messageList.push({req:r,cb:c,uuid:z,inUse:!1}),i.checkMessage()})},s.checkMessage=function(){var r=this.workerList.find(function(i){var u=i.inUse;return!u});if(r){var c=this.messageList.find(function(i){var u=i.inUse;return!u});c&&(c.inUse=!0,r.inUse=!0,r.worker.postMessage({req:c.req,uuid:c.uuid}))}},s.dispose=function(){this.workerList.forEach(function(r){var c=r.worker;c.terminate()}),this.workerList=[],this.messageList=[]},a}()})();var q=K.Ct,tt=K.Vw,et=K.hG,rt=K.Wk;export{q as Cache,tt as Data,et as Draw,rt as Wk};
|