gl-draw 0.17.0-beta.37 → 0.17.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cartographicToCartesian.js +1 -1
- package/dist/cartographicToCartesian.module.js +29 -29
- package/dist/objects/ellipsoid/createGeometry.d.ts +2 -2
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +359 -359
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var U=Math.pow;const o=require("three"),R=t=>t instanceof o.Vector3?t:new o.Vector3(...t),w=t=>t instanceof o.Vector2?t:new o.Vector2(...t),e={a:6378137,b:6356752314245179e-9,f:1/298.257223563};function x(t,p,u=0,n=1/e.a,h=!1){const s=o.MathUtils.degToRad(t),r=o.MathUtils.degToRad(p),c=Math.cos(r),i=Math.sin(r),d=Math.cos(s),T=Math.sin(s);let q,M,l;if(h){const a=(e.a+u)*n;q=a*c*T,M=a*i,l=a*c*d}else{const g=e.a,a=e.b,V=g*g,S=a*a,b=(V-S)/V,f=g/Math.sqrt(1-b*i*i);q=(f+u)*c*T*n,M=(f*(1-b)+u)*i*n,l=(f+u)*c*d*n}return new o.Vector3(q,M,l)}function y(t,p=1/e.a,u=!1){const n=t.x/p,h=t.y/p,s=t.z/p;if(u){const f=Math.sqrt(n*n+h*h+s*s),L=Math.atan2(n,s),C=Math.asin(h/f),D=f-e.a;return{longitude:o.MathUtils.radToDeg(L),latitude:o.MathUtils.radToDeg(C),height:D}}const r=e.a,c=e.b,i=r*r,d=c*c,T=(i-d)/i,q=(i-d)/d,M=Math.sqrt(n*n+s*s),l=Math.atan2(h*r,M*c),g=Math.atan2(n,s),a=Math.atan2(h+q*c*U(Math.sin(l),3),M-T*r*U(Math.cos(l),3)),V=Math.sin(a),S=r/Math.sqrt(1-T*V*V),b=M/Math.cos(a)-S;return{longitude:o.MathUtils.radToDeg(g),latitude:o.MathUtils.radToDeg(a),height:b}}exports.WGS84=e;exports.cartesianToCartographic=y;exports.cartographicToCartesian=x;exports.parseVector2=w;exports.parseVector3=R;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
import { Vector3 as
|
|
3
|
-
const
|
|
1
|
+
var x = Math.pow;
|
|
2
|
+
import { Vector3 as D, Vector2 as R, MathUtils as l } from "three";
|
|
3
|
+
const C = (t) => t instanceof D ? t : new D(...t), N = (t) => t instanceof R ? t : new R(...t), r = {
|
|
4
4
|
a: 6378137,
|
|
5
5
|
// 赤道半径
|
|
6
6
|
b: 6356752314245179e-9,
|
|
@@ -8,42 +8,42 @@ const X = (t) => t instanceof V ? t : new V(...t), Y = (t) => t instanceof w ? t
|
|
|
8
8
|
f: 1 / 298.257223563
|
|
9
9
|
// 扁率
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
let q,
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
q =
|
|
11
|
+
function W(t, p, d = 0, n = 1 / r.a, i = !1) {
|
|
12
|
+
const a = l.degToRad(t), c = l.degToRad(p), s = Math.cos(c), e = Math.sin(c), M = Math.cos(a), b = Math.sin(a);
|
|
13
|
+
let q, h, u;
|
|
14
|
+
if (i) {
|
|
15
|
+
const o = (r.a + d) * n;
|
|
16
|
+
q = o * s * b, h = o * e, u = o * s * M;
|
|
17
17
|
} else {
|
|
18
|
-
const
|
|
19
|
-
q =
|
|
18
|
+
const f = r.a, o = r.b, T = f * f, S = o * o, L = (T - S) / T, g = f / Math.sqrt(1 - L * e * e);
|
|
19
|
+
q = (g + d) * s * b * n, h = (g * (1 - L) + d) * e * n, u = (g + d) * s * M * n;
|
|
20
20
|
}
|
|
21
|
-
return new
|
|
21
|
+
return new D(q, h, u);
|
|
22
22
|
}
|
|
23
|
-
function G(t,
|
|
24
|
-
const
|
|
23
|
+
function G(t, p = 1 / r.a, d = !1) {
|
|
24
|
+
const n = t.x / p, i = t.y / p, a = t.z / p;
|
|
25
25
|
if (d) {
|
|
26
|
-
const
|
|
26
|
+
const g = Math.sqrt(n * n + i * i + a * a), V = Math.atan2(n, a), w = Math.asin(i / g), y = g - r.a;
|
|
27
27
|
return {
|
|
28
|
-
longitude:
|
|
29
|
-
latitude:
|
|
30
|
-
height:
|
|
28
|
+
longitude: l.radToDeg(V),
|
|
29
|
+
latitude: l.radToDeg(w),
|
|
30
|
+
height: y
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
),
|
|
33
|
+
const c = r.a, s = r.b, e = c * c, M = s * s, b = (e - M) / e, q = (e - M) / M, h = Math.sqrt(n * n + a * a), u = Math.atan2(i * c, h * s), f = Math.atan2(n, a), o = Math.atan2(
|
|
34
|
+
i + q * s * x(Math.sin(u), 3),
|
|
35
|
+
h - b * c * x(Math.cos(u), 3)
|
|
36
|
+
), T = Math.sin(o), S = c / Math.sqrt(1 - b * T * T), L = h / Math.cos(o) - S;
|
|
37
37
|
return {
|
|
38
|
-
longitude:
|
|
39
|
-
latitude:
|
|
40
|
-
height:
|
|
38
|
+
longitude: l.radToDeg(f),
|
|
39
|
+
latitude: l.radToDeg(o),
|
|
40
|
+
height: L
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
r as W,
|
|
45
|
+
N as a,
|
|
46
46
|
G as b,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
W as c,
|
|
48
|
+
C as p
|
|
49
49
|
};
|
|
@@ -23,8 +23,8 @@ interface EllipsoidGeometryOptions {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* 创建 WGS84 椭球体几何体
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* 使用与 polar2Cartesian 一致的坐标系:
|
|
27
|
+
* x = cos(lat) * sin(lon), y = sin(lat), z = cos(lat) * cos(lon)
|
|
28
28
|
*/
|
|
29
29
|
export default function createEllipsoidGeometry(options?: EllipsoidGeometryOptions): BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>;
|
|
30
30
|
export {};
|
package/dist/objects/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ye=Object.defineProperty,Ze=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var Pe=(d,e,t)=>e in d?Ye(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t,W=(d,e)=>{for(var t in e||(e={}))Ve.call(e,t)&&Pe(d,t,e[t]);if(de)for(var t of de(e))_e.call(e,t)&&Pe(d,t,e[t]);return d},me=(d,e)=>Ze(d,$e(e));var ye=(d,e)=>{var t={};for(var n in d)Ve.call(d,n)&&e.indexOf(n)<0&&(t[n]=d[n]);if(d!=null&&de)for(var n of de(d))e.indexOf(n)<0&&_e.call(d,n)&&(t[n]=d[n]);return t};var ce=(d,e,t)=>new Promise((n,s)=>{var r=i=>{try{m(t.next(i))}catch(u){s(u)}},c=i=>{try{m(t.throw(i))}catch(u){s(u)}},m=i=>i.done?n(i.value):Promise.resolve(i.value).then(r,c);m((t=t.apply(d,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qe=require("three/examples/jsm/lines/LineMaterial"),De=require("three/examples/jsm/lines/LineSegmentsGeometry"),z=require("../index2.js"),a=require("three"),be=require("three/examples/jsm/utils/BufferGeometryUtils"),xe=require("../cartographicToCartesian.js"),ze=require("../uvGenerator.js"),pe=require("three-bvh-csg"),Je=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),Qe=require("@tweenjs/tween.js"),Ke=require("three/examples/jsm/lines/LineSegments2");function et(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const ie=et(Qe);function N(d,e=0){const t=d[0].index!==null,n=new Set(Object.keys(d[0].attributes)),s=new Set(Object.keys(d[0].morphAttributes)),r={},c={},m=d[0].morphTargetsRelative,i=new a.BufferGeometry;let u=0;for(let o=0;o<d.length;++o){const l=d[o];let y=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 f in l.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(l.attributes[f]),y++}if(y!==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 f in l.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphAttributes must be consistent throughout all geometries."),null;c[f]===void 0&&(c[f]=[]),c[f].push(l.morphAttributes[f])}if(e){let f;if(t)f=l.index.count;else if(l.attributes.position!==void 0)f=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)i.addGroup(u,f,o);else if(e===2&&l.groups.length>0)for(let b of l.groups){let L=b.materialIndex;i.addGroup(u+b.start,Math.min(b.count,f),L)}u+=f}}if(t){let o=0;const l=[];for(let y=0;y<d.length;++y){const f=d[y].index;for(let b=0;b<f.count;++b)l.push(f.getX(b)+o);o+=d[y].attributes.position.count}i.setIndex(l)}for(const o in r){const l=be.mergeAttributes(r[o]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" attribute."),null;i.setAttribute(o,l)}for(const o in c){const l=c[o][0].length;if(l===0)break;i.morphAttributes=i.morphAttributes||{},i.morphAttributes[o]=[];for(let y=0;y<l;++y){const f=[];for(let L=0;L<c[o].length;++L)f.push(c[o][L][y]);const b=be.mergeAttributes(f);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" morphAttribute."),null;i.morphAttributes[o].push(b)}}return e===2?be.mergeGroups(i):i}const Oe=d=>{const m=d,{coordinate:e,startHeight:t,height:n}=m,s=ye(m,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(r=t+n),new z.PolygonGeometry([e],me(W({},s),{startHeight:t,endHeight:r}))};class tt extends z.BaseObject{constructor(e){super(),this.options=W({},e)}create(){const i=this.options,{geometry:e,coordinateArr:t,coordinate:n,material:s,useGroups:r}=i,c=ye(i,["geometry","coordinateArr","coordinate","material","useGroups"]);let m=e;if(!m&&n)m=Oe(W({coordinate:n},c));else if(!m&&t){const u=t.map(o=>Oe(W({coordinate:o},c)));m=N(u,r!=null?r:0)}this.createMesh(m,s)}}function nt(d={}){const{a:e=xe.WGS84.a,b:t=xe.WGS84.b,scaleFactor:n=1/xe.WGS84.a,widthSegments:s=64,heightSegments:r=32}=d,c=new a.BufferGeometry,m=[],i=[],u=[],o=[],l=e*e,y=t*t,f=(l-y)/l;let b=0;const L=[];for(let v=0;v<=r;v++){const S=[],C=v/r,E=(.5-C)*180*Math.PI/180,O=Math.sin(E),I=Math.cos(E),H=e/Math.sqrt(1-f*O*O);for(let P=0;P<=s;P++){const Z=P/s,X=(Z-.5)*360*Math.PI/180,re=Math.sin(X),V=Math.cos(X),_=H*I*V*n,ve=H*I*re*n,le=H*(1-f)*O*n,ae=_,R=le,$=ve;i.push(ae,R,$);const U=I*V/e,oe=O*(1-f)/t,J=I*re/e,K=Math.sqrt(U*U+oe*oe+J*J);u.push(U/K,oe/K,J/K),o.push(Z,1-C),S.push(b++)}L.push(S)}for(let v=0;v<r;v++)for(let S=0;S<s;S++){const C=L[v][S+1],A=L[v][S],E=L[v+1][S],O=L[v+1][S+1];m.push(C,A,O),m.push(A,E,O)}return c.setIndex(m),c.setAttribute("position",new a.Float32BufferAttribute(i,3)),c.setAttribute("normal",new a.Float32BufferAttribute(u,3)),c.setAttribute("uv",new a.Float32BufferAttribute(o,2)),c}class st extends z.BaseObject{constructor(e={}){super(),this.options=e}create(){const e=nt(this.options),t=this.options.material||new a.MeshStandardMaterial({color:2200782,metalness:.1,roughness:.7,wireframe:!1}),n=new a.Mesh(e,t);return n.name="Ellipsoid",this.object3d=n,n}}const ot={ArcCurve:a.ArcCurve,CatmullRomCurve3:a.CatmullRomCurve3,CubicBezierCurve:a.CubicBezierCurve,CubicBezierCurve3:a.CubicBezierCurve3,EllipseCurve:a.EllipseCurve,LineCurve:a.LineCurve,LineCurve3:a.LineCurve3,QuadraticBezierCurve:a.QuadraticBezierCurve,QuadraticBezierCurve3:a.QuadraticBezierCurve3,SplineCurve:a.SplineCurve};class ne 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 n=this,s=[],r=[];for(let m=0,i=e.length;m<i;m++){const u=e[m];c(u)}this.setAttribute("position",new a.Float32BufferAttribute(s,3)),this.setAttribute("uv",new a.Float32BufferAttribute(r,2)),this.computeVertexNormals();function c(m){var Me,Le,Ge;const i=[],u=t.curveSegments!==void 0?t.curveSegments:12,o=t.steps!==void 0?t.steps:1,l=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:f-.1,L=t.bevelOffset!==void 0?t.bevelOffset:0,v=t.bevelSegments!==void 0?t.bevelSegments:3;const S=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:it,A=(Me=t.hasTop)!=null?Me:!0,E=(Le=t.hasBottom)!=null?Le:!0,O=(Ge=t.hasSide)!=null?Ge:!0;let I,H=!1,P,Z,se,X;S&&(I=S.getSpacedPoints(o),H=!0,y=!1,P=S.computeFrenetFrames(o,!1),Z=new a.Vector3,se=new a.Vector3,X=new a.Vector3),y||(v=0,f=0,b=0,L=0);const re=m.extractPoints(u);let V=re.shape;const _=re.holes;if(!a.ShapeUtils.isClockWise(V)){V=V.reverse();for(let h=0,p=_.length;h<p;h++){const g=_[h];a.ShapeUtils.isClockWise(g)&&(_[h]=g.reverse())}}function le(h){const g=10000000000000001e-36;let w=h[0];for(let x=1;x<=h.length;x++){const G=x%h.length,M=h[G],T=M.x-w.x,B=M.y-w.y,j=T*T+B*B,q=Math.max(Math.abs(M.x),Math.abs(M.y),Math.abs(w.x),Math.abs(w.y)),te=g*q*q;if(j<=te){h.splice(G,1),x--;continue}w=M}}le(V),_.forEach(le);const ae=_.length,R=V;for(let h=0;h<ae;h++){const p=_[h];V=V.concat(p)}function $(h,p,g){return p||error("ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(p,g)}const U=V.length;function oe(h,p,g){let w,x,G;const M=h.x-p.x,T=h.y-p.y,B=g.x-h.x,j=g.y-h.y,q=M*M+T*T,te=M*j-T*B;if(Math.abs(te)>Number.EPSILON){const D=Math.sqrt(q),Te=Math.sqrt(B*B+j*j),Be=p.x-T/D,Ce=p.y+M/D,Fe=g.x-j/Te,ke=g.y+B/Te,je=((Fe-Be)*j-(ke-Ce)*B)/(M*j-T*B);w=Be+M*je-h.x,x=Ce+T*je-h.y;const Ee=w*w+x*x;if(Ee<=2)return new a.Vector2(w,x);G=Math.sqrt(Ee/2)}else{let D=!1;M>Number.EPSILON?B>Number.EPSILON&&(D=!0):M<-Number.EPSILON?B<-Number.EPSILON&&(D=!0):Math.sign(T)===Math.sign(j)&&(D=!0),D?(w=-T,x=M,G=Math.sqrt(q)):(w=M,x=T,G=Math.sqrt(q/2))}return new a.Vector2(w/G,x/G)}const J=[];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),J[h]=oe(R[h],R[g],R[w]);const K=[];let Q,he=J.concat();for(let h=0,p=ae;h<p;h++){const g=_[h];Q=[];for(let w=0,x=g.length,G=x-1,M=w+1;w<x;w++,G++,M++)G===x&&(G=0),M===x&&(M=0),Q[w]=oe(g[w],g[G],g[M]);K.push(Q),he=he.concat(Q)}let ee;if(v===0)ee=a.ShapeUtils.triangulateShape(R,_);else{const h=[],p=[];for(let g=0;g<v;g++){const w=g/v,x=f*Math.cos(w*Math.PI/2),G=b*Math.sin(w*Math.PI/2)+L;for(let M=0,T=R.length;M<T;M++){const B=$(R[M],J[M],G);F(B.x,B.y,-x),w===0&&h.push(B)}for(let M=0,T=ae;M<T;M++){const B=_[M];Q=K[M];const j=[];for(let q=0,te=B.length;q<te;q++){const D=$(B[q],Q[q],G);F(D.x,D.y,-x),w===0&&j.push(D)}w===0&&p.push(j)}}ee=a.ShapeUtils.triangulateShape(h,p)}const ue=ee.length,Se=b+L;for(let h=0;h<U;h++){const p=y?$(V[h],he[h],Se):V[h];H?(se.copy(P.normals[0]).multiplyScalar(p.x),Z.copy(P.binormals[0]).multiplyScalar(p.y),X.copy(I[0]).add(se).add(Z),F(X.x,X.y,X.z)):F(p.x,p.y,0)}for(let h=1;h<=o;h++)for(let p=0;p<U;p++){const g=y?$(V[p],he[p],Se):V[p];H?(se.copy(P.normals[h]).multiplyScalar(g.x),Z.copy(P.binormals[h]).multiplyScalar(g.y),X.copy(I[h]).add(se).add(Z),F(X.x,X.y,X.z)):F(g.x,g.y,l/o*h)}for(let h=v-1;h>=0;h--){const p=h/v,g=f*Math.cos(p*Math.PI/2),w=b*Math.sin(p*Math.PI/2)+L;for(let x=0,G=R.length;x<G;x++){const M=$(R[x],J[x],w);F(M.x,M.y,l+g)}for(let x=0,G=_.length;x<G;x++){const M=_[x];Q=K[x];for(let T=0,B=M.length;T<B;T++){const j=$(M[T],Q[T],w);H?F(j.x,j.y+I[o-1].y,I[o-1].x+g):F(j.x,j.y,l+g)}}}Xe(),O&&He();function Xe(){const h=s.length/3;if(y){let p=0,g=U*p;if(E)for(let w=0;w<ue;w++){const x=ee[w];fe(x[2]+g,x[1]+g,x[0]+g)}if(p=o+v*2,g=U*p,A)for(let w=0;w<ue;w++){const x=ee[w];fe(x[0]+g,x[1]+g,x[2]+g)}}else{if(E)for(let p=0;p<ue;p++){const g=ee[p];fe(g[2],g[1],g[0])}if(A)for(let p=0;p<ue;p++){const g=ee[p];fe(g[0]+U*o,g[1]+U*o,g[2]+U*o)}}n.addGroup(h,s.length/3-h,0)}function He(){const h=s.length/3;let p=0;Ae(R,p),p+=R.length;for(let g=0,w=_.length;g<w;g++){const x=_[g];Ae(x,p),p+=x.length}n.addGroup(h,s.length/3-h,1)}function Ae(h,p){let g=h.length;for(;--g>=0;){const w=g;let x=g-1;x<0&&(x=h.length-1);for(let G=0,M=o+v*2;G<M;G++){const T=U*G,B=U*(G+1),j=p+w+T,q=p+x+T,te=p+x+B,D=p+w+B;Ne(j,q,te,D)}}}function F(h,p,g){i.push(h),i.push(p),i.push(g)}function fe(h,p,g){k(h),k(p),k(g);const w=s.length/3,x=C.generateTopUV(n,s,w-3,w-2,w-1);Y(x[0]),Y(x[1]),Y(x[2])}function Ne(h,p,g,w){k(h),k(p),k(w),k(p),k(g),k(w);const x=s.length/3,G=C.generateSideWallUV(n,s,x-6,x-3,x-2,x-1);Y(G[0]),Y(G[1]),Y(G[3]),Y(G[1]),Y(G[2]),Y(G[3])}function k(h){s.push(i[h*3+0]),s.push(i[h*3+1]),s.push(i[h*3+2])}function Y(h){r.push(h.x),r.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 rt(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,c=e.shapes.length;r<c;r++){const m=t[e.shapes[r]];n.push(m)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new ot[s.type]().fromJSON(s)),new ne(n,e.options)}}const it={generateTopUV:function(d,e,t,n,s){const r=e[t*3],c=e[t*3+1],m=e[n*3],i=e[n*3+1],u=e[s*3],o=e[s*3+1];return[new a.Vector2(r,c),new a.Vector2(m,i),new a.Vector2(u,o)]},generateSideWallUV:function(d,e,t,n,s,r){const c=e[t*3],m=e[t*3+1],i=e[t*3+2],u=e[n*3],o=e[n*3+1],l=e[n*3+2],y=e[s*3],f=e[s*3+1],b=e[s*3+2],L=e[r*3],v=e[r*3+1],S=e[r*3+2];return Math.abs(m-o)<Math.abs(c-u)?[new a.Vector2(c,1-i),new a.Vector2(u,1-l),new a.Vector2(y,1-b),new a.Vector2(L,1-S)]:[new a.Vector2(m,1-i),new a.Vector2(o,1-l),new a.Vector2(f,1-b),new a.Vector2(v,1-S)]}};function rt(d,e,t){if(t.shapes=[],Array.isArray(d))for(let n=0,s=d.length;n<s;n++){const r=d[n];t.shapes.push(r.uuid)}else t.shapes.push(d.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class at extends ne{constructor(e,t){super(e,t);const n=new pe.Brush(new ne(e,me(W({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));n.updateMatrixWorld();const s=new a.Box3().setFromObject(n),r=new a.Vector3;s.getSize(r);const c=new a.Vector3(s.min.x+r.x/2,s.min.y+r.y/2,0);let m=t.topSegments,i=t.box3;if(i){i=i.union(s);const S=new a.Vector3;i.getSize(S);const C=Math.max(r.x/S.x,r.y/S.y);m=Math.ceil(t.topSegments*C)}if(m<4)return this;const u=new a.PlaneGeometry(r.x,r.y,m,m),o=new pe.Brush(u);o.position.set(c.x,c.y,c.z),o.updateMatrixWorld();const y=new pe.Evaluator().evaluate(o,n,pe.INTERSECTION),f=y.geometry.getAttribute("position"),b=new a.Float32BufferAttribute(f.count*2,2);for(let S=0;S<f.count;S++){const C=f.getZ(S);f.setZ(S,t.depth+C)}if(i){const S=i.min,C=i.max,A=new a.Vector3().subVectors(C,S);for(let E=0;E<f.count;E++){const O=f.getX(E),I=f.getY(E),H=(O-S.x)/A.x,P=(I-S.y)/A.y;b.setXY(E,H,P)}y.geometry.setAttribute("uv",b)}f.needsUpdate=!0;const L=new ne(e,me(W({},t),{hasTop:!1})),v=N([y.geometry,L],2);this.copy(v.toNonIndexed())}}const Ie=d=>{const{split:e,depth:t,points:n,box3:s,hasTop:r,hasBottom:c,hasSide:m,sideRepeat:i,topSegments:u}=d,o=u?at:ne,l=new o(new a.Shape(n),{depth:t,bevelEnabled:!1,box3:s,UVGenerator:ze.getUVGenerator({split:e,box3:s,sideRepeat:i}),hasTop:r,hasBottom:c,hasSide:m,topSegments:u});return ze.claerUVGenerator(),l};class ct extends z.BaseObject{constructor(e){super(),this.options=W({depth:1},e)}create(){return ce(this,null,function*(){const{points:e,pointsArr:t,useGroups:n,depth:s,geometry:r,geometryArr:c,material:m,box3:i,split:u,hasTop:o,hasBottom:l,hasSide:y}=this.options,f=Array.isArray(s)?s:[s],b=Array.isArray(i)?i:[i],L=m;let v=r;L||console.log("material is null"),!v&&e?v=Ie({points:e,depth:f[0],box3:b[0],split:u,hasTop:o,hasBottom:l,hasSide:y}):!v&&t?v=N(t.map((S,C)=>{var A,E;return Ie({points:S,depth:(A=f[C])!=null?A:f[0],box3:(E=b[C])!=null?E:b[0],split:u,hasTop:o,hasBottom:l,hasSide:y})}),n!=null?n:0):!v&&c&&c.length>1?v=N(c,n!=null?n:0):!v&&c&&c.length===1&&([v]=c),this.createMesh(v,L)})}addGeometries(e){const t=this.object3d,n=N([t.geometry,...e]);t.geometry=n}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const lt=d=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:r,maxAnisotropy:c}=d;return new Promise(m=>{const i=n?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};i.onload=()=>{const u=r,o=document.createElement("canvas"),l=o.getContext("2d");o.height=i.height/(1-u),o.width=i.width,u&&e&&(l.fillStyle=e,l.fillRect(0,0,i.width,o.height*u)),n&&i instanceof HTMLImageElement?l.drawImage(i,0,o.height*u,i.width,i.height):t&&(l.fillStyle=t,l.fillRect(0,o.height*u,i.width,i.height)),s&&o.toBlob(f=>{console.log(URL.createObjectURL(f))});const y=new a.CanvasTexture(o);m(y)},n?i.src=n:i instanceof HTMLImageElement||i.onload()})};class ht extends z.BaseObject{create(){this.createGroup()}render(){this.object3d.raycast=(e,t)=>e.intersectObjects(this.object3d.children,!0,t)}}class ut extends z.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,r,c,m,i,u,o,l,y,f,b,L,v,S,C;const e=this.options;if(e.type==="AmbientLight"){const A=new a.AmbientLight(e.color);A.name="环境光",this.object3d=A}else if(e.type==="DirectionalLight"){const A=new a.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 a.PointLight((t=e.color)!=null?t:16777215,(n=e.intensity)!=null?n:1,(s=e.distance)!=null?s:0,(r=e.decay)!=null?r:2);A.name="点光源",this.object3d=A,this.pointLight=A}else if(e.type==="SpotLight"){const A=new a.SpotLight((c=e.color)!=null?c:16777215,(m=e.intensity)!=null?m:1,(i=e.distance)!=null?i:0,(u=e.angle)!=null?u:Math.PI/3,(o=e.penumbra)!=null?o:1,(l=e.decay)!=null?l:2);A.name="聚光灯",this.object3d=A,this.spotLight=A,A.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const A=new a.HemisphereLight((y=e.color)!=null?y:16777215,(f=e.groundColor)!=null?f:16777215,(b=e.intensity)!=null?b:1);A.name="半球光",this.object3d=A,this.hemisphereLight=A}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Je.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const A=new a.RectAreaLight((L=e.color)!=null?L:16777215,(v=e.intensity)!=null?v:1,(S=e.width)!=null?S:10,(C=e.height)!=null?C: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 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 We extends a.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 a.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 a.Vector3(n[s],n[s+1],n[s+2]));return t}else return e.map(t=>{if(t instanceof a.Vector2)return new a.Vector3(t.x,t.y,0);if(t instanceof a.Vector3)return t;if(Array.isArray(t)&&t.length===2)return new a.Vector3(t[0],t[1],0);if(Array.isArray(t)&&t.length===3)return new a.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 a.BufferAttribute(new Float32Array(this.pointCount*6),3),t=new a.BufferAttribute(new Float32Array(this.pointCount*6),3),n=new a.BufferAttribute(new Float32Array(this.pointCount*6),3),s=new a.BufferAttribute(new Float32Array(this.pointCount*2),1),r=new a.BufferAttribute(new Float32Array(this.pointCount*2),1),c=new a.BufferAttribute(new Float32Array(this.pointCount*2),1),m=new a.BufferAttribute(new Float32Array(this.pointCount*4),2),i=new a.BufferAttribute(new Uint16Array((this.pointCount-1)*6),1);this.shape==="taper"&&(this.shapeFunction=u=>1*Math.pow(4*u*(1-u),1));for(let u=0,o=0,l=0;u<this.pointCount;u+=1,o+=2,l+=6){s.setX(o,u/this.pointCount),s.setX(o+1,u/this.pointCount),r.setX(o,1),r.setX(o+1,-1);const y=this.shape==="none"?1:this.shapeFunction(u/(this.pointCount-1));c.setX(o,y),c.setX(o+1,y);const f=u/(this.pointCount-1);if(m.setXY(o,f,0),m.setXY(o+1,f,1),u<this.pointCount-1){const b=u*2;i.setX(l+0,b+0),i.setX(l+1,b+1),i.setX(l+2,b+2),i.setX(l+3,b+2),i.setX(l+4,b+1),i.setX(l+5,b+3)}}this.setAttribute("position",e),this.setAttribute("previous",t),this.setAttribute("next",n),this.setAttribute("counters",s),this.setAttribute("side",r),this.setAttribute("width",c),this.setAttribute("uv",m),this.setIndex(i)}updateGeometry(){if(!this._points[0])return;const e=this.getAttribute("position"),t=this.getAttribute("previous"),n=this.getAttribute("next");let s=0,r=0,c=0;const m=this._points[0];t.setXYZ(r,m.x,m.y,m.z),r+=1,t.setXYZ(r,m.x,m.y,m.z),r+=1;for(let u=0;u<this.pointCount;u++){const o=this._points[u];e.setXYZ(s,o.x,o.y,o.z),s+=1,e.setXYZ(s,o.x,o.y,o.z),s+=1,u<this.pointCount-1&&(t.setXYZ(r,o.x,o.y,o.z),r+=1,t.setXYZ(r,o.x,o.y,o.z),r+=1),u>0&&u+1<=this.pointCount&&(n.setXYZ(c,o.x,o.y,o.z),c+=1,n.setXYZ(c,o.x,o.y,o.z),c+=1)}const i=this._points[this.pointCount-1];n.setXYZ(c,i.x,i.y,i.z),c+=1,n.setXYZ(c,i.x,i.y,i.z),c+=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 ft(d,e){const t=new a.Matrix4,n=new a.Ray,s=new a.Sphere,r=new a.Vector3,c=this.geometry;if(s.copy(c.boundingSphere),s.applyMatrix4(this.matrixWorld),!d.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),n.copy(d.ray).applyMatrix4(t);const m=new a.Vector3,i=new a.Vector3,u=new a.Vector3,o=this instanceof a.LineSegments?2:1,l=c.index,y=c.attributes;if(l!==null){const f=l.array,b=y.position.array,L=y.width.array;for(let v=0,S=f.length-1;v<S;v+=o){const C=f[v],A=f[v+1];m.fromArray(b,C*3),i.fromArray(b,A*3);const E=L[Math.floor(v/3)]!==void 0?L[Math.floor(v/3)]:1,O=d.params.Line.threshold+this.material.lineWidth*E/2,I=O*O;if(n.distanceSqToSegment(m,i,r,u)>I)continue;r.applyMatrix4(this.matrixWorld);const P=d.ray.origin.distanceTo(r);P<d.near||P>d.far||(e.push({distance:P,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:void 0,object:this}),v=S)}}}const we=d=>{const{setPointWidth:e,nodes:t}=d,n=new We;return n.setPoints(t,e),n},Re=new WeakMap,ge=new Map;let dt=class extends z.BaseObject{constructor(e={}){super(),this.options=W({},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:n,geometryArr:s,material:r,useGroups:c,setPointWidth:m,lineWidthArr:i,materialParameters:u}=this.options;let o=r,l=n;!o&&u&&(o=this.getMaterial(u)),!l&&e?l=we({nodes:e,setPointWidth:m}):!l&&t?l=N(t.map((y,f)=>{let b=m;return!b&&i&&(b=()=>{var L;return(L=i[f])!=null?L:i[0]}),we({nodes:y,setPointWidth:b})}),c!=null?c:0):!l&&s&&s.length>1?l=N(s,c!=null?c:0):!l&&s&&s.length===1&&([l]=s),this.createMesh(l,o)})}setGeometry(e,t){const n=we({nodes:e,setPointWidth:t}),s=this.object3d,r=s.geometry;s.geometry=n,r.dispose()}getMaterial(e){const{width:t,height:n}=this.pencil.getSize(),s=new z.MeshLineMaterial(W({color:new a.Color("#ffffff")},e));return s.uniforms.resolution.value.set(t,n),s}addGeometries(e){const t=this.object3d,n=N([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:r,onUpdate:c,onComplete:m,startShow:i}={}){const{offset:u,offsetLoop:o}=this.material.uniforms,l=this.pencil.userData.debugLine?ge:Re;if(l.get(this.material)&&this.stopAnimation(),e===0)return;const y=s!=null?s:!0;u.value.x=1,o.value=y&&i?1:0;let f=0;const b=new ie.Tween(u.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:L})=>{y&&L<=0&&o.value===0&&(o.value=1),c==null||c(L)}).onRepeat(()=>{f+=1,r==null||r(f)}).onComplete(()=>{m==null||m()}).start();l.set(this.material,b),this.material.addEventListener("dispose",()=>{this.stopAnimation()}),this.pencil.userData.debugLine&&console.log("animate",ge.size)}stopAnimation(){const e=this.pencil.userData.debugLine?ge:Re,t=e.get(this.material);t&&(t.stop(),ie.remove(t),e.delete(this.material),this.material.uniforms.offset.value.x=0,this.material.uniforms.offsetLoop.value=1),this.pencil.userData.debugLine&&console.log("stopAnimation",ge.size)}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}};const Ue=d=>{const{points:e}=d,t=e.reduce((s,r,c)=>(c<e.length-1&&s.push(r,e[c+1]),s),[]);return new a.BufferGeometry().setFromPoints(t)};class mt extends z.BaseObject{constructor(e={}){super(),this.options=W({},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:n,geometryArr:s,material:r,useGroups:c,setPointWidth:m,lineWidthArr:i,materialParameters:u,instanceCount:o}=this.options;let l=r,y=n;!l&&u&&(l=this.getMaterial(u)),!y&&e?y=Ue({points:e}):!y&&t?y=N(t.map(b=>Ue({points:b})),c!=null?c:0):!y&&s&&s.length>1?y=N(s,c!=null?c:0):!y&&s&&s.length===1&&([y]=s);const f=new De.LineSegmentsGeometry().fromLineSegments(new a.LineSegments(y));if(this.pencil.options.WebGPUTHREE){o&&(f.instanceCount=o);const b=new z.LineSegments2(f,l);b.computeLineDistances(),this.object3d=b}else{const b=new Ke.LineSegments2(f,l);b.computeLineDistances(),this.object3d=b}})}getMaterial(e){return new qe.LineMaterial(W({color:new a.Color("#ffffff")},e))}}class pt extends z.BaseObject{constructor(e){super(),this.options=W({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:n,material:s,percentDepth:r,activeIndex:c}=this.options,m=Math.max(...e),i=e.reduce((o,l)=>o+l,0);let u=Math.PI/2;e.forEach((o,l)=>{if(o===0)return;const y=Math.PI*2*(o/i),f=n[l],b=r?t*(o/m):t,L=this.createGeometry(b,y),v=s?s.clone():new a.MeshBasicMaterial({color:f});s&&v.color.set(f);const S=new a.Mesh(L,v);S.userData.depth=b,S.userData.index=l,S.rotateZ(u),u+=y,this.add(S)}),c!==-1&&this.setActive(c)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,r=new a.Shape;return r.moveTo(n,0),r.lineTo(s,0),r.absarc(0,0,s,0,t,!1),r.absarc(0,0,n,t,0,!0),new ne(r,{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(r=>r===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 r=new ie.Tween(s.scale).to({z:1},100);s.userData.levTween=r,r.start()}}),n){if(n.userData.enTween)return;n.userData.levTween&&(n.userData.levTween.stop(),n.userData.levTween=null);const s=new ie.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 ie.Tween(this.object3d.scale).to({z:1},1e3).easing(ie.Easing.Sinusoidal.InOut).start()}}Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>qe.LineMaterial});Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>De.LineSegmentsGeometry});exports.MeshLineMaterial=z.MeshLineMaterial;exports.Node=z.Node;exports.getConicPolygonGeometry=z.PolygonGeometry;exports.getConicPolygonGeometryMetas=z.getMetas;exports.ConicPolygon=tt;exports.Ellipsoid=st;exports.ExtrudePolygon=ct;exports.Group=ht;exports.Light=ut;exports.Line=dt;exports.Line2=mt;exports.MeshLineGeometry=We;exports.MeshLineRaycast=ft;exports.Pie=pt;exports.getSplitTexture=lt;
|
|
1
|
+
"use strict";var Ye=Object.defineProperty,Ze=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var Pe=(d,e,t)=>e in d?Ye(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t,W=(d,e)=>{for(var t in e||(e={}))Ve.call(e,t)&&Pe(d,t,e[t]);if(ue)for(var t of ue(e))_e.call(e,t)&&Pe(d,t,e[t]);return d},fe=(d,e)=>Ze(d,$e(e));var ge=(d,e)=>{var t={};for(var n in d)Ve.call(d,n)&&e.indexOf(n)<0&&(t[n]=d[n]);if(d!=null&&ue)for(var n of ue(d))e.indexOf(n)<0&&_e.call(d,n)&&(t[n]=d[n]);return t};var ie=(d,e,t)=>new Promise((n,s)=>{var r=i=>{try{m(t.next(i))}catch(u){s(u)}},c=i=>{try{m(t.throw(i))}catch(u){s(u)}},m=i=>i.done?n(i.value):Promise.resolve(i.value).then(r,c);m((t=t.apply(d,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qe=require("three/examples/jsm/lines/LineMaterial"),De=require("three/examples/jsm/lines/LineSegmentsGeometry"),O=require("../index2.js"),a=require("three"),ye=require("three/examples/jsm/utils/BufferGeometryUtils"),be=require("../cartographicToCartesian.js"),ze=require("../uvGenerator.js"),de=require("three-bvh-csg"),Je=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),Qe=require("@tweenjs/tween.js"),Ke=require("three/examples/jsm/lines/LineSegments2");function et(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const se=et(Qe);function F(d,e=0){const t=d[0].index!==null,n=new Set(Object.keys(d[0].attributes)),s=new Set(Object.keys(d[0].morphAttributes)),r={},c={},m=d[0].morphTargetsRelative,i=new a.BufferGeometry;let u=0;for(let o=0;o<d.length;++o){const l=d[o];let y=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 f in l.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(l.attributes[f]),y++}if(y!==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 f in l.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphAttributes must be consistent throughout all geometries."),null;c[f]===void 0&&(c[f]=[]),c[f].push(l.morphAttributes[f])}if(e){let f;if(t)f=l.index.count;else if(l.attributes.position!==void 0)f=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)i.addGroup(u,f,o);else if(e===2&&l.groups.length>0)for(let b of l.groups){let L=b.materialIndex;i.addGroup(u+b.start,Math.min(b.count,f),L)}u+=f}}if(t){let o=0;const l=[];for(let y=0;y<d.length;++y){const f=d[y].index;for(let b=0;b<f.count;++b)l.push(f.getX(b)+o);o+=d[y].attributes.position.count}i.setIndex(l)}for(const o in r){const l=ye.mergeAttributes(r[o]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" attribute."),null;i.setAttribute(o,l)}for(const o in c){const l=c[o][0].length;if(l===0)break;i.morphAttributes=i.morphAttributes||{},i.morphAttributes[o]=[];for(let y=0;y<l;++y){const f=[];for(let L=0;L<c[o].length;++L)f.push(c[o][L][y]);const b=ye.mergeAttributes(f);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" morphAttribute."),null;i.morphAttributes[o].push(b)}}return e===2?ye.mergeGroups(i):i}const Oe=d=>{const m=d,{coordinate:e,startHeight:t,height:n}=m,s=ge(m,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(r=t+n),new O.PolygonGeometry([e],fe(W({},s),{startHeight:t,endHeight:r}))};class tt extends O.BaseObject{constructor(e){super(),this.options=W({},e)}create(){const i=this.options,{geometry:e,coordinateArr:t,coordinate:n,material:s,useGroups:r}=i,c=ge(i,["geometry","coordinateArr","coordinate","material","useGroups"]);let m=e;if(!m&&n)m=Oe(W({coordinate:n},c));else if(!m&&t){const u=t.map(o=>Oe(W({coordinate:o},c)));m=F(u,r!=null?r:0)}this.createMesh(m,s)}}function nt(d={}){const{a:e=be.WGS84.a,b:t=be.WGS84.b,scaleFactor:n=1/be.WGS84.a,widthSegments:s=64,heightSegments:r=32}=d,c=new a.BufferGeometry,m=[],i=[],u=[],o=[],l=e*e,y=t*t,f=(l-y)/l;let b=0;const L=[];for(let v=0;v<=r;v++){const S=[],C=v/r,E=(.5-C)*180*Math.PI/180,I=Math.sin(E),R=Math.cos(E),X=e/Math.sqrt(1-f*I*I);for(let P=0;P<=s;P++){const $=P/s,H=($-.5)*360*Math.PI/180,oe=Math.sin(H),V=Math.cos(H),_=X*R*oe*n,we=X*(1-f)*I*n,re=X*R*V*n;i.push(_,we,re);const Q=R*oe/e,z=I*(1-f)/t,N=R*V/e,U=Math.sqrt(Q*Q+z*z+N*N);u.push(Q/U,z/U,N/U),o.push($,1-C),S.push(b++)}L.push(S)}for(let v=0;v<r;v++)for(let S=0;S<s;S++){const C=L[v][S+1],A=L[v][S],E=L[v+1][S],I=L[v+1][S+1];m.push(C,A,I),m.push(A,E,I)}return c.setIndex(m),c.setAttribute("position",new a.Float32BufferAttribute(i,3)),c.setAttribute("normal",new a.Float32BufferAttribute(u,3)),c.setAttribute("uv",new a.Float32BufferAttribute(o,2)),c}class st extends O.BaseObject{constructor(e={}){super(),this.options=e}create(){const e=nt(this.options),t=this.options.material||new a.MeshStandardMaterial({color:2200782,metalness:.1,roughness:.7,wireframe:!1}),n=new a.Mesh(e,t);return n.name="Ellipsoid",this.object3d=n,n}}const ot={ArcCurve:a.ArcCurve,CatmullRomCurve3:a.CatmullRomCurve3,CubicBezierCurve:a.CubicBezierCurve,CubicBezierCurve3:a.CubicBezierCurve3,EllipseCurve:a.EllipseCurve,LineCurve:a.LineCurve,LineCurve3:a.LineCurve3,QuadraticBezierCurve:a.QuadraticBezierCurve,QuadraticBezierCurve3:a.QuadraticBezierCurve3,SplineCurve:a.SplineCurve};class te 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 n=this,s=[],r=[];for(let m=0,i=e.length;m<i;m++){const u=e[m];c(u)}this.setAttribute("position",new a.Float32BufferAttribute(s,3)),this.setAttribute("uv",new a.Float32BufferAttribute(r,2)),this.computeVertexNormals();function c(m){var Me,Le,Ge;const i=[],u=t.curveSegments!==void 0?t.curveSegments:12,o=t.steps!==void 0?t.steps:1,l=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:f-.1,L=t.bevelOffset!==void 0?t.bevelOffset:0,v=t.bevelSegments!==void 0?t.bevelSegments:3;const S=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:it,A=(Me=t.hasTop)!=null?Me:!0,E=(Le=t.hasBottom)!=null?Le:!0,I=(Ge=t.hasSide)!=null?Ge:!0;let R,X=!1,P,$,ne,H;S&&(R=S.getSpacedPoints(o),X=!0,y=!1,P=S.computeFrenetFrames(o,!1),$=new a.Vector3,ne=new a.Vector3,H=new a.Vector3),y||(v=0,f=0,b=0,L=0);const oe=m.extractPoints(u);let V=oe.shape;const _=oe.holes;if(!a.ShapeUtils.isClockWise(V)){V=V.reverse();for(let h=0,p=_.length;h<p;h++){const g=_[h];a.ShapeUtils.isClockWise(g)&&(_[h]=g.reverse())}}function re(h){const g=10000000000000001e-36;let w=h[0];for(let x=1;x<=h.length;x++){const G=x%h.length,M=h[G],T=M.x-w.x,B=M.y-w.y,j=T*T+B*B,q=Math.max(Math.abs(M.x),Math.abs(M.y),Math.abs(w.x),Math.abs(w.y)),ee=g*q*q;if(j<=ee){h.splice(G,1),x--;continue}w=M}}re(V),_.forEach(re);const Q=_.length,z=V;for(let h=0;h<Q;h++){const p=_[h];V=V.concat(p)}function N(h,p,g){return p||error("ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(p,g)}const U=V.length;function ve(h,p,g){let w,x,G;const M=h.x-p.x,T=h.y-p.y,B=g.x-h.x,j=g.y-h.y,q=M*M+T*T,ee=M*j-T*B;if(Math.abs(ee)>Number.EPSILON){const D=Math.sqrt(q),Te=Math.sqrt(B*B+j*j),Be=p.x-T/D,Ce=p.y+M/D,Fe=g.x-j/Te,ke=g.y+B/Te,je=((Fe-Be)*j-(ke-Ce)*B)/(M*j-T*B);w=Be+M*je-h.x,x=Ce+T*je-h.y;const Ee=w*w+x*x;if(Ee<=2)return new a.Vector2(w,x);G=Math.sqrt(Ee/2)}else{let D=!1;M>Number.EPSILON?B>Number.EPSILON&&(D=!0):M<-Number.EPSILON?B<-Number.EPSILON&&(D=!0):Math.sign(T)===Math.sign(j)&&(D=!0),D?(w=-T,x=M,G=Math.sqrt(q)):(w=M,x=T,G=Math.sqrt(q/2))}return new a.Vector2(w/G,x/G)}const ae=[];for(let h=0,p=z.length,g=p-1,w=h+1;h<p;h++,g++,w++)g===p&&(g=0),w===p&&(w=0),ae[h]=ve(z[h],z[g],z[w]);const pe=[];let J,ce=ae.concat();for(let h=0,p=Q;h<p;h++){const g=_[h];J=[];for(let w=0,x=g.length,G=x-1,M=w+1;w<x;w++,G++,M++)G===x&&(G=0),M===x&&(M=0),J[w]=ve(g[w],g[G],g[M]);pe.push(J),ce=ce.concat(J)}let K;if(v===0)K=a.ShapeUtils.triangulateShape(z,_);else{const h=[],p=[];for(let g=0;g<v;g++){const w=g/v,x=f*Math.cos(w*Math.PI/2),G=b*Math.sin(w*Math.PI/2)+L;for(let M=0,T=z.length;M<T;M++){const B=N(z[M],ae[M],G);k(B.x,B.y,-x),w===0&&h.push(B)}for(let M=0,T=Q;M<T;M++){const B=_[M];J=pe[M];const j=[];for(let q=0,ee=B.length;q<ee;q++){const D=N(B[q],J[q],G);k(D.x,D.y,-x),w===0&&j.push(D)}w===0&&p.push(j)}}K=a.ShapeUtils.triangulateShape(h,p)}const le=K.length,Se=b+L;for(let h=0;h<U;h++){const p=y?N(V[h],ce[h],Se):V[h];X?(ne.copy(P.normals[0]).multiplyScalar(p.x),$.copy(P.binormals[0]).multiplyScalar(p.y),H.copy(R[0]).add(ne).add($),k(H.x,H.y,H.z)):k(p.x,p.y,0)}for(let h=1;h<=o;h++)for(let p=0;p<U;p++){const g=y?N(V[p],ce[p],Se):V[p];X?(ne.copy(P.normals[h]).multiplyScalar(g.x),$.copy(P.binormals[h]).multiplyScalar(g.y),H.copy(R[h]).add(ne).add($),k(H.x,H.y,H.z)):k(g.x,g.y,l/o*h)}for(let h=v-1;h>=0;h--){const p=h/v,g=f*Math.cos(p*Math.PI/2),w=b*Math.sin(p*Math.PI/2)+L;for(let x=0,G=z.length;x<G;x++){const M=N(z[x],ae[x],w);k(M.x,M.y,l+g)}for(let x=0,G=_.length;x<G;x++){const M=_[x];J=pe[x];for(let T=0,B=M.length;T<B;T++){const j=N(M[T],J[T],w);X?k(j.x,j.y+R[o-1].y,R[o-1].x+g):k(j.x,j.y,l+g)}}}He(),I&&Xe();function He(){const h=s.length/3;if(y){let p=0,g=U*p;if(E)for(let w=0;w<le;w++){const x=K[w];he(x[2]+g,x[1]+g,x[0]+g)}if(p=o+v*2,g=U*p,A)for(let w=0;w<le;w++){const x=K[w];he(x[0]+g,x[1]+g,x[2]+g)}}else{if(E)for(let p=0;p<le;p++){const g=K[p];he(g[2],g[1],g[0])}if(A)for(let p=0;p<le;p++){const g=K[p];he(g[0]+U*o,g[1]+U*o,g[2]+U*o)}}n.addGroup(h,s.length/3-h,0)}function Xe(){const h=s.length/3;let p=0;Ae(z,p),p+=z.length;for(let g=0,w=_.length;g<w;g++){const x=_[g];Ae(x,p),p+=x.length}n.addGroup(h,s.length/3-h,1)}function Ae(h,p){let g=h.length;for(;--g>=0;){const w=g;let x=g-1;x<0&&(x=h.length-1);for(let G=0,M=o+v*2;G<M;G++){const T=U*G,B=U*(G+1),j=p+w+T,q=p+x+T,ee=p+x+B,D=p+w+B;Ne(j,q,ee,D)}}}function k(h,p,g){i.push(h),i.push(p),i.push(g)}function he(h,p,g){Y(h),Y(p),Y(g);const w=s.length/3,x=C.generateTopUV(n,s,w-3,w-2,w-1);Z(x[0]),Z(x[1]),Z(x[2])}function Ne(h,p,g,w){Y(h),Y(p),Y(w),Y(p),Y(g),Y(w);const x=s.length/3,G=C.generateSideWallUV(n,s,x-6,x-3,x-2,x-1);Z(G[0]),Z(G[1]),Z(G[3]),Z(G[1]),Z(G[2]),Z(G[3])}function Y(h){s.push(i[h*3+0]),s.push(i[h*3+1]),s.push(i[h*3+2])}function Z(h){r.push(h.x),r.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 rt(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,c=e.shapes.length;r<c;r++){const m=t[e.shapes[r]];n.push(m)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new ot[s.type]().fromJSON(s)),new te(n,e.options)}}const it={generateTopUV:function(d,e,t,n,s){const r=e[t*3],c=e[t*3+1],m=e[n*3],i=e[n*3+1],u=e[s*3],o=e[s*3+1];return[new a.Vector2(r,c),new a.Vector2(m,i),new a.Vector2(u,o)]},generateSideWallUV:function(d,e,t,n,s,r){const c=e[t*3],m=e[t*3+1],i=e[t*3+2],u=e[n*3],o=e[n*3+1],l=e[n*3+2],y=e[s*3],f=e[s*3+1],b=e[s*3+2],L=e[r*3],v=e[r*3+1],S=e[r*3+2];return Math.abs(m-o)<Math.abs(c-u)?[new a.Vector2(c,1-i),new a.Vector2(u,1-l),new a.Vector2(y,1-b),new a.Vector2(L,1-S)]:[new a.Vector2(m,1-i),new a.Vector2(o,1-l),new a.Vector2(f,1-b),new a.Vector2(v,1-S)]}};function rt(d,e,t){if(t.shapes=[],Array.isArray(d))for(let n=0,s=d.length;n<s;n++){const r=d[n];t.shapes.push(r.uuid)}else t.shapes.push(d.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class at extends te{constructor(e,t){super(e,t);const n=new de.Brush(new te(e,fe(W({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));n.updateMatrixWorld();const s=new a.Box3().setFromObject(n),r=new a.Vector3;s.getSize(r);const c=new a.Vector3(s.min.x+r.x/2,s.min.y+r.y/2,0);let m=t.topSegments,i=t.box3;if(i){i=i.union(s);const S=new a.Vector3;i.getSize(S);const C=Math.max(r.x/S.x,r.y/S.y);m=Math.ceil(t.topSegments*C)}if(m<4)return this;const u=new a.PlaneGeometry(r.x,r.y,m,m),o=new de.Brush(u);o.position.set(c.x,c.y,c.z),o.updateMatrixWorld();const y=new de.Evaluator().evaluate(o,n,de.INTERSECTION),f=y.geometry.getAttribute("position"),b=new a.Float32BufferAttribute(f.count*2,2);for(let S=0;S<f.count;S++){const C=f.getZ(S);f.setZ(S,t.depth+C)}if(i){const S=i.min,C=i.max,A=new a.Vector3().subVectors(C,S);for(let E=0;E<f.count;E++){const I=f.getX(E),R=f.getY(E),X=(I-S.x)/A.x,P=(R-S.y)/A.y;b.setXY(E,X,P)}y.geometry.setAttribute("uv",b)}f.needsUpdate=!0;const L=new te(e,fe(W({},t),{hasTop:!1})),v=F([y.geometry,L],2);this.copy(v.toNonIndexed())}}const Ie=d=>{const{split:e,depth:t,points:n,box3:s,hasTop:r,hasBottom:c,hasSide:m,sideRepeat:i,topSegments:u}=d,o=u?at:te,l=new o(new a.Shape(n),{depth:t,bevelEnabled:!1,box3:s,UVGenerator:ze.getUVGenerator({split:e,box3:s,sideRepeat:i}),hasTop:r,hasBottom:c,hasSide:m,topSegments:u});return ze.claerUVGenerator(),l};class ct extends O.BaseObject{constructor(e){super(),this.options=W({depth:1},e)}create(){return ie(this,null,function*(){const{points:e,pointsArr:t,useGroups:n,depth:s,geometry:r,geometryArr:c,material:m,box3:i,split:u,hasTop:o,hasBottom:l,hasSide:y}=this.options,f=Array.isArray(s)?s:[s],b=Array.isArray(i)?i:[i],L=m;let v=r;L||console.log("material is null"),!v&&e?v=Ie({points:e,depth:f[0],box3:b[0],split:u,hasTop:o,hasBottom:l,hasSide:y}):!v&&t?v=F(t.map((S,C)=>{var A,E;return Ie({points:S,depth:(A=f[C])!=null?A:f[0],box3:(E=b[C])!=null?E:b[0],split:u,hasTop:o,hasBottom:l,hasSide:y})}),n!=null?n:0):!v&&c&&c.length>1?v=F(c,n!=null?n:0):!v&&c&&c.length===1&&([v]=c),this.createMesh(v,L)})}addGeometries(e){const t=this.object3d,n=F([t.geometry,...e]);t.geometry=n}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const lt=d=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:r,maxAnisotropy:c}=d;return new Promise(m=>{const i=n?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};i.onload=()=>{const u=r,o=document.createElement("canvas"),l=o.getContext("2d");o.height=i.height/(1-u),o.width=i.width,u&&e&&(l.fillStyle=e,l.fillRect(0,0,i.width,o.height*u)),n&&i instanceof HTMLImageElement?l.drawImage(i,0,o.height*u,i.width,i.height):t&&(l.fillStyle=t,l.fillRect(0,o.height*u,i.width,i.height)),s&&o.toBlob(f=>{console.log(URL.createObjectURL(f))});const y=new a.CanvasTexture(o);m(y)},n?i.src=n:i instanceof HTMLImageElement||i.onload()})};class ht extends O.BaseObject{create(){this.createGroup()}render(){this.object3d.raycast=(e,t)=>e.intersectObjects(this.object3d.children,!0,t)}}class ut extends O.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,r,c,m,i,u,o,l,y,f,b,L,v,S,C;const e=this.options;if(e.type==="AmbientLight"){const A=new a.AmbientLight(e.color);A.name="环境光",this.object3d=A}else if(e.type==="DirectionalLight"){const A=new a.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 a.PointLight((t=e.color)!=null?t:16777215,(n=e.intensity)!=null?n:1,(s=e.distance)!=null?s:0,(r=e.decay)!=null?r:2);A.name="点光源",this.object3d=A,this.pointLight=A}else if(e.type==="SpotLight"){const A=new a.SpotLight((c=e.color)!=null?c:16777215,(m=e.intensity)!=null?m:1,(i=e.distance)!=null?i:0,(u=e.angle)!=null?u:Math.PI/3,(o=e.penumbra)!=null?o:1,(l=e.decay)!=null?l:2);A.name="聚光灯",this.object3d=A,this.spotLight=A,A.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const A=new a.HemisphereLight((y=e.color)!=null?y:16777215,(f=e.groundColor)!=null?f:16777215,(b=e.intensity)!=null?b:1);A.name="半球光",this.object3d=A,this.hemisphereLight=A}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Je.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const A=new a.RectAreaLight((L=e.color)!=null?L:16777215,(v=e.intensity)!=null?v:1,(S=e.width)!=null?S:10,(C=e.height)!=null?C: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 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 We extends a.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 a.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 a.Vector3(n[s],n[s+1],n[s+2]));return t}else return e.map(t=>{if(t instanceof a.Vector2)return new a.Vector3(t.x,t.y,0);if(t instanceof a.Vector3)return t;if(Array.isArray(t)&&t.length===2)return new a.Vector3(t[0],t[1],0);if(Array.isArray(t)&&t.length===3)return new a.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 a.BufferAttribute(new Float32Array(this.pointCount*6),3),t=new a.BufferAttribute(new Float32Array(this.pointCount*6),3),n=new a.BufferAttribute(new Float32Array(this.pointCount*6),3),s=new a.BufferAttribute(new Float32Array(this.pointCount*2),1),r=new a.BufferAttribute(new Float32Array(this.pointCount*2),1),c=new a.BufferAttribute(new Float32Array(this.pointCount*2),1),m=new a.BufferAttribute(new Float32Array(this.pointCount*4),2),i=new a.BufferAttribute(new Uint16Array((this.pointCount-1)*6),1);this.shape==="taper"&&(this.shapeFunction=u=>1*Math.pow(4*u*(1-u),1));for(let u=0,o=0,l=0;u<this.pointCount;u+=1,o+=2,l+=6){s.setX(o,u/this.pointCount),s.setX(o+1,u/this.pointCount),r.setX(o,1),r.setX(o+1,-1);const y=this.shape==="none"?1:this.shapeFunction(u/(this.pointCount-1));c.setX(o,y),c.setX(o+1,y);const f=u/(this.pointCount-1);if(m.setXY(o,f,0),m.setXY(o+1,f,1),u<this.pointCount-1){const b=u*2;i.setX(l+0,b+0),i.setX(l+1,b+1),i.setX(l+2,b+2),i.setX(l+3,b+2),i.setX(l+4,b+1),i.setX(l+5,b+3)}}this.setAttribute("position",e),this.setAttribute("previous",t),this.setAttribute("next",n),this.setAttribute("counters",s),this.setAttribute("side",r),this.setAttribute("width",c),this.setAttribute("uv",m),this.setIndex(i)}updateGeometry(){if(!this._points[0])return;const e=this.getAttribute("position"),t=this.getAttribute("previous"),n=this.getAttribute("next");let s=0,r=0,c=0;const m=this._points[0];t.setXYZ(r,m.x,m.y,m.z),r+=1,t.setXYZ(r,m.x,m.y,m.z),r+=1;for(let u=0;u<this.pointCount;u++){const o=this._points[u];e.setXYZ(s,o.x,o.y,o.z),s+=1,e.setXYZ(s,o.x,o.y,o.z),s+=1,u<this.pointCount-1&&(t.setXYZ(r,o.x,o.y,o.z),r+=1,t.setXYZ(r,o.x,o.y,o.z),r+=1),u>0&&u+1<=this.pointCount&&(n.setXYZ(c,o.x,o.y,o.z),c+=1,n.setXYZ(c,o.x,o.y,o.z),c+=1)}const i=this._points[this.pointCount-1];n.setXYZ(c,i.x,i.y,i.z),c+=1,n.setXYZ(c,i.x,i.y,i.z),c+=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 ft(d,e){const t=new a.Matrix4,n=new a.Ray,s=new a.Sphere,r=new a.Vector3,c=this.geometry;if(s.copy(c.boundingSphere),s.applyMatrix4(this.matrixWorld),!d.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),n.copy(d.ray).applyMatrix4(t);const m=new a.Vector3,i=new a.Vector3,u=new a.Vector3,o=this instanceof a.LineSegments?2:1,l=c.index,y=c.attributes;if(l!==null){const f=l.array,b=y.position.array,L=y.width.array;for(let v=0,S=f.length-1;v<S;v+=o){const C=f[v],A=f[v+1];m.fromArray(b,C*3),i.fromArray(b,A*3);const E=L[Math.floor(v/3)]!==void 0?L[Math.floor(v/3)]:1,I=d.params.Line.threshold+this.material.lineWidth*E/2,R=I*I;if(n.distanceSqToSegment(m,i,r,u)>R)continue;r.applyMatrix4(this.matrixWorld);const P=d.ray.origin.distanceTo(r);P<d.near||P>d.far||(e.push({distance:P,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:void 0,object:this}),v=S)}}}const xe=d=>{const{setPointWidth:e,nodes:t}=d,n=new We;return n.setPoints(t,e),n},Re=new WeakMap,me=new Map;let dt=class extends O.BaseObject{constructor(e={}){super(),this.options=W({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ie(this,null,function*(){const{nodes:e,nodesArr:t,geometry:n,geometryArr:s,material:r,useGroups:c,setPointWidth:m,lineWidthArr:i,materialParameters:u}=this.options;let o=r,l=n;!o&&u&&(o=this.getMaterial(u)),!l&&e?l=xe({nodes:e,setPointWidth:m}):!l&&t?l=F(t.map((y,f)=>{let b=m;return!b&&i&&(b=()=>{var L;return(L=i[f])!=null?L:i[0]}),xe({nodes:y,setPointWidth:b})}),c!=null?c:0):!l&&s&&s.length>1?l=F(s,c!=null?c:0):!l&&s&&s.length===1&&([l]=s),this.createMesh(l,o)})}setGeometry(e,t){const n=xe({nodes:e,setPointWidth:t}),s=this.object3d,r=s.geometry;s.geometry=n,r.dispose()}getMaterial(e){const{width:t,height:n}=this.pencil.getSize(),s=new O.MeshLineMaterial(W({color:new a.Color("#ffffff")},e));return s.uniforms.resolution.value.set(t,n),s}addGeometries(e){const t=this.object3d,n=F([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:r,onUpdate:c,onComplete:m,startShow:i}={}){const{offset:u,offsetLoop:o}=this.material.uniforms,l=this.pencil.userData.debugLine?me:Re;if(l.get(this.material)&&this.stopAnimation(),e===0)return;const y=s!=null?s:!0;u.value.x=1,o.value=y&&i?1:0;let f=0;const b=new se.Tween(u.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:L})=>{y&&L<=0&&o.value===0&&(o.value=1),c==null||c(L)}).onRepeat(()=>{f+=1,r==null||r(f)}).onComplete(()=>{m==null||m()}).start();l.set(this.material,b),this.material.addEventListener("dispose",()=>{this.stopAnimation()}),this.pencil.userData.debugLine&&console.log("animate",me.size)}stopAnimation(){const e=this.pencil.userData.debugLine?me:Re,t=e.get(this.material);t&&(t.stop(),se.remove(t),e.delete(this.material),this.material.uniforms.offset.value.x=0,this.material.uniforms.offsetLoop.value=1),this.pencil.userData.debugLine&&console.log("stopAnimation",me.size)}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}};const Ue=d=>{const{points:e}=d,t=e.reduce((s,r,c)=>(c<e.length-1&&s.push(r,e[c+1]),s),[]);return new a.BufferGeometry().setFromPoints(t)};class mt extends O.BaseObject{constructor(e={}){super(),this.options=W({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ie(this,null,function*(){const{points:e,pointsArr:t,geometry:n,geometryArr:s,material:r,useGroups:c,setPointWidth:m,lineWidthArr:i,materialParameters:u,instanceCount:o}=this.options;let l=r,y=n;!l&&u&&(l=this.getMaterial(u)),!y&&e?y=Ue({points:e}):!y&&t?y=F(t.map(b=>Ue({points:b})),c!=null?c:0):!y&&s&&s.length>1?y=F(s,c!=null?c:0):!y&&s&&s.length===1&&([y]=s);const f=new De.LineSegmentsGeometry().fromLineSegments(new a.LineSegments(y));if(this.pencil.options.WebGPUTHREE){o&&(f.instanceCount=o);const b=new O.LineSegments2(f,l);b.computeLineDistances(),this.object3d=b}else{const b=new Ke.LineSegments2(f,l);b.computeLineDistances(),this.object3d=b}})}getMaterial(e){return new qe.LineMaterial(W({color:new a.Color("#ffffff")},e))}}class pt extends O.BaseObject{constructor(e){super(),this.options=W({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return ie(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:n,material:s,percentDepth:r,activeIndex:c}=this.options,m=Math.max(...e),i=e.reduce((o,l)=>o+l,0);let u=Math.PI/2;e.forEach((o,l)=>{if(o===0)return;const y=Math.PI*2*(o/i),f=n[l],b=r?t*(o/m):t,L=this.createGeometry(b,y),v=s?s.clone():new a.MeshBasicMaterial({color:f});s&&v.color.set(f);const S=new a.Mesh(L,v);S.userData.depth=b,S.userData.index=l,S.rotateZ(u),u+=y,this.add(S)}),c!==-1&&this.setActive(c)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,r=new a.Shape;return r.moveTo(n,0),r.lineTo(s,0),r.absarc(0,0,s,0,t,!1),r.absarc(0,0,n,t,0,!0),new te(r,{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(r=>r===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 r=new se.Tween(s.scale).to({z:1},100);s.userData.levTween=r,r.start()}}),n){if(n.userData.enTween)return;n.userData.levTween&&(n.userData.levTween.stop(),n.userData.levTween=null);const s=new se.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 se.Tween(this.object3d.scale).to({z:1},1e3).easing(se.Easing.Sinusoidal.InOut).start()}}Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>qe.LineMaterial});Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>De.LineSegmentsGeometry});exports.MeshLineMaterial=O.MeshLineMaterial;exports.Node=O.Node;exports.getConicPolygonGeometry=O.PolygonGeometry;exports.getConicPolygonGeometryMetas=O.getMetas;exports.ConicPolygon=tt;exports.Ellipsoid=st;exports.ExtrudePolygon=ct;exports.Group=ht;exports.Light=ut;exports.Line=dt;exports.Line2=mt;exports.MeshLineGeometry=We;exports.MeshLineRaycast=ft;exports.Pie=pt;exports.getSplitTexture=lt;
|