gl-draw 0.11.3 → 0.11.5

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";const b=require("three"),p=require("esus-lite"),j=require("three/examples/jsm/renderers/CSS2DRenderer"),u=require("three/examples/jsm/renderers/CSS3DRenderer"),c=require("./disposeMesh.js");require("idb-keyval");require("d3-geo");require("d3-geo-projection");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const i=f(b),h=(a,e,t=!0)=>{e&&(c.disposeMesh(e,t),e.children.forEach(r=>{a.has(r)||h(a,r,t)}))};class m{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.pm=p.makePromiseCreator(),this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}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 j.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new u.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new u.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=>{var r;if(this.object3d){if(this.object3d instanceof i.Sprite&&typeof e=="number"){const{size:s}=this.getSize(),n=new i.MeshBasicMaterial,o=["color","map","alphaMap","transparent","opacity","alphaTest","blending","side","depthTest","depthWrite"];for(const l of o){const d=this.object3d.material[l];d!==null&&(n[l]=d)}t.object3d=new i.Mesh(new i.PlaneGeometry(s.x,s.y,2,2),n)}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)),t.position.set(0,0,0),t.rotation.set(0,0,0),t.setMaterialList("instantiate","clone"),t.useMaterial("instantiate"),t.object3d.userData.bloom&&((r=this.pencil.composerController)==null||r.toggleBloomSelection(t.object3d,!0)),t.object3d.userData.prefab&&(t.object3d.userData.prefab=!1)}}})}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 s=r.userData;r.userData={};const n=r.clone();return r.userData=s,n});{const r=t.userData;t.userData={};const s=t.clone();return t.userData=r,s}}setMaterialList(e,t,r=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e])if(r){const o=this.materialList[e];c.disposeMesh({material:o})}else 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)}onPointerEvent(e,t){const r=this.drawController.handlePick([this],e,t);this.onPointerIndex.push(r)}dispose(){this.onPointerIndex.forEach(e=>{this.drawController.removePick(e)}),h(this.drawController.objMap,this.object3d),Object.keys(this.materialList).forEach(e=>{if(e!==this.useMaterialType){if(this.isInstantiate&&e==="origin")return;c.disposeMesh({material:this.materialList[e]})}})}disposeWithOutMaterial(){this.onPointerIndex.forEach(e=>{this.drawController.removePick(e)}),h(this.drawController.objMap,this.object3d,!1)}}exports.BaseObject=m;
1
+ "use strict";const u=require("three"),b=require("esus-lite"),p=require("three/examples/jsm/renderers/CSS2DRenderer"),d=require("three/examples/jsm/renderers/CSS3DRenderer"),n=require("./disposeMesh.js");require("idb-keyval");require("d3-geo");require("d3-geo-projection");function j(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const r=j(u);class f{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.pm=b.makePromiseCreator(),this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}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 r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.Points(...e),this}createCSS2DObject(e){return this.object3d=new p.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new d.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new d.CSS3DSprite(e),this}createSprite(e){return this.object3d=new r.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 r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.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=>{var i;if(this.object3d){if(this.object3d instanceof r.Sprite&&typeof e=="number"){const{size:s}=this.getSize(),a=new r.MeshBasicMaterial,c=["color","map","alphaMap","transparent","opacity","alphaTest","blending","side","depthTest","depthWrite"];for(const h of c){const l=this.object3d.material[h];l!==null&&(a[h]=l)}t.object3d=new r.Mesh(new r.PlaneGeometry(s.x,s.y,2,2),a)}else t.object3d=this.object3d.clone(!0);typeof e=="number"&&(t.object3d=new r.InstancedMesh(t.object3d.geometry,t.object3d.material,e),t.object3d.instanceMatrix.setUsage(r.DynamicDrawUsage)),t.position.set(0,0,0),t.rotation.set(0,0,0),t.setMaterialList("instantiate","clone"),t.useMaterial("instantiate"),t.object3d.userData.bloom&&((i=this.pencil.composerController)==null||i.toggleBloomSelection(t.object3d,!0)),t.object3d.userData.prefab&&(t.object3d.userData.prefab=!1)}}})}setInstancedMatrix(e){this.object3d instanceof r.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(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e])if(i){const c=this.materialList[e];n.disposeMesh({material:c})}else return this.materialList[e];const a=t==="clone"?this.cloneMaterial():t;return this.materialList[e]=a,a}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)}onPointerEvent(e,t){const i=this.drawController.handlePick([this],e,t);this.onPointerIndex.push(i)}dispose(){this.onPointerIndex.forEach(e=>{this.drawController.removePick(e)}),this.object3d&&n.disposeMesh(this.object3d),Object.keys(this.materialList).forEach(e=>{if(e!==this.useMaterialType){if(this.isInstantiate&&e==="origin")return;n.disposeMesh({material:this.materialList[e]})}})}disposeWithOutMaterial(){this.onPointerIndex.forEach(e=>{this.drawController.removePick(e)}),this.object3d&&n.disposeMesh(this.object3d,!1)}}exports.BaseObject=f;
@@ -1,19 +1,14 @@
1
1
  import * as r from "three";
2
- import { makePromiseCreator as b } from "esus-lite";
3
- import { CSS2DObject as u } from "three/examples/jsm/renderers/CSS2DRenderer";
4
- import { CSS3DObject as p, CSS3DSprite as j } from "three/examples/jsm/renderers/CSS3DRenderer";
5
- import { d as c } from "./disposeMesh.module.js";
2
+ import { makePromiseCreator as l } from "esus-lite";
3
+ import { CSS2DObject as d } from "three/examples/jsm/renderers/CSS2DRenderer";
4
+ import { CSS3DObject as b, CSS3DSprite as u } from "three/examples/jsm/renderers/CSS3DRenderer";
5
+ import { d as o } from "./disposeMesh.module.js";
6
6
  import "idb-keyval";
7
7
  import "d3-geo";
8
8
  import "d3-geo-projection";
9
- const h = (o, t, e = !0) => {
10
- t && (c(t, e), t.children.forEach((i) => {
11
- o.has(i) || h(o, i, e);
12
- }));
13
- };
14
9
  class D {
15
10
  constructor() {
16
- this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.pm = b(), this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [];
11
+ this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.pm = l(), this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [];
17
12
  }
18
13
  get parent() {
19
14
  const t = this.object3d.parent;
@@ -69,13 +64,13 @@ class D {
69
64
  return this.object3d = new r.Points(...t), this;
70
65
  }
71
66
  createCSS2DObject(t) {
72
- return this.object3d = new u(t), this;
67
+ return this.object3d = new d(t), this;
73
68
  }
74
69
  createCSS3DObject(t) {
75
- return this.object3d = new p(t), this;
70
+ return this.object3d = new b(t), this;
76
71
  }
77
72
  createCSS3DSprite(t) {
78
- return this.object3d = new j(t), this;
73
+ return this.object3d = new u(t), this;
79
74
  }
80
75
  createSprite(t) {
81
76
  return this.object3d = new r.Sprite(t), this;
@@ -119,9 +114,9 @@ class D {
119
114
  "depthTest",
120
115
  "depthWrite"
121
116
  ];
122
- for (const l of n) {
123
- const d = this.object3d.material[l];
124
- d !== null && (a[l] = d);
117
+ for (const c of n) {
118
+ const h = this.object3d.material[c];
119
+ h !== null && (a[c] = h);
125
120
  }
126
121
  e.object3d = new r.Mesh(
127
122
  new r.PlaneGeometry(s.x, s.y, 2, 2),
@@ -178,7 +173,7 @@ class D {
178
173
  if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t])
179
174
  if (i) {
180
175
  const n = this.materialList[t];
181
- c({
176
+ o({
182
177
  material: n
183
178
  });
184
179
  } else
@@ -200,11 +195,11 @@ class D {
200
195
  dispose() {
201
196
  this.onPointerIndex.forEach((t) => {
202
197
  this.drawController.removePick(t);
203
- }), h(this.drawController.objMap, this.object3d), Object.keys(this.materialList).forEach((t) => {
198
+ }), this.object3d && o(this.object3d), Object.keys(this.materialList).forEach((t) => {
204
199
  if (t !== this.useMaterialType) {
205
200
  if (this.isInstantiate && t === "origin")
206
201
  return;
207
- c({
202
+ o({
208
203
  material: this.materialList[t]
209
204
  });
210
205
  }
@@ -213,7 +208,7 @@ class D {
213
208
  disposeWithOutMaterial() {
214
209
  this.onPointerIndex.forEach((t) => {
215
210
  this.drawController.removePick(t);
216
- }), h(this.drawController.objMap, this.object3d, !1);
211
+ }), this.object3d && o(this.object3d, !1);
217
212
  }
218
213
  }
219
214
  export {
@@ -1,6 +1,3 @@
1
- export { default as Text } from './text';
2
- export { default as Image } from './image';
3
- export { default as Video } from './video';
4
1
  export { default as Node } from './node';
5
2
  export { default as Group } from './group';
6
3
  export { default as Pie } from './pie';
@@ -1,4 +1,4 @@
1
- "use strict";var wt=Object.defineProperty,Mt=Object.defineProperties;var At=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Je=Math.pow,He=(o,e,t)=>e in o?wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,I=(o,e)=>{for(var t in e||(e={}))$e.call(e,t)&&He(o,t,e[t]);if(ge)for(var t of ge(e))Ze.call(e,t)&&He(o,t,e[t]);return o},Me=(o,e)=>Mt(o,At(e));var Ae=(o,e)=>{var t={};for(var i in o)$e.call(o,i)&&e.indexOf(i)<0&&(t[i]=o[i]);if(o!=null&&ge)for(var i of ge(o))e.indexOf(i)<0&&Ze.call(o,i)&&(t[i]=o[i]);return t};var ee=(o,e,t)=>new Promise((i,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},r=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(n,r);a((t=t.apply(o,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("three"),ie=require("../BaseObject.js"),St=require("esus-lite"),_t=require("../index2.js"),Pt=require("@tweenjs/tween.js"),Vt=require("three/examples/jsm/lines/LineSegments2"),je=require("three/examples/jsm/lines/LineSegmentsGeometry"),lt=require("three/examples/jsm/lines/LineMaterial"),oe=require("d3-array"),Be=require("earcut"),Tt=require("@turf/boolean-clockwise"),Le=require("../uvGenerator.js"),Bt=require("delaunator"),Lt=require("@turf/boolean-point-in-polygon"),he=require("d3-geo"),Ct=require("d3-geo-voronoi"),Xe=require("d3-scale");function ct(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const y=ct(w),ae=ct(Pt),jt=+y.REVISION<144,ut=jt?"PlaneBufferGeometry":"PlaneGeometry";class ht extends ie.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=I({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return ee(this,null,function*(){const{src:e,texture:t,transparent:i,opacity:s,blending:n,depthWrite:r,depthTest:a,alphaTest:c,sprite:u,sizeAttenuation:l,color:h}=this.options,p=t||(yield new y.TextureLoader().loadAsync(e));return u?new y.SpriteMaterial({map:p,transparent:i!=null?i:!1,blending:n!=null?n:y.NormalBlending,depthWrite:r!=null?r:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:s!=null?s:1,sizeAttenuation:l!=null?l:!0}):new y.MeshBasicMaterial({color:h!=null?h:16777215,map:p,transparent:i!=null?i:!1,blending:n!=null?n:y.NormalBlending,depthWrite:r!=null?r:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:s!=null?s:1})})}create(){return ee(this,null,function*(){const{position:e,material:t,sprite:i}=this.options,s=t||(yield this.getMaterial());i?this.createSprite(s):this.createMesh(new y[ut](1,1),s),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 It extends ht{constructor(e){super(e),this.canvas=document.createElement("canvas")}getTexture(){const{text:e,textOptions:t}=this.options,{fontSize:i,fontFamily:s,fontWeight:n,flipX:r,color:a,setCtx:c}=I({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:f=>{}},t||{}),{canvas:u}=this;u.width=i*e.length*2,u.height=i;let l=u.getContext("2d");l.font=`${n} ${i}px/1 ${s}`;const{width:h}=l.measureText(e);u.width=h,l=u.getContext("2d"),l.clearRect(0,0,u.width,u.height),r&&l.scale(-1,1),l.font=`${n} ${i}px/1 ${s}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(e,r?h*-1:0,u.height/2),l.restore();const p=new y.Texture(u);return p.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),p.needsUpdate=!0,Promise.resolve(p)}}class Et extends ie.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=I({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:i,depthWrite:s,depthTest:n,format:r,autoPlay:a,loop:c,alphaTest:u,sprite:l}=this.options,h=St.makePromiseCreator();if(!e)return Promise.reject("src is required");const p=document.createElement("video");return p.addEventListener("loadedmetadata",()=>{const f=new y.VideoTexture(p);f.format=r!=null?r:y.RGBAFormat,f.needsUpdate=!0;const d=l?new y.SpriteMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:y.NormalBlending,depthWrite:s!=null?s:!0,depthTest:n!=null?n:!0,alphaTest:u!=null?u:0}):new y.MeshBasicMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:y.NormalBlending,depthWrite:s!=null?s:!0,depthTest:n!=null?n:!0,alphaTest:u!=null?u:0});h.resolve(d)},!1),p.src=e,p.muted=!0,p.autoplay=a,p.loop=c,p.preload="auto",h.promise}create(){return ee(this,null,function*(){const{scale:e,position:t,src:i,cache:s,sprite:n}=this.options,r=i&&(s?yield s.get(i,()=>this.getMaterial()):yield this.getMaterial());this.video=r.map.image,n?this.createSprite(r):this.createMesh(new y[ut](1,1),r),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 Gt extends ie.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.onNodePointerIndex=[],this.options=I({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=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}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight;let n=0,r=0;t.left<0?n=-t.left:t.right>i&&(n=i-t.right),t.top<0?r=-t.top:t.bottom>s&&(r=s-t.bottom),t.left+n<0&&(n=-t.left),t.top+r<0&&(r=-t.top),(n!==0||r!==0)&&(e.style.transform=`translate(${n}px, ${r}px)`)}ensureVisible(){return ee(this,null,function*(){const e=this.options.children;if(!e)return;e.style.transform&&(e.style.transform="");const t=new IntersectionObserver(i=>{i.forEach(s=>{s.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)})}checkVisible(){this.drawGroupShow&&this.visibleCache?super.show():(!this.drawGroupShow||!this.visibleCache)&&super.hide()}onPointerEvent(e,t){const i=this.drawController.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){this.onNodePointerIndex.forEach(e=>{this.drawController.removePickNode(e)}),super.dispose()}}class zt extends ie.BaseObject{constructor(e){super(),this.options=I({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return ee(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:i,material:s,percentDepth:n,activeIndex:r}=this.options,a=Math.max(...e),c=e.reduce((l,h)=>l+h,0);let u=Math.PI/2;e.forEach((l,h)=>{if(l===0)return;const p=Math.PI*2*(l/c),f=i[h],d=n?t*(l/a):t,m=this.createGeometry(d,p),M=s?s.clone():new y.MeshBasicMaterial({color:f});s&&M.color.set(f);const B=new y.Mesh(m,M);B.userData.depth=d,B.userData.index=h,B.rotateZ(u),u+=p,this.add(B)}),r!==-1&&this.setActive(r)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,n=new y.Shape;return n.moveTo(i,0),n.lineTo(s,0),n.absarc(0,0,s,0,t,!1),n.absarc(0,0,i,t,0,!0),new y.ExtrudeGeometry(n,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:i}=this.pencil.pick(e,this.object3d.children)||{},s=i?this.object3d.children.findIndex(n=>n===i):this.options.activeIndex;return this.setActive(s,t)}setActive(e,t=1.3){const i=this.object3d.children[e];if(this.object3d.children.forEach(s=>{if(!(i&&i===s)&&s.scale.z!==1){if(s.userData.levTween)return;s.userData.enTween&&(s.userData.enTween.stop(),s.userData.enTween=null);const n=new ae.Tween(s.scale).to({z:1},100);s.userData.levTween=n,n.start()}}),i){if(i.userData.enTween)return;i.userData.levTween&&(i.userData.levTween.stop(),i.userData.levTween=null);const s=new ae.Tween(i.scale).to({z:t},100);return i.userData.enTween=s,s.start(),i.userData.index}return-1}render(){this.object3d.scale.z=0,new ae.Tween(this.object3d.scale).to({z:1},1e3).easing(ae.Easing.Sinusoidal.InOut).start()}}class Ot extends ie.BaseObject{constructor(e){super(),this.options=e}create(){var t,i,s,n,r,a,c,u,l,h,p,f,d;const e=this.options;if(e.type==="AmbientLight"){const m=new y.AmbientLight(e.color);m.name="AmbientLight",this.object3d=m}else if(e.type==="DirectionalLight"){const m=new y.DirectionalLight(e.color,e.intensity);m.name="DirectionalLight",m.target.position.set(0,0,0),this.object3d=m,this.pencil.scene.add(m.target),this.directionalLight=m}else if(e.type==="PointLight"){const m=new y.PointLight((t=e.color)!=null?t:16777215,(i=e.intensity)!=null?i:1,(s=e.distance)!=null?s:0,(n=e.decay)!=null?n:2);m.name="PointLight",this.object3d=m,this.pointLight=m}else if(e.type==="SpotLight"){const m=new y.SpotLight((r=e.color)!=null?r:16777215,(a=e.intensity)!=null?a:1,(c=e.distance)!=null?c:0,(u=e.angle)!=null?u:Math.PI/3,(l=e.penumbra)!=null?l:1,(h=e.decay)!=null?h:2);m.name="SpotLight",this.object3d=m,this.spotLight=m,this.pencil.scene.add(m.target)}else if(e.type==="HemisphereLight"){const m=new y.HemisphereLight((p=e.color)!=null?p:16777215,(f=e.groundColor)!=null?f:16777215,(d=e.intensity)!=null?d:1);m.name="HemisphereLight",this.object3d=m,this.hemisphereLight=m}}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 te(o,e=0){const t=o[0].index!==null,i=new Set(Object.keys(o[0].attributes)),s=new Set(Object.keys(o[0].morphAttributes)),n={},r={},a=o[0].morphTargetsRelative,c=new w.BufferGeometry;let u=0;for(let l=0;l<o.length;++l){const h=o[l];let p=0;if(t!==(h.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 f in h.attributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;n[f]===void 0&&(n[f]=[]),n[f].push(h.attributes[f]),p++}if(p!==i.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!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;r[f]===void 0&&(r[f]=[]),r[f].push(h.morphAttributes[f])}if(e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". The geometry must have either an index or a position attribute"),null;if(e===1)c.addGroup(u,f,l);else if(e===2&&h.groups.length>0)for(let d of h.groups){let m=d.materialIndex;c.addGroup(u+d.start,Math.min(d.count,f),m)}u+=f}}if(t){let l=0;const h=[];for(let p=0;p<o.length;++p){const f=o[p].index;for(let d=0;d<f.count;++d)h.push(f.getX(d)+l);l+=o[p].attributes.position.count}c.setIndex(h)}for(const l in n){const h=Ye(n[l]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;c.setAttribute(l,h)}for(const l in r){const h=r[l][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let p=0;p<h;++p){const f=[];for(let m=0;m<r[l].length;++m)f.push(r[l][m][p]);const d=Ye(f);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;c.morphAttributes[l].push(d)}}return e===2?Ut(c):c}function Ye(o){let e,t,i,s=-1,n=0;for(let u=0;u<o.length;++u){const l=o[u];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(i===void 0&&(i=l.normalized),i!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=l.gpuType),s!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=l.count*t}const r=new e(n),a=new w.BufferAttribute(r,t,i);let c=0;for(let u=0;u<o.length;++u){const l=o[u];if(l.isInterleavedBufferAttribute){const h=c/t;for(let p=0,f=l.count;p<f;p++)for(let d=0;d<t;d++){const m=l.getComponent(p,d);a.setComponent(p+h,d,m)}}else r.set(l.array,c);c+=l.count*t}return s!==void 0&&(a.gpuType=s),a}function Ut(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((r,a)=>r.materialIndex!==a.materialIndex?r.materialIndex-a.materialIndex:r.start-a.start),o.getIndex()===null){const r=o.getAttribute("position"),a=[];for(let c=0;c<r.count;c+=3)a.push(c,c+1,c+2);o.setIndex(a)}const t=o.getIndex(),i=[];for(let r=0;r<e.length;r++){const a=e[r],c=a.start,u=c+a.count;for(let l=c;l<u;l++)i.push(t.getX(l))}o.dispose(),o.setIndex(i);let s=0;for(let r=0;r<e.length;r++){const a=e[r];a.start=s,s+=a.count}let n=e[0];o.groups=[n];for(let r=1;r<e.length;r++){const a=e[r];n.materialIndex===a.materialIndex?n.count+=a.count:(n=a,o.groups.push(n))}return o}const Se=new w.Vector4,Ke=new w.Vector3,Qe=new w.Vector3,z=new w.Vector4,O=new w.Vector4,q=new w.Vector4,_e=new w.Vector3,Pe=new w.Matrix4,U=new w.Line3,et=new w.Vector3,ye=new w.Box3,ve=new w.Sphere,H=new w.Vector4;let $,ne;function tt(o,e,t){return H.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),H.multiplyScalar(1/H.w),H.x=ne/t.width,H.y=ne/t.height,H.applyMatrix4(o.projectionMatrixInverse),H.multiplyScalar(1/H.w),Math.abs(Math.max(H.x,H.y))}function Wt(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,n=i.attributes.instanceEnd,r=Math.min(i.instanceCount,s.count);for(let a=0,c=r;a<c;a++){U.start.fromBufferAttribute(s,a),U.end.fromBufferAttribute(n,a),U.applyMatrix4(t);const u=new w.Vector3,l=new w.Vector3;$.distanceSqToSegment(U.start,U.end,l,u),l.distanceTo(u)<ne*.5&&e.push({point:l,pointOnLine:u,distance:$.origin.distanceTo(l),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function Dt(o,e,t){const i=e.projectionMatrix,n=o.material.resolution,r=o.matrixWorld,a=o.geometry,c=a.attributes.instanceStart,u=a.attributes.instanceEnd,l=Math.min(a.instanceCount,c.count),h=-e.near;$.at(1,q),q.w=1,q.applyMatrix4(e.matrixWorldInverse),q.applyMatrix4(i),q.multiplyScalar(1/q.w),q.x*=n.x/2,q.y*=n.y/2,q.z=0,_e.copy(q),Pe.multiplyMatrices(e.matrixWorldInverse,r);for(let p=0,f=l;p<f;p++){if(z.fromBufferAttribute(c,p),O.fromBufferAttribute(u,p),z.w=1,O.w=1,z.applyMatrix4(Pe),O.applyMatrix4(Pe),z.z>h&&O.z>h)continue;if(z.z>h){const V=z.z-O.z,T=(z.z-h)/V;z.lerp(O,T)}else if(O.z>h){const V=O.z-z.z,T=(O.z-h)/V;O.lerp(z,T)}z.applyMatrix4(i),O.applyMatrix4(i),z.multiplyScalar(1/z.w),O.multiplyScalar(1/O.w),z.x*=n.x/2,z.y*=n.y/2,O.x*=n.x/2,O.y*=n.y/2,U.start.copy(z),U.start.z=0,U.end.copy(O),U.end.z=0;const m=U.closestPointToPointParameter(_e,!0);U.at(m,et);const M=w.MathUtils.lerp(z.z,O.z,m),B=M>=-1&&M<=1,P=_e.distanceTo(et)<ne*.5;if(B&&P){U.start.fromBufferAttribute(c,p),U.end.fromBufferAttribute(u,p),U.start.applyMatrix4(r),U.end.applyMatrix4(r);const V=new w.Vector3,T=new w.Vector3;$.distanceSqToSegment(U.start,U.end,T,V),t.push({point:T,pointOnLine:V,distance:$.origin.distanceTo(T),object:o,face:null,faceIndex:p,uv:null,uv1:null})}}}class Rt extends w.Mesh{constructor(e=new je.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let r=0,a=0,c=t.count;r<c;r++,a+=2)Ke.fromBufferAttribute(t,r),Qe.fromBufferAttribute(i,r),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+Ke.distanceTo(Qe);const n=new w.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new w.InterleavedBufferAttribute(n,1,0)),e.setAttribute("instanceDistanceEnd",new w.InterleavedBufferAttribute(n,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const n=e.params.Line2!==void 0&&e.params.Line2.threshold||0;$=e.ray;const r=this.matrixWorld,a=this.geometry,c=this.material;ne=c.linewidth+n,a.boundingSphere===null&&a.computeBoundingSphere(),ve.copy(a.boundingSphere).applyMatrix4(r);let u;if(i)u=ne*.5;else{const h=Math.max(s.near,ve.distanceToPoint($.origin));u=tt(s,h,c.resolution)}if(ve.radius+=u,$.intersectsSphere(ve)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),ye.copy(a.boundingBox).applyMatrix4(r);let l;if(i)l=ne*.5;else{const h=Math.max(s.near,ye.distanceToPoint($.origin));l=tt(s,h,c.resolution)}ye.expandByScalar(l),$.intersectsBox(ye)!==!1&&(i?Wt(this,t):Dt(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Se),this.material.uniforms.resolution.value.set(Se.z,Se.w))}}const it=o=>{const{points:e}=o,t=e.reduce((s,n,r)=>(r<e.length-1&&s.push(n,e[r+1]),s),[]);return new y.BufferGeometry().setFromPoints(t)};let Nt=class extends ie.BaseObject{constructor(e={}){super(),this.options=I({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ee(this,null,function*(){const{points:e,pointsArr:t,geometry:i,geometryArr:s,material:n,useGroups:r,setPointWidth:a,lineWidthArr:c,materialParameters:u,instanceCount:l}=this.options;let h=n,p=i;!h&&u&&(h=this.getMaterial(u)),!p&&e?p=it({points:e}):!p&&t?p=te(t.map(d=>it({points:d})),r!=null?r:0):!p&&s&&s.length>1?p=te(s,r!=null?r:0):!p&&s&&s.length===1&&([p]=s);const f=new je.LineSegmentsGeometry().fromLineSegments(new y.LineSegments(p));if(this.pencil.options.WebGPUTHREE){l&&(f.instanceCount=l);const d=new Rt(f,h);d.computeLineDistances(),this.object3d=d}else{const d=new Vt.LineSegments2(f,h);d.computeLineDistances(),this.object3d=d}})}getMaterial(e){return new lt.LineMaterial(I({color:new y.Color("#ffffff")},e))}};function Ve(o,e,t,i,s){let n;if(o=o.subarray||o.slice?o:o.buffer,t=t.subarray||t.slice?t:t.buffer,o=e?o.subarray?o.subarray(e,s&&e+s):o.slice(e,s&&e+s):o,t.set)t.set(o,i);else for(n=0;n<o.length;n++)t[n+i]=o[n];return t}function kt(o){return o instanceof Float32Array?o:o instanceof y.BufferGeometry?o.getAttribute("position").array:o.map(e=>{const t=Array.isArray(e);return e instanceof y.Vector3?[e.x,e.y,e.z]:e instanceof y.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 ft extends y.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 y.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=kt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof y.Vector3)for(let i=0;i<e.length;i++){const s=e[i],n=i/(e.length-1);this.positions.push(s.x,s.y,s.z),this.positions.push(s.x,s.y,s.z),this.counters.push(n),this.counters.push(n)}else for(let i=0;i<e.length;i+=3){const s=i/(e.length-1);this.positions.push(e[i],e[i+1],e[i+2]),this.positions.push(e[i],e[i+1],e[i+2]),this.counters.push(s),this.counters.push(s)}this.process()}compareV3(e,t){const i=e*6,s=t*6;return this.positions[i]===this.positions[s]&&this.positions[i+1]===this.positions[s+1]&&this.positions[i+2]===this.positions[s+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,i;this.compareV3(0,e-1)?i=this.copyV3(e-2):i=this.copyV3(0),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);for(let s=0;s<e;s++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(s/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(s/(e-1),0),this.uvs.push(s/(e-1),1),s<e-1){i=this.copyV3(s),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);const n=s*2;this.indices_array.push(n,n+1,n+2),this.indices_array.push(n+2,n+1,n+3)}s>0&&(i=this.copyV3(s),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]))}this.compareV3(e-1,0)?i=this.copyV3(1):i=this.copyV3(e-1),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new y.BufferAttribute(new Float32Array(this.positions),3),previous:new y.BufferAttribute(new Float32Array(this.previous),3),next:new y.BufferAttribute(new Float32Array(this.next),3),side:new y.BufferAttribute(new Float32Array(this.side),1),width:new y.BufferAttribute(new Float32Array(this.width),1),uv:new y.BufferAttribute(new Float32Array(this.uvs),2),index:new y.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new y.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:i}){const s=this._attributes.position.array,n=this._attributes.previous.array,r=this._attributes.next.array,a=s.length;Ve(s,0,n,0,a),Ve(s,6,s,0,a-6),s[a-6]=e,s[a-5]=t,s[a-4]=i,s[a-3]=e,s[a-2]=t,s[a-1]=i,Ve(s,6,r,0,a-6),r[a-6]=e,r[a-5]=t,r[a-4]=i,r[a-3]=e,r[a-2]=t,r[a-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const st=["encodings_fragment","colorspace_fragment"],Ft=`
1
+ "use strict";var bt=Object.defineProperty,xt=Object.defineProperties;var wt=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Je=Math.pow,He=(n,e,t)=>e in n?bt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))$e.call(e,t)&&He(n,t,e[t]);if(ge)for(var t of ge(e))Ze.call(e,t)&&He(n,t,e[t]);return n},Ae=(n,e)=>xt(n,wt(e));var Me=(n,e)=>{var t={};for(var i in n)$e.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&ge)for(var i of ge(n))e.indexOf(i)<0&&Ze.call(n,i)&&(t[i]=n[i]);return t};var ce=(n,e,t)=>new Promise((i,s)=>{var r=u=>{try{a(t.next(u))}catch(f){s(f)}},o=u=>{try{a(t.throw(u))}catch(f){s(f)}},a=u=>u.done?i(u.value):Promise.resolve(u.value).then(r,o);a((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("../BaseObject.js"),At=require("../index2.js"),A=require("three"),Mt=require("@tweenjs/tween.js"),St=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),_t=require("three/examples/jsm/lines/LineSegments2"),Ce=require("three/examples/jsm/lines/LineSegmentsGeometry"),lt=require("three/examples/jsm/lines/LineMaterial"),re=require("d3-array"),Le=require("earcut"),Pt=require("@turf/boolean-clockwise"),Be=require("../uvGenerator.js"),Tt=require("delaunator"),Vt=require("@turf/boolean-point-in-polygon"),he=require("d3-geo"),Lt=require("d3-geo-voronoi"),Xe=require("d3-scale");function ut(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const x=ut(A),oe=ut(Mt);class Bt extends se.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=D({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight;let r=0,o=0;t.left<0?r=-t.left:t.right>i&&(r=i-t.right),t.top<0?o=-t.top:t.bottom>s&&(o=s-t.bottom),t.left+r<0&&(r=-t.left),t.top+o<0&&(o=-t.top),(r!==0||o!==0)&&(e.style.transform=`translate(${r}px, ${o}px)`)}ensureVisible(){const e=this.options.children;if(!e)return;e.style.transform&&(e.style.transform="");const t=new IntersectionObserver(i=>{i.forEach(s=>{s.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)}onPointerEvent(e,t){const i=this.drawController.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){this.onNodePointerIndex.forEach(e=>{this.drawController.removePickNode(e)}),super.dispose()}}class It extends se.BaseObject{constructor(e){super(),this.options=D({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return ce(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:i,material:s,percentDepth:r,activeIndex:o}=this.options,a=Math.max(...e),u=e.reduce((l,c)=>l+c,0);let f=Math.PI/2;e.forEach((l,c)=>{if(l===0)return;const p=Math.PI*2*(l/u),h=i[c],d=r?t*(l/a):t,w=this.createGeometry(d,p),M=s?s.clone():new x.MeshBasicMaterial({color:h});s&&M.color.set(h);const T=new x.Mesh(w,M);T.userData.depth=d,T.userData.index=c,T.rotateZ(f),f+=p,this.add(T)}),o!==-1&&this.setActive(o)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new x.Shape;return r.moveTo(i,0),r.lineTo(s,0),r.absarc(0,0,s,0,t,!1),r.absarc(0,0,i,t,0,!0),new x.ExtrudeGeometry(r,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:i}=this.pencil.pick(e,this.object3d.children)||{},s=i?this.object3d.children.findIndex(r=>r===i):this.options.activeIndex;return this.setActive(s,t)}setActive(e,t=1.3){const i=this.object3d.children[e];if(this.object3d.children.forEach(s=>{if(!(i&&i===s)&&s.scale.z!==1){if(s.userData.levTween)return;s.userData.enTween&&(s.userData.enTween.stop(),s.userData.enTween=null);const r=new oe.Tween(s.scale).to({z:1},100);s.userData.levTween=r,r.start()}}),i){if(i.userData.enTween)return;i.userData.levTween&&(i.userData.levTween.stop(),i.userData.levTween=null);const s=new oe.Tween(i.scale).to({z:t},100);return i.userData.enTween=s,s.start(),i.userData.index}return-1}render(){this.object3d.scale.z=0,new oe.Tween(this.object3d.scale).to({z:1},1e3).easing(oe.Easing.Sinusoidal.InOut).start()}}class Ct extends se.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,i,s,r,o,a,u,f,l,c,p,h,d,w,M,T,_;const e=this.options;if(e.type==="AmbientLight"){const b=new x.AmbientLight(e.color);b.name="环境光",this.object3d=b}else if(e.type==="DirectionalLight"){const b=new x.DirectionalLight(e.color,e.intensity);b.name="平行光",b.target.position.set(0,0,0),this.object3d=b,b.target.name="平行光目标",b.shadow.camera.name="平行光阴影相机",b.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=b}else if(e.type==="PointLight"){const b=new x.PointLight((t=e.color)!=null?t:16777215,(i=e.intensity)!=null?i:1,(s=e.distance)!=null?s:0,(r=e.decay)!=null?r:2);b.name="点光源",this.object3d=b,this.pointLight=b}else if(e.type==="SpotLight"){const b=new x.SpotLight((o=e.color)!=null?o:16777215,(a=e.intensity)!=null?a:1,(u=e.distance)!=null?u:0,(f=e.angle)!=null?f:Math.PI/3,(l=e.penumbra)!=null?l:1,(c=e.decay)!=null?c:2);b.name="聚光灯",this.object3d=b,this.spotLight=b,b.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const b=new x.HemisphereLight((p=e.color)!=null?p:16777215,(h=e.groundColor)!=null?h:16777215,(d=e.intensity)!=null?d:1);b.name="半球光",this.object3d=b,this.hemisphereLight=b}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(St.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const b=new x.RectAreaLight((w=e.color)!=null?w:16777215,(M=e.intensity)!=null?M:1,(T=e.width)!=null?T:10,(_=e.height)!=null?_:10);b.name="矩形区域光",this.object3d=b,this.rectAreaLight=b}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const i=this.spotLight||this.directionalLight;i.position.copy(t),i.target.position.copy(t)}else this.pointLight&&this.pointLight.position.copy(t)}dispose(){const e=this.object3d;e.target&&this.pencil.scene.remove(e.target),super.dispose()}}function ee(n,e=0){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,u=new A.BufferGeometry;let f=0;for(let l=0;l<n.length;++l){const c=n[l];let p=0;if(t!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in c.attributes){if(!i.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;r[h]===void 0&&(r[h]=[]),r[h].push(c.attributes[h]),p++}if(p!==i.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!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in c.morphAttributes){if(!s.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;o[h]===void 0&&(o[h]=[]),o[h].push(c.morphAttributes[h])}if(e){let h;if(t)h=c.index.count;else if(c.attributes.position!==void 0)h=c.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)u.addGroup(f,h,l);else if(e===2&&c.groups.length>0)for(let d of c.groups){let w=d.materialIndex;u.addGroup(f+d.start,Math.min(d.count,h),w)}f+=h}}if(t){let l=0;const c=[];for(let p=0;p<n.length;++p){const h=n[p].index;for(let d=0;d<h.count;++d)c.push(h.getX(d)+l);l+=n[p].attributes.position.count}u.setIndex(c)}for(const l in r){const c=Ye(r[l]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;u.setAttribute(l,c)}for(const l in o){const c=o[l][0].length;if(c===0)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[l]=[];for(let p=0;p<c;++p){const h=[];for(let w=0;w<o[l].length;++w)h.push(o[l][w][p]);const d=Ye(h);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;u.morphAttributes[l].push(d)}}return e===2?Et(u):u}function Ye(n){let e,t,i,s=-1,r=0;for(let f=0;f<n.length;++f){const l=n[f];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(i===void 0&&(i=l.normalized),i!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=l.gpuType),s!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=l.count*t}const o=new e(r),a=new A.BufferAttribute(o,t,i);let u=0;for(let f=0;f<n.length;++f){const l=n[f];if(l.isInterleavedBufferAttribute){const c=u/t;for(let p=0,h=l.count;p<h;p++)for(let d=0;d<t;d++){const w=l.getComponent(p,d);a.setComponent(p+c,d,w)}}else o.set(l.array,u);u+=l.count*t}return s!==void 0&&(a.gpuType=s),a}function Et(n){if(n.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),n;let e=n.groups;if(e=e.sort((o,a)=>o.materialIndex!==a.materialIndex?o.materialIndex-a.materialIndex:o.start-a.start),n.getIndex()===null){const o=n.getAttribute("position"),a=[];for(let u=0;u<o.count;u+=3)a.push(u,u+1,u+2);n.setIndex(a)}const t=n.getIndex(),i=[];for(let o=0;o<e.length;o++){const a=e[o],u=a.start,f=u+a.count;for(let l=u;l<f;l++)i.push(t.getX(l))}n.dispose(),n.setIndex(i);let s=0;for(let o=0;o<e.length;o++){const a=e[o];a.start=s,s+=a.count}let r=e[0];n.groups=[r];for(let o=1;o<e.length;o++){const a=e[o];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,n.groups.push(r))}return n}const Se=new A.Vector4,Ke=new A.Vector3,Qe=new A.Vector3,G=new A.Vector4,z=new A.Vector4,k=new A.Vector4,_e=new A.Vector3,Pe=new A.Matrix4,U=new A.Line3,et=new A.Vector3,ye=new A.Box3,ve=new A.Sphere,H=new A.Vector4;let $,ie;function tt(n,e,t){return H.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),H.multiplyScalar(1/H.w),H.x=ie/t.width,H.y=ie/t.height,H.applyMatrix4(n.projectionMatrixInverse),H.multiplyScalar(1/H.w),Math.abs(Math.max(H.x,H.y))}function jt(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,o=Math.min(i.instanceCount,s.count);for(let a=0,u=o;a<u;a++){U.start.fromBufferAttribute(s,a),U.end.fromBufferAttribute(r,a),U.applyMatrix4(t);const f=new A.Vector3,l=new A.Vector3;$.distanceSqToSegment(U.start,U.end,l,f),l.distanceTo(f)<ie*.5&&e.push({point:l,pointOnLine:f,distance:$.origin.distanceTo(l),object:n,face:null,faceIndex:a,uv:null,uv1:null})}}function Gt(n,e,t){const i=e.projectionMatrix,r=n.material.resolution,o=n.matrixWorld,a=n.geometry,u=a.attributes.instanceStart,f=a.attributes.instanceEnd,l=Math.min(a.instanceCount,u.count),c=-e.near;$.at(1,k),k.w=1,k.applyMatrix4(e.matrixWorldInverse),k.applyMatrix4(i),k.multiplyScalar(1/k.w),k.x*=r.x/2,k.y*=r.y/2,k.z=0,_e.copy(k),Pe.multiplyMatrices(e.matrixWorldInverse,o);for(let p=0,h=l;p<h;p++){if(G.fromBufferAttribute(u,p),z.fromBufferAttribute(f,p),G.w=1,z.w=1,G.applyMatrix4(Pe),z.applyMatrix4(Pe),G.z>c&&z.z>c)continue;if(G.z>c){const b=G.z-z.z,L=(G.z-c)/b;G.lerp(z,L)}else if(z.z>c){const b=z.z-G.z,L=(z.z-c)/b;z.lerp(G,L)}G.applyMatrix4(i),z.applyMatrix4(i),G.multiplyScalar(1/G.w),z.multiplyScalar(1/z.w),G.x*=r.x/2,G.y*=r.y/2,z.x*=r.x/2,z.y*=r.y/2,U.start.copy(G),U.start.z=0,U.end.copy(z),U.end.z=0;const w=U.closestPointToPointParameter(_e,!0);U.at(w,et);const M=A.MathUtils.lerp(G.z,z.z,w),T=M>=-1&&M<=1,_=_e.distanceTo(et)<ie*.5;if(T&&_){U.start.fromBufferAttribute(u,p),U.end.fromBufferAttribute(f,p),U.start.applyMatrix4(o),U.end.applyMatrix4(o);const b=new A.Vector3,L=new A.Vector3;$.distanceSqToSegment(U.start,U.end,L,b),t.push({point:L,pointOnLine:b,distance:$.origin.distanceTo(L),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class zt extends A.Mesh{constructor(e=new Ce.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let o=0,a=0,u=t.count;o<u;o++,a+=2)Ke.fromBufferAttribute(t,o),Qe.fromBufferAttribute(i,o),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+Ke.distanceTo(Qe);const r=new A.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new A.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new A.InterleavedBufferAttribute(r,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;$=e.ray;const o=this.matrixWorld,a=this.geometry,u=this.material;ie=u.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),ve.copy(a.boundingSphere).applyMatrix4(o);let f;if(i)f=ie*.5;else{const c=Math.max(s.near,ve.distanceToPoint($.origin));f=tt(s,c,u.resolution)}if(ve.radius+=f,$.intersectsSphere(ve)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),ye.copy(a.boundingBox).applyMatrix4(o);let l;if(i)l=ie*.5;else{const c=Math.max(s.near,ye.distanceToPoint($.origin));l=tt(s,c,u.resolution)}ye.expandByScalar(l),$.intersectsBox(ye)!==!1&&(i?jt(this,t):Gt(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Se),this.material.uniforms.resolution.value.set(Se.z,Se.w))}}const it=n=>{const{points:e}=n,t=e.reduce((s,r,o)=>(o<e.length-1&&s.push(r,e[o+1]),s),[]);return new x.BufferGeometry().setFromPoints(t)};let Ut=class extends se.BaseObject{constructor(e={}){super(),this.options=D({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ce(this,null,function*(){const{points:e,pointsArr:t,geometry:i,geometryArr:s,material:r,useGroups:o,setPointWidth:a,lineWidthArr:u,materialParameters:f,instanceCount:l}=this.options;let c=r,p=i;!c&&f&&(c=this.getMaterial(f)),!p&&e?p=it({points:e}):!p&&t?p=ee(t.map(d=>it({points:d})),o!=null?o:0):!p&&s&&s.length>1?p=ee(s,o!=null?o:0):!p&&s&&s.length===1&&([p]=s);const h=new Ce.LineSegmentsGeometry().fromLineSegments(new x.LineSegments(p));if(this.pencil.options.WebGPUTHREE){l&&(h.instanceCount=l);const d=new zt(h,c);d.computeLineDistances(),this.object3d=d}else{const d=new _t.LineSegments2(h,c);d.computeLineDistances(),this.object3d=d}})}getMaterial(e){return new lt.LineMaterial(D({color:new x.Color("#ffffff")},e))}};function Te(n,e,t,i,s){let r;if(n=n.subarray||n.slice?n:n.buffer,t=t.subarray||t.slice?t:t.buffer,n=e?n.subarray?n.subarray(e,s&&e+s):n.slice(e,s&&e+s):n,t.set)t.set(n,i);else for(r=0;r<n.length;r++)t[r+i]=n[r];return t}function Wt(n){return n instanceof Float32Array?n:n instanceof x.BufferGeometry?n.getAttribute("position").array:n.map(e=>{const t=Array.isArray(e);return e instanceof x.Vector3?[e.x,e.y,e.z]:e instanceof x.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 ct extends x.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 x.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=Wt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof x.Vector3)for(let i=0;i<e.length;i++){const s=e[i],r=i/(e.length-1);this.positions.push(s.x,s.y,s.z),this.positions.push(s.x,s.y,s.z),this.counters.push(r),this.counters.push(r)}else for(let i=0;i<e.length;i+=3){const s=i/(e.length-1);this.positions.push(e[i],e[i+1],e[i+2]),this.positions.push(e[i],e[i+1],e[i+2]),this.counters.push(s),this.counters.push(s)}this.process()}compareV3(e,t){const i=e*6,s=t*6;return this.positions[i]===this.positions[s]&&this.positions[i+1]===this.positions[s+1]&&this.positions[i+2]===this.positions[s+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,i;this.compareV3(0,e-1)?i=this.copyV3(e-2):i=this.copyV3(0),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);for(let s=0;s<e;s++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(s/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(s/(e-1),0),this.uvs.push(s/(e-1),1),s<e-1){i=this.copyV3(s),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);const r=s*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}s>0&&(i=this.copyV3(s),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]))}this.compareV3(e-1,0)?i=this.copyV3(1):i=this.copyV3(e-1),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new x.BufferAttribute(new Float32Array(this.positions),3),previous:new x.BufferAttribute(new Float32Array(this.previous),3),next:new x.BufferAttribute(new Float32Array(this.next),3),side:new x.BufferAttribute(new Float32Array(this.side),1),width:new x.BufferAttribute(new Float32Array(this.width),1),uv:new x.BufferAttribute(new Float32Array(this.uvs),2),index:new x.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new x.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:i}){const s=this._attributes.position.array,r=this._attributes.previous.array,o=this._attributes.next.array,a=s.length;Te(s,0,r,0,a),Te(s,6,s,0,a-6),s[a-6]=e,s[a-5]=t,s[a-4]=i,s[a-3]=e,s[a-2]=t,s[a-1]=i,Te(s,6,o,0,a-6),o[a-6]=e,o[a-5]=t,o[a-4]=i,o[a-3]=e,o[a-2]=t,o[a-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const st=["encodings_fragment","colorspace_fragment"],Ot=`
2
2
  #include <common>
3
3
  #include <logdepthbuf_pars_vertex>
4
4
  #include <fog_pars_vertex>
@@ -91,7 +91,7 @@
91
91
  vHighPrecisionZW = finalPosition.zw;
92
92
  #include <fog_vertex>
93
93
  }
94
- `,qt=`
94
+ `,Dt=`
95
95
  #include <packing>
96
96
  #include <fog_pars_fragment>
97
97
  #include <logdepthbuf_pars_fragment>
@@ -141,6 +141,6 @@
141
141
 
142
142
  #include <fog_fragment>
143
143
  #include <tonemapping_fragment>
144
- #include <${+y.REVISION<154?st[0]:st[1]}>
144
+ #include <${+x.REVISION<154?st[0]:st[1]}>
145
145
  }
146
- `;class pt extends y.ShaderMaterial{constructor(e){super({uniforms:Me(I({},y.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new y.Color(16777215)},opacity:{value:1},resolution:{value:new y.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new y.Vector2(1,1)},offset:{value:new y.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new y.Vector2(0,0)},lightColor:{value:new y.Color(16777215)}}),vertexShader:Ft,fragmentShader:qt}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(t){this.uniforms.useDash.value=t}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(t){this.uniforms.useDepth.value=t}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(t){this.uniforms.repeat.value.copy(t)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(t){this.uniforms.lineLightAnimation.value=t}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(t){this.uniforms.size.value=t}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(t){this.uniforms.speed.value=t}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(t){this.uniforms.lightWidth.value=t}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(t){this.uniforms.uCenter.value=t}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(t){t&&(this.uniforms.lightColor.value=t)}}}),this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray=e.dashArray,this.dashOffset=e.dashOffset,this.dashRatio=e.dashRatio,this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}function Ht(o,e){const t=new y.Matrix4,i=new y.Ray,s=new y.Sphere,n=new y.Vector3,r=this.geometry;if(s.copy(r.boundingSphere),s.applyMatrix4(this.matrixWorld),!o.ray.intersectSphere(s,n))return;t.copy(this.matrixWorld).invert(),i.copy(o.ray).applyMatrix4(t);const a=new y.Vector3,c=new y.Vector3,u=new y.Vector3,l=this instanceof y.LineSegments?2:1,h=r.index,p=r.attributes;if(h!==null){const f=h.array,d=p.position.array,m=p.width.array;for(let M=0,B=f.length-1;M<B;M+=l){const P=f[M],V=f[M+1];a.fromArray(d,P*3),c.fromArray(d,V*3);const T=m[Math.floor(M/3)]!=null?m[Math.floor(M/3)]:1,E=o.params.Line.threshold+this.material.lineWidth*T/2,j=E*E;if(i.distanceSqToSegment(a,c,n,u)>j)continue;n.applyMatrix4(this.matrixWorld);const W=o.ray.origin.distanceTo(n);W<o.near||W>o.far||(e.push({distance:W,point:u.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:void 0,object:this}),M=B)}}}const Te=o=>{const{setPointWidth:e,nodes:t}=o,i=new ft;return i.setPoints(t,e),i};class $t extends ie.BaseObject{constructor(e={}){super(),this.options=I({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ee(this,null,function*(){const{nodes:e,nodesArr:t,geometry:i,geometryArr:s,material:n,useGroups:r,setPointWidth:a,lineWidthArr:c,materialParameters:u}=this.options;let l=n,h=i;!l&&u&&(l=this.getMaterial(u)),!h&&e?h=Te({nodes:e,setPointWidth:a}):!h&&t?h=te(t.map((p,f)=>{let d=a;return!d&&c&&(d=()=>{var m;return(m=c[f])!=null?m:c[0]}),Te({nodes:p,setPointWidth:d})}),r!=null?r:0):!h&&s&&s.length>1?h=te(s,r!=null?r:0):!h&&s&&s.length===1&&([h]=s),this.createMesh(h,l)})}setGeometry(e,t){const i=Te({nodes:e,setPointWidth:t}),s=this.object3d,n=s.geometry;s.geometry=i,n.dispose()}getMaterial(e){const{width:t,height:i}=this.pencil.getSize();return new pt(I({color:new y.Color("#ffffff"),resolution:new y.Vector2(t,i)},e))}addGeometries(e){const t=this.object3d,i=te([t.geometry,...e]);t.geometry=i}resize(e,t){var i,s;(s=(i=this.material)==null?void 0:i.uniforms)==null||s.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:i}=this.pencil.getSize();this.resize(t,i)}animate({duration:e=1e3,delay:t=0,repeat:i=0,lineLoop:s,onRepeat:n,onUpdate:r,onComplete:a}={}){const{offset:c,offsetLoop:u}=this.material.uniforms;if(this.material.userData.tween)return;const l=s!=null?s:!0;c.value.x=1,u.value=0;let h=0;const p=new ae.Tween(c.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:f})=>{l&&f<=0&&u.value===0&&(u.value=1),r&&r(f)}).onRepeat(()=>{h+=1,n&&n(h)}).onComplete(()=>{a&&a()}).start();this.material.userData.tween=p}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),ae.remove(this.material.userData.tween)),super.dispose()}}function Zt(o,e){return o.map(t=>{const i=[];let s;return t.forEach(n=>{if(s){const r=he.geoDistance(n,s)*180/Math.PI;if(r>e){const a=he.geoInterpolate(s,n),c=1/Math.ceil(r/e);let u=c;for(;u<1;)i.push(a(u)),u+=c}}i.push(s=n)}),i})}function Jt(o,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const n=Math.round(Je(360/o,2)/Math.PI),r=(1+Math.sqrt(5))/2,a=f=>f/r*360%360-180,c=f=>Math.acos(2*f/n-1)/Math.PI*180-90,u=f=>n*(Math.cos((f+90)*Math.PI/180)+1)/2,l=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):n-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,p=[];for(let f=l[0];f<=l[1];f++){const d=a(f);h(d)&&p.push([d,c(f)])}return p}function Ce(o,e,t=!1){return t?he.geoContains(e,o):Lt(o,e)}function Xt(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[n,r]]=he.geoBounds(t);if(Math.min(Math.abs(n-i),Math.abs(r-s))<e)return[];const a=i>n||r>=89||s<=-89;return Jt(e,{minLng:i,maxLng:n,minLat:s,maxLat:r}).filter(c=>Ce(c,t,a))}function Yt(o,{resolution:e=1/0,bbox:t}={}){const i=Zt(o,e),s=oe.merge(i),n=Xt(o,e),r=[...s,...n],a={type:"Polygon",coordinates:o},[[c,u],[l,h]]=he.geoBounds(a),p=c>l||h>=89||u<=-89;let f=[];if(p){const P=Ct.geoVoronoi(r).triangles(),V=new Map(r.map(([T,E],j)=>[`${T}-${E}`,j]));P.features.forEach(T=>{const E=T.geometry.coordinates[0].slice(0,3).reverse(),j=[];if(E.forEach(([L,W])=>{const k=`${L}-${W}`;V.has(k)&&j.push(V.get(k))}),j.length===3){if(j.some(L=>L<s.length)){const L=T.properties.circumcenter;if(!Ce(L,a,p))return}f.push(...j)}})}else if(n.length){const P=Bt.from(r);for(let V=0,T=P.triangles.length;V<T;V+=3){const E=[2,1,0].map(L=>P.triangles[V+L]),j=E.map(L=>r[L]);if(E.some(L=>L<s.length)){const L=[0,1].map(W=>oe.mean(j,k=>k[W]));if(!Ce(L,a,p))continue}f.push(...E)}}else{const{vertices:P,holes:V=[]}=Be.flatten(i);f=Be(P,V,2)}const d=Xe.scaleLinear(t?[t[0],t[2]]:oe.extent(r,P=>P[0]),[0,1]),m=Xe.scaleLinear(t?[t[1],t[3]]:oe.extent(r,P=>P[1]),[0,1]),M=r.map(([P,V])=>[d(P),m(V)]);return{contour:i,triangles:{points:r,indices:f,uvs:M}}}const nt=new y.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function be(o,e,t,i){const s=o.map(n=>n.map(([r,a])=>{if(i){const[c,u]=i([r,a]);return[c,-u,e]}return t?Le.polar2Cartesian(r,a,e):[r,a,e]}));return Be.flatten(s)}function Kt(o,e,t,i,s){const{vertices:n,holes:r}=be(o,e,i,s),{vertices:a}=be(o,t,i,s),c=oe.merge([a,n]),u=Math.round(a.length/3),l=new Set(r);let h=0;const p=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(l.has(m)){const M=m;m=h,h=M}p.push(d,d+u,m+u),p.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:p,vertices:c,uvs:f,topVerts:a}}function rt(o,e,t,i,s,n){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:be([o.points],e,s,n).vertices,uvs:t}}const dt=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:n=!0,hasBottom:r=!1,hasTop:a=!1,projection:c,bbox:u})=>{o.forEach(B=>{Tt(B)||B.reverse()});const{contour:l,triangles:h}=Yt(o,{resolution:i,bbox:u});let p={},f;n&&(p=Kt(l,e!=null?e:t,t!=null?t:e,s,c),f=p.topVerts);let d=[];(r||a)&&(d=oe.merge(h.uvs));let m={};r&&(m=rt(h,e,d,!1,s,c));let M={};return a&&(M=rt(h,t,d,!0,s,c)),{contour:l,triangles:h,sideTorso:p,bottomCap:m,topCap:M,topVerts:f}};class mt extends y.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=I({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:n,hasBottom:r,hasSide:a,cartesian:c,userDataRsoOffset:u,projection:l}=this.parameters,{contour:h,sideTorso:p,topVerts:f,bottomCap:d,topCap:m}=dt(I({},this.parameters));let M=[],B=[],P=[],V=0;const T=E=>{const j=Math.round(M.length/3),L=P.length;M=M.concat(E.vertices),B=B.concat(E.uvs),P=P.concat(j?E.indices.map(W=>W+j):E.indices),this.addGroup(L,P.length-L,V++)};s&&n&&T(m),a&&(T(p),this.userData.topVerts=u?be(h,i+u,c,l).vertices:f),r&&T(d),s&&!n&&T(m),this.setIndex(P),this[nt]("position",new y.Float32BufferAttribute(M,3)),this[nt]("uv",new y.Float32BufferAttribute(B,2)),this.computeVertexNormals()}}const ot=o=>{const a=o,{coordinate:e,startHeight:t,height:i}=a,s=Ae(a,["coordinate","startHeight","height"]);let n=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(n=t+i),new mt([e],Me(I({},s),{startHeight:t,endHeight:n}))};class Qt extends ie.BaseObject{constructor(e){super(),this.options=I({},e)}create(){const c=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:n}=c,r=Ae(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&i)a=ot(I({coordinate:i},r));else if(!a&&t){const u=t.map(l=>ot(I({coordinate:l},r)));a=te(u,n!=null?n:0)}this.createMesh(a,s)}}class Ie extends w.BufferGeometry{constructor(e=new w.Shape([new w.Vector2(.5,.5),new w.Vector2(-.5,.5),new w.Vector2(-.5,-.5),new w.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,s=[],n=[];for(let a=0,c=e.length;a<c;a++){const u=e[a];r(u)}this.setAttribute("position",new w.Float32BufferAttribute(s,3)),this.setAttribute("uv",new w.Float32BufferAttribute(n,2)),this.computeVertexNormals();function r(a){var Ue,We,De;const c=[],u=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,d=t.bevelSize!==void 0?t.bevelSize:f-.1,m=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const B=t.extrudePath,P=t.UVGenerator!==void 0?t.UVGenerator:ei,V=(Ue=t.hasTop)!=null?Ue:!0,T=(We=t.hasBottom)!=null?We:!0,E=(De=t.hasSide)!=null?De:!0;let j,L=!1,W,k,le,Z;B&&(j=B.getSpacedPoints(l),L=!0,p=!1,W=B.computeFrenetFrames(l,!1),k=new w.Vector3,le=new w.Vector3,Z=new w.Vector3),p||(M=0,f=0,d=0,m=0);const Ee=a.extractPoints(u);let N=Ee.shape;const R=Ee.holes;if(!w.ShapeUtils.isClockWise(N)){N=N.reverse();for(let g=0,v=R.length;g<v;g++){const b=R[g];w.ShapeUtils.isClockWise(b)&&(R[g]=b.reverse())}}const ce=w.ShapeUtils.triangulateShape(N,R),F=N;for(let g=0,v=R.length;g<v;g++){const b=R[g];N=N.concat(b)}function re(g,v,b){return v||console.error("THREE.ExtrudeGeometry: vec does not exist"),g.clone().addScaledVector(v,b)}const J=N.length,fe=ce.length;function Ge(g,v,b){let A,x,S;const _=g.x-v.x,C=g.y-v.y,D=b.x-g.x,G=b.y-g.y,ue=_*_+C*C,we=_*G-C*D;if(Math.abs(we)>Number.EPSILON){const Q=Math.sqrt(ue),Re=Math.sqrt(D*D+G*G),Ne=v.x-C/Q,ke=v.y+_/Q,bt=b.x-G/Re,xt=b.y+D/Re,Fe=((bt-Ne)*G-(xt-ke)*D)/(_*G-C*D);A=Ne+_*Fe-g.x,x=ke+C*Fe-g.y;const qe=A*A+x*x;if(qe<=2)return new w.Vector2(A,x);S=Math.sqrt(qe/2)}else{let Q=!1;_>Number.EPSILON?D>Number.EPSILON&&(Q=!0):_<-Number.EPSILON?D<-Number.EPSILON&&(Q=!0):Math.sign(C)===Math.sign(G)&&(Q=!0),Q?(A=-C,x=_,S=Math.sqrt(ue)):(A=_,x=C,S=Math.sqrt(ue/2))}return new w.Vector2(A/S,x/S)}const pe=[];for(let g=0,v=F.length,b=v-1,A=g+1;g<v;g++,b++,A++)b===v&&(b=0),A===v&&(A=0),pe[g]=Ge(F[g],F[b],F[A]);const xe=[];let se,de=pe.concat();for(let g=0,v=R.length;g<v;g++){const b=R[g];se=[];for(let A=0,x=b.length,S=x-1,_=A+1;A<x;A++,S++,_++)S===x&&(S=0),_===x&&(_=0),se[A]=Ge(b[A],b[S],b[_]);xe.push(se),de=de.concat(se)}for(let g=0;g<M;g++){const v=g/M,b=f*Math.cos(v*Math.PI/2),A=d*Math.sin(v*Math.PI/2)+m;for(let x=0,S=F.length;x<S;x++){const _=re(F[x],pe[x],A);X(_.x,_.y,-b)}for(let x=0,S=R.length;x<S;x++){const _=R[x];se=xe[x];for(let C=0,D=_.length;C<D;C++){const G=re(_[C],se[C],A);X(G.x,G.y,-b)}}}const ze=d+m;for(let g=0;g<J;g++){const v=p?re(N[g],de[g],ze):N[g];L?(le.copy(W.normals[0]).multiplyScalar(v.x),k.copy(W.binormals[0]).multiplyScalar(v.y),Z.copy(j[0]).add(le).add(k),X(Z.x,Z.y,Z.z)):X(v.x,v.y,0)}for(let g=1;g<=l;g++)for(let v=0;v<J;v++){const b=p?re(N[v],de[v],ze):N[v];L?(le.copy(W.normals[g]).multiplyScalar(b.x),k.copy(W.binormals[g]).multiplyScalar(b.y),Z.copy(j[g]).add(le).add(k),X(Z.x,Z.y,Z.z)):X(b.x,b.y,h/l*g)}for(let g=M-1;g>=0;g--){const v=g/M,b=f*Math.cos(v*Math.PI/2),A=d*Math.sin(v*Math.PI/2)+m;for(let x=0,S=F.length;x<S;x++){const _=re(F[x],pe[x],A);X(_.x,_.y,h+b)}for(let x=0,S=R.length;x<S;x++){const _=R[x];se=xe[x];for(let C=0,D=_.length;C<D;C++){const G=re(_[C],se[C],A);L?X(G.x,G.y+j[l-1].y,j[l-1].x+b):X(G.x,G.y,h+b)}}}gt(),E&&yt();function gt(){const g=s.length/3;if(p){let v=0,b=J*v;if(T)for(let A=0;A<fe;A++){const x=ce[A];me(x[2]+b,x[1]+b,x[0]+b)}if(v=l+M*2,b=J*v,V)for(let A=0;A<fe;A++){const x=ce[A];me(x[0]+b,x[1]+b,x[2]+b)}}else{if(T)for(let v=0;v<fe;v++){const b=ce[v];me(b[2],b[1],b[0])}if(V)for(let v=0;v<fe;v++){const b=ce[v];me(b[0]+J*l,b[1]+J*l,b[2]+J*l)}}i.addGroup(g,s.length/3-g,0)}function yt(){const g=s.length/3;let v=0;Oe(F,v),v+=F.length;for(let b=0,A=R.length;b<A;b++){const x=R[b];Oe(x,v),v+=x.length}i.addGroup(g,s.length/3-g,1)}function Oe(g,v){let b=g.length;for(;--b>=0;){const A=b;let x=b-1;x<0&&(x=g.length-1);for(let S=0,_=l+M*2;S<_;S++){const C=J*S,D=J*(S+1),G=v+A+C,ue=v+x+C,we=v+x+D,Q=v+A+D;vt(G,ue,we,Q)}}}function X(g,v,b){c.push(g),c.push(v),c.push(b)}function me(g,v,b){Y(g),Y(v),Y(b);const A=s.length/3,x=P.generateTopUV(i,s,A-3,A-2,A-1);K(x[0]),K(x[1]),K(x[2])}function vt(g,v,b,A){Y(g),Y(v),Y(A),Y(v),Y(b),Y(A);const x=s.length/3,S=P.generateSideWallUV(i,s,x-6,x-3,x-2,x-1);K(S[0]),K(S[1]),K(S[3]),K(S[1]),K(S[2]),K(S[3])}function Y(g){s.push(c[g*3+0]),s.push(c[g*3+1]),s.push(c[g*3+2])}function K(g){n.push(g.x),n.push(g.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return ti(t,i,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const a=t[e.shapes[n]];i.push(a)}const s=e.options.extrudePath;return console.log(s.type),s!==void 0&&(e.options.extrudePath=new y[`${s.type}Curve`]().fromJSON(s)),new Ie(i,e.options)}}const ei={generateTopUV:function(o,e,t,i,s){const n=e[t*3],r=e[t*3+1],a=e[i*3],c=e[i*3+1],u=e[s*3],l=e[s*3+1];return[new w.Vector2(n,r),new w.Vector2(a,c),new w.Vector2(u,l)]},generateSideWallUV:function(o,e,t,i,s,n){const r=e[t*3],a=e[t*3+1],c=e[t*3+2],u=e[i*3],l=e[i*3+1],h=e[i*3+2],p=e[s*3],f=e[s*3+1],d=e[s*3+2],m=e[n*3],M=e[n*3+1],B=e[n*3+2];return Math.abs(a-l)<Math.abs(r-u)?[new w.Vector2(r,1-c),new w.Vector2(u,1-h),new w.Vector2(p,1-d),new w.Vector2(m,1-B)]:[new w.Vector2(a,1-c),new w.Vector2(l,1-h),new w.Vector2(f,1-d),new w.Vector2(M,1-B)]}};function ti(o,e,t){if(t.shapes=[],Array.isArray(o))for(let i=0,s=o.length;i<s;i++){const n=o[i];t.shapes.push(n.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 at=o=>{const{split:e,depth:t,points:i,box3:s,hasTop:n,hasBottom:r,hasSide:a,sideRepeat:c}=o,u=new Ie(new y.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:Le.getUVGenerator({split:e,box3:s,sideRepeat:c}),hasTop:n,hasBottom:r,hasSide:a});return Le.claerUVGenerator(),u};class ii extends ie.BaseObject{constructor(e){super(),this.options=I({depth:1},e)}create(){return ee(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:n,geometryArr:r,material:a,box3:c,split:u,hasTop:l,hasBottom:h,hasSide:p}=this.options,f=Array.isArray(s)?s:[s],d=Array.isArray(c)?c:[c],m=a;let M=n;m||console.log("material is null"),!M&&e?M=at({points:e,depth:f[0],box3:d[0],split:u,hasTop:l,hasBottom:h,hasSide:p}):!M&&t?M=te(t.map((B,P)=>{var V,T;return at({points:B,depth:(V=f[P])!=null?V:f[0],box3:(T=d[P])!=null?T:d[0],split:u,hasTop:l,hasBottom:h,hasSide:p})}),i!=null?i:0):!M&&r&&r.length>1?M=te(r,i!=null?i:0):!M&&r&&r.length===1&&([M]=r),this.createMesh(M,m)})}addGeometries(e){const t=this.object3d,i=te([t.geometry,...e]);t.geometry=i}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const si=o=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:n,maxAnisotropy:r}=o;return new Promise(a=>{const c=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const u=n,l=document.createElement("canvas"),h=l.getContext("2d");l.height=c.height/(1-u),l.width=c.width,u&&e&&(h.fillStyle=e,h.fillRect(0,0,c.width,l.height*u)),i&&c instanceof HTMLImageElement?h.drawImage(c,0,l.height*u,c.width,c.height):t&&(h.fillStyle=t,h.fillRect(0,l.height*u,c.width,c.height)),s&&l.toBlob(f=>{console.log(URL.createObjectURL(f))});const p=new y.CanvasTexture(l);a(p)},i?c.src=i:c instanceof HTMLImageElement||c.onload()})};exports.Group=_t.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>je.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>lt.LineMaterial});exports.ConicPolygon=Qt;exports.ExtrudePolygon=ii;exports.Image=ht;exports.Light=Ot;exports.Line=$t;exports.Line2=Nt;exports.MeshLineGeometry=ft;exports.MeshLineMaterial=pt;exports.MeshLineRaycast=Ht;exports.Node=Gt;exports.Pie=zt;exports.Text=It;exports.Video=Et;exports.getConicPolygonGeometry=mt;exports.getConicPolygonGeometryMetas=dt;exports.getSplitTexture=si;
146
+ `;class ht extends x.ShaderMaterial{constructor(e){super({uniforms:Ae(D({},x.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new x.Color(16777215)},opacity:{value:1},resolution:{value:new x.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new x.Vector2(1,1)},offset:{value:new x.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new x.Vector2(0,0)},lightColor:{value:new x.Color(16777215)}}),vertexShader:Ot,fragmentShader:Dt}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(t){this.uniforms.useDash.value=t}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(t){this.uniforms.useDepth.value=t}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(t){this.uniforms.repeat.value.copy(t)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(t){this.uniforms.lineLightAnimation.value=t}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(t){this.uniforms.size.value=t}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(t){this.uniforms.speed.value=t}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(t){this.uniforms.lightWidth.value=t}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(t){this.uniforms.uCenter.value=t}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(t){t&&(this.uniforms.lightColor.value=t)}}}),this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray=e.dashArray,this.dashOffset=e.dashOffset,this.dashRatio=e.dashRatio,this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}function Rt(n,e){const t=new x.Matrix4,i=new x.Ray,s=new x.Sphere,r=new x.Vector3,o=this.geometry;if(s.copy(o.boundingSphere),s.applyMatrix4(this.matrixWorld),!n.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(t);const a=new x.Vector3,u=new x.Vector3,f=new x.Vector3,l=this instanceof x.LineSegments?2:1,c=o.index,p=o.attributes;if(c!==null){const h=c.array,d=p.position.array,w=p.width.array;for(let M=0,T=h.length-1;M<T;M+=l){const _=h[M],b=h[M+1];a.fromArray(d,_*3),u.fromArray(d,b*3);const L=w[Math.floor(M/3)]!=null?w[Math.floor(M/3)]:1,E=n.params.Line.threshold+this.material.lineWidth*L/2,C=E*E;if(i.distanceSqToSegment(a,u,r,f)>C)continue;r.applyMatrix4(this.matrixWorld);const W=n.ray.origin.distanceTo(r);W<n.near||W>n.far||(e.push({distance:W,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:void 0,object:this}),M=T)}}}const Ve=n=>{const{setPointWidth:e,nodes:t}=n,i=new ct;return i.setPoints(t,e),i};class Nt extends se.BaseObject{constructor(e={}){super(),this.options=D({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ce(this,null,function*(){const{nodes:e,nodesArr:t,geometry:i,geometryArr:s,material:r,useGroups:o,setPointWidth:a,lineWidthArr:u,materialParameters:f}=this.options;let l=r,c=i;!l&&f&&(l=this.getMaterial(f)),!c&&e?c=Ve({nodes:e,setPointWidth:a}):!c&&t?c=ee(t.map((p,h)=>{let d=a;return!d&&u&&(d=()=>{var w;return(w=u[h])!=null?w:u[0]}),Ve({nodes:p,setPointWidth:d})}),o!=null?o:0):!c&&s&&s.length>1?c=ee(s,o!=null?o:0):!c&&s&&s.length===1&&([c]=s),this.createMesh(c,l)})}setGeometry(e,t){const i=Ve({nodes:e,setPointWidth:t}),s=this.object3d,r=s.geometry;s.geometry=i,r.dispose()}getMaterial(e){const{width:t,height:i}=this.pencil.getSize();return new ht(D({color:new x.Color("#ffffff"),resolution:new x.Vector2(t,i)},e))}addGeometries(e){const t=this.object3d,i=ee([t.geometry,...e]);t.geometry=i}resize(e,t){var i,s;(s=(i=this.material)==null?void 0:i.uniforms)==null||s.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:i}=this.pencil.getSize();this.resize(t,i)}animate({duration:e=1e3,delay:t=0,repeat:i=0,lineLoop:s,onRepeat:r,onUpdate:o,onComplete:a}={}){const{offset:u,offsetLoop:f}=this.material.uniforms;if(this.material.userData.tween)return;const l=s!=null?s:!0;u.value.x=1,f.value=0;let c=0;const p=new oe.Tween(u.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:h})=>{l&&h<=0&&f.value===0&&(f.value=1),o&&o(h)}).onRepeat(()=>{c+=1,r&&r(c)}).onComplete(()=>{a&&a()}).start();this.material.userData.tween=p}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),oe.remove(this.material.userData.tween)),super.dispose()}}function qt(n,e){return n.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const o=he.geoDistance(r,s)*180/Math.PI;if(o>e){const a=he.geoInterpolate(s,r),u=1/Math.ceil(o/e);let f=u;for(;f<1;)i.push(a(f)),f+=u}}i.push(s=r)}),i})}function Ft(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Je(360/n,2)/Math.PI),o=(1+Math.sqrt(5))/2,a=h=>h/o*360%360-180,u=h=>Math.acos(2*h/r-1)/Math.PI*180-90,f=h=>r*(Math.cos((h+90)*Math.PI/180)+1)/2,l=[s!==void 0?Math.ceil(f(s)):0,i!==void 0?Math.floor(f(i)):r-1],c=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,p=[];for(let h=l[0];h<=l[1];h++){const d=a(h);c(d)&&p.push([d,u(h)])}return p}function Ie(n,e,t=!1){return t?he.geoContains(e,n):Vt(n,e)}function kt(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[r,o]]=he.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(o-s))<e)return[];const a=i>r||o>=89||s<=-89;return Ft(e,{minLng:i,maxLng:r,minLat:s,maxLat:o}).filter(u=>Ie(u,t,a))}function Ht(n,{resolution:e=1/0,bbox:t}={}){const i=qt(n,e),s=re.merge(i),r=kt(n,e),o=[...s,...r],a={type:"Polygon",coordinates:n},[[u,f],[l,c]]=he.geoBounds(a),p=u>l||c>=89||f<=-89;let h=[];if(p){const _=Lt.geoVoronoi(o).triangles(),b=new Map(o.map(([L,E],C)=>[`${L}-${E}`,C]));_.features.forEach(L=>{const E=L.geometry.coordinates[0].slice(0,3).reverse(),C=[];if(E.forEach(([B,W])=>{const q=`${B}-${W}`;b.has(q)&&C.push(b.get(q))}),C.length===3){if(C.some(B=>B<s.length)){const B=L.properties.circumcenter;if(!Ie(B,a,p))return}h.push(...C)}})}else if(r.length){const _=Tt.from(o);for(let b=0,L=_.triangles.length;b<L;b+=3){const E=[2,1,0].map(B=>_.triangles[b+B]),C=E.map(B=>o[B]);if(E.some(B=>B<s.length)){const B=[0,1].map(W=>re.mean(C,q=>q[W]));if(!Ie(B,a,p))continue}h.push(...E)}}else{const{vertices:_,holes:b=[]}=Le.flatten(i);h=Le(_,b,2)}const d=Xe.scaleLinear(t?[t[0],t[2]]:re.extent(o,_=>_[0]),[0,1]),w=Xe.scaleLinear(t?[t[1],t[3]]:re.extent(o,_=>_[1]),[0,1]),M=o.map(([_,b])=>[d(_),w(b)]);return{contour:i,triangles:{points:o,indices:h,uvs:M}}}const nt=new x.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function be(n,e,t,i){const s=n.map(r=>r.map(([o,a])=>{if(i){const[u,f]=i([o,a]);return[u,-f,e]}return t?Be.polar2Cartesian(o,a,e):[o,a,e]}));return Le.flatten(s)}function $t(n,e,t,i,s){const{vertices:r,holes:o}=be(n,e,i,s),{vertices:a}=be(n,t,i,s),u=re.merge([a,r]),f=Math.round(a.length/3),l=new Set(o);let c=0;const p=[];for(let d=0;d<f;d++){let w=d+1;if(w===f)w=c;else if(l.has(w)){const M=w;w=c,c=M}p.push(d,d+f,w+f),p.push(w+f,w,d)}const h=[];for(let d=1;d>=0;d--)for(let w=0;w<f;w+=1)h.push(w/(f-1),d);return{indices:p,vertices:u,uvs:h,topVerts:a}}function rt(n,e,t,i,s,r){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:be([n.points],e,s,r).vertices,uvs:t}}const ft=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:o=!1,hasTop:a=!1,projection:u,bbox:f})=>{n.forEach(T=>{Pt(T)||T.reverse()});const{contour:l,triangles:c}=Ht(n,{resolution:i,bbox:f});let p={},h;r&&(p=$t(l,e!=null?e:t,t!=null?t:e,s,u),h=p.topVerts);let d=[];(o||a)&&(d=re.merge(c.uvs));let w={};o&&(w=rt(c,e,d,!1,s,u));let M={};return a&&(M=rt(c,t,d,!0,s,u)),{contour:l,triangles:c,sideTorso:p,bottomCap:w,topCap:M,topVerts:h}};class pt extends x.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=D({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:r,hasBottom:o,hasSide:a,cartesian:u,userDataRsoOffset:f,projection:l}=this.parameters,{contour:c,sideTorso:p,topVerts:h,bottomCap:d,topCap:w}=ft(D({},this.parameters));let M=[],T=[],_=[],b=0;const L=E=>{const C=Math.round(M.length/3),B=_.length;M=M.concat(E.vertices),T=T.concat(E.uvs),_=_.concat(C?E.indices.map(W=>W+C):E.indices),this.addGroup(B,_.length-B,b++)};s&&r&&L(w),a&&(L(p),this.userData.topVerts=f?be(c,i+f,u,l).vertices:h),o&&L(d),s&&!r&&L(w),this.setIndex(_),this[nt]("position",new x.Float32BufferAttribute(M,3)),this[nt]("uv",new x.Float32BufferAttribute(T,2)),this.computeVertexNormals()}}const ot=n=>{const a=n,{coordinate:e,startHeight:t,height:i}=a,s=Me(a,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(r=t+i),new pt([e],Ae(D({},s),{startHeight:t,endHeight:r}))};class Zt extends se.BaseObject{constructor(e){super(),this.options=D({},e)}create(){const u=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=u,o=Me(u,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&i)a=ot(D({coordinate:i},o));else if(!a&&t){const f=t.map(l=>ot(D({coordinate:l},o)));a=ee(f,r!=null?r:0)}this.createMesh(a,s)}}class Ee extends A.BufferGeometry{constructor(e=new A.Shape([new A.Vector2(.5,.5),new A.Vector2(-.5,.5),new A.Vector2(-.5,-.5),new A.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,s=[],r=[];for(let a=0,u=e.length;a<u;a++){const f=e[a];o(f)}this.setAttribute("position",new A.Float32BufferAttribute(s,3)),this.setAttribute("uv",new A.Float32BufferAttribute(r,2)),this.computeVertexNormals();function o(a){var We,Oe,De;const u=[],f=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,c=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,h=t.bevelThickness!==void 0?t.bevelThickness:.2,d=t.bevelSize!==void 0?t.bevelSize:h-.1,w=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const T=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Jt,b=(We=t.hasTop)!=null?We:!0,L=(Oe=t.hasBottom)!=null?Oe:!0,E=(De=t.hasSide)!=null?De:!0;let C,B=!1,W,q,ae,Z;T&&(C=T.getSpacedPoints(l),B=!0,p=!1,W=T.computeFrenetFrames(l,!1),q=new A.Vector3,ae=new A.Vector3,Z=new A.Vector3),p||(M=0,h=0,d=0,w=0);const je=a.extractPoints(f);let N=je.shape;const R=je.holes;if(!A.ShapeUtils.isClockWise(N)){N=N.reverse();for(let m=0,g=R.length;m<g;m++){const y=R[m];A.ShapeUtils.isClockWise(y)&&(R[m]=y.reverse())}}const le=A.ShapeUtils.triangulateShape(N,R),F=N;for(let m=0,g=R.length;m<g;m++){const y=R[m];N=N.concat(y)}function ne(m,g,y){return g||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(g,y)}const J=N.length,fe=le.length;function Ge(m,g,y){let S,v,P;const V=m.x-g.x,I=m.y-g.y,O=y.x-m.x,j=y.y-m.y,ue=V*V+I*I,we=V*j-I*O;if(Math.abs(we)>Number.EPSILON){const Q=Math.sqrt(ue),Re=Math.sqrt(O*O+j*j),Ne=g.x-I/Q,qe=g.y+V/Q,yt=y.x-j/Re,vt=y.y+O/Re,Fe=((yt-Ne)*j-(vt-qe)*O)/(V*j-I*O);S=Ne+V*Fe-m.x,v=qe+I*Fe-m.y;const ke=S*S+v*v;if(ke<=2)return new A.Vector2(S,v);P=Math.sqrt(ke/2)}else{let Q=!1;V>Number.EPSILON?O>Number.EPSILON&&(Q=!0):V<-Number.EPSILON?O<-Number.EPSILON&&(Q=!0):Math.sign(I)===Math.sign(j)&&(Q=!0),Q?(S=-I,v=V,P=Math.sqrt(ue)):(S=V,v=I,P=Math.sqrt(ue/2))}return new A.Vector2(S/P,v/P)}const pe=[];for(let m=0,g=F.length,y=g-1,S=m+1;m<g;m++,y++,S++)y===g&&(y=0),S===g&&(S=0),pe[m]=Ge(F[m],F[y],F[S]);const xe=[];let te,de=pe.concat();for(let m=0,g=R.length;m<g;m++){const y=R[m];te=[];for(let S=0,v=y.length,P=v-1,V=S+1;S<v;S++,P++,V++)P===v&&(P=0),V===v&&(V=0),te[S]=Ge(y[S],y[P],y[V]);xe.push(te),de=de.concat(te)}for(let m=0;m<M;m++){const g=m/M,y=h*Math.cos(g*Math.PI/2),S=d*Math.sin(g*Math.PI/2)+w;for(let v=0,P=F.length;v<P;v++){const V=ne(F[v],pe[v],S);X(V.x,V.y,-y)}for(let v=0,P=R.length;v<P;v++){const V=R[v];te=xe[v];for(let I=0,O=V.length;I<O;I++){const j=ne(V[I],te[I],S);X(j.x,j.y,-y)}}}const ze=d+w;for(let m=0;m<J;m++){const g=p?ne(N[m],de[m],ze):N[m];B?(ae.copy(W.normals[0]).multiplyScalar(g.x),q.copy(W.binormals[0]).multiplyScalar(g.y),Z.copy(C[0]).add(ae).add(q),X(Z.x,Z.y,Z.z)):X(g.x,g.y,0)}for(let m=1;m<=l;m++)for(let g=0;g<J;g++){const y=p?ne(N[g],de[g],ze):N[g];B?(ae.copy(W.normals[m]).multiplyScalar(y.x),q.copy(W.binormals[m]).multiplyScalar(y.y),Z.copy(C[m]).add(ae).add(q),X(Z.x,Z.y,Z.z)):X(y.x,y.y,c/l*m)}for(let m=M-1;m>=0;m--){const g=m/M,y=h*Math.cos(g*Math.PI/2),S=d*Math.sin(g*Math.PI/2)+w;for(let v=0,P=F.length;v<P;v++){const V=ne(F[v],pe[v],S);X(V.x,V.y,c+y)}for(let v=0,P=R.length;v<P;v++){const V=R[v];te=xe[v];for(let I=0,O=V.length;I<O;I++){const j=ne(V[I],te[I],S);B?X(j.x,j.y+C[l-1].y,C[l-1].x+y):X(j.x,j.y,c+y)}}}dt(),E&&mt();function dt(){const m=s.length/3;if(p){let g=0,y=J*g;if(L)for(let S=0;S<fe;S++){const v=le[S];me(v[2]+y,v[1]+y,v[0]+y)}if(g=l+M*2,y=J*g,b)for(let S=0;S<fe;S++){const v=le[S];me(v[0]+y,v[1]+y,v[2]+y)}}else{if(L)for(let g=0;g<fe;g++){const y=le[g];me(y[2],y[1],y[0])}if(b)for(let g=0;g<fe;g++){const y=le[g];me(y[0]+J*l,y[1]+J*l,y[2]+J*l)}}i.addGroup(m,s.length/3-m,0)}function mt(){const m=s.length/3;let g=0;Ue(F,g),g+=F.length;for(let y=0,S=R.length;y<S;y++){const v=R[y];Ue(v,g),g+=v.length}i.addGroup(m,s.length/3-m,1)}function Ue(m,g){let y=m.length;for(;--y>=0;){const S=y;let v=y-1;v<0&&(v=m.length-1);for(let P=0,V=l+M*2;P<V;P++){const I=J*P,O=J*(P+1),j=g+S+I,ue=g+v+I,we=g+v+O,Q=g+S+O;gt(j,ue,we,Q)}}}function X(m,g,y){u.push(m),u.push(g),u.push(y)}function me(m,g,y){Y(m),Y(g),Y(y);const S=s.length/3,v=_.generateTopUV(i,s,S-3,S-2,S-1);K(v[0]),K(v[1]),K(v[2])}function gt(m,g,y,S){Y(m),Y(g),Y(S),Y(g),Y(y),Y(S);const v=s.length/3,P=_.generateSideWallUV(i,s,v-6,v-3,v-2,v-1);K(P[0]),K(P[1]),K(P[3]),K(P[1]),K(P[2]),K(P[3])}function Y(m){s.push(u[m*3+0]),s.push(u[m*3+1]),s.push(u[m*3+2])}function K(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,i=this.parameters.options;return Xt(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];i.push(a)}const s=e.options.extrudePath;return console.log(s.type),s!==void 0&&(e.options.extrudePath=new x[`${s.type}Curve`]().fromJSON(s)),new Ee(i,e.options)}}const Jt={generateTopUV:function(n,e,t,i,s){const r=e[t*3],o=e[t*3+1],a=e[i*3],u=e[i*3+1],f=e[s*3],l=e[s*3+1];return[new A.Vector2(r,o),new A.Vector2(a,u),new A.Vector2(f,l)]},generateSideWallUV:function(n,e,t,i,s,r){const o=e[t*3],a=e[t*3+1],u=e[t*3+2],f=e[i*3],l=e[i*3+1],c=e[i*3+2],p=e[s*3],h=e[s*3+1],d=e[s*3+2],w=e[r*3],M=e[r*3+1],T=e[r*3+2];return Math.abs(a-l)<Math.abs(o-f)?[new A.Vector2(o,1-u),new A.Vector2(f,1-c),new A.Vector2(p,1-d),new A.Vector2(w,1-T)]:[new A.Vector2(a,1-u),new A.Vector2(l,1-c),new A.Vector2(h,1-d),new A.Vector2(M,1-T)]}};function Xt(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,s=n.length;i<s;i++){const r=n[i];t.shapes.push(r.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}const at=n=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:o,hasSide:a,sideRepeat:u}=n,f=new Ee(new x.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:Be.getUVGenerator({split:e,box3:s,sideRepeat:u}),hasTop:r,hasBottom:o,hasSide:a});return Be.claerUVGenerator(),f};class Yt extends se.BaseObject{constructor(e){super(),this.options=D({depth:1},e)}create(){return ce(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:o,material:a,box3:u,split:f,hasTop:l,hasBottom:c,hasSide:p}=this.options,h=Array.isArray(s)?s:[s],d=Array.isArray(u)?u:[u],w=a;let M=r;w||console.log("material is null"),!M&&e?M=at({points:e,depth:h[0],box3:d[0],split:f,hasTop:l,hasBottom:c,hasSide:p}):!M&&t?M=ee(t.map((T,_)=>{var b,L;return at({points:T,depth:(b=h[_])!=null?b:h[0],box3:(L=d[_])!=null?L:d[0],split:f,hasTop:l,hasBottom:c,hasSide:p})}),i!=null?i:0):!M&&o&&o.length>1?M=ee(o,i!=null?i:0):!M&&o&&o.length===1&&([M]=o),this.createMesh(M,w)})}addGeometries(e){const t=this.object3d,i=ee([t.geometry,...e]);t.geometry=i}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Kt=n=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:o}=n;return new Promise(a=>{const u=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};u.onload=()=>{const f=r,l=document.createElement("canvas"),c=l.getContext("2d");l.height=u.height/(1-f),l.width=u.width,f&&e&&(c.fillStyle=e,c.fillRect(0,0,u.width,l.height*f)),i&&u instanceof HTMLImageElement?c.drawImage(u,0,l.height*f,u.width,u.height):t&&(c.fillStyle=t,c.fillRect(0,l.height*f,u.width,u.height)),s&&l.toBlob(h=>{console.log(URL.createObjectURL(h))});const p=new x.CanvasTexture(l);a(p)},i?u.src=i:u instanceof HTMLImageElement||u.onload()})};exports.Group=At.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ce.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>lt.LineMaterial});exports.ConicPolygon=Zt;exports.ExtrudePolygon=Yt;exports.Light=Ct;exports.Line=Nt;exports.Line2=Ut;exports.MeshLineGeometry=ct;exports.MeshLineMaterial=ht;exports.MeshLineRaycast=Rt;exports.Node=Bt;exports.Pie=It;exports.getConicPolygonGeometry=pt;exports.getConicPolygonGeometryMetas=ft;exports.getSplitTexture=Kt;