gl-draw 0.9.0-beta.340 → 0.9.0-beta.342
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
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var et=Object.defineProperty,tt=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Ue=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Ce=Math.pow,Ie=(i,e,t)=>e in i?et(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,R=(i,e)=>{for(var t in e||(e={}))Ue.call(e,t)&&Ie(i,t,e[t]);if(ce)for(var t of ce(e))je.call(e,t)&&Ie(i,t,e[t]);return i},Oe=(i,e)=>tt(i,st(e));var fe=(i,e)=>{var t={};for(var s in i)Ue.call(i,s)&&e.indexOf(s)<0&&(t[s]=i[s]);if(i!=null&&ce)for(var s of ce(i))e.indexOf(s)<0&&je.call(i,s)&&(t[s]=i[s]);return t};var Q=(i,e,t)=>new Promise((s,r)=>{var n=c=>{try{a(t.next(c))}catch(u){r(u)}},o=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,o);a((t=t.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("three"),Z=require("../BaseObject.js"),rt=require("esus-lite"),it=require("../index2.js"),be=require("../MeshLineMaterial.js"),ot=require("@tweenjs/tween.js"),Y=require("d3-array"),me=require("earcut"),nt=require("@turf/boolean-clockwise"),ge=require("../uvGenerator.js"),at=require("delaunator"),ct=require("@turf/boolean-point-in-polygon"),re=require("d3-geo"),lt=require("d3-geo-voronoi"),Re=require("d3-scale");require("three/examples/jsm/renderers/CSS2DRenderer");require("three/examples/jsm/renderers/CSS3DRenderer");require("../disposeMesh.js");require("idb-keyval");function Fe(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const v=Fe(_),ut=Fe(ot),ht=+v.REVISION<144,We=ht?"PlaneBufferGeometry":"PlaneGeometry";class $e extends Z.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=R({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return Q(this,null,function*(){const{src:e,texture:t,transparent:s,opacity:r,blending:n,depthWrite:o,depthTest:a,alphaTest:c,sprite:u,sizeAttenuation:l,color:d}=this.options,f=t||(yield new v.TextureLoader().loadAsync(e));return u?new v.SpriteMaterial({map:f,transparent:s!=null?s:!1,blending:n!=null?n:v.NormalBlending,depthWrite:o!=null?o:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:r!=null?r:1,sizeAttenuation:l!=null?l:!0}):new v.MeshBasicMaterial({color:d!=null?d:16777215,map:f,transparent:s!=null?s:!1,blending:n!=null?n:v.NormalBlending,depthWrite:o!=null?o:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:r!=null?r:1})})}create(){return Q(this,null,function*(){const{position:e,material:t,sprite:s}=this.options,r=t||(yield this.getMaterial());s?this.createSprite(r):this.createMesh(new v[We](1,1),r),e&&this.object3d.position.copy(e)})}render(){const{scale:e}=this.options;this.setScale(e)}setScale(e){this.scaleValue=e;const t=this.material.map;t!=null&&t.image?this.object3d.scale.set(t.image.width*e,t.image.height*e,1):this.object3d.scale.set(e,e,1)}setTexture(e){const t=this.object3d;t.material.map&&t.material.map.dispose(),t.material.map=e,t.material.needsUpdate=!0,this.setScale(this.scaleValue)}}class ft extends $e{constructor(e){super(e),this.canvas=document.createElement("canvas")}getTexture(){const{text:e,textOptions:t}=this.options,{fontSize:s,fontFamily:r,fontWeight:n,flipX:o,color:a,setCtx:c}=R({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:h=>{}},t||{}),{canvas:u}=this;u.width=s*e.length*2,u.height=s;let l=u.getContext("2d");l.font=`${n} ${s}px/1 ${r}`;const{width:d}=l.measureText(e);u.width=d,l=u.getContext("2d"),l.clearRect(0,0,u.width,u.height),o&&l.scale(-1,1),l.font=`${n} ${s}px/1 ${r}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(e,o?d*-1:0,u.height/2),l.restore();const f=new v.Texture(u);return f.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),f.needsUpdate=!0,Promise.resolve(f)}}class dt extends Z.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=R({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:s,depthWrite:r,depthTest:n,format:o,autoPlay:a,loop:c,alphaTest:u,sprite:l}=this.options,d=rt.makePromiseCreator();if(!e)return Promise.reject("src is required");const f=document.createElement("video");return f.addEventListener("loadedmetadata",()=>{const h=new v.VideoTexture(f);h.format=o!=null?o:v.RGBAFormat,h.needsUpdate=!0;const b=l?new v.SpriteMaterial({map:h,transparent:t!=null?t:!1,blending:s!=null?s:v.NormalBlending,depthWrite:r!=null?r:!0,depthTest:n!=null?n:!0,alphaTest:u!=null?u:0}):new v.MeshBasicMaterial({map:h,transparent:t!=null?t:!1,blending:s!=null?s:v.NormalBlending,depthWrite:r!=null?r:!0,depthTest:n!=null?n:!0,alphaTest:u!=null?u:0});d.resolve(b)},!1),f.src=e,f.muted=!0,f.autoplay=a,f.loop=c,f.preload="auto",d.promise}create(){return Q(this,null,function*(){const{scale:e,position:t,src:s,cache:r,sprite:n}=this.options,o=s&&(r?yield r.get(s,()=>this.getMaterial()):yield this.getMaterial());this.video=o.map.image,n?this.createSprite(o):this.createMesh(new v[We](1,1),o),this.setScale(e),t&&this.object3d.position.copy(t)})}setScale(e){this.scaleValue=e,this.object3d.scale.set(this.video.videoWidth*e,this.video.videoHeight*e,1)}render(){const{autoPlay:e}=this.options;e&&this.video.play()}dispose(){this.video.pause(),this.video.src="",super.dispose()}}class pt extends Z.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.options=R({event:"click"},e)}get clickTarge(){const{eventTarge:e}=this.options;return e?e.map(s=>[...this.element.querySelectorAll(s)]).flat():[this.element]}create(){const{position:e,children:t,handler:s,event:r}=this.options,n=document.createElement("div");this.element=n,t&&n.appendChild(t),this.createCSS2DObject(n),e&&this.object3d.position.copy(e),s&&r&&this.clickTarge.forEach(o=>{const a=Array.isArray(r)?r:[r],c=Array.isArray(s)?s:[s];a.forEach((u,l)=>{const d=c[l];d&&o.addEventListener(u,d)})})}setChildren(e){this.element.innerHTML="",this.element.appendChild(e)}render(){this.checkVisible()}show(){return this.visibleCache=!0,this.checkVisible(),this}hide(){return this.visibleCache=!1,this.checkVisible(),this}checkVisible(){this.drawGroupShow&&this.visibleCache?super.show():(!this.drawGroupShow||!this.visibleCache)&&super.hide()}dispose(){const{handler:e,event:t}=this.options;e&&t&&this.clickTarge.forEach(s=>{const r=Array.isArray(t)?t:[t],n=Array.isArray(e)?e:[e];r.forEach((o,a)=>{const c=n[a];c&&s.removeEventListener(o,c)})}),super.dispose()}}function de(i,e,t,s,r){let n;if(i=i.subarray||i.slice?i:i.buffer,t=t.subarray||t.slice?t:t.buffer,i=e?i.subarray?i.subarray(e,r&&e+r):i.slice(e,r&&e+r):i,t.set)t.set(i,s);else for(n=0;n<i.length;n++)t[n+s]=i[n];return t}function mt(i){return i instanceof Float32Array?i:i instanceof v.BufferGeometry?i.getAttribute("position").array:i.map(e=>{const t=Array.isArray(e);return e instanceof v.Vector3?[e.x,e.y,e.z]:e instanceof v.Vector2?[e.x,e.y,0]:t&&e.length===3?[e[0],e[1],e[2]]:t&&e.length===2?[e[0],e[1],0]:e}).flat()}class He extends v.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new v.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=mt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof v.Vector3)for(let s=0;s<e.length;s++){const r=e[s],n=s/(e.length-1);this.positions.push(r.x,r.y,r.z),this.positions.push(r.x,r.y,r.z),this.counters.push(n),this.counters.push(n)}else for(let s=0;s<e.length;s+=3){const r=s/(e.length-1);this.positions.push(e[s],e[s+1],e[s+2]),this.positions.push(e[s],e[s+1],e[s+2]),this.counters.push(r),this.counters.push(r)}this.process()}compareV3(e,t){const s=e*6,r=t*6;return this.positions[s]===this.positions[r]&&this.positions[s+1]===this.positions[r+1]&&this.positions[s+2]===this.positions[r+2]}copyV3(e){const t=e*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]}process(){const e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let t,s;this.compareV3(0,e-1)?s=this.copyV3(e-2):s=this.copyV3(0),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);for(let r=0;r<e;r++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(r/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(r/(e-1),0),this.uvs.push(r/(e-1),1),r<e-1){s=this.copyV3(r),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const n=r*2;this.indices_array.push(n,n+1,n+2),this.indices_array.push(n+2,n+1,n+3)}r>0&&(s=this.copyV3(r),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(e-1,0)?s=this.copyV3(1):s=this.copyV3(e-1),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new v.BufferAttribute(new Float32Array(this.positions),3),previous:new v.BufferAttribute(new Float32Array(this.previous),3),next:new v.BufferAttribute(new Float32Array(this.next),3),side:new v.BufferAttribute(new Float32Array(this.side),1),width:new v.BufferAttribute(new Float32Array(this.width),1),uv:new v.BufferAttribute(new Float32Array(this.uvs),2),index:new v.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new v.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.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()}advance({x:e,y:t,z:s}){const r=this._attributes.position.array,n=this._attributes.previous.array,o=this._attributes.next.array,a=r.length;de(r,0,n,0,a),de(r,6,r,0,a-6),r[a-6]=e,r[a-5]=t,r[a-4]=s,r[a-3]=e,r[a-2]=t,r[a-1]=s,de(r,6,o,0,a-6),o[a-6]=e,o[a-5]=t,o[a-4]=s,o[a-3]=e,o[a-2]=t,o[a-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function gt(i,e){const t=new v.Matrix4,s=new v.Ray,r=new v.Sphere,n=new v.Vector3,o=this.geometry;if(r.copy(o.boundingSphere),r.applyMatrix4(this.matrixWorld),!i.ray.intersectSphere(r,n))return;t.copy(this.matrixWorld).invert(),s.copy(i.ray).applyMatrix4(t);const a=new v.Vector3,c=new v.Vector3,u=new v.Vector3,l=this instanceof v.LineSegments?2:1,d=o.index,f=o.attributes;if(d!==null){const h=d.array,b=f.position.array,x=f.width.array;for(let A=0,M=h.length-1;A<M;A+=l){const T=h[A],E=h[A+1];a.fromArray(b,T*3),c.fromArray(b,E*3);const P=x[Math.floor(A/3)]!=null?x[Math.floor(A/3)]:1,U=i.params.Line.threshold+this.material.lineWidth*P/2,I=U*U;if(s.distanceSqToSegment(a,c,n,u)>I)continue;n.applyMatrix4(this.matrixWorld);const L=i.ray.origin.distanceTo(n);L<i.near||L>i.far||(e.push({distance:L,point:u.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=M)}}}function X(i,e=0){const t=i[0].index!==null,s=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),n={},o={},a=i[0].morphTargetsRelative,c=new _.BufferGeometry;let u=0;for(let l=0;l<i.length;++l){const d=i[l];let f=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in d.attributes){if(!s.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;n[h]===void 0&&(n[h]=[]),n[h].push(d.attributes[h]),f++}if(f!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in d.morphAttributes){if(!r.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;o[h]===void 0&&(o[h]=[]),o[h].push(d.morphAttributes[h])}if(e){let h;if(t)h=d.index.count;else if(d.attributes.position!==void 0)h=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". The geometry must have either an index or a position attribute"),null;if(e===1)c.addGroup(u,h,l);else if(e===2&&d.groups.length>0)for(let b of d.groups){let x=b.materialIndex;c.addGroup(u+b.start,Math.min(b.count,h),x)}u+=h}}if(t){let l=0;const d=[];for(let f=0;f<i.length;++f){const h=i[f].index;for(let b=0;b<h.count;++b)d.push(h.getX(b)+l);l+=i[f].attributes.position.count}c.setIndex(d)}for(const l in n){const d=Le(n[l]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;c.setAttribute(l,d)}for(const l in o){const d=o[l][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let f=0;f<d;++f){const h=[];for(let x=0;x<o[l].length;++x)h.push(o[l][x][f]);const b=Le(h);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;c.morphAttributes[l].push(b)}}return e===2?yt(c):c}function Le(i){let e,t,s,r=-1,n=0;for(let u=0;u<i.length;++u){const l=i[u];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=l.normalized),s!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=l.gpuType),r!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=l.array.length}const o=new e(n);let a=0;for(let u=0;u<i.length;++u)o.set(i[u].array,a),a+=i[u].array.length;const c=new _.BufferAttribute(o,t,s);return r!==void 0&&(c.gpuType=r),c}function yt(i){if(i.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),i;let e=i.groups;if(e=e.sort((o,a)=>o.materialIndex!==a.materialIndex?o.materialIndex-a.materialIndex:o.start-a.start),i.getIndex()===null){const o=i.getAttribute("position"),a=[];for(let c=0;c<o.count;c+=3)a.push(c,c+1,c+2);i.setIndex(a),a.length=0}const t=i.getIndex(),s=[];for(let o=0;o<e.length;o++){const a=e[o],c=a.start,u=c+a.count;for(let l=c;l<u;l++)s.push(t.getX(l))}i.dispose(),i.setIndex(s),s.length=0;let r=0;for(let o=0;o<e.length;o++){const a=e[o];a.start=r,r+=a.count}let n=e[0];i.groups=[n];for(let o=1;o<e.length;o++){const a=e[o];n.materialIndex===a.materialIndex?n.count+=a.count:(n=a,i.groups.push(n))}return i}const pe=i=>{const{setPointWidth:e,nodes:t}=i,s=new He;return s.setPoints(t,e),s};class bt extends Z.BaseObject{constructor(e={}){super(),this.options=R({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return Q(this,null,function*(){const{nodes:e,nodesArr:t,geometry:s,geometryArr:r,material:n,useGroups:o,setPointWidth:a,lineWidthArr:c,useUserDataPos:u,materialParameters:l}=this.options;let d=n,f=s;if(!d&&l&&(d=this.getMaterial(l)),!f&&e?f=pe({nodes:e,setPointWidth:a}):!f&&t?f=X(t.map((h,b)=>{let x=a;return!x&&c&&(x=()=>{var A;return(A=c[b])!=null?A:c[0]}),pe({nodes:h,setPointWidth:x})}),o!=null?o:0):!f&&r&&r.length>1?f=X(r,o!=null?o:0):!f&&r&&r.length===1&&([f]=r),this.createMesh(f,d),u&&(f!=null&&f.userData.position)){const{x:h,y:b,z:x}=f.userData.position;this.object3d.position.set(h,b,x)}})}setGeometry(e,t){const s=pe({nodes:e,setPointWidth:t}),r=this.object3d,n=r.geometry;r.geometry=s,n.dispose()}getMaterial(e){const{width:t,height:s}=this.pencil.getSize();return new be.MeshLineMaterial(R({color:new v.Color("#ffffff"),resolution:new v.Vector2(t,s)},e))}addGeometries(e){const t=this.object3d,s=X([t.geometry,...e]);t.geometry=s}resize(e,t){var s,r;(r=(s=this.material)==null?void 0:s.uniforms)==null||r.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:s}=this.pencil.getSize();this.resize(t,s)}animate(e,t){var o,a;const{onComplete:s}=this.options,{offset:r}=this.material.uniforms;if(this.material.userData.tween)return;r.value.x=1;const n=new ut.Tween(r.value).to({x:0},(o=e!=null?e:this.options.duration)!=null?o:1e3).delay((a=t!=null?t:this.options.delay)!=null?a:0).repeat(1/0).onComplete(()=>{s&&s()}).start();this.material.userData.tween=n}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(e=!0){var t;(t=this.material.userData.tween)==null||t.stop(),super.dispose(e)}}function xt(i,e){return i.map(t=>{const s=[];let r;return t.forEach(n=>{if(r){const o=re.geoDistance(n,r)*180/Math.PI;if(o>e){const a=re.geoInterpolate(r,n),c=1/Math.ceil(o/e);let u=c;for(;u<1;)s.push(a(u)),u+=c}}s.push(r=n)}),s})}function vt(i,{minLng:e,maxLng:t,minLat:s,maxLat:r}={}){const n=Math.round(Ce(360/i,2)/Math.PI),o=(1+Math.sqrt(5))/2,a=h=>h/o*360%360-180,c=h=>Math.acos(2*h/n-1)/Math.PI*180-90,u=h=>n*(Math.cos((h+90)*Math.PI/180)+1)/2,l=[r!==void 0?Math.ceil(u(r)):0,s!==void 0?Math.floor(u(s)):n-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,f=[];for(let h=l[0];h<=l[1];h++){const b=a(h);d(b)&&f.push([b,c(h)])}return f}function ye(i,e,t=!1){return t?re.geoContains(e,i):ct(i,e)}function wt(i,e){const t={type:"Polygon",coordinates:i},[[s,r],[n,o]]=re.geoBounds(t);if(Math.min(Math.abs(n-s),Math.abs(o-r))<e)return[];const a=s>n||o>=89||r<=-89;return vt(e,{minLng:s,maxLng:n,minLat:r,maxLat:o}).filter(c=>ye(c,t,a))}function At(i,{resolution:e=1/0,bbox:t}={}){const s=xt(i,e),r=Y.merge(s),n=wt(i,e),o=[...r,...n],a={type:"Polygon",coordinates:i},[[c,u],[l,d]]=re.geoBounds(a),f=c>l||d>=89||u<=-89;let h=[];if(f){const T=lt.geoVoronoi(o).triangles(),E=new Map(o.map(([P,U],I)=>[`${P}-${U}`,I]));T.features.forEach(P=>{const U=P.geometry.coordinates[0].slice(0,3).reverse(),I=[];if(U.forEach(([G,L])=>{const k=`${G}-${L}`;E.has(k)&&I.push(E.get(k))}),I.length===3){if(I.some(G=>G<r.length)){const G=P.properties.circumcenter;if(!ye(G,a,f))return}h.push(...I)}})}else if(n.length){const T=at.from(o);for(let E=0,P=T.triangles.length;E<P;E+=3){const U=[2,1,0].map(G=>T.triangles[E+G]),I=U.map(G=>o[G]);if(U.some(G=>G<r.length)){const G=[0,1].map(L=>Y.mean(I,k=>k[L]));if(!ye(G,a,f))continue}h.push(...U)}}else{const{vertices:T,holes:E=[]}=me.flatten(s);h=me(T,E,2)}const b=Re.scaleLinear(t?[t[0],t[2]]:Y.extent(o,T=>T[0]),[0,1]),x=Re.scaleLinear(t?[t[1],t[3]]:Y.extent(o,T=>T[1]),[0,1]),A=o.map(([T,E])=>[b(T),x(E)]);return{contour:s,triangles:{points:o,indices:h,uvs:A}}}const qe=new v.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function le(i,e,t,s){const r=i.map(n=>n.map(([o,a])=>{if(s){const[c,u]=s([o,a]);return[c,-u,e]}return t?ge.polar2Cartesian(o,a,e):[o,a,e]}));return me.flatten(r)}function Mt(i,e,t,s,r){const{vertices:n,holes:o}=le(i,e,s,r),{vertices:a}=le(i,t,s,r),c=Y.merge([a,n]),u=Math.round(a.length/3),l=new Set(o);let d=0;const f=[];for(let b=0;b<u;b++){let x=b+1;if(x===u)x=d;else if(l.has(x)){const A=x;x=d,d=A}f.push(b,b+u,x+u),f.push(x+u,x,b)}const h=[];for(let b=1;b>=0;b--)for(let x=0;x<u;x+=1)h.push(x/(u-1),b);return{indices:f,vertices:c,uvs:h,topVerts:a}}function ke(i,e,t,s,r,n){return{indices:s?i.indices:i.indices.slice().reverse(),vertices:le([i.points],e,r,n).vertices,uvs:t}}const De=({polygonGeoJson:i,startHeight:e,endHeight:t,curvatureResolution:s=1,cartesian:r=!0,hasSide:n=!0,hasBottom:o=!1,hasTop:a=!1,projection:c,bbox:u})=>{i.forEach(M=>{nt(M)||M.reverse()});const{contour:l,triangles:d}=At(i,{resolution:s,bbox:u});let f={},h;n&&(f=Mt(l,e!=null?e:t,t!=null?t:e,r,c),h=f.topVerts);let b=[];(o||a)&&(b=Y.merge(d.uvs));let x={};o&&(x=ke(d,e,b,!1,r,c));let A={};return a&&(A=ke(d,t,b,!0,r,c)),{contour:l,triangles:d,sideTorso:f,bottomCap:x,topCap:A,topVerts:h}};class Je extends v.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=R({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:s,hasTop:r,hasBottom:n,hasSide:o,cartesian:a,userDataRsoOffset:c,projection:u}=this.parameters,{contour:l,sideTorso:d,topVerts:f,bottomCap:h,topCap:b}=De(R({},this.parameters));let x=[],A=[],M=[],T=0;const E=P=>{const U=Math.round(x.length/3),I=M.length;x=x.concat(P.vertices),A=A.concat(P.uvs),M=M.concat(U?P.indices.map(G=>G+U):P.indices),this.addGroup(I,M.length-I,T++)};o&&(E(d),this.userData.topVerts=c?le(l,s+c,a,u).vertices:f),n&&E(h),r&&E(b),this.setIndex(M),this[qe]("position",new v.Float32BufferAttribute(x,3)),this[qe]("uv",new v.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const ze=i=>{const a=i,{coordinate:e,startHeight:t,height:s}=a,r=fe(a,["coordinate","startHeight","height"]);let n=t||0;return typeof t!="undefined"&&typeof s!="undefined"&&(n=t+s),new Je([e],Oe(R({},r),{startHeight:t,endHeight:n}))};class St extends Z.BaseObject{constructor(e){super(),this.options=R({},e)}create(){const c=this.options,{geometry:e,coordinateArr:t,coordinate:s,material:r,useGroups:n}=c,o=fe(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&s)a=ze(R({coordinate:s},o));else if(!a&&t){const u=t.map(l=>ze(R({coordinate:l},o)));a=X(u,n!=null?n:0)}this.createMesh(a,r)}}class xe extends _.BufferGeometry{constructor(e=new _.Shape([new _.Vector2(.5,.5),new _.Vector2(-.5,.5),new _.Vector2(-.5,-.5),new _.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const s=this,r=[],n=[];for(let a=0,c=e.length;a<c;a++){const u=e[a];o(u)}this.setAttribute("position",new _.Float32BufferAttribute(r,3)),this.setAttribute("uv",new _.Float32BufferAttribute(n,2)),this.computeVertexNormals();function o(a){var Se,_e,Ve;const c=[],u=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,h=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:h-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const M=t.extrudePath,T=t.UVGenerator!==void 0?t.UVGenerator:_t,E=(Se=t.hasTop)!=null?Se:!0,P=(_e=t.hasBottom)!=null?_e:!0,U=(Ve=t.hasSide)!=null?Ve:!0;let I,G=!1,L,k,ee,N;M&&(I=M.getSpacedPoints(l),G=!0,f=!1,L=M.computeFrenetFrames(l,!1),k=new _.Vector3,ee=new _.Vector3,N=new _.Vector3),f||(A=0,h=0,b=0,x=0);const ve=a.extractPoints(u);let q=ve.shape;const O=ve.holes;if(!_.ShapeUtils.isClockWise(q)){q=q.reverse();for(let p=0,m=O.length;p<m;p++){const g=O[p];_.ShapeUtils.isClockWise(g)&&(O[p]=g.reverse())}}const te=_.ShapeUtils.triangulateShape(q,O),z=q;for(let p=0,m=O.length;p<m;p++){const g=O[p];q=q.concat(g)}function K(p,m,g){return m||console.error("THREE.ExtrudeGeometry: vec does not exist"),p.clone().addScaledVector(m,g)}const F=q.length,ie=te.length;function we(p,m,g){let w,y,S;const V=p.x-m.x,B=p.y-m.y,C=g.x-p.x,j=g.y-p.y,se=V*V+B*B,he=V*j-B*C;if(Math.abs(he)>Number.EPSILON){const D=Math.sqrt(se),Ee=Math.sqrt(C*C+j*j),Te=m.x-B/D,Be=m.y+V/D,Ye=g.x-j/Ee,Ze=g.y+C/Ee,Pe=((Ye-Te)*j-(Ze-Be)*C)/(V*j-B*C);w=Te+V*Pe-p.x,y=Be+B*Pe-p.y;const Ge=w*w+y*y;if(Ge<=2)return new _.Vector2(w,y);S=Math.sqrt(Ge/2)}else{let D=!1;V>Number.EPSILON?C>Number.EPSILON&&(D=!0):V<-Number.EPSILON?C<-Number.EPSILON&&(D=!0):Math.sign(B)===Math.sign(j)&&(D=!0),D?(w=-B,y=V,S=Math.sqrt(se)):(w=V,y=B,S=Math.sqrt(se/2))}return new _.Vector2(w/S,y/S)}const oe=[];for(let p=0,m=z.length,g=m-1,w=p+1;p<m;p++,g++,w++)g===m&&(g=0),w===m&&(w=0),oe[p]=we(z[p],z[g],z[w]);const ue=[];let J,ne=oe.concat();for(let p=0,m=O.length;p<m;p++){const g=O[p];J=[];for(let w=0,y=g.length,S=y-1,V=w+1;w<y;w++,S++,V++)S===y&&(S=0),V===y&&(V=0),J[w]=we(g[w],g[S],g[V]);ue.push(J),ne=ne.concat(J)}for(let p=0;p<A;p++){const m=p/A,g=h*Math.cos(m*Math.PI/2),w=b*Math.sin(m*Math.PI/2)+x;for(let y=0,S=z.length;y<S;y++){const V=K(z[y],oe[y],w);W(V.x,V.y,-g)}for(let y=0,S=O.length;y<S;y++){const V=O[y];J=ue[y];for(let B=0,C=V.length;B<C;B++){const j=K(V[B],J[B],w);W(j.x,j.y,-g)}}}const Ae=b+x;for(let p=0;p<F;p++){const m=f?K(q[p],ne[p],Ae):q[p];G?(ee.copy(L.normals[0]).multiplyScalar(m.x),k.copy(L.binormals[0]).multiplyScalar(m.y),N.copy(I[0]).add(ee).add(k),W(N.x,N.y,N.z)):W(m.x,m.y,0)}for(let p=1;p<=l;p++)for(let m=0;m<F;m++){const g=f?K(q[m],ne[m],Ae):q[m];G?(ee.copy(L.normals[p]).multiplyScalar(g.x),k.copy(L.binormals[p]).multiplyScalar(g.y),N.copy(I[p]).add(ee).add(k),W(N.x,N.y,N.z)):W(g.x,g.y,d/l*p)}for(let p=A-1;p>=0;p--){const m=p/A,g=h*Math.cos(m*Math.PI/2),w=b*Math.sin(m*Math.PI/2)+x;for(let y=0,S=z.length;y<S;y++){const V=K(z[y],oe[y],w);W(V.x,V.y,d+g)}for(let y=0,S=O.length;y<S;y++){const V=O[y];J=ue[y];for(let B=0,C=V.length;B<C;B++){const j=K(V[B],J[B],w);G?W(j.x,j.y+I[l-1].y,I[l-1].x+g):W(j.x,j.y,d+g)}}}Xe(),U&&Ke();function Xe(){const p=r.length/3;if(f){let m=0,g=F*m;if(P)for(let w=0;w<ie;w++){const y=te[w];ae(y[2]+g,y[1]+g,y[0]+g)}if(m=l+A*2,g=F*m,E)for(let w=0;w<ie;w++){const y=te[w];ae(y[0]+g,y[1]+g,y[2]+g)}}else{if(P)for(let m=0;m<ie;m++){const g=te[m];ae(g[2],g[1],g[0])}if(E)for(let m=0;m<ie;m++){const g=te[m];ae(g[0]+F*l,g[1]+F*l,g[2]+F*l)}}s.addGroup(p,r.length/3-p,0)}function Ke(){const p=r.length/3;let m=0;Me(z,m),m+=z.length;for(let g=0,w=O.length;g<w;g++){const y=O[g];Me(y,m),m+=y.length}s.addGroup(p,r.length/3-p,1)}function Me(p,m){let g=p.length;for(;--g>=0;){const w=g;let y=g-1;y<0&&(y=p.length-1);for(let S=0,V=l+A*2;S<V;S++){const B=F*S,C=F*(S+1),j=m+w+B,se=m+y+B,he=m+y+C,D=m+w+C;Qe(j,se,he,D)}}}function W(p,m,g){c.push(p),c.push(m),c.push(g)}function ae(p,m,g){$(p),$(m),$(g);const w=r.length/3,y=T.generateTopUV(s,r,w-3,w-2,w-1);H(y[0]),H(y[1]),H(y[2])}function Qe(p,m,g,w){$(p),$(m),$(w),$(m),$(g),$(w);const y=r.length/3,S=T.generateSideWallUV(s,r,y-6,y-3,y-2,y-1);H(S[0]),H(S[1]),H(S[3]),H(S[1]),H(S[2]),H(S[3])}function $(p){r.push(c[p*3+0]),r.push(c[p*3+1]),r.push(c[p*3+2])}function H(p){n.push(p.x),n.push(p.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,s=this.parameters.options;return Vt(t,s,e)}static fromJSON(e,t){const s=[];for(let n=0,o=e.shapes.length;n<o;n++){const a=t[e.shapes[n]];s.push(a)}const r=e.options.extrudePath;return console.log(r.type),r!==void 0&&(e.options.extrudePath=new v[`${r.type}Curve`]().fromJSON(r)),new xe(s,e.options)}}const _t={generateTopUV:function(i,e,t,s,r){const n=e[t*3],o=e[t*3+1],a=e[s*3],c=e[s*3+1],u=e[r*3],l=e[r*3+1];return[new _.Vector2(n,o),new _.Vector2(a,c),new _.Vector2(u,l)]},generateSideWallUV:function(i,e,t,s,r,n){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],u=e[s*3],l=e[s*3+1],d=e[s*3+2],f=e[r*3],h=e[r*3+1],b=e[r*3+2],x=e[n*3],A=e[n*3+1],M=e[n*3+2];return Math.abs(a-l)<Math.abs(o-u)?[new _.Vector2(o,1-c),new _.Vector2(u,1-d),new _.Vector2(f,1-b),new _.Vector2(x,1-M)]:[new _.Vector2(a,1-c),new _.Vector2(l,1-d),new _.Vector2(h,1-b),new _.Vector2(A,1-M)]}};function Vt(i,e,t){if(t.shapes=[],Array.isArray(i))for(let s=0,r=i.length;s<r;s++){const n=i[s];t.shapes.push(n.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}const Ne=i=>{const{split:e,depth:t,points:s,box3:r,hasTop:n,hasBottom:o,hasSide:a,sideRepeat:c}=i,u=new xe(new v.Shape(s),{depth:t,bevelEnabled:!1,UVGenerator:ge.getUVGenerator({split:e,box3:r,sideRepeat:c}),hasTop:n,hasBottom:o,hasSide:a});return ge.claerUVGenerator(),u};class Et extends Z.BaseObject{constructor(e){super(),this.options=R({depth:1},e)}create(){return Q(this,null,function*(){const{points:e,pointsArr:t,useGroups:s,depth:r,geometry:n,geometryArr:o,material:a,box3:c,split:u,hasTop:l,hasBottom:d,hasSide:f,useUserDataPos:h}=this.options,b=Array.isArray(r)?r:[r],x=Array.isArray(c)?c:[c],A=a;let M=n;if(A||console.log("material is null"),!M&&e?M=Ne({points:e,depth:b[0],box3:x[0],split:u,hasTop:l,hasBottom:d,hasSide:f}):!M&&t?M=X(t.map((T,E)=>{var P,U;return Ne({points:T,depth:(P=b[E])!=null?P:b[0],box3:(U=x[E])!=null?U:x[0],split:u,hasTop:l,hasBottom:d,hasSide:f})}),s!=null?s:0):!M&&o&&o.length>1?M=X(o,s!=null?s:0):!M&&o&&o.length===1&&([M]=o),this.createMesh(M,A),h&&(M!=null&&M.userData.position)){const{x:T,y:E,z:P}=M.userData.position;this.object3d.position.set(T,E,P)}})}addGeometries(e){const t=this.object3d,s=X([t.geometry,...e]);t.geometry=s}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Tt=i=>{const{topColor:e,sideColor:t,sideMap:s,createCanvasObjectURL:r,split:n,maxAnisotropy:o}=i;return new Promise(a=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const u=n,l=document.createElement("canvas"),d=l.getContext("2d");l.height=c.height/(1-u),l.width=c.width,u&&e&&(d.fillStyle=e,d.fillRect(0,0,c.width,l.height*u)),s&&c instanceof HTMLImageElement?d.drawImage(c,0,l.height*u,c.width,c.height):t&&(d.fillStyle=t,d.fillRect(0,l.height*u,c.width,c.height)),r&&l.toBlob(h=>{console.log(URL.createObjectURL(h))});const f=new v.CanvasTexture(l);a(f)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=it.Group;exports.MeshLineMaterial=be.MeshLineMaterial;exports.meshLineMaterialArr=be.meshLineMaterialArr;exports.ConicPolygon=St;exports.ExtrudePolygon=Et;exports.Image=$e;exports.Line=bt;exports.MeshLineGeometry=He;exports.MeshLineRaycast=gt;exports.Node=pt;exports.Text=ft;exports.Video=dt;exports.getConicPolygonGeometry=Je;exports.getConicPolygonGeometryMetas=De;exports.getSplitTexture=Tt;
|
|
1
|
+
"use strict";var et=Object.defineProperty,tt=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Ue=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Ce=Math.pow,Ie=(i,e,t)=>e in i?et(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,R=(i,e)=>{for(var t in e||(e={}))Ue.call(e,t)&&Ie(i,t,e[t]);if(ce)for(var t of ce(e))je.call(e,t)&&Ie(i,t,e[t]);return i},Oe=(i,e)=>tt(i,st(e));var fe=(i,e)=>{var t={};for(var s in i)Ue.call(i,s)&&e.indexOf(s)<0&&(t[s]=i[s]);if(i!=null&&ce)for(var s of ce(i))e.indexOf(s)<0&&je.call(i,s)&&(t[s]=i[s]);return t};var Q=(i,e,t)=>new Promise((s,r)=>{var n=c=>{try{a(t.next(c))}catch(u){r(u)}},o=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,o);a((t=t.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("three"),Z=require("../BaseObject.js"),rt=require("esus-lite"),it=require("../index2.js"),be=require("../MeshLineMaterial.js"),ot=require("@tweenjs/tween.js"),Y=require("d3-array"),me=require("earcut"),nt=require("@turf/boolean-clockwise"),ge=require("../uvGenerator.js"),at=require("delaunator"),ct=require("@turf/boolean-point-in-polygon"),re=require("d3-geo"),lt=require("d3-geo-voronoi"),Re=require("d3-scale");require("three/examples/jsm/renderers/CSS2DRenderer");require("three/examples/jsm/renderers/CSS3DRenderer");require("../disposeMesh.js");require("idb-keyval");function Fe(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const v=Fe(_),ut=Fe(ot),ht=+v.REVISION<144,We=ht?"PlaneBufferGeometry":"PlaneGeometry";class $e extends Z.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=R({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return Q(this,null,function*(){const{src:e,texture:t,transparent:s,opacity:r,blending:n,depthWrite:o,depthTest:a,alphaTest:c,sprite:u,sizeAttenuation:l,color:d}=this.options,f=t||(yield new v.TextureLoader().loadAsync(e));return u?new v.SpriteMaterial({map:f,transparent:s!=null?s:!1,blending:n!=null?n:v.NormalBlending,depthWrite:o!=null?o:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:r!=null?r:1,sizeAttenuation:l!=null?l:!0}):new v.MeshBasicMaterial({color:d!=null?d:16777215,map:f,transparent:s!=null?s:!1,blending:n!=null?n:v.NormalBlending,depthWrite:o!=null?o:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:r!=null?r:1})})}create(){return Q(this,null,function*(){const{position:e,material:t,sprite:s}=this.options,r=t||(yield this.getMaterial());s?this.createSprite(r):this.createMesh(new v[We](1,1),r),e&&this.object3d.position.copy(e)})}render(){const{scale:e}=this.options;this.setScale(e)}setScale(e){this.scaleValue=e;const t=this.material.map;t!=null&&t.image?this.object3d.scale.set(t.image.width*e,t.image.height*e,1):this.object3d.scale.set(e,e,1)}setTexture(e){const t=this.object3d;t.material.map&&t.material.map.dispose(),t.material.map=e,t.material.needsUpdate=!0,this.setScale(this.scaleValue)}}class ft extends $e{constructor(e){super(e),this.canvas=document.createElement("canvas")}getTexture(){const{text:e,textOptions:t}=this.options,{fontSize:s,fontFamily:r,fontWeight:n,flipX:o,color:a,setCtx:c}=R({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:h=>{}},t||{}),{canvas:u}=this;u.width=s*e.length*2,u.height=s;let l=u.getContext("2d");l.font=`${n} ${s}px/1 ${r}`;const{width:d}=l.measureText(e);u.width=d,l=u.getContext("2d"),l.clearRect(0,0,u.width,u.height),o&&l.scale(-1,1),l.font=`${n} ${s}px/1 ${r}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(e,o?d*-1:0,u.height/2),l.restore();const f=new v.Texture(u);return f.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),f.needsUpdate=!0,Promise.resolve(f)}}class dt extends Z.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=R({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:s,depthWrite:r,depthTest:n,format:o,autoPlay:a,loop:c,alphaTest:u,sprite:l}=this.options,d=rt.makePromiseCreator();if(!e)return Promise.reject("src is required");const f=document.createElement("video");return f.addEventListener("loadedmetadata",()=>{const h=new v.VideoTexture(f);h.format=o!=null?o:v.RGBAFormat,h.needsUpdate=!0;const b=l?new v.SpriteMaterial({map:h,transparent:t!=null?t:!1,blending:s!=null?s:v.NormalBlending,depthWrite:r!=null?r:!0,depthTest:n!=null?n:!0,alphaTest:u!=null?u:0}):new v.MeshBasicMaterial({map:h,transparent:t!=null?t:!1,blending:s!=null?s:v.NormalBlending,depthWrite:r!=null?r:!0,depthTest:n!=null?n:!0,alphaTest:u!=null?u:0});d.resolve(b)},!1),f.src=e,f.muted=!0,f.autoplay=a,f.loop=c,f.preload="auto",d.promise}create(){return Q(this,null,function*(){const{scale:e,position:t,src:s,cache:r,sprite:n}=this.options,o=s&&(r?yield r.get(s,()=>this.getMaterial()):yield this.getMaterial());this.video=o.map.image,n?this.createSprite(o):this.createMesh(new v[We](1,1),o),this.setScale(e),t&&this.object3d.position.copy(t)})}setScale(e){this.scaleValue=e,this.object3d.scale.set(this.video.videoWidth*e,this.video.videoHeight*e,1)}render(){const{autoPlay:e}=this.options;e&&this.video.play()}dispose(){this.video.pause(),this.video.src="",super.dispose()}}class pt extends Z.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.options=R({event:"click"},e)}get clickTarge(){const{eventTarge:e}=this.options;return e?e.map(s=>[...this.element.querySelectorAll(s)]).flat():[this.element]}create(){const{position:e,children:t,handler:s,event:r}=this.options,n=document.createElement("div");this.element=n,t&&n.appendChild(t),this.createCSS2DObject(n),e&&this.object3d.position.copy(e),s&&r&&this.clickTarge.forEach(o=>{const a=Array.isArray(r)?r:[r],c=Array.isArray(s)?s:[s];a.forEach((u,l)=>{const d=c[l];d&&o.addEventListener(u,d)})})}setChildren(e){this.element.innerHTML="",this.element.appendChild(e)}render(){this.checkVisible()}show(){return this.visibleCache=!0,this.checkVisible(),this}hide(){return this.visibleCache=!1,this.checkVisible(),this}checkVisible(){this.drawGroupShow&&this.visibleCache?super.show():(!this.drawGroupShow||!this.visibleCache)&&super.hide()}dispose(){const{handler:e,event:t}=this.options;e&&t&&this.clickTarge.forEach(s=>{const r=Array.isArray(t)?t:[t],n=Array.isArray(e)?e:[e];r.forEach((o,a)=>{const c=n[a];c&&s.removeEventListener(o,c)})}),super.dispose()}}function de(i,e,t,s,r){let n;if(i=i.subarray||i.slice?i:i.buffer,t=t.subarray||t.slice?t:t.buffer,i=e?i.subarray?i.subarray(e,r&&e+r):i.slice(e,r&&e+r):i,t.set)t.set(i,s);else for(n=0;n<i.length;n++)t[n+s]=i[n];return t}function mt(i){return i instanceof Float32Array?i:i instanceof v.BufferGeometry?i.getAttribute("position").array:i.map(e=>{const t=Array.isArray(e);return e instanceof v.Vector3?[e.x,e.y,e.z]:e instanceof v.Vector2?[e.x,e.y,0]:t&&e.length===3?[e[0],e[1],e[2]]:t&&e.length===2?[e[0],e[1],0]:e}).flat()}class He extends v.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new v.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=mt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof v.Vector3)for(let s=0;s<e.length;s++){const r=e[s],n=s/(e.length-1);this.positions.push(r.x,r.y,r.z),this.positions.push(r.x,r.y,r.z),this.counters.push(n),this.counters.push(n)}else for(let s=0;s<e.length;s+=3){const r=s/(e.length-1);this.positions.push(e[s],e[s+1],e[s+2]),this.positions.push(e[s],e[s+1],e[s+2]),this.counters.push(r),this.counters.push(r)}this.process()}compareV3(e,t){const s=e*6,r=t*6;return this.positions[s]===this.positions[r]&&this.positions[s+1]===this.positions[r+1]&&this.positions[s+2]===this.positions[r+2]}copyV3(e){const t=e*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]}process(){const e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let t,s;this.compareV3(0,e-1)?s=this.copyV3(e-2):s=this.copyV3(0),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);for(let r=0;r<e;r++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(r/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(r/(e-1),0),this.uvs.push(r/(e-1),1),r<e-1){s=this.copyV3(r),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const n=r*2;this.indices_array.push(n,n+1,n+2),this.indices_array.push(n+2,n+1,n+3)}r>0&&(s=this.copyV3(r),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(e-1,0)?s=this.copyV3(1):s=this.copyV3(e-1),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new v.BufferAttribute(new Float32Array(this.positions),3),previous:new v.BufferAttribute(new Float32Array(this.previous),3),next:new v.BufferAttribute(new Float32Array(this.next),3),side:new v.BufferAttribute(new Float32Array(this.side),1),width:new v.BufferAttribute(new Float32Array(this.width),1),uv:new v.BufferAttribute(new Float32Array(this.uvs),2),index:new v.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new v.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.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()}advance({x:e,y:t,z:s}){const r=this._attributes.position.array,n=this._attributes.previous.array,o=this._attributes.next.array,a=r.length;de(r,0,n,0,a),de(r,6,r,0,a-6),r[a-6]=e,r[a-5]=t,r[a-4]=s,r[a-3]=e,r[a-2]=t,r[a-1]=s,de(r,6,o,0,a-6),o[a-6]=e,o[a-5]=t,o[a-4]=s,o[a-3]=e,o[a-2]=t,o[a-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function gt(i,e){const t=new v.Matrix4,s=new v.Ray,r=new v.Sphere,n=new v.Vector3,o=this.geometry;if(r.copy(o.boundingSphere),r.applyMatrix4(this.matrixWorld),!i.ray.intersectSphere(r,n))return;t.copy(this.matrixWorld).invert(),s.copy(i.ray).applyMatrix4(t);const a=new v.Vector3,c=new v.Vector3,u=new v.Vector3,l=this instanceof v.LineSegments?2:1,d=o.index,f=o.attributes;if(d!==null){const h=d.array,b=f.position.array,x=f.width.array;for(let A=0,M=h.length-1;A<M;A+=l){const T=h[A],E=h[A+1];a.fromArray(b,T*3),c.fromArray(b,E*3);const P=x[Math.floor(A/3)]!=null?x[Math.floor(A/3)]:1,U=i.params.Line.threshold+this.material.lineWidth*P/2,I=U*U;if(s.distanceSqToSegment(a,c,n,u)>I)continue;n.applyMatrix4(this.matrixWorld);const L=i.ray.origin.distanceTo(n);L<i.near||L>i.far||(e.push({distance:L,point:u.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=M)}}}function X(i,e=0){const t=i[0].index!==null,s=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),n={},o={},a=i[0].morphTargetsRelative,c=new _.BufferGeometry;let u=0;for(let l=0;l<i.length;++l){const d=i[l];let f=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in d.attributes){if(!s.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;n[h]===void 0&&(n[h]=[]),n[h].push(d.attributes[h]),f++}if(f!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in d.morphAttributes){if(!r.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;o[h]===void 0&&(o[h]=[]),o[h].push(d.morphAttributes[h])}if(e){let h;if(t)h=d.index.count;else if(d.attributes.position!==void 0)h=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". The geometry must have either an index or a position attribute"),null;if(e===1)c.addGroup(u,h,l);else if(e===2&&d.groups.length>0)for(let b of d.groups){let x=b.materialIndex;c.addGroup(u+b.start,Math.min(b.count,h),x)}u+=h}}if(t){let l=0;const d=[];for(let f=0;f<i.length;++f){const h=i[f].index;for(let b=0;b<h.count;++b)d.push(h.getX(b)+l);l+=i[f].attributes.position.count}c.setIndex(d)}for(const l in n){const d=Le(n[l]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;c.setAttribute(l,d)}for(const l in o){const d=o[l][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let f=0;f<d;++f){const h=[];for(let x=0;x<o[l].length;++x)h.push(o[l][x][f]);const b=Le(h);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;c.morphAttributes[l].push(b)}}return e===2?yt(c):c}function Le(i){let e,t,s,r=-1,n=0;for(let u=0;u<i.length;++u){const l=i[u];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=l.normalized),s!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=l.gpuType),r!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=l.array.length}const o=new e(n);let a=0;for(let u=0;u<i.length;++u)o.set(i[u].array,a),a+=i[u].array.length;const c=new _.BufferAttribute(o,t,s);return r!==void 0&&(c.gpuType=r),c}function yt(i){if(i.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),i;let e=i.groups;if(e=e.sort((o,a)=>o.materialIndex!==a.materialIndex?o.materialIndex-a.materialIndex:o.start-a.start),i.getIndex()===null){const o=i.getAttribute("position"),a=[];for(let c=0;c<o.count;c+=3)a.push(c,c+1,c+2);i.setIndex(a),a.length=0}const t=i.getIndex(),s=[];for(let o=0;o<e.length;o++){const a=e[o],c=a.start,u=c+a.count;for(let l=c;l<u;l++)s.push(t.getX(l))}i.dispose(),i.setIndex(s),s.length=0;let r=0;for(let o=0;o<e.length;o++){const a=e[o];a.start=r,r+=a.count}let n=e[0];i.groups=[n];for(let o=1;o<e.length;o++){const a=e[o];n.materialIndex===a.materialIndex?n.count+=a.count:(n=a,i.groups.push(n))}return i}const pe=i=>{const{setPointWidth:e,nodes:t}=i,s=new He;return s.setPoints(t,e),s};class bt extends Z.BaseObject{constructor(e={}){super(),this.options=R({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return Q(this,null,function*(){const{nodes:e,nodesArr:t,geometry:s,geometryArr:r,material:n,useGroups:o,setPointWidth:a,lineWidthArr:c,useUserDataPos:u,materialParameters:l}=this.options;let d=n,f=s;if(!d&&l&&(d=this.getMaterial(l)),!f&&e?f=pe({nodes:e,setPointWidth:a}):!f&&t?f=X(t.map((h,b)=>{let x=a;return!x&&c&&(x=()=>{var A;return(A=c[b])!=null?A:c[0]}),pe({nodes:h,setPointWidth:x})}),o!=null?o:0):!f&&r&&r.length>1?f=X(r,o!=null?o:0):!f&&r&&r.length===1&&([f]=r),this.createMesh(f,d),u&&(f!=null&&f.userData.position)){const{x:h,y:b,z:x}=f.userData.position;this.object3d.position.set(h,b,x)}})}setGeometry(e,t){const s=pe({nodes:e,setPointWidth:t}),r=this.object3d,n=r.geometry;r.geometry=s,n.dispose()}getMaterial(e){const{width:t,height:s}=this.pencil.getSize();return new be.MeshLineMaterial(R({color:new v.Color("#ffffff"),resolution:new v.Vector2(t,s)},e))}addGeometries(e){const t=this.object3d,s=X([t.geometry,...e]);t.geometry=s}resize(e,t){var s,r;(r=(s=this.material)==null?void 0:s.uniforms)==null||r.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:s}=this.pencil.getSize();this.resize(t,s)}animate(e,t){var o,a;const{onComplete:s}=this.options,{offset:r}=this.material.uniforms;if(this.material.userData.tween)return;r.value.x=1;const n=new ut.Tween(r.value).to({x:0},(o=e!=null?e:this.options.duration)!=null?o:1e3).delay((a=t!=null?t:this.options.delay)!=null?a:0).repeat(1/0).onComplete(()=>{s&&s()}).start();this.material.userData.tween=n}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(e=!0){var t;e&&((t=this.material.userData.tween)==null||t.stop()),super.dispose(e)}}function xt(i,e){return i.map(t=>{const s=[];let r;return t.forEach(n=>{if(r){const o=re.geoDistance(n,r)*180/Math.PI;if(o>e){const a=re.geoInterpolate(r,n),c=1/Math.ceil(o/e);let u=c;for(;u<1;)s.push(a(u)),u+=c}}s.push(r=n)}),s})}function vt(i,{minLng:e,maxLng:t,minLat:s,maxLat:r}={}){const n=Math.round(Ce(360/i,2)/Math.PI),o=(1+Math.sqrt(5))/2,a=h=>h/o*360%360-180,c=h=>Math.acos(2*h/n-1)/Math.PI*180-90,u=h=>n*(Math.cos((h+90)*Math.PI/180)+1)/2,l=[r!==void 0?Math.ceil(u(r)):0,s!==void 0?Math.floor(u(s)):n-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,f=[];for(let h=l[0];h<=l[1];h++){const b=a(h);d(b)&&f.push([b,c(h)])}return f}function ye(i,e,t=!1){return t?re.geoContains(e,i):ct(i,e)}function wt(i,e){const t={type:"Polygon",coordinates:i},[[s,r],[n,o]]=re.geoBounds(t);if(Math.min(Math.abs(n-s),Math.abs(o-r))<e)return[];const a=s>n||o>=89||r<=-89;return vt(e,{minLng:s,maxLng:n,minLat:r,maxLat:o}).filter(c=>ye(c,t,a))}function At(i,{resolution:e=1/0,bbox:t}={}){const s=xt(i,e),r=Y.merge(s),n=wt(i,e),o=[...r,...n],a={type:"Polygon",coordinates:i},[[c,u],[l,d]]=re.geoBounds(a),f=c>l||d>=89||u<=-89;let h=[];if(f){const T=lt.geoVoronoi(o).triangles(),E=new Map(o.map(([P,U],I)=>[`${P}-${U}`,I]));T.features.forEach(P=>{const U=P.geometry.coordinates[0].slice(0,3).reverse(),I=[];if(U.forEach(([G,L])=>{const k=`${G}-${L}`;E.has(k)&&I.push(E.get(k))}),I.length===3){if(I.some(G=>G<r.length)){const G=P.properties.circumcenter;if(!ye(G,a,f))return}h.push(...I)}})}else if(n.length){const T=at.from(o);for(let E=0,P=T.triangles.length;E<P;E+=3){const U=[2,1,0].map(G=>T.triangles[E+G]),I=U.map(G=>o[G]);if(U.some(G=>G<r.length)){const G=[0,1].map(L=>Y.mean(I,k=>k[L]));if(!ye(G,a,f))continue}h.push(...U)}}else{const{vertices:T,holes:E=[]}=me.flatten(s);h=me(T,E,2)}const b=Re.scaleLinear(t?[t[0],t[2]]:Y.extent(o,T=>T[0]),[0,1]),x=Re.scaleLinear(t?[t[1],t[3]]:Y.extent(o,T=>T[1]),[0,1]),A=o.map(([T,E])=>[b(T),x(E)]);return{contour:s,triangles:{points:o,indices:h,uvs:A}}}const qe=new v.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function le(i,e,t,s){const r=i.map(n=>n.map(([o,a])=>{if(s){const[c,u]=s([o,a]);return[c,-u,e]}return t?ge.polar2Cartesian(o,a,e):[o,a,e]}));return me.flatten(r)}function Mt(i,e,t,s,r){const{vertices:n,holes:o}=le(i,e,s,r),{vertices:a}=le(i,t,s,r),c=Y.merge([a,n]),u=Math.round(a.length/3),l=new Set(o);let d=0;const f=[];for(let b=0;b<u;b++){let x=b+1;if(x===u)x=d;else if(l.has(x)){const A=x;x=d,d=A}f.push(b,b+u,x+u),f.push(x+u,x,b)}const h=[];for(let b=1;b>=0;b--)for(let x=0;x<u;x+=1)h.push(x/(u-1),b);return{indices:f,vertices:c,uvs:h,topVerts:a}}function ke(i,e,t,s,r,n){return{indices:s?i.indices:i.indices.slice().reverse(),vertices:le([i.points],e,r,n).vertices,uvs:t}}const De=({polygonGeoJson:i,startHeight:e,endHeight:t,curvatureResolution:s=1,cartesian:r=!0,hasSide:n=!0,hasBottom:o=!1,hasTop:a=!1,projection:c,bbox:u})=>{i.forEach(M=>{nt(M)||M.reverse()});const{contour:l,triangles:d}=At(i,{resolution:s,bbox:u});let f={},h;n&&(f=Mt(l,e!=null?e:t,t!=null?t:e,r,c),h=f.topVerts);let b=[];(o||a)&&(b=Y.merge(d.uvs));let x={};o&&(x=ke(d,e,b,!1,r,c));let A={};return a&&(A=ke(d,t,b,!0,r,c)),{contour:l,triangles:d,sideTorso:f,bottomCap:x,topCap:A,topVerts:h}};class Je extends v.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=R({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:s,hasTop:r,hasBottom:n,hasSide:o,cartesian:a,userDataRsoOffset:c,projection:u}=this.parameters,{contour:l,sideTorso:d,topVerts:f,bottomCap:h,topCap:b}=De(R({},this.parameters));let x=[],A=[],M=[],T=0;const E=P=>{const U=Math.round(x.length/3),I=M.length;x=x.concat(P.vertices),A=A.concat(P.uvs),M=M.concat(U?P.indices.map(G=>G+U):P.indices),this.addGroup(I,M.length-I,T++)};o&&(E(d),this.userData.topVerts=c?le(l,s+c,a,u).vertices:f),n&&E(h),r&&E(b),this.setIndex(M),this[qe]("position",new v.Float32BufferAttribute(x,3)),this[qe]("uv",new v.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const ze=i=>{const a=i,{coordinate:e,startHeight:t,height:s}=a,r=fe(a,["coordinate","startHeight","height"]);let n=t||0;return typeof t!="undefined"&&typeof s!="undefined"&&(n=t+s),new Je([e],Oe(R({},r),{startHeight:t,endHeight:n}))};class St extends Z.BaseObject{constructor(e){super(),this.options=R({},e)}create(){const c=this.options,{geometry:e,coordinateArr:t,coordinate:s,material:r,useGroups:n}=c,o=fe(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&s)a=ze(R({coordinate:s},o));else if(!a&&t){const u=t.map(l=>ze(R({coordinate:l},o)));a=X(u,n!=null?n:0)}this.createMesh(a,r)}}class xe extends _.BufferGeometry{constructor(e=new _.Shape([new _.Vector2(.5,.5),new _.Vector2(-.5,.5),new _.Vector2(-.5,-.5),new _.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const s=this,r=[],n=[];for(let a=0,c=e.length;a<c;a++){const u=e[a];o(u)}this.setAttribute("position",new _.Float32BufferAttribute(r,3)),this.setAttribute("uv",new _.Float32BufferAttribute(n,2)),this.computeVertexNormals();function o(a){var Se,_e,Ve;const c=[],u=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,h=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:h-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const M=t.extrudePath,T=t.UVGenerator!==void 0?t.UVGenerator:_t,E=(Se=t.hasTop)!=null?Se:!0,P=(_e=t.hasBottom)!=null?_e:!0,U=(Ve=t.hasSide)!=null?Ve:!0;let I,G=!1,L,k,ee,N;M&&(I=M.getSpacedPoints(l),G=!0,f=!1,L=M.computeFrenetFrames(l,!1),k=new _.Vector3,ee=new _.Vector3,N=new _.Vector3),f||(A=0,h=0,b=0,x=0);const ve=a.extractPoints(u);let q=ve.shape;const O=ve.holes;if(!_.ShapeUtils.isClockWise(q)){q=q.reverse();for(let p=0,m=O.length;p<m;p++){const g=O[p];_.ShapeUtils.isClockWise(g)&&(O[p]=g.reverse())}}const te=_.ShapeUtils.triangulateShape(q,O),z=q;for(let p=0,m=O.length;p<m;p++){const g=O[p];q=q.concat(g)}function K(p,m,g){return m||console.error("THREE.ExtrudeGeometry: vec does not exist"),p.clone().addScaledVector(m,g)}const F=q.length,ie=te.length;function we(p,m,g){let w,y,S;const V=p.x-m.x,B=p.y-m.y,C=g.x-p.x,j=g.y-p.y,se=V*V+B*B,he=V*j-B*C;if(Math.abs(he)>Number.EPSILON){const D=Math.sqrt(se),Ee=Math.sqrt(C*C+j*j),Te=m.x-B/D,Be=m.y+V/D,Ye=g.x-j/Ee,Ze=g.y+C/Ee,Pe=((Ye-Te)*j-(Ze-Be)*C)/(V*j-B*C);w=Te+V*Pe-p.x,y=Be+B*Pe-p.y;const Ge=w*w+y*y;if(Ge<=2)return new _.Vector2(w,y);S=Math.sqrt(Ge/2)}else{let D=!1;V>Number.EPSILON?C>Number.EPSILON&&(D=!0):V<-Number.EPSILON?C<-Number.EPSILON&&(D=!0):Math.sign(B)===Math.sign(j)&&(D=!0),D?(w=-B,y=V,S=Math.sqrt(se)):(w=V,y=B,S=Math.sqrt(se/2))}return new _.Vector2(w/S,y/S)}const oe=[];for(let p=0,m=z.length,g=m-1,w=p+1;p<m;p++,g++,w++)g===m&&(g=0),w===m&&(w=0),oe[p]=we(z[p],z[g],z[w]);const ue=[];let J,ne=oe.concat();for(let p=0,m=O.length;p<m;p++){const g=O[p];J=[];for(let w=0,y=g.length,S=y-1,V=w+1;w<y;w++,S++,V++)S===y&&(S=0),V===y&&(V=0),J[w]=we(g[w],g[S],g[V]);ue.push(J),ne=ne.concat(J)}for(let p=0;p<A;p++){const m=p/A,g=h*Math.cos(m*Math.PI/2),w=b*Math.sin(m*Math.PI/2)+x;for(let y=0,S=z.length;y<S;y++){const V=K(z[y],oe[y],w);W(V.x,V.y,-g)}for(let y=0,S=O.length;y<S;y++){const V=O[y];J=ue[y];for(let B=0,C=V.length;B<C;B++){const j=K(V[B],J[B],w);W(j.x,j.y,-g)}}}const Ae=b+x;for(let p=0;p<F;p++){const m=f?K(q[p],ne[p],Ae):q[p];G?(ee.copy(L.normals[0]).multiplyScalar(m.x),k.copy(L.binormals[0]).multiplyScalar(m.y),N.copy(I[0]).add(ee).add(k),W(N.x,N.y,N.z)):W(m.x,m.y,0)}for(let p=1;p<=l;p++)for(let m=0;m<F;m++){const g=f?K(q[m],ne[m],Ae):q[m];G?(ee.copy(L.normals[p]).multiplyScalar(g.x),k.copy(L.binormals[p]).multiplyScalar(g.y),N.copy(I[p]).add(ee).add(k),W(N.x,N.y,N.z)):W(g.x,g.y,d/l*p)}for(let p=A-1;p>=0;p--){const m=p/A,g=h*Math.cos(m*Math.PI/2),w=b*Math.sin(m*Math.PI/2)+x;for(let y=0,S=z.length;y<S;y++){const V=K(z[y],oe[y],w);W(V.x,V.y,d+g)}for(let y=0,S=O.length;y<S;y++){const V=O[y];J=ue[y];for(let B=0,C=V.length;B<C;B++){const j=K(V[B],J[B],w);G?W(j.x,j.y+I[l-1].y,I[l-1].x+g):W(j.x,j.y,d+g)}}}Xe(),U&&Ke();function Xe(){const p=r.length/3;if(f){let m=0,g=F*m;if(P)for(let w=0;w<ie;w++){const y=te[w];ae(y[2]+g,y[1]+g,y[0]+g)}if(m=l+A*2,g=F*m,E)for(let w=0;w<ie;w++){const y=te[w];ae(y[0]+g,y[1]+g,y[2]+g)}}else{if(P)for(let m=0;m<ie;m++){const g=te[m];ae(g[2],g[1],g[0])}if(E)for(let m=0;m<ie;m++){const g=te[m];ae(g[0]+F*l,g[1]+F*l,g[2]+F*l)}}s.addGroup(p,r.length/3-p,0)}function Ke(){const p=r.length/3;let m=0;Me(z,m),m+=z.length;for(let g=0,w=O.length;g<w;g++){const y=O[g];Me(y,m),m+=y.length}s.addGroup(p,r.length/3-p,1)}function Me(p,m){let g=p.length;for(;--g>=0;){const w=g;let y=g-1;y<0&&(y=p.length-1);for(let S=0,V=l+A*2;S<V;S++){const B=F*S,C=F*(S+1),j=m+w+B,se=m+y+B,he=m+y+C,D=m+w+C;Qe(j,se,he,D)}}}function W(p,m,g){c.push(p),c.push(m),c.push(g)}function ae(p,m,g){$(p),$(m),$(g);const w=r.length/3,y=T.generateTopUV(s,r,w-3,w-2,w-1);H(y[0]),H(y[1]),H(y[2])}function Qe(p,m,g,w){$(p),$(m),$(w),$(m),$(g),$(w);const y=r.length/3,S=T.generateSideWallUV(s,r,y-6,y-3,y-2,y-1);H(S[0]),H(S[1]),H(S[3]),H(S[1]),H(S[2]),H(S[3])}function $(p){r.push(c[p*3+0]),r.push(c[p*3+1]),r.push(c[p*3+2])}function H(p){n.push(p.x),n.push(p.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,s=this.parameters.options;return Vt(t,s,e)}static fromJSON(e,t){const s=[];for(let n=0,o=e.shapes.length;n<o;n++){const a=t[e.shapes[n]];s.push(a)}const r=e.options.extrudePath;return console.log(r.type),r!==void 0&&(e.options.extrudePath=new v[`${r.type}Curve`]().fromJSON(r)),new xe(s,e.options)}}const _t={generateTopUV:function(i,e,t,s,r){const n=e[t*3],o=e[t*3+1],a=e[s*3],c=e[s*3+1],u=e[r*3],l=e[r*3+1];return[new _.Vector2(n,o),new _.Vector2(a,c),new _.Vector2(u,l)]},generateSideWallUV:function(i,e,t,s,r,n){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],u=e[s*3],l=e[s*3+1],d=e[s*3+2],f=e[r*3],h=e[r*3+1],b=e[r*3+2],x=e[n*3],A=e[n*3+1],M=e[n*3+2];return Math.abs(a-l)<Math.abs(o-u)?[new _.Vector2(o,1-c),new _.Vector2(u,1-d),new _.Vector2(f,1-b),new _.Vector2(x,1-M)]:[new _.Vector2(a,1-c),new _.Vector2(l,1-d),new _.Vector2(h,1-b),new _.Vector2(A,1-M)]}};function Vt(i,e,t){if(t.shapes=[],Array.isArray(i))for(let s=0,r=i.length;s<r;s++){const n=i[s];t.shapes.push(n.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}const Ne=i=>{const{split:e,depth:t,points:s,box3:r,hasTop:n,hasBottom:o,hasSide:a,sideRepeat:c}=i,u=new xe(new v.Shape(s),{depth:t,bevelEnabled:!1,UVGenerator:ge.getUVGenerator({split:e,box3:r,sideRepeat:c}),hasTop:n,hasBottom:o,hasSide:a});return ge.claerUVGenerator(),u};class Et extends Z.BaseObject{constructor(e){super(),this.options=R({depth:1},e)}create(){return Q(this,null,function*(){const{points:e,pointsArr:t,useGroups:s,depth:r,geometry:n,geometryArr:o,material:a,box3:c,split:u,hasTop:l,hasBottom:d,hasSide:f,useUserDataPos:h}=this.options,b=Array.isArray(r)?r:[r],x=Array.isArray(c)?c:[c],A=a;let M=n;if(A||console.log("material is null"),!M&&e?M=Ne({points:e,depth:b[0],box3:x[0],split:u,hasTop:l,hasBottom:d,hasSide:f}):!M&&t?M=X(t.map((T,E)=>{var P,U;return Ne({points:T,depth:(P=b[E])!=null?P:b[0],box3:(U=x[E])!=null?U:x[0],split:u,hasTop:l,hasBottom:d,hasSide:f})}),s!=null?s:0):!M&&o&&o.length>1?M=X(o,s!=null?s:0):!M&&o&&o.length===1&&([M]=o),this.createMesh(M,A),h&&(M!=null&&M.userData.position)){const{x:T,y:E,z:P}=M.userData.position;this.object3d.position.set(T,E,P)}})}addGeometries(e){const t=this.object3d,s=X([t.geometry,...e]);t.geometry=s}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Tt=i=>{const{topColor:e,sideColor:t,sideMap:s,createCanvasObjectURL:r,split:n,maxAnisotropy:o}=i;return new Promise(a=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const u=n,l=document.createElement("canvas"),d=l.getContext("2d");l.height=c.height/(1-u),l.width=c.width,u&&e&&(d.fillStyle=e,d.fillRect(0,0,c.width,l.height*u)),s&&c instanceof HTMLImageElement?d.drawImage(c,0,l.height*u,c.width,c.height):t&&(d.fillStyle=t,d.fillRect(0,l.height*u,c.width,c.height)),r&&l.toBlob(h=>{console.log(URL.createObjectURL(h))});const f=new v.CanvasTexture(l);a(f)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=it.Group;exports.MeshLineMaterial=be.MeshLineMaterial;exports.meshLineMaterialArr=be.meshLineMaterialArr;exports.ConicPolygon=St;exports.ExtrudePolygon=Et;exports.Image=$e;exports.Line=bt;exports.MeshLineGeometry=He;exports.MeshLineRaycast=gt;exports.Node=pt;exports.Text=ft;exports.Video=dt;exports.getConicPolygonGeometry=Je;exports.getConicPolygonGeometryMetas=De;exports.getSplitTexture=Tt;
|
|
@@ -661,7 +661,7 @@ class ts extends Y {
|
|
|
661
661
|
}
|
|
662
662
|
dispose(t = !0) {
|
|
663
663
|
var e;
|
|
664
|
-
(e = this.material.userData.tween) == null || e.stop(), super.dispose(t);
|
|
664
|
+
t && ((e = this.material.userData.tween) == null || e.stop()), super.dispose(t);
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
function Ae(o, t) {
|