gl-draw 0.15.0-beta.3 → 0.15.0-beta.30
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/constants.d.ts +1 -0
- package/dist/core/BaseObject/PointerEvent.d.ts +13 -0
- package/dist/core/BaseObject/UseMaterial.d.ts +23 -0
- package/dist/core/{BaseObject.d.ts → BaseObject/index.d.ts} +24 -29
- package/dist/core/Composer.d.ts +5 -5
- package/dist/core/Lead/Lead.d.ts +17 -10
- package/dist/core/Lead/Pick.d.ts +2 -1
- package/dist/core/MList/MList.d.ts +11 -5
- package/dist/core/Pencil.d.ts +12 -10
- package/dist/core/Renderer.d.ts +0 -1
- package/dist/core/ResourceTracker.d.ts +4 -6
- package/dist/index.js +23 -23
- package/dist/index.module.js +1702 -1562
- package/dist/index.module2.js +641 -787
- package/dist/index2.js +130 -140
- package/dist/objects/conicPolygon/geometry/index.d.ts +4 -4
- package/dist/objects/extrudePolygon/ExtrudeGeometry.d.ts +1 -1
- package/dist/objects/extrudePolygon/createGeometry.d.ts +9 -13
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +811 -783
- package/dist/objects/line/createGeometry.d.ts +2 -2
- package/dist/objects/line/index.d.ts +4 -4
- package/dist/objects/line/meshLine/MeshLineGeometry.d.ts +16 -35
- package/dist/objects/line/meshLine/MeshLineMaterial.d.ts +59 -40
- package/dist/objects/line/meshLine/fragment.d.ts +1 -0
- package/dist/objects/line/meshLine/utils.d.ts +4 -0
- package/dist/objects/line/meshLine/vertex.d.ts +1 -0
- package/dist/objects/line2/WebGPULineSegments2.d.ts +1 -1
- package/dist/objects/line2/createGeometry.d.ts +1 -1
- package/dist/objects/pie/index.d.ts +9 -13
- package/dist/plugins/Worker/createGeometry.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +36 -36
- package/dist/utils/Sprite2Points.d.ts +1 -1
- package/dist/utils/setInstancedAttr.d.ts +6 -0
- package/package.json +1 -1
- package/dist/objects/scene/index.d.ts +0 -11
package/dist/index2.js
CHANGED
|
@@ -1,149 +1,139 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(s,e,t)=>e in s?pe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_=(s,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(s,t,e[t]);if(W)for(var t of W(e))ee.call(e,t)&&J(s,t,e[t]);return s},q=(s,e)=>me(s,ve(e));var ie=(s,e)=>{var t={};for(var i in s)H.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&W)for(var i of W(s))e.indexOf(i)<0&&ee.call(s,i)&&(t[i]=s[i]);return t};var ne=(s,e,t)=>new Promise((i,n)=>{var c=l=>{try{r(t.next(l))}catch(a){n(a)}},u=l=>{try{r(t.throw(l))}catch(a){n(a)}},r=l=>l.done?i(l.value):Promise.resolve(l.value).then(c,u);r((t=t.apply(s,e)).next())});const o=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),se=require("three/examples/jsm/renderers/CSS3DRenderer"),z=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),E=require("d3-array"),X=require("earcut"),ge=require("@turf/boolean-clockwise"),Me=require("delaunator"),Se=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),re=require("d3-scale"),we=0,je=1,Ae=2,Ce=!1;class de{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof Y?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Y)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const n=i.value;(n instanceof o.Texture||Array.isArray(n))&&this.track(n)}}}else this.disposeVideo&&e instanceof o.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const De=(s,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=s.material,n=new o.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return n.onBeforeCompile=c=>{c.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
|
-
${
|
|
4
|
-
`},new
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
#include <fog_pars_vertex>
|
|
8
|
-
|
|
9
|
-
attribute vec3 previous;
|
|
10
|
-
attribute vec3 next;
|
|
11
|
-
attribute float side;
|
|
12
|
-
attribute float width;
|
|
13
|
-
attribute float counters;
|
|
14
|
-
|
|
15
|
-
uniform vec2 resolution;
|
|
16
|
-
uniform float lineWidth;
|
|
17
|
-
uniform vec3 color;
|
|
18
|
-
uniform float opacity;
|
|
19
|
-
uniform float sizeAttenuation;
|
|
20
|
-
uniform vec2 offset;
|
|
21
|
-
|
|
22
|
-
uniform float time;
|
|
23
|
-
uniform vec3 lightColor;
|
|
24
|
-
uniform vec2 uCenter;
|
|
25
|
-
uniform float size;
|
|
26
|
-
uniform float speed;
|
|
27
|
-
uniform float lightWidth;
|
|
28
|
-
uniform float lineLightAnimation;
|
|
29
|
-
|
|
30
|
-
varying vec2 vUV;
|
|
31
|
-
varying vec4 vColor;
|
|
32
|
-
varying float vCounters;
|
|
33
|
-
varying vec2 vHighPrecisionZW;
|
|
34
|
-
|
|
35
|
-
vec2 fix(vec4 i, float aspect) {
|
|
36
|
-
vec2 res = i.xy / i.w;
|
|
37
|
-
res.x *= aspect;
|
|
38
|
-
vCounters = counters;
|
|
39
|
-
return res;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void main() {
|
|
43
|
-
float aspect = resolution.x / resolution.y;
|
|
44
|
-
if (lineLightAnimation == 1.0) {
|
|
45
|
-
vec2 vWorld=position.xy;
|
|
46
|
-
float r_time=mod(time/(speed*size),2.);
|
|
47
|
-
float l=distance(vWorld, uCenter)/size;
|
|
48
|
-
float r_opacity=smoothstep(r_time-lightWidth*2.,r_time-lightWidth,l)-smoothstep(r_time-lightWidth,r_time,l);
|
|
49
|
-
vColor=vec4(mix(color,lightColor,r_opacity),opacity);
|
|
50
|
-
} else {
|
|
51
|
-
vColor=vec4(color,opacity);
|
|
52
|
-
}
|
|
3
|
+
${c.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
+
`},new o.Points(t,n)},Pe=(s,e)=>{const t=new o.Object3D;e.forEach((i,n)=>{const c=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(c),t.scale.copy(u),t.updateMatrix();const r=t.matrix.clone();if(s instanceof o.InstancedMesh||s.isInstantiate)s.setMatrixAt(n,r);else if(s instanceof o.Points||s.type==="Points"){const a=s.geometry,p=a.attributes.position.array,d=a.attributes.scaleAtt.array,m=new o.Vector3,f=new o.Vector3,v=new o.Quaternion,h=n*3,y=n*1;r.decompose(m,v,f),p[h]=m.x,p[h+1]=m.y,p[h+2]=m.z,d[y]=Math.max(f.x,f.y,f.z),a.attributes.position.needsUpdate=!0,a.attributes.scaleAtt.needsUpdate=!0}})};class Be{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class Ie extends Be{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const n=i.userData;i.userData={};const c=i.clone();return i.userData=n,c});{const i=t.userData;t.userData={};const n=t.clone();return t.userData=i,n}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const n=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=n,n}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const n=this.object3d;Array.isArray(n.material)&&t!==void 0?n.material[t]=i:n.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends Ie{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get lookAt(){return this.object3d.lookAt}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new ye.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new se.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new se.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return ne(this,null,function*(){var l;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,{objectType:i,objectOptions:n}=this,[,c]=i.split("#");let u=e==null?void 0:e.create;u===void 0&&(u=a=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const d=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)a.object3d=De(this.object3d,d);else{const m=this.object3d,f=this.cloneMaterial();a.object3d=new o.InstancedMesh(m.geometry,f,d)}Pe(a.object3d,e==null?void 0:e.instancedAttr)}else a.object3d=this.object3d.clone(!1),a.object3d.material&&(a.object3d.material=this.cloneMaterial());a.object3d.userData.prefab&&delete a.object3d.userData.prefab}});const r=yield this.lead.draw(c,q(_({},n||{}),{create:u,prefab:!1,key:(e==null?void 0:e.key)||(n==null?void 0:n.key),target:(e==null?void 0:e.target)||(n==null?void 0:n.target)}));return this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(a=>a.instantiate({target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new de;t.disposeMaterial=!1,t.track(this),t.dispose()}}}const F=new o.Vector4,oe=new o.Vector3,ae=new o.Vector3,g=new o.Vector4,M=new o.Vector4,I=new o.Vector4,$=new o.Vector3,K=new o.Matrix4,S=new o.Line3,ce=new o.Vector3,N=new o.Box3,U=new o.Sphere,V=new o.Vector4;let T,O;function le(s,e,t){return V.set(0,0,-e,1).applyMatrix4(s.projectionMatrix),V.multiplyScalar(1/V.w),V.x=O/t.width,V.y=O/t.height,V.applyMatrix4(s.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ve(s,e){const t=s.matrixWorld,i=s.geometry,n=i.attributes.instanceStart,c=i.attributes.instanceEnd,u=Math.min(i.instanceCount,n.count);for(let r=0,l=u;r<l;r++){S.start.fromBufferAttribute(n,r),S.end.fromBufferAttribute(c,r),S.applyMatrix4(t);const a=new o.Vector3,p=new o.Vector3;T.distanceSqToSegment(S.start,S.end,p,a),p.distanceTo(a)<O*.5&&e.push({point:p,pointOnLine:a,distance:T.origin.distanceTo(p),object:s,face:null,faceIndex:r,uv:null,uv1:null})}}function Te(s,e,t){const i=e.projectionMatrix,c=s.material.resolution,u=s.matrixWorld,r=s.geometry,l=r.attributes.instanceStart,a=r.attributes.instanceEnd,p=Math.min(r.instanceCount,l.count),d=-e.near;T.at(1,I),I.w=1,I.applyMatrix4(e.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=c.x/2,I.y*=c.y/2,I.z=0,$.copy(I),K.multiplyMatrices(e.matrixWorldInverse,u);for(let m=0,f=p;m<f;m++){if(g.fromBufferAttribute(l,m),M.fromBufferAttribute(a,m),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>d&&M.z>d)continue;if(g.z>d){const A=g.z-M.z,C=(g.z-d)/A;g.lerp(M,C)}else if(M.z>d){const A=M.z-g.z,C=(M.z-d)/A;M.lerp(g,C)}g.applyMatrix4(i),M.applyMatrix4(i),g.multiplyScalar(1/g.w),M.multiplyScalar(1/M.w),g.x*=c.x/2,g.y*=c.y/2,M.x*=c.x/2,M.y*=c.y/2,S.start.copy(g),S.start.z=0,S.end.copy(M),S.end.z=0;const h=S.closestPointToPointParameter($,!0);S.at(h,ce);const y=o.MathUtils.lerp(g.z,M.z,h),w=y>=-1&&y<=1,j=$.distanceTo(ce)<O*.5;if(w&&j){S.start.fromBufferAttribute(l,m),S.end.fromBufferAttribute(a,m),S.start.applyMatrix4(u),S.end.applyMatrix4(u);const A=new o.Vector3,C=new o.Vector3;T.distanceSqToSegment(S.start,S.end,C,A),t.push({point:C,pointOnLine:A,distance:T.origin.distanceTo(C),object:s,face:null,faceIndex:m,uv:null,uv1:null})}}}class Le extends o.Mesh{constructor(e=new be.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,n=new Float32Array(2*t.count);for(let u=0,r=0,l=t.count;u<l;u++,r+=2)oe.fromBufferAttribute(t,u),ae.fromBufferAttribute(i,u),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+oe.distanceTo(ae);const c=new o.InstancedInterleavedBuffer(n,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(c,1,0)),e.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(c,1,1)),this}raycast(e,t){const i=this.material.worldUnits,n=e.camera;n===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const c=e.params.Line2!==void 0&&e.params.Line2.threshold||0;T=e.ray;const u=this.matrixWorld,r=this.geometry,l=this.material;O=l.linewidth+c,r.boundingSphere===null&&r.computeBoundingSphere(),U.copy(r.boundingSphere).applyMatrix4(u);let a;if(i)a=O*.5;else{const d=Math.max(n.near,U.distanceToPoint(T.origin));a=le(n,d,l.resolution)}if(U.radius+=a,T.intersectsSphere(U)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),N.copy(r.boundingBox).applyMatrix4(u);let p;if(i)p=O*.5;else{const d=Math.max(n.near,N.distanceToPoint(T.origin));p=le(n,d,l.resolution)}N.expandByScalar(p),T.intersectsBox(N)!==!1&&(i?Ve(this,t):Te(this,n,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const Oe=`
|
|
5
|
+
#include <fog_pars_fragment>
|
|
6
|
+
#include <logdepthbuf_pars_fragment>
|
|
53
7
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
vec4 normal = vec4(-dir.y, dir.x, 0., 1.);
|
|
82
|
-
normal.xy *= .5 * w;
|
|
83
|
-
//normal *= projectionMatrix;
|
|
84
|
-
if (sizeAttenuation == 0.) {
|
|
85
|
-
normal.xy *= finalPosition.w;
|
|
86
|
-
normal.xy /= (vec4(resolution, 0., 1.) * projectionMatrix).xy;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
finalPosition.xy += normal.xy * side;
|
|
90
|
-
gl_Position = finalPosition;
|
|
91
|
-
#include <logdepthbuf_vertex>
|
|
92
|
-
#include <fog_vertex>
|
|
93
|
-
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
94
|
-
vHighPrecisionZW = finalPosition.zw;
|
|
95
|
-
#include <fog_vertex>
|
|
96
|
-
}
|
|
97
|
-
`,Bt=`
|
|
98
|
-
#include <packing>
|
|
99
|
-
#include <fog_pars_fragment>
|
|
100
|
-
#include <logdepthbuf_pars_fragment>
|
|
101
|
-
|
|
102
|
-
uniform sampler2D map;
|
|
103
|
-
uniform sampler2D alphaMap;
|
|
104
|
-
uniform float useMap;
|
|
105
|
-
uniform float useAlphaMap;
|
|
106
|
-
uniform float useDash;
|
|
107
|
-
uniform float dashArray;
|
|
108
|
-
uniform float dashOffset;
|
|
109
|
-
uniform float dashRatio;
|
|
110
|
-
uniform float visibility;
|
|
111
|
-
uniform float alphaTest;
|
|
112
|
-
uniform vec2 repeat;
|
|
113
|
-
uniform float useDepth;
|
|
114
|
-
uniform float offsetLoop;
|
|
115
|
-
|
|
116
|
-
varying vec2 vUV;
|
|
117
|
-
varying vec4 vColor;
|
|
118
|
-
varying float vCounters;
|
|
119
|
-
varying vec2 vHighPrecisionZW;
|
|
120
|
-
|
|
121
|
-
void main() {
|
|
122
|
-
#include <logdepthbuf_fragment>
|
|
123
|
-
vec4 c = vColor;
|
|
124
|
-
if (useMap == 1.) c *= texture2D(map, vUV * repeat);
|
|
125
|
-
if (useAlphaMap == 1.) c.a *= texture2D(alphaMap, vUV * repeat).a;
|
|
126
|
-
if(offsetLoop!=1.0){
|
|
8
|
+
uniform float useDash;
|
|
9
|
+
uniform float dashArray;
|
|
10
|
+
uniform float dashOffset;
|
|
11
|
+
uniform float dashRatio;
|
|
12
|
+
uniform sampler2D alphaMap;
|
|
13
|
+
uniform float useAlphaMap;
|
|
14
|
+
|
|
15
|
+
varying vec2 vUV;
|
|
16
|
+
varying vec4 vColor;
|
|
17
|
+
varying float vCounters;
|
|
18
|
+
|
|
19
|
+
uniform sampler2D map;
|
|
20
|
+
uniform float useMap;
|
|
21
|
+
uniform vec2 repeat;
|
|
22
|
+
uniform float offsetLoop;
|
|
23
|
+
uniform float alphaTest;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
void main() {
|
|
28
|
+
#include <logdepthbuf_fragment>
|
|
29
|
+
|
|
30
|
+
vec4 c = vColor;
|
|
31
|
+
|
|
32
|
+
if( useMap == 1. ) c *= texture2D( map, vUV * repeat );
|
|
33
|
+
if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).r;
|
|
34
|
+
if(offsetLoop!=1.0){
|
|
127
35
|
if(vUV.x>1.0 || vUV.x<0.0){
|
|
128
36
|
c.a = 0.0;
|
|
129
37
|
}
|
|
130
38
|
}
|
|
39
|
+
if (c.a < alphaTest) discard;
|
|
40
|
+
if( useDash == 1. ){
|
|
41
|
+
c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
|
|
42
|
+
}
|
|
43
|
+
gl_FragColor = c;
|
|
44
|
+
#include <fog_fragment>
|
|
45
|
+
#include <${parseInt(o.REVISION)<154?"encodings_fragment":"colorspace_fragment"}>
|
|
46
|
+
}
|
|
47
|
+
`,Ee=`
|
|
48
|
+
#include <common>
|
|
49
|
+
${o.ShaderChunk.logdepthbuf_pars_vertex}
|
|
50
|
+
${o.ShaderChunk.fog_pars_vertex}
|
|
51
|
+
|
|
52
|
+
attribute vec3 previous;
|
|
53
|
+
attribute vec3 next;
|
|
54
|
+
attribute float side;
|
|
55
|
+
attribute float width;
|
|
56
|
+
attribute float counters;
|
|
57
|
+
|
|
58
|
+
uniform vec2 resolution;
|
|
59
|
+
uniform float lineWidth;
|
|
60
|
+
uniform vec3 color;
|
|
61
|
+
uniform float opacity;
|
|
62
|
+
uniform float sizeAttenuation;
|
|
63
|
+
uniform float scaleDown;
|
|
64
|
+
uniform vec2 offset;
|
|
131
65
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
66
|
+
varying vec2 vUV;
|
|
67
|
+
varying vec4 vColor;
|
|
68
|
+
varying float vCounters;
|
|
69
|
+
|
|
70
|
+
vec2 intoScreen(vec4 i) {
|
|
71
|
+
return resolution * (0.5 * i.xy / i.w + 0.5);
|
|
135
72
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
73
|
+
|
|
74
|
+
void main() {
|
|
75
|
+
float aspect = resolution.y / resolution.x;
|
|
76
|
+
|
|
77
|
+
mat4 m = projectionMatrix * modelViewMatrix;
|
|
78
|
+
|
|
79
|
+
vec4 currentClip = m * vec4( position, 1.0 );
|
|
80
|
+
vec4 prevClip = m * vec4( previous, 1.0 );
|
|
81
|
+
vec4 nextClip = m * vec4( next, 1.0 );
|
|
82
|
+
|
|
83
|
+
vec4 currentNormed = currentClip / currentClip.w;
|
|
84
|
+
vec4 prevNormed = prevClip / prevClip.w;
|
|
85
|
+
vec4 nextNormed = nextClip / nextClip.w;
|
|
86
|
+
|
|
87
|
+
vec2 currentScreen = intoScreen(currentNormed);
|
|
88
|
+
vec2 prevScreen = intoScreen(prevNormed);
|
|
89
|
+
vec2 nextScreen = intoScreen(nextNormed);
|
|
90
|
+
|
|
91
|
+
float actualWidth = lineWidth * width;
|
|
92
|
+
|
|
93
|
+
vec2 dir;
|
|
94
|
+
if(nextScreen == currentScreen) {
|
|
95
|
+
dir = normalize( currentScreen - prevScreen );
|
|
96
|
+
} else if(prevScreen == currentScreen) {
|
|
97
|
+
dir = normalize( nextScreen - currentScreen );
|
|
98
|
+
} else {
|
|
99
|
+
vec2 inDir = currentScreen - prevScreen;
|
|
100
|
+
vec2 outDir = nextScreen - currentScreen;
|
|
101
|
+
vec2 fullDir = nextScreen - prevScreen;
|
|
102
|
+
|
|
103
|
+
if(length(fullDir) > 0.0) {
|
|
104
|
+
dir = normalize(fullDir);
|
|
105
|
+
} else if(length(inDir) > 0.0){
|
|
106
|
+
dir = normalize(inDir);
|
|
107
|
+
} else {
|
|
108
|
+
dir = normalize(outDir);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
vec2 normal = vec2(-dir.y, dir.x);
|
|
113
|
+
|
|
114
|
+
if(sizeAttenuation != 0.0) {
|
|
115
|
+
normal /= currentClip.w;
|
|
116
|
+
normal *= min(resolution.x, resolution.y);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (scaleDown > 0.0) {
|
|
120
|
+
float dist = length(nextNormed - prevNormed);
|
|
121
|
+
normal *= smoothstep(0.0, scaleDown, dist);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
vec2 offsetInScreen = actualWidth * normal * side * 0.5;
|
|
125
|
+
|
|
126
|
+
vec2 withOffsetScreen = currentScreen + offsetInScreen;
|
|
127
|
+
vec3 withOffsetNormed = vec3((2.0 * withOffsetScreen/resolution - 1.0), currentNormed.z);
|
|
128
|
+
|
|
129
|
+
vCounters = counters;
|
|
130
|
+
vColor = vec4( color, opacity );
|
|
131
|
+
vUV = uv;
|
|
132
|
+
vUV=uv+offset;
|
|
133
|
+
|
|
134
|
+
gl_Position = currentClip.w * vec4(withOffsetNormed, 1.0);
|
|
135
|
+
|
|
136
|
+
${o.ShaderChunk.logdepthbuf_vertex}
|
|
137
|
+
${o.ShaderChunk.fog_vertex}
|
|
142
138
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
#include <fog_fragment>
|
|
146
|
-
#include <tonemapping_fragment>
|
|
147
|
-
#include <${+n.REVISION<154?ot[0]:ot[1]}>
|
|
148
|
-
}
|
|
149
|
-
`;class Dt extends n.ShaderMaterial{constructor(t){super({uniforms:F(O({},n.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new n.Color(16777215)},opacity:{value:1},resolution:{value:new n.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new n.Vector2(1,1)},offset:{value:new n.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new n.Vector2(0,0)},lightColor:{value:new n.Color(16777215)}}),vertexShader:Vt,fragmentShader:Bt}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}}function zt(o,t){return o.map(e=>{const i=[];let s;return e.forEach(a=>{if(s){const l=k.geoDistance(a,s)*180/Math.PI;if(l>t){const r=k.geoInterpolate(s,a),c=1/Math.ceil(l/t);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function It(o,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(J(360/o,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=f=>f/l*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,u=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,p=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],h=t===void 0&&e===void 0?()=>!0:t===void 0?f=>f<=e:e===void 0?f=>f>=t:e>=t?f=>f>=t&&f<=e:f=>f>=t||f<=e,v=[];for(let f=p[0];f<=p[1];f++){const d=r(f);h(d)&&v.push([d,c(f)])}return v}function X(o,t,e=!1){return e?k.geoContains(t,o):Mt(o,t)}function Lt(o,t){const e={type:"Polygon",coordinates:o},[[i,s],[a,l]]=k.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(l-s))<t)return[];const r=i>a||l>=89||s<=-89;return It(t,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>X(c,e,r))}function Tt(o,{resolution:t=1/0,bbox:e,projection:i}={}){const s=zt(o,t),a=W.merge(s),l=Lt(o,t),r=[...a,...l],c={type:"Polygon",coordinates:o},[[u,p],[h,v]]=k.geoBounds(c),f=u>h||v>=89||p<=-89;let d=[];if(f){const g=wt.geoVoronoi(r).triangles(),w=new Map(r.map(([S,j],L)=>[`${S}-${j}`,L]));g.features.forEach(S=>{const j=S.geometry.coordinates[0].slice(0,3).reverse(),L=[];if(j.forEach(([C,q])=>{const G=`${C}-${q}`;w.has(G)&&L.push(w.get(G))}),L.length===3){if(L.some(C=>C<a.length)){const C=S.properties.circumcenter;if(!X(C,c,f))return}d.push(...L)}})}else if(l.length){const g=xt.from(r);for(let w=0,S=g.triangles.length;w<S;w+=3){const j=[2,1,0].map(C=>g.triangles[w+C]),L=j.map(C=>r[C]);if(j.some(C=>C<a.length)){const C=[0,1].map(q=>W.mean(L,G=>G[q]));if(!X(C,c,f))continue}d.push(...j)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);d=K(g,w,2)}let m=e?[e[0],e[2]]:W.extent(r,g=>g[0]),b=e?[e[1],e[3]]:W.extent(r,g=>g[1]);if(i){const[g,w]=i([m[0],b[0]]),[S,j]=i([m[1],b[1]]);m=[g,S],b=[-w,-j]}const P=it.scaleLinear(m,[0,1]),V=it.scaleLinear(b,[0,1]),B=r.map(([g,w])=>{if(i){const[S,j]=i([g,w]);return[P(S),V(-j)]}else return[P(g),V(w)]});return{contour:s,triangles:{points:r,indices:d,uvs:B}}}const lt=new n.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(o,t,e,i){const s=o.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,t]}return e?Q.polar2Cartesian(l,r,t):[l,r,t]}));return K.flatten(s)}function Wt(o,t,e,i,s){const{vertices:a,holes:l}=U(o,t,i,s),{vertices:r}=U(o,e,i,s),c=W.merge([r,a]),u=Math.round(r.length/3),p=new Set(l);let h=0;const v=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(p.has(m)){const b=m;m=h,h=b}v.push(d,d+u,m+u),v.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:v,vertices:c,uvs:f,topVerts:r}}function ct(o,t,e,i,s,a){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:U([o.points],t,s,a).vertices,uvs:e}}const ht=({polygonGeoJson:o,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{o.forEach(P=>{yt(P)||P.reverse()});const{contour:p,triangles:h}=Tt(o,{resolution:i,bbox:u,projection:c});let v={},f;a&&(v=Wt(p,t!=null?t:e,e!=null?e:t,s,c),f=v.topVerts);let d=[];(l||r)&&(d=W.merge(h.uvs));let m={};l&&(m=ct(h,t,d,!1,s,c));let b={};return r&&(b=ct(h,e,d,!0,s,c)),{contour:p,triangles:h,sideTorso:v,bottomCap:m,topCap:b,topVerts:f}};class _t extends n.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:i,hasTop:s,topFirst:a,hasBottom:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:p}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:m}=ht(O({},this.parameters));let b=[],P=[],V=[],B=0;const A=g=>{const w=Math.round(b.length/3),S=V.length;b=b.concat(g.vertices),P=P.concat(g.uvs),V=V.concat(w?g.indices.map(j=>j+w):g.indices),this.addGroup(S,V.length-S,B++)};s&&a&&A(m),r&&(A(v),this.userData.topVerts=u?U(h,i+u,c,p).vertices:f),l&&A(d),s&&!a&&A(m),this.setIndex(V),this[lt]("position",new n.Float32BufferAttribute(b,3)),this[lt]("uv",new n.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=ut;exports.Group=At;exports.LineSegments2=Ct;exports.MeshLineMaterial=Dt;exports.PolygonGeometry=_t;exports.ResourceTracker=_;exports.getMetas=ht;
|
|
139
|
+
`;class _e extends o.ShaderMaterial{constructor(e={}){var A;const j=e,{lineWidth:t=1,color:i="#ffffff",map:n=null,useMap:c=0,dashOffset:u=0,dashArray:r=0,dashRatio:l=0,sizeAttenuation:a=!0,offsetLoop:p=!0,offset:d=new o.Vector2(0,0),scaleDown:m=0,alphaMap:f=void 0,alphaTest:v=0,repeat:h=new o.Vector2(1,1),resolution:y=new o.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","map","useMap","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(q(_({},w),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:(A=e.opacity)!=null?A:1},map:{value:n},useMap:{value:n?1:c},resolution:{value:y},sizeAttenuation:{value:a?1:0},offset:{value:d},offsetLoop:{value:p?1:0},dashArray:{value:r},dashOffset:{value:u},dashRatio:{value:l},useDash:{value:r>0?1:0},scaleDown:{value:m/10},alphaTest:{value:v},alphaMap:{value:f},useAlphaMap:{value:f?1:0},repeat:{value:h}},vertexShader:Ee,fragmentShader:Oe})),this.type="MeshLineMaterial"}updateUniforms(e){e.opacity!==void 0&&(this.uniforms.opacity.value=e.opacity),e.color!==void 0&&(this.uniforms.color.value=new o.Color(e.color)),e.map!==void 0&&(this.uniforms.map.value=e.map,this.uniforms.useMap.value=e.map?1:0),e.useMap!==void 0&&(this.uniforms.useMap.value=e.useMap),e.dashOffset!==void 0&&(this.uniforms.dashOffset.value=e.dashOffset),e.dashArray!==void 0&&(this.uniforms.dashArray.value=e.dashArray,this.uniforms.useDash.value=e.dashArray>0?1:0),e.dashRatio!==void 0&&(this.uniforms.dashRatio.value=e.dashRatio),e.sizeAttenuation!==void 0&&(this.uniforms.sizeAttenuation.value=e.sizeAttenuation?1:0),e.offset!==void 0&&(this.uniforms.offset.value=e.offset),e.offsetLoop!==void 0&&(this.uniforms.offsetLoop.value=e.offsetLoop?1:0),e.lineWidth!==void 0&&(this.uniforms.lineWidth.value=e.lineWidth),e.scaleDown!==void 0&&(this.uniforms.scaleDown.value=e.scaleDown/10),e.alphaMap!==void 0&&(this.uniforms.alphaMap.value=e.alphaMap,this.uniforms.useAlphaMap.value=e.alphaMap?1:0),e.resolution!==void 0&&(this.uniforms.resolution.value=e.resolution),e.repeat!==void 0&&(this.uniforms.repeat.value=e.repeat),e.alphaTest!==void 0&&(this.uniforms.alphaTest.value=e.alphaTest)}}function ze(s,e){return s.map(t=>{const i=[];let n;return t.forEach(c=>{if(n){const u=z.geoDistance(c,n)*180/Math.PI;if(u>e){const r=z.geoInterpolate(n,c),l=1/Math.ceil(u/e);let a=l;for(;a<1;)i.push(r(a)),a+=l}}i.push(n=c)}),i})}function ke(s,{minLng:e,maxLng:t,minLat:i,maxLat:n}={}){const c=Math.round(te(360/s,2)/Math.PI),u=(1+Math.sqrt(5))/2,r=f=>f/u*360%360-180,l=f=>Math.acos(2*f/c-1)/Math.PI*180-90,a=f=>c*(Math.cos((f+90)*Math.PI/180)+1)/2,p=[n!==void 0?Math.ceil(a(n)):0,i!==void 0?Math.floor(a(i)):c-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,m=[];for(let f=p[0];f<=p[1];f++){const v=r(f);d(v)&&m.push([v,l(f)])}return m}function Z(s,e,t=!1){return t?z.geoContains(e,s):Se(s,e)}function We(s,e){const t={type:"Polygon",coordinates:s},[[i,n],[c,u]]=z.geoBounds(t);if(Math.min(Math.abs(c-i),Math.abs(u-n))<e)return[];const r=i>c||u>=89||n<=-89;return ke(e,{minLng:i,maxLng:c,minLat:n,maxLat:u}).filter(l=>Z(l,t,r))}function Ne(s,{resolution:e=1/0,bbox:t,projection:i}={}){const n=ze(s,e),c=E.merge(n),u=We(s,e),r=[...c,...u],l={type:"Polygon",coordinates:s},[[a,p],[d,m]]=z.geoBounds(l),f=a>d||m>=89||p<=-89;let v=[];if(f){const b=xe.geoVoronoi(r).triangles(),x=new Map(r.map(([D,P],L)=>[`${D}-${P}`,L]));b.features.forEach(D=>{const P=D.geometry.coordinates[0].slice(0,3).reverse(),L=[];if(P.forEach(([B,G])=>{const k=`${B}-${G}`;x.has(k)&&L.push(x.get(k))}),L.length===3){if(L.some(B=>B<c.length)){const B=D.properties.circumcenter;if(!Z(B,l,f))return}v.push(...L)}})}else if(u.length){const b=Me.from(r);for(let x=0,D=b.triangles.length;x<D;x+=3){const P=[2,1,0].map(B=>b.triangles[x+B]),L=P.map(B=>r[B]);if(P.some(B=>B<c.length)){const B=[0,1].map(G=>E.mean(L,k=>k[G]));if(!Z(B,l,f))continue}v.push(...P)}}else{const{vertices:b,holes:x=[]}=X.flatten(n);v=X(b,x,2)}let h=t?[t[0],t[2]]:E.extent(r,b=>b[0]),y=t?[t[1],t[3]]:E.extent(r,b=>b[1]);if(i){const[b,x]=i([h[0],y[0]]),[D,P]=i([h[1],y[1]]);h=[b,D],y=[-x,-P]}const w=re.scaleLinear(h,[0,1]),j=re.scaleLinear(y,[0,1]),A=r.map(([b,x])=>{if(i){const[D,P]=i([b,x]);return[w(D),j(-P)]}else return[w(b),j(x)]});return{contour:n,triangles:{points:r,indices:v,uvs:A}}}const ue=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function R(s,e,t,i){const n=s.map(c=>c.map(([u,r])=>{if(i){const[l,a]=i([u,r]);return[l,-a,e]}return t?Q.polar2Cartesian(u,r,e):[u,r,e]}));return X.flatten(n)}function Ue(s,e,t,i,n){const{vertices:c,holes:u}=R(s,e,i,n),{vertices:r}=R(s,t,i,n),l=E.merge([r,c]),a=Math.round(r.length/3),p=new Set(u);let d=0;const m=[];for(let v=0;v<a;v++){let h=v+1;if(h===a)h=d;else if(p.has(h)){const y=h;h=d,d=y}m.push(v,v+a,h+a),m.push(h+a,h,v)}const f=[];for(let v=1;v>=0;v--)for(let h=0;h<a;h+=1)f.push(h/(a-1),v);return{indices:m,vertices:l,uvs:f,topVerts:r}}function fe(s,e,t,i,n,c){return{indices:i?s.indices:s.indices.slice().reverse(),vertices:R([s.points],e,n,c).vertices,uvs:t}}const he=({polygonGeoJson:s,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:n=!0,hasSide:c=!0,hasBottom:u=!1,hasTop:r=!1,projection:l,bbox:a})=>{s.forEach(w=>{ge(w)||w.reverse()});const{contour:p,triangles:d}=Ne(s,{resolution:i,bbox:a,projection:l});let m={},f;c&&(m=Ue(p,e!=null?e:t,t!=null?t:e,n,l),f=m.topVerts);let v=[];(u||r)&&(v=E.merge(d.uvs));let h={};u&&(h=fe(d,e,v,!1,n,l));let y={};return r&&(y=fe(d,t,v,!0,n,l)),{contour:p,triangles:d,sideTorso:m,bottomCap:h,topCap:y,topVerts:f}};class Re extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:n,topFirst:c,hasBottom:u,hasSide:r,cartesian:l,userDataRsoOffset:a,projection:p}=this.parameters,{contour:d,sideTorso:m,topVerts:f,bottomCap:v,topCap:h}=he(_({},this.parameters));let y=[],w=[],j=[],A=0;const C=b=>{const x=Math.round(y.length/3),D=j.length;y=y.concat(b.vertices),w=w.concat(b.uvs),j=j.concat(x?b.indices.map(P=>P+x):b.indices),this.addGroup(D,j.length-D,A++)};n&&c&&C(h),r&&(C(m),this.userData.topVerts=a?R(d,i+a,l,p).vertices:f),u&&C(v),n&&!c&&C(h),this.setIndex(j),this[ue]("position",new o.Float32BufferAttribute(y,3)),this[ue]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=Le;exports.MeshLineMaterial=_e;exports.PolygonGeometry=Re;exports.ResourceTracker=de;exports.getMetas=he;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {BufferGeometry} from 'three';
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
2
|
|
|
3
3
|
type PolygonCoords = number[][][];
|
|
4
4
|
|
|
@@ -20,15 +20,15 @@ export type Parameters = {
|
|
|
20
20
|
export function getMetas(
|
|
21
21
|
parameters?: Partial<Omit<Parameters, 'polygonGeoJson'>> & {
|
|
22
22
|
polygonGeoJson: PolygonCoords;
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
24
|
): {
|
|
25
|
-
topVerts: number[];
|
|
25
|
+
topVerts: number[][];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export default class PolygonGeometry extends BufferGeometry {
|
|
29
29
|
constructor(
|
|
30
30
|
polygonGeoJson: PolygonCoords,
|
|
31
|
-
parameters?: Partial<Omit<Parameters, 'polygonGeoJson'
|
|
31
|
+
parameters?: Partial<Omit<Parameters, 'polygonGeoJson'>>,
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
parameters: Parameters;
|
|
@@ -85,7 +85,7 @@ import { SplineCurve } from 'three';
|
|
|
85
85
|
*
|
|
86
86
|
* @augments BufferGeometry
|
|
87
87
|
*/
|
|
88
|
-
export class ExtrudeGeometry extends BufferGeometry<import("three").NormalBufferAttributes> {
|
|
88
|
+
export class ExtrudeGeometry extends BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap> {
|
|
89
89
|
/**
|
|
90
90
|
* Factory method for creating an instance of this class from the given
|
|
91
91
|
* JSON object.
|
|
@@ -21,7 +21,11 @@ declare const _default: (options: Options) => {
|
|
|
21
21
|
index: import("three").BufferAttribute | null;
|
|
22
22
|
indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
23
23
|
attributes: import("three").NormalBufferAttributes;
|
|
24
|
-
morphAttributes:
|
|
24
|
+
morphAttributes: {
|
|
25
|
+
position?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
26
|
+
normal?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
27
|
+
color?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
28
|
+
};
|
|
25
29
|
morphTargetsRelative: boolean;
|
|
26
30
|
groups: import("three").GeometryGroup[];
|
|
27
31
|
boundingBox: Box3 | null;
|
|
@@ -61,17 +65,9 @@ declare const _default: (options: Options) => {
|
|
|
61
65
|
toNonIndexed(): import("three").BufferGeometry;
|
|
62
66
|
clone(): any;
|
|
63
67
|
dispose(): void;
|
|
64
|
-
addEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
dispose: {};
|
|
69
|
-
}[T], T, any>): boolean;
|
|
70
|
-
removeEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<{
|
|
71
|
-
dispose: {};
|
|
72
|
-
}[T], T, any>): void;
|
|
73
|
-
dispatchEvent<T extends "dispose">(event: import("three").BaseEvent<T> & {
|
|
74
|
-
dispose: {};
|
|
75
|
-
}[T]): void;
|
|
68
|
+
addEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<import("three").BufferGeometryEventMap[T], T, any>): void;
|
|
69
|
+
hasEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<import("three").BufferGeometryEventMap[T], T, any>): boolean;
|
|
70
|
+
removeEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<import("three").BufferGeometryEventMap[T], T, any>): void;
|
|
71
|
+
dispatchEvent<T extends "dispose">(event: import("three").BaseEvent<T> & import("three").BufferGeometryEventMap[T]): void;
|
|
76
72
|
};
|
|
77
73
|
export default _default;
|
package/dist/objects/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var qe=Object.defineProperty,We=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var Be=(n,e,t)=>e in n?qe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,E=(n,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&Be(n,t,e[t]);if(ae)for(var t of ae(e))Pe.call(e,t)&&Be(n,t,e[t]);return n},ce=(n,e)=>We(n,$e(e));var fe=(n,e)=>{var t={};for(var s in n)Ee.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&ae)for(var s of ae(n))e.indexOf(s)<0&&Pe.call(n,s)&&(t[s]=n[s]);return t};var se=(n,e,t)=>new Promise((s,i)=>{var r=h=>{try{u(t.next(h))}catch(w){i(w)}},a=h=>{try{u(t.throw(h))}catch(w){i(w)}},u=h=>h.done?s(h.value):Promise.resolve(h.value).then(r,a);u((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../index2.js"),c=require("three"),Je=require("@tweenjs/tween.js"),Qe=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),pe=require("three/examples/jsm/utils/BufferGeometryUtils"),Xe=require("three/examples/jsm/lines/LineSegments2"),Ie=require("three/examples/jsm/lines/LineSegmentsGeometry"),ze=require("three/examples/jsm/lines/LineMaterial"),Ge=require("../uvGenerator.js"),he=require("three-bvh-csg");function Ye(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const K=Ye(Je);class Ze extends P.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=E({type:"2d"},e)}create(){const{position:e,children:t}=this.options,s=document.createElement("div");this.element=s,t&&s.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(s):this.options.type==="3dSprite"?this.createCSS3DSprite(s):this.createCSS2DObject(s),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),s=window.innerWidth,i=window.innerHeight;let r=0,a=0;t.left<0?r=-t.left:t.right>s&&(r=s-t.right),t.top<0?a=-t.top:t.bottom>i&&(a=i-t.bottom),t.left+r<0&&(r=-t.left),t.top+a<0&&(a=-t.top),(r!==0||a!==0)&&(e.style.transform=`translate(${r}px, ${a}px)`)}ensureVisible(){const e=this.options.children;if(!e)return;e.style.transform&&(e.style.transform="");const t=new IntersectionObserver(s=>{s.forEach(i=>{i.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)}onPointerEvent(e,t){const s=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(s)}dispose(){this.onNodePointerIndex.forEach(e=>{this.lead.removePickNode(e)}),super.dispose()}}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 X extends c.BufferGeometry{constructor(e=new c.Shape([new c.Vector2(.5,.5),new c.Vector2(-.5,.5),new c.Vector2(-.5,-.5),new c.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const s=this,i=[],r=[];for(let u=0,h=e.length;u<h;u++){const w=e[u];a(w)}this.setAttribute("position",new c.Float32BufferAttribute(i,3)),this.setAttribute("uv",new c.Float32BufferAttribute(r,2)),this.computeVertexNormals();function a(u){var Ae,Se,_e;const h=[],w=t.curveSegments!==void 0?t.curveSegments:12,o=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let b=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,x=t.bevelSize!==void 0?t.bevelSize:m-.1,L=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,B=t.UVGenerator!==void 0?t.UVGenerator:et,A=(Ae=t.hasTop)!=null?Ae:!0,I=(Se=t.hasBottom)!=null?Se:!0,le=(_e=t.hasSide)!=null?_e:!0;let W,Y=!1,$,ee,te,D;_&&(W=_.getSpacedPoints(o),Y=!0,b=!1,$=_.computeFrenetFrames(o,!1),ee=new c.Vector3,te=new c.Vector3,D=new c.Vector3),b||(M=0,m=0,x=0,L=0);const ye=u.extractPoints(w);let O=ye.shape;const G=ye.holes;if(!c.ShapeUtils.isClockWise(O)){O=O.reverse();for(let l=0,f=G.length;l<f;l++){const p=G[l];c.ShapeUtils.isClockWise(p)&&(G[l]=p.reverse())}}function be(l){const p=10000000000000001e-36;let y=l[0];for(let g=1;g<=l.length;g++){const S=g%l.length,v=l[S],T=v.x-y.x,j=v.y-y.y,V=T*T+j*j,C=Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(y.x),Math.abs(y.y)),Q=p*C*C;if(V<=Q){l.splice(S,1),g--;continue}y=v}}be(O),G.forEach(be);const ue=G.length,z=O;for(let l=0;l<ue;l++){const f=G[l];O=O.concat(f)}function Z(l,f,p){return f||console.error("THREE.ExtrudeGeometry: vec does not exist"),l.clone().addScaledVector(f,p)}const H=O.length;function we(l,f,p){let y,g,S;const v=l.x-f.x,T=l.y-f.y,j=p.x-l.x,V=p.y-l.y,C=v*v+T*T,Q=v*V-T*j;if(Math.abs(Q)>Number.EPSILON){const U=Math.sqrt(C),Me=Math.sqrt(j*j+V*V),Le=f.x-T/U,Te=f.y+v/U,ke=p.x-V/Me,Fe=p.y+j/Me,je=((ke-Le)*V-(Fe-Te)*j)/(v*V-T*j);y=Le+v*je-l.x,g=Te+T*je-l.y;const Ve=y*y+g*g;if(Ve<=2)return new c.Vector2(y,g);S=Math.sqrt(Ve/2)}else{let U=!1;v>Number.EPSILON?j>Number.EPSILON&&(U=!0):v<-Number.EPSILON?j<-Number.EPSILON&&(U=!0):Math.sign(T)===Math.sign(V)&&(U=!0),U?(y=-T,g=v,S=Math.sqrt(C)):(y=v,g=T,S=Math.sqrt(C/2))}return new c.Vector2(y/S,g/S)}const ie=[];for(let l=0,f=z.length,p=f-1,y=l+1;l<f;l++,p++,y++)p===f&&(p=0),y===f&&(y=0),ie[l]=we(z[l],z[p],z[y]);const de=[];let q,re=ie.concat();for(let l=0,f=ue;l<f;l++){const p=G[l];q=[];for(let y=0,g=p.length,S=g-1,v=y+1;y<g;y++,S++,v++)S===g&&(S=0),v===g&&(v=0),q[y]=we(p[y],p[S],p[v]);de.push(q),re=re.concat(q)}let J;if(M===0)J=c.ShapeUtils.triangulateShape(z,G);else{const l=[],f=[];for(let p=0;p<M;p++){const y=p/M,g=m*Math.cos(y*Math.PI/2),S=x*Math.sin(y*Math.PI/2)+L;for(let v=0,T=z.length;v<T;v++){const j=Z(z[v],ie[v],S);N(j.x,j.y,-g),y===0&&l.push(j)}for(let v=0,T=ue;v<T;v++){const j=G[v];q=de[v];const V=[];for(let C=0,Q=j.length;C<Q;C++){const U=Z(j[C],q[C],S);N(U.x,U.y,-g),y===0&&V.push(U)}y===0&&f.push(V)}}J=c.ShapeUtils.triangulateShape(l,f)}const ne=J.length,xe=x+L;for(let l=0;l<H;l++){const f=b?Z(O[l],re[l],xe):O[l];Y?(te.copy($.normals[0]).multiplyScalar(f.x),ee.copy($.binormals[0]).multiplyScalar(f.y),D.copy(W[0]).add(te).add(ee),N(D.x,D.y,D.z)):N(f.x,f.y,0)}for(let l=1;l<=o;l++)for(let f=0;f<H;f++){const p=b?Z(O[f],re[f],xe):O[f];Y?(te.copy($.normals[l]).multiplyScalar(p.x),ee.copy($.binormals[l]).multiplyScalar(p.y),D.copy(W[l]).add(te).add(ee),N(D.x,D.y,D.z)):N(p.x,p.y,d/o*l)}for(let l=M-1;l>=0;l--){const f=l/M,p=m*Math.cos(f*Math.PI/2),y=x*Math.sin(f*Math.PI/2)+L;for(let g=0,S=z.length;g<S;g++){const v=Z(z[g],ie[g],y);N(v.x,v.y,d+p)}for(let g=0,S=G.length;g<S;g++){const v=G[g];q=de[g];for(let T=0,j=v.length;T<j;T++){const V=Z(v[T],q[T],y);Y?N(V.x,V.y+W[o-1].y,W[o-1].x+p):N(V.x,V.y,d+p)}}}De(),le&&He();function De(){const l=i.length/3;if(b){let f=0,p=H*f;if(I)for(let y=0;y<ne;y++){const g=J[y];oe(g[2]+p,g[1]+p,g[0]+p)}if(f=o+M*2,p=H*f,A)for(let y=0;y<ne;y++){const g=J[y];oe(g[0]+p,g[1]+p,g[2]+p)}}else{if(I)for(let f=0;f<ne;f++){const p=J[f];oe(p[2],p[1],p[0])}if(A)for(let f=0;f<ne;f++){const p=J[f];oe(p[0]+H*o,p[1]+H*o,p[2]+H*o)}}s.addGroup(l,i.length/3-l,0)}function He(){const l=i.length/3;let f=0;ve(z,f),f+=z.length;for(let p=0,y=G.length;p<y;p++){const g=G[p];ve(g,f),f+=g.length}s.addGroup(l,i.length/3-l,1)}function ve(l,f){let p=l.length;for(;--p>=0;){const y=p;let g=p-1;g<0&&(g=l.length-1);for(let S=0,v=o+M*2;S<v;S++){const T=H*S,j=H*(S+1),V=f+y+T,C=f+g+T,Q=f+g+j,U=f+y+j;Ne(V,C,Q,U)}}}function N(l,f,p){h.push(l),h.push(f),h.push(p)}function oe(l,f,p){k(l),k(f),k(p);const y=i.length/3,g=B.generateTopUV(s,i,y-3,y-2,y-1);F(g[0]),F(g[1]),F(g[2])}function Ne(l,f,p,y){k(l),k(f),k(y),k(f),k(p),k(y);const g=i.length/3,S=B.generateSideWallUV(s,i,g-6,g-3,g-2,g-1);F(S[0]),F(S[1]),F(S[3]),F(S[1]),F(S[2]),F(S[3])}function k(l){i.push(h[l*3+0]),i.push(h[l*3+1]),i.push(h[l*3+2])}function F(l){r.push(l.x),r.push(l.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,s=this.parameters.options;return tt(t,s,e)}static fromJSON(e,t){const s=[];for(let r=0,a=e.shapes.length;r<a;r++){const u=t[e.shapes[r]];s.push(u)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Ke[`${i.type}`]().fromJSON(i)),new X(s,e.options)}}const et={generateTopUV:function(n,e,t,s,i){const r=e[t*3],a=e[t*3+1],u=e[s*3],h=e[s*3+1],w=e[i*3],o=e[i*3+1];return[new c.Vector2(r,a),new c.Vector2(u,h),new c.Vector2(w,o)]},generateSideWallUV:function(n,e,t,s,i,r){const a=e[t*3],u=e[t*3+1],h=e[t*3+2],w=e[s*3],o=e[s*3+1],d=e[s*3+2],b=e[i*3],m=e[i*3+1],x=e[i*3+2],L=e[r*3],M=e[r*3+1],_=e[r*3+2];return Math.abs(u-o)<Math.abs(a-w)?[new c.Vector2(a,1-h),new c.Vector2(w,1-d),new c.Vector2(b,1-x),new c.Vector2(L,1-_)]:[new c.Vector2(u,1-h),new c.Vector2(o,1-d),new c.Vector2(m,1-x),new c.Vector2(M,1-_)]}};function tt(n,e,t){if(t.shapes=[],Array.isArray(n))for(let s=0,i=n.length;s<i;s++){const r=n[s];t.shapes.push(r.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class st extends P.BaseObject{constructor(e){super(),this.options=E({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return se(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:s,material:i,percentDepth:r,activeIndex:a}=this.options,u=Math.max(...e),h=e.reduce((o,d)=>o+d,0);let w=Math.PI/2;e.forEach((o,d)=>{if(o===0)return;const b=Math.PI*2*(o/h),m=s[d],x=r?t*(o/u):t,L=this.createGeometry(x,b),M=i?i.clone():new c.MeshBasicMaterial({color:m});i&&M.color.set(m);const _=new c.Mesh(L,M);_.userData.depth=x,_.userData.index=d,_.rotateZ(w),w+=b,this.add(_)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:s,innerRadius:i}=this.options,r=new c.Shape;return r.moveTo(s,0),r.lineTo(i,0),r.absarc(0,0,i,0,t,!1),r.absarc(0,0,s,t,0,!0),new X(r,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:s}=this.pencil.pick(e,this.object3d.children)||{},i=s?this.object3d.children.findIndex(r=>r===s):this.options.activeIndex;return this.setActive(i,t)}setActive(e,t=1.3){const s=this.object3d.children[e];if(this.object3d.children.forEach(i=>{if(!(s&&s===i)&&i.scale.z!==1){if(i.userData.levTween)return;i.userData.enTween&&(i.userData.enTween.stop(),i.userData.enTween=null);const r=new K.Tween(i.scale).to({z:1},100);i.userData.levTween=r,r.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new K.Tween(s.scale).to({z:t},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new K.Tween(this.object3d.scale).to({z:1},1e3).easing(K.Easing.Sinusoidal.InOut).start()}}class it extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,s,i,r,a,u,h,w,o,d,b,m,x,L,M,_,B;const e=this.options;if(e.type==="AmbientLight"){const A=new c.AmbientLight(e.color);A.name="环境光",this.object3d=A}else if(e.type==="DirectionalLight"){const A=new c.DirectionalLight(e.color,e.intensity);A.name="平行光",A.target.position.set(0,0,0),this.object3d=A,A.target.name="平行光目标",A.shadow.camera.name="平行光阴影相机",A.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=A}else if(e.type==="PointLight"){const A=new c.PointLight((t=e.color)!=null?t:16777215,(s=e.intensity)!=null?s:1,(i=e.distance)!=null?i:0,(r=e.decay)!=null?r:2);A.name="点光源",this.object3d=A,this.pointLight=A}else if(e.type==="SpotLight"){const A=new c.SpotLight((a=e.color)!=null?a:16777215,(u=e.intensity)!=null?u:1,(h=e.distance)!=null?h:0,(w=e.angle)!=null?w:Math.PI/3,(o=e.penumbra)!=null?o:1,(d=e.decay)!=null?d:2);A.name="聚光灯",this.object3d=A,this.spotLight=A,A.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const A=new c.HemisphereLight((b=e.color)!=null?b:16777215,(m=e.groundColor)!=null?m:16777215,(x=e.intensity)!=null?x:1);A.name="半球光",this.object3d=A,this.hemisphereLight=A}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Qe.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const A=new c.RectAreaLight((L=e.color)!=null?L:16777215,(M=e.intensity)!=null?M:1,(_=e.width)!=null?_:10,(B=e.height)!=null?B:10);A.name="矩形区域光",this.object3d=A,this.rectAreaLight=A}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const s=this.spotLight||this.directionalLight;s.position.copy(t),s.target.position.copy(t)}else this.pointLight&&this.pointLight.position.copy(t)}dispose(){const e=this.object3d;e.target&&this.pencil.scene.remove(e.target),super.dispose()}}function R(n,e=0){const t=n[0].index!==null,s=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),r={},a={},u=n[0].morphTargetsRelative,h=new c.BufferGeometry;let w=0;for(let o=0;o<n.length;++o){const d=n[o];let b=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in d.attributes){if(!s.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;r[m]===void 0&&(r[m]=[]),r[m].push(d.attributes[m]),b++}if(b!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". Make sure all geometries have the same number of attributes."),null;if(u!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in d.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(d.morphAttributes[m])}if(e){let m;if(t)m=d.index.count;else if(d.attributes.position!==void 0)m=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". The geometry must have either an index or a position attribute"),null;if(e===1)h.addGroup(w,m,o);else if(e===2&&d.groups.length>0)for(let x of d.groups){let L=x.materialIndex;h.addGroup(w+x.start,Math.min(x.count,m),L)}w+=m}}if(t){let o=0;const d=[];for(let b=0;b<n.length;++b){const m=n[b].index;for(let x=0;x<m.count;++x)d.push(m.getX(x)+o);o+=n[b].attributes.position.count}h.setIndex(d)}for(const o in r){const d=pe.mergeAttributes(r[o]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" attribute."),null;h.setAttribute(o,d)}for(const o in a){const d=a[o][0].length;if(d===0)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[o]=[];for(let b=0;b<d;++b){const m=[];for(let L=0;L<a[o].length;++L)m.push(a[o][L][b]);const x=pe.mergeAttributes(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" morphAttribute."),null;h.morphAttributes[o].push(x)}}return e===2?pe.mergeGroups(h):h}const Ce=n=>{const{points:e}=n,t=e.reduce((i,r,a)=>(a<e.length-1&&i.push(r,e[a+1]),i),[]);return new c.BufferGeometry().setFromPoints(t)};let rt=class extends P.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return se(this,null,function*(){const{points:e,pointsArr:t,geometry:s,geometryArr:i,material:r,useGroups:a,setPointWidth:u,lineWidthArr:h,materialParameters:w,instanceCount:o}=this.options;let d=r,b=s;!d&&w&&(d=this.getMaterial(w)),!b&&e?b=Ce({points:e}):!b&&t?b=R(t.map(x=>Ce({points:x})),a!=null?a:0):!b&&i&&i.length>1?b=R(i,a!=null?a:0):!b&&i&&i.length===1&&([b]=i);const m=new Ie.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(b));if(this.pencil.options.WebGPUTHREE){o&&(m.instanceCount=o);const x=new P.LineSegments2(m,d);x.computeLineDistances(),this.object3d=x}else{const x=new Xe.LineSegments2(m,d);x.computeLineDistances(),this.object3d=x}})}getMaterial(e){return new ze.LineMaterial(E({color:new c.Color("#ffffff")},e))}};function me(n,e,t,s,i){let r;if(n=n.subarray||n.slice?n:n.buffer,t=t.subarray||t.slice?t:t.buffer,n=e?n.subarray?n.subarray(e,i&&e+i):n.slice(e,i&&e+i):n,t.set)t.set(n,s);else for(r=0;r<n.length;r++)t[r+s]=n[r];return t}function nt(n){return n instanceof Float32Array?n:n instanceof c.BufferGeometry?n.getAttribute("position").array:n.map(e=>{const t=Array.isArray(e);return e instanceof c.Vector3?[e.x,e.y,e.z]:e instanceof c.Vector2?[e.x,e.y,0]:t&&e.length===3?[e[0],e[1],e[2]]:t&&e.length===2?[e[0],e[1],0]:e}).flat()}class Re extends c.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new c.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=nt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof c.Vector3)for(let s=0;s<e.length;s++){const i=e[s],r=s/(e.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(r),this.counters.push(r)}else for(let s=0;s<e.length;s+=3){const i=s/(e.length-1);this.positions.push(e[s],e[s+1],e[s+2]),this.positions.push(e[s],e[s+1],e[s+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(e,t){const s=e*6,i=t*6;return this.positions[s]===this.positions[i]&&this.positions[s+1]===this.positions[i+1]&&this.positions[s+2]===this.positions[i+2]}copyV3(e){const t=e*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]}process(){const e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let t,s;this.compareV3(0,e-1)?s=this.copyV3(e-2):s=this.copyV3(0),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);for(let i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(i/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const r=i*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}i>0&&(s=this.copyV3(i),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(e-1,0)?s=this.copyV3(1):s=this.copyV3(e-1),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new c.BufferAttribute(new Float32Array(this.positions),3),previous:new c.BufferAttribute(new Float32Array(this.previous),3),next:new c.BufferAttribute(new Float32Array(this.next),3),side:new c.BufferAttribute(new Float32Array(this.side),1),width:new c.BufferAttribute(new Float32Array(this.width),1),uv:new c.BufferAttribute(new Float32Array(this.uvs),2),index:new c.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new c.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:e,y:t,z:s}){const i=this._attributes.position.array,r=this._attributes.previous.array,a=this._attributes.next.array,u=i.length;me(i,0,r,0,u),me(i,6,i,0,u-6),i[u-6]=e,i[u-5]=t,i[u-4]=s,i[u-3]=e,i[u-2]=t,i[u-1]=s,me(i,6,a,0,u-6),a[u-6]=e,a[u-5]=t,a[u-4]=s,a[u-3]=e,a[u-2]=t,a[u-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const ge=n=>{const{setPointWidth:e,nodes:t}=n,s=new Re;return s.setPoints(t,e),s};class ot extends P.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return se(this,null,function*(){const{nodes:e,nodesArr:t,geometry:s,geometryArr:i,material:r,useGroups:a,setPointWidth:u,lineWidthArr:h,materialParameters:w}=this.options;let o=r,d=s;!o&&w&&(o=this.getMaterial(w)),!d&&e?d=ge({nodes:e,setPointWidth:u}):!d&&t?d=R(t.map((b,m)=>{let x=u;return!x&&h&&(x=()=>{var L;return(L=h[m])!=null?L:h[0]}),ge({nodes:b,setPointWidth:x})}),a!=null?a:0):!d&&i&&i.length>1?d=R(i,a!=null?a:0):!d&&i&&i.length===1&&([d]=i),this.createMesh(d,o)})}setGeometry(e,t){const s=ge({nodes:e,setPointWidth:t}),i=this.object3d,r=i.geometry;i.geometry=s,r.dispose()}getMaterial(e){const{width:t,height:s}=this.pencil.getSize();return new P.MeshLineMaterial(E({color:new c.Color("#ffffff"),resolution:new c.Vector2(t,s)},e))}addGeometries(e){const t=this.object3d,s=R([t.geometry,...e]);t.geometry=s}resize(e,t){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:s}=this.pencil.getSize();this.resize(t,s)}animate({duration:e=1e3,delay:t=0,repeat:s=0,lineLoop:i,onRepeat:r,onUpdate:a,onComplete:u,startShow:h}={}){const{offset:w,offsetLoop:o}=this.material.uniforms;if(this.material.userData.tween)return;const d=i!=null?i:!0;w.value.x=1,o.value=d&&h?1:0;let b=0;const m=new K.Tween(w.value).to({x:-1},e).delay(t).repeat(s).onUpdate(({x})=>{d&&x<=0&&o.value===0&&(o.value=1),a&&a(x)}).onRepeat(()=>{b+=1,r&&r(b)}).onComplete(()=>{u&&u()}).start();this.material.userData.tween=m}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),K.remove(this.material.userData.tween)),super.dispose()}}const Ue=n=>{const u=n,{coordinate:e,startHeight:t,height:s}=u,i=fe(u,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof s!="undefined"&&(r=t+s),new P.PolygonGeometry([e],ce(E({},i),{startHeight:t,endHeight:r}))};class at extends P.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const h=this.options,{geometry:e,coordinateArr:t,coordinate:s,material:i,useGroups:r}=h,a=fe(h,["geometry","coordinateArr","coordinate","material","useGroups"]);let u=e;if(!u&&s)u=Ue(E({coordinate:s},a));else if(!u&&t){const w=t.map(o=>Ue(E({coordinate:o},a)));u=R(w,r!=null?r:0)}this.createMesh(u,i)}}class ct extends X{constructor(e,t){super(e,t);const s=new he.Brush(new X(e,ce(E({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));s.updateMatrixWorld();const i=new c.Box3().setFromObject(s),r=new c.Vector3;i.getSize(r);const a=new c.Vector3(i.min.x+r.x/2,i.min.y+r.y/2,0);let u=t.topSegments,h=t.box3;if(h){h=h.union(i);const _=new c.Vector3;h.getSize(_);const B=Math.max(r.x/_.x,r.y/_.y);u=Math.ceil(t.topSegments*B)}if(u<4)return this;const w=new c.PlaneGeometry(r.x,r.y,u,u),o=new he.Brush(w);o.position.set(a.x,a.y,a.z),o.updateMatrixWorld();const b=new he.Evaluator().evaluate(o,s,he.INTERSECTION),m=b.geometry.getAttribute("position"),x=new c.Float32BufferAttribute(m.count*2,2);for(let _=0;_<m.count;_++){const B=m.getZ(_);m.setZ(_,t.depth+B)}if(h){const _=h.min,B=h.max,A=new c.Vector3().subVectors(B,_);for(let I=0;I<m.count;I++){const le=m.getX(I),W=m.getY(I),Y=(le-_.x)/A.x,$=(W-_.y)/A.y;x.setXY(I,Y,$)}b.geometry.setAttribute("uv",x)}m.needsUpdate=!0;const L=new X(e,ce(E({},t),{hasTop:!1})),M=R([b.geometry,L],2);this.copy(M.toNonIndexed())}}const Oe=n=>{const{split:e,depth:t,points:s,box3:i,hasTop:r,hasBottom:a,hasSide:u,sideRepeat:h,topSegments:w}=n,o=w?ct:X,d=new o(new c.Shape(s),{depth:t,bevelEnabled:!1,box3:i,UVGenerator:Ge.getUVGenerator({split:e,box3:i,sideRepeat:h}),hasTop:r,hasBottom:a,hasSide:u,topSegments:w});return Ge.claerUVGenerator(),d};class ht extends P.BaseObject{constructor(e){super(),this.options=E({depth:1},e)}create(){return se(this,null,function*(){const{points:e,pointsArr:t,useGroups:s,depth:i,geometry:r,geometryArr:a,material:u,box3:h,split:w,hasTop:o,hasBottom:d,hasSide:b}=this.options,m=Array.isArray(i)?i:[i],x=Array.isArray(h)?h:[h],L=u;let M=r;L||console.log("material is null"),!M&&e?M=Oe({points:e,depth:m[0],box3:x[0],split:w,hasTop:o,hasBottom:d,hasSide:b}):!M&&t?M=R(t.map((_,B)=>{var A,I;return Oe({points:_,depth:(A=m[B])!=null?A:m[0],box3:(I=x[B])!=null?I:x[0],split:w,hasTop:o,hasBottom:d,hasSide:b})}),s!=null?s:0):!M&&a&&a.length>1?M=R(a,s!=null?s:0):!M&&a&&a.length===1&&([M]=a),this.createMesh(M,L)})}addGeometries(e){const t=this.object3d,s=R([t.geometry,...e]);t.geometry=s}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const lt=n=>{const{topColor:e,sideColor:t,sideMap:s,createCanvasObjectURL:i,split:r,maxAnisotropy:a}=n;return new Promise(u=>{const h=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};h.onload=()=>{const w=r,o=document.createElement("canvas"),d=o.getContext("2d");o.height=h.height/(1-w),o.width=h.width,w&&e&&(d.fillStyle=e,d.fillRect(0,0,h.width,o.height*w)),s&&h instanceof HTMLImageElement?d.drawImage(h,0,o.height*w,h.width,h.height):t&&(d.fillStyle=t,d.fillRect(0,o.height*w,h.width,h.height)),i&&o.toBlob(m=>{console.log(URL.createObjectURL(m))});const b=new c.CanvasTexture(o);u(b)},s?h.src=s:h instanceof HTMLImageElement||h.onload()})};exports.Group=P.Group;exports.MeshLineMaterial=P.MeshLineMaterial;exports.getConicPolygonGeometry=P.PolygonGeometry;exports.getConicPolygonGeometryMetas=P.getMetas;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ie.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>ze.LineMaterial});exports.ConicPolygon=at;exports.ExtrudePolygon=ht;exports.Light=it;exports.Line=ot;exports.Line2=rt;exports.MeshLineGeometry=Re;exports.Node=Ze;exports.Pie=st;exports.getSplitTexture=lt;
|
|
1
|
+
"use strict";var $e=Object.defineProperty,Xe=Object.defineProperties;var Ye=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var Be=(a,e,t)=>e in a?$e(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,E=(a,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&Be(a,t,e[t]);if(ce)for(var t of ce(e))_e.call(e,t)&&Be(a,t,e[t]);return a},le=(a,e)=>Xe(a,Ye(e));var me=(a,e)=>{var t={};for(var n in a)Ee.call(a,n)&&e.indexOf(n)<0&&(t[n]=a[n]);if(a!=null&&ce)for(var n of ce(a))e.indexOf(n)<0&&_e.call(a,n)&&(t[n]=a[n]);return t};var ne=(a,e,t)=>new Promise((n,s)=>{var o=r=>{try{p(t.next(r))}catch(y){s(y)}},l=r=>{try{p(t.throw(r))}catch(y){s(y)}},p=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,l);p((t=t.apply(a,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../index2.js"),u=require("three"),Ze=require("@tweenjs/tween.js"),Je=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),pe=require("three/examples/jsm/utils/BufferGeometryUtils"),Qe=require("three/examples/jsm/lines/LineSegments2"),Re=require("three/examples/jsm/lines/LineSegmentsGeometry"),De=require("three/examples/jsm/lines/LineMaterial"),Pe=require("../uvGenerator.js"),he=require("three-bvh-csg");function Ke(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const K=Ke(Ze);class et extends _.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=E({type:"2d"},e)}create(){const{position:e,children:t}=this.options,n=document.createElement("div");this.element=n,t&&n.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(n):this.options.type==="3dSprite"?this.createCSS3DSprite(n):this.createCSS2DObject(n),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),n=window.innerWidth,s=window.innerHeight;let o=0,l=0;t.left<0?o=-t.left:t.right>n&&(o=n-t.right),t.top<0?l=-t.top:t.bottom>s&&(l=s-t.bottom),t.left+o<0&&(o=-t.left),t.top+l<0&&(l=-t.top),(o!==0||l!==0)&&(e.style.transform=`translate(${o}px, ${l}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 tt extends _.BaseObject{create(){this.createGroup()}}const nt={ArcCurve:u.ArcCurve,CatmullRomCurve3:u.CatmullRomCurve3,CubicBezierCurve:u.CubicBezierCurve,CubicBezierCurve3:u.CubicBezierCurve3,EllipseCurve:u.EllipseCurve,LineCurve:u.LineCurve,LineCurve3:u.LineCurve3,QuadraticBezierCurve:u.QuadraticBezierCurve,QuadraticBezierCurve3:u.QuadraticBezierCurve3,SplineCurve:u.SplineCurve};class Z extends u.BufferGeometry{constructor(e=new u.Shape([new u.Vector2(.5,.5),new u.Vector2(-.5,.5),new u.Vector2(-.5,-.5),new u.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 y=e[p];l(y)}this.setAttribute("position",new u.Float32BufferAttribute(s,3)),this.setAttribute("uv",new u.Float32BufferAttribute(o,2)),this.computeVertexNormals();function l(p){var Se,Ae,Me;const r=[],y=t.curveSegments!==void 0?t.curveSegments:12,i=t.steps!==void 0?t.steps:1,c=t.depth!==void 0?t.depth:1;let x=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,w=t.bevelSize!==void 0?t.bevelSize:f-.1,T=t.bevelOffset!==void 0?t.bevelOffset:0,L=t.bevelSegments!==void 0?t.bevelSegments:3;const M=t.extrudePath,B=t.UVGenerator!==void 0?t.UVGenerator:st,S=(Se=t.hasTop)!=null?Se:!0,I=(Ae=t.hasBottom)!=null?Ae:!0,ue=(Me=t.hasSide)!=null?Me:!0;let F,J=!1,$,ee,te,D;M&&(F=M.getSpacedPoints(i),J=!0,x=!1,$=M.computeFrenetFrames(i,!1),ee=new u.Vector3,te=new u.Vector3,D=new u.Vector3),x||(L=0,f=0,w=0,T=0);const ye=p.extractPoints(y);let z=ye.shape;const P=ye.holes;if(!u.ShapeUtils.isClockWise(z)){z=z.reverse();for(let h=0,d=P.length;h<d;h++){const m=P[h];u.ShapeUtils.isClockWise(m)&&(P[h]=m.reverse())}}function be(h){const m=10000000000000001e-36;let b=h[0];for(let g=1;g<=h.length;g++){const A=g%h.length,v=h[A],C=v.x-b.x,G=v.y-b.y,j=C*C+G*G,V=Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(b.x),Math.abs(b.y)),Y=m*V*V;if(j<=Y){h.splice(A,1),g--;continue}b=v}}be(z),P.forEach(be);const fe=P.length,U=z;for(let h=0;h<fe;h++){const d=P[h];z=z.concat(d)}function Q(h,d,m){return d||console.error("THREE.ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(d,m)}const H=z.length;function xe(h,d,m){let b,g,A;const v=h.x-d.x,C=h.y-d.y,G=m.x-h.x,j=m.y-h.y,V=v*v+C*C,Y=v*j-C*G;if(Math.abs(Y)>Number.EPSILON){const O=Math.sqrt(V),Le=Math.sqrt(G*G+j*j),Te=d.x-C/O,Ce=d.y+v/O,ke=m.x-j/Le,Fe=m.y+G/Le,Ge=((ke-Te)*j-(Fe-Ce)*G)/(v*j-C*G);b=Te+v*Ge-h.x,g=Ce+C*Ge-h.y;const je=b*b+g*g;if(je<=2)return new u.Vector2(b,g);A=Math.sqrt(je/2)}else{let O=!1;v>Number.EPSILON?G>Number.EPSILON&&(O=!0):v<-Number.EPSILON?G<-Number.EPSILON&&(O=!0):Math.sign(C)===Math.sign(j)&&(O=!0),O?(b=-C,g=v,A=Math.sqrt(V)):(b=v,g=C,A=Math.sqrt(V/2))}return new u.Vector2(b/A,g/A)}const ie=[];for(let h=0,d=U.length,m=d-1,b=h+1;h<d;h++,m++,b++)m===d&&(m=0),b===d&&(b=0),ie[h]=xe(U[h],U[m],U[b]);const de=[];let k,oe=ie.concat();for(let h=0,d=fe;h<d;h++){const m=P[h];k=[];for(let b=0,g=m.length,A=g-1,v=b+1;b<g;b++,A++,v++)A===g&&(A=0),v===g&&(v=0),k[b]=xe(m[b],m[A],m[v]);de.push(k),oe=oe.concat(k)}let X;if(L===0)X=u.ShapeUtils.triangulateShape(U,P);else{const h=[],d=[];for(let m=0;m<L;m++){const b=m/L,g=f*Math.cos(b*Math.PI/2),A=w*Math.sin(b*Math.PI/2)+T;for(let v=0,C=U.length;v<C;v++){const G=Q(U[v],ie[v],A);N(G.x,G.y,-g),b===0&&h.push(G)}for(let v=0,C=fe;v<C;v++){const G=P[v];k=de[v];const j=[];for(let V=0,Y=G.length;V<Y;V++){const O=Q(G[V],k[V],A);N(O.x,O.y,-g),b===0&&j.push(O)}b===0&&d.push(j)}}X=u.ShapeUtils.triangulateShape(h,d)}const re=X.length,we=w+T;for(let h=0;h<H;h++){const d=x?Q(z[h],oe[h],we):z[h];J?(te.copy($.normals[0]).multiplyScalar(d.x),ee.copy($.binormals[0]).multiplyScalar(d.y),D.copy(F[0]).add(te).add(ee),N(D.x,D.y,D.z)):N(d.x,d.y,0)}for(let h=1;h<=i;h++)for(let d=0;d<H;d++){const m=x?Q(z[d],oe[d],we):z[d];J?(te.copy($.normals[h]).multiplyScalar(m.x),ee.copy($.binormals[h]).multiplyScalar(m.y),D.copy(F[h]).add(te).add(ee),N(D.x,D.y,D.z)):N(m.x,m.y,c/i*h)}for(let h=L-1;h>=0;h--){const d=h/L,m=f*Math.cos(d*Math.PI/2),b=w*Math.sin(d*Math.PI/2)+T;for(let g=0,A=U.length;g<A;g++){const v=Q(U[g],ie[g],b);N(v.x,v.y,c+m)}for(let g=0,A=P.length;g<A;g++){const v=P[g];k=de[g];for(let C=0,G=v.length;C<G;C++){const j=Q(v[C],k[C],b);J?N(j.x,j.y+F[i-1].y,F[i-1].x+m):N(j.x,j.y,c+m)}}}Ne(),ue&&We();function Ne(){const h=s.length/3;if(x){let d=0,m=H*d;if(I)for(let b=0;b<re;b++){const g=X[b];ae(g[2]+m,g[1]+m,g[0]+m)}if(d=i+L*2,m=H*d,S)for(let b=0;b<re;b++){const g=X[b];ae(g[0]+m,g[1]+m,g[2]+m)}}else{if(I)for(let d=0;d<re;d++){const m=X[d];ae(m[2],m[1],m[0])}if(S)for(let d=0;d<re;d++){const m=X[d];ae(m[0]+H*i,m[1]+H*i,m[2]+H*i)}}n.addGroup(h,s.length/3-h,0)}function We(){const h=s.length/3;let d=0;ve(U,d),d+=U.length;for(let m=0,b=P.length;m<b;m++){const g=P[m];ve(g,d),d+=g.length}n.addGroup(h,s.length/3-h,1)}function ve(h,d){let m=h.length;for(;--m>=0;){const b=m;let g=m-1;g<0&&(g=h.length-1);for(let A=0,v=i+L*2;A<v;A++){const C=H*A,G=H*(A+1),j=d+b+C,V=d+g+C,Y=d+g+G,O=d+b+G;qe(j,V,Y,O)}}}function N(h,d,m){r.push(h),r.push(d),r.push(m)}function ae(h,d,m){W(h),W(d),W(m);const b=s.length/3,g=B.generateTopUV(n,s,b-3,b-2,b-1);q(g[0]),q(g[1]),q(g[2])}function qe(h,d,m,b){W(h),W(d),W(b),W(d),W(m),W(b);const g=s.length/3,A=B.generateSideWallUV(n,s,g-6,g-3,g-2,g-1);q(A[0]),q(A[1]),q(A[3]),q(A[1]),q(A[2]),q(A[3])}function W(h){s.push(r[h*3+0]),s.push(r[h*3+1]),s.push(r[h*3+2])}function q(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 it(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,l=e.shapes.length;o<l;o++){const p=t[e.shapes[o]];n.push(p)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new nt[`${s.type}`]().fromJSON(s)),new Z(n,e.options)}}const st={generateTopUV:function(a,e,t,n,s){const o=e[t*3],l=e[t*3+1],p=e[n*3],r=e[n*3+1],y=e[s*3],i=e[s*3+1];return[new u.Vector2(o,l),new u.Vector2(p,r),new u.Vector2(y,i)]},generateSideWallUV:function(a,e,t,n,s,o){const l=e[t*3],p=e[t*3+1],r=e[t*3+2],y=e[n*3],i=e[n*3+1],c=e[n*3+2],x=e[s*3],f=e[s*3+1],w=e[s*3+2],T=e[o*3],L=e[o*3+1],M=e[o*3+2];return Math.abs(p-i)<Math.abs(l-y)?[new u.Vector2(l,1-r),new u.Vector2(y,1-c),new u.Vector2(x,1-w),new u.Vector2(T,1-M)]:[new u.Vector2(p,1-r),new u.Vector2(i,1-c),new u.Vector2(f,1-w),new u.Vector2(L,1-M)]}};function it(a,e,t){if(t.shapes=[],Array.isArray(a))for(let n=0,s=a.length;n<s;n++){const o=a[n];t.shapes.push(o.uuid)}else t.shapes.push(a.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class ot extends _.BaseObject{constructor(e){super(),this.options=E({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return ne(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:n,material:s,percentDepth:o,activeIndex:l}=this.options,p=Math.max(...e),r=e.reduce((i,c)=>i+c,0);let y=Math.PI/2;e.forEach((i,c)=>{if(i===0)return;const x=Math.PI*2*(i/r),f=n[c],w=o?t*(i/p):t,T=this.createGeometry(w,x),L=s?s.clone():new u.MeshBasicMaterial({color:f});s&&L.color.set(f);const M=new u.Mesh(T,L);M.userData.depth=w,M.userData.index=c,M.rotateZ(y),y+=x,this.add(M)}),l!==-1&&this.setActive(l)})}createGeometry(e,t){const{outRadius:n,innerRadius:s}=this.options,o=new u.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 Z(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 K.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 K.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 K.Tween(this.object3d.scale).to({z:1},1e3).easing(K.Easing.Sinusoidal.InOut).start()}}class rt extends _.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,n,s,o,l,p,r,y,i,c,x,f,w,T,L,M,B;const e=this.options;if(e.type==="AmbientLight"){const S=new u.AmbientLight(e.color);S.name="环境光",this.object3d=S}else if(e.type==="DirectionalLight"){const S=new u.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 u.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 u.SpotLight((l=e.color)!=null?l:16777215,(p=e.intensity)!=null?p:1,(r=e.distance)!=null?r:0,(y=e.angle)!=null?y:Math.PI/3,(i=e.penumbra)!=null?i:1,(c=e.decay)!=null?c:2);S.name="聚光灯",this.object3d=S,this.spotLight=S,S.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const S=new u.HemisphereLight((x=e.color)!=null?x:16777215,(f=e.groundColor)!=null?f:16777215,(w=e.intensity)!=null?w:1);S.name="半球光",this.object3d=S,this.hemisphereLight=S}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Je.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const S=new u.RectAreaLight((T=e.color)!=null?T:16777215,(L=e.intensity)!=null?L:1,(M=e.width)!=null?M:10,(B=e.height)!=null?B:10);S.name="矩形区域光",this.object3d=S,this.rectAreaLight=S}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const n=this.spotLight||this.directionalLight;n.position.copy(t),n.target.position.copy(t)}else this.pointLight&&this.pointLight.position.copy(t)}dispose(){const e=this.object3d;e.target&&this.pencil.scene.remove(e.target),super.dispose()}}function R(a,e=0){const t=a[0].index!==null,n=new Set(Object.keys(a[0].attributes)),s=new Set(Object.keys(a[0].morphAttributes)),o={},l={},p=a[0].morphTargetsRelative,r=new u.BufferGeometry;let y=0;for(let i=0;i<a.length;++i){const c=a[i];let x=0;if(t!==(c.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 f in c.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;o[f]===void 0&&(o[f]=[]),o[f].push(c.attributes[f]),x++}if(x!==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!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in c.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+i+". .morphAttributes must be consistent throughout all geometries."),null;l[f]===void 0&&(l[f]=[]),l[f].push(c.morphAttributes[f])}if(e){let f;if(t)f=c.index.count;else if(c.attributes.position!==void 0)f=c.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(y,f,i);else if(e===2&&c.groups.length>0)for(let w of c.groups){let T=w.materialIndex;r.addGroup(y+w.start,Math.min(w.count,f),T)}y+=f}}if(t){let i=0;const c=[];for(let x=0;x<a.length;++x){const f=a[x].index;for(let w=0;w<f.count;++w)c.push(f.getX(w)+i);i+=a[x].attributes.position.count}r.setIndex(c)}for(const i in o){const c=pe.mergeAttributes(o[i]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" attribute."),null;r.setAttribute(i,c)}for(const i in l){const c=l[i][0].length;if(c===0)break;r.morphAttributes=r.morphAttributes||{},r.morphAttributes[i]=[];for(let x=0;x<c;++x){const f=[];for(let T=0;T<l[i].length;++T)f.push(l[i][T][x]);const w=pe.mergeAttributes(f);if(!w)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+i+" morphAttribute."),null;r.morphAttributes[i].push(w)}}return e===2?pe.mergeGroups(r):r}const Ve=a=>{const{points:e}=a,t=e.reduce((s,o,l)=>(l<e.length-1&&s.push(o,e[l+1]),s),[]);return new u.BufferGeometry().setFromPoints(t)};let at=class extends _.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ne(this,null,function*(){const{points:e,pointsArr:t,geometry:n,geometryArr:s,material:o,useGroups:l,setPointWidth:p,lineWidthArr:r,materialParameters:y,instanceCount:i}=this.options;let c=o,x=n;!c&&y&&(c=this.getMaterial(y)),!x&&e?x=Ve({points:e}):!x&&t?x=R(t.map(w=>Ve({points:w})),l!=null?l:0):!x&&s&&s.length>1?x=R(s,l!=null?l:0):!x&&s&&s.length===1&&([x]=s);const f=new Re.LineSegmentsGeometry().fromLineSegments(new u.LineSegments(x));if(this.pencil.options.WebGPUTHREE){i&&(f.instanceCount=i);const w=new _.LineSegments2(f,c);w.computeLineDistances(),this.object3d=w}else{const w=new Qe.LineSegments2(f,c);w.computeLineDistances(),this.object3d=w}})}getMaterial(e){return new De.LineMaterial(E({color:new u.Color("#ffffff")},e))}};const se=(a,e,t,n,s)=>{a[e+0]=t,a[e+1]=n,a[e+2]=s,a[e+3]=t,a[e+4]=n,a[e+5]=s},Oe=(a,e,t,n)=>{a[e+0]=t,a[e+1]=n},ze=(a,e,t,n,s)=>{a[e+0]=t,a[e+1]=n,a[e+2]=s},ct=(a,e,t,n,s,o)=>{a[e+0]=t,a[e+1]=n,a[e+2]=s,a[e+3]=o};class He extends u.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 u.Matrix4,this.shape=t,n&&(this.shapeFunction=n),e.length>0&&this.setPoints(e)}convertToVector3Array(e){return e.map(t=>{var n;if(t instanceof u.Vector2)return new u.Vector3(t.x,t.y,0);if(t instanceof u.Vector3)return t;if(Array.isArray(t)&&t.length>=2)return new u.Vector3(t[0],t[1],(n=t[2])!=null?n:0)}).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=[];let t=0;const n=[],s=[];let o=0;const l=[];let p=0;const r=[];let y=0;this.shape==="taper"&&(this.shapeFunction=i=>1*Math.pow(4*i*(1-i),1));for(let i=0;i<this.pointCount;i++){const c=i/this._points.length;e[t+0]=c,e[t+1]=c,t+=2,Oe(n,o,1,-1);const x=this.shape==="none"?1:this.shapeFunction(i/(this.pointCount-1));if(Oe(s,o,x,x),o+=2,ct(l,p,i/(this.pointCount-1),0,i/(this.pointCount-1),1),p+=4,i<this.pointCount-1){const f=i*2;ze(r,y,f+0,f+1,f+2),ze(r,y+3,f+2,f+1,f+3),y+=6}}this.setAttribute("position",new u.BufferAttribute(new Float32Array(this.pointCount*6),3)),this.setAttribute("previous",new u.BufferAttribute(new Float32Array(this.pointCount*6),3)),this.setAttribute("next",new u.BufferAttribute(new Float32Array(this.pointCount*6),3)),this.setAttribute("counters",new u.BufferAttribute(new Float32Array(e),1)),this.setAttribute("side",new u.BufferAttribute(new Float32Array(n),1)),this.setAttribute("width",new u.BufferAttribute(new Float32Array(s),1)),this.setAttribute("uv",new u.BufferAttribute(new Float32Array(l),2)),this.setIndex(new u.BufferAttribute(new Uint16Array(r),1))}updateGeometry(){if(!this._points[0])return;const e=[],t=[],n=[];let s=0,o=0,l=0;se(t,o,this._points[0].x,this._points[0].y,this._points[0].z),o+=6;for(let i=0;i<this.pointCount;i++){const c=this._points[i];se(e,s,c.x,c.y,c.z),s+=6,i<this.pointCount-1&&(se(t,o,c.x,c.y,c.z),o+=6),i>0&&i+1<=this.pointCount&&(se(n,l,c.x,c.y,c.z),l+=6)}se(n,l,this._points[this.pointCount-1].x,this._points[this.pointCount-1].y,this._points[this.pointCount-1].z);const p=this.getAttribute("position"),r=this.getAttribute("previous"),y=this.getAttribute("next");p.set(e),r.set(t),y.set(n),p.needsUpdate=!0,r.needsUpdate=!0,y.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())}}const ge=a=>{const{setPointWidth:e,nodes:t}=a,n=new He;return n.setPoints(t,e),n};class lt extends _.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ne(this,null,function*(){const{nodes:e,nodesArr:t,geometry:n,geometryArr:s,material:o,useGroups:l,setPointWidth:p,lineWidthArr:r,materialParameters:y}=this.options;let i=o,c=n;!i&&y&&(i=this.getMaterial(y)),!c&&e?c=ge({nodes:e,setPointWidth:p}):!c&&t?c=R(t.map((x,f)=>{let w=p;return!w&&r&&(w=()=>{var T;return(T=r[f])!=null?T:r[0]}),ge({nodes:x,setPointWidth:w})}),l!=null?l:0):!c&&s&&s.length>1?c=R(s,l!=null?l:0):!c&&s&&s.length===1&&([c]=s),this.createMesh(c,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 _.MeshLineMaterial(E({color:new u.Color("#ffffff")},e));return s.uniforms.resolution.value.set(t,n),s}addGeometries(e){const t=this.object3d,n=R([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)}useMaterial(e){super.useMaterial(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:l,onComplete:p,startShow:r}={}){const{offset:y,offsetLoop:i}=this.material.uniforms;if(this.material.userData.tween)return;const c=s!=null?s:!0;y.value.x=1,i.value=c&&r?1:0;let x=0;const f=new K.Tween(y.value).to({x:-1},e).delay(t).repeat(n).onUpdate(({x:w})=>{c&&w<=0&&i.value===0&&(i.value=1),l&&l(w)}).onRepeat(()=>{x+=1,o&&o(x)}).onComplete(()=>{p&&p()}).start();this.material.userData.tween=f}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),K.remove(this.material.userData.tween)),super.dispose()}}const Ie=a=>{const p=a,{coordinate:e,startHeight:t,height:n}=p,s=me(p,["coordinate","startHeight","height"]);let o=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(o=t+n),new _.PolygonGeometry([e],le(E({},s),{startHeight:t,endHeight:o}))};class ht extends _.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const r=this.options,{geometry:e,coordinateArr:t,coordinate:n,material:s,useGroups:o}=r,l=me(r,["geometry","coordinateArr","coordinate","material","useGroups"]);let p=e;if(!p&&n)p=Ie(E({coordinate:n},l));else if(!p&&t){const y=t.map(i=>Ie(E({coordinate:i},l)));p=R(y,o!=null?o:0)}this.createMesh(p,s)}}class ut extends Z{constructor(e,t){super(e,t);const n=new he.Brush(new Z(e,le(E({},t),{hasTop:!0,hasSide:!0,hasBottom:!1})));n.updateMatrixWorld();const s=new u.Box3().setFromObject(n),o=new u.Vector3;s.getSize(o);const l=new u.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 u.Vector3;r.getSize(M);const B=Math.max(o.x/M.x,o.y/M.y);p=Math.ceil(t.topSegments*B)}if(p<4)return this;const y=new u.PlaneGeometry(o.x,o.y,p,p),i=new he.Brush(y);i.position.set(l.x,l.y,l.z),i.updateMatrixWorld();const x=new he.Evaluator().evaluate(i,n,he.INTERSECTION),f=x.geometry.getAttribute("position"),w=new u.Float32BufferAttribute(f.count*2,2);for(let M=0;M<f.count;M++){const B=f.getZ(M);f.setZ(M,t.depth+B)}if(r){const M=r.min,B=r.max,S=new u.Vector3().subVectors(B,M);for(let I=0;I<f.count;I++){const ue=f.getX(I),F=f.getY(I),J=(ue-M.x)/S.x,$=(F-M.y)/S.y;w.setXY(I,J,$)}x.geometry.setAttribute("uv",w)}f.needsUpdate=!0;const T=new Z(e,le(E({},t),{hasTop:!1})),L=R([x.geometry,T],2);this.copy(L.toNonIndexed())}}const Ue=a=>{const{split:e,depth:t,points:n,box3:s,hasTop:o,hasBottom:l,hasSide:p,sideRepeat:r,topSegments:y}=a,i=y?ut:Z,c=new i(new u.Shape(n),{depth:t,bevelEnabled:!1,box3:s,UVGenerator:Pe.getUVGenerator({split:e,box3:s,sideRepeat:r}),hasTop:o,hasBottom:l,hasSide:p,topSegments:y});return Pe.claerUVGenerator(),c};class ft extends _.BaseObject{constructor(e){super(),this.options=E({depth:1},e)}create(){return ne(this,null,function*(){const{points:e,pointsArr:t,useGroups:n,depth:s,geometry:o,geometryArr:l,material:p,box3:r,split:y,hasTop:i,hasBottom:c,hasSide:x}=this.options,f=Array.isArray(s)?s:[s],w=Array.isArray(r)?r:[r],T=p;let L=o;T||console.log("material is null"),!L&&e?L=Ue({points:e,depth:f[0],box3:w[0],split:y,hasTop:i,hasBottom:c,hasSide:x}):!L&&t?L=R(t.map((M,B)=>{var S,I;return Ue({points:M,depth:(S=f[B])!=null?S:f[0],box3:(I=w[B])!=null?I:w[0],split:y,hasTop:i,hasBottom:c,hasSide:x})}),n!=null?n:0):!L&&l&&l.length>1?L=R(l,n!=null?n:0):!L&&l&&l.length===1&&([L]=l),this.createMesh(L,T)})}addGeometries(e){const t=this.object3d,n=R([t.geometry,...e]);t.geometry=n}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const dt=a=>{const{topColor:e,sideColor:t,sideMap:n,createCanvasObjectURL:s,split:o,maxAnisotropy:l}=a;return new Promise(p=>{const r=n?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};r.onload=()=>{const y=o,i=document.createElement("canvas"),c=i.getContext("2d");i.height=r.height/(1-y),i.width=r.width,y&&e&&(c.fillStyle=e,c.fillRect(0,0,r.width,i.height*y)),n&&r instanceof HTMLImageElement?c.drawImage(r,0,i.height*y,r.width,r.height):t&&(c.fillStyle=t,c.fillRect(0,i.height*y,r.width,r.height)),s&&i.toBlob(f=>{console.log(URL.createObjectURL(f))});const x=new u.CanvasTexture(i);p(x)},n?r.src=n:r instanceof HTMLImageElement||r.onload()})};exports.MeshLineMaterial=_.MeshLineMaterial;exports.getConicPolygonGeometry=_.PolygonGeometry;exports.getConicPolygonGeometryMetas=_.getMetas;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Re.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>De.LineMaterial});exports.ConicPolygon=ht;exports.ExtrudePolygon=ft;exports.Group=tt;exports.Light=rt;exports.Line=lt;exports.Line2=at;exports.MeshLineGeometry=He;exports.Node=et;exports.Pie=ot;exports.getSplitTexture=dt;
|