gl-draw 0.14.35 → 0.14.37
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/core/BaseObject.d.ts +19 -19
- package/dist/core/CSSRenderer/index.d.ts +2 -2
- package/dist/core/Camera.d.ts +10 -10
- package/dist/core/Composer.d.ts +9 -9
- package/dist/core/Controls.d.ts +2 -2
- package/dist/core/Helper.d.ts +3 -3
- package/dist/core/Lead/Lead.d.ts +5 -5
- package/dist/core/Lead/index.d.ts +2 -2
- package/dist/core/Loader/GzipJSONLoader.d.ts +4 -4
- package/dist/core/Loader/Loader.d.ts +22 -22
- package/dist/core/Loader/TextureLoader.d.ts +4 -4
- package/dist/core/Loader/index.d.ts +2 -2
- package/dist/core/Pencil.d.ts +11 -11
- package/dist/core/Renderer.d.ts +3 -3
- package/dist/core/ResourceTracker.d.ts +4 -4
- package/dist/core/Scene.d.ts +5 -5
- package/dist/core/TransformControls/index.d.ts +5 -5
- package/dist/core/WebGPURenderer.d.ts +2 -2
- package/dist/effect/index.js +3 -3
- package/dist/effect/index.module.js +41 -41
- package/dist/effect/scan.d.ts +3 -3
- package/dist/effect/scan2.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.module.js +526 -557
- package/dist/index.module2.js +251 -255
- package/dist/index2.js +5 -5
- package/dist/objects/conicPolygon/index.d.ts +3 -3
- package/dist/objects/extrudePolygon/ExtrudeGeometry.d.ts +23 -3
- package/dist/objects/extrudePolygon/ExtrudeGeometry2.d.ts +2 -2
- package/dist/objects/extrudePolygon/createGeometry.d.ts +22 -22
- package/dist/objects/extrudePolygon/getSplitTexture.d.ts +2 -2
- package/dist/objects/extrudePolygon/index.d.ts +9 -9
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +539 -565
- package/dist/objects/light/index.d.ts +6 -6
- package/dist/objects/line/index.d.ts +4 -4
- package/dist/objects/line/meshLine/MeshLineGeometry.d.ts +15 -15
- package/dist/objects/line/meshLine/MeshLineMaterial.d.ts +14 -14
- package/dist/objects/line/meshLine/index.d.ts +0 -1
- package/dist/objects/line2/createGeometry.d.ts +3 -3
- package/dist/objects/line2/index.d.ts +5 -5
- package/dist/objects/node/index.d.ts +3 -3
- package/dist/objects/pie/index.d.ts +67 -4
- package/dist/objects/scene/index.d.ts +2 -2
- package/dist/parseVector.js +1 -1
- package/dist/parseVector.module.js +10 -10
- package/dist/plugins/Worker/createGeometry.d.ts +2 -2
- package/dist/plugins/Worker/getAttributes/coords2Vector.d.ts +2 -2
- package/dist/plugins/Worker/getAttributes/extrudePolygon.d.ts +1 -2
- package/dist/plugins/Worker/getAttributes/line2.d.ts +1 -2
- package/dist/plugins/Worker/getAttributes/splitPolygonsByLongitudeDifference.d.ts +2 -2
- package/dist/plugins/Worker/index.d.ts +8 -8
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +91 -91
- package/dist/utils/Sprite2Points.d.ts +2 -2
- package/dist/utils/colorCorrection.d.ts +4 -4
- package/dist/utils/parseVector.d.ts +3 -3
- package/dist/utils/uvGenerator.d.ts +4 -4
- package/dist/uvGenerator.js +1 -1
- package/dist/uvGenerator.module.js +46 -67
- package/package.json +1 -1
- package/dist/objects/fix.d.ts +0 -5
- package/dist/objects/line/meshLine/raycast.d.ts +0 -3
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var fe=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var J=Math.pow,H=(o,e,t)=>e in o?fe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,O=(o,e)=>{for(var t in e||(e={}))me.call(e,t)&&H(o,t,e[t]);if(Y)for(var t of Y(e))ve.call(e,t)&&H(o,t,e[t]);return o},F=(o,e)=>de(o,pe(e));var ee=(o,e,t)=>new Promise((i,s)=>{var a=c=>{try{r(t.next(c))}catch(u){s(u)}},l=c=>{try{r(t.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,l);r((t=t.apply(o,e)).next())});const n=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),k=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),ye=require("@turf/boolean-clockwise"),xe=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),we=require("d3-geo-voronoi"),ie=require("d3-scale");class _{constructor(){this.resources=new Set,this.disposeWithMaterial=!0,this.materialList={},this.disposeTrack=!0}track(e){if(!e||this.disposeTrack===!1)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeWithMaterial&&e instanceof n.Material)return e;if(e instanceof _?(e===this&&e.object3d?this.track(e.object3d):(e.disposeTrack=!1,this.resources.add(e)),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof n.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof _)this.track(e.children);else if(e instanceof n.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof n.Material){for(const i of Object.values(e))i instanceof n.Texture&&(this.track(i),i instanceof n.VideoTexture&&i.source.data&&this.track(i.source.data));const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof n.Texture||Array.isArray(s))&&this.track(s)}}}return e}dispose(){const e=[];for(const t of this.resources)t instanceof n.Object3D?e.push(t):t instanceof HTMLVideoElement&&(t.pause(),t.src="",t.remove()),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Pe=(o,e=1)=>{const t=new n.BufferGeometry;t.setAttribute("position",new n.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new n.Float32BufferAttribute(new Array(e).fill(1),1));const i=o.material,s=new n.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 s.onBeforeCompile=a=>{a.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
3
|
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
-
`},new
|
|
4
|
+
`},new n.Points(t,s)};class ue extends _{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}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 add(){return this.object3d.add.bind(this.object3d)}get remove(){return this.object3d.remove.bind(this.object3d)}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}hide(){return this.object3d.visible=!1,this}createMesh(...e){return this.object3d=new n.Mesh(...e),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...e){return this.object3d=new n.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new n.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new n.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new n.Vector3),center:e.getCenter(new n.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e,t){return ee(this,null,function*(){var p;const i=e&&e.length>0,s=(p=t==null?void 0:t.recursive)!=null?p:!0,{objectType:a,objectOptions:l}=this,[,r]=a.split("#");let c=t==null?void 0:t.create;c===void 0&&(c=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof n.Sprite)h.object3d=Pe(this.object3d,v);else{const d=this.object3d;h.object3d=new n.InstancedMesh(d.geometry,d.material,v),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate")}const f=new n.Object3D;e.forEach((d,m)=>{const b=Q.parseVector3(d.position),P=Q.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(m,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate");h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(r,F(O({},l||{}),{create:c,prefab:!1,key:(t==null?void 0:t.key)||(l==null?void 0:l.key),target:(t==null?void 0:t.target)||(l==null?void 0:l.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(e,t){if(this.object3d instanceof n.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof n.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,l=s.attributes.scaleAtt.array,r=new n.Vector3,c=new n.Vector3,u=new n.Quaternion,p=e*3,h=e*1;t.decompose(r,u,c),a[p]=r.x,a[p+1]=r.y,a[p+2]=r.z,l[h]=Math.max(c.x,c.y,c.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e])if(i){const l=this.materialList[e],r=new _;r.track(l),r.dispose()}else return this.materialList[e];const a=t==="clone"?this.cloneMaterial():t;return this.materialList[e]=a,a}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}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;this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}disposeWithOutMaterial(){this.disposeWithMaterial=!1,this.dispose()}}class Ae extends ue{create(){this.createGroup()}}const Z=new n.Vector4,se=new n.Vector3,re=new n.Vector3,y=new n.Vector4,x=new n.Vector4,z=new n.Vector4,$=new n.Vector3,N=new n.Matrix4,M=new n.Line3,ne=new n.Vector3,R=new n.Box3,E=new n.Sphere,B=new n.Vector4;let I,L;function ae(o,e,t){return B.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),B.multiplyScalar(1/B.w),B.x=L/t.width,B.y=L/t.height,B.applyMatrix4(o.projectionMatrixInverse),B.multiplyScalar(1/B.w),Math.abs(Math.max(B.x,B.y))}function Se(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){M.start.fromBufferAttribute(s,r),M.end.fromBufferAttribute(a,r),M.applyMatrix4(t);const u=new n.Vector3,p=new n.Vector3;I.distanceSqToSegment(M.start,M.end,p,u),p.distanceTo(u)<L*.5&&e.push({point:p,pointOnLine:u,distance:I.origin.distanceTo(p),object:o,face:null,faceIndex:r,uv:null,uv1:null})}}function je(o,e,t){const i=e.projectionMatrix,a=o.material.resolution,l=o.matrixWorld,r=o.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,p=Math.min(r.instanceCount,c.count),h=-e.near;I.at(1,z),z.w=1,z.applyMatrix4(e.matrixWorldInverse),z.applyMatrix4(i),z.multiplyScalar(1/z.w),z.x*=a.x/2,z.y*=a.y/2,z.z=0,$.copy(z),N.multiplyMatrices(e.matrixWorldInverse,l);for(let v=0,f=p;v<f;v++){if(y.fromBufferAttribute(c,v),x.fromBufferAttribute(u,v),y.w=1,x.w=1,y.applyMatrix4(N),x.applyMatrix4(N),y.z>h&&x.z>h)continue;if(y.z>h){const V=y.z-x.z,A=(y.z-h)/V;y.lerp(x,A)}else if(x.z>h){const V=x.z-y.z,A=(x.z-h)/V;x.lerp(y,A)}y.applyMatrix4(i),x.applyMatrix4(i),y.multiplyScalar(1/y.w),x.multiplyScalar(1/x.w),y.x*=a.x/2,y.y*=a.y/2,x.x*=a.x/2,x.y*=a.y/2,M.start.copy(y),M.start.z=0,M.end.copy(x),M.end.z=0;const m=M.closestPointToPointParameter($,!0);M.at(m,ne);const b=n.MathUtils.lerp(y.z,x.z,m),P=b>=-1&&b<=1,D=$.distanceTo(ne)<L*.5;if(P&&D){M.start.fromBufferAttribute(c,v),M.end.fromBufferAttribute(u,v),M.start.applyMatrix4(l),M.end.applyMatrix4(l);const V=new n.Vector3,A=new n.Vector3;I.distanceSqToSegment(M.start,M.end,A,V),t.push({point:A,pointOnLine:V,distance:I.origin.distanceTo(A),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ce extends n.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,s=new Float32Array(2*t.count);for(let l=0,r=0,c=t.count;l<c;l++,r+=2)se.fromBufferAttribute(t,l),re.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+se.distanceTo(re);const a=new n.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;I=e.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;L=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),E.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=L*.5;else{const h=Math.max(s.near,E.distanceToPoint(I.origin));u=ae(s,h,c.resolution)}if(E.radius+=u,I.intersectsSphere(E)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(l);let p;if(i)p=L*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));p=ae(s,h,c.resolution)}R.expandByScalar(p),I.intersectsBox(R)!==!1&&(i?Se(this,t):je(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Z),this.material.uniforms.resolution.value.set(Z.z,Z.w))}}const oe=["encodings_fragment","colorspace_fragment"],De=`
|
|
5
5
|
#include <common>
|
|
6
6
|
#include <logdepthbuf_pars_vertex>
|
|
7
7
|
#include <fog_pars_vertex>
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
vHighPrecisionZW = finalPosition.zw;
|
|
95
95
|
#include <fog_vertex>
|
|
96
96
|
}
|
|
97
|
-
`,
|
|
97
|
+
`,Ve=`
|
|
98
98
|
#include <packing>
|
|
99
99
|
#include <fog_pars_fragment>
|
|
100
100
|
#include <logdepthbuf_pars_fragment>
|
|
@@ -144,6 +144,6 @@
|
|
|
144
144
|
|
|
145
145
|
#include <fog_fragment>
|
|
146
146
|
#include <tonemapping_fragment>
|
|
147
|
-
#include <${+
|
|
147
|
+
#include <${+n.REVISION<154?oe[0]:oe[1]}>
|
|
148
148
|
}
|
|
149
|
-
`;class
|
|
149
|
+
`;class ze extends n.ShaderMaterial{constructor(e){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:De,fragmentShader:Ve}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(t){this.uniforms.useDash.value=t}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(t){this.uniforms.useDepth.value=t}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(t){this.uniforms.repeat.value.copy(t)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(t){this.uniforms.lineLightAnimation.value=t}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(t){this.uniforms.size.value=t}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(t){this.uniforms.speed.value=t}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(t){this.uniforms.lightWidth.value=t}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(t){this.uniforms.uCenter.value=t}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(t){t&&(this.uniforms.lightColor.value=t)}}}),this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray=e.dashArray,this.dashOffset=e.dashOffset,this.dashRatio=e.dashRatio,this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}function Be(o,e){return o.map(t=>{const i=[];let s;return t.forEach(a=>{if(s){const l=k.geoDistance(a,s)*180/Math.PI;if(l>e){const r=k.geoInterpolate(s,a),c=1/Math.ceil(l/e);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function Ie(o,{minLng:e,maxLng:t,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=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,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,e,t=!1){return t?k.geoContains(e,o):Me(o,e)}function Te(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[a,l]]=k.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(l-s))<e)return[];const r=i>a||l>=89||s<=-89;return Ie(e,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>X(c,t,r))}function Le(o,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Be(o,e),a=W.merge(s),l=Te(o,e),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=we.geoVoronoi(r).triangles(),w=new Map(r.map(([S,j],T)=>[`${S}-${j}`,T]));g.features.forEach(S=>{const j=S.geometry.coordinates[0].slice(0,3).reverse(),T=[];if(j.forEach(([C,q])=>{const G=`${C}-${q}`;w.has(G)&&T.push(w.get(G))}),T.length===3){if(T.some(C=>C<a.length)){const C=S.properties.circumcenter;if(!X(C,c,f))return}d.push(...T)}})}else if(l.length){const g=xe.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]),T=j.map(C=>r[C]);if(j.some(C=>C<a.length)){const C=[0,1].map(q=>W.mean(T,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=t?[t[0],t[2]]:W.extent(r,g=>g[0]),b=t?[t[1],t[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=ie.scaleLinear(m,[0,1]),D=ie.scaleLinear(b,[0,1]),V=r.map(([g,w])=>{if(i){const[S,j]=i([g,w]);return[P(S),D(-j)]}else return[P(g),D(w)]});return{contour:s,triangles:{points:r,indices:d,uvs:V}}}const le=new n.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(o,e,t,i){const s=o.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,e]}return t?Q.polar2Cartesian(l,r,e):[l,r,e]}));return K.flatten(s)}function We(o,e,t,i,s){const{vertices:a,holes:l}=U(o,e,i,s),{vertices:r}=U(o,t,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 ce(o,e,t,i,s,a){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:U([o.points],e,s,a).vertices,uvs:t}}const he=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{o.forEach(P=>{ye(P)||P.reverse()});const{contour:p,triangles:h}=Le(o,{resolution:i,bbox:u,projection:c});let v={},f;a&&(v=We(p,e!=null?e:t,t!=null?t:e,s,c),f=v.topVerts);let d=[];(l||r)&&(d=W.merge(h.uvs));let m={};l&&(m=ce(h,e,d,!1,s,c));let b={};return r&&(b=ce(h,t,d,!0,s,c)),{contour:p,triangles:h,sideTorso:v,bottomCap:m,topCap:b,topVerts:f}};class _e extends n.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({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: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}=he(O({},this.parameters));let b=[],P=[],D=[],V=0;const A=g=>{const w=Math.round(b.length/3),S=D.length;b=b.concat(g.vertices),P=P.concat(g.uvs),D=D.concat(w?g.indices.map(j=>j+w):g.indices),this.addGroup(S,D.length-S,V++)};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(D),this[le]("position",new n.Float32BufferAttribute(b,3)),this[le]("uv",new n.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=ue;exports.Group=Ae;exports.LineSegments2=Ce;exports.MeshLineMaterial=ze;exports.PolygonGeometry=_e;exports.ResourceTracker=_;exports.getMetas=he;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BufferGeometry, Material } from 'three';
|
|
2
2
|
import BaseObject from "../../core/BaseObject";
|
|
3
3
|
import type { Options } from './createGeometry';
|
|
4
4
|
interface Parameters extends Omit<Options, 'coordinate'> {
|
|
5
|
-
geometry?:
|
|
6
|
-
material?:
|
|
5
|
+
geometry?: BufferGeometry;
|
|
6
|
+
material?: Material | Material[];
|
|
7
7
|
coordinate?: number[][];
|
|
8
8
|
coordinateArr?: number[][][];
|
|
9
9
|
useGroups?: 0 | 1 | 2;
|
|
@@ -37,12 +37,33 @@ export type ExtrudeGeometry = {
|
|
|
37
37
|
/**
|
|
38
38
|
* - A 3D spline path along which the shape should be extruded. Bevels not supported for path extrusion.
|
|
39
39
|
*/
|
|
40
|
-
extrudePath?:
|
|
40
|
+
extrudePath?: {
|
|
41
|
+
ArcCurve: typeof ArcCurve;
|
|
42
|
+
CatmullRomCurve3: typeof CatmullRomCurve3;
|
|
43
|
+
CubicBezierCurve: typeof CubicBezierCurve;
|
|
44
|
+
CubicBezierCurve3: typeof CubicBezierCurve3;
|
|
45
|
+
EllipseCurve: typeof EllipseCurve;
|
|
46
|
+
LineCurve: typeof LineCurve;
|
|
47
|
+
LineCurve3: typeof LineCurve3;
|
|
48
|
+
QuadraticBezierCurve: typeof QuadraticBezierCurve;
|
|
49
|
+
QuadraticBezierCurve3: typeof QuadraticBezierCurve3;
|
|
50
|
+
SplineCurve: typeof SplineCurve;
|
|
51
|
+
} | null | undefined;
|
|
41
52
|
/**
|
|
42
53
|
* - An object that provides UV generator functions for custom UV generation.
|
|
43
54
|
*/
|
|
44
55
|
UVGenerator?: Object | undefined;
|
|
45
56
|
};
|
|
57
|
+
import { ArcCurve } from 'three';
|
|
58
|
+
import { CatmullRomCurve3 } from 'three';
|
|
59
|
+
import { CubicBezierCurve } from 'three';
|
|
60
|
+
import { CubicBezierCurve3 } from 'three';
|
|
61
|
+
import { EllipseCurve } from 'three';
|
|
62
|
+
import { LineCurve } from 'three';
|
|
63
|
+
import { LineCurve3 } from 'three';
|
|
64
|
+
import { QuadraticBezierCurve } from 'three';
|
|
65
|
+
import { QuadraticBezierCurve3 } from 'three';
|
|
66
|
+
import { SplineCurve } from 'three';
|
|
46
67
|
/**
|
|
47
68
|
* Creates extruded geometry from a path shape.
|
|
48
69
|
*
|
|
@@ -64,7 +85,7 @@ export type ExtrudeGeometry = {
|
|
|
64
85
|
*
|
|
65
86
|
* @augments BufferGeometry
|
|
66
87
|
*/
|
|
67
|
-
export class ExtrudeGeometry extends BufferGeometry<
|
|
88
|
+
export class ExtrudeGeometry extends BufferGeometry<import("three").NormalBufferAttributes> {
|
|
68
89
|
/**
|
|
69
90
|
* Factory method for creating an instance of this class from the given
|
|
70
91
|
* JSON object.
|
|
@@ -93,6 +114,5 @@ export class ExtrudeGeometry extends BufferGeometry<Three.NormalBufferAttributes
|
|
|
93
114
|
copy(source: any): this;
|
|
94
115
|
toJSON(): any;
|
|
95
116
|
}
|
|
96
|
-
import * as Three from 'three';
|
|
97
117
|
import { BufferGeometry } from 'three';
|
|
98
118
|
import { Shape } from 'three';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Shape } from 'three';
|
|
2
2
|
import { ExtrudeGeometry } from './ExtrudeGeometry';
|
|
3
3
|
declare class ExtrudeGeometry2 extends ExtrudeGeometry {
|
|
4
|
-
constructor(shapes:
|
|
4
|
+
constructor(shapes: Shape, options: any);
|
|
5
5
|
}
|
|
6
6
|
export { ExtrudeGeometry2 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Vector2, Box3 } from 'three';
|
|
2
2
|
interface Options {
|
|
3
|
-
points:
|
|
3
|
+
points: Vector2[];
|
|
4
4
|
split?: number;
|
|
5
5
|
sideRepeat?: number;
|
|
6
6
|
depth: number;
|
|
7
|
-
box3?:
|
|
7
|
+
box3?: Box3;
|
|
8
8
|
hasTop?: boolean;
|
|
9
9
|
hasBottom?: boolean;
|
|
10
10
|
hasSide?: boolean;
|
|
@@ -18,59 +18,59 @@ declare const _default: (options: Options) => {
|
|
|
18
18
|
id: number;
|
|
19
19
|
uuid: string;
|
|
20
20
|
name: string;
|
|
21
|
-
index:
|
|
21
|
+
index: import("three").BufferAttribute | null;
|
|
22
22
|
indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
23
|
-
attributes:
|
|
24
|
-
morphAttributes: Record<"position" | "normal" | "color", Array<
|
|
23
|
+
attributes: import("three").NormalBufferAttributes;
|
|
24
|
+
morphAttributes: Record<"position" | "normal" | "color", Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute>>;
|
|
25
25
|
morphTargetsRelative: boolean;
|
|
26
|
-
groups:
|
|
27
|
-
boundingBox:
|
|
28
|
-
boundingSphere:
|
|
26
|
+
groups: import("three").GeometryGroup[];
|
|
27
|
+
boundingBox: Box3 | null;
|
|
28
|
+
boundingSphere: import("three").Sphere | null;
|
|
29
29
|
drawRange: {
|
|
30
30
|
start: number;
|
|
31
31
|
count: number;
|
|
32
32
|
};
|
|
33
33
|
userData: Record<string, any>;
|
|
34
34
|
readonly isBufferGeometry: true;
|
|
35
|
-
getIndex():
|
|
36
|
-
setIndex(index:
|
|
35
|
+
getIndex(): import("three").BufferAttribute | null;
|
|
36
|
+
setIndex(index: import("three").BufferAttribute | number[] | null): any;
|
|
37
37
|
setIndirect(indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null): any;
|
|
38
38
|
getIndirect(): import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
39
|
-
setAttribute<K extends string>(name: K, attribute:
|
|
40
|
-
getAttribute<K extends string>(name: K):
|
|
39
|
+
setAttribute<K extends string>(name: K, attribute: import("three").BufferAttribute | import("three").InterleavedBufferAttribute): any;
|
|
40
|
+
getAttribute<K extends string>(name: K): import("three").BufferAttribute | import("three").InterleavedBufferAttribute;
|
|
41
41
|
deleteAttribute(name: string): any;
|
|
42
42
|
hasAttribute(name: string): boolean;
|
|
43
43
|
addGroup(start: number, count: number, materialIndex?: number): void;
|
|
44
44
|
clearGroups(): void;
|
|
45
45
|
setDrawRange(start: number, count: number): void;
|
|
46
|
-
applyMatrix4(matrix:
|
|
47
|
-
applyQuaternion(quaternion:
|
|
46
|
+
applyMatrix4(matrix: import("three").Matrix4): any;
|
|
47
|
+
applyQuaternion(quaternion: import("three").Quaternion): any;
|
|
48
48
|
rotateX(angle: number): any;
|
|
49
49
|
rotateY(angle: number): any;
|
|
50
50
|
rotateZ(angle: number): any;
|
|
51
51
|
translate(x: number, y: number, z: number): any;
|
|
52
52
|
scale(x: number, y: number, z: number): any;
|
|
53
|
-
lookAt(vector:
|
|
53
|
+
lookAt(vector: import("three").Vector3): any;
|
|
54
54
|
center(): any;
|
|
55
|
-
setFromPoints(points:
|
|
55
|
+
setFromPoints(points: import("three").Vector3[] | Vector2[]): any;
|
|
56
56
|
computeBoundingBox(): void;
|
|
57
57
|
computeBoundingSphere(): void;
|
|
58
58
|
computeTangents(): void;
|
|
59
59
|
computeVertexNormals(): void;
|
|
60
60
|
normalizeNormals(): void;
|
|
61
|
-
toNonIndexed():
|
|
61
|
+
toNonIndexed(): import("three").BufferGeometry;
|
|
62
62
|
clone(): any;
|
|
63
63
|
dispose(): void;
|
|
64
|
-
addEventListener<T extends "dispose">(type: T, listener:
|
|
64
|
+
addEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<{
|
|
65
65
|
dispose: {};
|
|
66
66
|
}[T], T, any>): void;
|
|
67
|
-
hasEventListener<T extends "dispose">(type: T, listener:
|
|
67
|
+
hasEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<{
|
|
68
68
|
dispose: {};
|
|
69
69
|
}[T], T, any>): boolean;
|
|
70
|
-
removeEventListener<T extends "dispose">(type: T, listener:
|
|
70
|
+
removeEventListener<T extends "dispose">(type: T, listener: import("three").EventListener<{
|
|
71
71
|
dispose: {};
|
|
72
72
|
}[T], T, any>): void;
|
|
73
|
-
dispatchEvent<T extends "dispose">(event:
|
|
73
|
+
dispatchEvent<T extends "dispose">(event: import("three").BaseEvent<T> & {
|
|
74
74
|
dispose: {};
|
|
75
75
|
}[T]): void;
|
|
76
76
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CanvasTexture } from 'three';
|
|
2
2
|
interface SplitTextureOptions {
|
|
3
3
|
topColor?: string;
|
|
4
4
|
sideColor?: string;
|
|
@@ -8,5 +8,5 @@ interface SplitTextureOptions {
|
|
|
8
8
|
maxAnisotropy?: number;
|
|
9
9
|
cacheKey?: string;
|
|
10
10
|
}
|
|
11
|
-
declare const _default: (splitTextureOptions: SplitTextureOptions) => Promise<
|
|
11
|
+
declare const _default: (splitTextureOptions: SplitTextureOptions) => Promise<CanvasTexture>;
|
|
12
12
|
export default _default;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BufferGeometry, Material, Vector2, Box3, Texture } from 'three';
|
|
2
2
|
import BaseObject from "../../core/BaseObject";
|
|
3
3
|
export interface Options {
|
|
4
|
-
points?:
|
|
5
|
-
pointsArr?:
|
|
6
|
-
material:
|
|
7
|
-
geometry?:
|
|
8
|
-
geometryArr?:
|
|
4
|
+
points?: Vector2[];
|
|
5
|
+
pointsArr?: Vector2[][];
|
|
6
|
+
material: Material | Material[];
|
|
7
|
+
geometry?: BufferGeometry;
|
|
8
|
+
geometryArr?: BufferGeometry[];
|
|
9
9
|
depth?: number | number[];
|
|
10
10
|
useGroups?: 0 | 1 | 2;
|
|
11
11
|
split?: number;
|
|
12
|
-
box3?:
|
|
12
|
+
box3?: Box3 | Box3[];
|
|
13
13
|
hasTop?: boolean;
|
|
14
14
|
hasBottom?: boolean;
|
|
15
15
|
hasSide?: boolean;
|
|
@@ -20,6 +20,6 @@ export default class extends BaseObject {
|
|
|
20
20
|
};
|
|
21
21
|
constructor(options: Options);
|
|
22
22
|
create(): Promise<void>;
|
|
23
|
-
addGeometries(geometries:
|
|
24
|
-
setTextureAnisotropic(texture:
|
|
23
|
+
addGeometries(geometries: BufferGeometry[]): void;
|
|
24
|
+
setTextureAnisotropic(texture: Texture, maxAnisotropy?: number): void;
|
|
25
25
|
}
|
package/dist/objects/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { default as Light } from './light';
|
|
|
5
5
|
export { default as Line2 } from './line2';
|
|
6
6
|
export { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry';
|
|
7
7
|
export { LineMaterial as Line2Material } from 'three/examples/jsm/lines/LineMaterial';
|
|
8
|
-
export { MeshLineGeometry, MeshLineMaterial
|
|
8
|
+
export { MeshLineGeometry, MeshLineMaterial } from './line/meshLine';
|
|
9
9
|
export { default as Line } from './line';
|
|
10
10
|
export { default as ConicPolygon } from './conicPolygon';
|
|
11
11
|
export { default as getConicPolygonGeometry, getMetas as getConicPolygonGeometryMetas, } from './conicPolygon/geometry';
|
package/dist/objects/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var $t=Object.defineProperty,Jt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var ht=Object.getOwnPropertySymbols;var Pt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var Gt=(r,t,e)=>t in r?$t(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P=(r,t)=>{for(var e in t||(t={}))Pt.call(t,e)&&Gt(r,e,t[e]);if(ht)for(var e of ht(t))Bt.call(t,e)&&Gt(r,e,t[e]);return r},lt=(r,t)=>Jt(r,Xt(t));var pt=(r,t)=>{var e={};for(var s in r)Pt.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ht)for(var s of ht(r))t.indexOf(s)<0&&Bt.call(r,s)&&(e[s]=r[s]);return e};var nt=(r,t,e)=>new Promise((s,i)=>{var n=c=>{try{l(e.next(c))}catch(b){i(b)}},a=c=>{try{l(e.throw(c))}catch(b){i(b)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,a);l((e=e.apply(r,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("../index2.js"),L=require("three"),Yt=require("@tweenjs/tween.js"),Zt=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),mt=require("three/examples/jsm/utils/BufferGeometryUtils"),Qt=require("three/examples/jsm/lines/LineSegments2"),Dt=require("three/examples/jsm/lines/LineSegmentsGeometry"),Ht=require("three/examples/jsm/lines/LineMaterial"),Ut=require("../uvGenerator.js"),ut=require("three-bvh-csg");function zt(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const x=zt(L),tt=zt(Yt);class Kt extends B.BaseObject{constructor(t){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=P({type:"2d"},t)}create(){const{position:t,children:e}=this.options,s=document.createElement("div");this.element=s,e&&s.appendChild(e),this.options.type==="3d"?this.createCSS3DObject(s):this.options.type==="3dSprite"?this.createCSS3DSprite(s):this.createCSS2DObject(s),t&&this.object3d.position.copy(t)}setChildren(t){this.options.children=t,this.element.innerHTML="",this.element.appendChild(t)}showAndEnsureVisible(){const t=this.options.children;t&&(t.style.visibility="hidden",this.show(),setTimeout(()=>{t.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const t=this.options.children;if(!t)return;const e=t.getBoundingClientRect(),s=window.innerWidth,i=window.innerHeight;let n=0,a=0;e.left<0?n=-e.left:e.right>s&&(n=s-e.right),e.top<0?a=-e.top:e.bottom>i&&(a=i-e.bottom),e.left+n<0&&(n=-e.left),e.top+a<0&&(a=-e.top),(n!==0||a!==0)&&(t.style.transform=`translate(${n}px, ${a}px)`)}ensureVisible(){const t=this.options.children;if(!t)return;t.style.transform&&(t.style.transform="");const e=new IntersectionObserver(s=>{s.forEach(i=>{i.isIntersecting&&(this.moveElementToViewport(),e.disconnect())})});e.observe(t)}onPointerEvent(t,e){const s=this.lead.handlePickNode([this],t,e);this.onNodePointerIndex.push(s)}dispose(){this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}}class te extends B.BaseObject{constructor(t){super(),this.options=P({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},t)}create(){return nt(this,null,function*(){this.createGroup();const{data:t,maxDepth:e,colors:s,material:i,percentDepth:n,activeIndex:a}=this.options,l=Math.max(...t),c=t.reduce((o,u)=>o+u,0);let b=Math.PI/2;t.forEach((o,u)=>{if(o===0)return;const y=Math.PI*2*(o/c),f=s[u],w=n?e*(o/l):e,T=this.createGeometry(w,y),S=i?i.clone():new x.MeshBasicMaterial({color:f});i&&S.color.set(f);const _=new x.Mesh(T,S);_.userData.depth=w,_.userData.index=u,_.rotateZ(b),b+=y,this.add(_)}),a!==-1&&this.setActive(a)})}createGeometry(t,e){const{outRadius:s,innerRadius:i}=this.options,n=new x.Shape;return n.moveTo(s,0),n.lineTo(i,0),n.absarc(0,0,i,0,e,!1),n.absarc(0,0,s,e,0,!0),new x.ExtrudeGeometry(n,{curveSegments:48,depth:t,bevelEnabled:!1})}handlePick(t,e=1.3){const{object:s}=this.pencil.pick(t,this.object3d.children)||{},i=s?this.object3d.children.findIndex(n=>n===s):this.options.activeIndex;return this.setActive(i,e)}setActive(t,e=1.3){const s=this.object3d.children[t];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 n=new tt.Tween(i.scale).to({z:1},100);i.userData.levTween=n,n.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new tt.Tween(s.scale).to({z:e},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new tt.Tween(this.object3d.scale).to({z:1},1e3).easing(tt.Easing.Sinusoidal.InOut).start()}}class ee extends B.BaseObject{constructor(t){super(),this.rectAreaLightUniformsLibInit=!1,this.options=t}create(){var e,s,i,n,a,l,c,b,o,u,y,f,w,T,S,_,G;const t=this.options;if(t.type==="AmbientLight"){const A=new x.AmbientLight(t.color);A.name="环境光",this.object3d=A}else if(t.type==="DirectionalLight"){const A=new x.DirectionalLight(t.color,t.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(t.type==="PointLight"){const A=new x.PointLight((e=t.color)!=null?e:16777215,(s=t.intensity)!=null?s:1,(i=t.distance)!=null?i:0,(n=t.decay)!=null?n:2);A.name="点光源",this.object3d=A,this.pointLight=A}else if(t.type==="SpotLight"){const A=new x.SpotLight((a=t.color)!=null?a:16777215,(l=t.intensity)!=null?l:1,(c=t.distance)!=null?c:0,(b=t.angle)!=null?b:Math.PI/3,(o=t.penumbra)!=null?o:1,(u=t.decay)!=null?u:2);A.name="聚光灯",this.object3d=A,this.spotLight=A,A.target.name="聚光灯目标"}else if(t.type==="HemisphereLight"){const A=new x.HemisphereLight((y=t.color)!=null?y:16777215,(f=t.groundColor)!=null?f:16777215,(w=t.intensity)!=null?w:1);A.name="半球光",this.object3d=A,this.hemisphereLight=A}else if(t.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Zt.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const A=new x.RectAreaLight((T=t.color)!=null?T:16777215,(S=t.intensity)!=null?S:1,(_=t.width)!=null?_:10,(G=t.height)!=null?G:10);A.name="矩形区域光",this.object3d=A,this.rectAreaLight=A}}render(){const t=this.object3d;t.target&&this.pencil.scene.add(t.target);const e=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const s=this.spotLight||this.directionalLight;s.position.copy(e),s.target.position.copy(e)}else this.pointLight&&this.pointLight.position.copy(e)}dispose(){const t=this.object3d;t.target&&this.pencil.scene.remove(t.target),super.dispose()}}function C(r,t=0){const e=r[0].index!==null,s=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),n={},a={},l=r[0].morphTargetsRelative,c=new L.BufferGeometry;let b=0;for(let o=0;o<r.length;++o){const u=r[o];let y=0;if(e!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;n[f]===void 0&&(n[f]=[]),n[f].push(u.attributes[f]),y++}if(y!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". Make sure all geometries have the same number of attributes."),null;if(l!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+o+". .morphAttributes must be consistent throughout all geometries."),null;a[f]===void 0&&(a[f]=[]),a[f].push(u.morphAttributes[f])}if(t){let f;if(e)f=u.index.count;else if(u.attributes.position!==void 0)f=u.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(t===1)c.addGroup(b,f,o);else if(t===2&&u.groups.length>0)for(let w of u.groups){let T=w.materialIndex;c.addGroup(b+w.start,Math.min(w.count,f),T)}b+=f}}if(e){let o=0;const u=[];for(let y=0;y<r.length;++y){const f=r[y].index;for(let w=0;w<f.count;++w)u.push(f.getX(w)+o);o+=r[y].attributes.position.count}c.setIndex(u)}for(const o in n){const u=mt.mergeAttributes(n[o]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" attribute."),null;c.setAttribute(o,u)}for(const o in a){const u=a[o][0].length;if(u===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[o]=[];for(let y=0;y<u;++y){const f=[];for(let T=0;T<a[o].length;++T)f.push(a[o][T][y]);const w=mt.mergeAttributes(f);if(!w)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+o+" morphAttribute."),null;c.morphAttributes[o].push(w)}}return t===2?mt.mergeGroups(c):c}const Ot=r=>{const{points:t}=r,e=t.reduce((i,n,a)=>(a<t.length-1&&i.push(n,t[a+1]),i),[]);return new x.BufferGeometry().setFromPoints(e)};let se=class extends B.BaseObject{constructor(t={}){super(),this.options=P({},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return nt(this,null,function*(){const{points:t,pointsArr:e,geometry:s,geometryArr:i,material:n,useGroups:a,setPointWidth:l,lineWidthArr:c,materialParameters:b,instanceCount:o}=this.options;let u=n,y=s;!u&&b&&(u=this.getMaterial(b)),!y&&t?y=Ot({points:t}):!y&&e?y=C(e.map(w=>Ot({points:w})),a!=null?a:0):!y&&i&&i.length>1?y=C(i,a!=null?a:0):!y&&i&&i.length===1&&([y]=i);const f=new Dt.LineSegmentsGeometry().fromLineSegments(new x.LineSegments(y));if(this.pencil.options.WebGPUTHREE){o&&(f.instanceCount=o);const w=new B.LineSegments2(f,u);w.computeLineDistances(),this.object3d=w}else{const w=new Qt.LineSegments2(f,u);w.computeLineDistances(),this.object3d=w}})}getMaterial(t){return new Ht.LineMaterial(P({color:new x.Color("#ffffff")},t))}};function gt(r,t,e,s,i){let n;if(r=r.subarray||r.slice?r:r.buffer,e=e.subarray||e.slice?e:e.buffer,r=t?r.subarray?r.subarray(t,i&&t+i):r.slice(t,i&&t+i):r,e.set)e.set(r,s);else for(n=0;n<r.length;n++)e[n+s]=r[n];return e}function ie(r){return r instanceof Float32Array?r:r instanceof x.BufferGeometry?r.getAttribute("position").array:r.map(t=>{const e=Array.isArray(t);return t instanceof x.Vector3?[t.x,t.y,t.z]:t instanceof x.Vector2?[t.x,t.y,0]:e&&t.length===3?[t[0],t[1],t[2]]:e&&t.length===2?[t[0],t[1],0]:t}).flat()}class Ct extends x.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 x.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(t){this.setPoints(t,this.widthCallback)}}})}setMatrixWorld(t){this.matrixWorld=t}setPoints(t,e){if(t=ie(t),this._points=t,this.widthCallback=e!=null?e:null,this.positions=[],this.counters=[],t.length&&t[0]instanceof x.Vector3)for(let s=0;s<t.length;s++){const i=t[s],n=s/(t.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(n),this.counters.push(n)}else for(let s=0;s<t.length;s+=3){const i=s/(t.length-1);this.positions.push(t[s],t[s+1],t[s+2]),this.positions.push(t[s],t[s+1],t[s+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(t,e){const s=t*6,i=e*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(t){const e=t*6;return[this.positions[e],this.positions[e+1],this.positions[e+2]]}process(){const t=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let e,s;this.compareV3(0,t-1)?s=this.copyV3(t-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<t;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?e=this.widthCallback(i/(t-1)):e=1,this.width.push(e),this.width.push(e),this.uvs.push(i/(t-1),0),this.uvs.push(i/(t-1),1),i<t-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const n=i*2;this.indices_array.push(n,n+1,n+2),this.indices_array.push(n+2,n+1,n+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(t-1,0)?s=this.copyV3(1):s=this.copyV3(t-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 x.BufferAttribute(new Float32Array(this.positions),3),previous:new x.BufferAttribute(new Float32Array(this.previous),3),next:new x.BufferAttribute(new Float32Array(this.next),3),side:new x.BufferAttribute(new Float32Array(this.side),1),width:new x.BufferAttribute(new Float32Array(this.width),1),uv:new x.BufferAttribute(new Float32Array(this.uvs),2),index:new x.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new x.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:t,y:e,z:s}){const i=this._attributes.position.array,n=this._attributes.previous.array,a=this._attributes.next.array,l=i.length;gt(i,0,n,0,l),gt(i,6,i,0,l-6),i[l-6]=t,i[l-5]=e,i[l-4]=s,i[l-3]=t,i[l-2]=e,i[l-1]=s,gt(i,6,a,0,l-6),a[l-6]=t,a[l-5]=e,a[l-4]=s,a[l-3]=t,a[l-2]=e,a[l-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function ne(r,t){const e=new x.Matrix4,s=new x.Ray,i=new x.Sphere,n=new x.Vector3,a=this.geometry;if(i.copy(a.boundingSphere),i.applyMatrix4(this.matrixWorld),!r.ray.intersectSphere(i,n))return;e.copy(this.matrixWorld).invert(),s.copy(r.ray).applyMatrix4(e);const l=new x.Vector3,c=new x.Vector3,b=new x.Vector3,o=this instanceof x.LineSegments?2:1,u=a.index,y=a.attributes;if(u!==null){const f=u.array,w=y.position.array,T=y.width.array;for(let S=0,_=f.length-1;S<_;S+=o){const G=f[S],A=f[S+1];l.fromArray(w,G*3),c.fromArray(w,A*3);const U=T[Math.floor(S/3)]!=null?T[Math.floor(S/3)]:1,Q=r.params.Line.threshold+this.material.lineWidth*U/2,N=Q*Q;if(s.distanceSqToSegment(l,c,n,b)>N)continue;n.applyMatrix4(this.matrixWorld);const H=r.ray.origin.distanceTo(n);H<r.near||H>r.far||(t.push({distance:H,point:b.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:void 0,object:this}),S=_)}}}const yt=r=>{const{setPointWidth:t,nodes:e}=r,s=new Ct;return s.setPoints(e,t),s};class re extends B.BaseObject{constructor(t={}){super(),this.options=P({},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return nt(this,null,function*(){const{nodes:t,nodesArr:e,geometry:s,geometryArr:i,material:n,useGroups:a,setPointWidth:l,lineWidthArr:c,materialParameters:b}=this.options;let o=n,u=s;!o&&b&&(o=this.getMaterial(b)),!u&&t?u=yt({nodes:t,setPointWidth:l}):!u&&e?u=C(e.map((y,f)=>{let w=l;return!w&&c&&(w=()=>{var T;return(T=c[f])!=null?T:c[0]}),yt({nodes:y,setPointWidth:w})}),a!=null?a:0):!u&&i&&i.length>1?u=C(i,a!=null?a:0):!u&&i&&i.length===1&&([u]=i),this.createMesh(u,o)})}setGeometry(t,e){const s=yt({nodes:t,setPointWidth:e}),i=this.object3d,n=i.geometry;i.geometry=s,n.dispose()}getMaterial(t){const{width:e,height:s}=this.pencil.getSize();return new B.MeshLineMaterial(P({color:new x.Color("#ffffff"),resolution:new x.Vector2(e,s)},t))}addGeometries(t){const e=this.object3d,s=C([e.geometry,...t]);e.geometry=s}resize(t,e){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(t,e)}useMaterial(t){super.useMaterial(t);const{width:e,height:s}=this.pencil.getSize();this.resize(e,s)}animate({duration:t=1e3,delay:e=0,repeat:s=0,lineLoop:i,onRepeat:n,onUpdate:a,onComplete:l,startShow:c}={}){const{offset:b,offsetLoop:o}=this.material.uniforms;if(this.material.userData.tween)return;const u=i!=null?i:!0;b.value.x=1,o.value=u&&c?1:0;let y=0;const f=new tt.Tween(b.value).to({x:-1},t).delay(e).repeat(s).onUpdate(({x:w})=>{u&&w<=0&&o.value===0&&(o.value=1),a&&a(w)}).onRepeat(()=>{y+=1,n&&n(y)}).onComplete(()=>{l&&l()}).start();this.material.userData.tween=f}render(){const{width:t,height:e}=this.pencil.getSize();this.resize(t,e)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),tt.remove(this.material.userData.tween)),super.dispose()}}const It=r=>{const l=r,{coordinate:t,startHeight:e,height:s}=l,i=pt(l,["coordinate","startHeight","height"]);let n=e||0;return typeof e!="undefined"&&typeof s!="undefined"&&(n=e+s),new B.PolygonGeometry([t],lt(P({},i),{startHeight:e,endHeight:n}))};class oe extends B.BaseObject{constructor(t){super(),this.options=P({},t)}create(){const c=this.options,{geometry:t,coordinateArr:e,coordinate:s,material:i,useGroups:n}=c,a=pt(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let l=t;if(!l&&s)l=It(P({coordinate:s},a));else if(!l&&e){const b=e.map(o=>It(P({coordinate:o},a)));l=C(b,n!=null?n:0)}this.createMesh(l,i)}}class et extends L.BufferGeometry{constructor(t=new L.Shape([new L.Vector2(.5,.5),new L.Vector2(-.5,.5),new L.Vector2(-.5,-.5),new L.Vector2(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const s=this,i=[],n=[];for(let l=0,c=t.length;l<c;l++){const b=t[l];a(b)}this.setAttribute("position",new L.Float32BufferAttribute(i,3)),this.setAttribute("uv",new L.Float32BufferAttribute(n,2)),this.computeVertexNormals();function a(l){var St,_t,Mt;const c=[],b=e.curveSegments!==void 0?e.curveSegments:12,o=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1;let y=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,w=e.bevelSize!==void 0?e.bevelSize:f-.1,T=e.bevelOffset!==void 0?e.bevelOffset:0,S=e.bevelSegments!==void 0?e.bevelSegments:3;const _=e.extrudePath,G=e.UVGenerator!==void 0?e.UVGenerator:ae,A=(St=e.hasTop)!=null?St:!0,U=(_t=e.hasBottom)!=null?_t:!0,Q=(Mt=e.hasSide)!=null?Mt:!0;let N,X=!1,H,st,it,W;_&&(N=_.getSpacedPoints(o),X=!0,y=!1,H=_.computeFrenetFrames(o,!1),st=new L.Vector3,it=new L.Vector3,W=new L.Vector3),y||(S=0,f=0,w=0,T=0);const bt=l.extractPoints(b);let D=bt.shape;const O=bt.holes;if(!L.ShapeUtils.isClockWise(D)){D=D.reverse();for(let h=0,d=O.length;h<d;h++){const p=O[h];L.ShapeUtils.isClockWise(p)&&(O[h]=p.reverse())}}function wt(h){const p=10000000000000001e-36;let g=h[0];for(let m=1;m<=h.length;m++){const M=m%h.length,v=h[M],V=v.x-g.x,E=v.y-g.y,j=V*V+E*E,I=Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(g.x),Math.abs(g.y)),Z=p*I*I;if(j<=Z){h.splice(M,1),m--;continue}g=v}}wt(D),O.forEach(wt);const dt=O.length,z=D;for(let h=0;h<dt;h++){const d=O[h];D=D.concat(d)}function K(h,d,p){return d||console.error("THREE.ExtrudeGeometry: vec does not exist"),h.clone().addScaledVector(d,p)}const k=D.length;function xt(h,d,p){let g,m,M;const v=h.x-d.x,V=h.y-d.y,E=p.x-h.x,j=p.y-h.y,I=v*v+V*V,Z=v*j-V*E;if(Math.abs(Z)>Number.EPSILON){const R=Math.sqrt(I),Lt=Math.sqrt(E*E+j*j),Tt=d.x-V/R,Vt=d.y+v/R,qt=p.x-j/Lt,Ft=p.y+E/Lt,Et=((qt-Tt)*j-(Ft-Vt)*E)/(v*j-V*E);g=Tt+v*Et-h.x,m=Vt+V*Et-h.y;const jt=g*g+m*m;if(jt<=2)return new L.Vector2(g,m);M=Math.sqrt(jt/2)}else{let R=!1;v>Number.EPSILON?E>Number.EPSILON&&(R=!0):v<-Number.EPSILON?E<-Number.EPSILON&&(R=!0):Math.sign(V)===Math.sign(j)&&(R=!0),R?(g=-V,m=v,M=Math.sqrt(I)):(g=v,m=V,M=Math.sqrt(I/2))}return new L.Vector2(g/M,m/M)}const rt=[];for(let h=0,d=z.length,p=d-1,g=h+1;h<d;h++,p++,g++)p===d&&(p=0),g===d&&(g=0),rt[h]=xt(z[h],z[p],z[g]);const ft=[];let J,ot=rt.concat();for(let h=0,d=dt;h<d;h++){const p=O[h];J=[];for(let g=0,m=p.length,M=m-1,v=g+1;g<m;g++,M++,v++)M===m&&(M=0),v===m&&(v=0),J[g]=xt(p[g],p[M],p[v]);ft.push(J),ot=ot.concat(J)}let Y;if(S===0)Y=L.ShapeUtils.triangulateShape(z,O);else{const h=[],d=[];for(let p=0;p<S;p++){const g=p/S,m=f*Math.cos(g*Math.PI/2),M=w*Math.sin(g*Math.PI/2)+T;for(let v=0,V=z.length;v<V;v++){const E=K(z[v],rt[v],M);q(E.x,E.y,-m),g===0&&h.push(E)}for(let v=0,V=dt;v<V;v++){const E=O[v];J=ft[v];const j=[];for(let I=0,Z=E.length;I<Z;I++){const R=K(E[I],J[I],M);q(R.x,R.y,-m),g===0&&j.push(R)}g===0&&d.push(j)}}Y=L.ShapeUtils.triangulateShape(h,d)}const at=Y.length,vt=w+T;for(let h=0;h<k;h++){const d=y?K(D[h],ot[h],vt):D[h];X?(it.copy(H.normals[0]).multiplyScalar(d.x),st.copy(H.binormals[0]).multiplyScalar(d.y),W.copy(N[0]).add(it).add(st),q(W.x,W.y,W.z)):q(d.x,d.y,0)}for(let h=1;h<=o;h++)for(let d=0;d<k;d++){const p=y?K(D[d],ot[d],vt):D[d];X?(it.copy(H.normals[h]).multiplyScalar(p.x),st.copy(H.binormals[h]).multiplyScalar(p.y),W.copy(N[h]).add(it).add(st),q(W.x,W.y,W.z)):q(p.x,p.y,u/o*h)}for(let h=S-1;h>=0;h--){const d=h/S,p=f*Math.cos(d*Math.PI/2),g=w*Math.sin(d*Math.PI/2)+T;for(let m=0,M=z.length;m<M;m++){const v=K(z[m],rt[m],g);q(v.x,v.y,u+p)}for(let m=0,M=O.length;m<M;m++){const v=O[m];J=ft[m];for(let V=0,E=v.length;V<E;V++){const j=K(v[V],J[V],g);X?q(j.x,j.y+N[o-1].y,N[o-1].x+p):q(j.x,j.y,u+p)}}}Nt(),Q&&Wt();function Nt(){const h=i.length/3;if(y){let d=0,p=k*d;if(U)for(let g=0;g<at;g++){const m=Y[g];ct(m[2]+p,m[1]+p,m[0]+p)}if(d=o+S*2,p=k*d,A)for(let g=0;g<at;g++){const m=Y[g];ct(m[0]+p,m[1]+p,m[2]+p)}}else{if(U)for(let d=0;d<at;d++){const p=Y[d];ct(p[2],p[1],p[0])}if(A)for(let d=0;d<at;d++){const p=Y[d];ct(p[0]+k*o,p[1]+k*o,p[2]+k*o)}}s.addGroup(h,i.length/3-h,0)}function Wt(){const h=i.length/3;let d=0;At(z,d),d+=z.length;for(let p=0,g=O.length;p<g;p++){const m=O[p];At(m,d),d+=m.length}s.addGroup(h,i.length/3-h,1)}function At(h,d){let p=h.length;for(;--p>=0;){const g=p;let m=p-1;m<0&&(m=h.length-1);for(let M=0,v=o+S*2;M<v;M++){const V=k*M,E=k*(M+1),j=d+g+V,I=d+m+V,Z=d+m+E,R=d+g+E;kt(j,I,Z,R)}}}function q(h,d,p){c.push(h),c.push(d),c.push(p)}function ct(h,d,p){F(h),F(d),F(p);const g=i.length/3,m=G.generateTopUV(s,i,g-3,g-2,g-1);$(m[0]),$(m[1]),$(m[2])}function kt(h,d,p,g){F(h),F(d),F(g),F(d),F(p),F(g);const m=i.length/3,M=G.generateSideWallUV(s,i,m-6,m-3,m-2,m-1);$(M[0]),$(M[1]),$(M[3]),$(M[1]),$(M[2]),$(M[3])}function F(h){i.push(c[h*3+0]),i.push(c[h*3+1]),i.push(c[h*3+2])}function $(h){n.push(h.x),n.push(h.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,s=this.parameters.options;return ce(e,s,t)}static fromJSON(t,e){const s=[];for(let n=0,a=t.shapes.length;n<a;n++){const l=e[t.shapes[n]];s.push(l)}const i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new x[`${i.type}Curve`]().fromJSON(i)),new et(s,t.options)}}const ae={generateTopUV:function(r,t,e,s,i){const n=t[e*3],a=t[e*3+1],l=t[s*3],c=t[s*3+1],b=t[i*3],o=t[i*3+1];return[new L.Vector2(n,a),new L.Vector2(l,c),new L.Vector2(b,o)]},generateSideWallUV:function(r,t,e,s,i,n){const a=t[e*3],l=t[e*3+1],c=t[e*3+2],b=t[s*3],o=t[s*3+1],u=t[s*3+2],y=t[i*3],f=t[i*3+1],w=t[i*3+2],T=t[n*3],S=t[n*3+1],_=t[n*3+2];return Math.abs(l-o)<Math.abs(a-b)?[new L.Vector2(a,1-c),new L.Vector2(b,1-u),new L.Vector2(y,1-w),new L.Vector2(T,1-_)]:[new L.Vector2(l,1-c),new L.Vector2(o,1-u),new L.Vector2(f,1-w),new L.Vector2(S,1-_)]}};function ce(r,t,e){if(e.shapes=[],Array.isArray(r))for(let s=0,i=r.length;s<i;s++){const n=r[s];e.shapes.push(n.uuid)}else e.shapes.push(r.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class he extends et{constructor(t,e){super(t,e);const s=new ut.Brush(new et(t,lt(P({},e),{hasTop:!0,hasSide:!0,hasBottom:!1})));s.updateMatrixWorld();const i=new x.Box3().setFromObject(s),n=new x.Vector3;i.getSize(n);const a=new x.Vector3(i.min.x+n.x/2,i.min.y+n.y/2,0);let l=e.topSegments,c=e.box3;if(c){c=c.union(i);const _=new x.Vector3;c.getSize(_);const G=Math.max(n.x/_.x,n.y/_.y);l=Math.ceil(e.topSegments*G)}if(l<4)return this;const b=new x.PlaneGeometry(n.x,n.y,l,l),o=new ut.Brush(b);o.position.set(a.x,a.y,a.z),o.updateMatrixWorld();const y=new ut.Evaluator().evaluate(o,s,ut.INTERSECTION),f=y.geometry.getAttribute("position"),w=new x.Float32BufferAttribute(f.count*2,2);for(let _=0;_<f.count;_++){const G=f.getZ(_);f.setZ(_,e.depth+G)}if(c){const _=c.min,G=c.max,A=new x.Vector3().subVectors(G,_);for(let U=0;U<f.count;U++){const Q=f.getX(U),N=f.getY(U),X=(Q-_.x)/A.x,H=(N-_.y)/A.y;w.setXY(U,X,H)}y.geometry.setAttribute("uv",w)}f.needsUpdate=!0;const T=new et(t,lt(P({},e),{hasTop:!1})),S=C([y.geometry,T],2);this.copy(S.toNonIndexed())}}const Rt=r=>{const{split:t,depth:e,points:s,box3:i,hasTop:n,hasBottom:a,hasSide:l,sideRepeat:c,topSegments:b}=r,o=b?he:et,u=new o(new x.Shape(s),{depth:e,bevelEnabled:!1,box3:i,UVGenerator:Ut.getUVGenerator({split:t,box3:i,sideRepeat:c}),hasTop:n,hasBottom:a,hasSide:l,topSegments:b});return Ut.claerUVGenerator(),u};class le extends B.BaseObject{constructor(t){super(),this.options=P({depth:1},t)}create(){return nt(this,null,function*(){const{points:t,pointsArr:e,useGroups:s,depth:i,geometry:n,geometryArr:a,material:l,box3:c,split:b,hasTop:o,hasBottom:u,hasSide:y}=this.options,f=Array.isArray(i)?i:[i],w=Array.isArray(c)?c:[c],T=l;let S=n;T||console.log("material is null"),!S&&t?S=Rt({points:t,depth:f[0],box3:w[0],split:b,hasTop:o,hasBottom:u,hasSide:y}):!S&&e?S=C(e.map((_,G)=>{var A,U;return Rt({points:_,depth:(A=f[G])!=null?A:f[0],box3:(U=w[G])!=null?U:w[0],split:b,hasTop:o,hasBottom:u,hasSide:y})}),s!=null?s:0):!S&&a&&a.length>1?S=C(a,s!=null?s:0):!S&&a&&a.length===1&&([S]=a),this.createMesh(S,T)})}addGeometries(t){const e=this.object3d,s=C([e.geometry,...t]);e.geometry=s}setTextureAnisotropic(t,e){t.anisotropy=e||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const ue=r=>{const{topColor:t,sideColor:e,sideMap:s,createCanvasObjectURL:i,split:n,maxAnisotropy:a}=r;return new Promise(l=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const b=n,o=document.createElement("canvas"),u=o.getContext("2d");o.height=c.height/(1-b),o.width=c.width,b&&t&&(u.fillStyle=t,u.fillRect(0,0,c.width,o.height*b)),s&&c instanceof HTMLImageElement?u.drawImage(c,0,o.height*b,c.width,c.height):e&&(u.fillStyle=e,u.fillRect(0,o.height*b,c.width,c.height)),i&&o.toBlob(f=>{console.log(URL.createObjectURL(f))});const y=new x.CanvasTexture(o);l(y)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=B.Group;exports.MeshLineMaterial=B.MeshLineMaterial;exports.getConicPolygonGeometry=B.PolygonGeometry;exports.getConicPolygonGeometryMetas=B.getMetas;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Dt.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>Ht.LineMaterial});exports.ConicPolygon=oe;exports.ExtrudePolygon=le;exports.Light=ee;exports.Line=re;exports.Line2=se;exports.MeshLineGeometry=Ct;exports.MeshLineRaycast=ne;exports.Node=Kt;exports.Pie=te;exports.getSplitTexture=ue;
|
|
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;
|