gl-draw 0.16.0-beta.6 → 0.16.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var ke=Object.defineProperty,Fe=Object.defineProperties;var Ye=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var je=(u,e,t)=>e in u?ke(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t,B=(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))Pe.call(e,t)&&je(u,t,e[t]);return u},le=(u,e)=>Fe(u,Ye(e));var pe=(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&&Pe.call(u,n)&&(t[n]=u[n]);return t};var se=(u,e,t)=>new Promise((n,s)=>{var o=r=>{try{p(t.next(r))}catch(f){s(f)}},a=r=>{try{p(t.throw(r))}catch(f){s(f)}},p=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,a);p((t=t.apply(u,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ue=require("three/examples/jsm/lines/LineMaterial"),Re=require("three/examples/jsm/lines/LineSegmentsGeometry"),P=require("../WebGPULineSegments2.js"),c=require("three"),me=require("three/examples/jsm/utils/BufferGeometryUtils"),Ve=require("../uvGenerator.js"),he=require("three-bvh-csg"),Ze=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),$e=require("@tweenjs/tween.js"),Je=require("three/examples/jsm/lines/LineSegments2");function Qe(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=Qe($e);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)),o={},a={},p=u[0].morphTargetsRelative,r=new c.BufferGeometry;let f=0;for(let i=0;i<u.length;++i){const l=u[i];let y=0;if(t!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". 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 "+i+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;o[d]===void 0&&(o[d]=[]),o[d].push(l.attributes[d]),y++}if(y!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". Make sure all geometries have the same number of attributes."),null;if(p!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". .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 "+i+". .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 "+i+". The geometry must have either an index or a position attribute"),null;if(e===1)r.addGroup(f,d,i);else if(e===2&&l.groups.length>0)for(let b of l.groups){let T=b.materialIndex;r.addGroup(f+b.start,Math.min(b.count,d),T)}f+=d}}if(t){let i=0;const l=[];for(let y=0;y<u.length;++y){const d=u[y].index;for(let b=0;b<d.count;++b)l.push(d.getX(b)+i);i+=u[y].attributes.position.count}r.setIndex(l)}for(const i in o){const l=me.mergeAttributes(o[i]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" attribute."),null;r.setAttribute(i,l)}for(const i in a){const l=a[i][0].length;if(l===0)break;r.morphAttributes=r.morphAttributes||{},r.morphAttributes[i]=[];for(let y=0;y<l;++y){const d=[];for(let T=0;T<a[i].length;++T)d.push(a[i][T][y]);const b=me.mergeAttributes(d);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" morphAttribute."),null;r.morphAttributes[i].push(b)}}return e===2?me.mergeGroups(r):r}const _e=u=>{const p=u,{coordinate:e,startHeight:t,height:n}=p,s=pe(p,["coordinate","startHeight","height"]);let o=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(o=t+n),new P.PolygonGeometry([e],le(B({},s),{startHeight:t,endHeight:o}))};class Ke extends P.BaseObject{constructor(e){super(),this.options=B({},e)}create(){const r=this.options,{geometry:e,coordinateArr:t,coordinate:n,material:s,useGroups:o}=r,a=pe(r,["geometry","coordinateArr","coordinate","material","useGroups"]);let p=e;if(!p&&n)p=_e(B({coordinate:n},a));else if(!p&&t){const f=t.map(i=>_e(B({coordinate:i},a)));p=D(f,o!=null?o:0)}this.createMesh(p,s)}}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 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=[],o=[];for(let p=0,r=e.length;p<r;p++){const f=e[p];a(f)}this.setAttribute("position",new c.Float32BufferAttribute(s,3)),this.setAttribute("uv",new c.Float32BufferAttribute(o,2)),this.computeVertexNormals();function a(p){var Se,Ae,Me;const r=[],f=t.curveSegments!==void 0?t.curveSegments:12,i=t.steps!==void 0?t.steps:1,l=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:d-.1,T=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const M=t.extrudePath,j=t.UVGenerator!==void 0?t.UVGenerator:tt,S=(Se=t.hasTop)!=null?Se:!0,V=(Ae=t.hasBottom)!=null?Ae:!0,Q=(Me=t.hasSide)!=null?Me:!0;let H,Y=!1,U,te,ne,N;M&&(H=M.getSpacedPoints(i),Y=!0,y=!1,U=M.computeFrenetFrames(i,!1),te=new c.Vector3,ne=new c.Vector3,N=new c.Vector3),y||(A=0,d=0,b=0,T=0);const ye=p.extractPoints(f);let I=ye.shape;const _=ye.holes;if(!c.ShapeUtils.isClockWise(I)){I=I.reverse();for(let h=0,m=_.length;h<m;h++){const g=_[h];c.ShapeUtils.isClockWise(g)&&(_[h]=g.reverse())}}function be(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],C=v.x-w.x,G=v.y-w.y,E=C*C+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(E<=$){h.splice(L,1),x--;continue}w=v}}be(I),_.forEach(be);const fe=_.length,R=I;for(let h=0;h<fe;h++){const m=_[h];I=I.concat(m)}function K(h,m,g){return m||console.error("THREE.ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(m,g)}const W=I.length;function xe(h,m,g){let w,x,L;const v=h.x-m.x,C=h.y-m.y,G=g.x-h.x,E=g.y-h.y,z=v*v+C*C,$=v*E-C*G;if(Math.abs($)>Number.EPSILON){const O=Math.sqrt(z),Le=Math.sqrt(G*G+E*E),Te=m.x-C/O,Ce=m.y+v/O,Xe=g.x-E/Le,qe=g.y+G/Le,Ge=((Xe-Te)*E-(qe-Ce)*G)/(v*E-C*G);w=Te+v*Ge-h.x,x=Ce+C*Ge-h.y;const Ee=w*w+x*x;if(Ee<=2)return new c.Vector2(w,x);L=Math.sqrt(Ee/2)}else{let O=!1;v>Number.EPSILON?G>Number.EPSILON&&(O=!0):v<-Number.EPSILON?G<-Number.EPSILON&&(O=!0):Math.sign(C)===Math.sign(E)&&(O=!0),O?(w=-C,x=v,L=Math.sqrt(z)):(w=v,x=C,L=Math.sqrt(z/2))}return new c.Vector2(w/L,x/L)}const ie=[];for(let h=0,m=R.length,g=m-1,w=h+1;h<m;h++,g++,w++)g===m&&(g=0),w===m&&(w=0),ie[h]=xe(R[h],R[g],R[w]);const de=[];let F,oe=ie.concat();for(let h=0,m=fe;h<m;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]=xe(g[w],g[L],g[v]);de.push(F),oe=oe.concat(F)}let Z;if(A===0)Z=c.ShapeUtils.triangulateShape(R,_);else{const h=[],m=[];for(let g=0;g<A;g++){const w=g/A,x=d*Math.cos(w*Math.PI/2),L=b*Math.sin(w*Math.PI/2)+T;for(let v=0,C=R.length;v<C;v++){const G=K(R[v],ie[v],L);X(G.x,G.y,-x),w===0&&h.push(G)}for(let v=0,C=fe;v<C;v++){const G=_[v];F=de[v];const E=[];for(let z=0,$=G.length;z<$;z++){const O=K(G[z],F[z],L);X(O.x,O.y,-x),w===0&&E.push(O)}w===0&&m.push(E)}}Z=c.ShapeUtils.triangulateShape(h,m)}const re=Z.length,we=b+T;for(let h=0;h<W;h++){const m=y?K(I[h],oe[h],we):I[h];Y?(ne.copy(U.normals[0]).multiplyScalar(m.x),te.copy(U.binormals[0]).multiplyScalar(m.y),N.copy(H[0]).add(ne).add(te),X(N.x,N.y,N.z)):X(m.x,m.y,0)}for(let h=1;h<=i;h++)for(let m=0;m<W;m++){const g=y?K(I[m],oe[m],we):I[m];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),X(N.x,N.y,N.z)):X(g.x,g.y,l/i*h)}for(let h=A-1;h>=0;h--){const m=h/A,g=d*Math.cos(m*Math.PI/2),w=b*Math.sin(m*Math.PI/2)+T;for(let x=0,L=R.length;x<L;x++){const v=K(R[x],ie[x],w);X(v.x,v.y,l+g)}for(let x=0,L=_.length;x<L;x++){const v=_[x];F=de[x];for(let C=0,G=v.length;C<G;C++){const E=K(v[C],F[C],w);Y?X(E.x,E.y+H[i-1].y,H[i-1].x+g):X(E.x,E.y,l+g)}}}He(),Q&&Ne();function He(){const h=s.length/3;if(y){let m=0,g=W*m;if(V)for(let w=0;w<re;w++){const x=Z[w];ae(x[2]+g,x[1]+g,x[0]+g)}if(m=i+A*2,g=W*m,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 m=0;m<re;m++){const g=Z[m];ae(g[2],g[1],g[0])}if(S)for(let m=0;m<re;m++){const g=Z[m];ae(g[0]+W*i,g[1]+W*i,g[2]+W*i)}}n.addGroup(h,s.length/3-h,0)}function Ne(){const h=s.length/3;let m=0;ve(R,m),m+=R.length;for(let g=0,w=_.length;g<w;g++){const x=_[g];ve(x,m),m+=x.length}n.addGroup(h,s.length/3-h,1)}function ve(h,m){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=i+A*2;L<v;L++){const C=W*L,G=W*(L+1),E=m+w+C,z=m+x+C,$=m+x+G,O=m+w+G;We(E,z,$,O)}}}function X(h,m,g){r.push(h),r.push(m),r.push(g)}function ae(h,m,g){q(h),q(m),q(g);const w=s.length/3,x=j.generateTopUV(n,s,w-3,w-2,w-1);k(x[0]),k(x[1]),k(x[2])}function We(h,m,g,w){q(h),q(m),q(w),q(m),q(g),q(w);const x=s.length/3,L=j.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){o.push(h.x),o.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 nt(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,a=e.shapes.length;o<a;o++){const p=t[e.shapes[o]];n.push(p)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new et[`${s.type}`]().fromJSON(s)),new J(n,e.options)}}const tt={generateTopUV:function(u,e,t,n,s){const o=e[t*3],a=e[t*3+1],p=e[n*3],r=e[n*3+1],f=e[s*3],i=e[s*3+1];return[new c.Vector2(o,a),new c.Vector2(p,r),new c.Vector2(f,i)]},generateSideWallUV:function(u,e,t,n,s,o){const a=e[t*3],p=e[t*3+1],r=e[t*3+2],f=e[n*3],i=e[n*3+1],l=e[n*3+2],y=e[s*3],d=e[s*3+1],b=e[s*3+2],T=e[o*3],A=e[o*3+1],M=e[o*3+2];return Math.abs(p-i)<Math.abs(a-f)?[new c.Vector2(a,1-r),new c.Vector2(f,1-l),new c.Vector2(y,1-b),new c.Vector2(T,1-M)]:[new c.Vector2(p,1-r),new c.Vector2(i,1-l),new c.Vector2(d,1-b),new c.Vector2(A,1-M)]}};function nt(u,e,t){if(t.shapes=[],Array.isArray(u))for(let n=0,s=u.length;n<s;n++){const o=u[n];t.shapes.push(o.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 st extends J{constructor(e,t){super(e,t);const n=new he.Brush(new J(e,le(B({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));n.updateMatrixWorld();const s=new c.Box3().setFromObject(n),o=new c.Vector3;s.getSize(o);const a=new c.Vector3(s.min.x+o.x/2,s.min.y+o.y/2,0);let p=t.topSegments,r=t.box3;if(r){r=r.union(s);const M=new c.Vector3;r.getSize(M);const j=Math.max(o.x/M.x,o.y/M.y);p=Math.ceil(t.topSegments*j)}if(p<4)return this;const f=new c.PlaneGeometry(o.x,o.y,p,p),i=new he.Brush(f);i.position.set(a.x,a.y,a.z),i.updateMatrixWorld();const y=new he.Evaluator().evaluate(i,n,he.INTERSECTION),d=y.geometry.getAttribute("position"),b=new c.Float32BufferAttribute(d.count*2,2);for(let M=0;M<d.count;M++){const j=d.getZ(M);d.setZ(M,t.depth+j)}if(r){const M=r.min,j=r.max,S=new c.Vector3().subVectors(j,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;b.setXY(V,Y,U)}y.geometry.setAttribute("uv",b)}d.needsUpdate=!0;const T=new J(e,le(B({},t),{hasTop:!1})),A=D([y.geometry,T],2);this.copy(A.toNonIndexed())}}const ze=u=>{const{split:e,depth:t,points:n,box3:s,hasTop:o,hasBottom:a,hasSide:p,sideRepeat:r,topSegments:f}=u,i=f?st:J,l=new i(new c.Shape(n),{depth:t,bevelEnabled:!1,box3:s,UVGenerator:Ve.getUVGenerator({split:e,box3:s,sideRepeat:r}),hasTop:o,hasBottom:a,hasSide:p,topSegments:f});return Ve.claerUVGenerator(),l};class it extends P.BaseObject{constructor(e){super(),this.options=B({depth:1},e)}create(){return se(this,null,function*(){const{points:e,pointsArr:t,useGroups:n,depth:s,geometry:o,geometryArr:a,material:p,box3:r,split:f,hasTop:i,hasBottom:l,hasSide:y}=this.options,d=Array.isArray(s)?s:[s],b=Array.isArray(r)?r:[r],T=p;let A=o;T||console.log("material is null"),!A&&e?A=ze({points:e,depth:d[0],box3:b[0],split:f,hasTop:i,hasBottom:l,hasSide:y}):!A&&t?A=D(t.map((M,j)=>{var S,V;return ze({points:M,depth:(S=d[j])!=null?S:d[0],box3:(V=b[j])!=null?V:b[0],split:f,hasTop:i,hasBottom:l,hasSide:y})}),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,T)})}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 ot=u=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:o,maxAnisotropy:a}=u;return new Promise(p=>{const r=n?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};r.onload=()=>{const f=o,i=document.createElement("canvas"),l=i.getContext("2d");i.height=r.height/(1-f),i.width=r.width,f&&e&&(l.fillStyle=e,l.fillRect(0,0,r.width,i.height*f)),n&&r instanceof HTMLImageElement?l.drawImage(r,0,i.height*f,r.width,r.height):t&&(l.fillStyle=t,l.fillRect(0,i.height*f,r.width,r.height)),s&&i.toBlob(d=>{console.log(URL.createObjectURL(d))});const y=new c.CanvasTexture(i);p(y)},n?r.src=n:r instanceof HTMLImageElement||r.onload()})};class rt extends P.BaseObject{create(){this.createGroup()}}class at extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,o,a,p,r,f,i,l,y,d,b,T,A,M,j;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,(o=e.decay)!=null?o: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,(p=e.intensity)!=null?p:1,(r=e.distance)!=null?r:0,(f=e.angle)!=null?f:Math.PI/3,(i=e.penumbra)!=null?i: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((y=e.color)!=null?y:16777215,(d=e.groundColor)!=null?d:16777215,(b=e.intensity)!=null?b:1);S.name="半球光",this.object3d=S,this.hemisphereLight=S}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Ze.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const S=new c.RectAreaLight((T=e.color)!=null?T:16777215,(A=e.intensity)!=null?A:1,(M=e.width)!=null?M:10,(j=e.height)!=null?j: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 De 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),o=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),a=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),p=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,i=0,l=0;f<this.pointCount;f+=1,i+=2,l+=6){s.setX(i,f/this.pointCount),s.setX(i+1,f/this.pointCount),o.setX(i,1),o.setX(i+1,-1);const y=this.shape==="none"?1:this.shapeFunction(f/(this.pointCount-1));a.setX(i,y),a.setX(i+1,y);const d=f/(this.pointCount-1);if(p.setXY(i,d,0),p.setXY(i+1,d,1),f<this.pointCount-1){const b=f*2;r.setX(l+0,b+0),r.setX(l+1,b+1),r.setX(l+2,b+2),r.setX(l+3,b+2),r.setX(l+4,b+1),r.setX(l+5,b+3)}}this.setAttribute("position",e),this.setAttribute("previous",t),this.setAttribute("next",n),this.setAttribute("counters",s),this.setAttribute("side",o),this.setAttribute("width",a),this.setAttribute("uv",p),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,o=0,a=0;const p=this._points[0];t.setXYZ(o,p.x,p.y,p.z),o+=1,t.setXYZ(o,p.x,p.y,p.z),o+=1;for(let f=0;f<this.pointCount;f++){const i=this._points[f];e.setXYZ(s,i.x,i.y,i.z),s+=1,e.setXYZ(s,i.x,i.y,i.z),s+=1,f<this.pointCount-1&&(t.setXYZ(o,i.x,i.y,i.z),o+=1,t.setXYZ(o,i.x,i.y,i.z),o+=1),f>0&&f+1<=this.pointCount&&(n.setXYZ(a,i.x,i.y,i.z),a+=1,n.setXYZ(a,i.x,i.y,i.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 ct(u,e){const t=new c.Matrix4,n=new c.Ray,s=new c.Sphere,o=new c.Vector3,a=this.geometry;if(s.copy(a.boundingSphere),s.applyMatrix4(this.matrixWorld),!u.ray.intersectSphere(s,o))return;t.copy(this.matrixWorld).invert(),n.copy(u.ray).applyMatrix4(t);const p=new c.Vector3,r=new c.Vector3,f=new c.Vector3,i=this instanceof c.LineSegments?2:1,l=a.index,y=a.attributes;if(l!==null){const d=l.array,b=y.position.array,T=y.width.array;for(let A=0,M=d.length-1;A<M;A+=i){const j=d[A],S=d[A+1];p.fromArray(b,j*3),r.fromArray(b,S*3);const V=T[Math.floor(A/3)]!==void 0?T[Math.floor(A/3)]:1,Q=u.params.Line.threshold+this.material.lineWidth*V/2,H=Q*Q;if(n.distanceSqToSegment(p,r,o,f)>H)continue;o.applyMatrix4(this.matrixWorld);const U=u.ray.origin.distanceTo(o);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 ge=u=>{const{setPointWidth:e,nodes:t}=u,n=new De;return n.setPoints(t,e),n},Oe=new WeakMap,ue=new Map;let lt=class extends P.BaseObject{constructor(e={}){super(),this.options=B({},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:o,useGroups:a,setPointWidth:p,lineWidthArr:r,materialParameters:f}=this.options;let i=o,l=n;!i&&f&&(i=this.getMaterial(f)),!l&&e?l=ge({nodes:e,setPointWidth:p}):!l&&t?l=D(t.map((y,d)=>{let b=p;return!b&&r&&(b=()=>{var T;return(T=r[d])!=null?T:r[0]}),ge({nodes:y,setPointWidth:b})}),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,i)})}setGeometry(e,t){const n=ge({nodes:e,setPointWidth:t}),s=this.object3d,o=s.geometry;s.geometry=n,o.dispose()}getMaterial(e){const{width:t,height:n}=this.pencil.getSize(),s=new P.MeshLineMaterial(B({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:o,onUpdate:a,onComplete:p,startShow:r}={}){const{offset:f,offsetLoop:i}=this.material.uniforms,l=this.pencil.userData.debugLine?ue:Oe;if(l.get(this.material)&&this.stopAnimation(),e===0)return;const y=s!=null?s:!0;f.value.x=1,i.value=y&&r?1:0;let d=0;const b=new ee.Tween(f.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:T})=>{y&&T<=0&&i.value===0&&(i.value=1),a==null||a(T)}).onRepeat(()=>{d+=1,o==null||o(d)}).onComplete(()=>{p==null||p()}).start();l.set(this.material,b),this.material.addEventListener("dispose",()=>{this.stopAnimation()}),this.pencil.userData.debugLine&&console.log("animate",ue.size)}stopAnimation(){const e=this.pencil.userData.debugLine?ue:Oe,t=e.get(this.material);t&&(t.stop(),ee.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",ue.size)}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}};const Ie=u=>{const{points:e}=u,t=e.reduce((s,o,a)=>(a<e.length-1&&s.push(o,e[a+1]),s),[]);return new c.BufferGeometry().setFromPoints(t)};class ht extends P.BaseObject{constructor(e={}){super(),this.options=B({},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:o,useGroups:a,setPointWidth:p,lineWidthArr:r,materialParameters:f,instanceCount:i}=this.options;let l=o,y=n;!l&&f&&(l=this.getMaterial(f)),!y&&e?y=Ie({points:e}):!y&&t?y=D(t.map(b=>Ie({points:b})),a!=null?a:0):!y&&s&&s.length>1?y=D(s,a!=null?a:0):!y&&s&&s.length===1&&([y]=s);const d=new Re.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(y));if(this.pencil.options.WebGPUTHREE){i&&(d.instanceCount=i);const b=new P.LineSegments2(d,l);b.computeLineDistances(),this.object3d=b}else{const b=new Je.LineSegments2(d,l);b.computeLineDistances(),this.object3d=b}})}getMaterial(e){return new Ue.LineMaterial(B({color:new c.Color("#ffffff")},e))}}class ut extends P.BaseObject{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=B({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 o=0,a=0;t.left<0?o=-t.left:t.right>n&&(o=n-t.right),t.top<0?a=-t.top:t.bottom>s&&(a=s-t.bottom),t.left+o<0&&(o=-t.left),t.top+a<0&&(a=-t.top),(o!==0||a!==0)&&(e.style.transform=`translate(${o}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 ft extends P.BaseObject{constructor(e){super(),this.options=B({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:o,activeIndex:a}=this.options,p=Math.max(...e),r=e.reduce((i,l)=>i+l,0);let f=Math.PI/2;e.forEach((i,l)=>{if(i===0)return;const y=Math.PI*2*(i/r),d=n[l],b=o?t*(i/p):t,T=this.createGeometry(b,y),A=s?s.clone():new c.MeshBasicMaterial({color:d});s&&A.color.set(d);const M=new c.Mesh(T,A);M.userData.depth=b,M.userData.index=l,M.rotateZ(f),f+=y,this.add(M)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,o=new c.Shape;return o.moveTo(n,0),o.lineTo(s,0),o.absarc(0,0,s,0,t,!1),o.absarc(0,0,n,t,0,!0),new J(o,{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(o=>o===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 o=new ee.Tween(s.scale).to({z:1},100);s.userData.levTween=o,o.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:()=>Ue.LineMaterial});Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Re.LineSegmentsGeometry});exports.MeshLineMaterial=P.MeshLineMaterial;exports.getConicPolygonGeometry=P.PolygonGeometry;exports.getConicPolygonGeometryMetas=P.getMetas;exports.ConicPolygon=Ke;exports.ExtrudePolygon=it;exports.Group=rt;exports.Light=at;exports.Line=lt;exports.Line2=ht;exports.MeshLineGeometry=De;exports.MeshLineRaycast=ct;exports.Node=ut;exports.Pie=ft;exports.getSplitTexture=ot;
1
+ "use strict";var ke=Object.defineProperty,Fe=Object.defineProperties;var Ye=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var Be=(u,e,t)=>e in u?ke(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t,E=(u,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&Be(u,t,e[t]);if(ce)for(var t of ce(e))Pe.call(e,t)&&Be(u,t,e[t]);return u},le=(u,e)=>Fe(u,Ye(e));var pe=(u,e)=>{var t={};for(var n in u)Ee.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&&Pe.call(u,n)&&(t[n]=u[n]);return t};var se=(u,e,t)=>new Promise((n,s)=>{var o=r=>{try{p(t.next(r))}catch(f){s(f)}},a=r=>{try{p(t.throw(r))}catch(f){s(f)}},p=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,a);p((t=t.apply(u,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ue=require("three/examples/jsm/lines/LineMaterial"),Re=require("three/examples/jsm/lines/LineSegmentsGeometry"),P=require("../WebGPULineSegments2.js"),c=require("three"),me=require("three/examples/jsm/utils/BufferGeometryUtils"),Ve=require("../uvGenerator.js"),he=require("three-bvh-csg"),Ze=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),$e=require("@tweenjs/tween.js"),Je=require("three/examples/jsm/lines/LineSegments2");function Qe(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=Qe($e);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)),o={},a={},p=u[0].morphTargetsRelative,r=new c.BufferGeometry;let f=0;for(let i=0;i<u.length;++i){const l=u[i];let y=0;if(t!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". 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 "+i+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;o[d]===void 0&&(o[d]=[]),o[d].push(l.attributes[d]),y++}if(y!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". Make sure all geometries have the same number of attributes."),null;if(p!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". .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 "+i+". .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 "+i+". The geometry must have either an index or a position attribute"),null;if(e===1)r.addGroup(f,d,i);else if(e===2&&l.groups.length>0)for(let b of l.groups){let T=b.materialIndex;r.addGroup(f+b.start,Math.min(b.count,d),T)}f+=d}}if(t){let i=0;const l=[];for(let y=0;y<u.length;++y){const d=u[y].index;for(let b=0;b<d.count;++b)l.push(d.getX(b)+i);i+=u[y].attributes.position.count}r.setIndex(l)}for(const i in o){const l=me.mergeAttributes(o[i]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" attribute."),null;r.setAttribute(i,l)}for(const i in a){const l=a[i][0].length;if(l===0)break;r.morphAttributes=r.morphAttributes||{},r.morphAttributes[i]=[];for(let y=0;y<l;++y){const d=[];for(let T=0;T<a[i].length;++T)d.push(a[i][T][y]);const b=me.mergeAttributes(d);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" morphAttribute."),null;r.morphAttributes[i].push(b)}}return e===2?me.mergeGroups(r):r}const _e=u=>{const p=u,{coordinate:e,startHeight:t,height:n}=p,s=pe(p,["coordinate","startHeight","height"]);let o=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(o=t+n),new P.PolygonGeometry([e],le(E({},s),{startHeight:t,endHeight:o}))};class Ke extends P.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const r=this.options,{geometry:e,coordinateArr:t,coordinate:n,material:s,useGroups:o}=r,a=pe(r,["geometry","coordinateArr","coordinate","material","useGroups"]);let p=e;if(!p&&n)p=_e(E({coordinate:n},a));else if(!p&&t){const f=t.map(i=>_e(E({coordinate:i},a)));p=D(f,o!=null?o:0)}this.createMesh(p,s)}}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 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=[],o=[];for(let p=0,r=e.length;p<r;p++){const f=e[p];a(f)}this.setAttribute("position",new c.Float32BufferAttribute(s,3)),this.setAttribute("uv",new c.Float32BufferAttribute(o,2)),this.computeVertexNormals();function a(p){var Se,Ae,Me;const r=[],f=t.curveSegments!==void 0?t.curveSegments:12,i=t.steps!==void 0?t.steps:1,l=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,b=t.bevelSize!==void 0?t.bevelSize:d-.1,T=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:tt,S=(Se=t.hasTop)!=null?Se:!0,V=(Ae=t.hasBottom)!=null?Ae:!0,Q=(Me=t.hasSide)!=null?Me:!0;let H,Y=!1,U,te,ne,N;M&&(H=M.getSpacedPoints(i),Y=!0,y=!1,U=M.computeFrenetFrames(i,!1),te=new c.Vector3,ne=new c.Vector3,N=new c.Vector3),y||(A=0,d=0,b=0,T=0);const ye=p.extractPoints(f);let I=ye.shape;const _=ye.holes;if(!c.ShapeUtils.isClockWise(I)){I=I.reverse();for(let h=0,m=_.length;h<m;h++){const g=_[h];c.ShapeUtils.isClockWise(g)&&(_[h]=g.reverse())}}function be(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],C=v.x-w.x,G=v.y-w.y,j=C*C+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}}be(I),_.forEach(be);const fe=_.length,R=I;for(let h=0;h<fe;h++){const m=_[h];I=I.concat(m)}function K(h,m,g){return m||error("ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(m,g)}const W=I.length;function xe(h,m,g){let w,x,L;const v=h.x-m.x,C=h.y-m.y,G=g.x-h.x,j=g.y-h.y,z=v*v+C*C,$=v*j-C*G;if(Math.abs($)>Number.EPSILON){const O=Math.sqrt(z),Le=Math.sqrt(G*G+j*j),Te=m.x-C/O,Ce=m.y+v/O,Xe=g.x-j/Le,qe=g.y+G/Le,Ge=((Xe-Te)*j-(qe-Ce)*G)/(v*j-C*G);w=Te+v*Ge-h.x,x=Ce+C*Ge-h.y;const je=w*w+x*x;if(je<=2)return new c.Vector2(w,x);L=Math.sqrt(je/2)}else{let O=!1;v>Number.EPSILON?G>Number.EPSILON&&(O=!0):v<-Number.EPSILON?G<-Number.EPSILON&&(O=!0):Math.sign(C)===Math.sign(j)&&(O=!0),O?(w=-C,x=v,L=Math.sqrt(z)):(w=v,x=C,L=Math.sqrt(z/2))}return new c.Vector2(w/L,x/L)}const ie=[];for(let h=0,m=R.length,g=m-1,w=h+1;h<m;h++,g++,w++)g===m&&(g=0),w===m&&(w=0),ie[h]=xe(R[h],R[g],R[w]);const de=[];let F,oe=ie.concat();for(let h=0,m=fe;h<m;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]=xe(g[w],g[L],g[v]);de.push(F),oe=oe.concat(F)}let Z;if(A===0)Z=c.ShapeUtils.triangulateShape(R,_);else{const h=[],m=[];for(let g=0;g<A;g++){const w=g/A,x=d*Math.cos(w*Math.PI/2),L=b*Math.sin(w*Math.PI/2)+T;for(let v=0,C=R.length;v<C;v++){const G=K(R[v],ie[v],L);X(G.x,G.y,-x),w===0&&h.push(G)}for(let v=0,C=fe;v<C;v++){const G=_[v];F=de[v];const j=[];for(let z=0,$=G.length;z<$;z++){const O=K(G[z],F[z],L);X(O.x,O.y,-x),w===0&&j.push(O)}w===0&&m.push(j)}}Z=c.ShapeUtils.triangulateShape(h,m)}const re=Z.length,we=b+T;for(let h=0;h<W;h++){const m=y?K(I[h],oe[h],we):I[h];Y?(ne.copy(U.normals[0]).multiplyScalar(m.x),te.copy(U.binormals[0]).multiplyScalar(m.y),N.copy(H[0]).add(ne).add(te),X(N.x,N.y,N.z)):X(m.x,m.y,0)}for(let h=1;h<=i;h++)for(let m=0;m<W;m++){const g=y?K(I[m],oe[m],we):I[m];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),X(N.x,N.y,N.z)):X(g.x,g.y,l/i*h)}for(let h=A-1;h>=0;h--){const m=h/A,g=d*Math.cos(m*Math.PI/2),w=b*Math.sin(m*Math.PI/2)+T;for(let x=0,L=R.length;x<L;x++){const v=K(R[x],ie[x],w);X(v.x,v.y,l+g)}for(let x=0,L=_.length;x<L;x++){const v=_[x];F=de[x];for(let C=0,G=v.length;C<G;C++){const j=K(v[C],F[C],w);Y?X(j.x,j.y+H[i-1].y,H[i-1].x+g):X(j.x,j.y,l+g)}}}He(),Q&&Ne();function He(){const h=s.length/3;if(y){let m=0,g=W*m;if(V)for(let w=0;w<re;w++){const x=Z[w];ae(x[2]+g,x[1]+g,x[0]+g)}if(m=i+A*2,g=W*m,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 m=0;m<re;m++){const g=Z[m];ae(g[2],g[1],g[0])}if(S)for(let m=0;m<re;m++){const g=Z[m];ae(g[0]+W*i,g[1]+W*i,g[2]+W*i)}}n.addGroup(h,s.length/3-h,0)}function Ne(){const h=s.length/3;let m=0;ve(R,m),m+=R.length;for(let g=0,w=_.length;g<w;g++){const x=_[g];ve(x,m),m+=x.length}n.addGroup(h,s.length/3-h,1)}function ve(h,m){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=i+A*2;L<v;L++){const C=W*L,G=W*(L+1),j=m+w+C,z=m+x+C,$=m+x+G,O=m+w+G;We(j,z,$,O)}}}function X(h,m,g){r.push(h),r.push(m),r.push(g)}function ae(h,m,g){q(h),q(m),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 We(h,m,g,w){q(h),q(m),q(w),q(m),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){o.push(h.x),o.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 nt(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,a=e.shapes.length;o<a;o++){const p=t[e.shapes[o]];n.push(p)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new et[s.type]().fromJSON(s)),new J(n,e.options)}}const tt={generateTopUV:function(u,e,t,n,s){const o=e[t*3],a=e[t*3+1],p=e[n*3],r=e[n*3+1],f=e[s*3],i=e[s*3+1];return[new c.Vector2(o,a),new c.Vector2(p,r),new c.Vector2(f,i)]},generateSideWallUV:function(u,e,t,n,s,o){const a=e[t*3],p=e[t*3+1],r=e[t*3+2],f=e[n*3],i=e[n*3+1],l=e[n*3+2],y=e[s*3],d=e[s*3+1],b=e[s*3+2],T=e[o*3],A=e[o*3+1],M=e[o*3+2];return Math.abs(p-i)<Math.abs(a-f)?[new c.Vector2(a,1-r),new c.Vector2(f,1-l),new c.Vector2(y,1-b),new c.Vector2(T,1-M)]:[new c.Vector2(p,1-r),new c.Vector2(i,1-l),new c.Vector2(d,1-b),new c.Vector2(A,1-M)]}};function nt(u,e,t){if(t.shapes=[],Array.isArray(u))for(let n=0,s=u.length;n<s;n++){const o=u[n];t.shapes.push(o.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 st 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),o=new c.Vector3;s.getSize(o);const a=new c.Vector3(s.min.x+o.x/2,s.min.y+o.y/2,0);let p=t.topSegments,r=t.box3;if(r){r=r.union(s);const M=new c.Vector3;r.getSize(M);const B=Math.max(o.x/M.x,o.y/M.y);p=Math.ceil(t.topSegments*B)}if(p<4)return this;const f=new c.PlaneGeometry(o.x,o.y,p,p),i=new he.Brush(f);i.position.set(a.x,a.y,a.z),i.updateMatrixWorld();const y=new he.Evaluator().evaluate(i,n,he.INTERSECTION),d=y.geometry.getAttribute("position"),b=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;b.setXY(V,Y,U)}y.geometry.setAttribute("uv",b)}d.needsUpdate=!0;const T=new J(e,le(E({},t),{hasTop:!1})),A=D([y.geometry,T],2);this.copy(A.toNonIndexed())}}const ze=u=>{const{split:e,depth:t,points:n,box3:s,hasTop:o,hasBottom:a,hasSide:p,sideRepeat:r,topSegments:f}=u,i=f?st:J,l=new i(new c.Shape(n),{depth:t,bevelEnabled:!1,box3:s,UVGenerator:Ve.getUVGenerator({split:e,box3:s,sideRepeat:r}),hasTop:o,hasBottom:a,hasSide:p,topSegments:f});return Ve.claerUVGenerator(),l};class it 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:o,geometryArr:a,material:p,box3:r,split:f,hasTop:i,hasBottom:l,hasSide:y}=this.options,d=Array.isArray(s)?s:[s],b=Array.isArray(r)?r:[r],T=p;let A=o;T||console.log("material is null"),!A&&e?A=ze({points:e,depth:d[0],box3:b[0],split:f,hasTop:i,hasBottom:l,hasSide:y}):!A&&t?A=D(t.map((M,B)=>{var S,V;return ze({points:M,depth:(S=d[B])!=null?S:d[0],box3:(V=b[B])!=null?V:b[0],split:f,hasTop:i,hasBottom:l,hasSide:y})}),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,T)})}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 ot=u=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:o,maxAnisotropy:a}=u;return new Promise(p=>{const r=n?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};r.onload=()=>{const f=o,i=document.createElement("canvas"),l=i.getContext("2d");i.height=r.height/(1-f),i.width=r.width,f&&e&&(l.fillStyle=e,l.fillRect(0,0,r.width,i.height*f)),n&&r instanceof HTMLImageElement?l.drawImage(r,0,i.height*f,r.width,r.height):t&&(l.fillStyle=t,l.fillRect(0,i.height*f,r.width,r.height)),s&&i.toBlob(d=>{console.log(URL.createObjectURL(d))});const y=new c.CanvasTexture(i);p(y)},n?r.src=n:r instanceof HTMLImageElement||r.onload()})};class rt extends P.BaseObject{create(){this.createGroup()}}class at extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,o,a,p,r,f,i,l,y,d,b,T,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,(o=e.decay)!=null?o: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,(p=e.intensity)!=null?p:1,(r=e.distance)!=null?r:0,(f=e.angle)!=null?f:Math.PI/3,(i=e.penumbra)!=null?i: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((y=e.color)!=null?y:16777215,(d=e.groundColor)!=null?d:16777215,(b=e.intensity)!=null?b:1);S.name="半球光",this.object3d=S,this.hemisphereLight=S}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Ze.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const S=new c.RectAreaLight((T=e.color)!=null?T: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 De 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),o=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),a=new c.BufferAttribute(new Float32Array(this.pointCount*2),1),p=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,i=0,l=0;f<this.pointCount;f+=1,i+=2,l+=6){s.setX(i,f/this.pointCount),s.setX(i+1,f/this.pointCount),o.setX(i,1),o.setX(i+1,-1);const y=this.shape==="none"?1:this.shapeFunction(f/(this.pointCount-1));a.setX(i,y),a.setX(i+1,y);const d=f/(this.pointCount-1);if(p.setXY(i,d,0),p.setXY(i+1,d,1),f<this.pointCount-1){const b=f*2;r.setX(l+0,b+0),r.setX(l+1,b+1),r.setX(l+2,b+2),r.setX(l+3,b+2),r.setX(l+4,b+1),r.setX(l+5,b+3)}}this.setAttribute("position",e),this.setAttribute("previous",t),this.setAttribute("next",n),this.setAttribute("counters",s),this.setAttribute("side",o),this.setAttribute("width",a),this.setAttribute("uv",p),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,o=0,a=0;const p=this._points[0];t.setXYZ(o,p.x,p.y,p.z),o+=1,t.setXYZ(o,p.x,p.y,p.z),o+=1;for(let f=0;f<this.pointCount;f++){const i=this._points[f];e.setXYZ(s,i.x,i.y,i.z),s+=1,e.setXYZ(s,i.x,i.y,i.z),s+=1,f<this.pointCount-1&&(t.setXYZ(o,i.x,i.y,i.z),o+=1,t.setXYZ(o,i.x,i.y,i.z),o+=1),f>0&&f+1<=this.pointCount&&(n.setXYZ(a,i.x,i.y,i.z),a+=1,n.setXYZ(a,i.x,i.y,i.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 ct(u,e){const t=new c.Matrix4,n=new c.Ray,s=new c.Sphere,o=new c.Vector3,a=this.geometry;if(s.copy(a.boundingSphere),s.applyMatrix4(this.matrixWorld),!u.ray.intersectSphere(s,o))return;t.copy(this.matrixWorld).invert(),n.copy(u.ray).applyMatrix4(t);const p=new c.Vector3,r=new c.Vector3,f=new c.Vector3,i=this instanceof c.LineSegments?2:1,l=a.index,y=a.attributes;if(l!==null){const d=l.array,b=y.position.array,T=y.width.array;for(let A=0,M=d.length-1;A<M;A+=i){const B=d[A],S=d[A+1];p.fromArray(b,B*3),r.fromArray(b,S*3);const V=T[Math.floor(A/3)]!==void 0?T[Math.floor(A/3)]:1,Q=u.params.Line.threshold+this.material.lineWidth*V/2,H=Q*Q;if(n.distanceSqToSegment(p,r,o,f)>H)continue;o.applyMatrix4(this.matrixWorld);const U=u.ray.origin.distanceTo(o);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 ge=u=>{const{setPointWidth:e,nodes:t}=u,n=new De;return n.setPoints(t,e),n},Oe=new WeakMap,ue=new Map;let lt=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:o,useGroups:a,setPointWidth:p,lineWidthArr:r,materialParameters:f}=this.options;let i=o,l=n;!i&&f&&(i=this.getMaterial(f)),!l&&e?l=ge({nodes:e,setPointWidth:p}):!l&&t?l=D(t.map((y,d)=>{let b=p;return!b&&r&&(b=()=>{var T;return(T=r[d])!=null?T:r[0]}),ge({nodes:y,setPointWidth:b})}),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,i)})}setGeometry(e,t){const n=ge({nodes:e,setPointWidth:t}),s=this.object3d,o=s.geometry;s.geometry=n,o.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:o,onUpdate:a,onComplete:p,startShow:r}={}){const{offset:f,offsetLoop:i}=this.material.uniforms,l=this.pencil.userData.debugLine?ue:Oe;if(l.get(this.material)&&this.stopAnimation(),e===0)return;const y=s!=null?s:!0;f.value.x=1,i.value=y&&r?1:0;let d=0;const b=new ee.Tween(f.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:T})=>{y&&T<=0&&i.value===0&&(i.value=1),a==null||a(T)}).onRepeat(()=>{d+=1,o==null||o(d)}).onComplete(()=>{p==null||p()}).start();l.set(this.material,b),this.material.addEventListener("dispose",()=>{this.stopAnimation()}),this.pencil.userData.debugLine&&console.log("animate",ue.size)}stopAnimation(){const e=this.pencil.userData.debugLine?ue:Oe,t=e.get(this.material);t&&(t.stop(),ee.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",ue.size)}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}};const Ie=u=>{const{points:e}=u,t=e.reduce((s,o,a)=>(a<e.length-1&&s.push(o,e[a+1]),s),[]);return new c.BufferGeometry().setFromPoints(t)};class ht 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:o,useGroups:a,setPointWidth:p,lineWidthArr:r,materialParameters:f,instanceCount:i}=this.options;let l=o,y=n;!l&&f&&(l=this.getMaterial(f)),!y&&e?y=Ie({points:e}):!y&&t?y=D(t.map(b=>Ie({points:b})),a!=null?a:0):!y&&s&&s.length>1?y=D(s,a!=null?a:0):!y&&s&&s.length===1&&([y]=s);const d=new Re.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(y));if(this.pencil.options.WebGPUTHREE){i&&(d.instanceCount=i);const b=new P.LineSegments2(d,l);b.computeLineDistances(),this.object3d=b}else{const b=new Je.LineSegments2(d,l);b.computeLineDistances(),this.object3d=b}})}getMaterial(e){return new Ue.LineMaterial(E({color:new c.Color("#ffffff")},e))}}class ut extends P.BaseObject{constructor(e){super(),this.objectType="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 o=0,a=0;t.left<0?o=-t.left:t.right>n&&(o=n-t.right),t.top<0?a=-t.top:t.bottom>s&&(a=s-t.bottom),t.left+o<0&&(o=-t.left),t.top+a<0&&(a=-t.top),(o!==0||a!==0)&&(e.style.transform=`translate(${o}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 ft 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:o,activeIndex:a}=this.options,p=Math.max(...e),r=e.reduce((i,l)=>i+l,0);let f=Math.PI/2;e.forEach((i,l)=>{if(i===0)return;const y=Math.PI*2*(i/r),d=n[l],b=o?t*(i/p):t,T=this.createGeometry(b,y),A=s?s.clone():new c.MeshBasicMaterial({color:d});s&&A.color.set(d);const M=new c.Mesh(T,A);M.userData.depth=b,M.userData.index=l,M.rotateZ(f),f+=y,this.add(M)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,o=new c.Shape;return o.moveTo(n,0),o.lineTo(s,0),o.absarc(0,0,s,0,t,!1),o.absarc(0,0,n,t,0,!0),new J(o,{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(o=>o===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 o=new ee.Tween(s.scale).to({z:1},100);s.userData.levTween=o,o.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:()=>Ue.LineMaterial});Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Re.LineSegmentsGeometry});exports.MeshLineMaterial=P.MeshLineMaterial;exports.getConicPolygonGeometry=P.PolygonGeometry;exports.getConicPolygonGeometryMetas=P.getMetas;exports.ConicPolygon=Ke;exports.ExtrudePolygon=it;exports.Group=rt;exports.Light=at;exports.Line=lt;exports.Line2=ht;exports.MeshLineGeometry=De;exports.MeshLineRaycast=ct;exports.Node=ut;exports.Pie=ft;exports.getSplitTexture=ot;
@@ -48,7 +48,7 @@ import { Brush as Ue, Evaluator as _t, INTERSECTION as zt } from "three-bvh-csg"
48
48
  import { RectAreaLightUniformsLib as jt } from "three/examples/jsm/lights/RectAreaLightUniformsLib";
49
49
  import * as ne from "@tweenjs/tween.js";
50
50
  import { LineSegments2 as It } from "three/examples/jsm/lines/LineSegments2";
51
- function H(p, e = 0) {
51
+ function V(p, e = 0) {
52
52
  const t = p[0].index !== null, n = new Set(Object.keys(p[0].attributes)), s = new Set(
53
53
  Object.keys(p[0].morphAttributes)
54
54
  ), o = {}, a = {}, f = p[0].morphTargetsRelative, r = new me();
@@ -180,7 +180,7 @@ class Jt extends Z {
180
180
  coordinate: i
181
181
  }, a))
182
182
  );
183
- f = H(h, o != null ? o : 0);
183
+ f = V(h, o != null ? o : 0);
184
184
  }
185
185
  this.createMesh(f, s);
186
186
  }
@@ -225,8 +225,8 @@ class K extends me {
225
225
  const r = [], h = t.curveSegments !== void 0 ? t.curveSegments : 12, i = t.steps !== void 0 ? t.steps : 1, c = t.depth !== void 0 ? t.depth : 1;
226
226
  let g = t.bevelEnabled !== void 0 ? t.bevelEnabled : !0, u = t.bevelThickness !== void 0 ? t.bevelThickness : 0.2, y = t.bevelSize !== void 0 ? t.bevelSize : u - 0.1, L = t.bevelOffset !== void 0 ? t.bevelOffset : 0, S = t.bevelSegments !== void 0 ? t.bevelSegments : 3;
227
227
  const A = t.extrudePath, C = t.UVGenerator !== void 0 ? t.UVGenerator : Ot, v = (Te = t.hasTop) != null ? Te : !0, j = (Ee = t.hasBottom) != null ? Ee : !0, ee = (Ge = t.hasSide) != null ? Ge : !0;
228
- let V, $ = !1, U, se, ie, X;
229
- A && (V = A.getSpacedPoints(i), $ = !0, g = !1, U = A.computeFrenetFrames(i, !1), se = new _(), ie = new _(), X = new _()), g || (S = 0, u = 0, y = 0, L = 0);
228
+ let H, $ = !1, U, se, ie, X;
229
+ A && (H = A.getSpacedPoints(i), $ = !0, g = !1, U = A.computeFrenetFrames(i, !1), se = new _(), ie = new _(), X = new _()), g || (S = 0, u = 0, y = 0, L = 0);
230
230
  const ve = f.extractPoints(h);
231
231
  let R = ve.shape;
232
232
  const I = ve.holes;
@@ -261,7 +261,7 @@ class K extends me {
261
261
  R = R.concat(d);
262
262
  }
263
263
  function te(l, d, m) {
264
- return d || console.error("THREE.ExtrudeGeometry: vec does not exist"), l.clone().addScaledVector(d, m);
264
+ return d || error("ExtrudeGeometry: vec does not exist"), l.clone().addScaledVector(d, m);
265
265
  }
266
266
  const N = R.length;
267
267
  function Ae(l, d, m) {
@@ -324,12 +324,12 @@ class K extends me {
324
324
  const ce = J.length, Me = y + L;
325
325
  for (let l = 0; l < N; l++) {
326
326
  const d = g ? te(R[l], ae[l], Me) : R[l];
327
- $ ? (ie.copy(U.normals[0]).multiplyScalar(d.x), se.copy(U.binormals[0]).multiplyScalar(d.y), X.copy(V[0]).add(ie).add(se), W(X.x, X.y, X.z)) : W(d.x, d.y, 0);
327
+ $ ? (ie.copy(U.normals[0]).multiplyScalar(d.x), se.copy(U.binormals[0]).multiplyScalar(d.y), X.copy(H[0]).add(ie).add(se), W(X.x, X.y, X.z)) : W(d.x, d.y, 0);
328
328
  }
329
329
  for (let l = 1; l <= i; l++)
330
330
  for (let d = 0; d < N; d++) {
331
331
  const m = g ? te(R[d], ae[d], Me) : R[d];
332
- $ ? (ie.copy(U.normals[l]).multiplyScalar(m.x), se.copy(U.binormals[l]).multiplyScalar(m.y), X.copy(V[l]).add(ie).add(se), W(X.x, X.y, X.z)) : W(m.x, m.y, c / i * l);
332
+ $ ? (ie.copy(U.normals[l]).multiplyScalar(m.x), se.copy(U.binormals[l]).multiplyScalar(m.y), X.copy(H[l]).add(ie).add(se), W(X.x, X.y, X.z)) : W(m.x, m.y, c / i * l);
333
333
  }
334
334
  for (let l = S - 1; l >= 0; l--) {
335
335
  const d = l / S, m = u * Math.cos(d * Math.PI / 2), x = y * Math.sin(d * Math.PI / 2) + L;
@@ -344,8 +344,8 @@ class K extends me {
344
344
  const G = te(w[T], q[T], x);
345
345
  $ ? W(
346
346
  G.x,
347
- G.y + V[i - 1].y,
348
- V[i - 1].x + m
347
+ G.y + H[i - 1].y,
348
+ H[i - 1].x + m
349
349
  ) : W(G.x, G.y, c + m);
350
350
  }
351
351
  }
@@ -461,7 +461,7 @@ class K extends me {
461
461
  n.push(f);
462
462
  }
463
463
  const s = e.options.extrudePath;
464
- return s !== void 0 && (e.options.extrudePath = new Bt[`${s.type}`]().fromJSON(
464
+ return s !== void 0 && (e.options.extrudePath = new Bt[s.type]().fromJSON(
465
465
  s
466
466
  )), new K(n, e.options);
467
467
  }
@@ -549,7 +549,7 @@ class Ut extends K {
549
549
  if (r) {
550
550
  const A = r.min, C = r.max, v = new _().subVectors(C, A);
551
551
  for (let j = 0; j < u.count; j++) {
552
- const ee = u.getX(j), V = u.getY(j), $ = (ee - A.x) / v.x, U = (V - A.y) / v.y;
552
+ const ee = u.getX(j), H = u.getY(j), $ = (ee - A.x) / v.x, U = (H - A.y) / v.y;
553
553
  y.setXY(j, $, U);
554
554
  }
555
555
  g.geometry.setAttribute("uv", y);
@@ -557,11 +557,11 @@ class Ut extends K {
557
557
  u.needsUpdate = !0;
558
558
  const L = new K(e, ue(z({}, t), {
559
559
  hasTop: !1
560
- })), S = H([g.geometry, L], 2);
560
+ })), S = V([g.geometry, L], 2);
561
561
  this.copy(S.toNonIndexed());
562
562
  }
563
563
  }
564
- const He = (p) => {
564
+ const Ve = (p) => {
565
565
  const {
566
566
  split: e,
567
567
  depth: t,
@@ -611,7 +611,7 @@ class Qt extends Z {
611
611
  hasSide: g
612
612
  } = this.options, u = Array.isArray(s) ? s : [s], y = Array.isArray(r) ? r : [r], L = f;
613
613
  let S = o;
614
- L || console.log("material is null"), !S && e ? S = He({
614
+ L || console.log("material is null"), !S && e ? S = Ve({
615
615
  points: e,
616
616
  depth: u[0],
617
617
  box3: y[0],
@@ -619,11 +619,11 @@ class Qt extends Z {
619
619
  hasTop: i,
620
620
  hasBottom: c,
621
621
  hasSide: g
622
- }) : !S && t ? S = H(
622
+ }) : !S && t ? S = V(
623
623
  t.map(
624
624
  (A, C) => {
625
625
  var v, j;
626
- return He({
626
+ return Ve({
627
627
  points: A,
628
628
  depth: (v = u[C]) != null ? v : u[0],
629
629
  box3: (j = y[C]) != null ? j : y[0],
@@ -635,11 +635,11 @@ class Qt extends Z {
635
635
  }
636
636
  ),
637
637
  n != null ? n : 0
638
- ) : !S && a && a.length > 1 ? S = H(a, n != null ? n : 0) : !S && a && a.length === 1 && ([S] = a), this.createMesh(S, L);
638
+ ) : !S && a && a.length > 1 ? S = V(a, n != null ? n : 0) : !S && a && a.length === 1 && ([S] = a), this.createMesh(S, L);
639
639
  });
640
640
  }
641
641
  addGeometries(e) {
642
- const t = this.object3d, n = H([t.geometry, ...e]);
642
+ const t = this.object3d, n = V([t.geometry, ...e]);
643
643
  t.geometry = n;
644
644
  }
645
645
  setTextureAnisotropic(e, t) {
@@ -839,13 +839,13 @@ function nn(p, e) {
839
839
  for (let S = 0, A = u.length - 1; S < A; S += i) {
840
840
  const C = u[S], v = u[S + 1];
841
841
  f.fromArray(y, C * 3), r.fromArray(y, v * 3);
842
- const j = L[Math.floor(S / 3)] !== void 0 ? L[Math.floor(S / 3)] : 1, ee = p.params.Line.threshold + this.material.lineWidth * j / 2, V = ee * ee;
842
+ const j = L[Math.floor(S / 3)] !== void 0 ? L[Math.floor(S / 3)] : 1, ee = p.params.Line.threshold + this.material.lineWidth * j / 2, H = ee * ee;
843
843
  if (n.distanceSqToSegment(
844
844
  f,
845
845
  r,
846
846
  o,
847
847
  h
848
- ) > V) continue;
848
+ ) > H) continue;
849
849
  o.applyMatrix4(this.matrixWorld);
850
850
  const U = p.ray.origin.distanceTo(o);
851
851
  U < p.near || U > p.far || (e.push({
@@ -864,7 +864,7 @@ function nn(p, e) {
864
864
  const be = (p) => {
865
865
  const { setPointWidth: e, nodes: t } = p, n = new Dt();
866
866
  return n.setPoints(t, e), n;
867
- }, Ve = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new Map();
867
+ }, He = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new Map();
868
868
  let sn = class extends Z {
869
869
  constructor(e = {}) {
870
870
  super(), this.options = z({}, e);
@@ -890,7 +890,7 @@ let sn = class extends Z {
890
890
  !i && h && (i = this.getMaterial(h)), !c && e ? c = be({
891
891
  nodes: e,
892
892
  setPointWidth: f
893
- }) : !c && t ? c = H(
893
+ }) : !c && t ? c = V(
894
894
  t.map((g, u) => {
895
895
  let y = f;
896
896
  return !y && r && (y = () => {
@@ -902,7 +902,7 @@ let sn = class extends Z {
902
902
  });
903
903
  }),
904
904
  a != null ? a : 0
905
- ) : !c && s && s.length > 1 ? c = H(s, a != null ? a : 0) : !c && s && s.length === 1 && ([c] = s), this.createMesh(c, i);
905
+ ) : !c && s && s.length > 1 ? c = V(s, a != null ? a : 0) : !c && s && s.length === 1 && ([c] = s), this.createMesh(c, i);
906
906
  });
907
907
  }
908
908
  setGeometry(e, t) {
@@ -919,7 +919,7 @@ let sn = class extends Z {
919
919
  return s.uniforms.resolution.value.set(t, n), s;
920
920
  }
921
921
  addGeometries(e) {
922
- const t = this.object3d, n = H([t.geometry, ...e]);
922
+ const t = this.object3d, n = V([t.geometry, ...e]);
923
923
  t.geometry = n;
924
924
  }
925
925
  resize(e, t) {
@@ -942,7 +942,7 @@ let sn = class extends Z {
942
942
  onComplete: f,
943
943
  startShow: r
944
944
  } = {}) {
945
- const { offset: h, offsetLoop: i } = this.material.uniforms, c = this.pencil.userData.debugLine ? de : Ve;
945
+ const { offset: h, offsetLoop: i } = this.material.uniforms, c = this.pencil.userData.debugLine ? de : He;
946
946
  if (c.get(this.material) && this.stopAnimation(), e === 0) return;
947
947
  const g = s != null ? s : !0;
948
948
  h.value.x = 1, i.value = g && r ? 1 : 0;
@@ -959,7 +959,7 @@ let sn = class extends Z {
959
959
  }), this.pencil.userData.debugLine && console.log("animate", de.size);
960
960
  }
961
961
  stopAnimation() {
962
- const e = this.pencil.userData.debugLine ? de : Ve, t = e.get(this.material);
962
+ const e = this.pencil.userData.debugLine ? de : He, t = e.get(this.material);
963
963
  t && (t.stop(), ne.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", de.size);
964
964
  }
965
965
  render() {
@@ -996,12 +996,12 @@ class rn extends Z {
996
996
  let c = o, g = n;
997
997
  !c && h && (c = this.getMaterial(h)), !g && e ? g = Xe({
998
998
  points: e
999
- }) : !g && t ? g = H(
999
+ }) : !g && t ? g = V(
1000
1000
  t.map((y) => Xe({
1001
1001
  points: y
1002
1002
  })),
1003
1003
  a != null ? a : 0
1004
- ) : !g && s && s.length > 1 ? g = H(s, a != null ? a : 0) : !g && s && s.length === 1 && ([g] = s);
1004
+ ) : !g && s && s.length > 1 ? g = V(s, a != null ? a : 0) : !g && s && s.length === 1 && ([g] = s);
1005
1005
  const u = new tt().fromLineSegments(
1006
1006
  new We(g)
1007
1007
  );