gl-draw 0.11.7 → 0.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default geoPolygonTriangulate;
|
|
2
|
-
declare function geoPolygonTriangulate(polygon: any, { resolution, bbox }?: {
|
|
2
|
+
declare function geoPolygonTriangulate(polygon: any, { resolution, bbox, projection }?: {
|
|
3
3
|
resolution?: number | undefined;
|
|
4
4
|
bbox: any;
|
|
5
|
+
projection: any;
|
|
5
6
|
}): {
|
|
6
7
|
contour: any;
|
|
7
8
|
triangles: {
|
package/dist/objects/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var bt=Object.defineProperty,xt=Object.defineProperties;var wt=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Je=Math.pow,He=(n,e,t)=>e in n?bt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))$e.call(e,t)&&He(n,t,e[t]);if(ge)for(var t of ge(e))Ze.call(e,t)&&He(n,t,e[t]);return n},Ae=(n,e)=>xt(n,wt(e));var Me=(n,e)=>{var t={};for(var i in n)$e.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&ge)for(var i of ge(n))e.indexOf(i)<0&&Ze.call(n,i)&&(t[i]=n[i]);return t};var ce=(n,e,t)=>new Promise((i,s)=>{var r=u=>{try{a(t.next(u))}catch(f){s(f)}},o=u=>{try{a(t.throw(u))}catch(f){s(f)}},a=u=>u.done?i(u.value):Promise.resolve(u.value).then(r,o);a((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("../BaseObject.js"),At=require("../index2.js"),A=require("three"),Mt=require("@tweenjs/tween.js"),St=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),_t=require("three/examples/jsm/lines/LineSegments2"),Ce=require("three/examples/jsm/lines/LineSegmentsGeometry"),lt=require("three/examples/jsm/lines/LineMaterial"),re=require("d3-array"),Le=require("earcut"),Pt=require("@turf/boolean-clockwise"),Be=require("../uvGenerator.js"),Tt=require("delaunator"),Vt=require("@turf/boolean-point-in-polygon"),he=require("d3-geo"),Lt=require("d3-geo-voronoi"),Xe=require("d3-scale");function ut(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const x=ut(A),oe=ut(Mt);class Bt extends se.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=D({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),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(),i=window.innerWidth,s=window.innerHeight;let r=0,o=0;t.left<0?r=-t.left:t.right>i&&(r=i-t.right),t.top<0?o=-t.top:t.bottom>s&&(o=s-t.bottom),t.left+r<0&&(r=-t.left),t.top+o<0&&(o=-t.top),(r!==0||o!==0)&&(e.style.transform=`translate(${r}px, ${o}px)`)}ensureVisible(){const e=this.options.children;if(!e)return;e.style.transform&&(e.style.transform="");const t=new IntersectionObserver(i=>{i.forEach(s=>{s.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)}onPointerEvent(e,t){const i=this.drawController.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){this.onNodePointerIndex.forEach(e=>{this.drawController.removePickNode(e)}),super.dispose()}}class It extends se.BaseObject{constructor(e){super(),this.options=D({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return ce(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:i,material:s,percentDepth:r,activeIndex:o}=this.options,a=Math.max(...e),u=e.reduce((l,c)=>l+c,0);let f=Math.PI/2;e.forEach((l,c)=>{if(l===0)return;const p=Math.PI*2*(l/u),h=i[c],d=r?t*(l/a):t,w=this.createGeometry(d,p),M=s?s.clone():new x.MeshBasicMaterial({color:h});s&&M.color.set(h);const T=new x.Mesh(w,M);T.userData.depth=d,T.userData.index=c,T.rotateZ(f),f+=p,this.add(T)}),o!==-1&&this.setActive(o)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new x.Shape;return r.moveTo(i,0),r.lineTo(s,0),r.absarc(0,0,s,0,t,!1),r.absarc(0,0,i,t,0,!0),new x.ExtrudeGeometry(r,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:i}=this.pencil.pick(e,this.object3d.children)||{},s=i?this.object3d.children.findIndex(r=>r===i):this.options.activeIndex;return this.setActive(s,t)}setActive(e,t=1.3){const i=this.object3d.children[e];if(this.object3d.children.forEach(s=>{if(!(i&&i===s)&&s.scale.z!==1){if(s.userData.levTween)return;s.userData.enTween&&(s.userData.enTween.stop(),s.userData.enTween=null);const r=new oe.Tween(s.scale).to({z:1},100);s.userData.levTween=r,r.start()}}),i){if(i.userData.enTween)return;i.userData.levTween&&(i.userData.levTween.stop(),i.userData.levTween=null);const s=new oe.Tween(i.scale).to({z:t},100);return i.userData.enTween=s,s.start(),i.userData.index}return-1}render(){this.object3d.scale.z=0,new oe.Tween(this.object3d.scale).to({z:1},1e3).easing(oe.Easing.Sinusoidal.InOut).start()}}class Ct extends se.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,i,s,r,o,a,u,f,l,c,p,h,d,w,M,T,_;const e=this.options;if(e.type==="AmbientLight"){const b=new x.AmbientLight(e.color);b.name="环境光",this.object3d=b}else if(e.type==="DirectionalLight"){const b=new x.DirectionalLight(e.color,e.intensity);b.name="平行光",b.target.position.set(0,0,0),this.object3d=b,b.target.name="平行光目标",b.shadow.camera.name="平行光阴影相机",b.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=b}else if(e.type==="PointLight"){const b=new x.PointLight((t=e.color)!=null?t:16777215,(i=e.intensity)!=null?i:1,(s=e.distance)!=null?s:0,(r=e.decay)!=null?r:2);b.name="点光源",this.object3d=b,this.pointLight=b}else if(e.type==="SpotLight"){const b=new x.SpotLight((o=e.color)!=null?o:16777215,(a=e.intensity)!=null?a:1,(u=e.distance)!=null?u:0,(f=e.angle)!=null?f:Math.PI/3,(l=e.penumbra)!=null?l:1,(c=e.decay)!=null?c:2);b.name="聚光灯",this.object3d=b,this.spotLight=b,b.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const b=new x.HemisphereLight((p=e.color)!=null?p:16777215,(h=e.groundColor)!=null?h:16777215,(d=e.intensity)!=null?d:1);b.name="半球光",this.object3d=b,this.hemisphereLight=b}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(St.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const b=new x.RectAreaLight((w=e.color)!=null?w:16777215,(M=e.intensity)!=null?M:1,(T=e.width)!=null?T:10,(_=e.height)!=null?_:10);b.name="矩形区域光",this.object3d=b,this.rectAreaLight=b}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const i=this.spotLight||this.directionalLight;i.position.copy(t),i.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 ee(n,e=0){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,u=new A.BufferGeometry;let f=0;for(let l=0;l<n.length;++l){const c=n[l];let p=0;if(t!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in c.attributes){if(!i.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;r[h]===void 0&&(r[h]=[]),r[h].push(c.attributes[h]),p++}if(p!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". Make sure all geometries have the same number of attributes."),null;if(a!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in c.morphAttributes){if(!s.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;o[h]===void 0&&(o[h]=[]),o[h].push(c.morphAttributes[h])}if(e){let h;if(t)h=c.index.count;else if(c.attributes.position!==void 0)h=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". The geometry must have either an index or a position attribute"),null;if(e===1)u.addGroup(f,h,l);else if(e===2&&c.groups.length>0)for(let d of c.groups){let w=d.materialIndex;u.addGroup(f+d.start,Math.min(d.count,h),w)}f+=h}}if(t){let l=0;const c=[];for(let p=0;p<n.length;++p){const h=n[p].index;for(let d=0;d<h.count;++d)c.push(h.getX(d)+l);l+=n[p].attributes.position.count}u.setIndex(c)}for(const l in r){const c=Ye(r[l]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;u.setAttribute(l,c)}for(const l in o){const c=o[l][0].length;if(c===0)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[l]=[];for(let p=0;p<c;++p){const h=[];for(let w=0;w<o[l].length;++w)h.push(o[l][w][p]);const d=Ye(h);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;u.morphAttributes[l].push(d)}}return e===2?Et(u):u}function Ye(n){let e,t,i,s=-1,r=0;for(let f=0;f<n.length;++f){const l=n[f];if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=l.normalized),i!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=l.gpuType),s!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=l.count*t}const o=new e(r),a=new A.BufferAttribute(o,t,i);let u=0;for(let f=0;f<n.length;++f){const l=n[f];if(l.isInterleavedBufferAttribute){const c=u/t;for(let p=0,h=l.count;p<h;p++)for(let d=0;d<t;d++){const w=l.getComponent(p,d);a.setComponent(p+c,d,w)}}else o.set(l.array,u);u+=l.count*t}return s!==void 0&&(a.gpuType=s),a}function Et(n){if(n.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),n;let e=n.groups;if(e=e.sort((o,a)=>o.materialIndex!==a.materialIndex?o.materialIndex-a.materialIndex:o.start-a.start),n.getIndex()===null){const o=n.getAttribute("position"),a=[];for(let u=0;u<o.count;u+=3)a.push(u,u+1,u+2);n.setIndex(a)}const t=n.getIndex(),i=[];for(let o=0;o<e.length;o++){const a=e[o],u=a.start,f=u+a.count;for(let l=u;l<f;l++)i.push(t.getX(l))}n.dispose(),n.setIndex(i);let s=0;for(let o=0;o<e.length;o++){const a=e[o];a.start=s,s+=a.count}let r=e[0];n.groups=[r];for(let o=1;o<e.length;o++){const a=e[o];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,n.groups.push(r))}return n}const Se=new A.Vector4,Ke=new A.Vector3,Qe=new A.Vector3,G=new A.Vector4,z=new A.Vector4,k=new A.Vector4,_e=new A.Vector3,Pe=new A.Matrix4,U=new A.Line3,et=new A.Vector3,ye=new A.Box3,ve=new A.Sphere,H=new A.Vector4;let $,ie;function tt(n,e,t){return H.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),H.multiplyScalar(1/H.w),H.x=ie/t.width,H.y=ie/t.height,H.applyMatrix4(n.projectionMatrixInverse),H.multiplyScalar(1/H.w),Math.abs(Math.max(H.x,H.y))}function jt(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,o=Math.min(i.instanceCount,s.count);for(let a=0,u=o;a<u;a++){U.start.fromBufferAttribute(s,a),U.end.fromBufferAttribute(r,a),U.applyMatrix4(t);const f=new A.Vector3,l=new A.Vector3;$.distanceSqToSegment(U.start,U.end,l,f),l.distanceTo(f)<ie*.5&&e.push({point:l,pointOnLine:f,distance:$.origin.distanceTo(l),object:n,face:null,faceIndex:a,uv:null,uv1:null})}}function Gt(n,e,t){const i=e.projectionMatrix,r=n.material.resolution,o=n.matrixWorld,a=n.geometry,u=a.attributes.instanceStart,f=a.attributes.instanceEnd,l=Math.min(a.instanceCount,u.count),c=-e.near;$.at(1,k),k.w=1,k.applyMatrix4(e.matrixWorldInverse),k.applyMatrix4(i),k.multiplyScalar(1/k.w),k.x*=r.x/2,k.y*=r.y/2,k.z=0,_e.copy(k),Pe.multiplyMatrices(e.matrixWorldInverse,o);for(let p=0,h=l;p<h;p++){if(G.fromBufferAttribute(u,p),z.fromBufferAttribute(f,p),G.w=1,z.w=1,G.applyMatrix4(Pe),z.applyMatrix4(Pe),G.z>c&&z.z>c)continue;if(G.z>c){const b=G.z-z.z,L=(G.z-c)/b;G.lerp(z,L)}else if(z.z>c){const b=z.z-G.z,L=(z.z-c)/b;z.lerp(G,L)}G.applyMatrix4(i),z.applyMatrix4(i),G.multiplyScalar(1/G.w),z.multiplyScalar(1/z.w),G.x*=r.x/2,G.y*=r.y/2,z.x*=r.x/2,z.y*=r.y/2,U.start.copy(G),U.start.z=0,U.end.copy(z),U.end.z=0;const w=U.closestPointToPointParameter(_e,!0);U.at(w,et);const M=A.MathUtils.lerp(G.z,z.z,w),T=M>=-1&&M<=1,_=_e.distanceTo(et)<ie*.5;if(T&&_){U.start.fromBufferAttribute(u,p),U.end.fromBufferAttribute(f,p),U.start.applyMatrix4(o),U.end.applyMatrix4(o);const b=new A.Vector3,L=new A.Vector3;$.distanceSqToSegment(U.start,U.end,L,b),t.push({point:L,pointOnLine:b,distance:$.origin.distanceTo(L),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class zt extends A.Mesh{constructor(e=new Ce.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 o=0,a=0,u=t.count;o<u;o++,a+=2)Ke.fromBufferAttribute(t,o),Qe.fromBufferAttribute(i,o),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+Ke.distanceTo(Qe);const r=new A.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new A.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new A.InterleavedBufferAttribute(r,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 r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;$=e.ray;const o=this.matrixWorld,a=this.geometry,u=this.material;ie=u.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),ve.copy(a.boundingSphere).applyMatrix4(o);let f;if(i)f=ie*.5;else{const c=Math.max(s.near,ve.distanceToPoint($.origin));f=tt(s,c,u.resolution)}if(ve.radius+=f,$.intersectsSphere(ve)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),ye.copy(a.boundingBox).applyMatrix4(o);let l;if(i)l=ie*.5;else{const c=Math.max(s.near,ye.distanceToPoint($.origin));l=tt(s,c,u.resolution)}ye.expandByScalar(l),$.intersectsBox(ye)!==!1&&(i?jt(this,t):Gt(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Se),this.material.uniforms.resolution.value.set(Se.z,Se.w))}}const it=n=>{const{points:e}=n,t=e.reduce((s,r,o)=>(o<e.length-1&&s.push(r,e[o+1]),s),[]);return new x.BufferGeometry().setFromPoints(t)};let Ut=class extends se.BaseObject{constructor(e={}){super(),this.options=D({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ce(this,null,function*(){const{points:e,pointsArr:t,geometry:i,geometryArr:s,material:r,useGroups:o,setPointWidth:a,lineWidthArr:u,materialParameters:f,instanceCount:l}=this.options;let c=r,p=i;!c&&f&&(c=this.getMaterial(f)),!p&&e?p=it({points:e}):!p&&t?p=ee(t.map(d=>it({points:d})),o!=null?o:0):!p&&s&&s.length>1?p=ee(s,o!=null?o:0):!p&&s&&s.length===1&&([p]=s);const h=new Ce.LineSegmentsGeometry().fromLineSegments(new x.LineSegments(p));if(this.pencil.options.WebGPUTHREE){l&&(h.instanceCount=l);const d=new zt(h,c);d.computeLineDistances(),this.object3d=d}else{const d=new _t.LineSegments2(h,c);d.computeLineDistances(),this.object3d=d}})}getMaterial(e){return new lt.LineMaterial(D({color:new x.Color("#ffffff")},e))}};function Te(n,e,t,i,s){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,s&&e+s):n.slice(e,s&&e+s):n,t.set)t.set(n,i);else for(r=0;r<n.length;r++)t[r+i]=n[r];return t}function Wt(n){return n instanceof Float32Array?n:n instanceof x.BufferGeometry?n.getAttribute("position").array:n.map(e=>{const t=Array.isArray(e);return e instanceof x.Vector3?[e.x,e.y,e.z]:e instanceof x.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 ct extends x.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new x.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=Wt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof x.Vector3)for(let i=0;i<e.length;i++){const s=e[i],r=i/(e.length-1);this.positions.push(s.x,s.y,s.z),this.positions.push(s.x,s.y,s.z),this.counters.push(r),this.counters.push(r)}else for(let i=0;i<e.length;i+=3){const s=i/(e.length-1);this.positions.push(e[i],e[i+1],e[i+2]),this.positions.push(e[i],e[i+1],e[i+2]),this.counters.push(s),this.counters.push(s)}this.process()}compareV3(e,t){const i=e*6,s=t*6;return this.positions[i]===this.positions[s]&&this.positions[i+1]===this.positions[s+1]&&this.positions[i+2]===this.positions[s+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,i;this.compareV3(0,e-1)?i=this.copyV3(e-2):i=this.copyV3(0),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);for(let s=0;s<e;s++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(s/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(s/(e-1),0),this.uvs.push(s/(e-1),1),s<e-1){i=this.copyV3(s),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);const r=s*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}s>0&&(i=this.copyV3(s),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]))}this.compareV3(e-1,0)?i=this.copyV3(1):i=this.copyV3(e-1),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new x.BufferAttribute(new Float32Array(this.positions),3),previous:new x.BufferAttribute(new Float32Array(this.previous),3),next:new x.BufferAttribute(new Float32Array(this.next),3),side:new x.BufferAttribute(new Float32Array(this.side),1),width:new x.BufferAttribute(new Float32Array(this.width),1),uv:new x.BufferAttribute(new Float32Array(this.uvs),2),index:new x.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new x.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:e,y:t,z:i}){const s=this._attributes.position.array,r=this._attributes.previous.array,o=this._attributes.next.array,a=s.length;Te(s,0,r,0,a),Te(s,6,s,0,a-6),s[a-6]=e,s[a-5]=t,s[a-4]=i,s[a-3]=e,s[a-2]=t,s[a-1]=i,Te(s,6,o,0,a-6),o[a-6]=e,o[a-5]=t,o[a-4]=i,o[a-3]=e,o[a-2]=t,o[a-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const st=["encodings_fragment","colorspace_fragment"],Ot=`
|
|
1
|
+
"use strict";var bt=Object.defineProperty,xt=Object.defineProperties;var wt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Je=Math.pow,He=(n,e,t)=>e in n?bt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,R=(n,e)=>{for(var t in e||(e={}))$e.call(e,t)&&He(n,t,e[t]);if(ye)for(var t of ye(e))Ze.call(e,t)&&He(n,t,e[t]);return n},Me=(n,e)=>xt(n,wt(e));var Se=(n,e)=>{var t={};for(var i in n)$e.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&ye)for(var i of ye(n))e.indexOf(i)<0&&Ze.call(n,i)&&(t[i]=n[i]);return t};var he=(n,e,t)=>new Promise((i,s)=>{var r=l=>{try{o(t.next(l))}catch(h){s(h)}},a=l=>{try{o(t.throw(l))}catch(h){s(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(r,a);o((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("../BaseObject.js"),At=require("../index2.js"),A=require("three"),Mt=require("@tweenjs/tween.js"),St=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),_t=require("three/examples/jsm/lines/LineSegments2"),Ee=require("three/examples/jsm/lines/LineSegmentsGeometry"),lt=require("three/examples/jsm/lines/LineMaterial"),ae=require("d3-array"),Be=require("earcut"),Pt=require("@turf/boolean-clockwise"),Ie=require("../uvGenerator.js"),Tt=require("delaunator"),Vt=require("@turf/boolean-point-in-polygon"),fe=require("d3-geo"),Lt=require("d3-geo-voronoi"),Xe=require("d3-scale");function ut(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const x=ut(A),le=ut(Mt);class Bt extends re.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=R({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),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(),i=window.innerWidth,s=window.innerHeight;let r=0,a=0;t.left<0?r=-t.left:t.right>i&&(r=i-t.right),t.top<0?a=-t.top:t.bottom>s&&(a=s-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(i=>{i.forEach(s=>{s.isIntersecting&&(this.moveElementToViewport(),t.disconnect())})});t.observe(e)}onPointerEvent(e,t){const i=this.drawController.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){this.onNodePointerIndex.forEach(e=>{this.drawController.removePickNode(e)}),super.dispose()}}class It extends re.BaseObject{constructor(e){super(),this.options=R({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return he(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:i,material:s,percentDepth:r,activeIndex:a}=this.options,o=Math.max(...e),l=e.reduce((u,c)=>u+c,0);let h=Math.PI/2;e.forEach((u,c)=>{if(u===0)return;const d=Math.PI*2*(u/l),f=i[c],p=r?t*(u/o):t,b=this.createGeometry(p,d),w=s?s.clone():new x.MeshBasicMaterial({color:f});s&&w.color.set(f);const _=new x.Mesh(b,w);_.userData.depth=p,_.userData.index=c,_.rotateZ(h),h+=d,this.add(_)}),a!==-1&&this.setActive(a)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new x.Shape;return r.moveTo(i,0),r.lineTo(s,0),r.absarc(0,0,s,0,t,!1),r.absarc(0,0,i,t,0,!0),new x.ExtrudeGeometry(r,{curveSegments:48,depth:e,bevelEnabled:!1})}handlePick(e,t=1.3){const{object:i}=this.pencil.pick(e,this.object3d.children)||{},s=i?this.object3d.children.findIndex(r=>r===i):this.options.activeIndex;return this.setActive(s,t)}setActive(e,t=1.3){const i=this.object3d.children[e];if(this.object3d.children.forEach(s=>{if(!(i&&i===s)&&s.scale.z!==1){if(s.userData.levTween)return;s.userData.enTween&&(s.userData.enTween.stop(),s.userData.enTween=null);const r=new le.Tween(s.scale).to({z:1},100);s.userData.levTween=r,r.start()}}),i){if(i.userData.enTween)return;i.userData.levTween&&(i.userData.levTween.stop(),i.userData.levTween=null);const s=new le.Tween(i.scale).to({z:t},100);return i.userData.enTween=s,s.start(),i.userData.index}return-1}render(){this.object3d.scale.z=0,new le.Tween(this.object3d.scale).to({z:1},1e3).easing(le.Easing.Sinusoidal.InOut).start()}}class Ct extends re.BaseObject{constructor(e){super(),this.rectAreaLightUniformsLibInit=!1,this.options=e}create(){var t,i,s,r,a,o,l,h,u,c,d,f,p,b,w,_,C;const e=this.options;if(e.type==="AmbientLight"){const M=new x.AmbientLight(e.color);M.name="环境光",this.object3d=M}else if(e.type==="DirectionalLight"){const M=new x.DirectionalLight(e.color,e.intensity);M.name="平行光",M.target.position.set(0,0,0),this.object3d=M,M.target.name="平行光目标",M.shadow.camera.name="平行光阴影相机",M.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=M}else if(e.type==="PointLight"){const M=new x.PointLight((t=e.color)!=null?t:16777215,(i=e.intensity)!=null?i:1,(s=e.distance)!=null?s:0,(r=e.decay)!=null?r:2);M.name="点光源",this.object3d=M,this.pointLight=M}else if(e.type==="SpotLight"){const M=new x.SpotLight((a=e.color)!=null?a:16777215,(o=e.intensity)!=null?o:1,(l=e.distance)!=null?l:0,(h=e.angle)!=null?h:Math.PI/3,(u=e.penumbra)!=null?u:1,(c=e.decay)!=null?c:2);M.name="聚光灯",this.object3d=M,this.spotLight=M,M.target.name="聚光灯目标"}else if(e.type==="HemisphereLight"){const M=new x.HemisphereLight((d=e.color)!=null?d:16777215,(f=e.groundColor)!=null?f:16777215,(p=e.intensity)!=null?p:1);M.name="半球光",this.object3d=M,this.hemisphereLight=M}else if(e.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(St.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const M=new x.RectAreaLight((b=e.color)!=null?b:16777215,(w=e.intensity)!=null?w:1,(_=e.width)!=null?_:10,(C=e.height)!=null?C:10);M.name="矩形区域光",this.object3d=M,this.rectAreaLight=M}}render(){const e=this.object3d;e.target&&this.pencil.scene.add(e.target);const t=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const i=this.spotLight||this.directionalLight;i.position.copy(t),i.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 te(n,e=0){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},a={},o=n[0].morphTargetsRelative,l=new A.BufferGeometry;let h=0;for(let u=0;u<n.length;++u){const c=n[u];let d=0;if(t!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in c.attributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(c.attributes[f]),d++}if(d!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in c.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[f]===void 0&&(a[f]=[]),a[f].push(c.morphAttributes[f])}if(e){let f;if(t)f=c.index.count;else if(c.attributes.position!==void 0)f=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;if(e===1)l.addGroup(h,f,u);else if(e===2&&c.groups.length>0)for(let p of c.groups){let b=p.materialIndex;l.addGroup(h+p.start,Math.min(p.count,f),b)}h+=f}}if(t){let u=0;const c=[];for(let d=0;d<n.length;++d){const f=n[d].index;for(let p=0;p<f.count;++p)c.push(f.getX(p)+u);u+=n[d].attributes.position.count}l.setIndex(c)}for(const u in r){const c=Ye(r[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(const u in a){const c=a[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){const f=[];for(let b=0;b<a[u].length;++b)f.push(a[u][b][d]);const p=Ye(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(p)}}return e===2?Et(l):l}function Ye(n){let e,t,i,s=-1,r=0;for(let h=0;h<n.length;++h){const u=n[h];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=u.itemSize),t!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=u.normalized),i!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=u.count*t}const a=new e(r),o=new A.BufferAttribute(a,t,i);let l=0;for(let h=0;h<n.length;++h){const u=n[h];if(u.isInterleavedBufferAttribute){const c=l/t;for(let d=0,f=u.count;d<f;d++)for(let p=0;p<t;p++){const b=u.getComponent(d,p);o.setComponent(d+c,p,b)}}else a.set(u.array,l);l+=u.count*t}return s!==void 0&&(o.gpuType=s),o}function Et(n){if(n.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),n;let e=n.groups;if(e=e.sort((a,o)=>a.materialIndex!==o.materialIndex?a.materialIndex-o.materialIndex:a.start-o.start),n.getIndex()===null){const a=n.getAttribute("position"),o=[];for(let l=0;l<a.count;l+=3)o.push(l,l+1,l+2);n.setIndex(o)}const t=n.getIndex(),i=[];for(let a=0;a<e.length;a++){const o=e[a],l=o.start,h=l+o.count;for(let u=l;u<h;u++)i.push(t.getX(u))}n.dispose(),n.setIndex(i);let s=0;for(let a=0;a<e.length;a++){const o=e[a];o.start=s,s+=o.count}let r=e[0];n.groups=[r];for(let a=1;a<e.length;a++){const o=e[a];r.materialIndex===o.materialIndex?r.count+=o.count:(r=o,n.groups.push(r))}return n}const _e=new A.Vector4,Ke=new A.Vector3,Qe=new A.Vector3,U=new A.Vector4,W=new A.Vector4,$=new A.Vector4,Pe=new A.Vector3,Te=new A.Matrix4,O=new A.Line3,et=new A.Vector3,ve=new A.Box3,be=new A.Sphere,Z=new A.Vector4;let J,ne;function tt(n,e,t){return Z.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),Z.multiplyScalar(1/Z.w),Z.x=ne/t.width,Z.y=ne/t.height,Z.applyMatrix4(n.projectionMatrixInverse),Z.multiplyScalar(1/Z.w),Math.abs(Math.max(Z.x,Z.y))}function Gt(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,a=Math.min(i.instanceCount,s.count);for(let o=0,l=a;o<l;o++){O.start.fromBufferAttribute(s,o),O.end.fromBufferAttribute(r,o),O.applyMatrix4(t);const h=new A.Vector3,u=new A.Vector3;J.distanceSqToSegment(O.start,O.end,u,h),u.distanceTo(h)<ne*.5&&e.push({point:u,pointOnLine:h,distance:J.origin.distanceTo(u),object:n,face:null,faceIndex:o,uv:null,uv1:null})}}function jt(n,e,t){const i=e.projectionMatrix,r=n.material.resolution,a=n.matrixWorld,o=n.geometry,l=o.attributes.instanceStart,h=o.attributes.instanceEnd,u=Math.min(o.instanceCount,l.count),c=-e.near;J.at(1,$),$.w=1,$.applyMatrix4(e.matrixWorldInverse),$.applyMatrix4(i),$.multiplyScalar(1/$.w),$.x*=r.x/2,$.y*=r.y/2,$.z=0,Pe.copy($),Te.multiplyMatrices(e.matrixWorldInverse,a);for(let d=0,f=u;d<f;d++){if(U.fromBufferAttribute(l,d),W.fromBufferAttribute(h,d),U.w=1,W.w=1,U.applyMatrix4(Te),W.applyMatrix4(Te),U.z>c&&W.z>c)continue;if(U.z>c){const M=U.z-W.z,E=(U.z-c)/M;U.lerp(W,E)}else if(W.z>c){const M=W.z-U.z,E=(W.z-c)/M;W.lerp(U,E)}U.applyMatrix4(i),W.applyMatrix4(i),U.multiplyScalar(1/U.w),W.multiplyScalar(1/W.w),U.x*=r.x/2,U.y*=r.y/2,W.x*=r.x/2,W.y*=r.y/2,O.start.copy(U),O.start.z=0,O.end.copy(W),O.end.z=0;const b=O.closestPointToPointParameter(Pe,!0);O.at(b,et);const w=A.MathUtils.lerp(U.z,W.z,b),_=w>=-1&&w<=1,C=Pe.distanceTo(et)<ne*.5;if(_&&C){O.start.fromBufferAttribute(l,d),O.end.fromBufferAttribute(h,d),O.start.applyMatrix4(a),O.end.applyMatrix4(a);const M=new A.Vector3,E=new A.Vector3;J.distanceSqToSegment(O.start,O.end,E,M),t.push({point:E,pointOnLine:M,distance:J.origin.distanceTo(E),object:n,face:null,faceIndex:d,uv:null,uv1:null})}}}class zt extends A.Mesh{constructor(e=new Ee.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 a=0,o=0,l=t.count;a<l;a++,o+=2)Ke.fromBufferAttribute(t,a),Qe.fromBufferAttribute(i,a),s[o]=o===0?0:s[o-1],s[o+1]=s[o]+Ke.distanceTo(Qe);const r=new A.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new A.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new A.InterleavedBufferAttribute(r,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 r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;J=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;ne=l.linewidth+r,o.boundingSphere===null&&o.computeBoundingSphere(),be.copy(o.boundingSphere).applyMatrix4(a);let h;if(i)h=ne*.5;else{const c=Math.max(s.near,be.distanceToPoint(J.origin));h=tt(s,c,l.resolution)}if(be.radius+=h,J.intersectsSphere(be)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),ve.copy(o.boundingBox).applyMatrix4(a);let u;if(i)u=ne*.5;else{const c=Math.max(s.near,ve.distanceToPoint(J.origin));u=tt(s,c,l.resolution)}ve.expandByScalar(u),J.intersectsBox(ve)!==!1&&(i?Gt(this,t):jt(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(_e),this.material.uniforms.resolution.value.set(_e.z,_e.w))}}const it=n=>{const{points:e}=n,t=e.reduce((s,r,a)=>(a<e.length-1&&s.push(r,e[a+1]),s),[]);return new x.BufferGeometry().setFromPoints(t)};let Ut=class extends re.BaseObject{constructor(e={}){super(),this.options=R({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return he(this,null,function*(){const{points:e,pointsArr:t,geometry:i,geometryArr:s,material:r,useGroups:a,setPointWidth:o,lineWidthArr:l,materialParameters:h,instanceCount:u}=this.options;let c=r,d=i;!c&&h&&(c=this.getMaterial(h)),!d&&e?d=it({points:e}):!d&&t?d=te(t.map(p=>it({points:p})),a!=null?a:0):!d&&s&&s.length>1?d=te(s,a!=null?a:0):!d&&s&&s.length===1&&([d]=s);const f=new Ee.LineSegmentsGeometry().fromLineSegments(new x.LineSegments(d));if(this.pencil.options.WebGPUTHREE){u&&(f.instanceCount=u);const p=new zt(f,c);p.computeLineDistances(),this.object3d=p}else{const p=new _t.LineSegments2(f,c);p.computeLineDistances(),this.object3d=p}})}getMaterial(e){return new lt.LineMaterial(R({color:new x.Color("#ffffff")},e))}};function Ve(n,e,t,i,s){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,s&&e+s):n.slice(e,s&&e+s):n,t.set)t.set(n,i);else for(r=0;r<n.length;r++)t[r+i]=n[r];return t}function Wt(n){return n instanceof Float32Array?n:n instanceof x.BufferGeometry?n.getAttribute("position").array:n.map(e=>{const t=Array.isArray(e);return e instanceof x.Vector3?[e.x,e.y,e.z]:e instanceof x.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 ct extends x.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new x.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=Wt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof x.Vector3)for(let i=0;i<e.length;i++){const s=e[i],r=i/(e.length-1);this.positions.push(s.x,s.y,s.z),this.positions.push(s.x,s.y,s.z),this.counters.push(r),this.counters.push(r)}else for(let i=0;i<e.length;i+=3){const s=i/(e.length-1);this.positions.push(e[i],e[i+1],e[i+2]),this.positions.push(e[i],e[i+1],e[i+2]),this.counters.push(s),this.counters.push(s)}this.process()}compareV3(e,t){const i=e*6,s=t*6;return this.positions[i]===this.positions[s]&&this.positions[i+1]===this.positions[s+1]&&this.positions[i+2]===this.positions[s+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,i;this.compareV3(0,e-1)?i=this.copyV3(e-2):i=this.copyV3(0),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);for(let s=0;s<e;s++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(s/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(s/(e-1),0),this.uvs.push(s/(e-1),1),s<e-1){i=this.copyV3(s),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);const r=s*2;this.indices_array.push(r,r+1,r+2),this.indices_array.push(r+2,r+1,r+3)}s>0&&(i=this.copyV3(s),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]))}this.compareV3(e-1,0)?i=this.copyV3(1):i=this.copyV3(e-1),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new x.BufferAttribute(new Float32Array(this.positions),3),previous:new x.BufferAttribute(new Float32Array(this.previous),3),next:new x.BufferAttribute(new Float32Array(this.next),3),side:new x.BufferAttribute(new Float32Array(this.side),1),width:new x.BufferAttribute(new Float32Array(this.width),1),uv:new x.BufferAttribute(new Float32Array(this.uvs),2),index:new x.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new x.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:e,y:t,z:i}){const s=this._attributes.position.array,r=this._attributes.previous.array,a=this._attributes.next.array,o=s.length;Ve(s,0,r,0,o),Ve(s,6,s,0,o-6),s[o-6]=e,s[o-5]=t,s[o-4]=i,s[o-3]=e,s[o-2]=t,s[o-1]=i,Ve(s,6,a,0,o-6),a[o-6]=e,a[o-5]=t,a[o-4]=i,a[o-3]=e,a[o-2]=t,a[o-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const st=["encodings_fragment","colorspace_fragment"],Ot=`
|
|
2
2
|
#include <common>
|
|
3
3
|
#include <logdepthbuf_pars_vertex>
|
|
4
4
|
#include <fog_pars_vertex>
|
|
@@ -143,4 +143,4 @@
|
|
|
143
143
|
#include <tonemapping_fragment>
|
|
144
144
|
#include <${+x.REVISION<154?st[0]:st[1]}>
|
|
145
145
|
}
|
|
146
|
-
`;class ht extends x.ShaderMaterial{constructor(e){super({uniforms:Ae(D({},x.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new x.Color(16777215)},opacity:{value:1},resolution:{value:new x.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 x.Vector2(1,1)},offset:{value:new x.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new x.Vector2(0,0)},lightColor:{value:new x.Color(16777215)}}),vertexShader:Ot,fragmentShader:Dt}),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 Rt(n,e){const t=new x.Matrix4,i=new x.Ray,s=new x.Sphere,r=new x.Vector3,o=this.geometry;if(s.copy(o.boundingSphere),s.applyMatrix4(this.matrixWorld),!n.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(t);const a=new x.Vector3,u=new x.Vector3,f=new x.Vector3,l=this instanceof x.LineSegments?2:1,c=o.index,p=o.attributes;if(c!==null){const h=c.array,d=p.position.array,w=p.width.array;for(let M=0,T=h.length-1;M<T;M+=l){const _=h[M],b=h[M+1];a.fromArray(d,_*3),u.fromArray(d,b*3);const L=w[Math.floor(M/3)]!=null?w[Math.floor(M/3)]:1,E=n.params.Line.threshold+this.material.lineWidth*L/2,C=E*E;if(i.distanceSqToSegment(a,u,r,f)>C)continue;r.applyMatrix4(this.matrixWorld);const W=n.ray.origin.distanceTo(r);W<n.near||W>n.far||(e.push({distance:W,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:void 0,object:this}),M=T)}}}const Ve=n=>{const{setPointWidth:e,nodes:t}=n,i=new ct;return i.setPoints(t,e),i};class Nt extends se.BaseObject{constructor(e={}){super(),this.options=D({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return ce(this,null,function*(){const{nodes:e,nodesArr:t,geometry:i,geometryArr:s,material:r,useGroups:o,setPointWidth:a,lineWidthArr:u,materialParameters:f}=this.options;let l=r,c=i;!l&&f&&(l=this.getMaterial(f)),!c&&e?c=Ve({nodes:e,setPointWidth:a}):!c&&t?c=ee(t.map((p,h)=>{let d=a;return!d&&u&&(d=()=>{var w;return(w=u[h])!=null?w:u[0]}),Ve({nodes:p,setPointWidth:d})}),o!=null?o:0):!c&&s&&s.length>1?c=ee(s,o!=null?o:0):!c&&s&&s.length===1&&([c]=s),this.createMesh(c,l)})}setGeometry(e,t){const i=Ve({nodes:e,setPointWidth:t}),s=this.object3d,r=s.geometry;s.geometry=i,r.dispose()}getMaterial(e){const{width:t,height:i}=this.pencil.getSize();return new ht(D({color:new x.Color("#ffffff"),resolution:new x.Vector2(t,i)},e))}addGeometries(e){const t=this.object3d,i=ee([t.geometry,...e]);t.geometry=i}resize(e,t){var i,s;(s=(i=this.material)==null?void 0:i.uniforms)==null||s.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:i}=this.pencil.getSize();this.resize(t,i)}animate({duration:e=1e3,delay:t=0,repeat:i=0,lineLoop:s,onRepeat:r,onUpdate:o,onComplete:a}={}){const{offset:u,offsetLoop:f}=this.material.uniforms;if(this.material.userData.tween)return;const l=s!=null?s:!0;u.value.x=1,f.value=0;let c=0;const p=new oe.Tween(u.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:h})=>{l&&h<=0&&f.value===0&&(f.value=1),o&&o(h)}).onRepeat(()=>{c+=1,r&&r(c)}).onComplete(()=>{a&&a()}).start();this.material.userData.tween=p}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),oe.remove(this.material.userData.tween)),super.dispose()}}function qt(n,e){return n.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const o=he.geoDistance(r,s)*180/Math.PI;if(o>e){const a=he.geoInterpolate(s,r),u=1/Math.ceil(o/e);let f=u;for(;f<1;)i.push(a(f)),f+=u}}i.push(s=r)}),i})}function Ft(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Je(360/n,2)/Math.PI),o=(1+Math.sqrt(5))/2,a=h=>h/o*360%360-180,u=h=>Math.acos(2*h/r-1)/Math.PI*180-90,f=h=>r*(Math.cos((h+90)*Math.PI/180)+1)/2,l=[s!==void 0?Math.ceil(f(s)):0,i!==void 0?Math.floor(f(i)):r-1],c=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,p=[];for(let h=l[0];h<=l[1];h++){const d=a(h);c(d)&&p.push([d,u(h)])}return p}function Ie(n,e,t=!1){return t?he.geoContains(e,n):Vt(n,e)}function kt(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[r,o]]=he.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(o-s))<e)return[];const a=i>r||o>=89||s<=-89;return Ft(e,{minLng:i,maxLng:r,minLat:s,maxLat:o}).filter(u=>Ie(u,t,a))}function Ht(n,{resolution:e=1/0,bbox:t}={}){const i=qt(n,e),s=re.merge(i),r=kt(n,e),o=[...s,...r],a={type:"Polygon",coordinates:n},[[u,f],[l,c]]=he.geoBounds(a),p=u>l||c>=89||f<=-89;let h=[];if(p){const _=Lt.geoVoronoi(o).triangles(),b=new Map(o.map(([L,E],C)=>[`${L}-${E}`,C]));_.features.forEach(L=>{const E=L.geometry.coordinates[0].slice(0,3).reverse(),C=[];if(E.forEach(([B,W])=>{const q=`${B}-${W}`;b.has(q)&&C.push(b.get(q))}),C.length===3){if(C.some(B=>B<s.length)){const B=L.properties.circumcenter;if(!Ie(B,a,p))return}h.push(...C)}})}else if(r.length){const _=Tt.from(o);for(let b=0,L=_.triangles.length;b<L;b+=3){const E=[2,1,0].map(B=>_.triangles[b+B]),C=E.map(B=>o[B]);if(E.some(B=>B<s.length)){const B=[0,1].map(W=>re.mean(C,q=>q[W]));if(!Ie(B,a,p))continue}h.push(...E)}}else{const{vertices:_,holes:b=[]}=Le.flatten(i);h=Le(_,b,2)}const d=Xe.scaleLinear(t?[t[0],t[2]]:re.extent(o,_=>_[0]),[0,1]),w=Xe.scaleLinear(t?[t[1],t[3]]:re.extent(o,_=>_[1]),[0,1]),M=o.map(([_,b])=>[d(_),w(b)]);return{contour:i,triangles:{points:o,indices:h,uvs:M}}}const nt=new x.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function be(n,e,t,i){const s=n.map(r=>r.map(([o,a])=>{if(i){const[u,f]=i([o,a]);return[u,-f,e]}return t?Be.polar2Cartesian(o,a,e):[o,a,e]}));return Le.flatten(s)}function $t(n,e,t,i,s){const{vertices:r,holes:o}=be(n,e,i,s),{vertices:a}=be(n,t,i,s),u=re.merge([a,r]),f=Math.round(a.length/3),l=new Set(o);let c=0;const p=[];for(let d=0;d<f;d++){let w=d+1;if(w===f)w=c;else if(l.has(w)){const M=w;w=c,c=M}p.push(d,d+f,w+f),p.push(w+f,w,d)}const h=[];for(let d=1;d>=0;d--)for(let w=0;w<f;w+=1)h.push(w/(f-1),d);return{indices:p,vertices:u,uvs:h,topVerts:a}}function rt(n,e,t,i,s,r){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:be([n.points],e,s,r).vertices,uvs:t}}const ft=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:o=!1,hasTop:a=!1,projection:u,bbox:f})=>{n.forEach(T=>{Pt(T)||T.reverse()});const{contour:l,triangles:c}=Ht(n,{resolution:i,bbox:f});let p={},h;r&&(p=$t(l,e!=null?e:t,t!=null?t:e,s,u),h=p.topVerts);let d=[];(o||a)&&(d=re.merge(c.uvs));let w={};o&&(w=rt(c,e,d,!1,s,u));let M={};return a&&(M=rt(c,t,d,!0,s,u)),{contour:l,triangles:c,sideTorso:p,bottomCap:w,topCap:M,topVerts:h}};class pt extends x.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=D({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:r,hasBottom:o,hasSide:a,cartesian:u,userDataRsoOffset:f,projection:l}=this.parameters,{contour:c,sideTorso:p,topVerts:h,bottomCap:d,topCap:w}=ft(D({},this.parameters));let M=[],T=[],_=[],b=0;const L=E=>{const C=Math.round(M.length/3),B=_.length;M=M.concat(E.vertices),T=T.concat(E.uvs),_=_.concat(C?E.indices.map(W=>W+C):E.indices),this.addGroup(B,_.length-B,b++)};s&&r&&L(w),a&&(L(p),this.userData.topVerts=f?be(c,i+f,u,l).vertices:h),o&&L(d),s&&!r&&L(w),this.setIndex(_),this[nt]("position",new x.Float32BufferAttribute(M,3)),this[nt]("uv",new x.Float32BufferAttribute(T,2)),this.computeVertexNormals()}}const ot=n=>{const a=n,{coordinate:e,startHeight:t,height:i}=a,s=Me(a,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(r=t+i),new pt([e],Ae(D({},s),{startHeight:t,endHeight:r}))};class Zt extends se.BaseObject{constructor(e){super(),this.options=D({},e)}create(){const u=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=u,o=Me(u,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&i)a=ot(D({coordinate:i},o));else if(!a&&t){const f=t.map(l=>ot(D({coordinate:l},o)));a=ee(f,r!=null?r:0)}this.createMesh(a,s)}}class Ee extends A.BufferGeometry{constructor(e=new A.Shape([new A.Vector2(.5,.5),new A.Vector2(-.5,.5),new A.Vector2(-.5,-.5),new A.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,s=[],r=[];for(let a=0,u=e.length;a<u;a++){const f=e[a];o(f)}this.setAttribute("position",new A.Float32BufferAttribute(s,3)),this.setAttribute("uv",new A.Float32BufferAttribute(r,2)),this.computeVertexNormals();function o(a){var We,Oe,De;const u=[],f=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,c=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,h=t.bevelThickness!==void 0?t.bevelThickness:.2,d=t.bevelSize!==void 0?t.bevelSize:h-.1,w=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const T=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Jt,b=(We=t.hasTop)!=null?We:!0,L=(Oe=t.hasBottom)!=null?Oe:!0,E=(De=t.hasSide)!=null?De:!0;let C,B=!1,W,q,ae,Z;T&&(C=T.getSpacedPoints(l),B=!0,p=!1,W=T.computeFrenetFrames(l,!1),q=new A.Vector3,ae=new A.Vector3,Z=new A.Vector3),p||(M=0,h=0,d=0,w=0);const je=a.extractPoints(f);let N=je.shape;const R=je.holes;if(!A.ShapeUtils.isClockWise(N)){N=N.reverse();for(let m=0,g=R.length;m<g;m++){const y=R[m];A.ShapeUtils.isClockWise(y)&&(R[m]=y.reverse())}}const le=A.ShapeUtils.triangulateShape(N,R),F=N;for(let m=0,g=R.length;m<g;m++){const y=R[m];N=N.concat(y)}function ne(m,g,y){return g||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(g,y)}const J=N.length,fe=le.length;function Ge(m,g,y){let S,v,P;const V=m.x-g.x,I=m.y-g.y,O=y.x-m.x,j=y.y-m.y,ue=V*V+I*I,we=V*j-I*O;if(Math.abs(we)>Number.EPSILON){const Q=Math.sqrt(ue),Re=Math.sqrt(O*O+j*j),Ne=g.x-I/Q,qe=g.y+V/Q,yt=y.x-j/Re,vt=y.y+O/Re,Fe=((yt-Ne)*j-(vt-qe)*O)/(V*j-I*O);S=Ne+V*Fe-m.x,v=qe+I*Fe-m.y;const ke=S*S+v*v;if(ke<=2)return new A.Vector2(S,v);P=Math.sqrt(ke/2)}else{let Q=!1;V>Number.EPSILON?O>Number.EPSILON&&(Q=!0):V<-Number.EPSILON?O<-Number.EPSILON&&(Q=!0):Math.sign(I)===Math.sign(j)&&(Q=!0),Q?(S=-I,v=V,P=Math.sqrt(ue)):(S=V,v=I,P=Math.sqrt(ue/2))}return new A.Vector2(S/P,v/P)}const pe=[];for(let m=0,g=F.length,y=g-1,S=m+1;m<g;m++,y++,S++)y===g&&(y=0),S===g&&(S=0),pe[m]=Ge(F[m],F[y],F[S]);const xe=[];let te,de=pe.concat();for(let m=0,g=R.length;m<g;m++){const y=R[m];te=[];for(let S=0,v=y.length,P=v-1,V=S+1;S<v;S++,P++,V++)P===v&&(P=0),V===v&&(V=0),te[S]=Ge(y[S],y[P],y[V]);xe.push(te),de=de.concat(te)}for(let m=0;m<M;m++){const g=m/M,y=h*Math.cos(g*Math.PI/2),S=d*Math.sin(g*Math.PI/2)+w;for(let v=0,P=F.length;v<P;v++){const V=ne(F[v],pe[v],S);X(V.x,V.y,-y)}for(let v=0,P=R.length;v<P;v++){const V=R[v];te=xe[v];for(let I=0,O=V.length;I<O;I++){const j=ne(V[I],te[I],S);X(j.x,j.y,-y)}}}const ze=d+w;for(let m=0;m<J;m++){const g=p?ne(N[m],de[m],ze):N[m];B?(ae.copy(W.normals[0]).multiplyScalar(g.x),q.copy(W.binormals[0]).multiplyScalar(g.y),Z.copy(C[0]).add(ae).add(q),X(Z.x,Z.y,Z.z)):X(g.x,g.y,0)}for(let m=1;m<=l;m++)for(let g=0;g<J;g++){const y=p?ne(N[g],de[g],ze):N[g];B?(ae.copy(W.normals[m]).multiplyScalar(y.x),q.copy(W.binormals[m]).multiplyScalar(y.y),Z.copy(C[m]).add(ae).add(q),X(Z.x,Z.y,Z.z)):X(y.x,y.y,c/l*m)}for(let m=M-1;m>=0;m--){const g=m/M,y=h*Math.cos(g*Math.PI/2),S=d*Math.sin(g*Math.PI/2)+w;for(let v=0,P=F.length;v<P;v++){const V=ne(F[v],pe[v],S);X(V.x,V.y,c+y)}for(let v=0,P=R.length;v<P;v++){const V=R[v];te=xe[v];for(let I=0,O=V.length;I<O;I++){const j=ne(V[I],te[I],S);B?X(j.x,j.y+C[l-1].y,C[l-1].x+y):X(j.x,j.y,c+y)}}}dt(),E&&mt();function dt(){const m=s.length/3;if(p){let g=0,y=J*g;if(L)for(let S=0;S<fe;S++){const v=le[S];me(v[2]+y,v[1]+y,v[0]+y)}if(g=l+M*2,y=J*g,b)for(let S=0;S<fe;S++){const v=le[S];me(v[0]+y,v[1]+y,v[2]+y)}}else{if(L)for(let g=0;g<fe;g++){const y=le[g];me(y[2],y[1],y[0])}if(b)for(let g=0;g<fe;g++){const y=le[g];me(y[0]+J*l,y[1]+J*l,y[2]+J*l)}}i.addGroup(m,s.length/3-m,0)}function mt(){const m=s.length/3;let g=0;Ue(F,g),g+=F.length;for(let y=0,S=R.length;y<S;y++){const v=R[y];Ue(v,g),g+=v.length}i.addGroup(m,s.length/3-m,1)}function Ue(m,g){let y=m.length;for(;--y>=0;){const S=y;let v=y-1;v<0&&(v=m.length-1);for(let P=0,V=l+M*2;P<V;P++){const I=J*P,O=J*(P+1),j=g+S+I,ue=g+v+I,we=g+v+O,Q=g+S+O;gt(j,ue,we,Q)}}}function X(m,g,y){u.push(m),u.push(g),u.push(y)}function me(m,g,y){Y(m),Y(g),Y(y);const S=s.length/3,v=_.generateTopUV(i,s,S-3,S-2,S-1);K(v[0]),K(v[1]),K(v[2])}function gt(m,g,y,S){Y(m),Y(g),Y(S),Y(g),Y(y),Y(S);const v=s.length/3,P=_.generateSideWallUV(i,s,v-6,v-3,v-2,v-1);K(P[0]),K(P[1]),K(P[3]),K(P[1]),K(P[2]),K(P[3])}function Y(m){s.push(u[m*3+0]),s.push(u[m*3+1]),s.push(u[m*3+2])}function K(m){r.push(m.x),r.push(m.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return Xt(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];i.push(a)}const s=e.options.extrudePath;return console.log(s.type),s!==void 0&&(e.options.extrudePath=new x[`${s.type}Curve`]().fromJSON(s)),new Ee(i,e.options)}}const Jt={generateTopUV:function(n,e,t,i,s){const r=e[t*3],o=e[t*3+1],a=e[i*3],u=e[i*3+1],f=e[s*3],l=e[s*3+1];return[new A.Vector2(r,o),new A.Vector2(a,u),new A.Vector2(f,l)]},generateSideWallUV:function(n,e,t,i,s,r){const o=e[t*3],a=e[t*3+1],u=e[t*3+2],f=e[i*3],l=e[i*3+1],c=e[i*3+2],p=e[s*3],h=e[s*3+1],d=e[s*3+2],w=e[r*3],M=e[r*3+1],T=e[r*3+2];return Math.abs(a-l)<Math.abs(o-f)?[new A.Vector2(o,1-u),new A.Vector2(f,1-c),new A.Vector2(p,1-d),new A.Vector2(w,1-T)]:[new A.Vector2(a,1-u),new A.Vector2(l,1-c),new A.Vector2(h,1-d),new A.Vector2(M,1-T)]}};function Xt(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,s=n.length;i<s;i++){const r=n[i];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}const at=n=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:o,hasSide:a,sideRepeat:u}=n,f=new Ee(new x.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:Be.getUVGenerator({split:e,box3:s,sideRepeat:u}),hasTop:r,hasBottom:o,hasSide:a});return Be.claerUVGenerator(),f};class Yt extends se.BaseObject{constructor(e){super(),this.options=D({depth:1},e)}create(){return ce(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:o,material:a,box3:u,split:f,hasTop:l,hasBottom:c,hasSide:p}=this.options,h=Array.isArray(s)?s:[s],d=Array.isArray(u)?u:[u],w=a;let M=r;w||console.log("material is null"),!M&&e?M=at({points:e,depth:h[0],box3:d[0],split:f,hasTop:l,hasBottom:c,hasSide:p}):!M&&t?M=ee(t.map((T,_)=>{var b,L;return at({points:T,depth:(b=h[_])!=null?b:h[0],box3:(L=d[_])!=null?L:d[0],split:f,hasTop:l,hasBottom:c,hasSide:p})}),i!=null?i:0):!M&&o&&o.length>1?M=ee(o,i!=null?i:0):!M&&o&&o.length===1&&([M]=o),this.createMesh(M,w)})}addGeometries(e){const t=this.object3d,i=ee([t.geometry,...e]);t.geometry=i}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Kt=n=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:o}=n;return new Promise(a=>{const u=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};u.onload=()=>{const f=r,l=document.createElement("canvas"),c=l.getContext("2d");l.height=u.height/(1-f),l.width=u.width,f&&e&&(c.fillStyle=e,c.fillRect(0,0,u.width,l.height*f)),i&&u instanceof HTMLImageElement?c.drawImage(u,0,l.height*f,u.width,u.height):t&&(c.fillStyle=t,c.fillRect(0,l.height*f,u.width,u.height)),s&&l.toBlob(h=>{console.log(URL.createObjectURL(h))});const p=new x.CanvasTexture(l);a(p)},i?u.src=i:u instanceof HTMLImageElement||u.onload()})};exports.Group=At.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ce.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>lt.LineMaterial});exports.ConicPolygon=Zt;exports.ExtrudePolygon=Yt;exports.Light=Ct;exports.Line=Nt;exports.Line2=Ut;exports.MeshLineGeometry=ct;exports.MeshLineMaterial=ht;exports.MeshLineRaycast=Rt;exports.Node=Bt;exports.Pie=It;exports.getConicPolygonGeometry=pt;exports.getConicPolygonGeometryMetas=ft;exports.getSplitTexture=Kt;
|
|
146
|
+
`;class ht extends x.ShaderMaterial{constructor(e){super({uniforms:Me(R({},x.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new x.Color(16777215)},opacity:{value:1},resolution:{value:new x.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 x.Vector2(1,1)},offset:{value:new x.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new x.Vector2(0,0)},lightColor:{value:new x.Color(16777215)}}),vertexShader:Ot,fragmentShader:Dt}),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 Rt(n,e){const t=new x.Matrix4,i=new x.Ray,s=new x.Sphere,r=new x.Vector3,a=this.geometry;if(s.copy(a.boundingSphere),s.applyMatrix4(this.matrixWorld),!n.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(t);const o=new x.Vector3,l=new x.Vector3,h=new x.Vector3,u=this instanceof x.LineSegments?2:1,c=a.index,d=a.attributes;if(c!==null){const f=c.array,p=d.position.array,b=d.width.array;for(let w=0,_=f.length-1;w<_;w+=u){const C=f[w],M=f[w+1];o.fromArray(p,C*3),l.fromArray(p,M*3);const E=b[Math.floor(w/3)]!=null?b[Math.floor(w/3)]:1,V=n.params.Line.threshold+this.material.lineWidth*E/2,L=V*V;if(i.distanceSqToSegment(o,l,r,h)>L)continue;r.applyMatrix4(this.matrixWorld);const B=n.ray.origin.distanceTo(r);B<n.near||B>n.far||(e.push({distance:B,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:void 0,object:this}),w=_)}}}const Le=n=>{const{setPointWidth:e,nodes:t}=n,i=new ct;return i.setPoints(t,e),i};class Nt extends re.BaseObject{constructor(e={}){super(),this.options=R({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return he(this,null,function*(){const{nodes:e,nodesArr:t,geometry:i,geometryArr:s,material:r,useGroups:a,setPointWidth:o,lineWidthArr:l,materialParameters:h}=this.options;let u=r,c=i;!u&&h&&(u=this.getMaterial(h)),!c&&e?c=Le({nodes:e,setPointWidth:o}):!c&&t?c=te(t.map((d,f)=>{let p=o;return!p&&l&&(p=()=>{var b;return(b=l[f])!=null?b:l[0]}),Le({nodes:d,setPointWidth:p})}),a!=null?a:0):!c&&s&&s.length>1?c=te(s,a!=null?a:0):!c&&s&&s.length===1&&([c]=s),this.createMesh(c,u)})}setGeometry(e,t){const i=Le({nodes:e,setPointWidth:t}),s=this.object3d,r=s.geometry;s.geometry=i,r.dispose()}getMaterial(e){const{width:t,height:i}=this.pencil.getSize();return new ht(R({color:new x.Color("#ffffff"),resolution:new x.Vector2(t,i)},e))}addGeometries(e){const t=this.object3d,i=te([t.geometry,...e]);t.geometry=i}resize(e,t){var i,s;(s=(i=this.material)==null?void 0:i.uniforms)==null||s.resolution.value.set(e,t)}useMaterial(e){super.useMaterial(e);const{width:t,height:i}=this.pencil.getSize();this.resize(t,i)}animate({duration:e=1e3,delay:t=0,repeat:i=0,lineLoop:s,onRepeat:r,onUpdate:a,onComplete:o}={}){const{offset:l,offsetLoop:h}=this.material.uniforms;if(this.material.userData.tween)return;const u=s!=null?s:!0;l.value.x=1,h.value=0;let c=0;const d=new le.Tween(l.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:f})=>{u&&f<=0&&h.value===0&&(h.value=1),a&&a(f)}).onRepeat(()=>{c+=1,r&&r(c)}).onComplete(()=>{o&&o()}).start();this.material.userData.tween=d}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),le.remove(this.material.userData.tween)),super.dispose()}}function qt(n,e){return n.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const a=fe.geoDistance(r,s)*180/Math.PI;if(a>e){const o=fe.geoInterpolate(s,r),l=1/Math.ceil(a/e);let h=l;for(;h<1;)i.push(o(h)),h+=l}}i.push(s=r)}),i})}function Ft(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Je(360/n,2)/Math.PI),a=(1+Math.sqrt(5))/2,o=f=>f/a*360%360-180,l=f=>Math.acos(2*f/r-1)/Math.PI*180-90,h=f=>r*(Math.cos((f+90)*Math.PI/180)+1)/2,u=[s!==void 0?Math.ceil(h(s)):0,i!==void 0?Math.floor(h(i)):r-1],c=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,d=[];for(let f=u[0];f<=u[1];f++){const p=o(f);c(p)&&d.push([p,l(f)])}return d}function Ce(n,e,t=!1){return t?fe.geoContains(e,n):Vt(n,e)}function kt(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[r,a]]=fe.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(a-s))<e)return[];const o=i>r||a>=89||s<=-89;return Ft(e,{minLng:i,maxLng:r,minLat:s,maxLat:a}).filter(l=>Ce(l,t,o))}function Ht(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=qt(n,e),r=ae.merge(s),a=kt(n,e),o=[...r,...a],l={type:"Polygon",coordinates:n},[[h,u],[c,d]]=fe.geoBounds(l),f=h>c||d>=89||u<=-89;let p=[];if(f){const V=Lt.geoVoronoi(o).triangles(),L=new Map(o.map(([G,B],N)=>[`${G}-${B}`,N]));V.features.forEach(G=>{const B=G.geometry.coordinates[0].slice(0,3).reverse(),N=[];if(B.forEach(([j,F])=>{const se=`${j}-${F}`;L.has(se)&&N.push(L.get(se))}),N.length===3){if(N.some(j=>j<r.length)){const j=G.properties.circumcenter;if(!Ce(j,l,f))return}p.push(...N)}})}else if(a.length){const V=Tt.from(o);for(let L=0,G=V.triangles.length;L<G;L+=3){const B=[2,1,0].map(j=>V.triangles[L+j]),N=B.map(j=>o[j]);if(B.some(j=>j<r.length)){const j=[0,1].map(F=>ae.mean(N,se=>se[F]));if(!Ce(j,l,f))continue}p.push(...B)}}else{const{vertices:V,holes:L=[]}=Be.flatten(s);p=Be(V,L,2)}let b=t?[t[0],t[2]]:ae.extent(o,V=>V[0]),w=t?[t[1],t[3]]:ae.extent(o,V=>V[1]);if(i){const[V,L]=i([b[0],w[0]]),[G,B]=i([b[1],w[1]]);b=[V,G],w=[-L,-B]}const _=Xe.scaleLinear(b,[0,1]),C=Xe.scaleLinear(w,[0,1]),M=o.map(([V,L])=>{if(i){const[G,B]=i([V,L]);return[_(G),C(-B)]}else return[_(V),C(L)]});return{contour:s,triangles:{points:o,indices:p,uvs:M}}}const nt=new x.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function xe(n,e,t,i){const s=n.map(r=>r.map(([a,o])=>{if(i){const[l,h]=i([a,o]);return[l,-h,e]}return t?Ie.polar2Cartesian(a,o,e):[a,o,e]}));return Be.flatten(s)}function $t(n,e,t,i,s){const{vertices:r,holes:a}=xe(n,e,i,s),{vertices:o}=xe(n,t,i,s),l=ae.merge([o,r]),h=Math.round(o.length/3),u=new Set(a);let c=0;const d=[];for(let p=0;p<h;p++){let b=p+1;if(b===h)b=c;else if(u.has(b)){const w=b;b=c,c=w}d.push(p,p+h,b+h),d.push(b+h,b,p)}const f=[];for(let p=1;p>=0;p--)for(let b=0;b<h;b+=1)f.push(b/(h-1),p);return{indices:d,vertices:l,uvs:f,topVerts:o}}function rt(n,e,t,i,s,r){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:xe([n.points],e,s,r).vertices,uvs:t}}const ft=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:a=!1,hasTop:o=!1,projection:l,bbox:h})=>{n.forEach(_=>{Pt(_)||_.reverse()});const{contour:u,triangles:c}=Ht(n,{resolution:i,bbox:h,projection:l});let d={},f;r&&(d=$t(u,e!=null?e:t,t!=null?t:e,s,l),f=d.topVerts);let p=[];(a||o)&&(p=ae.merge(c.uvs));let b={};a&&(b=rt(c,e,p,!1,s,l));let w={};return o&&(w=rt(c,t,p,!0,s,l)),{contour:u,triangles:c,sideTorso:d,bottomCap:b,topCap:w,topVerts:f}};class dt extends x.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=R({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:r,hasBottom:a,hasSide:o,cartesian:l,userDataRsoOffset:h,projection:u}=this.parameters,{contour:c,sideTorso:d,topVerts:f,bottomCap:p,topCap:b}=ft(R({},this.parameters));let w=[],_=[],C=[],M=0;const E=V=>{const L=Math.round(w.length/3),G=C.length;w=w.concat(V.vertices),_=_.concat(V.uvs),C=C.concat(L?V.indices.map(B=>B+L):V.indices),this.addGroup(G,C.length-G,M++)};s&&r&&E(b),o&&(E(d),this.userData.topVerts=h?xe(c,i+h,l,u).vertices:f),a&&E(p),s&&!r&&E(b),this.setIndex(C),this[nt]("position",new x.Float32BufferAttribute(w,3)),this[nt]("uv",new x.Float32BufferAttribute(_,2)),this.computeVertexNormals()}}const ot=n=>{const o=n,{coordinate:e,startHeight:t,height:i}=o,s=Se(o,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(r=t+i),new dt([e],Me(R({},s),{startHeight:t,endHeight:r}))};class Zt extends re.BaseObject{constructor(e){super(),this.options=R({},e)}create(){const l=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=l,a=Se(l,["geometry","coordinateArr","coordinate","material","useGroups"]);let o=e;if(!o&&i)o=ot(R({coordinate:i},a));else if(!o&&t){const h=t.map(u=>ot(R({coordinate:u},a)));o=te(h,r!=null?r:0)}this.createMesh(o,s)}}class Ge extends A.BufferGeometry{constructor(e=new A.Shape([new A.Vector2(.5,.5),new A.Vector2(-.5,.5),new A.Vector2(-.5,-.5),new A.Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,s=[],r=[];for(let o=0,l=e.length;o<l;o++){const h=e[o];a(h)}this.setAttribute("position",new A.Float32BufferAttribute(s,3)),this.setAttribute("uv",new A.Float32BufferAttribute(r,2)),this.computeVertexNormals();function a(o){var We,Oe,De;const l=[],h=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,c=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,b=t.bevelOffset!==void 0?t.bevelOffset:0,w=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:Jt,M=(We=t.hasTop)!=null?We:!0,E=(Oe=t.hasBottom)!=null?Oe:!0,V=(De=t.hasSide)!=null?De:!0;let L,G=!1,B,N,j,F;_&&(L=_.getSpacedPoints(u),G=!0,d=!1,B=_.computeFrenetFrames(u,!1),N=new A.Vector3,j=new A.Vector3,F=new A.Vector3),d||(w=0,f=0,p=0,b=0);const se=o.extractPoints(h);let k=se.shape;const q=se.holes;if(!A.ShapeUtils.isClockWise(k)){k=k.reverse();for(let m=0,g=q.length;m<g;m++){const y=q[m];A.ShapeUtils.isClockWise(y)&&(q[m]=y.reverse())}}const ue=A.ShapeUtils.triangulateShape(k,q),H=k;for(let m=0,g=q.length;m<g;m++){const y=q[m];k=k.concat(y)}function oe(m,g,y){return g||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(g,y)}const X=k.length,de=ue.length;function je(m,g,y){let S,v,P;const T=m.x-g.x,I=m.y-g.y,D=y.x-m.x,z=y.y-m.y,ce=T*T+I*I,Ae=T*z-I*D;if(Math.abs(Ae)>Number.EPSILON){const ee=Math.sqrt(ce),Re=Math.sqrt(D*D+z*z),Ne=g.x-I/ee,qe=g.y+T/ee,yt=y.x-z/Re,vt=y.y+D/Re,Fe=((yt-Ne)*z-(vt-qe)*D)/(T*z-I*D);S=Ne+T*Fe-m.x,v=qe+I*Fe-m.y;const ke=S*S+v*v;if(ke<=2)return new A.Vector2(S,v);P=Math.sqrt(ke/2)}else{let ee=!1;T>Number.EPSILON?D>Number.EPSILON&&(ee=!0):T<-Number.EPSILON?D<-Number.EPSILON&&(ee=!0):Math.sign(I)===Math.sign(z)&&(ee=!0),ee?(S=-I,v=T,P=Math.sqrt(ce)):(S=T,v=I,P=Math.sqrt(ce/2))}return new A.Vector2(S/P,v/P)}const pe=[];for(let m=0,g=H.length,y=g-1,S=m+1;m<g;m++,y++,S++)y===g&&(y=0),S===g&&(S=0),pe[m]=je(H[m],H[y],H[S]);const we=[];let ie,me=pe.concat();for(let m=0,g=q.length;m<g;m++){const y=q[m];ie=[];for(let S=0,v=y.length,P=v-1,T=S+1;S<v;S++,P++,T++)P===v&&(P=0),T===v&&(T=0),ie[S]=je(y[S],y[P],y[T]);we.push(ie),me=me.concat(ie)}for(let m=0;m<w;m++){const g=m/w,y=f*Math.cos(g*Math.PI/2),S=p*Math.sin(g*Math.PI/2)+b;for(let v=0,P=H.length;v<P;v++){const T=oe(H[v],pe[v],S);Y(T.x,T.y,-y)}for(let v=0,P=q.length;v<P;v++){const T=q[v];ie=we[v];for(let I=0,D=T.length;I<D;I++){const z=oe(T[I],ie[I],S);Y(z.x,z.y,-y)}}}const ze=p+b;for(let m=0;m<X;m++){const g=d?oe(k[m],me[m],ze):k[m];G?(j.copy(B.normals[0]).multiplyScalar(g.x),N.copy(B.binormals[0]).multiplyScalar(g.y),F.copy(L[0]).add(j).add(N),Y(F.x,F.y,F.z)):Y(g.x,g.y,0)}for(let m=1;m<=u;m++)for(let g=0;g<X;g++){const y=d?oe(k[g],me[g],ze):k[g];G?(j.copy(B.normals[m]).multiplyScalar(y.x),N.copy(B.binormals[m]).multiplyScalar(y.y),F.copy(L[m]).add(j).add(N),Y(F.x,F.y,F.z)):Y(y.x,y.y,c/u*m)}for(let m=w-1;m>=0;m--){const g=m/w,y=f*Math.cos(g*Math.PI/2),S=p*Math.sin(g*Math.PI/2)+b;for(let v=0,P=H.length;v<P;v++){const T=oe(H[v],pe[v],S);Y(T.x,T.y,c+y)}for(let v=0,P=q.length;v<P;v++){const T=q[v];ie=we[v];for(let I=0,D=T.length;I<D;I++){const z=oe(T[I],ie[I],S);G?Y(z.x,z.y+L[u-1].y,L[u-1].x+y):Y(z.x,z.y,c+y)}}}pt(),V&&mt();function pt(){const m=s.length/3;if(d){let g=0,y=X*g;if(E)for(let S=0;S<de;S++){const v=ue[S];ge(v[2]+y,v[1]+y,v[0]+y)}if(g=u+w*2,y=X*g,M)for(let S=0;S<de;S++){const v=ue[S];ge(v[0]+y,v[1]+y,v[2]+y)}}else{if(E)for(let g=0;g<de;g++){const y=ue[g];ge(y[2],y[1],y[0])}if(M)for(let g=0;g<de;g++){const y=ue[g];ge(y[0]+X*u,y[1]+X*u,y[2]+X*u)}}i.addGroup(m,s.length/3-m,0)}function mt(){const m=s.length/3;let g=0;Ue(H,g),g+=H.length;for(let y=0,S=q.length;y<S;y++){const v=q[y];Ue(v,g),g+=v.length}i.addGroup(m,s.length/3-m,1)}function Ue(m,g){let y=m.length;for(;--y>=0;){const S=y;let v=y-1;v<0&&(v=m.length-1);for(let P=0,T=u+w*2;P<T;P++){const I=X*P,D=X*(P+1),z=g+S+I,ce=g+v+I,Ae=g+v+D,ee=g+S+D;gt(z,ce,Ae,ee)}}}function Y(m,g,y){l.push(m),l.push(g),l.push(y)}function ge(m,g,y){K(m),K(g),K(y);const S=s.length/3,v=C.generateTopUV(i,s,S-3,S-2,S-1);Q(v[0]),Q(v[1]),Q(v[2])}function gt(m,g,y,S){K(m),K(g),K(S),K(g),K(y),K(S);const v=s.length/3,P=C.generateSideWallUV(i,s,v-6,v-3,v-2,v-1);Q(P[0]),Q(P[1]),Q(P[3]),Q(P[1]),Q(P[2]),Q(P[3])}function K(m){s.push(l[m*3+0]),s.push(l[m*3+1]),s.push(l[m*3+2])}function Q(m){r.push(m.x),r.push(m.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return Xt(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,a=e.shapes.length;r<a;r++){const o=t[e.shapes[r]];i.push(o)}const s=e.options.extrudePath;return console.log(s.type),s!==void 0&&(e.options.extrudePath=new x[`${s.type}Curve`]().fromJSON(s)),new Ge(i,e.options)}}const Jt={generateTopUV:function(n,e,t,i,s){const r=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],h=e[s*3],u=e[s*3+1];return[new A.Vector2(r,a),new A.Vector2(o,l),new A.Vector2(h,u)]},generateSideWallUV:function(n,e,t,i,s,r){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],h=e[i*3],u=e[i*3+1],c=e[i*3+2],d=e[s*3],f=e[s*3+1],p=e[s*3+2],b=e[r*3],w=e[r*3+1],_=e[r*3+2];return Math.abs(o-u)<Math.abs(a-h)?[new A.Vector2(a,1-l),new A.Vector2(h,1-c),new A.Vector2(d,1-p),new A.Vector2(b,1-_)]:[new A.Vector2(o,1-l),new A.Vector2(u,1-c),new A.Vector2(f,1-p),new A.Vector2(w,1-_)]}};function Xt(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,s=n.length;i<s;i++){const r=n[i];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}const at=n=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:a,hasSide:o,sideRepeat:l}=n,h=new Ge(new x.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:Ie.getUVGenerator({split:e,box3:s,sideRepeat:l}),hasTop:r,hasBottom:a,hasSide:o});return Ie.claerUVGenerator(),h};class Yt extends re.BaseObject{constructor(e){super(),this.options=R({depth:1},e)}create(){return he(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:a,material:o,box3:l,split:h,hasTop:u,hasBottom:c,hasSide:d}=this.options,f=Array.isArray(s)?s:[s],p=Array.isArray(l)?l:[l],b=o;let w=r;b||console.log("material is null"),!w&&e?w=at({points:e,depth:f[0],box3:p[0],split:h,hasTop:u,hasBottom:c,hasSide:d}):!w&&t?w=te(t.map((_,C)=>{var M,E;return at({points:_,depth:(M=f[C])!=null?M:f[0],box3:(E=p[C])!=null?E:p[0],split:h,hasTop:u,hasBottom:c,hasSide:d})}),i!=null?i:0):!w&&a&&a.length>1?w=te(a,i!=null?i:0):!w&&a&&a.length===1&&([w]=a),this.createMesh(w,b)})}addGeometries(e){const t=this.object3d,i=te([t.geometry,...e]);t.geometry=i}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Kt=n=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:a}=n;return new Promise(o=>{const l=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};l.onload=()=>{const h=r,u=document.createElement("canvas"),c=u.getContext("2d");u.height=l.height/(1-h),u.width=l.width,h&&e&&(c.fillStyle=e,c.fillRect(0,0,l.width,u.height*h)),i&&l instanceof HTMLImageElement?c.drawImage(l,0,u.height*h,l.width,l.height):t&&(c.fillStyle=t,c.fillRect(0,u.height*h,l.width,l.height)),s&&u.toBlob(f=>{console.log(URL.createObjectURL(f))});const d=new x.CanvasTexture(u);o(d)},i?l.src=i:l instanceof HTMLImageElement||l.onload()})};exports.Group=At.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ee.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>lt.LineMaterial});exports.ConicPolygon=Zt;exports.ExtrudePolygon=Yt;exports.Light=Ct;exports.Line=Nt;exports.Line2=Ut;exports.MeshLineGeometry=ct;exports.MeshLineMaterial=ht;exports.MeshLineRaycast=Rt;exports.Node=Bt;exports.Pie=It;exports.getConicPolygonGeometry=dt;exports.getConicPolygonGeometryMetas=ft;exports.getSplitTexture=Kt;
|