gl-draw 0.9.21 → 0.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/BaseObject.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const d=require("three"),l=require("esus-lite"),
|
|
1
|
+
"use strict";const d=require("three"),l=require("esus-lite"),b=require("three/examples/jsm/renderers/CSS2DRenderer"),c=require("three/examples/jsm/renderers/CSS3DRenderer"),o=require("./disposeMesh.js");require("idb-keyval");require("d3-geo");function u(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const i=u(d),h=(s,e,t)=>{e&&(o.disposeMesh(e,t),e.children.forEach(r=>{s.has(r)||h(s,r,t)}))};class j{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.pm=l.makePromiseCreator(),this.materialList={},this.useMaterialType="origin"}get parent(){const e=this.object3d.parent;return e?this.drawController.objMap.get(e)||this.pencil.scene:null}get children(){return this.object3d.children.map(e=>this.drawController.objMap.get(e)).filter(e=>!!e)}get position(){var e;return(e=this.object3d)==null?void 0:e.position}get rotation(){var e;return(e=this.object3d)==null?void 0:e.rotation}get scale(){var e;return(e=this.object3d)==null?void 0:e.scale}get add(){var e;return(e=this.object3d)==null?void 0:e.add.bind(this.object3d)}get remove(){var e;return(e=this.object3d)==null?void 0:e.remove.bind(this.object3d)}get visible(){return this.object3d?this.object3d.visible:!1}create(){}render(){}update(e,t){}resize(e,t){}show(){return this.object3d&&(this.object3d.visible=!0),this}hide(){return this.object3d&&(this.object3d.visible=!1),this}createMesh(...e){return this.object3d=new i.Mesh(...e),this}createGroup(){return this.object3d=new i.Group,this}createPoints(...e){return this.object3d=new i.Points(...e),this}createCSS2DObject(e){return this.object3d=new b.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new c.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new c.CSS3DSprite(e),this}createSprite(e){return this.object3d=new i.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d),this.drawController!==t.drawController&&(t.drawController.objects.delete(t.key),this.drawController.objects.set(t.key,t))}),this}getSize(){const e=new i.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new i.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e){return this.drawController.instantiate(this,{create:t=>{if(this.object3d)if(this.object3d instanceof i.Sprite&&typeof e=="number"){const{size:r}=this.getSize();t.object3d=new i.Mesh(new i.PlaneGeometry(r.x,r.y,2,2),new i.MeshBasicMaterial({map:this.object3d.material.map,color:this.object3d.material.color,transparent:this.object3d.material.transparent,alphaTest:this.object3d.material.alphaTest}))}else t.object3d=this.object3d.clone(!0);typeof e=="number"&&(t.object3d=new i.InstancedMesh(t.object3d.geometry,t.object3d.material,e),t.object3d.instanceMatrix.setUsage(i.DynamicDrawUsage))}})}setInstancedMatrix(e){this.object3d instanceof i.InstancedMesh&&(Object.keys(e).forEach(t=>{this.object3d.setMatrixAt(Number(t),e[t])}),this.object3d.instanceMatrix.needsUpdate=!0,this.object3d.computeBoundingSphere())}erase(){this.drawController.erase(this)}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(r=>{const a=r.userData;r.userData={};const n=r.clone();return r.userData=a,n});{const r=t.userData;t.userData={};const a=t.clone();return t.userData=r,a}}setMaterialList(e,t,r=!0){const a=this.object3d;if(!a||!a.material)return;if(this.materialList.origin||(this.materialList.origin=a.material),!r&&this.materialList[e])return this.materialList[e];const n=t==="clone"?this.cloneMaterial():t;return this.materialList[e]=n,n}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}dispose(e=!0){h(this.drawController.objMap,this.object3d,e),e&&Object.keys(this.materialList).forEach(t=>{t!=="origin"&&o.disposeMesh({material:this.materialList[t]})})}}exports.BaseObject=j;
|
|
@@ -103,7 +103,21 @@ class g {
|
|
|
103
103
|
instantiate(t) {
|
|
104
104
|
return this.drawController.instantiate(this, {
|
|
105
105
|
create: (e) => {
|
|
106
|
-
|
|
106
|
+
if (this.object3d)
|
|
107
|
+
if (this.object3d instanceof i.Sprite && typeof t == "number") {
|
|
108
|
+
const { size: r } = this.getSize();
|
|
109
|
+
e.object3d = new i.Mesh(
|
|
110
|
+
new i.PlaneGeometry(r.x, r.y, 2, 2),
|
|
111
|
+
new i.MeshBasicMaterial({
|
|
112
|
+
map: this.object3d.material.map,
|
|
113
|
+
color: this.object3d.material.color,
|
|
114
|
+
transparent: this.object3d.material.transparent,
|
|
115
|
+
alphaTest: this.object3d.material.alphaTest
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
} else
|
|
119
|
+
e.object3d = this.object3d.clone(!0);
|
|
120
|
+
typeof t == "number" && (e.object3d = new i.InstancedMesh(
|
|
107
121
|
e.object3d.geometry,
|
|
108
122
|
e.object3d.material,
|
|
109
123
|
t
|
package/dist/objects/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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=1e3,delay:t=0,repeat:s=0,lineLoop:i,onRepeat:r,onComplete:n}={}){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;
|
|
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=1e3,delay:t=0,repeat:s=0,lineLoop:i,onRepeat:r,onComplete:n}={}){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()});setTimeout(()=>{d.start()},0),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;
|
|
@@ -768,8 +768,10 @@ class Qe extends X {
|
|
|
768
768
|
l += 1, r && r(l);
|
|
769
769
|
}).onComplete(() => {
|
|
770
770
|
n && n();
|
|
771
|
-
})
|
|
772
|
-
|
|
771
|
+
});
|
|
772
|
+
setTimeout(() => {
|
|
773
|
+
d.start();
|
|
774
|
+
}, 0), this.material.userData.tween = d;
|
|
773
775
|
}
|
|
774
776
|
render() {
|
|
775
777
|
const { width: t, height: e } = this.pencil.getSize();
|