gl-draw 0.9.18 → 0.9.20

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.
@@ -1 +1 @@
1
- "use strict";var ee=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var lt=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable;var Ct=Math.pow,It=(o,t,e)=>t in o?ee(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,C=(o,t)=>{for(var e in t||(t={}))Lt.call(t,e)&&It(o,e,t[e]);if(lt)for(var e of lt(t))Ut.call(t,e)&&It(o,e,t[e]);return o},Ot=(o,t)=>se(o,ie(t));var ft=(o,t)=>{var e={};for(var s in o)Lt.call(o,s)&&t.indexOf(s)<0&&(e[s]=o[s]);if(o!=null&&lt)for(var s of lt(o))t.indexOf(s)<0&&Ut.call(o,s)&&(e[s]=o[s]);return e};var Z=(o,t,e)=>new Promise((s,i)=>{var r=c=>{try{a(e.next(c))}catch(h){i(h)}},n=c=>{try{a(e.throw(c))}catch(h){i(h)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(r,n);a((e=e.apply(o,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("three"),X=require("../BaseObject.js"),re=require("esus-lite"),ne=require("../index2.js"),oe=require("@tweenjs/tween.js"),xt=require("../MeshLineMaterial.js"),Y=require("d3-array"),gt=require("earcut"),ae=require("@turf/boolean-clockwise"),yt=require("../uvGenerator.js"),ce=require("delaunator"),le=require("@turf/boolean-point-in-polygon"),rt=require("d3-geo"),he=require("d3-geo-voronoi"),Rt=require("d3-scale");function Ft(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const v=Ft(_),it=Ft(oe),ue=+v.REVISION<144,Ht=ue?"PlaneBufferGeometry":"PlaneGeometry";class Wt extends X.BaseObject{constructor(t){super(),this.scaleValue=1,this.options=C({scale:1},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}getMaterial(){return Z(this,null,function*(){const{src:t,texture:e,transparent:s,opacity:i,blending:r,depthWrite:n,depthTest:a,alphaTest:c,sprite:h,sizeAttenuation:l,color:d}=this.options,f=e||(yield new v.TextureLoader().loadAsync(t));return h?new v.SpriteMaterial({map:f,transparent:s!=null?s:!1,blending:r!=null?r:v.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:i!=null?i:1,sizeAttenuation:l!=null?l:!0}):new v.MeshBasicMaterial({color:d!=null?d:16777215,map:f,transparent:s!=null?s:!1,blending:r!=null?r:v.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:i!=null?i:1})})}create(){return Z(this,null,function*(){const{position:t,material:e,sprite:s}=this.options,i=e||(yield this.getMaterial());s?this.createSprite(i):this.createMesh(new v[Ht](1,1),i),t&&this.object3d.position.copy(t)})}render(){const{scale:t}=this.options;this.setScale(t)}setScale(t){this.scaleValue=t;const e=this.material.map;e!=null&&e.image?this.object3d.scale.set(e.image.width*t,e.image.height*t,1):this.object3d.scale.set(t,t,1)}setTexture(t){const e=this.object3d;e.material.map&&e.material.map.dispose(),e.material.map=t,e.material.needsUpdate=!0,this.setScale(this.scaleValue)}}class de extends Wt{constructor(t){super(t),this.canvas=document.createElement("canvas")}getTexture(){const{text:t,textOptions:e}=this.options,{fontSize:s,fontFamily:i,fontWeight:r,flipX:n,color:a,setCtx:c}=C({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:u=>{}},e||{}),{canvas:h}=this;h.width=s*t.length*2,h.height=s;let l=h.getContext("2d");l.font=`${r} ${s}px/1 ${i}`;const{width:d}=l.measureText(t);h.width=d,l=h.getContext("2d"),l.clearRect(0,0,h.width,h.height),n&&l.scale(-1,1),l.font=`${r} ${s}px/1 ${i}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(t,n?d*-1:0,h.height/2),l.restore();const f=new v.Texture(h);return f.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),f.needsUpdate=!0,Promise.resolve(f)}}class fe extends X.BaseObject{constructor(t){super(),this.scaleValue=1,this.options=C({scale:1,autoPlay:!0,loop:!0},t)}getMaterial(){const{src:t,transparent:e,blending:s,depthWrite:i,depthTest:r,format:n,autoPlay:a,loop:c,alphaTest:h,sprite:l}=this.options,d=re.makePromiseCreator();if(!t)return Promise.reject("src is required");const f=document.createElement("video");return f.addEventListener("loadedmetadata",()=>{const u=new v.VideoTexture(f);u.format=n!=null?n:v.RGBAFormat,u.needsUpdate=!0;const b=l?new v.SpriteMaterial({map:u,transparent:e!=null?e:!1,blending:s!=null?s:v.NormalBlending,depthWrite:i!=null?i:!0,depthTest:r!=null?r:!0,alphaTest:h!=null?h:0}):new v.MeshBasicMaterial({map:u,transparent:e!=null?e:!1,blending:s!=null?s:v.NormalBlending,depthWrite:i!=null?i:!0,depthTest:r!=null?r:!0,alphaTest:h!=null?h:0});d.resolve(b)},!1),f.src=t,f.muted=!0,f.autoplay=a,f.loop=c,f.preload="auto",d.promise}create(){return Z(this,null,function*(){const{scale:t,position:e,src:s,cache:i,sprite:r}=this.options,n=s&&(i?yield i.get(s,()=>this.getMaterial()):yield this.getMaterial());this.video=n.map.image,r?this.createSprite(n):this.createMesh(new v[Ht](1,1),n),this.setScale(t),e&&this.object3d.position.copy(e)})}setScale(t){this.scaleValue=t,this.object3d.scale.set(this.video.videoWidth*t,this.video.videoHeight*t,1)}render(){const{autoPlay:t}=this.options;t&&this.video.play()}dispose(){this.video.pause(),this.video.src="",super.dispose()}}class pe extends X.BaseObject{constructor(t){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.options=C({event:"click",type:"2d"},t)}get clickTarge(){const{eventTarge:t}=this.options;return t?t.map(s=>[...this.element.querySelectorAll(s)]).flat():[this.element]}create(){const{position:t,children:e,handler:s,event:i}=this.options,r=document.createElement("div");this.element=r,e&&r.appendChild(e),this.options.type==="3d"?this.createCSS3DObject(r):this.options.type==="3dSprite"?this.createCSS3DSprite(r):this.createCSS2DObject(r),t&&this.object3d.position.copy(t),s&&i&&this.clickTarge.forEach(n=>{const a=Array.isArray(i)?i:[i],c=Array.isArray(s)?s:[s];a.forEach((h,l)=>{const d=c[l];d&&n.addEventListener(h,d)})})}setChildren(t){this.element.innerHTML="",this.element.appendChild(t)}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:t,event:e}=this.options;t&&e&&this.clickTarge.forEach(s=>{const i=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t];i.forEach((n,a)=>{const c=r[a];c&&s.removeEventListener(n,c)})}),super.dispose()}}class me extends X.BaseObject{constructor(t){super(),this.options=C({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},t)}create(){return Z(this,null,function*(){this.createGroup();const{data:t,maxDepth:e,colors:s,material:i,percentDepth:r,activeIndex:n}=this.options,a=Math.max(...t),c=t.reduce((l,d)=>l+d,0);let h=Math.PI/2;t.forEach((l,d)=>{if(l===0)return;const f=Math.PI*2*(l/c),u=s[d],b=r?e*(l/a):e,p=this.createGeometry(b,f),A=i?i.clone():new v.MeshBasicMaterial({color:u});i&&A.color.set(u);const S=new v.Mesh(p,A);S.userData.depth=b,S.userData.index=d,S.rotateZ(h),h+=f,this.add(S)}),n!==-1&&this.setActive(n)})}createGeometry(t,e){const{outRadius:s,innerRadius:i}=this.options,r=new v.Shape;return r.moveTo(s,0),r.lineTo(i,0),r.absarc(0,0,i,0,e,!1),r.absarc(0,0,s,e,0,!0),new v.ExtrudeGeometry(r,{curveSegments:48,depth:t,bevelEnabled:!1})}handlePick(t,e=1.3){const{object:s}=this.pencil.pick(t,this.object3d.children)||{},i=s?this.object3d.children.findIndex(r=>r===s):this.options.activeIndex;return this.setActive(i,e)}setActive(t,e=1.3){const s=this.object3d.children[t];if(this.object3d.children.forEach(i=>{if(!(s&&s===i)&&i.scale.z!==1){if(i.userData.levTween)return;i.userData.enTween&&(i.userData.enTween.stop(),i.userData.enTween=null);const r=new it.Tween(i.scale).to({z:1},100);i.userData.levTween=r,r.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new it.Tween(s.scale).to({z:e},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new it.Tween(this.object3d.scale).to({z:1},1e3).easing(it.Easing.Sinusoidal.InOut).start()}}class ge extends X.BaseObject{constructor(t){super(),this.options=t}create(){var e,s,i,r,n,a,c,h,l,d,f,u,b;const t=this.options;if(t.type==="AmbientLight"){const p=new v.AmbientLight(t.color);p.name="AmbientLight",this.object3d=p}else if(t.type==="DirectionalLight"){const p=new v.DirectionalLight(t.color,t.intensity);p.name="DirectionalLight",p.target.position.set(0,0,0),this.object3d=p,this.pencil.scene.add(p.target),this.directionalLight=p}else if(t.type==="PointLight"){const p=new v.PointLight((e=t.color)!=null?e:16777215,(s=t.intensity)!=null?s:1,(i=t.distance)!=null?i:0,(r=t.decay)!=null?r:2);p.name="PointLight",this.object3d=p,this.pointLight=p}else if(t.type==="SpotLight"){const p=new v.SpotLight((n=t.color)!=null?n:16777215,(a=t.intensity)!=null?a:1,(c=t.distance)!=null?c:0,(h=t.angle)!=null?h:Math.PI/3,(l=t.penumbra)!=null?l:1,(d=t.decay)!=null?d:2);p.name="SpotLight",this.object3d=p,this.spotLight=p,this.pencil.scene.add(p.target)}else if(t.type==="HemisphereLight"){const p=new v.HemisphereLight((f=t.color)!=null?f:16777215,(u=t.groundColor)!=null?u:16777215,(b=t.intensity)!=null?b:1);p.name="HemisphereLight",this.object3d=p,this.hemisphereLight=p}}render(){const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const e=this.spotLight||this.directionalLight;e.position.copy(t),e.target.position.copy(t)}else this.pointLight&&this.pointLight.position.copy(t)}dispose(){const t=this.object3d;t.target&&this.pencil.scene.remove(t.target),super.dispose()}}function pt(o,t,e,s,i){let r;if(o=o.subarray||o.slice?o:o.buffer,e=e.subarray||e.slice?e:e.buffer,o=t?o.subarray?o.subarray(t,i&&t+i):o.slice(t,i&&t+i):o,e.set)e.set(o,s);else for(r=0;r<o.length;r++)e[r+s]=o[r];return e}function ye(o){return o instanceof Float32Array?o:o instanceof v.BufferGeometry?o.getAttribute("position").array:o.map(t=>{const e=Array.isArray(t);return t instanceof v.Vector3?[t.x,t.y,t.z]:t instanceof v.Vector2?[t.x,t.y,0]:e&&t.length===3?[t[0],t[1],t[2]]:e&&t.length===2?[t[0],t[1],0]:t}).flat()}class $t 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(t){this.setPoints(t,this.widthCallback)}}})}setMatrixWorld(t){this.matrixWorld=t}setPoints(t,e){if(t=ye(t),this._points=t,this.widthCallback=e!=null?e:null,this.positions=[],this.counters=[],t.length&&t[0]instanceof v.Vector3)for(let s=0;s<t.length;s++){const i=t[s],r=s/(t.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(r),this.counters.push(r)}else for(let s=0;s<t.length;s+=3){const i=s/(t.length-1);this.positions.push(t[s],t[s+1],t[s+2]),this.positions.push(t[s],t[s+1],t[s+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(t,e){const s=t*6,i=e*6;return this.positions[s]===this.positions[i]&&this.positions[s+1]===this.positions[i+1]&&this.positions[s+2]===this.positions[i+2]}copyV3(t){const e=t*6;return[this.positions[e],this.positions[e+1],this.positions[e+2]]}process(){const t=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let e,s;this.compareV3(0,t-1)?s=this.copyV3(t-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 i=0;i<t;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?e=this.widthCallback(i/(t-1)):e=1,this.width.push(e),this.width.push(e),this.uvs.push(i/(t-1),0),this.uvs.push(i/(t-1),1),i<t-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const r=i*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}i>0&&(s=this.copyV3(i),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(t-1,0)?s=this.copyV3(1):s=this.copyV3(t-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:t,y:e,z:s}){const i=this._attributes.position.array,r=this._attributes.previous.array,n=this._attributes.next.array,a=i.length;pt(i,0,r,0,a),pt(i,6,i,0,a-6),i[a-6]=t,i[a-5]=e,i[a-4]=s,i[a-3]=t,i[a-2]=e,i[a-1]=s,pt(i,6,n,0,a-6),n[a-6]=t,n[a-5]=e,n[a-4]=s,n[a-3]=t,n[a-2]=e,n[a-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function be(o,t){const e=new v.Matrix4,s=new v.Ray,i=new v.Sphere,r=new v.Vector3,n=this.geometry;if(i.copy(n.boundingSphere),i.applyMatrix4(this.matrixWorld),!o.ray.intersectSphere(i,r))return;e.copy(this.matrixWorld).invert(),s.copy(o.ray).applyMatrix4(e);const a=new v.Vector3,c=new v.Vector3,h=new v.Vector3,l=this instanceof v.LineSegments?2:1,d=n.index,f=n.attributes;if(d!==null){const u=d.array,b=f.position.array,p=f.width.array;for(let A=0,S=u.length-1;A<S;A+=l){const P=u[A],V=u[A+1];a.fromArray(b,P*3),c.fromArray(b,V*3);const B=p[Math.floor(A/3)]!=null?p[Math.floor(A/3)]:1,I=o.params.Line.threshold+this.material.lineWidth*B/2,j=I*I;if(s.distanceSqToSegment(a,c,r,h)>j)continue;r.applyMatrix4(this.matrixWorld);const R=o.ray.origin.distanceTo(r);R<o.near||R>o.far||(t.push({distance:R,point:h.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=S)}}}function K(o,t=0){const e=o[0].index!==null,s=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),r={},n={},a=o[0].morphTargetsRelative,c=new _.BufferGeometry;let h=0;for(let l=0;l<o.length;++l){const d=o[l];let f=0;if(e!==(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 u in d.attributes){if(!s.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),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 u in d.morphAttributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;n[u]===void 0&&(n[u]=[]),n[u].push(d.morphAttributes[u])}if(t){let u;if(e)u=d.index.count;else if(d.attributes.position!==void 0)u=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(t===1)c.addGroup(h,u,l);else if(t===2&&d.groups.length>0)for(let b of d.groups){let p=b.materialIndex;c.addGroup(h+b.start,Math.min(b.count,u),p)}h+=u}}if(e){let l=0;const d=[];for(let f=0;f<o.length;++f){const u=o[f].index;for(let b=0;b<u.count;++b)d.push(u.getX(b)+l);l+=o[f].attributes.position.count}c.setIndex(d)}for(const l in r){const d=zt(r[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 n){const d=n[l][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let f=0;f<d;++f){const u=[];for(let p=0;p<n[l].length;++p)u.push(n[l][p][f]);const b=zt(u);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;c.morphAttributes[l].push(b)}}return t===2?xe(c):c}function zt(o){let t,e,s,i=-1,r=0;for(let h=0;h<o.length;++h){const l=o[h];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==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(i===-1&&(i=l.gpuType),i!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=l.array.length}const n=new t(r);let a=0;for(let h=0;h<o.length;++h)n.set(o[h].array,a),a+=o[h].array.length;const c=new _.BufferAttribute(n,e,s);return i!==void 0&&(c.gpuType=i),c}function xe(o){if(o.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),o;let t=o.groups;if(t=t.sort((n,a)=>n.materialIndex!==a.materialIndex?n.materialIndex-a.materialIndex:n.start-a.start),o.getIndex()===null){const n=o.getAttribute("position"),a=[];for(let c=0;c<n.count;c+=3)a.push(c,c+1,c+2);o.setIndex(a),a.length=0}const e=o.getIndex(),s=[];for(let n=0;n<t.length;n++){const a=t[n],c=a.start,h=c+a.count;for(let l=c;l<h;l++)s.push(e.getX(l))}o.dispose(),o.setIndex(s),s.length=0;let i=0;for(let n=0;n<t.length;n++){const a=t[n];a.start=i,i+=a.count}let r=t[0];o.groups=[r];for(let n=1;n<t.length;n++){const a=t[n];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,o.groups.push(r))}return o}const mt=o=>{const{setPointWidth:t,nodes:e}=o,s=new $t;return s.setPoints(e,t),s};class ve extends X.BaseObject{constructor(t={}){super(),this.options=C({delay:0,duration:1e3},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return Z(this,null,function*(){const{nodes:t,nodesArr:e,geometry:s,geometryArr:i,material:r,useGroups:n,setPointWidth:a,lineWidthArr:c,useUserDataPos:h,materialParameters:l}=this.options;let d=r,f=s;if(!d&&l&&(d=this.getMaterial(l)),!f&&t?f=mt({nodes:t,setPointWidth:a}):!f&&e?f=K(e.map((u,b)=>{let p=a;return!p&&c&&(p=()=>{var A;return(A=c[b])!=null?A:c[0]}),mt({nodes:u,setPointWidth:p})}),n!=null?n:0):!f&&i&&i.length>1?f=K(i,n!=null?n:0):!f&&i&&i.length===1&&([f]=i),this.createMesh(f,d),h&&(f!=null&&f.userData.position)){const{x:u,y:b,z:p}=f.userData.position;this.object3d.position.set(u,b,p)}})}setGeometry(t,e){const s=mt({nodes:t,setPointWidth:e}),i=this.object3d,r=i.geometry;i.geometry=s,r.dispose()}getMaterial(t){const{width:e,height:s}=this.pencil.getSize();return new xt.MeshLineMaterial(C({color:new v.Color("#ffffff"),resolution:new v.Vector2(e,s)},t))}addGeometries(t){const e=this.object3d,s=K([e.geometry,...t]);e.geometry=s}resize(t,e){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(t,e)}useMaterial(t){super.useMaterial(t);const{width:e,height:s}=this.pencil.getSize();this.resize(e,s)}animate({duration:t,delay:e,repeat:s,lineLoop:i}={}){const{onComplete:r}=this.options,{offset:n,offsetLoop:a}=this.material.uniforms;if(this.material.userData.tween)return;const c=i!=null?i:!0;n.value.x=1,a.value=0;const h=new it.Tween(n.value).to({x:-1},t!=null?t:this.options.duration).delay(e!=null?e:this.options.delay).repeat(s!=null?s:0).onUpdate(({x:l})=>{c&&l<=0&&a.value===0&&(a.value=1)}).onComplete(()=>{r&&r()}).start();this.material.userData.tween=h}render(){const{width:t,height:e}=this.pencil.getSize();this.resize(t,e)}dispose(t=!0){var e;t&&((e=this.material.userData.tween)==null||e.stop()),super.dispose(t)}}function we(o,t){return o.map(e=>{const s=[];let i;return e.forEach(r=>{if(i){const n=rt.geoDistance(r,i)*180/Math.PI;if(n>t){const a=rt.geoInterpolate(i,r),c=1/Math.ceil(n/t);let h=c;for(;h<1;)s.push(a(h)),h+=c}}s.push(i=r)}),s})}function Ae(o,{minLng:t,maxLng:e,minLat:s,maxLat:i}={}){const r=Math.round(Ct(360/o,2)/Math.PI),n=(1+Math.sqrt(5))/2,a=u=>u/n*360%360-180,c=u=>Math.acos(2*u/r-1)/Math.PI*180-90,h=u=>r*(Math.cos((u+90)*Math.PI/180)+1)/2,l=[i!==void 0?Math.ceil(h(i)):0,s!==void 0?Math.floor(h(s)):r-1],d=t===void 0&&e===void 0?()=>!0:t===void 0?u=>u<=e:e===void 0?u=>u>=t:e>=t?u=>u>=t&&u<=e:u=>u>=t||u<=e,f=[];for(let u=l[0];u<=l[1];u++){const b=a(u);d(b)&&f.push([b,c(u)])}return f}function bt(o,t,e=!1){return e?rt.geoContains(t,o):le(o,t)}function Se(o,t){const e={type:"Polygon",coordinates:o},[[s,i],[r,n]]=rt.geoBounds(e);if(Math.min(Math.abs(r-s),Math.abs(n-i))<t)return[];const a=s>r||n>=89||i<=-89;return Ae(t,{minLng:s,maxLng:r,minLat:i,maxLat:n}).filter(c=>bt(c,e,a))}function Me(o,{resolution:t=1/0,bbox:e}={}){const s=we(o,t),i=Y.merge(s),r=Se(o,t),n=[...i,...r],a={type:"Polygon",coordinates:o},[[c,h],[l,d]]=rt.geoBounds(a),f=c>l||d>=89||h<=-89;let u=[];if(f){const P=he.geoVoronoi(n).triangles(),V=new Map(n.map(([B,I],j)=>[`${B}-${I}`,j]));P.features.forEach(B=>{const I=B.geometry.coordinates[0].slice(0,3).reverse(),j=[];if(I.forEach(([G,R])=>{const k=`${G}-${R}`;V.has(k)&&j.push(V.get(k))}),j.length===3){if(j.some(G=>G<i.length)){const G=B.properties.circumcenter;if(!bt(G,a,f))return}u.push(...j)}})}else if(r.length){const P=ce.from(n);for(let V=0,B=P.triangles.length;V<B;V+=3){const I=[2,1,0].map(G=>P.triangles[V+G]),j=I.map(G=>n[G]);if(I.some(G=>G<i.length)){const G=[0,1].map(R=>Y.mean(j,k=>k[R]));if(!bt(G,a,f))continue}u.push(...I)}}else{const{vertices:P,holes:V=[]}=gt.flatten(s);u=gt(P,V,2)}const b=Rt.scaleLinear(e?[e[0],e[2]]:Y.extent(n,P=>P[0]),[0,1]),p=Rt.scaleLinear(e?[e[1],e[3]]:Y.extent(n,P=>P[1]),[0,1]),A=n.map(([P,V])=>[b(P),p(V)]);return{contour:s,triangles:{points:n,indices:u,uvs:A}}}const kt=new v.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function ht(o,t,e,s){const i=o.map(r=>r.map(([n,a])=>{if(s){const[c,h]=s([n,a]);return[c,-h,t]}return e?yt.polar2Cartesian(n,a,t):[n,a,t]}));return gt.flatten(i)}function _e(o,t,e,s,i){const{vertices:r,holes:n}=ht(o,t,s,i),{vertices:a}=ht(o,e,s,i),c=Y.merge([a,r]),h=Math.round(a.length/3),l=new Set(n);let d=0;const f=[];for(let b=0;b<h;b++){let p=b+1;if(p===h)p=d;else if(l.has(p)){const A=p;p=d,d=A}f.push(b,b+h,p+h),f.push(p+h,p,b)}const u=[];for(let b=1;b>=0;b--)for(let p=0;p<h;p+=1)u.push(p/(h-1),b);return{indices:f,vertices:c,uvs:u,topVerts:a}}function Dt(o,t,e,s,i,r){return{indices:s?o.indices:o.indices.slice().reverse(),vertices:ht([o.points],t,i,r).vertices,uvs:e}}const Jt=({polygonGeoJson:o,startHeight:t,endHeight:e,curvatureResolution:s=1,cartesian:i=!0,hasSide:r=!0,hasBottom:n=!1,hasTop:a=!1,projection:c,bbox:h})=>{o.forEach(S=>{ae(S)||S.reverse()});const{contour:l,triangles:d}=Me(o,{resolution:s,bbox:h});let f={},u;r&&(f=_e(l,t!=null?t:e,e!=null?e:t,i,c),u=f.topVerts);let b=[];(n||a)&&(b=Y.merge(d.uvs));let p={};n&&(p=Dt(d,t,b,!1,i,c));let A={};return a&&(A=Dt(d,e,b,!0,i,c)),{contour:l,triangles:d,sideTorso:f,bottomCap:p,topCap:A,topVerts:u}};class Xt extends v.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=C({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:s,hasTop:i,hasBottom:r,hasSide:n,cartesian:a,userDataRsoOffset:c,projection:h}=this.parameters,{contour:l,sideTorso:d,topVerts:f,bottomCap:u,topCap:b}=Jt(C({},this.parameters));let p=[],A=[],S=[],P=0;const V=B=>{const I=Math.round(p.length/3),j=S.length;p=p.concat(B.vertices),A=A.concat(B.uvs),S=S.concat(I?B.indices.map(G=>G+I):B.indices),this.addGroup(j,S.length-j,P++)};n&&(V(d),this.userData.topVerts=c?ht(l,s+c,a,h).vertices:f),r&&V(u),i&&V(b),this.setIndex(S),this[kt]("position",new v.Float32BufferAttribute(p,3)),this[kt]("uv",new v.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const qt=o=>{const a=o,{coordinate:t,startHeight:e,height:s}=a,i=ft(a,["coordinate","startHeight","height"]);let r=e||0;return typeof e!="undefined"&&typeof s!="undefined"&&(r=e+s),new Xt([t],Ot(C({},i),{startHeight:e,endHeight:r}))};class Te extends X.BaseObject{constructor(t){super(),this.options=C({},t)}create(){const c=this.options,{geometry:t,coordinateArr:e,coordinate:s,material:i,useGroups:r}=c,n=ft(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=t;if(!a&&s)a=qt(C({coordinate:s},n));else if(!a&&e){const h=e.map(l=>qt(C({coordinate:l},n)));a=K(h,r!=null?r:0)}this.createMesh(a,i)}}class vt extends _.BufferGeometry{constructor(t=new _.Shape([new _.Vector2(.5,.5),new _.Vector2(-.5,.5),new _.Vector2(-.5,-.5),new _.Vector2(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const s=this,i=[],r=[];for(let a=0,c=t.length;a<c;a++){const h=t[a];n(h)}this.setAttribute("position",new _.Float32BufferAttribute(i,3)),this.setAttribute("uv",new _.Float32BufferAttribute(r,2)),this.computeVertexNormals();function n(a){var _t,Tt,Vt;const c=[],h=e.curveSegments!==void 0?e.curveSegments:12,l=e.steps!==void 0?e.steps:1,d=e.depth!==void 0?e.depth:1;let f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,u=e.bevelThickness!==void 0?e.bevelThickness:.2,b=e.bevelSize!==void 0?e.bevelSize:u-.1,p=e.bevelOffset!==void 0?e.bevelOffset:0,A=e.bevelSegments!==void 0?e.bevelSegments:3;const S=e.extrudePath,P=e.UVGenerator!==void 0?e.UVGenerator:Ve,V=(_t=e.hasTop)!=null?_t:!0,B=(Tt=e.hasBottom)!=null?Tt:!0,I=(Vt=e.hasSide)!=null?Vt:!0;let j,G=!1,R,k,tt,q;S&&(j=S.getSpacedPoints(l),G=!0,f=!1,R=S.computeFrenetFrames(l,!1),k=new _.Vector3,tt=new _.Vector3,q=new _.Vector3),f||(A=0,u=0,b=0,p=0);const wt=a.extractPoints(h);let z=wt.shape;const O=wt.holes;if(!_.ShapeUtils.isClockWise(z)){z=z.reverse();for(let m=0,g=O.length;m<g;m++){const y=O[m];_.ShapeUtils.isClockWise(y)&&(O[m]=y.reverse())}}const et=_.ShapeUtils.triangulateShape(z,O),D=z;for(let m=0,g=O.length;m<g;m++){const y=O[m];z=z.concat(y)}function Q(m,g,y){return g||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(g,y)}const N=z.length,nt=et.length;function At(m,g,y){let w,x,M;const T=m.x-g.x,E=m.y-g.y,U=y.x-m.x,L=y.y-m.y,st=T*T+E*E,dt=T*L-E*U;if(Math.abs(dt)>Number.EPSILON){const $=Math.sqrt(st),Pt=Math.sqrt(U*U+L*L),Et=g.x-E/$,Bt=g.y+T/$,Yt=y.x-L/Pt,te=y.y+U/Pt,Gt=((Yt-Et)*L-(te-Bt)*U)/(T*L-E*U);w=Et+T*Gt-m.x,x=Bt+E*Gt-m.y;const jt=w*w+x*x;if(jt<=2)return new _.Vector2(w,x);M=Math.sqrt(jt/2)}else{let $=!1;T>Number.EPSILON?U>Number.EPSILON&&($=!0):T<-Number.EPSILON?U<-Number.EPSILON&&($=!0):Math.sign(E)===Math.sign(L)&&($=!0),$?(w=-E,x=T,M=Math.sqrt(st)):(w=T,x=E,M=Math.sqrt(st/2))}return new _.Vector2(w/M,x/M)}const ot=[];for(let m=0,g=D.length,y=g-1,w=m+1;m<g;m++,y++,w++)y===g&&(y=0),w===g&&(w=0),ot[m]=At(D[m],D[y],D[w]);const ut=[];let J,at=ot.concat();for(let m=0,g=O.length;m<g;m++){const y=O[m];J=[];for(let w=0,x=y.length,M=x-1,T=w+1;w<x;w++,M++,T++)M===x&&(M=0),T===x&&(T=0),J[w]=At(y[w],y[M],y[T]);ut.push(J),at=at.concat(J)}for(let m=0;m<A;m++){const g=m/A,y=u*Math.cos(g*Math.PI/2),w=b*Math.sin(g*Math.PI/2)+p;for(let x=0,M=D.length;x<M;x++){const T=Q(D[x],ot[x],w);F(T.x,T.y,-y)}for(let x=0,M=O.length;x<M;x++){const T=O[x];J=ut[x];for(let E=0,U=T.length;E<U;E++){const L=Q(T[E],J[E],w);F(L.x,L.y,-y)}}}const St=b+p;for(let m=0;m<N;m++){const g=f?Q(z[m],at[m],St):z[m];G?(tt.copy(R.normals[0]).multiplyScalar(g.x),k.copy(R.binormals[0]).multiplyScalar(g.y),q.copy(j[0]).add(tt).add(k),F(q.x,q.y,q.z)):F(g.x,g.y,0)}for(let m=1;m<=l;m++)for(let g=0;g<N;g++){const y=f?Q(z[g],at[g],St):z[g];G?(tt.copy(R.normals[m]).multiplyScalar(y.x),k.copy(R.binormals[m]).multiplyScalar(y.y),q.copy(j[m]).add(tt).add(k),F(q.x,q.y,q.z)):F(y.x,y.y,d/l*m)}for(let m=A-1;m>=0;m--){const g=m/A,y=u*Math.cos(g*Math.PI/2),w=b*Math.sin(g*Math.PI/2)+p;for(let x=0,M=D.length;x<M;x++){const T=Q(D[x],ot[x],w);F(T.x,T.y,d+y)}for(let x=0,M=O.length;x<M;x++){const T=O[x];J=ut[x];for(let E=0,U=T.length;E<U;E++){const L=Q(T[E],J[E],w);G?F(L.x,L.y+j[l-1].y,j[l-1].x+y):F(L.x,L.y,d+y)}}}Zt(),I&&Kt();function Zt(){const m=i.length/3;if(f){let g=0,y=N*g;if(B)for(let w=0;w<nt;w++){const x=et[w];ct(x[2]+y,x[1]+y,x[0]+y)}if(g=l+A*2,y=N*g,V)for(let w=0;w<nt;w++){const x=et[w];ct(x[0]+y,x[1]+y,x[2]+y)}}else{if(B)for(let g=0;g<nt;g++){const y=et[g];ct(y[2],y[1],y[0])}if(V)for(let g=0;g<nt;g++){const y=et[g];ct(y[0]+N*l,y[1]+N*l,y[2]+N*l)}}s.addGroup(m,i.length/3-m,0)}function Kt(){const m=i.length/3;let g=0;Mt(D,g),g+=D.length;for(let y=0,w=O.length;y<w;y++){const x=O[y];Mt(x,g),g+=x.length}s.addGroup(m,i.length/3-m,1)}function Mt(m,g){let y=m.length;for(;--y>=0;){const w=y;let x=y-1;x<0&&(x=m.length-1);for(let M=0,T=l+A*2;M<T;M++){const E=N*M,U=N*(M+1),L=g+w+E,st=g+x+E,dt=g+x+U,$=g+w+U;Qt(L,st,dt,$)}}}function F(m,g,y){c.push(m),c.push(g),c.push(y)}function ct(m,g,y){H(m),H(g),H(y);const w=i.length/3,x=P.generateTopUV(s,i,w-3,w-2,w-1);W(x[0]),W(x[1]),W(x[2])}function Qt(m,g,y,w){H(m),H(g),H(w),H(g),H(y),H(w);const x=i.length/3,M=P.generateSideWallUV(s,i,x-6,x-3,x-2,x-1);W(M[0]),W(M[1]),W(M[3]),W(M[1]),W(M[2]),W(M[3])}function H(m){i.push(c[m*3+0]),i.push(c[m*3+1]),i.push(c[m*3+2])}function W(m){r.push(m.x),r.push(m.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,s=this.parameters.options;return Pe(e,s,t)}static fromJSON(t,e){const s=[];for(let r=0,n=t.shapes.length;r<n;r++){const a=e[t.shapes[r]];s.push(a)}const i=t.options.extrudePath;return console.log(i.type),i!==void 0&&(t.options.extrudePath=new v[`${i.type}Curve`]().fromJSON(i)),new vt(s,t.options)}}const Ve={generateTopUV:function(o,t,e,s,i){const r=t[e*3],n=t[e*3+1],a=t[s*3],c=t[s*3+1],h=t[i*3],l=t[i*3+1];return[new _.Vector2(r,n),new _.Vector2(a,c),new _.Vector2(h,l)]},generateSideWallUV:function(o,t,e,s,i,r){const n=t[e*3],a=t[e*3+1],c=t[e*3+2],h=t[s*3],l=t[s*3+1],d=t[s*3+2],f=t[i*3],u=t[i*3+1],b=t[i*3+2],p=t[r*3],A=t[r*3+1],S=t[r*3+2];return Math.abs(a-l)<Math.abs(n-h)?[new _.Vector2(n,1-c),new _.Vector2(h,1-d),new _.Vector2(f,1-b),new _.Vector2(p,1-S)]:[new _.Vector2(a,1-c),new _.Vector2(l,1-d),new _.Vector2(u,1-b),new _.Vector2(A,1-S)]}};function Pe(o,t,e){if(e.shapes=[],Array.isArray(o))for(let s=0,i=o.length;s<i;s++){const r=o[s];e.shapes.push(r.uuid)}else e.shapes.push(o.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}const Nt=o=>{const{split:t,depth:e,points:s,box3:i,hasTop:r,hasBottom:n,hasSide:a,sideRepeat:c}=o,h=new vt(new v.Shape(s),{depth:e,bevelEnabled:!1,UVGenerator:yt.getUVGenerator({split:t,box3:i,sideRepeat:c}),hasTop:r,hasBottom:n,hasSide:a});return yt.claerUVGenerator(),h};class Ee extends X.BaseObject{constructor(t){super(),this.options=C({depth:1},t)}create(){return Z(this,null,function*(){const{points:t,pointsArr:e,useGroups:s,depth:i,geometry:r,geometryArr:n,material:a,box3:c,split:h,hasTop:l,hasBottom:d,hasSide:f,useUserDataPos:u}=this.options,b=Array.isArray(i)?i:[i],p=Array.isArray(c)?c:[c],A=a;let S=r;if(A||console.log("material is null"),!S&&t?S=Nt({points:t,depth:b[0],box3:p[0],split:h,hasTop:l,hasBottom:d,hasSide:f}):!S&&e?S=K(e.map((P,V)=>{var B,I;return Nt({points:P,depth:(B=b[V])!=null?B:b[0],box3:(I=p[V])!=null?I:p[0],split:h,hasTop:l,hasBottom:d,hasSide:f})}),s!=null?s:0):!S&&n&&n.length>1?S=K(n,s!=null?s:0):!S&&n&&n.length===1&&([S]=n),this.createMesh(S,A),u&&(S!=null&&S.userData.position)){const{x:P,y:V,z:B}=S.userData.position;this.object3d.position.set(P,V,B)}})}addGeometries(t){const e=this.object3d,s=K([e.geometry,...t]);e.geometry=s}setTextureAnisotropic(t,e){t.anisotropy=e||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Be=o=>{const{topColor:t,sideColor:e,sideMap:s,createCanvasObjectURL:i,split:r,maxAnisotropy:n}=o;return new Promise(a=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const h=r,l=document.createElement("canvas"),d=l.getContext("2d");l.height=c.height/(1-h),l.width=c.width,h&&t&&(d.fillStyle=t,d.fillRect(0,0,c.width,l.height*h)),s&&c instanceof HTMLImageElement?d.drawImage(c,0,l.height*h,c.width,c.height):e&&(d.fillStyle=e,d.fillRect(0,l.height*h,c.width,c.height)),i&&l.toBlob(u=>{console.log(URL.createObjectURL(u))});const f=new v.CanvasTexture(l);a(f)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=ne.Group;exports.MeshLineMaterial=xt.MeshLineMaterial;exports.meshLineMaterialArr=xt.meshLineMaterialArr;exports.ConicPolygon=Te;exports.ExtrudePolygon=Ee;exports.Image=Wt;exports.Light=ge;exports.Line=ve;exports.MeshLineGeometry=$t;exports.MeshLineRaycast=be;exports.Node=pe;exports.Pie=me;exports.Text=de;exports.Video=fe;exports.getConicPolygonGeometry=Xt;exports.getConicPolygonGeometryMetas=Jt;exports.getSplitTexture=Be;
1
+ "use strict";var tt=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var Ce=Math.pow,Ie=(o,e,t)=>e in o?tt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,C=(o,e)=>{for(var t in e||(e={}))Le.call(e,t)&&Ie(o,t,e[t]);if(le)for(var t of le(e))Ue.call(e,t)&&Ie(o,t,e[t]);return o},Oe=(o,e)=>st(o,it(e));var fe=(o,e)=>{var t={};for(var s in o)Le.call(o,s)&&e.indexOf(s)<0&&(t[s]=o[s]);if(o!=null&&le)for(var s of le(o))e.indexOf(s)<0&&Ue.call(o,s)&&(t[s]=o[s]);return t};var Z=(o,e,t)=>new Promise((s,i)=>{var r=c=>{try{a(t.next(c))}catch(h){i(h)}},n=c=>{try{a(t.throw(c))}catch(h){i(h)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(r,n);a((t=t.apply(o,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("three"),X=require("../BaseObject.js"),rt=require("esus-lite"),nt=require("../index2.js"),ot=require("@tweenjs/tween.js"),xe=require("../MeshLineMaterial.js"),Y=require("d3-array"),ge=require("earcut"),at=require("@turf/boolean-clockwise"),ye=require("../uvGenerator.js"),ct=require("delaunator"),lt=require("@turf/boolean-point-in-polygon"),re=require("d3-geo"),ht=require("d3-geo-voronoi"),Re=require("d3-scale");function Fe(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const v=Fe(_),ie=Fe(ot),ut=+v.REVISION<144,He=ut?"PlaneBufferGeometry":"PlaneGeometry";class We extends X.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=C({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return Z(this,null,function*(){const{src:e,texture:t,transparent:s,opacity:i,blending:r,depthWrite:n,depthTest:a,alphaTest:c,sprite:h,sizeAttenuation:l,color:d}=this.options,f=t||(yield new v.TextureLoader().loadAsync(e));return h?new v.SpriteMaterial({map:f,transparent:s!=null?s:!1,blending:r!=null?r:v.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:i!=null?i:1,sizeAttenuation:l!=null?l:!0}):new v.MeshBasicMaterial({color:d!=null?d:16777215,map:f,transparent:s!=null?s:!1,blending:r!=null?r:v.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:i!=null?i:1})})}create(){return Z(this,null,function*(){const{position:e,material:t,sprite:s}=this.options,i=t||(yield this.getMaterial());s?this.createSprite(i):this.createMesh(new v[He](1,1),i),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 dt extends We{constructor(e){super(e),this.canvas=document.createElement("canvas")}getTexture(){const{text:e,textOptions:t}=this.options,{fontSize:s,fontFamily:i,fontWeight:r,flipX:n,color:a,setCtx:c}=C({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:u=>{}},t||{}),{canvas:h}=this;h.width=s*e.length*2,h.height=s;let l=h.getContext("2d");l.font=`${r} ${s}px/1 ${i}`;const{width:d}=l.measureText(e);h.width=d,l=h.getContext("2d"),l.clearRect(0,0,h.width,h.height),n&&l.scale(-1,1),l.font=`${r} ${s}px/1 ${i}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(e,n?d*-1:0,h.height/2),l.restore();const f=new v.Texture(h);return f.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),f.needsUpdate=!0,Promise.resolve(f)}}class ft extends X.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=C({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:s,depthWrite:i,depthTest:r,format:n,autoPlay:a,loop:c,alphaTest:h,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 u=new v.VideoTexture(f);u.format=n!=null?n:v.RGBAFormat,u.needsUpdate=!0;const b=l?new v.SpriteMaterial({map:u,transparent:t!=null?t:!1,blending:s!=null?s:v.NormalBlending,depthWrite:i!=null?i:!0,depthTest:r!=null?r:!0,alphaTest:h!=null?h:0}):new v.MeshBasicMaterial({map:u,transparent:t!=null?t:!1,blending:s!=null?s:v.NormalBlending,depthWrite:i!=null?i:!0,depthTest:r!=null?r:!0,alphaTest:h!=null?h:0});d.resolve(b)},!1),f.src=e,f.muted=!0,f.autoplay=a,f.loop=c,f.preload="auto",d.promise}create(){return Z(this,null,function*(){const{scale:e,position:t,src:s,cache:i,sprite:r}=this.options,n=s&&(i?yield i.get(s,()=>this.getMaterial()):yield this.getMaterial());this.video=n.map.image,r?this.createSprite(n):this.createMesh(new v[He](1,1),n),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 X.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.options=C({event:"click",type:"2d"},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:i}=this.options,r=document.createElement("div");this.element=r,t&&r.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(r):this.options.type==="3dSprite"?this.createCSS3DSprite(r):this.createCSS2DObject(r),e&&this.object3d.position.copy(e),s&&i&&this.clickTarge.forEach(n=>{const a=Array.isArray(i)?i:[i],c=Array.isArray(s)?s:[s];a.forEach((h,l)=>{const d=c[l];d&&n.addEventListener(h,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 i=Array.isArray(t)?t:[t],r=Array.isArray(e)?e:[e];i.forEach((n,a)=>{const c=r[a];c&&s.removeEventListener(n,c)})}),super.dispose()}}class mt extends X.BaseObject{constructor(e){super(),this.options=C({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return Z(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:s,material:i,percentDepth:r,activeIndex:n}=this.options,a=Math.max(...e),c=e.reduce((l,d)=>l+d,0);let h=Math.PI/2;e.forEach((l,d)=>{if(l===0)return;const f=Math.PI*2*(l/c),u=s[d],b=r?t*(l/a):t,p=this.createGeometry(b,f),A=i?i.clone():new v.MeshBasicMaterial({color:u});i&&A.color.set(u);const S=new v.Mesh(p,A);S.userData.depth=b,S.userData.index=d,S.rotateZ(h),h+=f,this.add(S)}),n!==-1&&this.setActive(n)})}createGeometry(e,t){const{outRadius:s,innerRadius:i}=this.options,r=new v.Shape;return r.moveTo(s,0),r.lineTo(i,0),r.absarc(0,0,i,0,t,!1),r.absarc(0,0,s,t,0,!0),new v.ExtrudeGeometry(r,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:s}=this.pencil.pick(e,this.object3d.children)||{},i=s?this.object3d.children.findIndex(r=>r===s):this.options.activeIndex;return this.setActive(i,t)}setActive(e,t=1.3){const s=this.object3d.children[e];if(this.object3d.children.forEach(i=>{if(!(s&&s===i)&&i.scale.z!==1){if(i.userData.levTween)return;i.userData.enTween&&(i.userData.enTween.stop(),i.userData.enTween=null);const r=new ie.Tween(i.scale).to({z:1},100);i.userData.levTween=r,r.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new ie.Tween(s.scale).to({z:t},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new ie.Tween(this.object3d.scale).to({z:1},1e3).easing(ie.Easing.Sinusoidal.InOut).start()}}class gt extends X.BaseObject{constructor(e){super(),this.options=e}create(){var t,s,i,r,n,a,c,h,l,d,f,u,b;const e=this.options;if(e.type==="AmbientLight"){const p=new v.AmbientLight(e.color);p.name="AmbientLight",this.object3d=p}else if(e.type==="DirectionalLight"){const p=new v.DirectionalLight(e.color,e.intensity);p.name="DirectionalLight",p.target.position.set(0,0,0),this.object3d=p,this.pencil.scene.add(p.target),this.directionalLight=p}else if(e.type==="PointLight"){const p=new v.PointLight((t=e.color)!=null?t:16777215,(s=e.intensity)!=null?s:1,(i=e.distance)!=null?i:0,(r=e.decay)!=null?r:2);p.name="PointLight",this.object3d=p,this.pointLight=p}else if(e.type==="SpotLight"){const p=new v.SpotLight((n=e.color)!=null?n:16777215,(a=e.intensity)!=null?a:1,(c=e.distance)!=null?c:0,(h=e.angle)!=null?h:Math.PI/3,(l=e.penumbra)!=null?l:1,(d=e.decay)!=null?d:2);p.name="SpotLight",this.object3d=p,this.spotLight=p,this.pencil.scene.add(p.target)}else if(e.type==="HemisphereLight"){const p=new v.HemisphereLight((f=e.color)!=null?f:16777215,(u=e.groundColor)!=null?u:16777215,(b=e.intensity)!=null?b:1);p.name="HemisphereLight",this.object3d=p,this.hemisphereLight=p}}render(){const e=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const t=this.spotLight||this.directionalLight;t.position.copy(e),t.target.position.copy(e)}else this.pointLight&&this.pointLight.position.copy(e)}dispose(){const e=this.object3d;e.target&&this.pencil.scene.remove(e.target),super.dispose()}}function pe(o,e,t,s,i){let r;if(o=o.subarray||o.slice?o:o.buffer,t=t.subarray||t.slice?t:t.buffer,o=e?o.subarray?o.subarray(e,i&&e+i):o.slice(e,i&&e+i):o,t.set)t.set(o,s);else for(r=0;r<o.length;r++)t[r+s]=o[r];return t}function yt(o){return o instanceof Float32Array?o:o instanceof v.BufferGeometry?o.getAttribute("position").array:o.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 $e 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=yt(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 i=e[s],r=s/(e.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(r),this.counters.push(r)}else for(let s=0;s<e.length;s+=3){const i=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(i),this.counters.push(i)}this.process()}compareV3(e,t){const s=e*6,i=t*6;return this.positions[s]===this.positions[i]&&this.positions[s+1]===this.positions[i+1]&&this.positions[s+2]===this.positions[i+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 i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(i/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const r=i*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}i>0&&(s=this.copyV3(i),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 i=this._attributes.position.array,r=this._attributes.previous.array,n=this._attributes.next.array,a=i.length;pe(i,0,r,0,a),pe(i,6,i,0,a-6),i[a-6]=e,i[a-5]=t,i[a-4]=s,i[a-3]=e,i[a-2]=t,i[a-1]=s,pe(i,6,n,0,a-6),n[a-6]=e,n[a-5]=t,n[a-4]=s,n[a-3]=e,n[a-2]=t,n[a-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function bt(o,e){const t=new v.Matrix4,s=new v.Ray,i=new v.Sphere,r=new v.Vector3,n=this.geometry;if(i.copy(n.boundingSphere),i.applyMatrix4(this.matrixWorld),!o.ray.intersectSphere(i,r))return;t.copy(this.matrixWorld).invert(),s.copy(o.ray).applyMatrix4(t);const a=new v.Vector3,c=new v.Vector3,h=new v.Vector3,l=this instanceof v.LineSegments?2:1,d=n.index,f=n.attributes;if(d!==null){const u=d.array,b=f.position.array,p=f.width.array;for(let A=0,S=u.length-1;A<S;A+=l){const P=u[A],V=u[A+1];a.fromArray(b,P*3),c.fromArray(b,V*3);const B=p[Math.floor(A/3)]!=null?p[Math.floor(A/3)]:1,I=o.params.Line.threshold+this.material.lineWidth*B/2,j=I*I;if(s.distanceSqToSegment(a,c,r,h)>j)continue;r.applyMatrix4(this.matrixWorld);const R=o.ray.origin.distanceTo(r);R<o.near||R>o.far||(e.push({distance:R,point:h.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=S)}}}function K(o,e=0){const t=o[0].index!==null,s=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),r={},n={},a=o[0].morphTargetsRelative,c=new _.BufferGeometry;let h=0;for(let l=0;l<o.length;++l){const d=o[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 u in d.attributes){if(!s.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),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 u in d.morphAttributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;n[u]===void 0&&(n[u]=[]),n[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=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(h,u,l);else if(e===2&&d.groups.length>0)for(let b of d.groups){let p=b.materialIndex;c.addGroup(h+b.start,Math.min(b.count,u),p)}h+=u}}if(t){let l=0;const d=[];for(let f=0;f<o.length;++f){const u=o[f].index;for(let b=0;b<u.count;++b)d.push(u.getX(b)+l);l+=o[f].attributes.position.count}c.setIndex(d)}for(const l in r){const d=ze(r[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 n){const d=n[l][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let f=0;f<d;++f){const u=[];for(let p=0;p<n[l].length;++p)u.push(n[l][p][f]);const b=ze(u);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?xt(c):c}function ze(o){let e,t,s,i=-1,r=0;for(let h=0;h<o.length;++h){const l=o[h];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(i===-1&&(i=l.gpuType),i!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=l.array.length}const n=new e(r);let a=0;for(let h=0;h<o.length;++h)n.set(o[h].array,a),a+=o[h].array.length;const c=new _.BufferAttribute(n,t,s);return i!==void 0&&(c.gpuType=i),c}function xt(o){if(o.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),o;let e=o.groups;if(e=e.sort((n,a)=>n.materialIndex!==a.materialIndex?n.materialIndex-a.materialIndex:n.start-a.start),o.getIndex()===null){const n=o.getAttribute("position"),a=[];for(let c=0;c<n.count;c+=3)a.push(c,c+1,c+2);o.setIndex(a),a.length=0}const t=o.getIndex(),s=[];for(let n=0;n<e.length;n++){const a=e[n],c=a.start,h=c+a.count;for(let l=c;l<h;l++)s.push(t.getX(l))}o.dispose(),o.setIndex(s),s.length=0;let i=0;for(let n=0;n<e.length;n++){const a=e[n];a.start=i,i+=a.count}let r=e[0];o.groups=[r];for(let n=1;n<e.length;n++){const a=e[n];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,o.groups.push(r))}return o}const me=o=>{const{setPointWidth:e,nodes:t}=o,s=new $e;return s.setPoints(t,e),s};class vt extends X.BaseObject{constructor(e={}){super(),this.options=C({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return Z(this,null,function*(){const{nodes:e,nodesArr:t,geometry:s,geometryArr:i,material:r,useGroups:n,setPointWidth:a,lineWidthArr:c,useUserDataPos:h,materialParameters:l}=this.options;let d=r,f=s;if(!d&&l&&(d=this.getMaterial(l)),!f&&e?f=me({nodes:e,setPointWidth:a}):!f&&t?f=K(t.map((u,b)=>{let p=a;return!p&&c&&(p=()=>{var A;return(A=c[b])!=null?A:c[0]}),me({nodes:u,setPointWidth:p})}),n!=null?n:0):!f&&i&&i.length>1?f=K(i,n!=null?n:0):!f&&i&&i.length===1&&([f]=i),this.createMesh(f,d),h&&(f!=null&&f.userData.position)){const{x:u,y:b,z:p}=f.userData.position;this.object3d.position.set(u,b,p)}})}setGeometry(e,t){const s=me({nodes:e,setPointWidth:t}),i=this.object3d,r=i.geometry;i.geometry=s,r.dispose()}getMaterial(e){const{width:t,height:s}=this.pencil.getSize();return new xe.MeshLineMaterial(C({color:new v.Color("#ffffff"),resolution:new v.Vector2(t,s)},e))}addGeometries(e){const t=this.object3d,s=K([t.geometry,...e]);t.geometry=s}resize(e,t){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:s}=this.pencil.getSize();this.resize(t,s)}animate({duration:e,delay:t,repeat:s,lineLoop:i,onRepeat:r,onComplete:n}={delay:0,duration:1e3,repeat:0}){const{offset:a,offsetLoop:c}=this.material.uniforms;if(this.material.userData.tween)return;const h=i!=null?i:!0;a.value.x=1,c.value=0;let l=0;const d=new ie.Tween(a.value).to({x:-1},e).delay(t).repeat(s).onUpdate(({x:f})=>{h&&f<=0&&c.value===0&&(c.value=1)}).onRepeat(()=>{l+=1,r&&r(l)}).onComplete(()=>{n&&n()}).start();this.material.userData.tween=d}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 wt(o,e){return o.map(t=>{const s=[];let i;return t.forEach(r=>{if(i){const n=re.geoDistance(r,i)*180/Math.PI;if(n>e){const a=re.geoInterpolate(i,r),c=1/Math.ceil(n/e);let h=c;for(;h<1;)s.push(a(h)),h+=c}}s.push(i=r)}),s})}function At(o,{minLng:e,maxLng:t,minLat:s,maxLat:i}={}){const r=Math.round(Ce(360/o,2)/Math.PI),n=(1+Math.sqrt(5))/2,a=u=>u/n*360%360-180,c=u=>Math.acos(2*u/r-1)/Math.PI*180-90,h=u=>r*(Math.cos((u+90)*Math.PI/180)+1)/2,l=[i!==void 0?Math.ceil(h(i)):0,s!==void 0?Math.floor(h(s)):r-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?u=>u<=t:t===void 0?u=>u>=e:t>=e?u=>u>=e&&u<=t:u=>u>=e||u<=t,f=[];for(let u=l[0];u<=l[1];u++){const b=a(u);d(b)&&f.push([b,c(u)])}return f}function be(o,e,t=!1){return t?re.geoContains(e,o):lt(o,e)}function St(o,e){const t={type:"Polygon",coordinates:o},[[s,i],[r,n]]=re.geoBounds(t);if(Math.min(Math.abs(r-s),Math.abs(n-i))<e)return[];const a=s>r||n>=89||i<=-89;return At(e,{minLng:s,maxLng:r,minLat:i,maxLat:n}).filter(c=>be(c,t,a))}function Mt(o,{resolution:e=1/0,bbox:t}={}){const s=wt(o,e),i=Y.merge(s),r=St(o,e),n=[...i,...r],a={type:"Polygon",coordinates:o},[[c,h],[l,d]]=re.geoBounds(a),f=c>l||d>=89||h<=-89;let u=[];if(f){const P=ht.geoVoronoi(n).triangles(),V=new Map(n.map(([B,I],j)=>[`${B}-${I}`,j]));P.features.forEach(B=>{const I=B.geometry.coordinates[0].slice(0,3).reverse(),j=[];if(I.forEach(([G,R])=>{const k=`${G}-${R}`;V.has(k)&&j.push(V.get(k))}),j.length===3){if(j.some(G=>G<i.length)){const G=B.properties.circumcenter;if(!be(G,a,f))return}u.push(...j)}})}else if(r.length){const P=ct.from(n);for(let V=0,B=P.triangles.length;V<B;V+=3){const I=[2,1,0].map(G=>P.triangles[V+G]),j=I.map(G=>n[G]);if(I.some(G=>G<i.length)){const G=[0,1].map(R=>Y.mean(j,k=>k[R]));if(!be(G,a,f))continue}u.push(...I)}}else{const{vertices:P,holes:V=[]}=ge.flatten(s);u=ge(P,V,2)}const b=Re.scaleLinear(t?[t[0],t[2]]:Y.extent(n,P=>P[0]),[0,1]),p=Re.scaleLinear(t?[t[1],t[3]]:Y.extent(n,P=>P[1]),[0,1]),A=n.map(([P,V])=>[b(P),p(V)]);return{contour:s,triangles:{points:n,indices:u,uvs:A}}}const ke=new v.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function he(o,e,t,s){const i=o.map(r=>r.map(([n,a])=>{if(s){const[c,h]=s([n,a]);return[c,-h,e]}return t?ye.polar2Cartesian(n,a,e):[n,a,e]}));return ge.flatten(i)}function _t(o,e,t,s,i){const{vertices:r,holes:n}=he(o,e,s,i),{vertices:a}=he(o,t,s,i),c=Y.merge([a,r]),h=Math.round(a.length/3),l=new Set(n);let d=0;const f=[];for(let b=0;b<h;b++){let p=b+1;if(p===h)p=d;else if(l.has(p)){const A=p;p=d,d=A}f.push(b,b+h,p+h),f.push(p+h,p,b)}const u=[];for(let b=1;b>=0;b--)for(let p=0;p<h;p+=1)u.push(p/(h-1),b);return{indices:f,vertices:c,uvs:u,topVerts:a}}function De(o,e,t,s,i,r){return{indices:s?o.indices:o.indices.slice().reverse(),vertices:he([o.points],e,i,r).vertices,uvs:t}}const Je=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:s=1,cartesian:i=!0,hasSide:r=!0,hasBottom:n=!1,hasTop:a=!1,projection:c,bbox:h})=>{o.forEach(S=>{at(S)||S.reverse()});const{contour:l,triangles:d}=Mt(o,{resolution:s,bbox:h});let f={},u;r&&(f=_t(l,e!=null?e:t,t!=null?t:e,i,c),u=f.topVerts);let b=[];(n||a)&&(b=Y.merge(d.uvs));let p={};n&&(p=De(d,e,b,!1,i,c));let A={};return a&&(A=De(d,t,b,!0,i,c)),{contour:l,triangles:d,sideTorso:f,bottomCap:p,topCap:A,topVerts:u}};class Xe extends v.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=C({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:s,hasTop:i,hasBottom:r,hasSide:n,cartesian:a,userDataRsoOffset:c,projection:h}=this.parameters,{contour:l,sideTorso:d,topVerts:f,bottomCap:u,topCap:b}=Je(C({},this.parameters));let p=[],A=[],S=[],P=0;const V=B=>{const I=Math.round(p.length/3),j=S.length;p=p.concat(B.vertices),A=A.concat(B.uvs),S=S.concat(I?B.indices.map(G=>G+I):B.indices),this.addGroup(j,S.length-j,P++)};n&&(V(d),this.userData.topVerts=c?he(l,s+c,a,h).vertices:f),r&&V(u),i&&V(b),this.setIndex(S),this[ke]("position",new v.Float32BufferAttribute(p,3)),this[ke]("uv",new v.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const qe=o=>{const a=o,{coordinate:e,startHeight:t,height:s}=a,i=fe(a,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof s!="undefined"&&(r=t+s),new Xe([e],Oe(C({},i),{startHeight:t,endHeight:r}))};class Tt extends X.BaseObject{constructor(e){super(),this.options=C({},e)}create(){const c=this.options,{geometry:e,coordinateArr:t,coordinate:s,material:i,useGroups:r}=c,n=fe(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&s)a=qe(C({coordinate:s},n));else if(!a&&t){const h=t.map(l=>qe(C({coordinate:l},n)));a=K(h,r!=null?r:0)}this.createMesh(a,i)}}class ve 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,i=[],r=[];for(let a=0,c=e.length;a<c;a++){const h=e[a];n(h)}this.setAttribute("position",new _.Float32BufferAttribute(i,3)),this.setAttribute("uv",new _.Float32BufferAttribute(r,2)),this.computeVertexNormals();function n(a){var _e,Te,Ve;const c=[],h=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,u=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:u-.1,p=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const S=t.extrudePath,P=t.UVGenerator!==void 0?t.UVGenerator:Vt,V=(_e=t.hasTop)!=null?_e:!0,B=(Te=t.hasBottom)!=null?Te:!0,I=(Ve=t.hasSide)!=null?Ve:!0;let j,G=!1,R,k,ee,q;S&&(j=S.getSpacedPoints(l),G=!0,f=!1,R=S.computeFrenetFrames(l,!1),k=new _.Vector3,ee=new _.Vector3,q=new _.Vector3),f||(A=0,u=0,b=0,p=0);const we=a.extractPoints(h);let z=we.shape;const O=we.holes;if(!_.ShapeUtils.isClockWise(z)){z=z.reverse();for(let m=0,g=O.length;m<g;m++){const y=O[m];_.ShapeUtils.isClockWise(y)&&(O[m]=y.reverse())}}const te=_.ShapeUtils.triangulateShape(z,O),D=z;for(let m=0,g=O.length;m<g;m++){const y=O[m];z=z.concat(y)}function Q(m,g,y){return g||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(g,y)}const N=z.length,ne=te.length;function Ae(m,g,y){let w,x,M;const T=m.x-g.x,E=m.y-g.y,U=y.x-m.x,L=y.y-m.y,se=T*T+E*E,de=T*L-E*U;if(Math.abs(de)>Number.EPSILON){const $=Math.sqrt(se),Pe=Math.sqrt(U*U+L*L),Ee=g.x-E/$,Be=g.y+T/$,Ye=y.x-L/Pe,et=y.y+U/Pe,Ge=((Ye-Ee)*L-(et-Be)*U)/(T*L-E*U);w=Ee+T*Ge-m.x,x=Be+E*Ge-m.y;const je=w*w+x*x;if(je<=2)return new _.Vector2(w,x);M=Math.sqrt(je/2)}else{let $=!1;T>Number.EPSILON?U>Number.EPSILON&&($=!0):T<-Number.EPSILON?U<-Number.EPSILON&&($=!0):Math.sign(E)===Math.sign(L)&&($=!0),$?(w=-E,x=T,M=Math.sqrt(se)):(w=T,x=E,M=Math.sqrt(se/2))}return new _.Vector2(w/M,x/M)}const oe=[];for(let m=0,g=D.length,y=g-1,w=m+1;m<g;m++,y++,w++)y===g&&(y=0),w===g&&(w=0),oe[m]=Ae(D[m],D[y],D[w]);const ue=[];let J,ae=oe.concat();for(let m=0,g=O.length;m<g;m++){const y=O[m];J=[];for(let w=0,x=y.length,M=x-1,T=w+1;w<x;w++,M++,T++)M===x&&(M=0),T===x&&(T=0),J[w]=Ae(y[w],y[M],y[T]);ue.push(J),ae=ae.concat(J)}for(let m=0;m<A;m++){const g=m/A,y=u*Math.cos(g*Math.PI/2),w=b*Math.sin(g*Math.PI/2)+p;for(let x=0,M=D.length;x<M;x++){const T=Q(D[x],oe[x],w);F(T.x,T.y,-y)}for(let x=0,M=O.length;x<M;x++){const T=O[x];J=ue[x];for(let E=0,U=T.length;E<U;E++){const L=Q(T[E],J[E],w);F(L.x,L.y,-y)}}}const Se=b+p;for(let m=0;m<N;m++){const g=f?Q(z[m],ae[m],Se):z[m];G?(ee.copy(R.normals[0]).multiplyScalar(g.x),k.copy(R.binormals[0]).multiplyScalar(g.y),q.copy(j[0]).add(ee).add(k),F(q.x,q.y,q.z)):F(g.x,g.y,0)}for(let m=1;m<=l;m++)for(let g=0;g<N;g++){const y=f?Q(z[g],ae[g],Se):z[g];G?(ee.copy(R.normals[m]).multiplyScalar(y.x),k.copy(R.binormals[m]).multiplyScalar(y.y),q.copy(j[m]).add(ee).add(k),F(q.x,q.y,q.z)):F(y.x,y.y,d/l*m)}for(let m=A-1;m>=0;m--){const g=m/A,y=u*Math.cos(g*Math.PI/2),w=b*Math.sin(g*Math.PI/2)+p;for(let x=0,M=D.length;x<M;x++){const T=Q(D[x],oe[x],w);F(T.x,T.y,d+y)}for(let x=0,M=O.length;x<M;x++){const T=O[x];J=ue[x];for(let E=0,U=T.length;E<U;E++){const L=Q(T[E],J[E],w);G?F(L.x,L.y+j[l-1].y,j[l-1].x+y):F(L.x,L.y,d+y)}}}Ze(),I&&Ke();function Ze(){const m=i.length/3;if(f){let g=0,y=N*g;if(B)for(let w=0;w<ne;w++){const x=te[w];ce(x[2]+y,x[1]+y,x[0]+y)}if(g=l+A*2,y=N*g,V)for(let w=0;w<ne;w++){const x=te[w];ce(x[0]+y,x[1]+y,x[2]+y)}}else{if(B)for(let g=0;g<ne;g++){const y=te[g];ce(y[2],y[1],y[0])}if(V)for(let g=0;g<ne;g++){const y=te[g];ce(y[0]+N*l,y[1]+N*l,y[2]+N*l)}}s.addGroup(m,i.length/3-m,0)}function Ke(){const m=i.length/3;let g=0;Me(D,g),g+=D.length;for(let y=0,w=O.length;y<w;y++){const x=O[y];Me(x,g),g+=x.length}s.addGroup(m,i.length/3-m,1)}function Me(m,g){let y=m.length;for(;--y>=0;){const w=y;let x=y-1;x<0&&(x=m.length-1);for(let M=0,T=l+A*2;M<T;M++){const E=N*M,U=N*(M+1),L=g+w+E,se=g+x+E,de=g+x+U,$=g+w+U;Qe(L,se,de,$)}}}function F(m,g,y){c.push(m),c.push(g),c.push(y)}function ce(m,g,y){H(m),H(g),H(y);const w=i.length/3,x=P.generateTopUV(s,i,w-3,w-2,w-1);W(x[0]),W(x[1]),W(x[2])}function Qe(m,g,y,w){H(m),H(g),H(w),H(g),H(y),H(w);const x=i.length/3,M=P.generateSideWallUV(s,i,x-6,x-3,x-2,x-1);W(M[0]),W(M[1]),W(M[3]),W(M[1]),W(M[2]),W(M[3])}function H(m){i.push(c[m*3+0]),i.push(c[m*3+1]),i.push(c[m*3+2])}function W(m){r.push(m.x),r.push(m.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 Pt(t,s,e)}static fromJSON(e,t){const s=[];for(let r=0,n=e.shapes.length;r<n;r++){const a=t[e.shapes[r]];s.push(a)}const i=e.options.extrudePath;return console.log(i.type),i!==void 0&&(e.options.extrudePath=new v[`${i.type}Curve`]().fromJSON(i)),new ve(s,e.options)}}const Vt={generateTopUV:function(o,e,t,s,i){const r=e[t*3],n=e[t*3+1],a=e[s*3],c=e[s*3+1],h=e[i*3],l=e[i*3+1];return[new _.Vector2(r,n),new _.Vector2(a,c),new _.Vector2(h,l)]},generateSideWallUV:function(o,e,t,s,i,r){const n=e[t*3],a=e[t*3+1],c=e[t*3+2],h=e[s*3],l=e[s*3+1],d=e[s*3+2],f=e[i*3],u=e[i*3+1],b=e[i*3+2],p=e[r*3],A=e[r*3+1],S=e[r*3+2];return Math.abs(a-l)<Math.abs(n-h)?[new _.Vector2(n,1-c),new _.Vector2(h,1-d),new _.Vector2(f,1-b),new _.Vector2(p,1-S)]:[new _.Vector2(a,1-c),new _.Vector2(l,1-d),new _.Vector2(u,1-b),new _.Vector2(A,1-S)]}};function Pt(o,e,t){if(t.shapes=[],Array.isArray(o))for(let s=0,i=o.length;s<i;s++){const r=o[s];t.shapes.push(r.uuid)}else t.shapes.push(o.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}const Ne=o=>{const{split:e,depth:t,points:s,box3:i,hasTop:r,hasBottom:n,hasSide:a,sideRepeat:c}=o,h=new ve(new v.Shape(s),{depth:t,bevelEnabled:!1,UVGenerator:ye.getUVGenerator({split:e,box3:i,sideRepeat:c}),hasTop:r,hasBottom:n,hasSide:a});return ye.claerUVGenerator(),h};class Et extends X.BaseObject{constructor(e){super(),this.options=C({depth:1},e)}create(){return Z(this,null,function*(){const{points:e,pointsArr:t,useGroups:s,depth:i,geometry:r,geometryArr:n,material:a,box3:c,split:h,hasTop:l,hasBottom:d,hasSide:f,useUserDataPos:u}=this.options,b=Array.isArray(i)?i:[i],p=Array.isArray(c)?c:[c],A=a;let S=r;if(A||console.log("material is null"),!S&&e?S=Ne({points:e,depth:b[0],box3:p[0],split:h,hasTop:l,hasBottom:d,hasSide:f}):!S&&t?S=K(t.map((P,V)=>{var B,I;return Ne({points:P,depth:(B=b[V])!=null?B:b[0],box3:(I=p[V])!=null?I:p[0],split:h,hasTop:l,hasBottom:d,hasSide:f})}),s!=null?s:0):!S&&n&&n.length>1?S=K(n,s!=null?s:0):!S&&n&&n.length===1&&([S]=n),this.createMesh(S,A),u&&(S!=null&&S.userData.position)){const{x:P,y:V,z:B}=S.userData.position;this.object3d.position.set(P,V,B)}})}addGeometries(e){const t=this.object3d,s=K([t.geometry,...e]);t.geometry=s}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Bt=o=>{const{topColor:e,sideColor:t,sideMap:s,createCanvasObjectURL:i,split:r,maxAnisotropy:n}=o;return new Promise(a=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const h=r,l=document.createElement("canvas"),d=l.getContext("2d");l.height=c.height/(1-h),l.width=c.width,h&&e&&(d.fillStyle=e,d.fillRect(0,0,c.width,l.height*h)),s&&c instanceof HTMLImageElement?d.drawImage(c,0,l.height*h,c.width,c.height):t&&(d.fillStyle=t,d.fillRect(0,l.height*h,c.width,c.height)),i&&l.toBlob(u=>{console.log(URL.createObjectURL(u))});const f=new v.CanvasTexture(l);a(f)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=nt.Group;exports.MeshLineMaterial=xe.MeshLineMaterial;exports.meshLineMaterialArr=xe.meshLineMaterialArr;exports.ConicPolygon=Tt;exports.ExtrudePolygon=Et;exports.Image=We;exports.Light=gt;exports.Line=vt;exports.MeshLineGeometry=$e;exports.MeshLineRaycast=bt;exports.Node=pt;exports.Pie=mt;exports.Text=dt;exports.Video=ft;exports.getConicPolygonGeometry=Xe;exports.getConicPolygonGeometryMetas=Je;exports.getSplitTexture=Bt;
@@ -36,7 +36,7 @@ var Z = (o, t, e) => new Promise((s, i) => {
36
36
  a((e = e.apply(o, t)).next());
37
37
  });
38
38
  import * as v from "three";
39
- import { BufferGeometry as Wt, BufferAttribute as se, Float32BufferAttribute as Rt, Vector3 as ft, ShapeUtils as dt, Shape as ie, Vector2 as U } from "three";
39
+ import { BufferGeometry as Wt, BufferAttribute as se, Float32BufferAttribute as Rt, Vector3 as dt, ShapeUtils as ft, Shape as ie, Vector2 as U } from "three";
40
40
  import { B as X } from "../BaseObject.module.js";
41
41
  import { makePromiseCreator as re } from "esus-lite";
42
42
  import { G as rs } from "../index.module2.js";
@@ -48,8 +48,8 @@ import gt from "earcut";
48
48
  import ae from "@turf/boolean-clockwise";
49
49
  import { p as ce, g as le, c as he } from "../uvGenerator.module.js";
50
50
  import ue from "delaunator";
51
- import fe from "@turf/boolean-point-in-polygon";
52
- import { geoBounds as $t, geoContains as de, geoDistance as pe, geoInterpolate as me } from "d3-geo";
51
+ import de from "@turf/boolean-point-in-polygon";
52
+ import { geoBounds as $t, geoContains as fe, geoDistance as pe, geoInterpolate as me } from "d3-geo";
53
53
  import { geoVoronoi as ge } from "d3-geo-voronoi";
54
54
  import { scaleLinear as kt } from "d3-scale";
55
55
  const ye = +v.REVISION < 144, qt = ye ? "PlaneBufferGeometry" : "PlaneGeometry";
@@ -76,10 +76,10 @@ class be extends X {
76
76
  alphaTest: c,
77
77
  sprite: h,
78
78
  sizeAttenuation: l,
79
- color: f
80
- } = this.options, d = e || (yield new v.TextureLoader().loadAsync(t));
79
+ color: d
80
+ } = this.options, f = e || (yield new v.TextureLoader().loadAsync(t));
81
81
  return h ? new v.SpriteMaterial({
82
- map: d,
82
+ map: f,
83
83
  transparent: s != null ? s : !1,
84
84
  blending: r != null ? r : v.NormalBlending,
85
85
  depthWrite: n != null ? n : !0,
@@ -88,8 +88,8 @@ class be extends X {
88
88
  opacity: i != null ? i : 1,
89
89
  sizeAttenuation: l != null ? l : !0
90
90
  }) : new v.MeshBasicMaterial({
91
- color: f != null ? f : 16777215,
92
- map: d,
91
+ color: d != null ? d : 16777215,
92
+ map: f,
93
93
  transparent: s != null ? s : !1,
94
94
  blending: r != null ? r : v.NormalBlending,
95
95
  depthWrite: n != null ? n : !0,
@@ -141,10 +141,10 @@ class $e extends be {
141
141
  h.width = s * t.length * 2, h.height = s;
142
142
  let l = h.getContext("2d");
143
143
  l.font = `${r} ${s}px/1 ${i}`;
144
- const { width: f } = l.measureText(t);
145
- h.width = f, l = h.getContext("2d"), l.clearRect(0, 0, h.width, h.height), n && l.scale(-1, 1), l.font = `${r} ${s}px/1 ${i}`, l.textBaseline = "middle", l.fillStyle = a, c && c(l), l.fillText(t, n ? f * -1 : 0, h.height / 2), l.restore();
146
- const d = new v.Texture(h);
147
- return d.anisotropy = this.pencil.renderer.capabilities.getMaxAnisotropy(), d.needsUpdate = !0, Promise.resolve(d);
144
+ const { width: d } = l.measureText(t);
145
+ h.width = d, l = h.getContext("2d"), l.clearRect(0, 0, h.width, h.height), n && l.scale(-1, 1), l.font = `${r} ${s}px/1 ${i}`, l.textBaseline = "middle", l.fillStyle = a, c && c(l), l.fillText(t, n ? d * -1 : 0, h.height / 2), l.restore();
146
+ const f = new v.Texture(h);
147
+ return f.anisotropy = this.pencil.renderer.capabilities.getMaxAnisotropy(), f.needsUpdate = !0, Promise.resolve(f);
148
148
  }
149
149
  }
150
150
  class qe extends X {
@@ -167,13 +167,13 @@ class qe extends X {
167
167
  loop: c,
168
168
  alphaTest: h,
169
169
  sprite: l
170
- } = this.options, f = re();
170
+ } = this.options, d = re();
171
171
  if (!t) return Promise.reject("src is required");
172
- const d = document.createElement("video");
173
- return d.addEventListener(
172
+ const f = document.createElement("video");
173
+ return f.addEventListener(
174
174
  "loadedmetadata",
175
175
  () => {
176
- const u = new v.VideoTexture(d);
176
+ const u = new v.VideoTexture(f);
177
177
  u.format = n != null ? n : v.RGBAFormat, u.needsUpdate = !0;
178
178
  const b = l ? new v.SpriteMaterial({
179
179
  map: u,
@@ -190,10 +190,10 @@ class qe extends X {
190
190
  depthTest: r != null ? r : !0,
191
191
  alphaTest: h != null ? h : 0
192
192
  });
193
- f.resolve(b);
193
+ d.resolve(b);
194
194
  },
195
195
  !1
196
- ), d.src = t, d.muted = !0, d.autoplay = a, d.loop = c, d.preload = "auto", f.promise;
196
+ ), f.src = t, f.muted = !0, f.autoplay = a, f.loop = c, f.preload = "auto", d.promise;
197
197
  }
198
198
  create() {
199
199
  return Z(this, null, function* () {
@@ -232,8 +232,8 @@ class Je extends X {
232
232
  this.element = r, e && r.appendChild(e), this.options.type === "3d" ? this.createCSS3DObject(r) : this.options.type === "3dSprite" ? this.createCSS3DSprite(r) : this.createCSS2DObject(r), t && this.object3d.position.copy(t), s && i && this.clickTarge.forEach((n) => {
233
233
  const a = Array.isArray(i) ? i : [i], c = Array.isArray(s) ? s : [s];
234
234
  a.forEach((h, l) => {
235
- const f = c[l];
236
- f && n.addEventListener(h, f);
235
+ const d = c[l];
236
+ d && n.addEventListener(h, d);
237
237
  });
238
238
  });
239
239
  }
@@ -276,16 +276,16 @@ class Xe extends X {
276
276
  create() {
277
277
  return Z(this, null, function* () {
278
278
  this.createGroup();
279
- const { data: t, maxDepth: e, colors: s, material: i, percentDepth: r, activeIndex: n } = this.options, a = Math.max(...t), c = t.reduce((l, f) => l + f, 0);
279
+ const { data: t, maxDepth: e, colors: s, material: i, percentDepth: r, activeIndex: n } = this.options, a = Math.max(...t), c = t.reduce((l, d) => l + d, 0);
280
280
  let h = Math.PI / 2;
281
- t.forEach((l, f) => {
281
+ t.forEach((l, d) => {
282
282
  if (l === 0) return;
283
- const d = Math.PI * 2 * (l / c), u = s[f], b = r ? e * (l / a) : e, p = this.createGeometry(b, d), A = i ? i.clone() : new v.MeshBasicMaterial({
283
+ const f = Math.PI * 2 * (l / c), u = s[d], b = r ? e * (l / a) : e, p = this.createGeometry(b, f), A = i ? i.clone() : new v.MeshBasicMaterial({
284
284
  color: u
285
285
  });
286
286
  i && A.color.set(u);
287
287
  const S = new v.Mesh(p, A);
288
- S.userData.depth = b, S.userData.index = f, S.rotateZ(h), h += d, this.add(S);
288
+ S.userData.depth = b, S.userData.index = d, S.rotateZ(h), h += f, this.add(S);
289
289
  }), n !== -1 && this.setActive(n);
290
290
  });
291
291
  }
@@ -328,7 +328,7 @@ class Ze extends X {
328
328
  super(), this.options = t;
329
329
  }
330
330
  create() {
331
- var e, s, i, r, n, a, c, h, l, f, d, u, b;
331
+ var e, s, i, r, n, a, c, h, l, d, f, u, b;
332
332
  const t = this.options;
333
333
  if (t.type === "AmbientLight") {
334
334
  const p = new v.AmbientLight(t.color);
@@ -351,12 +351,12 @@ class Ze extends X {
351
351
  (c = t.distance) != null ? c : 0,
352
352
  (h = t.angle) != null ? h : Math.PI / 3,
353
353
  (l = t.penumbra) != null ? l : 1,
354
- (f = t.decay) != null ? f : 2
354
+ (d = t.decay) != null ? d : 2
355
355
  );
356
356
  p.name = "SpotLight", this.object3d = p, this.spotLight = p, this.pencil.scene.add(p.target);
357
357
  } else if (t.type === "HemisphereLight") {
358
358
  const p = new v.HemisphereLight(
359
- (d = t.color) != null ? d : 16777215,
359
+ (f = t.color) != null ? f : 16777215,
360
360
  (u = t.groundColor) != null ? u : 16777215,
361
361
  (b = t.intensity) != null ? b : 1
362
362
  );
@@ -479,9 +479,9 @@ function Ke(o, t) {
479
479
  const e = new v.Matrix4(), s = new v.Ray(), i = new v.Sphere(), r = new v.Vector3(), n = this.geometry;
480
480
  if (i.copy(n.boundingSphere), i.applyMatrix4(this.matrixWorld), !o.ray.intersectSphere(i, r)) return;
481
481
  e.copy(this.matrixWorld).invert(), s.copy(o.ray).applyMatrix4(e);
482
- const a = new v.Vector3(), c = new v.Vector3(), h = new v.Vector3(), l = this instanceof v.LineSegments ? 2 : 1, f = n.index, d = n.attributes;
483
- if (f !== null) {
484
- const u = f.array, b = d.position.array, p = d.width.array;
482
+ const a = new v.Vector3(), c = new v.Vector3(), h = new v.Vector3(), l = this instanceof v.LineSegments ? 2 : 1, d = n.index, f = n.attributes;
483
+ if (d !== null) {
484
+ const u = d.array, b = f.position.array, p = f.width.array;
485
485
  for (let A = 0, S = u.length - 1; A < S; A += l) {
486
486
  const P = u[A], T = u[A + 1];
487
487
  a.fromArray(b, P * 3), c.fromArray(b, T * 3);
@@ -513,48 +513,48 @@ function K(o, t = 0) {
513
513
  ), r = {}, n = {}, a = o[0].morphTargetsRelative, c = new Wt();
514
514
  let h = 0;
515
515
  for (let l = 0; l < o.length; ++l) {
516
- const f = o[l];
517
- let d = 0;
518
- if (e !== (f.index !== null))
516
+ const d = o[l];
517
+ let f = 0;
518
+ if (e !== (d.index !== null))
519
519
  return console.error(
520
520
  "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."
521
521
  ), null;
522
- for (const u in f.attributes) {
522
+ for (const u in d.attributes) {
523
523
  if (!s.has(u))
524
524
  return console.error(
525
525
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + l + '. All geometries must have compatible attributes; make sure "' + u + '" attribute exists among all geometries, or in none of them.'
526
526
  ), null;
527
- r[u] === void 0 && (r[u] = []), r[u].push(f.attributes[u]), d++;
527
+ r[u] === void 0 && (r[u] = []), r[u].push(d.attributes[u]), f++;
528
528
  }
529
- if (d !== s.size)
529
+ if (f !== s.size)
530
530
  return console.error(
531
531
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + l + ". Make sure all geometries have the same number of attributes."
532
532
  ), null;
533
- if (a !== f.morphTargetsRelative)
533
+ if (a !== d.morphTargetsRelative)
534
534
  return console.error(
535
535
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + l + ". .morphTargetsRelative must be consistent throughout all geometries."
536
536
  ), null;
537
- for (const u in f.morphAttributes) {
537
+ for (const u in d.morphAttributes) {
538
538
  if (!i.has(u))
539
539
  return console.error(
540
540
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + l + ". .morphAttributes must be consistent throughout all geometries."
541
541
  ), null;
542
- n[u] === void 0 && (n[u] = []), n[u].push(f.morphAttributes[u]);
542
+ n[u] === void 0 && (n[u] = []), n[u].push(d.morphAttributes[u]);
543
543
  }
544
544
  if (t) {
545
545
  let u;
546
546
  if (e)
547
- u = f.index.count;
548
- else if (f.attributes.position !== void 0)
549
- u = f.attributes.position.count;
547
+ u = d.index.count;
548
+ else if (d.attributes.position !== void 0)
549
+ u = d.attributes.position.count;
550
550
  else
551
551
  return console.error(
552
552
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + l + ". The geometry must have either an index or a position attribute"
553
553
  ), null;
554
554
  if (t === 1)
555
555
  c.addGroup(h, u, l);
556
- else if (t === 2 && f.groups.length > 0)
557
- for (let b of f.groups) {
556
+ else if (t === 2 && d.groups.length > 0)
557
+ for (let b of d.groups) {
558
558
  let p = b.materialIndex;
559
559
  c.addGroup(
560
560
  h + b.start,
@@ -567,31 +567,31 @@ function K(o, t = 0) {
567
567
  }
568
568
  if (e) {
569
569
  let l = 0;
570
- const f = [];
571
- for (let d = 0; d < o.length; ++d) {
572
- const u = o[d].index;
570
+ const d = [];
571
+ for (let f = 0; f < o.length; ++f) {
572
+ const u = o[f].index;
573
573
  for (let b = 0; b < u.count; ++b)
574
- f.push(u.getX(b) + l);
575
- l += o[d].attributes.position.count;
574
+ d.push(u.getX(b) + l);
575
+ l += o[f].attributes.position.count;
576
576
  }
577
- c.setIndex(f);
577
+ c.setIndex(d);
578
578
  }
579
579
  for (const l in r) {
580
- const f = Dt(r[l]);
581
- if (!f)
580
+ const d = Dt(r[l]);
581
+ if (!d)
582
582
  return console.error(
583
583
  "THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + l + " attribute."
584
584
  ), null;
585
- c.setAttribute(l, f);
585
+ c.setAttribute(l, d);
586
586
  }
587
587
  for (const l in n) {
588
- const f = n[l][0].length;
589
- if (f === 0) break;
588
+ const d = n[l][0].length;
589
+ if (d === 0) break;
590
590
  c.morphAttributes = c.morphAttributes || {}, c.morphAttributes[l] = [];
591
- for (let d = 0; d < f; ++d) {
591
+ for (let f = 0; f < d; ++f) {
592
592
  const u = [];
593
593
  for (let p = 0; p < n[l].length; ++p)
594
- u.push(n[l][p][d]);
594
+ u.push(n[l][p][f]);
595
595
  const b = Dt(u);
596
596
  if (!b)
597
597
  return console.error(
@@ -673,10 +673,7 @@ const mt = (o) => {
673
673
  };
674
674
  class Qe extends X {
675
675
  constructor(t = {}) {
676
- super(), this.options = C({
677
- delay: 0,
678
- duration: 1e3
679
- }, t);
676
+ super(), this.options = C({}, t);
680
677
  }
681
678
  get material() {
682
679
  var t;
@@ -696,11 +693,11 @@ class Qe extends X {
696
693
  useUserDataPos: h,
697
694
  materialParameters: l
698
695
  } = this.options;
699
- let f = r, d = s;
700
- if (!f && l && (f = this.getMaterial(l)), !d && t ? d = mt({
696
+ let d = r, f = s;
697
+ if (!d && l && (d = this.getMaterial(l)), !f && t ? f = mt({
701
698
  nodes: t,
702
699
  setPointWidth: a
703
- }) : !d && e ? d = K(
700
+ }) : !f && e ? f = K(
704
701
  e.map((u, b) => {
705
702
  let p = a;
706
703
  return !p && c && (p = () => {
@@ -712,11 +709,11 @@ class Qe extends X {
712
709
  });
713
710
  }),
714
711
  n != null ? n : 0
715
- ) : !d && i && i.length > 1 ? d = K(
712
+ ) : !f && i && i.length > 1 ? f = K(
716
713
  i,
717
714
  n != null ? n : 0
718
- ) : !d && i && i.length === 1 && ([d] = i), this.createMesh(d, f), h && (d != null && d.userData.position)) {
719
- const { x: u, y: b, z: p } = d.userData.position;
715
+ ) : !f && i && i.length === 1 && ([f] = i), this.createMesh(f, d), h && (f != null && f.userData.position)) {
716
+ const { x: u, y: b, z: p } = f.userData.position;
720
717
  this.object3d.position.set(u, b, p);
721
718
  }
722
719
  });
@@ -755,19 +752,28 @@ class Qe extends X {
755
752
  duration: t,
756
753
  delay: e,
757
754
  repeat: s,
758
- lineLoop: i
759
- } = {}) {
760
- const { onComplete: r } = this.options, { offset: n, offsetLoop: a } = this.material.uniforms;
755
+ lineLoop: i,
756
+ onRepeat: r,
757
+ onComplete: n
758
+ } = {
759
+ delay: 0,
760
+ duration: 1e3,
761
+ repeat: 0
762
+ }) {
763
+ const { offset: a, offsetLoop: c } = this.material.uniforms;
761
764
  if (this.material.userData.tween)
762
765
  return;
763
- const c = i != null ? i : !0;
764
- n.value.x = 1, a.value = 0;
765
- const h = new st.Tween(n.value).to({ x: -1 }, t != null ? t : this.options.duration).delay(e != null ? e : this.options.delay).repeat(s != null ? s : 0).onUpdate(({ x: l }) => {
766
- c && l <= 0 && a.value === 0 && (a.value = 1);
766
+ const h = i != null ? i : !0;
767
+ a.value.x = 1, c.value = 0;
768
+ let l = 0;
769
+ const d = new st.Tween(a.value).to({ x: -1 }, t).delay(e).repeat(s).onUpdate(({ x: f }) => {
770
+ h && f <= 0 && c.value === 0 && (c.value = 1);
771
+ }).onRepeat(() => {
772
+ l += 1, r && r(l);
767
773
  }).onComplete(() => {
768
- r && r();
774
+ n && n();
769
775
  }).start();
770
- this.material.userData.tween = h;
776
+ this.material.userData.tween = d;
771
777
  }
772
778
  render() {
773
779
  const { width: t, height: e } = this.pencil.getSize();
@@ -800,15 +806,15 @@ function Se(o, { minLng: t, maxLng: e, minLat: s, maxLat: i } = {}) {
800
806
  const r = Math.round(Lt(360 / o, 2) / Math.PI), n = (1 + Math.sqrt(5)) / 2, a = (u) => u / n * 360 % 360 - 180, c = (u) => Math.acos(2 * u / r - 1) / Math.PI * 180 - 90, h = (u) => r * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, l = [
801
807
  i !== void 0 ? Math.ceil(h(i)) : 0,
802
808
  s !== void 0 ? Math.floor(h(s)) : r - 1
803
- ], f = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (u) => u <= e : e === void 0 ? (u) => u >= t : e >= t ? (u) => u >= t && u <= e : (u) => u >= t || u <= e, d = [];
809
+ ], d = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (u) => u <= e : e === void 0 ? (u) => u >= t : e >= t ? (u) => u >= t && u <= e : (u) => u >= t || u <= e, f = [];
804
810
  for (let u = l[0]; u <= l[1]; u++) {
805
811
  const b = a(u);
806
- f(b) && d.push([b, c(u)]);
812
+ d(b) && f.push([b, c(u)]);
807
813
  }
808
- return d;
814
+ return f;
809
815
  }
810
816
  function yt(o, t, e = !1) {
811
- return e ? de(t, o) : fe(o, t);
817
+ return e ? fe(t, o) : de(o, t);
812
818
  }
813
819
  function Me(o, t) {
814
820
  const e = { type: "Polygon", coordinates: o }, [[s, i], [r, n]] = $t(e);
@@ -825,11 +831,11 @@ function Me(o, t) {
825
831
  );
826
832
  }
827
833
  function _e(o, { resolution: t = 1 / 0, bbox: e } = {}) {
828
- const s = Ae(o, t), i = bt(s), r = Me(o, t), n = [...i, ...r], a = { type: "Polygon", coordinates: o }, [[c, h], [l, f]] = $t(a), d = c > l || // crosses antimeridian
829
- f >= 89 || // crosses north pole
834
+ const s = Ae(o, t), i = bt(s), r = Me(o, t), n = [...i, ...r], a = { type: "Polygon", coordinates: o }, [[c, h], [l, d]] = $t(a), f = c > l || // crosses antimeridian
835
+ d >= 89 || // crosses north pole
830
836
  h <= -89;
831
837
  let u = [];
832
- if (d) {
838
+ if (f) {
833
839
  const P = ge(n).triangles(), T = new Map(
834
840
  n.map(([G, V], B) => [`${G}-${V}`, B])
835
841
  );
@@ -844,7 +850,7 @@ function _e(o, { resolution: t = 1 / 0, bbox: e } = {}) {
844
850
  if (!yt(
845
851
  I,
846
852
  a,
847
- d
853
+ f
848
854
  ))
849
855
  return;
850
856
  }
@@ -862,7 +868,7 @@ function _e(o, { resolution: t = 1 / 0, bbox: e } = {}) {
862
868
  if (!yt(
863
869
  I,
864
870
  a,
865
- d
871
+ f
866
872
  ))
867
873
  continue;
868
874
  }
@@ -906,22 +912,22 @@ function Te(o, t, e, s, i) {
906
912
  s,
907
913
  i
908
914
  ), c = bt([a, r]), h = Math.round(a.length / 3), l = new Set(n);
909
- let f = 0;
910
- const d = [];
915
+ let d = 0;
916
+ const f = [];
911
917
  for (let b = 0; b < h; b++) {
912
918
  let p = b + 1;
913
919
  if (p === h)
914
- p = f;
920
+ p = d;
915
921
  else if (l.has(p)) {
916
922
  const A = p;
917
- p = f, f = A;
923
+ p = d, d = A;
918
924
  }
919
- d.push(b, b + h, p + h), d.push(p + h, p, b);
925
+ f.push(b, b + h, p + h), f.push(p + h, p, b);
920
926
  }
921
927
  const u = [];
922
928
  for (let b = 1; b >= 0; b--)
923
929
  for (let p = 0; p < h; p += 1) u.push(p / (h - 1), b);
924
- return { indices: d, vertices: c, uvs: u, topVerts: a };
930
+ return { indices: f, vertices: c, uvs: u, topVerts: a };
925
931
  }
926
932
  function Nt(o, t, e, s, i, r) {
927
933
  return {
@@ -950,23 +956,23 @@ const Pe = ({
950
956
  o.forEach((S) => {
951
957
  ae(S) || S.reverse();
952
958
  });
953
- const { contour: l, triangles: f } = _e(o, {
959
+ const { contour: l, triangles: d } = _e(o, {
954
960
  resolution: s,
955
961
  bbox: h
956
962
  });
957
- let d = {}, u;
958
- r && (d = Te(
963
+ let f = {}, u;
964
+ r && (f = Te(
959
965
  l,
960
966
  t != null ? t : e,
961
967
  e != null ? e : t,
962
968
  i,
963
969
  c
964
- ), u = d.topVerts);
970
+ ), u = f.topVerts);
965
971
  let b = [];
966
- (n || a) && (b = bt(f.uvs));
972
+ (n || a) && (b = bt(d.uvs));
967
973
  let p = {};
968
974
  n && (p = Nt(
969
- f,
975
+ d,
970
976
  t,
971
977
  b,
972
978
  !1,
@@ -975,13 +981,13 @@ const Pe = ({
975
981
  ));
976
982
  let A = {};
977
983
  return a && (A = Nt(
978
- f,
984
+ d,
979
985
  e,
980
986
  b,
981
987
  !0,
982
988
  i,
983
989
  c
984
- )), { contour: l, triangles: f, sideTorso: d, bottomCap: p, topCap: A, topVerts: u };
990
+ )), { contour: l, triangles: d, sideTorso: f, bottomCap: p, topCap: A, topVerts: u };
985
991
  };
986
992
  class Ee extends v.BufferGeometry {
987
993
  constructor(t, e = {}) {
@@ -1004,7 +1010,7 @@ class Ee extends v.BufferGeometry {
1004
1010
  cartesian: a,
1005
1011
  userDataRsoOffset: c,
1006
1012
  projection: h
1007
- } = this.parameters, { contour: l, sideTorso: f, topVerts: d, bottomCap: u, topCap: b } = Pe(C({}, this.parameters));
1013
+ } = this.parameters, { contour: l, sideTorso: d, topVerts: f, bottomCap: u, topCap: b } = Pe(C({}, this.parameters));
1008
1014
  let p = [], A = [], S = [], P = 0;
1009
1015
  const T = (G) => {
1010
1016
  const V = Math.round(p.length / 3), B = S.length;
@@ -1012,12 +1018,12 @@ class Ee extends v.BufferGeometry {
1012
1018
  V ? G.indices.map((I) => I + V) : G.indices
1013
1019
  ), this.addGroup(B, S.length - B, P++);
1014
1020
  };
1015
- n && (T(f), this.userData.topVerts = c ? ct(
1021
+ n && (T(d), this.userData.topVerts = c ? ct(
1016
1022
  l,
1017
1023
  s + c,
1018
1024
  a,
1019
1025
  h
1020
- ).vertices : d), r && T(u), i && T(b), this.setIndex(S), this[Ot](
1026
+ ).vertices : f), r && T(u), i && T(b), this.setIndex(S), this[Ot](
1021
1027
  "position",
1022
1028
  new v.Float32BufferAttribute(p, 3)
1023
1029
  ), this[Ot]("uv", new v.Float32BufferAttribute(A, 2)), this.computeVertexNormals();
@@ -1087,22 +1093,22 @@ class xt extends Wt {
1087
1093
  this.setAttribute("position", new Rt(i, 3)), this.setAttribute("uv", new Rt(r, 2)), this.computeVertexNormals();
1088
1094
  function n(a) {
1089
1095
  var Mt, _t, Tt;
1090
- const c = [], h = e.curveSegments !== void 0 ? e.curveSegments : 12, l = e.steps !== void 0 ? e.steps : 1, f = e.depth !== void 0 ? e.depth : 1;
1091
- let d = e.bevelEnabled !== void 0 ? e.bevelEnabled : !0, u = e.bevelThickness !== void 0 ? e.bevelThickness : 0.2, b = e.bevelSize !== void 0 ? e.bevelSize : u - 0.1, p = e.bevelOffset !== void 0 ? e.bevelOffset : 0, A = e.bevelSegments !== void 0 ? e.bevelSegments : 3;
1096
+ const c = [], h = e.curveSegments !== void 0 ? e.curveSegments : 12, l = e.steps !== void 0 ? e.steps : 1, d = e.depth !== void 0 ? e.depth : 1;
1097
+ let f = e.bevelEnabled !== void 0 ? e.bevelEnabled : !0, u = e.bevelThickness !== void 0 ? e.bevelThickness : 0.2, b = e.bevelSize !== void 0 ? e.bevelSize : u - 0.1, p = e.bevelOffset !== void 0 ? e.bevelOffset : 0, A = e.bevelSegments !== void 0 ? e.bevelSegments : 3;
1092
1098
  const S = e.extrudePath, P = e.UVGenerator !== void 0 ? e.UVGenerator : Ge, T = (Mt = e.hasTop) != null ? Mt : !0, G = (_t = e.hasBottom) != null ? _t : !0, V = (Tt = e.hasSide) != null ? Tt : !0;
1093
1099
  let B, I = !1, z, D, Y, N;
1094
- S && (B = S.getSpacedPoints(l), I = !0, d = !1, z = S.computeFrenetFrames(l, !1), D = new ft(), Y = new ft(), N = new ft()), d || (A = 0, u = 0, b = 0, p = 0);
1100
+ S && (B = S.getSpacedPoints(l), I = !0, f = !1, z = S.computeFrenetFrames(l, !1), D = new dt(), Y = new dt(), N = new dt()), f || (A = 0, u = 0, b = 0, p = 0);
1095
1101
  const vt = a.extractPoints(h);
1096
1102
  let k = vt.shape;
1097
1103
  const R = vt.holes;
1098
- if (!dt.isClockWise(k)) {
1104
+ if (!ft.isClockWise(k)) {
1099
1105
  k = k.reverse();
1100
1106
  for (let m = 0, g = R.length; m < g; m++) {
1101
1107
  const y = R[m];
1102
- dt.isClockWise(y) && (R[m] = y.reverse());
1108
+ ft.isClockWise(y) && (R[m] = y.reverse());
1103
1109
  }
1104
1110
  }
1105
- const tt = dt.triangulateShape(k, R), O = k;
1111
+ const tt = ft.triangulateShape(k, R), O = k;
1106
1112
  for (let m = 0, g = R.length; m < g; m++) {
1107
1113
  const y = R[m];
1108
1114
  k = k.concat(y);
@@ -1158,19 +1164,19 @@ class xt extends Wt {
1158
1164
  }
1159
1165
  const At = b + p;
1160
1166
  for (let m = 0; m < F; m++) {
1161
- const g = d ? Q(k[m], nt[m], At) : k[m];
1167
+ const g = f ? Q(k[m], nt[m], At) : k[m];
1162
1168
  I ? (Y.copy(z.normals[0]).multiplyScalar(g.x), D.copy(z.binormals[0]).multiplyScalar(g.y), N.copy(B[0]).add(Y).add(D), H(N.x, N.y, N.z)) : H(g.x, g.y, 0);
1163
1169
  }
1164
1170
  for (let m = 1; m <= l; m++)
1165
1171
  for (let g = 0; g < F; g++) {
1166
- const y = d ? Q(k[g], nt[g], At) : k[g];
1167
- I ? (Y.copy(z.normals[m]).multiplyScalar(y.x), D.copy(z.binormals[m]).multiplyScalar(y.y), N.copy(B[m]).add(Y).add(D), H(N.x, N.y, N.z)) : H(y.x, y.y, f / l * m);
1172
+ const y = f ? Q(k[g], nt[g], At) : k[g];
1173
+ I ? (Y.copy(z.normals[m]).multiplyScalar(y.x), D.copy(z.binormals[m]).multiplyScalar(y.y), N.copy(B[m]).add(Y).add(D), H(N.x, N.y, N.z)) : H(y.x, y.y, d / l * m);
1168
1174
  }
1169
1175
  for (let m = A - 1; m >= 0; m--) {
1170
1176
  const g = m / A, y = u * Math.cos(g * Math.PI / 2), w = b * Math.sin(g * Math.PI / 2) + p;
1171
1177
  for (let x = 0, M = O.length; x < M; x++) {
1172
1178
  const _ = Q(O[x], rt[x], w);
1173
- H(_.x, _.y, f + y);
1179
+ H(_.x, _.y, d + y);
1174
1180
  }
1175
1181
  for (let x = 0, M = R.length; x < M; x++) {
1176
1182
  const _ = R[x];
@@ -1181,14 +1187,14 @@ class xt extends Wt {
1181
1187
  j.x,
1182
1188
  j.y + B[l - 1].y,
1183
1189
  B[l - 1].x + y
1184
- ) : H(j.x, j.y, f + y);
1190
+ ) : H(j.x, j.y, d + y);
1185
1191
  }
1186
1192
  }
1187
1193
  }
1188
1194
  Jt(), V && Xt();
1189
1195
  function Jt() {
1190
1196
  const m = i.length / 3;
1191
- if (d) {
1197
+ if (f) {
1192
1198
  let g = 0, y = F * g;
1193
1199
  if (G)
1194
1200
  for (let w = 0; w < it; w++) {
@@ -1301,15 +1307,15 @@ const Ge = {
1301
1307
  ];
1302
1308
  },
1303
1309
  generateSideWallUV: function(o, t, e, s, i, r) {
1304
- const n = t[e * 3], a = t[e * 3 + 1], c = t[e * 3 + 2], h = t[s * 3], l = t[s * 3 + 1], f = t[s * 3 + 2], d = t[i * 3], u = t[i * 3 + 1], b = t[i * 3 + 2], p = t[r * 3], A = t[r * 3 + 1], S = t[r * 3 + 2];
1310
+ const n = t[e * 3], a = t[e * 3 + 1], c = t[e * 3 + 2], h = t[s * 3], l = t[s * 3 + 1], d = t[s * 3 + 2], f = t[i * 3], u = t[i * 3 + 1], b = t[i * 3 + 2], p = t[r * 3], A = t[r * 3 + 1], S = t[r * 3 + 2];
1305
1311
  return Math.abs(a - l) < Math.abs(n - h) ? [
1306
1312
  new U(n, 1 - c),
1307
- new U(h, 1 - f),
1308
- new U(d, 1 - b),
1313
+ new U(h, 1 - d),
1314
+ new U(f, 1 - b),
1309
1315
  new U(p, 1 - S)
1310
1316
  ] : [
1311
1317
  new U(a, 1 - c),
1312
- new U(l, 1 - f),
1318
+ new U(l, 1 - d),
1313
1319
  new U(u, 1 - b),
1314
1320
  new U(A, 1 - S)
1315
1321
  ];
@@ -1359,8 +1365,8 @@ class ts extends X {
1359
1365
  box3: c,
1360
1366
  split: h,
1361
1367
  hasTop: l,
1362
- hasBottom: f,
1363
- hasSide: d,
1368
+ hasBottom: d,
1369
+ hasSide: f,
1364
1370
  useUserDataPos: u
1365
1371
  } = this.options, b = Array.isArray(i) ? i : [i], p = Array.isArray(c) ? c : [c], A = a;
1366
1372
  let S = r;
@@ -1370,8 +1376,8 @@ class ts extends X {
1370
1376
  box3: p[0],
1371
1377
  split: h,
1372
1378
  hasTop: l,
1373
- hasBottom: f,
1374
- hasSide: d
1379
+ hasBottom: d,
1380
+ hasSide: f
1375
1381
  }) : !S && e ? S = K(
1376
1382
  e.map(
1377
1383
  (P, T) => {
@@ -1382,8 +1388,8 @@ class ts extends X {
1382
1388
  box3: (V = p[T]) != null ? V : p[0],
1383
1389
  split: h,
1384
1390
  hasTop: l,
1385
- hasBottom: f,
1386
- hasSide: d
1391
+ hasBottom: d,
1392
+ hasSide: f
1387
1393
  });
1388
1394
  }
1389
1395
  ),
@@ -1426,12 +1432,12 @@ const es = (o) => {
1426
1432
  height: 128
1427
1433
  };
1428
1434
  c.onload = () => {
1429
- const h = r, l = document.createElement("canvas"), f = l.getContext("2d");
1430
- l.height = c.height / (1 - h), l.width = c.width, h && t && (f.fillStyle = t, f.fillRect(0, 0, c.width, l.height * h)), s && c instanceof HTMLImageElement ? f.drawImage(c, 0, l.height * h, c.width, c.height) : e && (f.fillStyle = e, f.fillRect(0, l.height * h, c.width, c.height)), i && l.toBlob((u) => {
1435
+ const h = r, l = document.createElement("canvas"), d = l.getContext("2d");
1436
+ l.height = c.height / (1 - h), l.width = c.width, h && t && (d.fillStyle = t, d.fillRect(0, 0, c.width, l.height * h)), s && c instanceof HTMLImageElement ? d.drawImage(c, 0, l.height * h, c.width, c.height) : e && (d.fillStyle = e, d.fillRect(0, l.height * h, c.width, c.height)), i && l.toBlob((u) => {
1431
1437
  console.log(URL.createObjectURL(u));
1432
1438
  });
1433
- const d = new v.CanvasTexture(l);
1434
- a(d);
1439
+ const f = new v.CanvasTexture(l);
1440
+ a(f);
1435
1441
  }, s ? c.src = s : c instanceof HTMLImageElement || c.onload();
1436
1442
  });
1437
1443
  };
@@ -11,9 +11,6 @@ interface Options {
11
11
  material?: MeshLineMaterial;
12
12
  key?: string;
13
13
  useGroups?: 0 | 1 | 2;
14
- duration?: number;
15
- delay?: number;
16
- onComplete?: (...args: any[]) => void;
17
14
  setPointWidth?: (p: number) => any;
18
15
  lineWidthArr?: number[];
19
16
  useUserDataPos?: boolean;
@@ -29,11 +26,13 @@ export default class Line extends BaseObject {
29
26
  addGeometries(geometries: THREE.BufferGeometry[]): void;
30
27
  resize(w: number, h: number): void;
31
28
  useMaterial(type: string): void;
32
- animate({ duration, delay, repeat, lineLoop, }?: {
29
+ animate({ duration, delay, repeat, lineLoop, onRepeat, onComplete, }?: {
33
30
  duration?: number;
34
31
  delay?: number;
35
32
  repeat?: number;
36
33
  lineLoop?: boolean;
34
+ onComplete?: (...args: any[]) => void;
35
+ onRepeat?: (...args: any[]) => void;
37
36
  }): void;
38
37
  render(): void;
39
38
  dispose(disposeWithMaterial?: boolean): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",