gl-draw 0.15.0-beta.8 → 0.15.0
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 +4 -3
- package/dist/core/Lead/Lead.d.ts +7 -6
- package/dist/core/Lead/Pick.d.ts +0 -1
- package/dist/core/MList/MList.d.ts +4 -3
- package/dist/core/Pencil.d.ts +4 -0
- package/dist/core/Renderer.d.ts +0 -1
- package/dist/core/ResourceTracker.d.ts +4 -6
- package/dist/index.js +3 -3
- package/dist/index.module.js +878 -812
- package/dist/index.module2.js +242 -238
- package/dist/index2.js +6 -6
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +63 -58
- package/package.json +1 -1
- package/dist/objects/scene/index.d.ts +0 -11
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=(a,e,t)=>e in a?fe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,W=(a,e)=>{for(var t in e||(e={}))me.call(e,t)&&H(a,t,e[t]);if(Y)for(var t of Y(e))ve.call(e,t)&&H(a,t,e[t]);return a},q=(a,e)=>de(a,pe(e));var ee=(a,e,t)=>new Promise((i,s)=>{var o=l=>{try{n(t.next(l))}catch(u){s(u)}},c=l=>{try{n(t.throw(l))}catch(u){s(u)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,c);n((t=t.apply(a,e)).next())});const r=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const $=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),_=require("d3-array"),Q=require("earcut"),ye=require("@turf/boolean-clockwise"),Me=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),we=require("d3-geo-voronoi"),ie=require("d3-scale"),Pe=(a,e=1)=>{const t=new r.BufferGeometry;t.setAttribute("position",new r.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new r.Float32BufferAttribute(new Array(e).fill(1),1));const i=a.material,s=new r.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=o=>{o.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
|
-
${
|
|
4
|
-
`},new n.Points(e,s)};class ut extends _{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.disposeWithMaterial=!1,this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}get parent(){const t=this.object3d.parent;return t&&this.lead.objMap.get(t)||null}get children(){return this.object3d.children.map(t=>this.lead.objMap.get(t)).filter(t=>!!t)}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 t=this.parent;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(t,e){}resize(t,e){}show(){return this.object3d.visible=!0,this}hide(){return this.object3d.visible=!1,this}createMesh(...t){return this.object3d=new n.Mesh(...t),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...t){return this.object3d=new n.Points(...t),this}createCSS2DObject(t){return this.object3d=new gt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new et.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new et.CSS3DSprite(t),this}createSprite(t){return this.object3d=new n.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new n.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new n.Vector3),center:t.getCenter(new n.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return tt(this,null,function*(){var p;const i=t&&t.length>0,s=(p=e==null?void 0:e.recursive)!=null?p:!0,{objectType:a,objectOptions:l}=this,[,r]=a.split("#");let c=e==null?void 0:e.create;c===void 0&&(c=h=>{if(this.object3d){if(i){const v=t.length;if(this.object3d instanceof n.Sprite)h.object3d=Pt(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;t.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:(e==null?void 0:e.key)||(l==null?void 0:l.key),target:(e==null?void 0:e.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(t,e){if(this.object3d instanceof n.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);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=t*3,h=t*1;e.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 t=this.object3d;if(!t||!t.material)return;const e=t.material;if(Array.isArray(e))return e.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=e.userData;e.userData={};const s=e.clone();return e.userData=i,s}}setMaterialList(t,e,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[t])if(i){const l=this.materialList[t],r=new _;r.track(l),r.dispose()}else return this.materialList[t];const a=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=a,a}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}onPointerEvent(t,e){const i=this.lead.handlePick([this],t,e);this.onPointerIndex.push(i)}enableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var t;this.onPointerIndex.forEach(e=>{this.lead.removePick(e)}),this.mList.rmBaseObjectMap(this),(t=this.pencil.composerController)==null||t.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}}class At extends ut{create(){this.createGroup()}}const Z=new n.Vector4,st=new n.Vector3,rt=new n.Vector3,y=new n.Vector4,x=new n.Vector4,D=new n.Vector4,$=new n.Vector3,N=new n.Matrix4,M=new n.Line3,nt=new n.Vector3,R=new n.Box3,E=new n.Sphere,z=new n.Vector4;let I,T;function at(o,t,e){return z.set(0,0,-t,1).applyMatrix4(o.projectionMatrix),z.multiplyScalar(1/z.w),z.x=T/e.width,z.y=T/e.height,z.applyMatrix4(o.projectionMatrixInverse),z.multiplyScalar(1/z.w),Math.abs(Math.max(z.x,z.y))}function St(o,t){const e=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(e);const u=new n.Vector3,p=new n.Vector3;I.distanceSqToSegment(M.start,M.end,p,u),p.distanceTo(u)<T*.5&&t.push({point:p,pointOnLine:u,distance:I.origin.distanceTo(p),object:o,face:null,faceIndex:r,uv:null,uv1:null})}}function jt(o,t,e){const i=t.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=-t.near;I.at(1,D),D.w=1,D.applyMatrix4(t.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=a.x/2,D.y*=a.y/2,D.z=0,$.copy(D),N.multiplyMatrices(t.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 B=y.z-x.z,A=(y.z-h)/B;y.lerp(x,A)}else if(x.z>h){const B=x.z-y.z,A=(x.z-h)/B;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,nt);const b=n.MathUtils.lerp(y.z,x.z,m),P=b>=-1&&b<=1,V=$.distanceTo(nt)<T*.5;if(P&&V){M.start.fromBufferAttribute(c,v),M.end.fromBufferAttribute(u,v),M.start.applyMatrix4(l),M.end.applyMatrix4(l);const B=new n.Vector3,A=new n.Vector3;I.distanceSqToSegment(M.start,M.end,A,B),e.push({point:A,pointOnLine:B,distance:I.origin.distanceTo(A),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ct extends n.Mesh{constructor(t=new bt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let l=0,r=0,c=e.count;l<c;l++,r+=2)st.fromBufferAttribute(e,l),rt.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+st.distanceTo(rt);const a=new n.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),t.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(a,1,1)),this}raycast(t,e){const i=this.material.worldUnits,s=t.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=t.params.Line2!==void 0&&t.params.Line2.threshold||0;I=t.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;T=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),E.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=T*.5;else{const h=Math.max(s.near,E.distanceToPoint(I.origin));u=at(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=T*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));p=at(s,h,c.resolution)}R.expandByScalar(p),I.intersectsBox(R)!==!1&&(i?St(this,e):jt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Z),this.material.uniforms.resolution.value.set(Z.z,Z.w))}}const ot=["encodings_fragment","colorspace_fragment"],Vt=`
|
|
3
|
+
${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
+
`},new r.Points(t,s)};class K{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[],this.disposeTrack=!0,this.disposeMaterialIfNotUsed=!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 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 r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.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 r.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.Vector3),center:e.getCenter(new r.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 m;const i=e&&e.length>0,s=(m=t==null?void 0:t.recursive)!=null?m:!0,{objectType:o,objectOptions:c}=this,[,n]=o.split("#");let l=t==null?void 0:t.create;l===void 0&&(l=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof r.Sprite)h.object3d=Pe(this.object3d,v);else{const d=this.object3d,p=this.cloneMaterial();h.object3d=new r.InstancedMesh(d.geometry,p,v)}const f=new r.Object3D;e.forEach((d,p)=>{const b=$.parseVector3(d.position),P=$.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(p,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(n,q(W({},c||{}),{create:l,prefab:!1,key:(t==null?void 0:t.key)||(c==null?void 0:c.key),target:(t==null?void 0:t.target)||(c==null?void 0:c.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 r.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof r.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,o=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new r.Vector3,l=new r.Vector3,u=new r.Quaternion,m=e*3,h=e*1;t.decompose(n,u,l),o[m]=n.x,o[m+1]=n.y,o[m+2]=n.z,c[h]=Math.max(l.x,l.y,l.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 o=i.clone();return i.userData=s,o});{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]&&!i)return this.materialList[e];const o=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=o,o}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMList(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}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;if(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(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.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{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 r.Material)return e;if(e instanceof K?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof r.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof K)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof r.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof r.Material){for(const i of Object.values(e))i instanceof r.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof r.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof r.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof r.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 F=new r.Vector4,se=new r.Vector3,re=new r.Vector3,y=new r.Vector4,M=new r.Vector4,D=new r.Vector4,Z=new r.Vector3,N=new r.Matrix4,x=new r.Line3,ne=new r.Vector3,R=new r.Box3,U=new r.Sphere,z=new r.Vector4;let I,L;function oe(a,e,t){return z.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),z.multiplyScalar(1/z.w),z.x=L/t.width,z.y=L/t.height,z.applyMatrix4(a.projectionMatrixInverse),z.multiplyScalar(1/z.w),Math.abs(Math.max(z.x,z.y))}function je(a,e){const t=a.matrixWorld,i=a.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){x.start.fromBufferAttribute(s,n),x.end.fromBufferAttribute(o,n),x.applyMatrix4(t);const u=new r.Vector3,m=new r.Vector3;I.distanceSqToSegment(x.start,x.end,m,u),m.distanceTo(u)<L*.5&&e.push({point:m,pointOnLine:u,distance:I.origin.distanceTo(m),object:a,face:null,faceIndex:n,uv:null,uv1:null})}}function Ae(a,e,t){const i=e.projectionMatrix,o=a.material.resolution,c=a.matrixWorld,n=a.geometry,l=n.attributes.instanceStart,u=n.attributes.instanceEnd,m=Math.min(n.instanceCount,l.count),h=-e.near;I.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,Z.copy(D),N.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,f=m;v<f;v++){if(y.fromBufferAttribute(l,v),M.fromBufferAttribute(u,v),y.w=1,M.w=1,y.applyMatrix4(N),M.applyMatrix4(N),y.z>h&&M.z>h)continue;if(y.z>h){const B=y.z-M.z,j=(y.z-h)/B;y.lerp(M,j)}else if(M.z>h){const B=M.z-y.z,j=(M.z-h)/B;M.lerp(y,j)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=o.x/2,y.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const p=x.closestPointToPointParameter(Z,!0);x.at(p,ne);const b=r.MathUtils.lerp(y.z,M.z,p),P=b>=-1&&b<=1,V=Z.distanceTo(ne)<L*.5;if(P&&V){x.start.fromBufferAttribute(l,v),x.end.fromBufferAttribute(u,v),x.start.applyMatrix4(c),x.end.applyMatrix4(c);const B=new r.Vector3,j=new r.Vector3;I.distanceSqToSegment(x.start,x.end,j,B),t.push({point:j,pointOnLine:B,distance:I.origin.distanceTo(j),object:a,face:null,faceIndex:v,uv:null,uv1:null})}}}class Se extends r.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 c=0,n=0,l=t.count;c<l;c++,n+=2)se.fromBufferAttribute(t,c),re.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+se.distanceTo(re);const o=new r.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(o,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 o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;I=e.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;L=l.linewidth+o,n.boundingSphere===null&&n.computeBoundingSphere(),U.copy(n.boundingSphere).applyMatrix4(c);let u;if(i)u=L*.5;else{const h=Math.max(s.near,U.distanceToPoint(I.origin));u=oe(s,h,l.resolution)}if(U.radius+=u,I.intersectsSphere(U)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),R.copy(n.boundingBox).applyMatrix4(c);let m;if(i)m=L*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));m=oe(s,h,l.resolution)}R.expandByScalar(m),I.intersectsBox(R)!==!1&&(i?je(this,t):Ae(this,s,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 ae=["encodings_fragment","colorspace_fragment"],Ce=`
|
|
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 <${+r.REVISION<154?ae[0]:ae[1]}>
|
|
148
148
|
}
|
|
149
|
-
`;class
|
|
149
|
+
`;class Be extends r.ShaderMaterial{constructor(e){super({uniforms:q(W({},r.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new r.Color(16777215)},opacity:{value:1},resolution:{value:new r.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 r.Vector2(1,1)},offset:{value:new r.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new r.Vector2(0,0)},lightColor:{value:new r.Color(16777215)}}),vertexShader:Ce,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 De(a,e){return a.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const c=O.geoDistance(o,s)*180/Math.PI;if(c>e){const n=O.geoInterpolate(s,o),l=1/Math.ceil(c/e);let u=l;for(;u<1;)i.push(n(u)),u+=l}}i.push(s=o)}),i})}function ze(a,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(J(360/a,2)/Math.PI),c=(1+Math.sqrt(5))/2,n=f=>f/c*360%360-180,l=f=>Math.acos(2*f/o-1)/Math.PI*180-90,u=f=>o*(Math.cos((f+90)*Math.PI/180)+1)/2,m=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):o-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=m[0];f<=m[1];f++){const d=n(f);h(d)&&v.push([d,l(f)])}return v}function X(a,e,t=!1){return t?O.geoContains(e,a):xe(a,e)}function Ie(a,e){const t={type:"Polygon",coordinates:a},[[i,s],[o,c]]=O.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(c-s))<e)return[];const n=i>o||c>=89||s<=-89;return ze(e,{minLng:i,maxLng:o,minLat:s,maxLat:c}).filter(l=>X(l,t,n))}function Te(a,{resolution:e=1/0,bbox:t,projection:i}={}){const s=De(a,e),o=_.merge(s),c=Ie(a,e),n=[...o,...c],l={type:"Polygon",coordinates:a},[[u,m],[h,v]]=O.geoBounds(l),f=u>h||v>=89||m<=-89;let d=[];if(f){const g=we.geoVoronoi(n).triangles(),w=new Map(n.map(([A,S],T)=>[`${A}-${S}`,T]));g.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),T=[];if(S.forEach(([C,G])=>{const k=`${C}-${G}`;w.has(k)&&T.push(w.get(k))}),T.length===3){if(T.some(C=>C<o.length)){const C=A.properties.circumcenter;if(!X(C,l,f))return}d.push(...T)}})}else if(c.length){const g=Me.from(n);for(let w=0,A=g.triangles.length;w<A;w+=3){const S=[2,1,0].map(C=>g.triangles[w+C]),T=S.map(C=>n[C]);if(S.some(C=>C<o.length)){const C=[0,1].map(G=>_.mean(T,k=>k[G]));if(!X(C,l,f))continue}d.push(...S)}}else{const{vertices:g,holes:w=[]}=Q.flatten(s);d=Q(g,w,2)}let p=t?[t[0],t[2]]:_.extent(n,g=>g[0]),b=t?[t[1],t[3]]:_.extent(n,g=>g[1]);if(i){const[g,w]=i([p[0],b[0]]),[A,S]=i([p[1],b[1]]);p=[g,A],b=[-w,-S]}const P=ie.scaleLinear(p,[0,1]),V=ie.scaleLinear(b,[0,1]),B=n.map(([g,w])=>{if(i){const[A,S]=i([g,w]);return[P(A),V(-S)]}else return[P(g),V(w)]});return{contour:s,triangles:{points:n,indices:d,uvs:B}}}const le=new r.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function E(a,e,t,i){const s=a.map(o=>o.map(([c,n])=>{if(i){const[l,u]=i([c,n]);return[l,-u,e]}return t?$.polar2Cartesian(c,n,e):[c,n,e]}));return Q.flatten(s)}function Le(a,e,t,i,s){const{vertices:o,holes:c}=E(a,e,i,s),{vertices:n}=E(a,t,i,s),l=_.merge([n,o]),u=Math.round(n.length/3),m=new Set(c);let h=0;const v=[];for(let d=0;d<u;d++){let p=d+1;if(p===u)p=h;else if(m.has(p)){const b=p;p=h,h=b}v.push(d,d+u,p+u),v.push(p+u,p,d)}const f=[];for(let d=1;d>=0;d--)for(let p=0;p<u;p+=1)f.push(p/(u-1),d);return{indices:v,vertices:l,uvs:f,topVerts:n}}function ce(a,e,t,i,s,o){return{indices:i?a.indices:a.indices.slice().reverse(),vertices:E([a.points],e,s,o).vertices,uvs:t}}const he=({polygonGeoJson:a,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:c=!1,hasTop:n=!1,projection:l,bbox:u})=>{a.forEach(P=>{ye(P)||P.reverse()});const{contour:m,triangles:h}=Te(a,{resolution:i,bbox:u,projection:l});let v={},f;o&&(v=Le(m,e!=null?e:t,t!=null?t:e,s,l),f=v.topVerts);let d=[];(c||n)&&(d=_.merge(h.uvs));let p={};c&&(p=ce(h,e,d,!1,s,l));let b={};return n&&(b=ce(h,t,d,!0,s,l)),{contour:m,triangles:h,sideTorso:v,bottomCap:p,topCap:b,topVerts:f}};class _e extends r.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=W({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:o,hasBottom:c,hasSide:n,cartesian:l,userDataRsoOffset:u,projection:m}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:p}=he(W({},this.parameters));let b=[],P=[],V=[],B=0;const j=g=>{const w=Math.round(b.length/3),A=V.length;b=b.concat(g.vertices),P=P.concat(g.uvs),V=V.concat(w?g.indices.map(S=>S+w):g.indices),this.addGroup(A,V.length-A,B++)};s&&o&&j(p),n&&(j(v),this.userData.topVerts=u?E(h,i+u,l,m).vertices:f),c&&j(d),s&&!o&&j(p),this.setIndex(V),this[le]("position",new r.Float32BufferAttribute(b,3)),this[le]("uv",new r.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=K;exports.LineSegments2=Se;exports.MeshLineMaterial=Be;exports.PolygonGeometry=_e;exports.ResourceTracker=ue;exports.getMetas=he;
|
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 qe=Object.defineProperty,We=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var Ve=(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)&&Ve(n,t,e[t]);if(ae)for(var t of ae(e))Pe.call(e,t)&&Ve(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()}}class Ke extends P.BaseObject{create(){this.createGroup()}}const et={ArcCurve:c.ArcCurve,CatmullRomCurve3:c.CatmullRomCurve3,CubicBezierCurve:c.CubicBezierCurve,CubicBezierCurve3:c.CubicBezierCurve3,EllipseCurve:c.EllipseCurve,LineCurve:c.LineCurve,LineCurve3:c.LineCurve3,QuadraticBezierCurve:c.QuadraticBezierCurve,QuadraticBezierCurve3:c.QuadraticBezierCurve3,SplineCurve:c.SplineCurve};class 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 y=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,V=t.UVGenerator!==void 0?t.UVGenerator:tt,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,y=!1,$=_.computeFrenetFrames(o,!1),ee=new c.Vector3,te=new c.Vector3,D=new c.Vector3),y||(M=0,m=0,x=0,L=0);const be=u.extractPoints(w);let O=be.shape;const G=be.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 ye(l){const p=10000000000000001e-36;let b=l[0];for(let g=1;g<=l.length;g++){const S=g%l.length,v=l[S],T=v.x-b.x,j=v.y-b.y,B=T*T+j*j,C=Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(b.x),Math.abs(b.y)),Q=p*C*C;if(B<=Q){l.splice(S,1),g--;continue}b=v}}ye(O),G.forEach(ye);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 b,g,S;const v=l.x-f.x,T=l.y-f.y,j=p.x-l.x,B=p.y-l.y,C=v*v+T*T,Q=v*B-T*j;if(Math.abs(Q)>Number.EPSILON){const U=Math.sqrt(C),Me=Math.sqrt(j*j+B*B),Le=f.x-T/U,Te=f.y+v/U,ke=p.x-B/Me,Fe=p.y+j/Me,je=((ke-Le)*B-(Fe-Te)*j)/(v*B-T*j);b=Le+v*je-l.x,g=Te+T*je-l.y;const Be=b*b+g*g;if(Be<=2)return new c.Vector2(b,g);S=Math.sqrt(Be/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(B)&&(U=!0),U?(b=-T,g=v,S=Math.sqrt(C)):(b=v,g=T,S=Math.sqrt(C/2))}return new c.Vector2(b/S,g/S)}const ie=[];for(let l=0,f=z.length,p=f-1,b=l+1;l<f;l++,p++,b++)p===f&&(p=0),b===f&&(b=0),ie[l]=we(z[l],z[p],z[b]);const de=[];let q,re=ie.concat();for(let l=0,f=ue;l<f;l++){const p=G[l];q=[];for(let b=0,g=p.length,S=g-1,v=b+1;b<g;b++,S++,v++)S===g&&(S=0),v===g&&(v=0),q[b]=we(p[b],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 b=p/M,g=m*Math.cos(b*Math.PI/2),S=x*Math.sin(b*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),b===0&&l.push(j)}for(let v=0,T=ue;v<T;v++){const j=G[v];q=de[v];const B=[];for(let C=0,Q=j.length;C<Q;C++){const U=Z(j[C],q[C],S);N(U.x,U.y,-g),b===0&&B.push(U)}b===0&&f.push(B)}}J=c.ShapeUtils.triangulateShape(l,f)}const ne=J.length,xe=x+L;for(let l=0;l<H;l++){const f=y?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=y?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),b=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],b);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 B=Z(v[T],q[T],b);Y?N(B.x,B.y+W[o-1].y,W[o-1].x+p):N(B.x,B.y,d+p)}}}De(),le&&He();function De(){const l=i.length/3;if(y){let f=0,p=H*f;if(I)for(let b=0;b<ne;b++){const g=J[b];oe(g[2]+p,g[1]+p,g[0]+p)}if(f=o+M*2,p=H*f,A)for(let b=0;b<ne;b++){const g=J[b];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,b=G.length;p<b;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 b=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),B=f+b+T,C=f+g+T,Q=f+g+j,U=f+b+j;Ne(B,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 b=i.length/3,g=V.generateTopUV(s,i,b-3,b-2,b-1);F(g[0]),F(g[1]),F(g[2])}function Ne(l,f,p,b){k(l),k(f),k(b),k(f),k(p),k(b);const g=i.length/3,S=V.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 st(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 et[`${i.type}`]().fromJSON(i)),new X(s,e.options)}}const tt={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],y=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(y,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 st(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 it 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 y=Math.PI*2*(o/h),m=s[d],x=r?t*(o/u):t,L=this.createGeometry(x,y),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+=y,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 rt extends P.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,s,i,r,a,u,h,w,o,d,y,m,x,L,M,_,V;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((y=e.color)!=null?y: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,(V=e.height)!=null?V: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 y=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]),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(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 y=0;y<n.length;++y){const m=n[y].index;for(let x=0;x<m.count;++x)d.push(m.getX(x)+o);o+=n[y].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 y=0;y<d;++y){const m=[];for(let L=0;L<a[o].length;++L)m.push(a[o][L][y]);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 nt=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,y=s;!d&&w&&(d=this.getMaterial(w)),!y&&e?y=Ce({points:e}):!y&&t?y=R(t.map(x=>Ce({points:x})),a!=null?a:0):!y&&i&&i.length>1?y=R(i,a!=null?a:0):!y&&i&&i.length===1&&([y]=i);const m=new Ie.LineSegmentsGeometry().fromLineSegments(new c.LineSegments(y));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 ot(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=ot(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 at 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((y,m)=>{let x=u;return!x&&h&&(x=()=>{var L;return(L=h[m])!=null?L:h[0]}),ge({nodes:y,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 y=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(()=>{y+=1,r&&r(y)}).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 ct 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 ht 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 V=Math.max(r.x/_.x,r.y/_.y);u=Math.ceil(t.topSegments*V)}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 y=new he.Evaluator().evaluate(o,s,he.INTERSECTION),m=y.geometry.getAttribute("position"),x=new c.Float32BufferAttribute(m.count*2,2);for(let _=0;_<m.count;_++){const V=m.getZ(_);m.setZ(_,t.depth+V)}if(h){const _=h.min,V=h.max,A=new c.Vector3().subVectors(V,_);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,$)}y.geometry.setAttribute("uv",x)}m.needsUpdate=!0;const L=new X(e,ce(E({},t),{hasTop:!1})),M=R([y.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?ht: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 lt 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:y}=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:y}):!M&&t?M=R(t.map((_,V)=>{var A,I;return Oe({points:_,depth:(A=m[V])!=null?A:m[0],box3:(I=x[V])!=null?I:x[0],split:w,hasTop:o,hasBottom:d,hasSide:y})}),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 ut=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 y=new c.CanvasTexture(o);u(y)},s?h.src=s:h instanceof HTMLImageElement||h.onload()})};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=ct;exports.ExtrudePolygon=lt;exports.Group=Ke;exports.Light=rt;exports.Line=at;exports.Line2=nt;exports.MeshLineGeometry=Re;exports.Node=Ze;exports.Pie=it;exports.getSplitTexture=ut;
|
|
@@ -35,9 +35,9 @@ var nt = (a, t, e) => new Promise((s, i) => {
|
|
|
35
35
|
}, l = (h) => h.done ? s(h.value) : Promise.resolve(h.value).then(n, r);
|
|
36
36
|
l((e = e.apply(a, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { B as
|
|
39
|
-
import {
|
|
40
|
-
import { BufferGeometry as ot, Float32BufferAttribute as wt, Vector3 as F, ShapeUtils as dt, Shape as xt, Vector2 as P, ArcCurve as te, CatmullRomCurve3 as ee, CubicBezierCurve as se, CubicBezierCurve3 as ie, EllipseCurve as ne, LineCurve as oe, LineCurve3 as re, QuadraticBezierCurve as ae, QuadraticBezierCurve3 as he, SplineCurve as ce, MeshBasicMaterial as le, Mesh as ue, AmbientLight as de, DirectionalLight as pe, PointLight as fe, SpotLight as me, HemisphereLight as ge, RectAreaLight as ye, LineSegments as be, Color as Nt, Matrix4 as we, BufferAttribute as
|
|
38
|
+
import { B as q, L as Yt, M as Zt, P as Kt } from "../index.module2.js";
|
|
39
|
+
import { g as as } from "../index.module2.js";
|
|
40
|
+
import { BufferGeometry as ot, Float32BufferAttribute as wt, Vector3 as F, ShapeUtils as dt, Shape as xt, Vector2 as P, ArcCurve as te, CatmullRomCurve3 as ee, CubicBezierCurve as se, CubicBezierCurve3 as ie, EllipseCurve as ne, LineCurve as oe, LineCurve3 as re, QuadraticBezierCurve as ae, QuadraticBezierCurve3 as he, SplineCurve as ce, MeshBasicMaterial as le, Mesh as ue, AmbientLight as de, DirectionalLight as pe, PointLight as fe, SpotLight as me, HemisphereLight as ge, RectAreaLight as ye, LineSegments as be, Color as Nt, Matrix4 as we, BufferAttribute as $, Box3 as xe, PlaneGeometry as ve, CanvasTexture as Ae } from "three";
|
|
41
41
|
import * as et from "@tweenjs/tween.js";
|
|
42
42
|
import { RectAreaLightUniformsLib as Se } from "three/examples/jsm/lights/RectAreaLightUniformsLib";
|
|
43
43
|
import { mergeAttributes as zt, mergeGroups as _e } from "three/examples/jsm/utils/BufferGeometryUtils";
|
|
@@ -48,7 +48,7 @@ import { LineMaterial as Te } from "three/examples/jsm/lines/LineMaterial";
|
|
|
48
48
|
import { LineMaterial as us } from "three/examples/jsm/lines/LineMaterial";
|
|
49
49
|
import { g as Ee, c as Pe } from "../uvGenerator.module.js";
|
|
50
50
|
import { Brush as Rt, Evaluator as je, INTERSECTION as Ge } from "three-bvh-csg";
|
|
51
|
-
class Xe extends
|
|
51
|
+
class Xe extends q {
|
|
52
52
|
constructor(t) {
|
|
53
53
|
super(), this.objectType = "BaseObject#Node", this.onNodePointerIndex = [], this.options = G({
|
|
54
54
|
type: "2d"
|
|
@@ -95,6 +95,11 @@ class Xe extends Z {
|
|
|
95
95
|
}), super.dispose();
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
class Qe extends q {
|
|
99
|
+
create() {
|
|
100
|
+
this.createGroup();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
98
103
|
const Ue = {
|
|
99
104
|
ArcCurve: te,
|
|
100
105
|
CatmullRomCurve3: ee,
|
|
@@ -107,7 +112,7 @@ const Ue = {
|
|
|
107
112
|
QuadraticBezierCurve3: he,
|
|
108
113
|
SplineCurve: ce
|
|
109
114
|
};
|
|
110
|
-
class
|
|
115
|
+
class Z extends ot {
|
|
111
116
|
/**
|
|
112
117
|
* Constructs a new extrude geometry.
|
|
113
118
|
*
|
|
@@ -135,8 +140,8 @@ class Y extends ot {
|
|
|
135
140
|
const h = [], b = e.curveSegments !== void 0 ? e.curveSegments : 12, o = e.steps !== void 0 ? e.steps : 1, u = e.depth !== void 0 ? e.depth : 1;
|
|
136
141
|
let y = e.bevelEnabled !== void 0 ? e.bevelEnabled : !0, f = e.bevelThickness !== void 0 ? e.bevelThickness : 0.2, w = e.bevelSize !== void 0 ? e.bevelSize : f - 0.1, M = e.bevelOffset !== void 0 ? e.bevelOffset : 0, _ = e.bevelSegments !== void 0 ? e.bevelSegments : 3;
|
|
137
142
|
const S = e.extrudePath, j = e.UVGenerator !== void 0 ? e.UVGenerator : Ce, v = (Lt = e.hasTop) != null ? Lt : !0, V = (Tt = e.hasBottom) != null ? Tt : !0, pt = (Et = e.hasSide) != null ? Et : !0;
|
|
138
|
-
let
|
|
139
|
-
S && (
|
|
143
|
+
let J, K = !1, X, st, it, D;
|
|
144
|
+
S && (J = S.getSpacedPoints(o), K = !0, y = !1, X = S.computeFrenetFrames(o, !1), st = new F(), it = new F(), D = new F()), y || (_ = 0, f = 0, w = 0, M = 0);
|
|
140
145
|
const vt = l.extractPoints(b);
|
|
141
146
|
let B = vt.shape;
|
|
142
147
|
const U = vt.holes;
|
|
@@ -156,8 +161,8 @@ class Y extends ot {
|
|
|
156
161
|
Math.abs(x.y),
|
|
157
162
|
Math.abs(g.x),
|
|
158
163
|
Math.abs(g.y)
|
|
159
|
-
),
|
|
160
|
-
if (E <=
|
|
164
|
+
), Y = p * C * C;
|
|
165
|
+
if (E <= Y) {
|
|
161
166
|
c.splice(A, 1), m--;
|
|
162
167
|
continue;
|
|
163
168
|
}
|
|
@@ -176,11 +181,11 @@ class Y extends ot {
|
|
|
176
181
|
const O = B.length;
|
|
177
182
|
function St(c, d, p) {
|
|
178
183
|
let g, m, A;
|
|
179
|
-
const x = c.x - d.x, L = c.y - d.y, T = p.x - c.x, E = p.y - c.y, C = x * x + L * L,
|
|
180
|
-
if (Math.abs(
|
|
184
|
+
const x = c.x - d.x, L = c.y - d.y, T = p.x - c.x, E = p.y - c.y, C = x * x + L * L, Y = x * E - L * T;
|
|
185
|
+
if (Math.abs(Y) > Number.EPSILON) {
|
|
181
186
|
const I = Math.sqrt(C), Pt = Math.sqrt(
|
|
182
187
|
T * T + E * E
|
|
183
|
-
), jt = d.x - L / I, Gt = d.y + x / I,
|
|
188
|
+
), jt = d.x - L / I, Gt = d.y + x / I, $t = p.x - E / Pt, qt = p.y + T / Pt, Ut = (($t - jt) * E - (qt - Gt) * T) / (x * E - L * T);
|
|
184
189
|
g = jt + x * Ut - c.x, m = Gt + L * Ut - c.y;
|
|
185
190
|
const Ct = g * g + m * m;
|
|
186
191
|
if (Ct <= 2)
|
|
@@ -204,9 +209,9 @@ class Y extends ot {
|
|
|
204
209
|
A === m && (A = 0), x === m && (x = 0), W[g] = St(p[g], p[A], p[x]);
|
|
205
210
|
mt.push(W), at = at.concat(W);
|
|
206
211
|
}
|
|
207
|
-
let
|
|
212
|
+
let Q;
|
|
208
213
|
if (_ === 0)
|
|
209
|
-
|
|
214
|
+
Q = dt.triangulateShape(z, U);
|
|
210
215
|
else {
|
|
211
216
|
const c = [], d = [];
|
|
212
217
|
for (let p = 0; p < _; p++) {
|
|
@@ -219,27 +224,27 @@ class Y extends ot {
|
|
|
219
224
|
const T = U[x];
|
|
220
225
|
W = mt[x];
|
|
221
226
|
const E = [];
|
|
222
|
-
for (let C = 0,
|
|
227
|
+
for (let C = 0, Y = T.length; C < Y; C++) {
|
|
223
228
|
const I = tt(T[C], W[C], A);
|
|
224
229
|
H(I.x, I.y, -m), g === 0 && E.push(I);
|
|
225
230
|
}
|
|
226
231
|
g === 0 && d.push(E);
|
|
227
232
|
}
|
|
228
233
|
}
|
|
229
|
-
|
|
234
|
+
Q = dt.triangulateShape(
|
|
230
235
|
c,
|
|
231
236
|
d
|
|
232
237
|
);
|
|
233
238
|
}
|
|
234
|
-
const ht =
|
|
239
|
+
const ht = Q.length, _t = w + M;
|
|
235
240
|
for (let c = 0; c < O; c++) {
|
|
236
241
|
const d = y ? tt(B[c], at[c], _t) : B[c];
|
|
237
|
-
K ? (it.copy(
|
|
242
|
+
K ? (it.copy(X.normals[0]).multiplyScalar(d.x), st.copy(X.binormals[0]).multiplyScalar(d.y), D.copy(J[0]).add(it).add(st), H(D.x, D.y, D.z)) : H(d.x, d.y, 0);
|
|
238
243
|
}
|
|
239
244
|
for (let c = 1; c <= o; c++)
|
|
240
245
|
for (let d = 0; d < O; d++) {
|
|
241
246
|
const p = y ? tt(B[d], at[d], _t) : B[d];
|
|
242
|
-
K ? (it.copy(
|
|
247
|
+
K ? (it.copy(X.normals[c]).multiplyScalar(p.x), st.copy(X.binormals[c]).multiplyScalar(p.y), D.copy(J[c]).add(it).add(st), H(D.x, D.y, D.z)) : H(p.x, p.y, u / o * c);
|
|
243
248
|
}
|
|
244
249
|
for (let c = _ - 1; c >= 0; c--) {
|
|
245
250
|
const d = c / _, p = f * Math.cos(d * Math.PI / 2), g = w * Math.sin(d * Math.PI / 2) + M;
|
|
@@ -254,8 +259,8 @@ class Y extends ot {
|
|
|
254
259
|
const E = tt(x[L], W[L], g);
|
|
255
260
|
K ? H(
|
|
256
261
|
E.x,
|
|
257
|
-
E.y +
|
|
258
|
-
|
|
262
|
+
E.y + J[o - 1].y,
|
|
263
|
+
J[o - 1].x + p
|
|
259
264
|
) : H(E.x, E.y, u + p);
|
|
260
265
|
}
|
|
261
266
|
}
|
|
@@ -267,23 +272,23 @@ class Y extends ot {
|
|
|
267
272
|
let d = 0, p = O * d;
|
|
268
273
|
if (V)
|
|
269
274
|
for (let g = 0; g < ht; g++) {
|
|
270
|
-
const m =
|
|
275
|
+
const m = Q[g];
|
|
271
276
|
ct(m[2] + p, m[1] + p, m[0] + p);
|
|
272
277
|
}
|
|
273
278
|
if (d = o + _ * 2, p = O * d, v)
|
|
274
279
|
for (let g = 0; g < ht; g++) {
|
|
275
|
-
const m =
|
|
280
|
+
const m = Q[g];
|
|
276
281
|
ct(m[0] + p, m[1] + p, m[2] + p);
|
|
277
282
|
}
|
|
278
283
|
} else {
|
|
279
284
|
if (V)
|
|
280
285
|
for (let d = 0; d < ht; d++) {
|
|
281
|
-
const p =
|
|
286
|
+
const p = Q[d];
|
|
282
287
|
ct(p[2], p[1], p[0]);
|
|
283
288
|
}
|
|
284
289
|
if (v)
|
|
285
290
|
for (let d = 0; d < ht; d++) {
|
|
286
|
-
const p =
|
|
291
|
+
const p = Q[d];
|
|
287
292
|
ct(
|
|
288
293
|
p[0] + O * o,
|
|
289
294
|
p[1] + O * o,
|
|
@@ -310,8 +315,8 @@ class Y extends ot {
|
|
|
310
315
|
let m = p - 1;
|
|
311
316
|
m < 0 && (m = c.length - 1);
|
|
312
317
|
for (let A = 0, x = o + _ * 2; A < x; A++) {
|
|
313
|
-
const L = O * A, T = O * (A + 1), E = d + g + L, C = d + m + L,
|
|
314
|
-
Wt(E, C,
|
|
318
|
+
const L = O * A, T = O * (A + 1), E = d + g + L, C = d + m + L, Y = d + m + T, I = d + g + T;
|
|
319
|
+
Wt(E, C, Y, I);
|
|
315
320
|
}
|
|
316
321
|
}
|
|
317
322
|
}
|
|
@@ -373,7 +378,7 @@ class Y extends ot {
|
|
|
373
378
|
const i = t.options.extrudePath;
|
|
374
379
|
return i !== void 0 && (t.options.extrudePath = new Ue[`${i.type}`]().fromJSON(
|
|
375
380
|
i
|
|
376
|
-
)), new
|
|
381
|
+
)), new Z(s, t.options);
|
|
377
382
|
}
|
|
378
383
|
}
|
|
379
384
|
const Ce = {
|
|
@@ -410,7 +415,7 @@ function Ie(a, t, e) {
|
|
|
410
415
|
e.shapes.push(a.uuid);
|
|
411
416
|
return e.options = Object.assign({}, t), t.extrudePath !== void 0 && (e.options.extrudePath = t.extrudePath.toJSON()), e;
|
|
412
417
|
}
|
|
413
|
-
class
|
|
418
|
+
class Ye extends q {
|
|
414
419
|
constructor(t) {
|
|
415
420
|
super(), this.options = G({
|
|
416
421
|
maxDepth: 10,
|
|
@@ -438,7 +443,7 @@ class Qe extends Z {
|
|
|
438
443
|
}
|
|
439
444
|
createGeometry(t, e) {
|
|
440
445
|
const { outRadius: s, innerRadius: i } = this.options, n = new xt();
|
|
441
|
-
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
|
|
446
|
+
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 Z(n, {
|
|
442
447
|
curveSegments: 48,
|
|
443
448
|
depth: t,
|
|
444
449
|
bevelEnabled: !1
|
|
@@ -470,7 +475,7 @@ class Qe extends Z {
|
|
|
470
475
|
this.object3d.scale.z = 0, new et.Tween(this.object3d.scale).to({ z: 1 }, 1e3).easing(et.Easing.Sinusoidal.InOut).start();
|
|
471
476
|
}
|
|
472
477
|
}
|
|
473
|
-
class
|
|
478
|
+
class Ze extends q {
|
|
474
479
|
constructor(t) {
|
|
475
480
|
super(), this.rectAreaLightUniformsLibInit = !1, this.options = t;
|
|
476
481
|
}
|
|
@@ -632,7 +637,7 @@ const Dt = (a) => {
|
|
|
632
637
|
const { points: t } = a, e = t.reduce((i, n, r) => (r < t.length - 1 && i.push(n, t[r + 1]), i), []);
|
|
633
638
|
return new ot().setFromPoints(e);
|
|
634
639
|
};
|
|
635
|
-
let
|
|
640
|
+
let Ke = class extends q {
|
|
636
641
|
constructor(t = {}) {
|
|
637
642
|
super(), this.options = G({}, t);
|
|
638
643
|
}
|
|
@@ -757,14 +762,14 @@ class Ve extends ot {
|
|
|
757
762
|
i > 0 && (s = this.copyV3(i), this.next.push(s[0], s[1], s[2]), this.next.push(s[0], s[1], s[2]));
|
|
758
763
|
}
|
|
759
764
|
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 = {
|
|
760
|
-
position: new
|
|
761
|
-
previous: new
|
|
762
|
-
next: new
|
|
763
|
-
side: new
|
|
764
|
-
width: new
|
|
765
|
-
uv: new
|
|
766
|
-
index: new
|
|
767
|
-
counters: new
|
|
765
|
+
position: new $(new Float32Array(this.positions), 3),
|
|
766
|
+
previous: new $(new Float32Array(this.previous), 3),
|
|
767
|
+
next: new $(new Float32Array(this.next), 3),
|
|
768
|
+
side: new $(new Float32Array(this.side), 1),
|
|
769
|
+
width: new $(new Float32Array(this.width), 1),
|
|
770
|
+
uv: new $(new Float32Array(this.uvs), 2),
|
|
771
|
+
index: new $(new Uint16Array(this.indices_array), 1),
|
|
772
|
+
counters: new $(new Float32Array(this.counters), 1)
|
|
768
773
|
} : (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();
|
|
769
774
|
}
|
|
770
775
|
/**
|
|
@@ -780,7 +785,7 @@ const bt = (a) => {
|
|
|
780
785
|
const { setPointWidth: t, nodes: e } = a, s = new Ve();
|
|
781
786
|
return s.setPoints(e, t), s;
|
|
782
787
|
};
|
|
783
|
-
class
|
|
788
|
+
class es extends q {
|
|
784
789
|
constructor(t = {}) {
|
|
785
790
|
super(), this.options = G({}, t);
|
|
786
791
|
}
|
|
@@ -888,7 +893,7 @@ const Ot = (a) => {
|
|
|
888
893
|
endHeight: n
|
|
889
894
|
}));
|
|
890
895
|
};
|
|
891
|
-
class
|
|
896
|
+
class ss extends q {
|
|
892
897
|
constructor(t) {
|
|
893
898
|
super(), this.options = G({}, t);
|
|
894
899
|
}
|
|
@@ -922,11 +927,11 @@ class es extends Z {
|
|
|
922
927
|
this.createMesh(l, i);
|
|
923
928
|
}
|
|
924
929
|
}
|
|
925
|
-
class ze extends
|
|
930
|
+
class ze extends Z {
|
|
926
931
|
constructor(t, e) {
|
|
927
932
|
super(t, e);
|
|
928
933
|
const s = new Rt(
|
|
929
|
-
new
|
|
934
|
+
new Z(t, ut(G({}, e), {
|
|
930
935
|
hasTop: !0,
|
|
931
936
|
hasSide: !0,
|
|
932
937
|
hasBottom: !1
|
|
@@ -971,13 +976,13 @@ class ze extends Y {
|
|
|
971
976
|
if (h) {
|
|
972
977
|
const S = h.min, j = h.max, v = new F().subVectors(j, S);
|
|
973
978
|
for (let V = 0; V < f.count; V++) {
|
|
974
|
-
const pt = f.getX(V),
|
|
975
|
-
w.setXY(V, K,
|
|
979
|
+
const pt = f.getX(V), J = f.getY(V), K = (pt - S.x) / v.x, X = (J - S.y) / v.y;
|
|
980
|
+
w.setXY(V, K, X);
|
|
976
981
|
}
|
|
977
982
|
y.geometry.setAttribute("uv", w);
|
|
978
983
|
}
|
|
979
984
|
f.needsUpdate = !0;
|
|
980
|
-
const M = new
|
|
985
|
+
const M = new Z(t, ut(G({}, e), {
|
|
981
986
|
hasTop: !1
|
|
982
987
|
})), _ = R([y.geometry, M], 2);
|
|
983
988
|
this.copy(_.toNonIndexed());
|
|
@@ -994,7 +999,7 @@ const Ht = (a) => {
|
|
|
994
999
|
hasSide: l,
|
|
995
1000
|
sideRepeat: h,
|
|
996
1001
|
topSegments: b
|
|
997
|
-
} = a, o = b ? ze :
|
|
1002
|
+
} = a, o = b ? ze : Z, u = new o(new xt(s), {
|
|
998
1003
|
depth: e,
|
|
999
1004
|
bevelEnabled: !1,
|
|
1000
1005
|
box3: i,
|
|
@@ -1010,7 +1015,7 @@ const Ht = (a) => {
|
|
|
1010
1015
|
});
|
|
1011
1016
|
return Pe(), u;
|
|
1012
1017
|
};
|
|
1013
|
-
class
|
|
1018
|
+
class is extends q {
|
|
1014
1019
|
constructor(t) {
|
|
1015
1020
|
super(), this.options = G({
|
|
1016
1021
|
depth: 1
|
|
@@ -1068,7 +1073,7 @@ class ss extends Z {
|
|
|
1068
1073
|
t.anisotropy = e || this.pencil.renderer.capabilities.getMaxAnisotropy();
|
|
1069
1074
|
}
|
|
1070
1075
|
}
|
|
1071
|
-
const
|
|
1076
|
+
const ns = (a) => {
|
|
1072
1077
|
const {
|
|
1073
1078
|
topColor: t,
|
|
1074
1079
|
sideColor: e,
|
|
@@ -1096,19 +1101,19 @@ const is = (a) => {
|
|
|
1096
1101
|
});
|
|
1097
1102
|
};
|
|
1098
1103
|
export {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1104
|
+
ss as ConicPolygon,
|
|
1105
|
+
is as ExtrudePolygon,
|
|
1106
|
+
Qe as Group,
|
|
1107
|
+
Ze as Light,
|
|
1108
|
+
es as Line,
|
|
1109
|
+
Ke as Line2,
|
|
1105
1110
|
us as Line2Material,
|
|
1106
1111
|
cs as LineSegmentsGeometry,
|
|
1107
1112
|
Ve as MeshLineGeometry,
|
|
1108
1113
|
Zt as MeshLineMaterial,
|
|
1109
1114
|
Xe as Node,
|
|
1110
|
-
|
|
1115
|
+
Ye as Pie,
|
|
1111
1116
|
Kt as getConicPolygonGeometry,
|
|
1112
1117
|
as as getConicPolygonGeometryMetas,
|
|
1113
|
-
|
|
1118
|
+
ns as getSplitTexture
|
|
1114
1119
|
};
|