gl-draw 0.15.26 → 0.15.28
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/objects/index.js +1 -1
- package/dist/objects/index.module.js +201 -201
- package/package.json +1 -1
package/dist/objects/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var qe=Object.defineProperty,ke=Object.defineProperties;var Fe=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var je=(u,e,t)=>e in u?qe(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)=>ke(u,Fe(e));var me=(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{m(t.next(r))}catch(f){s(f)}},a=r=>{try{m(t.throw(r))}catch(f){s(f)}},m=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,a);m((t=t.apply(u,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ie=require("three/examples/jsm/lines/LineMaterial"),Ue=require("three/examples/jsm/lines/LineSegmentsGeometry"),P=require("../WebGPULineSegments2.js"),c=require("three"),pe=require("three/examples/jsm/utils/BufferGeometryUtils"),Ve=require("../uvGenerator.js"),he=require("three-bvh-csg"),Ye=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),Ze=require("@tweenjs/tween.js"),$e=require("three/examples/jsm/lines/LineSegments2");function Je(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=Je(Ze);function H(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={},m=u[0].morphTargetsRelative,r=new c.BufferGeometry;let f=0;for(let i=0;i<u.length;++i){const l=u[i];let b=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]),b++}if(b!==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(m!==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 y of l.groups){let T=y.materialIndex;r.addGroup(f+y.start,Math.min(y.count,d),T)}f+=d}}if(t){let i=0;const l=[];for(let b=0;b<u.length;++b){const d=u[b].index;for(let y=0;y<d.count;++y)l.push(d.getX(y)+i);i+=u[b].attributes.position.count}r.setIndex(l)}for(const i in o){const l=pe.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 b=0;b<l;++b){const d=[];for(let T=0;T<a[i].length;++T)d.push(a[i][T][b]);const y=pe.mergeAttributes(d);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" morphAttribute."),null;r.morphAttributes[i].push(y)}}return e===2?pe.mergeGroups(r):r}const _e=u=>{const m=u,{coordinate:e,startHeight:t,height:n}=m,s=me(m,["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 Qe 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=me(r,["geometry","coordinateArr","coordinate","material","useGroups"]);let m=e;if(!m&&n)m=_e(B({coordinate:n},a));else if(!m&&t){const f=t.map(i=>_e(B({coordinate:i},a)));m=H(f,o!=null?o:0)}this.createMesh(m,s)}}const Ke={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 m=0,r=e.length;m<r;m++){const f=e[m];a(f)}this.setAttribute("position",new c.Float32BufferAttribute(s,3)),this.setAttribute("uv",new c.Float32BufferAttribute(o,2)),this.computeVertexNormals();function a(m){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 b=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,y=t.bevelSize!==void 0?t.bevelSize:d-.1,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:et,S=(Se=t.hasTop)!=null?Se:!0,V=(Ae=t.hasBottom)!=null?Ae:!0,Q=(Me=t.hasSide)!=null?Me:!0;let N,Y=!1,U,te,ne,D;M&&(N=M.getSpacedPoints(i),Y=!0,b=!1,U=M.computeFrenetFrames(i,!1),te=new c.Vector3,ne=new c.Vector3,D=new c.Vector3),b||(A=0,d=0,y=0,T=0);const ye=m.extractPoints(f);let I=ye.shape;const _=ye.holes;if(!c.ShapeUtils.isClockWise(I)){I=I.reverse();for(let h=0,p=_.length;h<p;h++){const g=_[h];c.ShapeUtils.isClockWise(g)&&(_[h]=g.reverse())}}function 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 p=_[h];I=I.concat(p)}function K(h,p,g){return p||console.error("THREE.ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(p,g)}const W=I.length;function xe(h,p,g){let w,x,L;const v=h.x-p.x,C=h.y-p.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=p.x-C/O,Ce=p.y+v/O,We=g.x-E/Le,Xe=g.y+G/Le,Ge=((We-Te)*E-(Xe-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,p=R.length,g=p-1,w=h+1;h<p;h++,g++,w++)g===p&&(g=0),w===p&&(w=0),ie[h]=xe(R[h],R[g],R[w]);const de=[];let F,oe=ie.concat();for(let h=0,p=fe;h<p;h++){const g=_[h];F=[];for(let w=0,x=g.length,L=x-1,v=w+1;w<x;w++,L++,v++)L===x&&(L=0),v===x&&(v=0),F[w]=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=[],p=[];for(let g=0;g<A;g++){const w=g/A,x=d*Math.cos(w*Math.PI/2),L=y*Math.sin(w*Math.PI/2)+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&&p.push(E)}}Z=c.ShapeUtils.triangulateShape(h,p)}const re=Z.length,we=y+T;for(let h=0;h<W;h++){const p=b?K(I[h],oe[h],we):I[h];Y?(ne.copy(U.normals[0]).multiplyScalar(p.x),te.copy(U.binormals[0]).multiplyScalar(p.y),D.copy(N[0]).add(ne).add(te),X(D.x,D.y,D.z)):X(p.x,p.y,0)}for(let h=1;h<=i;h++)for(let p=0;p<W;p++){const g=b?K(I[p],oe[p],we):I[p];Y?(ne.copy(U.normals[h]).multiplyScalar(g.x),te.copy(U.binormals[h]).multiplyScalar(g.y),D.copy(N[h]).add(ne).add(te),X(D.x,D.y,D.z)):X(g.x,g.y,l/i*h)}for(let h=A-1;h>=0;h--){const p=h/A,g=d*Math.cos(p*Math.PI/2),w=y*Math.sin(p*Math.PI/2)+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+N[i-1].y,N[i-1].x+g):X(E.x,E.y,l+g)}}}He(),Q&&Ne();function He(){const h=s.length/3;if(b){let p=0,g=W*p;if(V)for(let w=0;w<re;w++){const x=Z[w];ae(x[2]+g,x[1]+g,x[0]+g)}if(p=i+A*2,g=W*p,S)for(let w=0;w<re;w++){const x=Z[w];ae(x[0]+g,x[1]+g,x[2]+g)}}else{if(V)for(let p=0;p<re;p++){const g=Z[p];ae(g[2],g[1],g[0])}if(S)for(let p=0;p<re;p++){const g=Z[p];ae(g[0]+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 p=0;ve(R,p),p+=R.length;for(let g=0,w=_.length;g<w;g++){const x=_[g];ve(x,p),p+=x.length}n.addGroup(h,s.length/3-h,1)}function ve(h,p){let g=h.length;for(;--g>=0;){const w=g;let x=g-1;x<0&&(x=h.length-1);for(let L=0,v=i+A*2;L<v;L++){const C=W*L,G=W*(L+1),E=p+w+C,z=p+x+C,$=p+x+G,O=p+w+G;De(E,z,$,O)}}}function X(h,p,g){r.push(h),r.push(p),r.push(g)}function ae(h,p,g){q(h),q(p),q(g);const w=s.length/3,x=j.generateTopUV(n,s,w-3,w-2,w-1);k(x[0]),k(x[1]),k(x[2])}function De(h,p,g,w){q(h),q(p),q(w),q(p),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 tt(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,a=e.shapes.length;o<a;o++){const m=t[e.shapes[o]];n.push(m)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new Ke[`${s.type}`]().fromJSON(s)),new J(n,e.options)}}const et={generateTopUV:function(u,e,t,n,s){const o=e[t*3],a=e[t*3+1],m=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(m,r),new c.Vector2(f,i)]},generateSideWallUV:function(u,e,t,n,s,o){const a=e[t*3],m=e[t*3+1],r=e[t*3+2],f=e[n*3],i=e[n*3+1],l=e[n*3+2],b=e[s*3],d=e[s*3+1],y=e[s*3+2],T=e[o*3],A=e[o*3+1],M=e[o*3+2];return Math.abs(m-i)<Math.abs(a-f)?[new c.Vector2(a,1-r),new c.Vector2(f,1-l),new c.Vector2(b,1-y),new c.Vector2(T,1-M)]:[new c.Vector2(m,1-r),new c.Vector2(i,1-l),new c.Vector2(d,1-y),new c.Vector2(A,1-M)]}};function tt(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 nt 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 m=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);m=Math.ceil(t.topSegments*j)}if(m<4)return this;const f=new c.PlaneGeometry(o.x,o.y,m,m),i=new he.Brush(f);i.position.set(a.x,a.y,a.z),i.updateMatrixWorld();const b=new he.Evaluator().evaluate(i,n,he.INTERSECTION),d=b.geometry.getAttribute("position"),y=new c.Float32BufferAttribute(d.count*2,2);for(let M=0;M<d.count;M++){const 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),N=d.getY(V),Y=(Q-M.x)/S.x,U=(N-M.y)/S.y;y.setXY(V,Y,U)}b.geometry.setAttribute("uv",y)}d.needsUpdate=!0;const T=new J(e,le(B({},t),{hasTop:!1})),A=H([b.geometry,T],2);this.copy(A.toNonIndexed())}}const ze=u=>{const{split:e,depth:t,points:n,box3:s,hasTop:o,hasBottom:a,hasSide:m,sideRepeat:r,topSegments:f}=u,i=f?nt: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:m,topSegments:f});return Ve.claerUVGenerator(),l};class st 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:m,box3:r,split:f,hasTop:i,hasBottom:l,hasSide:b}=this.options,d=Array.isArray(s)?s:[s],y=Array.isArray(r)?r:[r],T=m;let A=o;T||console.log("material is null"),!A&&e?A=ze({points:e,depth:d[0],box3:y[0],split:f,hasTop:i,hasBottom:l,hasSide:b}):!A&&t?A=H(t.map((M,j)=>{var S,V;return ze({points:M,depth:(S=d[j])!=null?S:d[0],box3:(V=y[j])!=null?V:y[0],split:f,hasTop:i,hasBottom:l,hasSide:b})}),n!=null?n:0):!A&&a&&a.length>1?A=H(a,n!=null?n:0):!A&&a&&a.length===1&&([A]=a),this.createMesh(A,T)})}addGeometries(e){const t=this.object3d,n=H([t.geometry,...e]);t.geometry=n}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const it=u=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:o,maxAnisotropy:a}=u;return new Promise(m=>{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 b=new c.CanvasTexture(i);m(b)},n?r.src=n:r instanceof HTMLImageElement||r.onload()})};class ot extends P.BaseObject{create(){this.createGroup()}}class rt extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,o,a,m,r,f,i,l,b,d,y,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,(m=e.intensity)!=null?m: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((b=e.color)!=null?b:16777215,(d=e.groundColor)!=null?d:16777215,(y=e.intensity)!=null?y:1);S.name="半球光",this.object3d=S,this.hemisphereLight=S}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Ye.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 Re 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),m=new c.BufferAttribute(new Float32Array(this.pointCount*4),2),r=new c.BufferAttribute(new Uint16Array((this.pointCount-1)*6),1);this.shape==="taper"&&(this.shapeFunction=f=>1*Math.pow(4*f*(1-f),1));for(let f=0,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 b=this.shape==="none"?1:this.shapeFunction(f/(this.pointCount-1));a.setX(i,b),a.setX(i+1,b);const d=f/(this.pointCount-1);if(m.setXY(i,d,0),m.setXY(i+1,d,1),f<this.pointCount-1){const y=f*2;r.setX(l+0,y+0),r.setX(l+1,y+1),r.setX(l+2,y+2),r.setX(l+3,y+2),r.setX(l+4,y+1),r.setX(l+5,y+3)}}this.setAttribute("position",e),this.setAttribute("previous",t),this.setAttribute("next",n),this.setAttribute("counters",s),this.setAttribute("side",o),this.setAttribute("width",a),this.setAttribute("uv",m),this.setIndex(r)}updateGeometry(){if(!this._points[0])return;const e=this.getAttribute("position"),t=this.getAttribute("previous"),n=this.getAttribute("next");let s=0,o=0,a=0;const m=this._points[0];t.setXYZ(o,m.x,m.y,m.z),o+=1,t.setXYZ(o,m.x,m.y,m.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 at(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 m=new c.Vector3,r=new c.Vector3,f=new c.Vector3,i=this instanceof c.LineSegments?2:1,l=a.index,b=a.attributes;if(l!==null){const d=l.array,y=b.position.array,T=b.width.array;for(let A=0,M=d.length-1;A<M;A+=i){const j=d[A],S=d[A+1];m.fromArray(y,j*3),r.fromArray(y,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,N=Q*Q;if(n.distanceSqToSegment(m,r,o,f)>N)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 Re;return n.setPoints(t,e),n},ue=new WeakMap;let ct=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:m,lineWidthArr:r,materialParameters:f}=this.options;let i=o,l=n;!i&&f&&(i=this.getMaterial(f)),!l&&e?l=ge({nodes:e,setPointWidth:m}):!l&&t?l=H(t.map((b,d)=>{let y=m;return!y&&r&&(y=()=>{var T;return(T=r[d])!=null?T:r[0]}),ge({nodes:b,setPointWidth:y})}),a!=null?a:0):!l&&s&&s.length>1?l=H(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=H([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:m,startShow:r}={}){const{offset:f,offsetLoop:i}=this.material.uniforms;if(ue.get(this.material)&&this.stopAnimation(),e===0)return;const l=s!=null?s:!0;f.value.x=1,i.value=l&&r?1:0;let b=0;const d=new ee.Tween(f.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:y})=>{l&&y<=0&&i.value===0&&(i.value=1),a==null||a(y)}).onRepeat(()=>{b+=1,o==null||o(b)}).onComplete(()=>{m==null||m()}).start();ue.set(this.material,d),this.material.addEventListener("dispose",()=>{this.stopAnimation()})}stopAnimation(){const e=ue.get(this.material);e&&(e.stop(),ee.remove(e),ue.delete(this.material),this.material.uniforms.offset.value.x=0,this.material.uniforms.offsetLoop.value=1)}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}};const Oe=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 lt 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:m,lineWidthArr:r,materialParameters:f,instanceCount:i}=this.options;let l=o,b=n;!l&&f&&(l=this.getMaterial(f)),!b&&e?b=Oe({points:e}):!b&&t?b=H(t.map(y=>Oe({points:y})),a!=null?a:0):!b&&s&&s.length>1?b=H(s,a!=null?a:0):!b&&s&&s.length===1&&([b]=s);const d=new Ue.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(b));if(this.pencil.options.WebGPUTHREE){i&&(d.instanceCount=i);const y=new P.LineSegments2(d,l);y.computeLineDistances(),this.object3d=y}else{const y=new $e.LineSegments2(d,l);y.computeLineDistances(),this.object3d=y}})}getMaterial(e){return new Ie.LineMaterial(B({color:new c.Color("#ffffff")},e))}}class ht extends P.BaseObject{constructor(e){super(),this.objectType="BaseObject#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 ut 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,m=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 b=Math.PI*2*(i/r),d=n[l],y=o?t*(i/m):t,T=this.createGeometry(y,b),A=s?s.clone():new c.MeshBasicMaterial({color:d});s&&A.color.set(d);const M=new c.Mesh(T,A);M.userData.depth=y,M.userData.index=l,M.rotateZ(f),f+=b,this.add(M)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,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:()=>Ie.LineMaterial});Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ue.LineSegmentsGeometry});exports.MeshLineMaterial=P.MeshLineMaterial;exports.getConicPolygonGeometry=P.PolygonGeometry;exports.getConicPolygonGeometryMetas=P.getMetas;exports.ConicPolygon=Qe;exports.ExtrudePolygon=st;exports.Group=ot;exports.Light=rt;exports.Line=ct;exports.Line2=lt;exports.MeshLineGeometry=Re;exports.MeshLineRaycast=at;exports.Node=ht;exports.Pie=ut;exports.getSplitTexture=it;
|
|
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="BaseObject#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,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Je = Object.defineProperty, Qe = Object.defineProperties;
|
|
2
|
+
var Ke = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var he = Object.getOwnPropertySymbols;
|
|
4
4
|
var Be = Object.prototype.hasOwnProperty, Oe = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var Ie = (p, e, t) => e in p ?
|
|
5
|
+
var Ie = (p, e, t) => e in p ? Je(p, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[e] = t, j = (p, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
7
|
Be.call(e, t) && Ie(p, t, e[t]);
|
|
8
8
|
if (he)
|
|
9
9
|
for (var t of he(e))
|
|
10
10
|
Oe.call(e, t) && Ie(p, t, e[t]);
|
|
11
11
|
return p;
|
|
12
|
-
}, ue = (p, e) =>
|
|
12
|
+
}, ue = (p, e) => Qe(p, Ke(e));
|
|
13
13
|
var ye = (p, e) => {
|
|
14
14
|
var t = {};
|
|
15
15
|
for (var n in p)
|
|
@@ -35,27 +35,27 @@ var oe = (p, e, t) => new Promise((n, s) => {
|
|
|
35
35
|
}, f = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(o, a);
|
|
36
36
|
f((t = t.apply(p, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import { LineMaterial as
|
|
39
|
-
import { LineMaterial as
|
|
40
|
-
import { LineSegmentsGeometry as
|
|
41
|
-
import { LineSegmentsGeometry as
|
|
42
|
-
import { P as
|
|
43
|
-
import { g as
|
|
44
|
-
import { BufferGeometry as me, Float32BufferAttribute as xe, Vector3 as _, ShapeUtils as fe, Shape as we, Vector2 as P, ArcCurve as
|
|
45
|
-
import { mergeAttributes as Re, mergeGroups as
|
|
46
|
-
import { g as
|
|
47
|
-
import { Brush as Ue, Evaluator as
|
|
48
|
-
import { RectAreaLightUniformsLib as
|
|
38
|
+
import { LineMaterial as et } from "three/examples/jsm/lines/LineMaterial";
|
|
39
|
+
import { LineMaterial as un } from "three/examples/jsm/lines/LineMaterial";
|
|
40
|
+
import { LineSegmentsGeometry as tt } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
41
|
+
import { LineSegmentsGeometry as dn } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
42
|
+
import { P as nt, a as Z, M as st, L as it } from "../WebGPULineSegments2.module.js";
|
|
43
|
+
import { g as pn } from "../WebGPULineSegments2.module.js";
|
|
44
|
+
import { BufferGeometry as me, Float32BufferAttribute as xe, Vector3 as _, ShapeUtils as fe, Shape as we, Vector2 as P, ArcCurve as ot, CatmullRomCurve3 as rt, CubicBezierCurve as at, CubicBezierCurve3 as ct, EllipseCurve as lt, LineCurve as ht, LineCurve3 as ut, QuadraticBezierCurve as ft, QuadraticBezierCurve3 as dt, SplineCurve as mt, Box3 as pt, PlaneGeometry as gt, CanvasTexture as yt, AmbientLight as bt, DirectionalLight as xt, PointLight as wt, SpotLight as vt, HemisphereLight as St, RectAreaLight as At, Matrix4 as Ne, BufferAttribute as Y, Ray as Mt, Sphere as Lt, LineSegments as We, Color as ke, MeshBasicMaterial as Tt, Mesh as Et } from "three";
|
|
45
|
+
import { mergeAttributes as Re, mergeGroups as Gt } from "three/examples/jsm/utils/BufferGeometryUtils";
|
|
46
|
+
import { g as Pt, c as Ct } from "../uvGenerator.module.js";
|
|
47
|
+
import { Brush as Ue, Evaluator as _t, INTERSECTION as jt } from "three-bvh-csg";
|
|
48
|
+
import { RectAreaLightUniformsLib as zt } from "three/examples/jsm/lights/RectAreaLightUniformsLib";
|
|
49
49
|
import * as ne from "@tweenjs/tween.js";
|
|
50
|
-
import { LineSegments2 as
|
|
51
|
-
function
|
|
50
|
+
import { LineSegments2 as It } from "three/examples/jsm/lines/LineSegments2";
|
|
51
|
+
function H(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();
|
|
55
55
|
let h = 0;
|
|
56
56
|
for (let i = 0; i < p.length; ++i) {
|
|
57
57
|
const c = p[i];
|
|
58
|
-
let
|
|
58
|
+
let g = 0;
|
|
59
59
|
if (t !== (c.index !== null))
|
|
60
60
|
return console.error(
|
|
61
61
|
"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."
|
|
@@ -65,9 +65,9 @@ function V(p, e = 0) {
|
|
|
65
65
|
return console.error(
|
|
66
66
|
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + '. All geometries must have compatible attributes; make sure "' + u + '" attribute exists among all geometries, or in none of them.'
|
|
67
67
|
), null;
|
|
68
|
-
o[u] === void 0 && (o[u] = []), o[u].push(c.attributes[u]),
|
|
68
|
+
o[u] === void 0 && (o[u] = []), o[u].push(c.attributes[u]), g++;
|
|
69
69
|
}
|
|
70
|
-
if (
|
|
70
|
+
if (g !== n.size)
|
|
71
71
|
return console.error(
|
|
72
72
|
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + ". Make sure all geometries have the same number of attributes."
|
|
73
73
|
), null;
|
|
@@ -95,11 +95,11 @@ function V(p, e = 0) {
|
|
|
95
95
|
if (e === 1)
|
|
96
96
|
r.addGroup(h, u, i);
|
|
97
97
|
else if (e === 2 && c.groups.length > 0)
|
|
98
|
-
for (let
|
|
99
|
-
let L =
|
|
98
|
+
for (let y of c.groups) {
|
|
99
|
+
let L = y.materialIndex;
|
|
100
100
|
r.addGroup(
|
|
101
|
-
h +
|
|
102
|
-
Math.min(
|
|
101
|
+
h + y.start,
|
|
102
|
+
Math.min(y.count, u),
|
|
103
103
|
L
|
|
104
104
|
);
|
|
105
105
|
}
|
|
@@ -109,11 +109,11 @@ function V(p, e = 0) {
|
|
|
109
109
|
if (t) {
|
|
110
110
|
let i = 0;
|
|
111
111
|
const c = [];
|
|
112
|
-
for (let
|
|
113
|
-
const u = p[
|
|
114
|
-
for (let
|
|
115
|
-
c.push(u.getX(
|
|
116
|
-
i += p[
|
|
112
|
+
for (let g = 0; g < p.length; ++g) {
|
|
113
|
+
const u = p[g].index;
|
|
114
|
+
for (let y = 0; y < u.count; ++y)
|
|
115
|
+
c.push(u.getX(y) + i);
|
|
116
|
+
i += p[g].attributes.position.count;
|
|
117
117
|
}
|
|
118
118
|
r.setIndex(c);
|
|
119
119
|
}
|
|
@@ -129,29 +129,29 @@ function V(p, e = 0) {
|
|
|
129
129
|
const c = a[i][0].length;
|
|
130
130
|
if (c === 0) break;
|
|
131
131
|
r.morphAttributes = r.morphAttributes || {}, r.morphAttributes[i] = [];
|
|
132
|
-
for (let
|
|
132
|
+
for (let g = 0; g < c; ++g) {
|
|
133
133
|
const u = [];
|
|
134
134
|
for (let L = 0; L < a[i].length; ++L)
|
|
135
|
-
u.push(a[i][L][
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
135
|
+
u.push(a[i][L][g]);
|
|
136
|
+
const y = Re(u);
|
|
137
|
+
if (!y)
|
|
138
138
|
return console.error(
|
|
139
139
|
"THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + i + " morphAttribute."
|
|
140
140
|
), null;
|
|
141
|
-
r.morphAttributes[i].push(
|
|
141
|
+
r.morphAttributes[i].push(y);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
return e === 2 ?
|
|
144
|
+
return e === 2 ? Gt(r) : r;
|
|
145
145
|
}
|
|
146
|
-
const
|
|
146
|
+
const De = (p) => {
|
|
147
147
|
const f = p, { coordinate: e, startHeight: t, height: n } = f, s = ye(f, ["coordinate", "startHeight", "height"]);
|
|
148
148
|
let o = t || 0;
|
|
149
|
-
return typeof t != "undefined" && typeof n != "undefined" && (o = t + n), new
|
|
149
|
+
return typeof t != "undefined" && typeof n != "undefined" && (o = t + n), new nt([e], ue(j({}, s), {
|
|
150
150
|
startHeight: t,
|
|
151
151
|
endHeight: o
|
|
152
152
|
}));
|
|
153
153
|
};
|
|
154
|
-
class
|
|
154
|
+
class Jt extends Z {
|
|
155
155
|
constructor(e) {
|
|
156
156
|
super(), this.options = j({}, e);
|
|
157
157
|
}
|
|
@@ -171,31 +171,31 @@ class $t extends Z {
|
|
|
171
171
|
]);
|
|
172
172
|
let f = e;
|
|
173
173
|
if (!f && n)
|
|
174
|
-
f =
|
|
174
|
+
f = De(j({
|
|
175
175
|
coordinate: n
|
|
176
176
|
}, a));
|
|
177
177
|
else if (!f && t) {
|
|
178
178
|
const h = t.map(
|
|
179
|
-
(i) =>
|
|
179
|
+
(i) => De(j({
|
|
180
180
|
coordinate: i
|
|
181
181
|
}, a))
|
|
182
182
|
);
|
|
183
|
-
f =
|
|
183
|
+
f = H(h, o != null ? o : 0);
|
|
184
184
|
}
|
|
185
185
|
this.createMesh(f, s);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
ArcCurve:
|
|
190
|
-
CatmullRomCurve3:
|
|
191
|
-
CubicBezierCurve:
|
|
192
|
-
CubicBezierCurve3:
|
|
193
|
-
EllipseCurve:
|
|
194
|
-
LineCurve:
|
|
195
|
-
LineCurve3:
|
|
196
|
-
QuadraticBezierCurve:
|
|
197
|
-
QuadraticBezierCurve3:
|
|
198
|
-
SplineCurve:
|
|
188
|
+
const Bt = {
|
|
189
|
+
ArcCurve: ot,
|
|
190
|
+
CatmullRomCurve3: rt,
|
|
191
|
+
CubicBezierCurve: at,
|
|
192
|
+
CubicBezierCurve3: ct,
|
|
193
|
+
EllipseCurve: lt,
|
|
194
|
+
LineCurve: ht,
|
|
195
|
+
LineCurve3: ut,
|
|
196
|
+
QuadraticBezierCurve: ft,
|
|
197
|
+
QuadraticBezierCurve3: dt,
|
|
198
|
+
SplineCurve: mt
|
|
199
199
|
};
|
|
200
200
|
class K extends me {
|
|
201
201
|
/**
|
|
@@ -223,10 +223,10 @@ class K extends me {
|
|
|
223
223
|
function a(f) {
|
|
224
224
|
var Te, Ee, Ge;
|
|
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
|
-
let
|
|
227
|
-
const A = t.extrudePath, C = t.UVGenerator !== void 0 ? t.UVGenerator :
|
|
228
|
-
let
|
|
229
|
-
A && (
|
|
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
|
+
const A = t.extrudePath, C = t.UVGenerator !== void 0 ? t.UVGenerator : Ot, v = (Te = t.hasTop) != null ? Te : !0, z = (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);
|
|
230
230
|
const ve = f.extractPoints(h);
|
|
231
231
|
let R = ve.shape;
|
|
232
232
|
const I = ve.holes;
|
|
@@ -255,7 +255,7 @@ class K extends me {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
Se(R), I.forEach(Se);
|
|
258
|
-
const pe = I.length,
|
|
258
|
+
const pe = I.length, D = R;
|
|
259
259
|
for (let l = 0; l < pe; l++) {
|
|
260
260
|
const d = I[l];
|
|
261
261
|
R = R.concat(d);
|
|
@@ -270,7 +270,7 @@ class K extends me {
|
|
|
270
270
|
if (Math.abs(Q) > Number.EPSILON) {
|
|
271
271
|
const O = Math.sqrt(B), Pe = Math.sqrt(
|
|
272
272
|
E * E + G * G
|
|
273
|
-
), Ce = d.x - T / O, _e = d.y + w / O,
|
|
273
|
+
), Ce = d.x - T / O, _e = d.y + w / O, Ze = m.x - G / Pe, $e = m.y + E / Pe, je = ((Ze - Ce) * G - ($e - _e) * E) / (w * G - T * E);
|
|
274
274
|
x = Ce + w * je - l.x, b = _e + T * je - l.y;
|
|
275
275
|
const ze = x * x + b * b;
|
|
276
276
|
if (ze <= 2)
|
|
@@ -283,8 +283,8 @@ class K extends me {
|
|
|
283
283
|
return new P(x / M, b / M);
|
|
284
284
|
}
|
|
285
285
|
const re = [];
|
|
286
|
-
for (let l = 0, d =
|
|
287
|
-
m === d && (m = 0), x === d && (x = 0), re[l] = Ae(
|
|
286
|
+
for (let l = 0, d = D.length, m = d - 1, x = l + 1; l < d; l++, m++, x++)
|
|
287
|
+
m === d && (m = 0), x === d && (x = 0), re[l] = Ae(D[l], D[m], D[x]);
|
|
288
288
|
const ge = [];
|
|
289
289
|
let q, ae = re.concat();
|
|
290
290
|
for (let l = 0, d = pe; l < d; l++) {
|
|
@@ -296,13 +296,13 @@ class K extends me {
|
|
|
296
296
|
}
|
|
297
297
|
let J;
|
|
298
298
|
if (S === 0)
|
|
299
|
-
J = fe.triangulateShape(
|
|
299
|
+
J = fe.triangulateShape(D, I);
|
|
300
300
|
else {
|
|
301
301
|
const l = [], d = [];
|
|
302
302
|
for (let m = 0; m < S; m++) {
|
|
303
|
-
const x = m / S, b = u * Math.cos(x * Math.PI / 2), M =
|
|
304
|
-
for (let w = 0, T =
|
|
305
|
-
const E = te(
|
|
303
|
+
const x = m / S, b = u * Math.cos(x * Math.PI / 2), M = y * Math.sin(x * Math.PI / 2) + L;
|
|
304
|
+
for (let w = 0, T = D.length; w < T; w++) {
|
|
305
|
+
const E = te(D[w], re[w], M);
|
|
306
306
|
W(E.x, E.y, -b), x === 0 && l.push(E);
|
|
307
307
|
}
|
|
308
308
|
for (let w = 0, T = pe; w < T; w++) {
|
|
@@ -321,20 +321,20 @@ class K extends me {
|
|
|
321
321
|
d
|
|
322
322
|
);
|
|
323
323
|
}
|
|
324
|
-
const ce = J.length, Me =
|
|
324
|
+
const ce = J.length, Me = y + L;
|
|
325
325
|
for (let l = 0; l < N; l++) {
|
|
326
|
-
const d =
|
|
327
|
-
$ ? (ie.copy(U.normals[0]).multiplyScalar(d.x), se.copy(U.binormals[0]).multiplyScalar(d.y),
|
|
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);
|
|
328
328
|
}
|
|
329
329
|
for (let l = 1; l <= i; l++)
|
|
330
330
|
for (let d = 0; d < N; d++) {
|
|
331
|
-
const m =
|
|
332
|
-
$ ? (ie.copy(U.normals[l]).multiplyScalar(m.x), se.copy(U.binormals[l]).multiplyScalar(m.y),
|
|
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);
|
|
333
333
|
}
|
|
334
334
|
for (let l = S - 1; l >= 0; l--) {
|
|
335
|
-
const d = l / S, m = u * Math.cos(d * Math.PI / 2), x =
|
|
336
|
-
for (let b = 0, M =
|
|
337
|
-
const w = te(
|
|
335
|
+
const d = l / S, m = u * Math.cos(d * Math.PI / 2), x = y * Math.sin(d * Math.PI / 2) + L;
|
|
336
|
+
for (let b = 0, M = D.length; b < M; b++) {
|
|
337
|
+
const w = te(D[b], re[b], x);
|
|
338
338
|
W(w.x, w.y, c + m);
|
|
339
339
|
}
|
|
340
340
|
for (let b = 0, M = I.length; b < M; b++) {
|
|
@@ -344,16 +344,16 @@ class K extends me {
|
|
|
344
344
|
const G = te(w[T], q[T], x);
|
|
345
345
|
$ ? W(
|
|
346
346
|
G.x,
|
|
347
|
-
G.y +
|
|
348
|
-
|
|
347
|
+
G.y + V[i - 1].y,
|
|
348
|
+
V[i - 1].x + m
|
|
349
349
|
) : W(G.x, G.y, c + m);
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
function
|
|
353
|
+
Fe(), ee && qe();
|
|
354
|
+
function Fe() {
|
|
355
355
|
const l = s.length / 3;
|
|
356
|
-
if (
|
|
356
|
+
if (g) {
|
|
357
357
|
let d = 0, m = N * d;
|
|
358
358
|
if (z)
|
|
359
359
|
for (let x = 0; x < ce; x++) {
|
|
@@ -383,10 +383,10 @@ class K extends me {
|
|
|
383
383
|
}
|
|
384
384
|
n.addGroup(l, s.length / 3 - l, 0);
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function qe() {
|
|
387
387
|
const l = s.length / 3;
|
|
388
388
|
let d = 0;
|
|
389
|
-
Le(
|
|
389
|
+
Le(D, d), d += D.length;
|
|
390
390
|
for (let m = 0, x = I.length; m < x; m++) {
|
|
391
391
|
const b = I[m];
|
|
392
392
|
Le(b, d), d += b.length;
|
|
@@ -401,7 +401,7 @@ class K extends me {
|
|
|
401
401
|
b < 0 && (b = l.length - 1);
|
|
402
402
|
for (let M = 0, w = i + S * 2; M < w; M++) {
|
|
403
403
|
const T = N * M, E = N * (M + 1), G = d + x + T, B = d + b + T, Q = d + b + E, O = d + x + E;
|
|
404
|
-
|
|
404
|
+
Ye(G, B, Q, O);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
}
|
|
@@ -419,7 +419,7 @@ class K extends me {
|
|
|
419
419
|
);
|
|
420
420
|
F(b[0]), F(b[1]), F(b[2]);
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function Ye(l, d, m, x) {
|
|
423
423
|
k(l), k(d), k(x), k(d), k(m), k(x);
|
|
424
424
|
const b = s.length / 3, M = C.generateSideWallUV(
|
|
425
425
|
n,
|
|
@@ -444,7 +444,7 @@ class K extends me {
|
|
|
444
444
|
}
|
|
445
445
|
toJSON() {
|
|
446
446
|
const e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options;
|
|
447
|
-
return
|
|
447
|
+
return Rt(t, n, e);
|
|
448
448
|
}
|
|
449
449
|
/**
|
|
450
450
|
* Factory method for creating an instance of this class from the given
|
|
@@ -461,12 +461,12 @@ 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
|
|
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
|
}
|
|
468
468
|
}
|
|
469
|
-
const
|
|
469
|
+
const Ot = {
|
|
470
470
|
generateTopUV: function(p, e, t, n, s) {
|
|
471
471
|
const o = e[t * 3], a = e[t * 3 + 1], f = e[n * 3], r = e[n * 3 + 1], h = e[s * 3], i = e[s * 3 + 1];
|
|
472
472
|
return [
|
|
@@ -476,21 +476,21 @@ const Bt = {
|
|
|
476
476
|
];
|
|
477
477
|
},
|
|
478
478
|
generateSideWallUV: function(p, e, t, n, s, o) {
|
|
479
|
-
const a = e[t * 3], f = e[t * 3 + 1], r = e[t * 3 + 2], h = e[n * 3], i = e[n * 3 + 1], c = e[n * 3 + 2],
|
|
479
|
+
const a = e[t * 3], f = e[t * 3 + 1], r = e[t * 3 + 2], h = e[n * 3], i = e[n * 3 + 1], c = e[n * 3 + 2], g = e[s * 3], u = e[s * 3 + 1], y = e[s * 3 + 2], L = e[o * 3], S = e[o * 3 + 1], A = e[o * 3 + 2];
|
|
480
480
|
return Math.abs(f - i) < Math.abs(a - h) ? [
|
|
481
481
|
new P(a, 1 - r),
|
|
482
482
|
new P(h, 1 - c),
|
|
483
|
-
new P(
|
|
483
|
+
new P(g, 1 - y),
|
|
484
484
|
new P(L, 1 - A)
|
|
485
485
|
] : [
|
|
486
486
|
new P(f, 1 - r),
|
|
487
487
|
new P(i, 1 - c),
|
|
488
|
-
new P(u, 1 -
|
|
488
|
+
new P(u, 1 - y),
|
|
489
489
|
new P(S, 1 - A)
|
|
490
490
|
];
|
|
491
491
|
}
|
|
492
492
|
};
|
|
493
|
-
function
|
|
493
|
+
function Rt(p, e, t) {
|
|
494
494
|
if (t.shapes = [], Array.isArray(p))
|
|
495
495
|
for (let n = 0, s = p.length; n < s; n++) {
|
|
496
496
|
const o = p[n];
|
|
@@ -500,7 +500,7 @@ function Ot(p, e, t) {
|
|
|
500
500
|
t.shapes.push(p.uuid);
|
|
501
501
|
return t.options = Object.assign({}, e), e.extrudePath !== void 0 && (t.options.extrudePath = e.extrudePath.toJSON()), t;
|
|
502
502
|
}
|
|
503
|
-
class
|
|
503
|
+
class Ut extends K {
|
|
504
504
|
constructor(e, t) {
|
|
505
505
|
super(e, t);
|
|
506
506
|
const n = new Ue(
|
|
@@ -511,7 +511,7 @@ class Rt extends K {
|
|
|
511
511
|
}))
|
|
512
512
|
);
|
|
513
513
|
n.updateMatrixWorld();
|
|
514
|
-
const s = new
|
|
514
|
+
const s = new pt().setFromObject(n), o = new _();
|
|
515
515
|
s.getSize(o);
|
|
516
516
|
const a = new _(
|
|
517
517
|
s.min.x + o.x / 2,
|
|
@@ -531,14 +531,14 @@ class Rt extends K {
|
|
|
531
531
|
}
|
|
532
532
|
if (f < 4)
|
|
533
533
|
return this;
|
|
534
|
-
const h = new
|
|
534
|
+
const h = new gt(
|
|
535
535
|
o.x,
|
|
536
536
|
o.y,
|
|
537
537
|
f,
|
|
538
538
|
f
|
|
539
539
|
), i = new Ue(h);
|
|
540
540
|
i.position.set(a.x, a.y, a.z), i.updateMatrixWorld();
|
|
541
|
-
const
|
|
541
|
+
const g = new _t().evaluate(i, n, jt), u = g.geometry.getAttribute("position"), y = new xe(
|
|
542
542
|
u.count * 2,
|
|
543
543
|
2
|
|
544
544
|
);
|
|
@@ -549,19 +549,19 @@ class Rt extends K {
|
|
|
549
549
|
if (r) {
|
|
550
550
|
const A = r.min, C = r.max, v = new _().subVectors(C, A);
|
|
551
551
|
for (let z = 0; z < u.count; z++) {
|
|
552
|
-
const ee = u.getX(z),
|
|
553
|
-
|
|
552
|
+
const ee = u.getX(z), V = u.getY(z), $ = (ee - A.x) / v.x, U = (V - A.y) / v.y;
|
|
553
|
+
y.setXY(z, $, U);
|
|
554
554
|
}
|
|
555
|
-
|
|
555
|
+
g.geometry.setAttribute("uv", y);
|
|
556
556
|
}
|
|
557
557
|
u.needsUpdate = !0;
|
|
558
558
|
const L = new K(e, ue(j({}, t), {
|
|
559
559
|
hasTop: !1
|
|
560
|
-
})), S =
|
|
560
|
+
})), S = H([g.geometry, L], 2);
|
|
561
561
|
this.copy(S.toNonIndexed());
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
const
|
|
564
|
+
const He = (p) => {
|
|
565
565
|
const {
|
|
566
566
|
split: e,
|
|
567
567
|
depth: t,
|
|
@@ -572,11 +572,11 @@ const Ve = (p) => {
|
|
|
572
572
|
hasSide: f,
|
|
573
573
|
sideRepeat: r,
|
|
574
574
|
topSegments: h
|
|
575
|
-
} = p, i = h ?
|
|
575
|
+
} = p, i = h ? Ut : K, c = new i(new we(n), {
|
|
576
576
|
depth: t,
|
|
577
577
|
bevelEnabled: !1,
|
|
578
578
|
box3: s,
|
|
579
|
-
UVGenerator:
|
|
579
|
+
UVGenerator: Pt({
|
|
580
580
|
split: e,
|
|
581
581
|
box3: s,
|
|
582
582
|
sideRepeat: r
|
|
@@ -586,9 +586,9 @@ const Ve = (p) => {
|
|
|
586
586
|
hasSide: f,
|
|
587
587
|
topSegments: h
|
|
588
588
|
});
|
|
589
|
-
return
|
|
589
|
+
return Ct(), c;
|
|
590
590
|
};
|
|
591
|
-
class
|
|
591
|
+
class Qt extends Z {
|
|
592
592
|
constructor(e) {
|
|
593
593
|
super(), this.options = j({
|
|
594
594
|
depth: 1
|
|
@@ -608,45 +608,45 @@ class Jt extends Z {
|
|
|
608
608
|
split: h,
|
|
609
609
|
hasTop: i,
|
|
610
610
|
hasBottom: c,
|
|
611
|
-
hasSide:
|
|
612
|
-
} = this.options, u = Array.isArray(s) ? s : [s],
|
|
611
|
+
hasSide: g
|
|
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 =
|
|
614
|
+
L || console.log("material is null"), !S && e ? S = He({
|
|
615
615
|
points: e,
|
|
616
616
|
depth: u[0],
|
|
617
|
-
box3:
|
|
617
|
+
box3: y[0],
|
|
618
618
|
split: h,
|
|
619
619
|
hasTop: i,
|
|
620
620
|
hasBottom: c,
|
|
621
|
-
hasSide:
|
|
622
|
-
}) : !S && t ? S =
|
|
621
|
+
hasSide: g
|
|
622
|
+
}) : !S && t ? S = H(
|
|
623
623
|
t.map(
|
|
624
624
|
(A, C) => {
|
|
625
625
|
var v, z;
|
|
626
|
-
return
|
|
626
|
+
return He({
|
|
627
627
|
points: A,
|
|
628
628
|
depth: (v = u[C]) != null ? v : u[0],
|
|
629
|
-
box3: (z =
|
|
629
|
+
box3: (z = y[C]) != null ? z : y[0],
|
|
630
630
|
split: h,
|
|
631
631
|
hasTop: i,
|
|
632
632
|
hasBottom: c,
|
|
633
|
-
hasSide:
|
|
633
|
+
hasSide: g
|
|
634
634
|
});
|
|
635
635
|
}
|
|
636
636
|
),
|
|
637
637
|
n != null ? n : 0
|
|
638
|
-
) : !S && a && a.length > 1 ? S =
|
|
638
|
+
) : !S && a && a.length > 1 ? S = H(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 =
|
|
642
|
+
const t = this.object3d, n = H([t.geometry, ...e]);
|
|
643
643
|
t.geometry = n;
|
|
644
644
|
}
|
|
645
645
|
setTextureAnisotropic(e, t) {
|
|
646
646
|
e.anisotropy = t || this.pencil.renderer.capabilities.getMaxAnisotropy();
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
const
|
|
649
|
+
const Kt = (p) => {
|
|
650
650
|
const {
|
|
651
651
|
topColor: e,
|
|
652
652
|
sideColor: t,
|
|
@@ -668,31 +668,31 @@ const Qt = (p) => {
|
|
|
668
668
|
i.height = r.height / (1 - h), i.width = r.width, h && e && (c.fillStyle = e, c.fillRect(0, 0, r.width, i.height * h)), n && r instanceof HTMLImageElement ? c.drawImage(r, 0, i.height * h, r.width, r.height) : t && (c.fillStyle = t, c.fillRect(0, i.height * h, r.width, r.height)), s && i.toBlob((u) => {
|
|
669
669
|
console.log(URL.createObjectURL(u));
|
|
670
670
|
});
|
|
671
|
-
const
|
|
672
|
-
f(
|
|
671
|
+
const g = new yt(i);
|
|
672
|
+
f(g);
|
|
673
673
|
}, n ? r.src = n : r instanceof HTMLImageElement || r.onload();
|
|
674
674
|
});
|
|
675
675
|
};
|
|
676
|
-
class
|
|
676
|
+
class en extends Z {
|
|
677
677
|
create() {
|
|
678
678
|
this.createGroup();
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
|
-
class
|
|
681
|
+
class tn extends Z {
|
|
682
682
|
constructor(e) {
|
|
683
683
|
super(), this.rectAreaLightUniformsLibInit = !1, this.options = e;
|
|
684
684
|
}
|
|
685
685
|
create() {
|
|
686
|
-
var t, n, s, o, a, f, r, h, i, c,
|
|
686
|
+
var t, n, s, o, a, f, r, h, i, c, g, u, y, L, S, A, C;
|
|
687
687
|
const e = this.options;
|
|
688
688
|
if (e.type === "AmbientLight") {
|
|
689
|
-
const v = new
|
|
689
|
+
const v = new bt(e.color);
|
|
690
690
|
v.name = "环境光", this.object3d = v;
|
|
691
691
|
} else if (e.type === "DirectionalLight") {
|
|
692
|
-
const v = new
|
|
692
|
+
const v = new xt(e.color, e.intensity);
|
|
693
693
|
v.name = "平行光", v.target.position.set(0, 0, 0), this.object3d = v, v.target.name = "平行光目标", v.shadow.camera.name = "平行光阴影相机", v.shadow.camera.userData.directionalLightShadow = !0, this.directionalLight = v;
|
|
694
694
|
} else if (e.type === "PointLight") {
|
|
695
|
-
const v = new
|
|
695
|
+
const v = new wt(
|
|
696
696
|
(t = e.color) != null ? t : 16777215,
|
|
697
697
|
(n = e.intensity) != null ? n : 1,
|
|
698
698
|
(s = e.distance) != null ? s : 0,
|
|
@@ -700,7 +700,7 @@ class en extends Z {
|
|
|
700
700
|
);
|
|
701
701
|
v.name = "点光源", this.object3d = v, this.pointLight = v;
|
|
702
702
|
} else if (e.type === "SpotLight") {
|
|
703
|
-
const v = new
|
|
703
|
+
const v = new vt(
|
|
704
704
|
(a = e.color) != null ? a : 16777215,
|
|
705
705
|
(f = e.intensity) != null ? f : 1,
|
|
706
706
|
(r = e.distance) != null ? r : 0,
|
|
@@ -710,15 +710,15 @@ class en extends Z {
|
|
|
710
710
|
);
|
|
711
711
|
v.name = "聚光灯", this.object3d = v, this.spotLight = v, v.target.name = "聚光灯目标";
|
|
712
712
|
} else if (e.type === "HemisphereLight") {
|
|
713
|
-
const v = new
|
|
714
|
-
(
|
|
713
|
+
const v = new St(
|
|
714
|
+
(g = e.color) != null ? g : 16777215,
|
|
715
715
|
(u = e.groundColor) != null ? u : 16777215,
|
|
716
|
-
(
|
|
716
|
+
(y = e.intensity) != null ? y : 1
|
|
717
717
|
);
|
|
718
718
|
v.name = "半球光", this.object3d = v, this.hemisphereLight = v;
|
|
719
719
|
} else if (e.type === "RectAreaLight") {
|
|
720
|
-
this.rectAreaLightUniformsLibInit || (
|
|
721
|
-
const v = new
|
|
720
|
+
this.rectAreaLightUniformsLibInit || (zt.init(), this.rectAreaLightUniformsLibInit = !0);
|
|
721
|
+
const v = new At(
|
|
722
722
|
(L = e.color) != null ? L : 16777215,
|
|
723
723
|
(S = e.intensity) != null ? S : 1,
|
|
724
724
|
(A = e.width) != null ? A : 10,
|
|
@@ -741,9 +741,9 @@ class en extends Z {
|
|
|
741
741
|
e.target && this.pencil.scene.remove(e.target), super.dispose();
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
|
-
class
|
|
744
|
+
class Dt extends me {
|
|
745
745
|
constructor(e = [], t = "none", n) {
|
|
746
|
-
super(), this.type = "MeshLineGeometry", this.pointCount = 0, this._points = [], this.shape = "none", this.shapeFunction = (s) => 1, this.matrixWorld = new
|
|
746
|
+
super(), this.type = "MeshLineGeometry", this.pointCount = 0, this._points = [], this.shape = "none", this.shapeFunction = (s) => 1, this.matrixWorld = new Ne(), this.shape = t, n && (this.shapeFunction = n), e.length > 0 && this.setPoints(e);
|
|
747
747
|
}
|
|
748
748
|
convertToVector3Array(e) {
|
|
749
749
|
if (typeof e[0] == "number") {
|
|
@@ -786,12 +786,12 @@ class Ut extends me {
|
|
|
786
786
|
this.shape === "taper" && (this.shapeFunction = (h) => 1 * Math.pow(4 * h * (1 - h), 1));
|
|
787
787
|
for (let h = 0, i = 0, c = 0; h < this.pointCount; h += 1, i += 2, c += 6) {
|
|
788
788
|
s.setX(i, h / this.pointCount), s.setX(i + 1, h / this.pointCount), o.setX(i, 1), o.setX(i + 1, -1);
|
|
789
|
-
const
|
|
790
|
-
a.setX(i,
|
|
789
|
+
const g = this.shape === "none" ? 1 : this.shapeFunction(h / (this.pointCount - 1));
|
|
790
|
+
a.setX(i, g), a.setX(i + 1, g);
|
|
791
791
|
const u = h / (this.pointCount - 1);
|
|
792
792
|
if (f.setXY(i, u, 0), f.setXY(i + 1, u, 1), h < this.pointCount - 1) {
|
|
793
|
-
const
|
|
794
|
-
r.setX(c + 0,
|
|
793
|
+
const y = h * 2;
|
|
794
|
+
r.setX(c + 0, y + 0), r.setX(c + 1, y + 1), r.setX(c + 2, y + 2), r.setX(c + 3, y + 2), r.setX(c + 4, y + 1), r.setX(c + 5, y + 3);
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
797
|
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", f), this.setIndex(r);
|
|
@@ -829,23 +829,23 @@ class Ut extends me {
|
|
|
829
829
|
this.shape = e, t && (this.shapeFunction = t), this._points.length > 0 && (this.initializeGeometry(), this.updateGeometry());
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
|
-
function
|
|
833
|
-
const t = new
|
|
832
|
+
function nn(p, e) {
|
|
833
|
+
const t = new Ne(), n = new Mt(), s = new Lt(), o = new _(), a = this.geometry;
|
|
834
834
|
if (s.copy(a.boundingSphere), s.applyMatrix4(this.matrixWorld), !p.ray.intersectSphere(s, o)) return;
|
|
835
835
|
t.copy(this.matrixWorld).invert(), n.copy(p.ray).applyMatrix4(t);
|
|
836
|
-
const f = new _(), r = new _(), h = new _(), i = this instanceof
|
|
836
|
+
const f = new _(), r = new _(), h = new _(), i = this instanceof We ? 2 : 1, c = a.index, g = a.attributes;
|
|
837
837
|
if (c !== null) {
|
|
838
|
-
const u = c.array,
|
|
838
|
+
const u = c.array, y = g.position.array, L = g.width.array;
|
|
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
|
-
f.fromArray(
|
|
842
|
-
const z = L[Math.floor(S / 3)] !== void 0 ? L[Math.floor(S / 3)] : 1, ee = p.params.Line.threshold + this.material.lineWidth * z / 2,
|
|
841
|
+
f.fromArray(y, C * 3), r.fromArray(y, v * 3);
|
|
842
|
+
const z = L[Math.floor(S / 3)] !== void 0 ? L[Math.floor(S / 3)] : 1, ee = p.params.Line.threshold + this.material.lineWidth * z / 2, V = ee * ee;
|
|
843
843
|
if (n.distanceSqToSegment(
|
|
844
844
|
f,
|
|
845
845
|
r,
|
|
846
846
|
o,
|
|
847
847
|
h
|
|
848
|
-
) >
|
|
848
|
+
) > V) 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({
|
|
@@ -862,10 +862,10 @@ function tn(p, e) {
|
|
|
862
862
|
}
|
|
863
863
|
}
|
|
864
864
|
const be = (p) => {
|
|
865
|
-
const { setPointWidth: e, nodes: t } = p, n = new
|
|
865
|
+
const { setPointWidth: e, nodes: t } = p, n = new Dt();
|
|
866
866
|
return n.setPoints(t, e), n;
|
|
867
|
-
},
|
|
868
|
-
let
|
|
867
|
+
}, Ve = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new Map();
|
|
868
|
+
let sn = class extends Z {
|
|
869
869
|
constructor(e = {}) {
|
|
870
870
|
super(), this.options = j({}, e);
|
|
871
871
|
}
|
|
@@ -890,19 +890,19 @@ let nn = 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 =
|
|
894
|
-
t.map((
|
|
895
|
-
let
|
|
896
|
-
return !
|
|
893
|
+
}) : !c && t ? c = H(
|
|
894
|
+
t.map((g, u) => {
|
|
895
|
+
let y = f;
|
|
896
|
+
return !y && r && (y = () => {
|
|
897
897
|
var L;
|
|
898
898
|
return (L = r[u]) != null ? L : r[0];
|
|
899
899
|
}), be({
|
|
900
|
-
nodes:
|
|
901
|
-
setPointWidth:
|
|
900
|
+
nodes: g,
|
|
901
|
+
setPointWidth: y
|
|
902
902
|
});
|
|
903
903
|
}),
|
|
904
904
|
a != null ? a : 0
|
|
905
|
-
) : !c && s && s.length > 1 ? c =
|
|
905
|
+
) : !c && s && s.length > 1 ? c = H(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) {
|
|
@@ -913,13 +913,13 @@ let nn = class extends Z {
|
|
|
913
913
|
s.geometry = n, o.dispose();
|
|
914
914
|
}
|
|
915
915
|
getMaterial(e) {
|
|
916
|
-
const { width: t, height: n } = this.pencil.getSize(), s = new
|
|
917
|
-
color: new
|
|
916
|
+
const { width: t, height: n } = this.pencil.getSize(), s = new st(j({
|
|
917
|
+
color: new ke("#ffffff")
|
|
918
918
|
}, e));
|
|
919
919
|
return s.uniforms.resolution.value.set(t, n), s;
|
|
920
920
|
}
|
|
921
921
|
addGeometries(e) {
|
|
922
|
-
const t = this.object3d, n =
|
|
922
|
+
const t = this.object3d, n = H([t.geometry, ...e]);
|
|
923
923
|
t.geometry = n;
|
|
924
924
|
}
|
|
925
925
|
resize(e, t) {
|
|
@@ -942,25 +942,25 @@ let nn = class extends Z {
|
|
|
942
942
|
onComplete: f,
|
|
943
943
|
startShow: r
|
|
944
944
|
} = {}) {
|
|
945
|
-
const { offset: h, offsetLoop: i } = this.material.uniforms;
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
h.value.x = 1, i.value =
|
|
949
|
-
let
|
|
950
|
-
const
|
|
951
|
-
|
|
945
|
+
const { offset: h, offsetLoop: i } = this.material.uniforms, c = this.pencil.userData.debugLine ? de : Ve;
|
|
946
|
+
if (c.get(this.material) && this.stopAnimation(), e === 0) return;
|
|
947
|
+
const g = s != null ? s : !0;
|
|
948
|
+
h.value.x = 1, i.value = g && r ? 1 : 0;
|
|
949
|
+
let u = 0;
|
|
950
|
+
const y = new ne.Tween(h.value).to({ x: -1 }, e).delay(t).repeat(n).onUpdate(({ x: L }) => {
|
|
951
|
+
g && L <= 0 && i.value === 0 && (i.value = 1), a == null || a(L);
|
|
952
952
|
}).onRepeat(() => {
|
|
953
|
-
|
|
953
|
+
u += 1, o == null || o(u);
|
|
954
954
|
}).onComplete(() => {
|
|
955
955
|
f == null || f();
|
|
956
956
|
}).start();
|
|
957
|
-
|
|
957
|
+
c.set(this.material, y), this.material.addEventListener("dispose", () => {
|
|
958
958
|
this.stopAnimation();
|
|
959
|
-
});
|
|
959
|
+
}), this.pencil.userData.debugLine && console.log("animate", de.size);
|
|
960
960
|
}
|
|
961
961
|
stopAnimation() {
|
|
962
|
-
const e = de.get(this.material);
|
|
963
|
-
|
|
962
|
+
const e = this.pencil.userData.debugLine ? de : Ve, t = e.get(this.material);
|
|
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() {
|
|
966
966
|
const { width: e, height: t } = this.pencil.getSize();
|
|
@@ -971,7 +971,7 @@ const Xe = (p) => {
|
|
|
971
971
|
const { points: e } = p, t = e.reduce((s, o, a) => (a < e.length - 1 && s.push(o, e[a + 1]), s), []);
|
|
972
972
|
return new me().setFromPoints(t);
|
|
973
973
|
};
|
|
974
|
-
class
|
|
974
|
+
class rn extends Z {
|
|
975
975
|
constructor(e = {}) {
|
|
976
976
|
super(), this.options = j({}, e);
|
|
977
977
|
}
|
|
@@ -993,35 +993,35 @@ class on extends Z {
|
|
|
993
993
|
materialParameters: h,
|
|
994
994
|
instanceCount: i
|
|
995
995
|
} = this.options;
|
|
996
|
-
let c = o,
|
|
997
|
-
!c && h && (c = this.getMaterial(h)), !
|
|
996
|
+
let c = o, g = n;
|
|
997
|
+
!c && h && (c = this.getMaterial(h)), !g && e ? g = Xe({
|
|
998
998
|
points: e
|
|
999
|
-
}) : !
|
|
1000
|
-
t.map((
|
|
1001
|
-
points:
|
|
999
|
+
}) : !g && t ? g = H(
|
|
1000
|
+
t.map((y) => Xe({
|
|
1001
|
+
points: y
|
|
1002
1002
|
})),
|
|
1003
1003
|
a != null ? a : 0
|
|
1004
|
-
) : !
|
|
1005
|
-
const u = new
|
|
1006
|
-
new
|
|
1004
|
+
) : !g && s && s.length > 1 ? g = H(s, a != null ? a : 0) : !g && s && s.length === 1 && ([g] = s);
|
|
1005
|
+
const u = new tt().fromLineSegments(
|
|
1006
|
+
new We(g)
|
|
1007
1007
|
);
|
|
1008
1008
|
if (this.pencil.options.WebGPUTHREE) {
|
|
1009
1009
|
i && (u.instanceCount = i);
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1010
|
+
const y = new it(u, c);
|
|
1011
|
+
y.computeLineDistances(), this.object3d = y;
|
|
1012
1012
|
} else {
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1013
|
+
const y = new It(u, c);
|
|
1014
|
+
y.computeLineDistances(), this.object3d = y;
|
|
1015
1015
|
}
|
|
1016
1016
|
});
|
|
1017
1017
|
}
|
|
1018
1018
|
getMaterial(e) {
|
|
1019
|
-
return new
|
|
1020
|
-
color: new
|
|
1019
|
+
return new et(j({
|
|
1020
|
+
color: new ke("#ffffff")
|
|
1021
1021
|
}, e));
|
|
1022
1022
|
}
|
|
1023
1023
|
}
|
|
1024
|
-
class
|
|
1024
|
+
class an extends Z {
|
|
1025
1025
|
constructor(e) {
|
|
1026
1026
|
super(), this.objectType = "BaseObject#Node", this.onNodePointerIndex = [], this.options = j({
|
|
1027
1027
|
type: "2d"
|
|
@@ -1068,7 +1068,7 @@ class rn extends Z {
|
|
|
1068
1068
|
}), super.dispose();
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
|
-
class
|
|
1071
|
+
class cn extends Z {
|
|
1072
1072
|
constructor(e) {
|
|
1073
1073
|
super(), this.options = j({
|
|
1074
1074
|
maxDepth: 10,
|
|
@@ -1085,12 +1085,12 @@ class an extends Z {
|
|
|
1085
1085
|
let h = Math.PI / 2;
|
|
1086
1086
|
e.forEach((i, c) => {
|
|
1087
1087
|
if (i === 0) return;
|
|
1088
|
-
const
|
|
1088
|
+
const g = Math.PI * 2 * (i / r), u = n[c], y = o ? t * (i / f) : t, L = this.createGeometry(y, g), S = s ? s.clone() : new Tt({
|
|
1089
1089
|
color: u
|
|
1090
1090
|
});
|
|
1091
1091
|
s && S.color.set(u);
|
|
1092
|
-
const A = new
|
|
1093
|
-
A.userData.depth =
|
|
1092
|
+
const A = new Et(L, S);
|
|
1093
|
+
A.userData.depth = y, A.userData.index = c, A.rotateZ(h), h += g, this.add(A);
|
|
1094
1094
|
}), a !== -1 && this.setActive(a);
|
|
1095
1095
|
});
|
|
1096
1096
|
}
|
|
@@ -1129,20 +1129,20 @@ class an extends Z {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
export {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1132
|
+
Jt as ConicPolygon,
|
|
1133
|
+
Qt as ExtrudePolygon,
|
|
1134
|
+
en as Group,
|
|
1135
|
+
tn as Light,
|
|
1136
|
+
sn as Line,
|
|
1137
|
+
rn as Line2,
|
|
1138
|
+
un as Line2Material,
|
|
1139
|
+
dn as LineSegmentsGeometry,
|
|
1140
|
+
Dt as MeshLineGeometry,
|
|
1141
|
+
st as MeshLineMaterial,
|
|
1142
|
+
nn as MeshLineRaycast,
|
|
1143
|
+
an as Node,
|
|
1144
|
+
cn as Pie,
|
|
1145
|
+
nt as getConicPolygonGeometry,
|
|
1146
|
+
pn as getConicPolygonGeometryMetas,
|
|
1147
|
+
Kt as getSplitTexture
|
|
1148
1148
|
};
|