gl-draw 0.15.20 → 0.15.21

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.
@@ -29,26 +29,26 @@ var se = (h, e, t) => new Promise((s, i) => {
29
29
  import * as Ce from "@tweenjs/tween.js";
30
30
  import Ut from "deepmerge";
31
31
  import zt from "stats-gl";
32
- import { Vector3 as j, PerspectiveCamera as kt, Matrix4 as W, UniformsUtils as Ft, RawShaderMaterial as Nt, ShaderMaterial as It, MeshBasicMaterial as jt, PointsMaterial as nt, SpriteMaterial as at, Layers as Ht, Vector2 as B, WebGLRenderTarget as Bt, HalfFloatType as Vt, MathUtils as Yt, Vector4 as Zt, Quaternion as lt, Spherical as Wt, Box3 as ht, Sphere as Kt, Raycaster as ct, AxesHelper as De, CameraHelper as $t, PointLightHelper as Gt, DirectionalLightHelper as Xt, SpotLightHelper as qt, HemisphereLightHelper as Qt, Box3Helper as Ue, Scene as dt, Group as ze, Camera as Jt, Loader as mt, Texture as ue, VideoTexture as pt, FileLoader as Ae, LoadingManager as es, DataTexture as ts, WebGLRenderer as ss, REVISION as is, Object3D as rs } from "three";
32
+ import { Vector3 as j, PerspectiveCamera as kt, Matrix4 as W, ShaderMaterial as Ft, UniformsUtils as Nt, RawShaderMaterial as It, MeshBasicMaterial as jt, PointsMaterial as nt, SpriteMaterial as at, Layers as Ht, Vector2 as B, WebGLRenderTarget as Bt, HalfFloatType as Vt, MathUtils as Yt, Vector4 as Zt, Quaternion as lt, Spherical as Wt, Box3 as ht, Sphere as Kt, Raycaster as ct, AxesHelper as De, CameraHelper as $t, PointLightHelper as Gt, DirectionalLightHelper as Xt, SpotLightHelper as qt, HemisphereLightHelper as Qt, Box3Helper as Ue, Scene as dt, Group as ze, Camera as Jt, Loader as mt, Texture as ue, VideoTexture as pt, FileLoader as Ae, LoadingManager as es, DataTexture as ts, WebGLRenderer as ss, REVISION as is, Object3D as rs } from "three";
33
33
  import { Timer as os } from "three/examples/jsm/misc/Timer";
34
- import { M as ft, B as Oe, a as ns, R as Pe, I as he } from "./index.module2.js";
34
+ import { M as ft, B as Oe, a as ns, R as Pe, I as he } from "./WebGPULineSegments2.module.js";
35
35
  import { EffectComposer as ke } from "three/examples/jsm/postprocessing/EffectComposer";
36
36
  import { RenderPass as as } from "three/examples/jsm/postprocessing/RenderPass";
37
37
  import { SSAOPass as ls } from "three/examples/jsm/postprocessing/SSAOPass";
38
- import { FullScreenQuad as Fe } from "three/examples/jsm/postprocessing/Pass";
39
- import { OutputPass as hs } from "three/examples/jsm/postprocessing/OutputPass";
40
- import { ShaderPass as cs } from "three/examples/jsm/postprocessing/ShaderPass";
41
- import { UnrealBloomPass as ds } from "three/examples/jsm/postprocessing/UnrealBloomPass";
38
+ import { UnrealBloomPass as hs } from "three/examples/jsm/postprocessing/UnrealBloomPass";
39
+ import "three/examples/jsm/lines/LineMaterial";
40
+ import "three/examples/jsm/lines/LineSegmentsGeometry";
42
41
  import "three/examples/jsm/renderers/CSS2DRenderer";
43
42
  import "three/examples/jsm/renderers/CSS3DRenderer";
44
43
  import "d3-geo";
45
44
  import "d3-geo-projection";
46
- import "three/examples/jsm/lights/RectAreaLightUniformsLib";
47
45
  import "three/examples/jsm/utils/BufferGeometryUtils";
48
- import "three/examples/jsm/lines/LineSegments2";
49
- import "three/examples/jsm/lines/LineSegmentsGeometry";
50
- import "three/examples/jsm/lines/LineMaterial";
51
46
  import "three-bvh-csg";
47
+ import "three/examples/jsm/lights/RectAreaLightUniformsLib";
48
+ import "three/examples/jsm/lines/LineSegments2";
49
+ import { ShaderPass as cs } from "three/examples/jsm/postprocessing/ShaderPass";
50
+ import { FullScreenQuad as Fe } from "three/examples/jsm/postprocessing/Pass";
51
+ import { OutputPass as ds } from "three/examples/jsm/postprocessing/OutputPass";
52
52
  import { RectAreaLightHelper as ms } from "three/examples/jsm/helpers/RectAreaLightHelper";
53
53
  import { ViewHelper as ps } from "three/examples/jsm/helpers/ViewHelper";
54
54
  import { generateUUID as Ne, makePromiseCreator as fs } from "esus-lite";
@@ -2078,7 +2078,43 @@ class Ms extends ee {
2078
2078
  }
2079
2079
  }
2080
2080
  }
2081
- const Rs = {
2081
+ const Rs = (h) => {
2082
+ const e = new cs(
2083
+ new Ft({
2084
+ uniforms: {
2085
+ baseTexture: { value: null },
2086
+ bloomTexture: { value: h.renderTarget2.texture },
2087
+ bloomAlphaType: { value: 0 }
2088
+ },
2089
+ vertexShader: `
2090
+ varying vec2 vUv;
2091
+ void main() {
2092
+ vUv = uv;
2093
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
2094
+ }
2095
+ `,
2096
+ fragmentShader: `
2097
+ uniform sampler2D baseTexture;
2098
+ uniform sampler2D bloomTexture;
2099
+ uniform float bloomAlphaType;
2100
+ varying vec2 vUv;
2101
+ void main() {
2102
+ vec4 base_color = texture2D(baseTexture, vUv);
2103
+ vec4 bloom_color = texture2D(bloomTexture, vUv);
2104
+ if (bloomAlphaType == 0.0){
2105
+ float lum = 0.21 * bloom_color.r + 0.71 * bloom_color.g + 0.07 * bloom_color.b;
2106
+ gl_FragColor = vec4(base_color.rgb + bloom_color.rgb, max(base_color.a, lum));
2107
+ }else{
2108
+ gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
2109
+ }
2110
+ }
2111
+ `,
2112
+ defines: {}
2113
+ }),
2114
+ "baseTexture"
2115
+ );
2116
+ return e.needsSwap = !0, e;
2117
+ }, Ds = {
2082
2118
  name: "OutputShader",
2083
2119
  uniforms: {
2084
2120
  tDiffuse: { value: null },
@@ -2172,11 +2208,11 @@ const Rs = {
2172
2208
  }`
2173
2209
  )
2174
2210
  };
2175
- class Ds extends hs {
2211
+ class Us extends ds {
2176
2212
  constructor() {
2177
2213
  super();
2178
- const e = Rs;
2179
- this.uniforms = Ft.clone(e.uniforms), this.material = new Nt({
2214
+ const e = Ds;
2215
+ this.uniforms = Nt.clone(e.uniforms), this.material = new It({
2180
2216
  name: e.name,
2181
2217
  uniforms: this.uniforms,
2182
2218
  vertexShader: e.vertexShader,
@@ -2184,43 +2220,7 @@ class Ds extends hs {
2184
2220
  }), this.fsQuad ? this.fsQuad = new Fe(this.material) : this._fsQuad && (this._fsQuad = new Fe(this.material));
2185
2221
  }
2186
2222
  }
2187
- const Us = (h) => {
2188
- const e = new cs(
2189
- new It({
2190
- uniforms: {
2191
- baseTexture: { value: null },
2192
- bloomTexture: { value: h.renderTarget2.texture },
2193
- bloomAlphaType: { value: 0 }
2194
- },
2195
- vertexShader: `
2196
- varying vec2 vUv;
2197
- void main() {
2198
- vUv = uv;
2199
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
2200
- }
2201
- `,
2202
- fragmentShader: `
2203
- uniform sampler2D baseTexture;
2204
- uniform sampler2D bloomTexture;
2205
- uniform float bloomAlphaType;
2206
- varying vec2 vUv;
2207
- void main() {
2208
- vec4 base_color = texture2D(baseTexture, vUv);
2209
- vec4 bloom_color = texture2D(bloomTexture, vUv);
2210
- if (bloomAlphaType == 0.0){
2211
- float lum = 0.21 * bloom_color.r + 0.71 * bloom_color.g + 0.07 * bloom_color.b;
2212
- gl_FragColor = vec4(base_color.rgb + bloom_color.rgb, max(base_color.a, lum));
2213
- }else{
2214
- gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
2215
- }
2216
- }
2217
- `,
2218
- defines: {}
2219
- }),
2220
- "baseTexture"
2221
- );
2222
- return e.needsSwap = !0, e;
2223
- }, zs = new jt({ color: "black" }), ks = new nt({
2223
+ const zs = new jt({ color: "black" }), ks = new nt({
2224
2224
  color: "black",
2225
2225
  sizeAttenuation: !1
2226
2226
  }), Fs = new nt({
@@ -2234,7 +2234,7 @@ const Us = (h) => {
2234
2234
  sizeAttenuation: !1
2235
2235
  }), js = new ft({
2236
2236
  color: "black",
2237
- sizeAttenuation: 0,
2237
+ sizeAttenuation: !1,
2238
2238
  lineWidth: 0
2239
2239
  }), Hs = {
2240
2240
  kernelRadius: 8,
@@ -2285,7 +2285,7 @@ class Ys {
2285
2285
  this.renderPass.scene = e, this.ssaoPass && (this.ssaoPass.scene = e), this.scene = e;
2286
2286
  }
2287
2287
  addOutputPass() {
2288
- const { premultiplieAlpha: e } = this.options.composerParams, t = new Ds();
2288
+ const { premultiplieAlpha: e } = this.options.composerParams, t = new Us();
2289
2289
  this.outputPass = t, this.setPremultiplieAlpha(e), this.finalComposer.addPass(t);
2290
2290
  }
2291
2291
  setPremultiplieAlpha(e) {
@@ -2296,7 +2296,7 @@ class Ys {
2296
2296
  a.kernelRadius = e.kernelRadius, a.minDistance = e.minDistance, a.maxDistance = e.maxDistance, this.ssaoPass = a, this.finalComposer.addPass(a);
2297
2297
  }
2298
2298
  addBloomPass(e) {
2299
- const { renderer: t } = this, { threshold: s, strength: i, radius: r, bloomAlphaType: o } = e, n = new ds(
2299
+ const { renderer: t } = this, { threshold: s, strength: i, radius: r, bloomAlphaType: o } = e, n = new hs(
2300
2300
  new B(window.innerWidth, window.innerHeight),
2301
2301
  i,
2302
2302
  r,
@@ -2305,7 +2305,7 @@ class Ys {
2305
2305
  this.bloomPass = n;
2306
2306
  const a = new ke(t);
2307
2307
  a.renderToScreen = !1, a.addPass(this.renderPass), a.addPass(n), this.bloomComposer = a;
2308
- const c = Us(a);
2308
+ const c = Rs(a);
2309
2309
  c.uniforms.bloomAlphaType.value = o, this.bloomComposer = a, this.finalComposer.addPass(c), this.mixPass = c, this.bloomLayer.set(Oe);
2310
2310
  }
2311
2311
  setBloomSelection(e, t) {
@@ -3475,6 +3475,7 @@ class ni {
3475
3475
  }
3476
3476
  this.rmBaseObjectMap(e), t[r] = o, this.addBaseObjectMap(e);
3477
3477
  }
3478
+ e.handleMaterialChange(o);
3478
3479
  },
3479
3480
  enumerable: !0,
3480
3481
  configurable: !0
@@ -3742,7 +3743,7 @@ const _e = class _e {
3742
3743
  return this.rendererController.renderer;
3743
3744
  }
3744
3745
  get maxAnisotropy() {
3745
- return this.options.WebGPUTHREE ? 0 : this.renderer.capabilities.getMaxAnisotropy();
3746
+ return this.options.WebGPUTHREE ? 2 : this.renderer.capabilities.getMaxAnisotropy();
3746
3747
  }
3747
3748
  get controls() {
3748
3749
  return this.controlsController.cameraControls;
@@ -3808,7 +3809,8 @@ const _e = class _e {
3808
3809
  } = this.options, { width: a, height: c } = this.getSize(), u = t ? new fi({
3809
3810
  width: a,
3810
3811
  height: c,
3811
- renderer: t.WebGPURenderer,
3812
+ //@ts-ignore
3813
+ renderer: this.options.WebGPURenderer,
3812
3814
  rendererParams: pi
3813
3815
  }) : new hi({
3814
3816
  width: a,
@@ -3816,7 +3818,9 @@ const _e = class _e {
3816
3818
  rendererParams: te(U({}, r), {
3817
3819
  antialias: !1
3818
3820
  })
3819
- }), m = new Ms({
3821
+ });
3822
+ this.rendererController = u;
3823
+ const m = new Ms({
3820
3824
  width: a,
3821
3825
  height: c
3822
3826
  }), v = new di({}), p = new Zs({
@@ -3825,14 +3829,14 @@ const _e = class _e {
3825
3829
  }
3826
3830
  }), f = new oi({
3827
3831
  loaderParams: U({
3828
- anisotropy: u.renderer.capabilities.getMaxAnisotropy()
3832
+ anisotropy: this.maxAnisotropy
3829
3833
  }, n)
3830
3834
  }), g = new ai({
3831
3835
  pencil: this
3832
3836
  }), y = new ei({
3833
3837
  pencil: this
3834
3838
  });
3835
- this.sceneController = v, this.cameraController = m, this.controlsController = p, this.rendererController = u, this.loaderController = f, this.mListController = g, this.leadController = y;
3839
+ this.sceneController = v, this.cameraController = m, this.controlsController = p, this.loaderController = f, this.mListController = g, this.leadController = y;
3836
3840
  const l = this.addPage({
3837
3841
  sceneOptions: this.options.scene,
3838
3842
  cameraOptions: this.options.camera
@@ -1,4 +1,4 @@
1
- import {BufferGeometry} from 'three';
1
+ import { BufferGeometry } from 'three';
2
2
 
3
3
  type PolygonCoords = number[][][];
4
4
 
@@ -20,15 +20,15 @@ export type Parameters = {
20
20
  export function getMetas(
21
21
  parameters?: Partial<Omit<Parameters, 'polygonGeoJson'>> & {
22
22
  polygonGeoJson: PolygonCoords;
23
- }
23
+ },
24
24
  ): {
25
- topVerts: number[];
25
+ topVerts: number[][];
26
26
  };
27
27
 
28
28
  export default class PolygonGeometry extends BufferGeometry {
29
29
  constructor(
30
30
  polygonGeoJson: PolygonCoords,
31
- parameters?: Partial<Omit<Parameters, 'polygonGeoJson'>>
31
+ parameters?: Partial<Omit<Parameters, 'polygonGeoJson'>>,
32
32
  );
33
33
 
34
34
  parameters: Parameters;
@@ -1,13 +1,13 @@
1
- export { default as Node } from './node';
2
- export { default as Group } from './group';
3
- export { default as Pie } from './pie';
4
- export { default as Light } from './light';
5
- export { default as Line2 } from './line2';
6
- export { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry';
7
1
  export { LineMaterial as Line2Material } from 'three/examples/jsm/lines/LineMaterial';
8
- export { MeshLineGeometry, MeshLineMaterial } from './line/meshLine';
9
- export { default as Line } from './line';
2
+ export { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry';
10
3
  export { default as ConicPolygon } from './conicPolygon';
11
4
  export { default as getConicPolygonGeometry, getMetas as getConicPolygonGeometryMetas, } from './conicPolygon/geometry';
12
5
  export { default as ExtrudePolygon } from './extrudePolygon';
13
6
  export { default as getSplitTexture } from './extrudePolygon/getSplitTexture';
7
+ export { default as Group } from './group';
8
+ export { default as Light } from './light';
9
+ export { default as Line } from './line';
10
+ export { MeshLineGeometry, MeshLineMaterial, MeshLineRaycast, } from './line/meshLine';
11
+ export { default as Line2 } from './line2';
12
+ export { default as Node } from './node';
13
+ export { default as Pie } from './pie';
@@ -1 +1 @@
1
- "use strict";var qe=Object.defineProperty,We=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var Ve=(n,e,t)=>e in n?qe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,E=(n,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&Ve(n,t,e[t]);if(ae)for(var t of ae(e))Pe.call(e,t)&&Ve(n,t,e[t]);return n},ce=(n,e)=>We(n,$e(e));var fe=(n,e)=>{var t={};for(var s in n)Ee.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&ae)for(var s of ae(n))e.indexOf(s)<0&&Pe.call(n,s)&&(t[s]=n[s]);return t};var se=(n,e,t)=>new Promise((s,i)=>{var r=h=>{try{u(t.next(h))}catch(w){i(w)}},a=h=>{try{u(t.throw(h))}catch(w){i(w)}},u=h=>h.done?s(h.value):Promise.resolve(h.value).then(r,a);u((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../index2.js"),c=require("three"),Je=require("@tweenjs/tween.js"),Qe=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),pe=require("three/examples/jsm/utils/BufferGeometryUtils"),Xe=require("three/examples/jsm/lines/LineSegments2"),Ie=require("three/examples/jsm/lines/LineSegmentsGeometry"),ze=require("three/examples/jsm/lines/LineMaterial"),Ge=require("../uvGenerator.js"),he=require("three-bvh-csg");function Ye(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const K=Ye(Je);class Ze extends P.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=E({type:"2d"},e)}create(){const{position:e,children:t}=this.options,s=document.createElement("div");this.element=s,t&&s.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(s):this.options.type==="3dSprite"?this.createCSS3DSprite(s):this.createCSS2DObject(s),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(),s=window.innerWidth,i=window.innerHeight;let r=0,a=0;t.left<0?r=-t.left:t.right>s&&(r=s-t.right),t.top<0?a=-t.top:t.bottom>i&&(a=i-t.bottom),t.left+r<0&&(r=-t.left),t.top+a<0&&(a=-t.top),(r!==0||a!==0)&&(e.style.transform=`translate(${r}px, ${a}px)`)}ensureVisible(){const e=this.options.children;if(!e)return;e.style.transform&&(e.style.transform="");const t=new IntersectionObserver(s=>{s.forEach(i=>{i.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)}onPointerEvent(e,t){const s=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(s)}dispose(){this.onNodePointerIndex.forEach(e=>{this.lead.removePickNode(e)}),super.dispose()}}class Ke extends P.BaseObject{create(){this.createGroup()}}const et={ArcCurve:c.ArcCurve,CatmullRomCurve3:c.CatmullRomCurve3,CubicBezierCurve:c.CubicBezierCurve,CubicBezierCurve3:c.CubicBezierCurve3,EllipseCurve:c.EllipseCurve,LineCurve:c.LineCurve,LineCurve3:c.LineCurve3,QuadraticBezierCurve:c.QuadraticBezierCurve,QuadraticBezierCurve3:c.QuadraticBezierCurve3,SplineCurve:c.SplineCurve};class X extends c.BufferGeometry{constructor(e=new c.Shape([new c.Vector2(.5,.5),new c.Vector2(-.5,.5),new c.Vector2(-.5,-.5),new c.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const s=this,i=[],r=[];for(let u=0,h=e.length;u<h;u++){const w=e[u];a(w)}this.setAttribute("position",new c.Float32BufferAttribute(i,3)),this.setAttribute("uv",new c.Float32BufferAttribute(r,2)),this.computeVertexNormals();function a(u){var Ae,Se,_e;const h=[],w=t.curveSegments!==void 0?t.curveSegments:12,o=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,x=t.bevelSize!==void 0?t.bevelSize:m-.1,L=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,V=t.UVGenerator!==void 0?t.UVGenerator:tt,A=(Ae=t.hasTop)!=null?Ae:!0,I=(Se=t.hasBottom)!=null?Se:!0,le=(_e=t.hasSide)!=null?_e:!0;let W,Y=!1,$,ee,te,D;_&&(W=_.getSpacedPoints(o),Y=!0,y=!1,$=_.computeFrenetFrames(o,!1),ee=new c.Vector3,te=new c.Vector3,D=new c.Vector3),y||(M=0,m=0,x=0,L=0);const be=u.extractPoints(w);let O=be.shape;const G=be.holes;if(!c.ShapeUtils.isClockWise(O)){O=O.reverse();for(let l=0,f=G.length;l<f;l++){const p=G[l];c.ShapeUtils.isClockWise(p)&&(G[l]=p.reverse())}}function ye(l){const p=10000000000000001e-36;let b=l[0];for(let g=1;g<=l.length;g++){const S=g%l.length,v=l[S],T=v.x-b.x,j=v.y-b.y,B=T*T+j*j,C=Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(b.x),Math.abs(b.y)),Q=p*C*C;if(B<=Q){l.splice(S,1),g--;continue}b=v}}ye(O),G.forEach(ye);const ue=G.length,z=O;for(let l=0;l<ue;l++){const f=G[l];O=O.concat(f)}function Z(l,f,p){return f||console.error("THREE.ExtrudeGeometry: vec does not exist"),l.clone().addScaledVector(f,p)}const H=O.length;function we(l,f,p){let b,g,S;const v=l.x-f.x,T=l.y-f.y,j=p.x-l.x,B=p.y-l.y,C=v*v+T*T,Q=v*B-T*j;if(Math.abs(Q)>Number.EPSILON){const U=Math.sqrt(C),Me=Math.sqrt(j*j+B*B),Le=f.x-T/U,Te=f.y+v/U,ke=p.x-B/Me,Fe=p.y+j/Me,je=((ke-Le)*B-(Fe-Te)*j)/(v*B-T*j);b=Le+v*je-l.x,g=Te+T*je-l.y;const Be=b*b+g*g;if(Be<=2)return new c.Vector2(b,g);S=Math.sqrt(Be/2)}else{let U=!1;v>Number.EPSILON?j>Number.EPSILON&&(U=!0):v<-Number.EPSILON?j<-Number.EPSILON&&(U=!0):Math.sign(T)===Math.sign(B)&&(U=!0),U?(b=-T,g=v,S=Math.sqrt(C)):(b=v,g=T,S=Math.sqrt(C/2))}return new c.Vector2(b/S,g/S)}const ie=[];for(let l=0,f=z.length,p=f-1,b=l+1;l<f;l++,p++,b++)p===f&&(p=0),b===f&&(b=0),ie[l]=we(z[l],z[p],z[b]);const de=[];let q,re=ie.concat();for(let l=0,f=ue;l<f;l++){const p=G[l];q=[];for(let b=0,g=p.length,S=g-1,v=b+1;b<g;b++,S++,v++)S===g&&(S=0),v===g&&(v=0),q[b]=we(p[b],p[S],p[v]);de.push(q),re=re.concat(q)}let J;if(M===0)J=c.ShapeUtils.triangulateShape(z,G);else{const l=[],f=[];for(let p=0;p<M;p++){const b=p/M,g=m*Math.cos(b*Math.PI/2),S=x*Math.sin(b*Math.PI/2)+L;for(let v=0,T=z.length;v<T;v++){const j=Z(z[v],ie[v],S);N(j.x,j.y,-g),b===0&&l.push(j)}for(let v=0,T=ue;v<T;v++){const j=G[v];q=de[v];const B=[];for(let C=0,Q=j.length;C<Q;C++){const U=Z(j[C],q[C],S);N(U.x,U.y,-g),b===0&&B.push(U)}b===0&&f.push(B)}}J=c.ShapeUtils.triangulateShape(l,f)}const ne=J.length,xe=x+L;for(let l=0;l<H;l++){const f=y?Z(O[l],re[l],xe):O[l];Y?(te.copy($.normals[0]).multiplyScalar(f.x),ee.copy($.binormals[0]).multiplyScalar(f.y),D.copy(W[0]).add(te).add(ee),N(D.x,D.y,D.z)):N(f.x,f.y,0)}for(let l=1;l<=o;l++)for(let f=0;f<H;f++){const p=y?Z(O[f],re[f],xe):O[f];Y?(te.copy($.normals[l]).multiplyScalar(p.x),ee.copy($.binormals[l]).multiplyScalar(p.y),D.copy(W[l]).add(te).add(ee),N(D.x,D.y,D.z)):N(p.x,p.y,d/o*l)}for(let l=M-1;l>=0;l--){const f=l/M,p=m*Math.cos(f*Math.PI/2),b=x*Math.sin(f*Math.PI/2)+L;for(let g=0,S=z.length;g<S;g++){const v=Z(z[g],ie[g],b);N(v.x,v.y,d+p)}for(let g=0,S=G.length;g<S;g++){const v=G[g];q=de[g];for(let T=0,j=v.length;T<j;T++){const B=Z(v[T],q[T],b);Y?N(B.x,B.y+W[o-1].y,W[o-1].x+p):N(B.x,B.y,d+p)}}}De(),le&&He();function De(){const l=i.length/3;if(y){let f=0,p=H*f;if(I)for(let b=0;b<ne;b++){const g=J[b];oe(g[2]+p,g[1]+p,g[0]+p)}if(f=o+M*2,p=H*f,A)for(let b=0;b<ne;b++){const g=J[b];oe(g[0]+p,g[1]+p,g[2]+p)}}else{if(I)for(let f=0;f<ne;f++){const p=J[f];oe(p[2],p[1],p[0])}if(A)for(let f=0;f<ne;f++){const p=J[f];oe(p[0]+H*o,p[1]+H*o,p[2]+H*o)}}s.addGroup(l,i.length/3-l,0)}function He(){const l=i.length/3;let f=0;ve(z,f),f+=z.length;for(let p=0,b=G.length;p<b;p++){const g=G[p];ve(g,f),f+=g.length}s.addGroup(l,i.length/3-l,1)}function ve(l,f){let p=l.length;for(;--p>=0;){const b=p;let g=p-1;g<0&&(g=l.length-1);for(let S=0,v=o+M*2;S<v;S++){const T=H*S,j=H*(S+1),B=f+b+T,C=f+g+T,Q=f+g+j,U=f+b+j;Ne(B,C,Q,U)}}}function N(l,f,p){h.push(l),h.push(f),h.push(p)}function oe(l,f,p){k(l),k(f),k(p);const b=i.length/3,g=V.generateTopUV(s,i,b-3,b-2,b-1);F(g[0]),F(g[1]),F(g[2])}function Ne(l,f,p,b){k(l),k(f),k(b),k(f),k(p),k(b);const g=i.length/3,S=V.generateSideWallUV(s,i,g-6,g-3,g-2,g-1);F(S[0]),F(S[1]),F(S[3]),F(S[1]),F(S[2]),F(S[3])}function k(l){i.push(h[l*3+0]),i.push(h[l*3+1]),i.push(h[l*3+2])}function F(l){r.push(l.x),r.push(l.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,s=this.parameters.options;return st(t,s,e)}static fromJSON(e,t){const s=[];for(let r=0,a=e.shapes.length;r<a;r++){const u=t[e.shapes[r]];s.push(u)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new et[`${i.type}`]().fromJSON(i)),new X(s,e.options)}}const tt={generateTopUV:function(n,e,t,s,i){const r=e[t*3],a=e[t*3+1],u=e[s*3],h=e[s*3+1],w=e[i*3],o=e[i*3+1];return[new c.Vector2(r,a),new c.Vector2(u,h),new c.Vector2(w,o)]},generateSideWallUV:function(n,e,t,s,i,r){const a=e[t*3],u=e[t*3+1],h=e[t*3+2],w=e[s*3],o=e[s*3+1],d=e[s*3+2],y=e[i*3],m=e[i*3+1],x=e[i*3+2],L=e[r*3],M=e[r*3+1],_=e[r*3+2];return Math.abs(u-o)<Math.abs(a-w)?[new c.Vector2(a,1-h),new c.Vector2(w,1-d),new c.Vector2(y,1-x),new c.Vector2(L,1-_)]:[new c.Vector2(u,1-h),new c.Vector2(o,1-d),new c.Vector2(m,1-x),new c.Vector2(M,1-_)]}};function st(n,e,t){if(t.shapes=[],Array.isArray(n))for(let s=0,i=n.length;s<i;s++){const r=n[s];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}class it extends P.BaseObject{constructor(e){super(),this.options=E({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return se(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:s,material:i,percentDepth:r,activeIndex:a}=this.options,u=Math.max(...e),h=e.reduce((o,d)=>o+d,0);let w=Math.PI/2;e.forEach((o,d)=>{if(o===0)return;const y=Math.PI*2*(o/h),m=s[d],x=r?t*(o/u):t,L=this.createGeometry(x,y),M=i?i.clone():new c.MeshBasicMaterial({color:m});i&&M.color.set(m);const _=new c.Mesh(L,M);_.userData.depth=x,_.userData.index=d,_.rotateZ(w),w+=y,this.add(_)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:s,innerRadius:i}=this.options,r=new c.Shape;return r.moveTo(s,0),r.lineTo(i,0),r.absarc(0,0,i,0,t,!1),r.absarc(0,0,s,t,0,!0),new X(r,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:s}=this.pencil.pick(e,this.object3d.children)||{},i=s?this.object3d.children.findIndex(r=>r===s):this.options.activeIndex;return this.setActive(i,t)}setActive(e,t=1.3){const s=this.object3d.children[e];if(this.object3d.children.forEach(i=>{if(!(s&&s===i)&&i.scale.z!==1){if(i.userData.levTween)return;i.userData.enTween&&(i.userData.enTween.stop(),i.userData.enTween=null);const r=new K.Tween(i.scale).to({z:1},100);i.userData.levTween=r,r.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new K.Tween(s.scale).to({z:t},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new K.Tween(this.object3d.scale).to({z:1},1e3).easing(K.Easing.Sinusoidal.InOut).start()}}class rt extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,s,i,r,a,u,h,w,o,d,y,m,x,L,M,_,V;const e=this.options;if(e.type==="AmbientLight"){const A=new c.AmbientLight(e.color);A.name="环境光",this.object3d=A}else if(e.type==="DirectionalLight"){const A=new c.DirectionalLight(e.color,e.intensity);A.name="平行光",A.target.position.set(0,0,0),this.object3d=A,A.target.name="平行光目标",A.shadow.camera.name="平行光阴影相机",A.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=A}else if(e.type==="PointLight"){const A=new c.PointLight((t=e.color)!=null?t:16777215,(s=e.intensity)!=null?s:1,(i=e.distance)!=null?i:0,(r=e.decay)!=null?r:2);A.name="点光源",this.object3d=A,this.pointLight=A}else if(e.type==="SpotLight"){const A=new c.SpotLight((a=e.color)!=null?a:16777215,(u=e.intensity)!=null?u:1,(h=e.distance)!=null?h:0,(w=e.angle)!=null?w:Math.PI/3,(o=e.penumbra)!=null?o:1,(d=e.decay)!=null?d:2);A.name="聚光灯",this.object3d=A,this.spotLight=A,A.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const A=new c.HemisphereLight((y=e.color)!=null?y:16777215,(m=e.groundColor)!=null?m:16777215,(x=e.intensity)!=null?x:1);A.name="半球光",this.object3d=A,this.hemisphereLight=A}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Qe.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const A=new c.RectAreaLight((L=e.color)!=null?L:16777215,(M=e.intensity)!=null?M:1,(_=e.width)!=null?_:10,(V=e.height)!=null?V:10);A.name="矩形区域光",this.object3d=A,this.rectAreaLight=A}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const s=this.spotLight||this.directionalLight;s.position.copy(t),s.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 R(n,e=0){const t=n[0].index!==null,s=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),r={},a={},u=n[0].morphTargetsRelative,h=new c.BufferGeometry;let w=0;for(let o=0;o<n.length;++o){const d=n[o];let y=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in d.attributes){if(!s.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;r[m]===void 0&&(r[m]=[]),r[m].push(d.attributes[m]),y++}if(y!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". Make sure all geometries have the same number of attributes."),null;if(u!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in d.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(d.morphAttributes[m])}if(e){let m;if(t)m=d.index.count;else if(d.attributes.position!==void 0)m=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". The geometry must have either an index or a position attribute"),null;if(e===1)h.addGroup(w,m,o);else if(e===2&&d.groups.length>0)for(let x of d.groups){let L=x.materialIndex;h.addGroup(w+x.start,Math.min(x.count,m),L)}w+=m}}if(t){let o=0;const d=[];for(let y=0;y<n.length;++y){const m=n[y].index;for(let x=0;x<m.count;++x)d.push(m.getX(x)+o);o+=n[y].attributes.position.count}h.setIndex(d)}for(const o in r){const d=pe.mergeAttributes(r[o]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" attribute."),null;h.setAttribute(o,d)}for(const o in a){const d=a[o][0].length;if(d===0)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[o]=[];for(let y=0;y<d;++y){const m=[];for(let L=0;L<a[o].length;++L)m.push(a[o][L][y]);const x=pe.mergeAttributes(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" morphAttribute."),null;h.morphAttributes[o].push(x)}}return e===2?pe.mergeGroups(h):h}const Ce=n=>{const{points:e}=n,t=e.reduce((i,r,a)=>(a<e.length-1&&i.push(r,e[a+1]),i),[]);return new c.BufferGeometry().setFromPoints(t)};let nt=class extends P.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return se(this,null,function*(){const{points:e,pointsArr:t,geometry:s,geometryArr:i,material:r,useGroups:a,setPointWidth:u,lineWidthArr:h,materialParameters:w,instanceCount:o}=this.options;let d=r,y=s;!d&&w&&(d=this.getMaterial(w)),!y&&e?y=Ce({points:e}):!y&&t?y=R(t.map(x=>Ce({points:x})),a!=null?a:0):!y&&i&&i.length>1?y=R(i,a!=null?a:0):!y&&i&&i.length===1&&([y]=i);const m=new Ie.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(y));if(this.pencil.options.WebGPUTHREE){o&&(m.instanceCount=o);const x=new P.LineSegments2(m,d);x.computeLineDistances(),this.object3d=x}else{const x=new Xe.LineSegments2(m,d);x.computeLineDistances(),this.object3d=x}})}getMaterial(e){return new ze.LineMaterial(E({color:new c.Color("#ffffff")},e))}};function me(n,e,t,s,i){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,i&&e+i):n.slice(e,i&&e+i):n,t.set)t.set(n,s);else for(r=0;r<n.length;r++)t[r+s]=n[r];return t}function ot(n){return n instanceof Float32Array?n:n instanceof c.BufferGeometry?n.getAttribute("position").array:n.map(e=>{const t=Array.isArray(e);return e instanceof c.Vector3?[e.x,e.y,e.z]:e instanceof c.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 Re extends c.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 c.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=ot(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof c.Vector3)for(let s=0;s<e.length;s++){const i=e[s],r=s/(e.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(r),this.counters.push(r)}else for(let s=0;s<e.length;s+=3){const i=s/(e.length-1);this.positions.push(e[s],e[s+1],e[s+2]),this.positions.push(e[s],e[s+1],e[s+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(e,t){const s=e*6,i=t*6;return this.positions[s]===this.positions[i]&&this.positions[s+1]===this.positions[i+1]&&this.positions[s+2]===this.positions[i+2]}copyV3(e){const t=e*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]}process(){const e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let t,s;this.compareV3(0,e-1)?s=this.copyV3(e-2):s=this.copyV3(0),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);for(let i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(i/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const r=i*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}i>0&&(s=this.copyV3(i),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(e-1,0)?s=this.copyV3(1):s=this.copyV3(e-1),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new c.BufferAttribute(new Float32Array(this.positions),3),previous:new c.BufferAttribute(new Float32Array(this.previous),3),next:new c.BufferAttribute(new Float32Array(this.next),3),side:new c.BufferAttribute(new Float32Array(this.side),1),width:new c.BufferAttribute(new Float32Array(this.width),1),uv:new c.BufferAttribute(new Float32Array(this.uvs),2),index:new c.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new c.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:e,y:t,z:s}){const i=this._attributes.position.array,r=this._attributes.previous.array,a=this._attributes.next.array,u=i.length;me(i,0,r,0,u),me(i,6,i,0,u-6),i[u-6]=e,i[u-5]=t,i[u-4]=s,i[u-3]=e,i[u-2]=t,i[u-1]=s,me(i,6,a,0,u-6),a[u-6]=e,a[u-5]=t,a[u-4]=s,a[u-3]=e,a[u-2]=t,a[u-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const ge=n=>{const{setPointWidth:e,nodes:t}=n,s=new Re;return s.setPoints(t,e),s};class at extends P.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return se(this,null,function*(){const{nodes:e,nodesArr:t,geometry:s,geometryArr:i,material:r,useGroups:a,setPointWidth:u,lineWidthArr:h,materialParameters:w}=this.options;let o=r,d=s;!o&&w&&(o=this.getMaterial(w)),!d&&e?d=ge({nodes:e,setPointWidth:u}):!d&&t?d=R(t.map((y,m)=>{let x=u;return!x&&h&&(x=()=>{var L;return(L=h[m])!=null?L:h[0]}),ge({nodes:y,setPointWidth:x})}),a!=null?a:0):!d&&i&&i.length>1?d=R(i,a!=null?a:0):!d&&i&&i.length===1&&([d]=i),this.createMesh(d,o)})}setGeometry(e,t){const s=ge({nodes:e,setPointWidth:t}),i=this.object3d,r=i.geometry;i.geometry=s,r.dispose()}getMaterial(e){const{width:t,height:s}=this.pencil.getSize();return new P.MeshLineMaterial(E({color:new c.Color("#ffffff"),resolution:new c.Vector2(t,s)},e))}addGeometries(e){const t=this.object3d,s=R([t.geometry,...e]);t.geometry=s}resize(e,t){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:s}=this.pencil.getSize();this.resize(t,s)}animate({duration:e=1e3,delay:t=0,repeat:s=0,lineLoop:i,onRepeat:r,onUpdate:a,onComplete:u,startShow:h}={}){const{offset:w,offsetLoop:o}=this.material.uniforms;if(this.material.userData.tween)return;const d=i!=null?i:!0;w.value.x=1,o.value=d&&h?1:0;let y=0;const m=new K.Tween(w.value).to({x:-1},e).delay(t).repeat(s).onUpdate(({x})=>{d&&x<=0&&o.value===0&&(o.value=1),a&&a(x)}).onRepeat(()=>{y+=1,r&&r(y)}).onComplete(()=>{u&&u()}).start();this.material.userData.tween=m}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),K.remove(this.material.userData.tween)),super.dispose()}}const Ue=n=>{const u=n,{coordinate:e,startHeight:t,height:s}=u,i=fe(u,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof s!="undefined"&&(r=t+s),new P.PolygonGeometry([e],ce(E({},i),{startHeight:t,endHeight:r}))};class ct extends P.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const h=this.options,{geometry:e,coordinateArr:t,coordinate:s,material:i,useGroups:r}=h,a=fe(h,["geometry","coordinateArr","coordinate","material","useGroups"]);let u=e;if(!u&&s)u=Ue(E({coordinate:s},a));else if(!u&&t){const w=t.map(o=>Ue(E({coordinate:o},a)));u=R(w,r!=null?r:0)}this.createMesh(u,i)}}class ht extends X{constructor(e,t){super(e,t);const s=new he.Brush(new X(e,ce(E({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));s.updateMatrixWorld();const i=new c.Box3().setFromObject(s),r=new c.Vector3;i.getSize(r);const a=new c.Vector3(i.min.x+r.x/2,i.min.y+r.y/2,0);let u=t.topSegments,h=t.box3;if(h){h=h.union(i);const _=new c.Vector3;h.getSize(_);const V=Math.max(r.x/_.x,r.y/_.y);u=Math.ceil(t.topSegments*V)}if(u<4)return this;const w=new c.PlaneGeometry(r.x,r.y,u,u),o=new he.Brush(w);o.position.set(a.x,a.y,a.z),o.updateMatrixWorld();const y=new he.Evaluator().evaluate(o,s,he.INTERSECTION),m=y.geometry.getAttribute("position"),x=new c.Float32BufferAttribute(m.count*2,2);for(let _=0;_<m.count;_++){const V=m.getZ(_);m.setZ(_,t.depth+V)}if(h){const _=h.min,V=h.max,A=new c.Vector3().subVectors(V,_);for(let I=0;I<m.count;I++){const le=m.getX(I),W=m.getY(I),Y=(le-_.x)/A.x,$=(W-_.y)/A.y;x.setXY(I,Y,$)}y.geometry.setAttribute("uv",x)}m.needsUpdate=!0;const L=new X(e,ce(E({},t),{hasTop:!1})),M=R([y.geometry,L],2);this.copy(M.toNonIndexed())}}const Oe=n=>{const{split:e,depth:t,points:s,box3:i,hasTop:r,hasBottom:a,hasSide:u,sideRepeat:h,topSegments:w}=n,o=w?ht:X,d=new o(new c.Shape(s),{depth:t,bevelEnabled:!1,box3:i,UVGenerator:Ge.getUVGenerator({split:e,box3:i,sideRepeat:h}),hasTop:r,hasBottom:a,hasSide:u,topSegments:w});return Ge.claerUVGenerator(),d};class lt extends P.BaseObject{constructor(e){super(),this.options=E({depth:1},e)}create(){return se(this,null,function*(){const{points:e,pointsArr:t,useGroups:s,depth:i,geometry:r,geometryArr:a,material:u,box3:h,split:w,hasTop:o,hasBottom:d,hasSide:y}=this.options,m=Array.isArray(i)?i:[i],x=Array.isArray(h)?h:[h],L=u;let M=r;L||console.log("material is null"),!M&&e?M=Oe({points:e,depth:m[0],box3:x[0],split:w,hasTop:o,hasBottom:d,hasSide:y}):!M&&t?M=R(t.map((_,V)=>{var A,I;return Oe({points:_,depth:(A=m[V])!=null?A:m[0],box3:(I=x[V])!=null?I:x[0],split:w,hasTop:o,hasBottom:d,hasSide:y})}),s!=null?s:0):!M&&a&&a.length>1?M=R(a,s!=null?s:0):!M&&a&&a.length===1&&([M]=a),this.createMesh(M,L)})}addGeometries(e){const t=this.object3d,s=R([t.geometry,...e]);t.geometry=s}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const ut=n=>{const{topColor:e,sideColor:t,sideMap:s,createCanvasObjectURL:i,split:r,maxAnisotropy:a}=n;return new Promise(u=>{const h=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};h.onload=()=>{const w=r,o=document.createElement("canvas"),d=o.getContext("2d");o.height=h.height/(1-w),o.width=h.width,w&&e&&(d.fillStyle=e,d.fillRect(0,0,h.width,o.height*w)),s&&h instanceof HTMLImageElement?d.drawImage(h,0,o.height*w,h.width,h.height):t&&(d.fillStyle=t,d.fillRect(0,o.height*w,h.width,h.height)),i&&o.toBlob(m=>{console.log(URL.createObjectURL(m))});const y=new c.CanvasTexture(o);u(y)},s?h.src=s:h instanceof HTMLImageElement||h.onload()})};exports.MeshLineMaterial=P.MeshLineMaterial;exports.getConicPolygonGeometry=P.PolygonGeometry;exports.getConicPolygonGeometryMetas=P.getMetas;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ie.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>ze.LineMaterial});exports.ConicPolygon=ct;exports.ExtrudePolygon=lt;exports.Group=Ke;exports.Light=rt;exports.Line=at;exports.Line2=nt;exports.MeshLineGeometry=Re;exports.Node=Ze;exports.Pie=it;exports.getSplitTexture=ut;
1
+ "use strict";var We=Object.defineProperty,qe=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var je=(u,e,t)=>e in u?We(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t,E=(u,e)=>{for(var t in e||(e={}))Be.call(e,t)&&je(u,t,e[t]);if(ce)for(var t of ce(e))Ee.call(e,t)&&je(u,t,e[t]);return u},le=(u,e)=>qe(u,ke(e));var de=(u,e)=>{var t={};for(var n in u)Be.call(u,n)&&e.indexOf(n)<0&&(t[n]=u[n]);if(u!=null&&ce)for(var n of ce(u))e.indexOf(n)<0&&Ee.call(u,n)&&(t[n]=u[n]);return t};var se=(u,e,t)=>new Promise((n,s)=>{var i=r=>{try{m(t.next(r))}catch(f){s(f)}},a=r=>{try{m(t.throw(r))}catch(f){s(f)}},m=r=>r.done?n(r.value):Promise.resolve(r.value).then(i,a);m((t=t.apply(u,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Oe=require("three/examples/jsm/lines/LineMaterial"),Ie=require("three/examples/jsm/lines/LineSegmentsGeometry"),P=require("../WebGPULineSegments2.js"),c=require("three"),pe=require("three/examples/jsm/utils/BufferGeometryUtils"),Pe=require("../uvGenerator.js"),he=require("three-bvh-csg"),Fe=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),Ye=require("@tweenjs/tween.js"),Ze=require("three/examples/jsm/lines/LineSegments2");function $e(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>u[t]})}}return e.default=u,Object.freeze(e)}const ee=$e(Ye);function D(u,e=0){const t=u[0].index!==null,n=new Set(Object.keys(u[0].attributes)),s=new Set(Object.keys(u[0].morphAttributes)),i={},a={},m=u[0].morphTargetsRelative,r=new c.BufferGeometry;let f=0;for(let o=0;o<u.length;++o){const l=u[o];let b=0;if(t!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in l.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;i[d]===void 0&&(i[d]=[]),i[d].push(l.attributes[d]),b++}if(b!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". Make sure all geometries have the same number of attributes."),null;if(m!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in l.morphAttributes){if(!s.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphAttributes must be consistent throughout all geometries."),null;a[d]===void 0&&(a[d]=[]),a[d].push(l.morphAttributes[d])}if(e){let d;if(t)d=l.index.count;else if(l.attributes.position!==void 0)d=l.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". The geometry must have either an index or a position attribute"),null;if(e===1)r.addGroup(f,d,o);else if(e===2&&l.groups.length>0)for(let y of l.groups){let C=y.materialIndex;r.addGroup(f+y.start,Math.min(y.count,d),C)}f+=d}}if(t){let o=0;const l=[];for(let b=0;b<u.length;++b){const d=u[b].index;for(let y=0;y<d.count;++y)l.push(d.getX(y)+o);o+=u[b].attributes.position.count}r.setIndex(l)}for(const o in i){const l=pe.mergeAttributes(i[o]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" attribute."),null;r.setAttribute(o,l)}for(const o in a){const l=a[o][0].length;if(l===0)break;r.morphAttributes=r.morphAttributes||{},r.morphAttributes[o]=[];for(let b=0;b<l;++b){const d=[];for(let C=0;C<a[o].length;++C)d.push(a[o][C][b]);const y=pe.mergeAttributes(d);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" morphAttribute."),null;r.morphAttributes[o].push(y)}}return e===2?pe.mergeGroups(r):r}const Ve=u=>{const m=u,{coordinate:e,startHeight:t,height:n}=m,s=de(m,["coordinate","startHeight","height"]);let i=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(i=t+n),new P.PolygonGeometry([e],le(E({},s),{startHeight:t,endHeight:i}))};class Je extends P.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const r=this.options,{geometry:e,coordinateArr:t,coordinate:n,material:s,useGroups:i}=r,a=de(r,["geometry","coordinateArr","coordinate","material","useGroups"]);let m=e;if(!m&&n)m=Ve(E({coordinate:n},a));else if(!m&&t){const f=t.map(o=>Ve(E({coordinate:o},a)));m=D(f,i!=null?i:0)}this.createMesh(m,s)}}const Qe={ArcCurve:c.ArcCurve,CatmullRomCurve3:c.CatmullRomCurve3,CubicBezierCurve:c.CubicBezierCurve,CubicBezierCurve3:c.CubicBezierCurve3,EllipseCurve:c.EllipseCurve,LineCurve:c.LineCurve,LineCurve3:c.LineCurve3,QuadraticBezierCurve:c.QuadraticBezierCurve,QuadraticBezierCurve3:c.QuadraticBezierCurve3,SplineCurve:c.SplineCurve};class J extends c.BufferGeometry{constructor(e=new c.Shape([new c.Vector2(.5,.5),new c.Vector2(-.5,.5),new c.Vector2(-.5,-.5),new c.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,s=[],i=[];for(let m=0,r=e.length;m<r;m++){const f=e[m];a(f)}this.setAttribute("position",new c.Float32BufferAttribute(s,3)),this.setAttribute("uv",new c.Float32BufferAttribute(i,2)),this.computeVertexNormals();function a(m){var ve,Se,Ae;const r=[],f=t.curveSegments!==void 0?t.curveSegments:12,o=t.steps!==void 0?t.steps:1,l=t.depth!==void 0?t.depth:1;let b=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,y=t.bevelSize!==void 0?t.bevelSize:d-.1,C=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const M=t.extrudePath,B=t.UVGenerator!==void 0?t.UVGenerator:Ke,S=(ve=t.hasTop)!=null?ve:!0,V=(Se=t.hasBottom)!=null?Se:!0,Q=(Ae=t.hasSide)!=null?Ae:!0;let H,Y=!1,U,te,ne,N;M&&(H=M.getSpacedPoints(o),Y=!0,b=!1,U=M.computeFrenetFrames(o,!1),te=new c.Vector3,ne=new c.Vector3,N=new c.Vector3),b||(A=0,d=0,y=0,C=0);const ge=m.extractPoints(f);let I=ge.shape;const _=ge.holes;if(!c.ShapeUtils.isClockWise(I)){I=I.reverse();for(let h=0,p=_.length;h<p;h++){const g=_[h];c.ShapeUtils.isClockWise(g)&&(_[h]=g.reverse())}}function ye(h){const g=10000000000000001e-36;let w=h[0];for(let x=1;x<=h.length;x++){const L=x%h.length,v=h[L],T=v.x-w.x,G=v.y-w.y,j=T*T+G*G,z=Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(w.x),Math.abs(w.y)),$=g*z*z;if(j<=$){h.splice(L,1),x--;continue}w=v}}ye(I),_.forEach(ye);const ue=_.length,R=I;for(let h=0;h<ue;h++){const p=_[h];I=I.concat(p)}function K(h,p,g){return p||console.error("THREE.ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(p,g)}const X=I.length;function be(h,p,g){let w,x,L;const v=h.x-p.x,T=h.y-p.y,G=g.x-h.x,j=g.y-h.y,z=v*v+T*T,$=v*j-T*G;if(Math.abs($)>Number.EPSILON){const O=Math.sqrt(z),Me=Math.sqrt(G*G+j*j),Le=p.x-T/O,Ce=p.y+v/O,Ne=g.x-j/Me,Xe=g.y+G/Me,Te=((Ne-Le)*j-(Xe-Ce)*G)/(v*j-T*G);w=Le+v*Te-h.x,x=Ce+T*Te-h.y;const Ge=w*w+x*x;if(Ge<=2)return new c.Vector2(w,x);L=Math.sqrt(Ge/2)}else{let O=!1;v>Number.EPSILON?G>Number.EPSILON&&(O=!0):v<-Number.EPSILON?G<-Number.EPSILON&&(O=!0):Math.sign(T)===Math.sign(j)&&(O=!0),O?(w=-T,x=v,L=Math.sqrt(z)):(w=v,x=T,L=Math.sqrt(z/2))}return new c.Vector2(w/L,x/L)}const oe=[];for(let h=0,p=R.length,g=p-1,w=h+1;h<p;h++,g++,w++)g===p&&(g=0),w===p&&(w=0),oe[h]=be(R[h],R[g],R[w]);const fe=[];let F,ie=oe.concat();for(let h=0,p=ue;h<p;h++){const g=_[h];F=[];for(let w=0,x=g.length,L=x-1,v=w+1;w<x;w++,L++,v++)L===x&&(L=0),v===x&&(v=0),F[w]=be(g[w],g[L],g[v]);fe.push(F),ie=ie.concat(F)}let Z;if(A===0)Z=c.ShapeUtils.triangulateShape(R,_);else{const h=[],p=[];for(let g=0;g<A;g++){const w=g/A,x=d*Math.cos(w*Math.PI/2),L=y*Math.sin(w*Math.PI/2)+C;for(let v=0,T=R.length;v<T;v++){const G=K(R[v],oe[v],L);W(G.x,G.y,-x),w===0&&h.push(G)}for(let v=0,T=ue;v<T;v++){const G=_[v];F=fe[v];const j=[];for(let z=0,$=G.length;z<$;z++){const O=K(G[z],F[z],L);W(O.x,O.y,-x),w===0&&j.push(O)}w===0&&p.push(j)}}Z=c.ShapeUtils.triangulateShape(h,p)}const re=Z.length,xe=y+C;for(let h=0;h<X;h++){const p=b?K(I[h],ie[h],xe):I[h];Y?(ne.copy(U.normals[0]).multiplyScalar(p.x),te.copy(U.binormals[0]).multiplyScalar(p.y),N.copy(H[0]).add(ne).add(te),W(N.x,N.y,N.z)):W(p.x,p.y,0)}for(let h=1;h<=o;h++)for(let p=0;p<X;p++){const g=b?K(I[p],ie[p],xe):I[p];Y?(ne.copy(U.normals[h]).multiplyScalar(g.x),te.copy(U.binormals[h]).multiplyScalar(g.y),N.copy(H[h]).add(ne).add(te),W(N.x,N.y,N.z)):W(g.x,g.y,l/o*h)}for(let h=A-1;h>=0;h--){const p=h/A,g=d*Math.cos(p*Math.PI/2),w=y*Math.sin(p*Math.PI/2)+C;for(let x=0,L=R.length;x<L;x++){const v=K(R[x],oe[x],w);W(v.x,v.y,l+g)}for(let x=0,L=_.length;x<L;x++){const v=_[x];F=fe[x];for(let T=0,G=v.length;T<G;T++){const j=K(v[T],F[T],w);Y?W(j.x,j.y+H[o-1].y,H[o-1].x+g):W(j.x,j.y,l+g)}}}Re(),Q&&De();function Re(){const h=s.length/3;if(b){let p=0,g=X*p;if(V)for(let w=0;w<re;w++){const x=Z[w];ae(x[2]+g,x[1]+g,x[0]+g)}if(p=o+A*2,g=X*p,S)for(let w=0;w<re;w++){const x=Z[w];ae(x[0]+g,x[1]+g,x[2]+g)}}else{if(V)for(let p=0;p<re;p++){const g=Z[p];ae(g[2],g[1],g[0])}if(S)for(let p=0;p<re;p++){const g=Z[p];ae(g[0]+X*o,g[1]+X*o,g[2]+X*o)}}n.addGroup(h,s.length/3-h,0)}function De(){const h=s.length/3;let p=0;we(R,p),p+=R.length;for(let g=0,w=_.length;g<w;g++){const x=_[g];we(x,p),p+=x.length}n.addGroup(h,s.length/3-h,1)}function we(h,p){let g=h.length;for(;--g>=0;){const w=g;let x=g-1;x<0&&(x=h.length-1);for(let L=0,v=o+A*2;L<v;L++){const T=X*L,G=X*(L+1),j=p+w+T,z=p+x+T,$=p+x+G,O=p+w+G;He(j,z,$,O)}}}function W(h,p,g){r.push(h),r.push(p),r.push(g)}function ae(h,p,g){q(h),q(p),q(g);const w=s.length/3,x=B.generateTopUV(n,s,w-3,w-2,w-1);k(x[0]),k(x[1]),k(x[2])}function He(h,p,g,w){q(h),q(p),q(w),q(p),q(g),q(w);const x=s.length/3,L=B.generateSideWallUV(n,s,x-6,x-3,x-2,x-1);k(L[0]),k(L[1]),k(L[3]),k(L[1]),k(L[2]),k(L[3])}function q(h){s.push(r[h*3+0]),s.push(r[h*3+1]),s.push(r[h*3+2])}function k(h){i.push(h.x),i.push(h.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return et(t,n,e)}static fromJSON(e,t){const n=[];for(let i=0,a=e.shapes.length;i<a;i++){const m=t[e.shapes[i]];n.push(m)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new Qe[`${s.type}`]().fromJSON(s)),new J(n,e.options)}}const Ke={generateTopUV:function(u,e,t,n,s){const i=e[t*3],a=e[t*3+1],m=e[n*3],r=e[n*3+1],f=e[s*3],o=e[s*3+1];return[new c.Vector2(i,a),new c.Vector2(m,r),new c.Vector2(f,o)]},generateSideWallUV:function(u,e,t,n,s,i){const a=e[t*3],m=e[t*3+1],r=e[t*3+2],f=e[n*3],o=e[n*3+1],l=e[n*3+2],b=e[s*3],d=e[s*3+1],y=e[s*3+2],C=e[i*3],A=e[i*3+1],M=e[i*3+2];return Math.abs(m-o)<Math.abs(a-f)?[new c.Vector2(a,1-r),new c.Vector2(f,1-l),new c.Vector2(b,1-y),new c.Vector2(C,1-M)]:[new c.Vector2(m,1-r),new c.Vector2(o,1-l),new c.Vector2(d,1-y),new c.Vector2(A,1-M)]}};function et(u,e,t){if(t.shapes=[],Array.isArray(u))for(let n=0,s=u.length;n<s;n++){const i=u[n];t.shapes.push(i.uuid)}else t.shapes.push(u.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class tt extends J{constructor(e,t){super(e,t);const n=new he.Brush(new J(e,le(E({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));n.updateMatrixWorld();const s=new c.Box3().setFromObject(n),i=new c.Vector3;s.getSize(i);const a=new c.Vector3(s.min.x+i.x/2,s.min.y+i.y/2,0);let m=t.topSegments,r=t.box3;if(r){r=r.union(s);const M=new c.Vector3;r.getSize(M);const B=Math.max(i.x/M.x,i.y/M.y);m=Math.ceil(t.topSegments*B)}if(m<4)return this;const f=new c.PlaneGeometry(i.x,i.y,m,m),o=new he.Brush(f);o.position.set(a.x,a.y,a.z),o.updateMatrixWorld();const b=new he.Evaluator().evaluate(o,n,he.INTERSECTION),d=b.geometry.getAttribute("position"),y=new c.Float32BufferAttribute(d.count*2,2);for(let M=0;M<d.count;M++){const B=d.getZ(M);d.setZ(M,t.depth+B)}if(r){const M=r.min,B=r.max,S=new c.Vector3().subVectors(B,M);for(let V=0;V<d.count;V++){const Q=d.getX(V),H=d.getY(V),Y=(Q-M.x)/S.x,U=(H-M.y)/S.y;y.setXY(V,Y,U)}b.geometry.setAttribute("uv",y)}d.needsUpdate=!0;const C=new J(e,le(E({},t),{hasTop:!1})),A=D([b.geometry,C],2);this.copy(A.toNonIndexed())}}const _e=u=>{const{split:e,depth:t,points:n,box3:s,hasTop:i,hasBottom:a,hasSide:m,sideRepeat:r,topSegments:f}=u,o=f?tt:J,l=new o(new c.Shape(n),{depth:t,bevelEnabled:!1,box3:s,UVGenerator:Pe.getUVGenerator({split:e,box3:s,sideRepeat:r}),hasTop:i,hasBottom:a,hasSide:m,topSegments:f});return Pe.claerUVGenerator(),l};class nt extends P.BaseObject{constructor(e){super(),this.options=E({depth:1},e)}create(){return se(this,null,function*(){const{points:e,pointsArr:t,useGroups:n,depth:s,geometry:i,geometryArr:a,material:m,box3:r,split:f,hasTop:o,hasBottom:l,hasSide:b}=this.options,d=Array.isArray(s)?s:[s],y=Array.isArray(r)?r:[r],C=m;let A=i;C||console.log("material is null"),!A&&e?A=_e({points:e,depth:d[0],box3:y[0],split:f,hasTop:o,hasBottom:l,hasSide:b}):!A&&t?A=D(t.map((M,B)=>{var S,V;return _e({points:M,depth:(S=d[B])!=null?S:d[0],box3:(V=y[B])!=null?V:y[0],split:f,hasTop:o,hasBottom:l,hasSide:b})}),n!=null?n:0):!A&&a&&a.length>1?A=D(a,n!=null?n:0):!A&&a&&a.length===1&&([A]=a),this.createMesh(A,C)})}addGeometries(e){const t=this.object3d,n=D([t.geometry,...e]);t.geometry=n}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const st=u=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:i,maxAnisotropy:a}=u;return new Promise(m=>{const r=n?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};r.onload=()=>{const f=i,o=document.createElement("canvas"),l=o.getContext("2d");o.height=r.height/(1-f),o.width=r.width,f&&e&&(l.fillStyle=e,l.fillRect(0,0,r.width,o.height*f)),n&&r instanceof HTMLImageElement?l.drawImage(r,0,o.height*f,r.width,r.height):t&&(l.fillStyle=t,l.fillRect(0,o.height*f,r.width,r.height)),s&&o.toBlob(d=>{console.log(URL.createObjectURL(d))});const b=new c.CanvasTexture(o);m(b)},n?r.src=n:r instanceof HTMLImageElement||r.onload()})};class ot extends P.BaseObject{create(){this.createGroup()}}class it extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,i,a,m,r,f,o,l,b,d,y,C,A,M,B;const e=this.options;if(e.type==="AmbientLight"){const S=new c.AmbientLight(e.color);S.name="环境光",this.object3d=S}else if(e.type==="DirectionalLight"){const S=new c.DirectionalLight(e.color,e.intensity);S.name="平行光",S.target.position.set(0,0,0),this.object3d=S,S.target.name="平行光目标",S.shadow.camera.name="平行光阴影相机",S.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=S}else if(e.type==="PointLight"){const S=new c.PointLight((t=e.color)!=null?t:16777215,(n=e.intensity)!=null?n:1,(s=e.distance)!=null?s:0,(i=e.decay)!=null?i:2);S.name="点光源",this.object3d=S,this.pointLight=S}else if(e.type==="SpotLight"){const S=new c.SpotLight((a=e.color)!=null?a:16777215,(m=e.intensity)!=null?m:1,(r=e.distance)!=null?r:0,(f=e.angle)!=null?f:Math.PI/3,(o=e.penumbra)!=null?o:1,(l=e.decay)!=null?l:2);S.name="聚光灯",this.object3d=S,this.spotLight=S,S.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const S=new c.HemisphereLight((b=e.color)!=null?b:16777215,(d=e.groundColor)!=null?d:16777215,(y=e.intensity)!=null?y:1);S.name="半球光",this.object3d=S,this.hemisphereLight=S}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Fe.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const S=new c.RectAreaLight((C=e.color)!=null?C:16777215,(A=e.intensity)!=null?A:1,(M=e.width)!=null?M:10,(B=e.height)!=null?B:10);S.name="矩形区域光",this.object3d=S,this.rectAreaLight=S}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const n=this.spotLight||this.directionalLight;n.position.copy(t),n.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()}}class Ue extends c.BufferGeometry{constructor(e=[],t="none",n){super(),this.type="MeshLineGeometry",this.pointCount=0,this._points=[],this.shape="none",this.shapeFunction=s=>1,this.matrixWorld=new c.Matrix4,this.shape=t,n&&(this.shapeFunction=n),e.length>0&&this.setPoints(e)}convertToVector3Array(e){if(typeof e[0]=="number"){const t=[],n=e;for(let s=0;s<n.length;s+=3)t.push(new c.Vector3(n[s],n[s+1],n[s+2]));return t}else return e.map(t=>{if(t instanceof c.Vector2)return new c.Vector3(t.x,t.y,0);if(t instanceof c.Vector3)return t;if(Array.isArray(t)&&t.length===2)return new c.Vector3(t[0],t[1],0);if(Array.isArray(t)&&t.length===3)return new c.Vector3(t[0],t[1],t[2])}).filter(Boolean)}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){!e||e.length===0||(this._points=this.convertToVector3Array(e),this.pointCount=this._points.length,t&&(this.shapeFunction=t,this.shape="custom"),this.initializeGeometry(),this.updateGeometry())}initializeGeometry(){const e=new c.BufferAttribute(new Float32Array(this.pointCount*6),3),t=new c.BufferAttribute(new Float32Array(this.pointCount*6),3),n=new c.BufferAttribute(new Float32Array(this.pointCount*6),3),s=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),i=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),a=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),m=new c.BufferAttribute(new Float32Array(this.pointCount*4),2),r=new c.BufferAttribute(new Uint16Array((this.pointCount-1)*6),1);this.shape==="taper"&&(this.shapeFunction=f=>1*Math.pow(4*f*(1-f),1));for(let f=0,o=0,l=0;f<this.pointCount;f+=1,o+=2,l+=6){s.setX(o,f/this.pointCount),s.setX(o+1,f/this.pointCount),i.setX(o,1),i.setX(o+1,-1);const b=this.shape==="none"?1:this.shapeFunction(f/(this.pointCount-1));a.setX(o,b),a.setX(o+1,b);const d=f/(this.pointCount-1);if(m.setXY(o,d,0),m.setXY(o+1,d,1),f<this.pointCount-1){const y=f*2;r.setX(l+0,y+0),r.setX(l+1,y+1),r.setX(l+2,y+2),r.setX(l+3,y+2),r.setX(l+4,y+1),r.setX(l+5,y+3)}}this.setAttribute("position",e),this.setAttribute("previous",t),this.setAttribute("next",n),this.setAttribute("counters",s),this.setAttribute("side",i),this.setAttribute("width",a),this.setAttribute("uv",m),this.setIndex(r)}updateGeometry(){if(!this._points[0])return;const e=this.getAttribute("position"),t=this.getAttribute("previous"),n=this.getAttribute("next");let s=0,i=0,a=0;const m=this._points[0];t.setXYZ(i,m.x,m.y,m.z),i+=1,t.setXYZ(i,m.x,m.y,m.z),i+=1;for(let f=0;f<this.pointCount;f++){const o=this._points[f];e.setXYZ(s,o.x,o.y,o.z),s+=1,e.setXYZ(s,o.x,o.y,o.z),s+=1,f<this.pointCount-1&&(t.setXYZ(i,o.x,o.y,o.z),i+=1,t.setXYZ(i,o.x,o.y,o.z),i+=1),f>0&&f+1<=this.pointCount&&(n.setXYZ(a,o.x,o.y,o.z),a+=1,n.setXYZ(a,o.x,o.y,o.z),a+=1)}const r=this._points[this.pointCount-1];n.setXYZ(a,r.x,r.y,r.z),a+=1,n.setXYZ(a,r.x,r.y,r.z),a+=1,e.needsUpdate=!0,t.needsUpdate=!0,n.needsUpdate=!0,this.computeBoundingSphere(),this.computeBoundingBox()}get points(){return this._points}set points(e){this.setPoints(e)}updatePoints(e,t){const n=this.convertToVector3Array(e);if(n.length!==this.pointCount){console.warn("MeshLineGeometry: Cannot update points with different length. Use setPoints() instead.");return}this._points=n,t&&(this.shapeFunction=t,this.shape="custom",this.initializeGeometry()),this.updateGeometry()}setShape(e,t){this.shape=e,t&&(this.shapeFunction=t),this._points.length>0&&(this.initializeGeometry(),this.updateGeometry())}}function rt(u,e){const t=new c.Matrix4,n=new c.Ray,s=new c.Sphere,i=new c.Vector3,a=this.geometry;if(s.copy(a.boundingSphere),s.applyMatrix4(this.matrixWorld),!u.ray.intersectSphere(s,i))return;t.copy(this.matrixWorld).invert(),n.copy(u.ray).applyMatrix4(t);const m=new c.Vector3,r=new c.Vector3,f=new c.Vector3,o=this instanceof c.LineSegments?2:1,l=a.index,b=a.attributes;if(l!==null){const d=l.array,y=b.position.array,C=b.width.array;for(let A=0,M=d.length-1;A<M;A+=o){const B=d[A],S=d[A+1];m.fromArray(y,B*3),r.fromArray(y,S*3);const V=C[Math.floor(A/3)]!==void 0?C[Math.floor(A/3)]:1,Q=u.params.Line.threshold+this.material.lineWidth*V/2,H=Q*Q;if(n.distanceSqToSegment(m,r,i,f)>H)continue;i.applyMatrix4(this.matrixWorld);const U=u.ray.origin.distanceTo(i);U<u.near||U>u.far||(e.push({distance:U,point:f.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=M)}}}const me=u=>{const{setPointWidth:e,nodes:t}=u,n=new Ue;return n.setPoints(t,e),n};let at=class extends P.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return se(this,null,function*(){const{nodes:e,nodesArr:t,geometry:n,geometryArr:s,material:i,useGroups:a,setPointWidth:m,lineWidthArr:r,materialParameters:f}=this.options;let o=i,l=n;!o&&f&&(o=this.getMaterial(f)),!l&&e?l=me({nodes:e,setPointWidth:m}):!l&&t?l=D(t.map((b,d)=>{let y=m;return!y&&r&&(y=()=>{var C;return(C=r[d])!=null?C:r[0]}),me({nodes:b,setPointWidth:y})}),a!=null?a:0):!l&&s&&s.length>1?l=D(s,a!=null?a:0):!l&&s&&s.length===1&&([l]=s),this.createMesh(l,o)})}setGeometry(e,t){const n=me({nodes:e,setPointWidth:t}),s=this.object3d,i=s.geometry;s.geometry=n,i.dispose()}getMaterial(e){const{width:t,height:n}=this.pencil.getSize(),s=new P.MeshLineMaterial(E({color:new c.Color("#ffffff")},e));return s.uniforms.resolution.value.set(t,n),s}addGeometries(e){const t=this.object3d,n=D([t.geometry,...e]);t.geometry=n}resize(e,t){var n,s;(s=(n=this.material)==null?void 0:n.uniforms)==null||s.resolution.value.set(e,t)}handleMaterialChange(e){if(e){const{width:t,height:n}=this.pencil.getSize();this.resize(t,n)}}animate({duration:e=1e3,delay:t=0,repeat:n=0,lineLoop:s,onRepeat:i,onUpdate:a,onComplete:m,startShow:r}={}){const{offset:f,offsetLoop:o}=this.material.uniforms;if(this.material.userData.tween)return;const l=s!=null?s:!0;f.value.x=1,o.value=l&&r?1:0;let b=0;const d=new ee.Tween(f.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:y})=>{l&&y<=0&&o.value===0&&(o.value=1),a&&a(y)}).onRepeat(()=>{b+=1,i&&i(b)}).onComplete(()=>{m&&m()}).start();this.material.userData.tween=d}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),ee.remove(this.material.userData.tween)),super.dispose()}};const ze=u=>{const{points:e}=u,t=e.reduce((s,i,a)=>(a<e.length-1&&s.push(i,e[a+1]),s),[]);return new c.BufferGeometry().setFromPoints(t)};class ct extends P.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return se(this,null,function*(){const{points:e,pointsArr:t,geometry:n,geometryArr:s,material:i,useGroups:a,setPointWidth:m,lineWidthArr:r,materialParameters:f,instanceCount:o}=this.options;let l=i,b=n;!l&&f&&(l=this.getMaterial(f)),!b&&e?b=ze({points:e}):!b&&t?b=D(t.map(y=>ze({points:y})),a!=null?a:0):!b&&s&&s.length>1?b=D(s,a!=null?a:0):!b&&s&&s.length===1&&([b]=s);const d=new Ie.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(b));if(this.pencil.options.WebGPUTHREE){o&&(d.instanceCount=o);const y=new P.LineSegments2(d,l);y.computeLineDistances(),this.object3d=y}else{const y=new Ze.LineSegments2(d,l);y.computeLineDistances(),this.object3d=y}})}getMaterial(e){return new Oe.LineMaterial(E({color:new c.Color("#ffffff")},e))}}class lt extends P.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=E({type:"2d"},e)}create(){const{position:e,children:t}=this.options,n=document.createElement("div");this.element=n,t&&n.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(n):this.options.type==="3dSprite"?this.createCSS3DSprite(n):this.createCSS2DObject(n),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(),n=window.innerWidth,s=window.innerHeight;let i=0,a=0;t.left<0?i=-t.left:t.right>n&&(i=n-t.right),t.top<0?a=-t.top:t.bottom>s&&(a=s-t.bottom),t.left+i<0&&(i=-t.left),t.top+a<0&&(a=-t.top),(i!==0||a!==0)&&(e.style.transform=`translate(${i}px, ${a}px)`)}ensureVisible(){const e=this.options.children;if(!e)return;e.style.transform&&(e.style.transform="");const t=new IntersectionObserver(n=>{n.forEach(s=>{s.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)}onPointerEvent(e,t){const n=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(n)}dispose(){this.onNodePointerIndex.forEach(e=>{this.lead.removePickNode(e)}),super.dispose()}}class ht extends P.BaseObject{constructor(e){super(),this.options=E({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return se(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:n,material:s,percentDepth:i,activeIndex:a}=this.options,m=Math.max(...e),r=e.reduce((o,l)=>o+l,0);let f=Math.PI/2;e.forEach((o,l)=>{if(o===0)return;const b=Math.PI*2*(o/r),d=n[l],y=i?t*(o/m):t,C=this.createGeometry(y,b),A=s?s.clone():new c.MeshBasicMaterial({color:d});s&&A.color.set(d);const M=new c.Mesh(C,A);M.userData.depth=y,M.userData.index=l,M.rotateZ(f),f+=b,this.add(M)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,i=new c.Shape;return i.moveTo(n,0),i.lineTo(s,0),i.absarc(0,0,s,0,t,!1),i.absarc(0,0,n,t,0,!0),new J(i,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:n}=this.pencil.pick(e,this.object3d.children)||{},s=n?this.object3d.children.findIndex(i=>i===n):this.options.activeIndex;return this.setActive(s,t)}setActive(e,t=1.3){const n=this.object3d.children[e];if(this.object3d.children.forEach(s=>{if(!(n&&n===s)&&s.scale.z!==1){if(s.userData.levTween)return;s.userData.enTween&&(s.userData.enTween.stop(),s.userData.enTween=null);const i=new ee.Tween(s.scale).to({z:1},100);s.userData.levTween=i,i.start()}}),n){if(n.userData.enTween)return;n.userData.levTween&&(n.userData.levTween.stop(),n.userData.levTween=null);const s=new ee.Tween(n.scale).to({z:t},100);return n.userData.enTween=s,s.start(),n.userData.index}return-1}render(){this.object3d.scale.z=0,new ee.Tween(this.object3d.scale).to({z:1},1e3).easing(ee.Easing.Sinusoidal.InOut).start()}}Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>Oe.LineMaterial});Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ie.LineSegmentsGeometry});exports.MeshLineMaterial=P.MeshLineMaterial;exports.getConicPolygonGeometry=P.PolygonGeometry;exports.getConicPolygonGeometryMetas=P.getMetas;exports.ConicPolygon=Je;exports.ExtrudePolygon=nt;exports.Group=ot;exports.Light=it;exports.Line=at;exports.Line2=ct;exports.MeshLineGeometry=Ue;exports.MeshLineRaycast=rt;exports.Node=lt;exports.Pie=ht;exports.getSplitTexture=st;