gl-draw 0.10.21 → 0.10.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/objects/index.js +2 -2
- package/dist/objects/index.module.js +312 -323
- package/dist/objects/node/index.d.ts +3 -5
- package/dist/plugins/Draw.d.ts +4 -0
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +92 -66
- package/package.json +1 -1
package/dist/objects/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var wt=Object.defineProperty,At=Object.defineProperties;var Mt=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Je=Math.pow,He=(o,e,t)=>e in o?wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,E=(o,e)=>{for(var t in e||(e={}))$e.call(e,t)&&He(o,t,e[t]);if(ge)for(var t of ge(e))Ze.call(e,t)&&He(o,t,e[t]);return o},Ae=(o,e)=>At(o,Mt(e));var Me=(o,e)=>{var t={};for(var i in o)$e.call(o,i)&&e.indexOf(i)<0&&(t[i]=o[i]);if(o!=null&&ge)for(var i of ge(o))e.indexOf(i)<0&&Ze.call(o,i)&&(t[i]=o[i]);return t};var se=(o,e,t)=>new Promise((i,s)=>{var r=c=>{try{a(t.next(c))}catch(u){s(u)}},n=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,n);a((t=t.apply(o,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("three"),te=require("../BaseObject.js"),St=require("esus-lite"),_t=require("../index2.js"),Pt=require("@tweenjs/tween.js"),Vt=require("three/examples/jsm/lines/LineSegments2"),je=require("three/examples/jsm/lines/LineSegmentsGeometry"),lt=require("three/examples/jsm/lines/LineMaterial"),oe=require("d3-array"),Be=require("earcut"),Tt=require("@turf/boolean-clockwise"),Le=require("../uvGenerator.js"),Bt=require("delaunator"),Lt=require("@turf/boolean-point-in-polygon"),he=require("d3-geo"),Ct=require("d3-geo-voronoi"),Xe=require("d3-scale");function ct(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const y=ct(w),ae=ct(Pt),jt=+y.REVISION<144,ut=jt?"PlaneBufferGeometry":"PlaneGeometry";class ht extends te.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=E({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return se(this,null,function*(){const{src:e,texture:t,transparent:i,opacity:s,blending:r,depthWrite:n,depthTest:a,alphaTest:c,sprite:u,sizeAttenuation:l,color:h}=this.options,p=t||(yield new y.TextureLoader().loadAsync(e));return u?new y.SpriteMaterial({map:p,transparent:i!=null?i:!1,blending:r!=null?r:y.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:s!=null?s:1,sizeAttenuation:l!=null?l:!0}):new y.MeshBasicMaterial({color:h!=null?h:16777215,map:p,transparent:i!=null?i:!1,blending:r!=null?r:y.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:s!=null?s:1})})}create(){return se(this,null,function*(){const{position:e,material:t,sprite:i}=this.options,s=t||(yield this.getMaterial());i?this.createSprite(s):this.createMesh(new y[ut](1,1),s),e&&this.object3d.position.copy(e)})}render(){const{scale:e}=this.options;this.setScale(e)}setScale(e){this.scaleValue=e;const t=this.material.map;t!=null&&t.image?this.object3d.scale.set(t.image.width*e,t.image.height*e,1):this.object3d.scale.set(e,e,1)}setTexture(e){const t=this.object3d;t.material.map&&t.material.map.dispose(),t.material.map=e,t.material.needsUpdate=!0,this.setScale(this.scaleValue)}}class Et extends ht{constructor(e){super(e),this.canvas=document.createElement("canvas")}getTexture(){const{text:e,textOptions:t}=this.options,{fontSize:i,fontFamily:s,fontWeight:r,flipX:n,color:a,setCtx:c}=E({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:f=>{}},t||{}),{canvas:u}=this;u.width=i*e.length*2,u.height=i;let l=u.getContext("2d");l.font=`${r} ${i}px/1 ${s}`;const{width:h}=l.measureText(e);u.width=h,l=u.getContext("2d"),l.clearRect(0,0,u.width,u.height),n&&l.scale(-1,1),l.font=`${r} ${i}px/1 ${s}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(e,n?h*-1:0,u.height/2),l.restore();const p=new y.Texture(u);return p.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),p.needsUpdate=!0,Promise.resolve(p)}}class Gt extends te.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=E({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:i,depthWrite:s,depthTest:r,format:n,autoPlay:a,loop:c,alphaTest:u,sprite:l}=this.options,h=St.makePromiseCreator();if(!e)return Promise.reject("src is required");const p=document.createElement("video");return p.addEventListener("loadedmetadata",()=>{const f=new y.VideoTexture(p);f.format=n!=null?n:y.RGBAFormat,f.needsUpdate=!0;const d=l?new y.SpriteMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:y.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:u!=null?u:0}):new y.MeshBasicMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:y.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:u!=null?u:0});h.resolve(d)},!1),p.src=e,p.muted=!0,p.autoplay=a,p.loop=c,p.preload="auto",h.promise}create(){return se(this,null,function*(){const{scale:e,position:t,src:i,cache:s,sprite:r}=this.options,n=i&&(s?yield s.get(i,()=>this.getMaterial()):yield this.getMaterial());this.video=n.map.image,r?this.createSprite(n):this.createMesh(new y[ut](1,1),n),this.setScale(e),t&&this.object3d.position.copy(t)})}setScale(e){this.scaleValue=e,this.object3d.scale.set(this.video.videoWidth*e,this.video.videoHeight*e,1)}render(){const{autoPlay:e}=this.options;e&&this.video.play()}dispose(){this.video.pause(),this.video.src="",super.dispose()}}class It extends te.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.options=E({event:"click",type:"2d"},e)}get clickTarge(){const{eventTarge:e}=this.options;return e?e.map(i=>[...this.element.querySelectorAll(i)]).flat():[this.element]}create(){const{position:e,children:t,handler:i,event:s}=this.options,r=document.createElement("div");this.element=r,t&&r.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(r):this.options.type==="3dSprite"?this.createCSS3DSprite(r):this.createCSS2DObject(r),e&&this.object3d.position.copy(e),i&&s&&this.clickTarge.forEach(n=>{const a=Array.isArray(s)?s:[s],c=Array.isArray(i)?i:[i];a.forEach((u,l)=>{const h=c[l];h&&n.addEventListener(u,h)})})}setChildren(e){this.element.innerHTML="",this.element.appendChild(e)}render(){this.checkVisible()}show(){return this.visibleCache=!0,this.checkVisible(),this}hide(){return this.visibleCache=!1,this.checkVisible(),this}checkVisible(){this.drawGroupShow&&this.visibleCache?super.show():(!this.drawGroupShow||!this.visibleCache)&&super.hide()}dispose(){const{handler:e,event:t}=this.options;e&&t&&this.clickTarge.forEach(i=>{const s=Array.isArray(t)?t:[t],r=Array.isArray(e)?e:[e];s.forEach((n,a)=>{const c=r[a];c&&i.removeEventListener(n,c)})}),super.dispose()}}class zt extends te.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:i,material:s,percentDepth:r,activeIndex:n}=this.options,a=Math.max(...e),c=e.reduce((l,h)=>l+h,0);let u=Math.PI/2;e.forEach((l,h)=>{if(l===0)return;const p=Math.PI*2*(l/c),f=i[h],d=r?t*(l/a):t,m=this.createGeometry(d,p),A=s?s.clone():new y.MeshBasicMaterial({color:f});s&&A.color.set(f);const V=new y.Mesh(m,A);V.userData.depth=d,V.userData.index=h,V.rotateZ(u),u+=p,this.add(V)}),n!==-1&&this.setActive(n)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new y.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 y.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 ae.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 ae.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 ae.Tween(this.object3d.scale).to({z:1},1e3).easing(ae.Easing.Sinusoidal.InOut).start()}}class Ut extends te.BaseObject{constructor(e){super(),this.options=e}create(){var t,i,s,r,n,a,c,u,l,h,p,f,d;const e=this.options;if(e.type==="AmbientLight"){const m=new y.AmbientLight(e.color);m.name="AmbientLight",this.object3d=m}else if(e.type==="DirectionalLight"){const m=new y.DirectionalLight(e.color,e.intensity);m.name="DirectionalLight",m.target.position.set(0,0,0),this.object3d=m,this.pencil.scene.add(m.target),this.directionalLight=m}else if(e.type==="PointLight"){const m=new y.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="PointLight",this.object3d=m,this.pointLight=m}else if(e.type==="SpotLight"){const m=new y.SpotLight((n=e.color)!=null?n:16777215,(a=e.intensity)!=null?a:1,(c=e.distance)!=null?c:0,(u=e.angle)!=null?u:Math.PI/3,(l=e.penumbra)!=null?l:1,(h=e.decay)!=null?h:2);m.name="SpotLight",this.object3d=m,this.spotLight=m,this.pencil.scene.add(m.target)}else if(e.type==="HemisphereLight"){const m=new y.HemisphereLight((p=e.color)!=null?p:16777215,(f=e.groundColor)!=null?f:16777215,(d=e.intensity)!=null?d:1);m.name="HemisphereLight",this.object3d=m,this.hemisphereLight=m}}render(){const e=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const t=this.spotLight||this.directionalLight;t.position.copy(e),t.target.position.copy(e)}else this.pointLight&&this.pointLight.position.copy(e)}dispose(){const e=this.object3d;e.target&&this.pencil.scene.remove(e.target),super.dispose()}}function ee(o,e=0){const t=o[0].index!==null,i=new Set(Object.keys(o[0].attributes)),s=new Set(Object.keys(o[0].morphAttributes)),r={},n={},a=o[0].morphTargetsRelative,c=new w.BufferGeometry;let u=0;for(let l=0;l<o.length;++l){const h=o[l];let p=0;if(t!==(h.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 f in h.attributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. 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(h.attributes[f]),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!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;n[f]===void 0&&(n[f]=[]),n[f].push(h.morphAttributes[f])}if(e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.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)c.addGroup(u,f,l);else if(e===2&&h.groups.length>0)for(let d of h.groups){let m=d.materialIndex;c.addGroup(u+d.start,Math.min(d.count,f),m)}u+=f}}if(t){let l=0;const h=[];for(let p=0;p<o.length;++p){const f=o[p].index;for(let d=0;d<f.count;++d)h.push(f.getX(d)+l);l+=o[p].attributes.position.count}c.setIndex(h)}for(const l in r){const h=Ke(r[l]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;c.setAttribute(l,h)}for(const l in n){const h=n[l][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let p=0;p<h;++p){const f=[];for(let m=0;m<n[l].length;++m)f.push(n[l][m][p]);const d=Ke(f);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;c.morphAttributes[l].push(d)}}return e===2?Ot(c):c}function Ke(o){let e,t,i,s=-1,r=0;for(let u=0;u<o.length;++u){const l=o[u];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 n=new e(r),a=new w.BufferAttribute(n,t,i);let c=0;for(let u=0;u<o.length;++u){const l=o[u];if(l.isInterleavedBufferAttribute){const h=c/t;for(let p=0,f=l.count;p<f;p++)for(let d=0;d<t;d++){const m=l.getComponent(p,d);a.setComponent(p+h,d,m)}}else n.set(l.array,c);c+=l.count*t}return s!==void 0&&(a.gpuType=s),a}function Ot(o){if(o.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),o;let e=o.groups;if(e=e.sort((n,a)=>n.materialIndex!==a.materialIndex?n.materialIndex-a.materialIndex:n.start-a.start),o.getIndex()===null){const n=o.getAttribute("position"),a=[];for(let c=0;c<n.count;c+=3)a.push(c,c+1,c+2);o.setIndex(a)}const t=o.getIndex(),i=[];for(let n=0;n<e.length;n++){const a=e[n],c=a.start,u=c+a.count;for(let l=c;l<u;l++)i.push(t.getX(l))}o.dispose(),o.setIndex(i);let s=0;for(let n=0;n<e.length;n++){const a=e[n];a.start=s,s+=a.count}let r=e[0];o.groups=[r];for(let n=1;n<e.length;n++){const a=e[n];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,o.groups.push(r))}return o}const Se=new w.Vector4,Qe=new w.Vector3,Ye=new w.Vector3,I=new w.Vector4,z=new w.Vector4,F=new w.Vector4,_e=new w.Vector3,Pe=new w.Matrix4,U=new w.Line3,et=new w.Vector3,ye=new w.Box3,ve=new w.Sphere,H=new w.Vector4;let $,re;function tt(o,e,t){return H.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),H.multiplyScalar(1/H.w),H.x=re/t.width,H.y=re/t.height,H.applyMatrix4(o.projectionMatrixInverse),H.multiplyScalar(1/H.w),Math.abs(Math.max(H.x,H.y))}function Wt(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,n=Math.min(i.instanceCount,s.count);for(let a=0,c=n;a<c;a++){U.start.fromBufferAttribute(s,a),U.end.fromBufferAttribute(r,a),U.applyMatrix4(t);const u=new w.Vector3,l=new w.Vector3;$.distanceSqToSegment(U.start,U.end,l,u),l.distanceTo(u)<re*.5&&e.push({point:l,pointOnLine:u,distance:$.origin.distanceTo(l),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function Dt(o,e,t){const i=e.projectionMatrix,r=o.material.resolution,n=o.matrixWorld,a=o.geometry,c=a.attributes.instanceStart,u=a.attributes.instanceEnd,l=Math.min(a.instanceCount,c.count),h=-e.near;$.at(1,F),F.w=1,F.applyMatrix4(e.matrixWorldInverse),F.applyMatrix4(i),F.multiplyScalar(1/F.w),F.x*=r.x/2,F.y*=r.y/2,F.z=0,_e.copy(F),Pe.multiplyMatrices(e.matrixWorldInverse,n);for(let p=0,f=l;p<f;p++){if(I.fromBufferAttribute(c,p),z.fromBufferAttribute(u,p),I.w=1,z.w=1,I.applyMatrix4(Pe),z.applyMatrix4(Pe),I.z>h&&z.z>h)continue;if(I.z>h){const _=I.z-z.z,T=(I.z-h)/_;I.lerp(z,T)}else if(z.z>h){const _=z.z-I.z,T=(z.z-h)/_;z.lerp(I,T)}I.applyMatrix4(i),z.applyMatrix4(i),I.multiplyScalar(1/I.w),z.multiplyScalar(1/z.w),I.x*=r.x/2,I.y*=r.y/2,z.x*=r.x/2,z.y*=r.y/2,U.start.copy(I),U.start.z=0,U.end.copy(z),U.end.z=0;const m=U.closestPointToPointParameter(_e,!0);U.at(m,et);const A=w.MathUtils.lerp(I.z,z.z,m),V=A>=-1&&A<=1,B=_e.distanceTo(et)<re*.5;if(V&&B){U.start.fromBufferAttribute(c,p),U.end.fromBufferAttribute(u,p),U.start.applyMatrix4(n),U.end.applyMatrix4(n);const _=new w.Vector3,T=new w.Vector3;$.distanceSqToSegment(U.start,U.end,T,_),t.push({point:T,pointOnLine:_,distance:$.origin.distanceTo(T),object:o,face:null,faceIndex:p,uv:null,uv1:null})}}}class Rt extends w.Mesh{constructor(e=new je.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 n=0,a=0,c=t.count;n<c;n++,a+=2)Qe.fromBufferAttribute(t,n),Ye.fromBufferAttribute(i,n),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+Qe.distanceTo(Ye);const r=new w.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new w.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new w.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 n=this.matrixWorld,a=this.geometry,c=this.material;re=c.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),ve.copy(a.boundingSphere).applyMatrix4(n);let u;if(i)u=re*.5;else{const h=Math.max(s.near,ve.distanceToPoint($.origin));u=tt(s,h,c.resolution)}if(ve.radius+=u,$.intersectsSphere(ve)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),ye.copy(a.boundingBox).applyMatrix4(n);let l;if(i)l=re*.5;else{const h=Math.max(s.near,ye.distanceToPoint($.origin));l=tt(s,h,c.resolution)}ye.expandByScalar(l),$.intersectsBox(ye)!==!1&&(i?Wt(this,t):Dt(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=o=>{const{points:e}=o,t=e.reduce((s,r,n)=>(n<e.length-1&&s.push(r,e[n+1]),s),[]);return new y.BufferGeometry().setFromPoints(t)};let kt=class extends te.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:i,geometryArr:s,material:r,useGroups:n,setPointWidth:a,lineWidthArr:c,materialParameters:u,instanceCount:l}=this.options;let h=r,p=i;!h&&u&&(h=this.getMaterial(u)),!p&&e?p=it({points:e}):!p&&t?p=ee(t.map(d=>it({points:d})),n!=null?n:0):!p&&s&&s.length>1?p=ee(s,n!=null?n:0):!p&&s&&s.length===1&&([p]=s);const f=new je.LineSegmentsGeometry().fromLineSegments(new y.LineSegments(p));if(this.pencil.options.WebGPUTHREE){l&&(f.instanceCount=l);const d=new Rt(f,h);d.computeLineDistances(),this.object3d=d}else{const d=new Vt.LineSegments2(f,h);d.computeLineDistances(),this.object3d=d}})}getMaterial(e){return new lt.LineMaterial(E({color:new y.Color("#ffffff")},e))}};function Ve(o,e,t,i,s){let r;if(o=o.subarray||o.slice?o:o.buffer,t=t.subarray||t.slice?t:t.buffer,o=e?o.subarray?o.subarray(e,s&&e+s):o.slice(e,s&&e+s):o,t.set)t.set(o,i);else for(r=0;r<o.length;r++)t[r+i]=o[r];return t}function qt(o){return o instanceof Float32Array?o:o instanceof y.BufferGeometry?o.getAttribute("position").array:o.map(e=>{const t=Array.isArray(e);return e instanceof y.Vector3?[e.x,e.y,e.z]:e instanceof y.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 ft extends y.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 y.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=qt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof y.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 y.BufferAttribute(new Float32Array(this.positions),3),previous:new y.BufferAttribute(new Float32Array(this.previous),3),next:new y.BufferAttribute(new Float32Array(this.next),3),side:new y.BufferAttribute(new Float32Array(this.side),1),width:new y.BufferAttribute(new Float32Array(this.width),1),uv:new y.BufferAttribute(new Float32Array(this.uvs),2),index:new y.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new y.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,n=this._attributes.next.array,a=s.length;Ve(s,0,r,0,a),Ve(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,Ve(s,6,n,0,a-6),n[a-6]=e,n[a-5]=t,n[a-4]=i,n[a-3]=e,n[a-2]=t,n[a-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const st=["encodings_fragment","colorspace_fragment"],Nt=`
|
|
1
|
+
"use strict";var wt=Object.defineProperty,Mt=Object.defineProperties;var At=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Je=Math.pow,He=(o,e,t)=>e in o?wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,I=(o,e)=>{for(var t in e||(e={}))$e.call(e,t)&&He(o,t,e[t]);if(ge)for(var t of ge(e))Ze.call(e,t)&&He(o,t,e[t]);return o},Me=(o,e)=>Mt(o,At(e));var Ae=(o,e)=>{var t={};for(var i in o)$e.call(o,i)&&e.indexOf(i)<0&&(t[i]=o[i]);if(o!=null&&ge)for(var i of ge(o))e.indexOf(i)<0&&Ze.call(o,i)&&(t[i]=o[i]);return t};var se=(o,e,t)=>new Promise((i,s)=>{var r=c=>{try{a(t.next(c))}catch(u){s(u)}},n=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,n);a((t=t.apply(o,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("three"),te=require("../BaseObject.js"),St=require("esus-lite"),_t=require("../index2.js"),Pt=require("@tweenjs/tween.js"),Vt=require("three/examples/jsm/lines/LineSegments2"),je=require("three/examples/jsm/lines/LineSegmentsGeometry"),lt=require("three/examples/jsm/lines/LineMaterial"),oe=require("d3-array"),Be=require("earcut"),Tt=require("@turf/boolean-clockwise"),Le=require("../uvGenerator.js"),Bt=require("delaunator"),Lt=require("@turf/boolean-point-in-polygon"),he=require("d3-geo"),Ct=require("d3-geo-voronoi"),Xe=require("d3-scale");function ct(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const y=ct(w),ae=ct(Pt),jt=+y.REVISION<144,ut=jt?"PlaneBufferGeometry":"PlaneGeometry";class ht extends te.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=I({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return se(this,null,function*(){const{src:e,texture:t,transparent:i,opacity:s,blending:r,depthWrite:n,depthTest:a,alphaTest:c,sprite:u,sizeAttenuation:l,color:h}=this.options,p=t||(yield new y.TextureLoader().loadAsync(e));return u?new y.SpriteMaterial({map:p,transparent:i!=null?i:!1,blending:r!=null?r:y.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:s!=null?s:1,sizeAttenuation:l!=null?l:!0}):new y.MeshBasicMaterial({color:h!=null?h:16777215,map:p,transparent:i!=null?i:!1,blending:r!=null?r:y.NormalBlending,depthWrite:n!=null?n:!0,depthTest:a!=null?a:!0,alphaTest:c!=null?c:0,opacity:s!=null?s:1})})}create(){return se(this,null,function*(){const{position:e,material:t,sprite:i}=this.options,s=t||(yield this.getMaterial());i?this.createSprite(s):this.createMesh(new y[ut](1,1),s),e&&this.object3d.position.copy(e)})}render(){const{scale:e}=this.options;this.setScale(e)}setScale(e){this.scaleValue=e;const t=this.material.map;t!=null&&t.image?this.object3d.scale.set(t.image.width*e,t.image.height*e,1):this.object3d.scale.set(e,e,1)}setTexture(e){const t=this.object3d;t.material.map&&t.material.map.dispose(),t.material.map=e,t.material.needsUpdate=!0,this.setScale(this.scaleValue)}}class It extends ht{constructor(e){super(e),this.canvas=document.createElement("canvas")}getTexture(){const{text:e,textOptions:t}=this.options,{fontSize:i,fontFamily:s,fontWeight:r,flipX:n,color:a,setCtx:c}=I({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:f=>{}},t||{}),{canvas:u}=this;u.width=i*e.length*2,u.height=i;let l=u.getContext("2d");l.font=`${r} ${i}px/1 ${s}`;const{width:h}=l.measureText(e);u.width=h,l=u.getContext("2d"),l.clearRect(0,0,u.width,u.height),n&&l.scale(-1,1),l.font=`${r} ${i}px/1 ${s}`,l.textBaseline="middle",l.fillStyle=a,c&&c(l),l.fillText(e,n?h*-1:0,u.height/2),l.restore();const p=new y.Texture(u);return p.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),p.needsUpdate=!0,Promise.resolve(p)}}class Gt extends te.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=I({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:i,depthWrite:s,depthTest:r,format:n,autoPlay:a,loop:c,alphaTest:u,sprite:l}=this.options,h=St.makePromiseCreator();if(!e)return Promise.reject("src is required");const p=document.createElement("video");return p.addEventListener("loadedmetadata",()=>{const f=new y.VideoTexture(p);f.format=n!=null?n:y.RGBAFormat,f.needsUpdate=!0;const d=l?new y.SpriteMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:y.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:u!=null?u:0}):new y.MeshBasicMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:y.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:u!=null?u:0});h.resolve(d)},!1),p.src=e,p.muted=!0,p.autoplay=a,p.loop=c,p.preload="auto",h.promise}create(){return se(this,null,function*(){const{scale:e,position:t,src:i,cache:s,sprite:r}=this.options,n=i&&(s?yield s.get(i,()=>this.getMaterial()):yield this.getMaterial());this.video=n.map.image,r?this.createSprite(n):this.createMesh(new y[ut](1,1),n),this.setScale(e),t&&this.object3d.position.copy(t)})}setScale(e){this.scaleValue=e,this.object3d.scale.set(this.video.videoWidth*e,this.video.videoHeight*e,1)}render(){const{autoPlay:e}=this.options;e&&this.video.play()}dispose(){this.video.pause(),this.video.src="",super.dispose()}}class Et extends te.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.onNodePointerIndex=[],this.options=I({event:"click",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.element.innerHTML="",this.element.appendChild(e)}render(){this.checkVisible()}show(){return this.visibleCache=!0,this.checkVisible(),this}hide(){return this.visibleCache=!1,this.checkVisible(),this}checkVisible(){this.drawGroupShow&&this.visibleCache?super.show():(!this.drawGroupShow||!this.visibleCache)&&super.hide()}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 zt extends te.BaseObject{constructor(e){super(),this.options=I({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:i,material:s,percentDepth:r,activeIndex:n}=this.options,a=Math.max(...e),c=e.reduce((l,h)=>l+h,0);let u=Math.PI/2;e.forEach((l,h)=>{if(l===0)return;const p=Math.PI*2*(l/c),f=i[h],d=r?t*(l/a):t,m=this.createGeometry(d,p),M=s?s.clone():new y.MeshBasicMaterial({color:f});s&&M.color.set(f);const V=new y.Mesh(m,M);V.userData.depth=d,V.userData.index=h,V.rotateZ(u),u+=p,this.add(V)}),n!==-1&&this.setActive(n)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new y.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 y.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 ae.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 ae.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 ae.Tween(this.object3d.scale).to({z:1},1e3).easing(ae.Easing.Sinusoidal.InOut).start()}}class Ut extends te.BaseObject{constructor(e){super(),this.options=e}create(){var t,i,s,r,n,a,c,u,l,h,p,f,d;const e=this.options;if(e.type==="AmbientLight"){const m=new y.AmbientLight(e.color);m.name="AmbientLight",this.object3d=m}else if(e.type==="DirectionalLight"){const m=new y.DirectionalLight(e.color,e.intensity);m.name="DirectionalLight",m.target.position.set(0,0,0),this.object3d=m,this.pencil.scene.add(m.target),this.directionalLight=m}else if(e.type==="PointLight"){const m=new y.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="PointLight",this.object3d=m,this.pointLight=m}else if(e.type==="SpotLight"){const m=new y.SpotLight((n=e.color)!=null?n:16777215,(a=e.intensity)!=null?a:1,(c=e.distance)!=null?c:0,(u=e.angle)!=null?u:Math.PI/3,(l=e.penumbra)!=null?l:1,(h=e.decay)!=null?h:2);m.name="SpotLight",this.object3d=m,this.spotLight=m,this.pencil.scene.add(m.target)}else if(e.type==="HemisphereLight"){const m=new y.HemisphereLight((p=e.color)!=null?p:16777215,(f=e.groundColor)!=null?f:16777215,(d=e.intensity)!=null?d:1);m.name="HemisphereLight",this.object3d=m,this.hemisphereLight=m}}render(){const e=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const t=this.spotLight||this.directionalLight;t.position.copy(e),t.target.position.copy(e)}else this.pointLight&&this.pointLight.position.copy(e)}dispose(){const e=this.object3d;e.target&&this.pencil.scene.remove(e.target),super.dispose()}}function ee(o,e=0){const t=o[0].index!==null,i=new Set(Object.keys(o[0].attributes)),s=new Set(Object.keys(o[0].morphAttributes)),r={},n={},a=o[0].morphTargetsRelative,c=new w.BufferGeometry;let u=0;for(let l=0;l<o.length;++l){const h=o[l];let p=0;if(t!==(h.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 f in h.attributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. 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(h.attributes[f]),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!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;n[f]===void 0&&(n[f]=[]),n[f].push(h.morphAttributes[f])}if(e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.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)c.addGroup(u,f,l);else if(e===2&&h.groups.length>0)for(let d of h.groups){let m=d.materialIndex;c.addGroup(u+d.start,Math.min(d.count,f),m)}u+=f}}if(t){let l=0;const h=[];for(let p=0;p<o.length;++p){const f=o[p].index;for(let d=0;d<f.count;++d)h.push(f.getX(d)+l);l+=o[p].attributes.position.count}c.setIndex(h)}for(const l in r){const h=Ke(r[l]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;c.setAttribute(l,h)}for(const l in n){const h=n[l][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[l]=[];for(let p=0;p<h;++p){const f=[];for(let m=0;m<n[l].length;++m)f.push(n[l][m][p]);const d=Ke(f);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;c.morphAttributes[l].push(d)}}return e===2?Ot(c):c}function Ke(o){let e,t,i,s=-1,r=0;for(let u=0;u<o.length;++u){const l=o[u];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 n=new e(r),a=new w.BufferAttribute(n,t,i);let c=0;for(let u=0;u<o.length;++u){const l=o[u];if(l.isInterleavedBufferAttribute){const h=c/t;for(let p=0,f=l.count;p<f;p++)for(let d=0;d<t;d++){const m=l.getComponent(p,d);a.setComponent(p+h,d,m)}}else n.set(l.array,c);c+=l.count*t}return s!==void 0&&(a.gpuType=s),a}function Ot(o){if(o.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),o;let e=o.groups;if(e=e.sort((n,a)=>n.materialIndex!==a.materialIndex?n.materialIndex-a.materialIndex:n.start-a.start),o.getIndex()===null){const n=o.getAttribute("position"),a=[];for(let c=0;c<n.count;c+=3)a.push(c,c+1,c+2);o.setIndex(a)}const t=o.getIndex(),i=[];for(let n=0;n<e.length;n++){const a=e[n],c=a.start,u=c+a.count;for(let l=c;l<u;l++)i.push(t.getX(l))}o.dispose(),o.setIndex(i);let s=0;for(let n=0;n<e.length;n++){const a=e[n];a.start=s,s+=a.count}let r=e[0];o.groups=[r];for(let n=1;n<e.length;n++){const a=e[n];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,o.groups.push(r))}return o}const Se=new w.Vector4,Qe=new w.Vector3,Ye=new w.Vector3,E=new w.Vector4,z=new w.Vector4,F=new w.Vector4,_e=new w.Vector3,Pe=new w.Matrix4,U=new w.Line3,et=new w.Vector3,ye=new w.Box3,ve=new w.Sphere,H=new w.Vector4;let $,re;function tt(o,e,t){return H.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),H.multiplyScalar(1/H.w),H.x=re/t.width,H.y=re/t.height,H.applyMatrix4(o.projectionMatrixInverse),H.multiplyScalar(1/H.w),Math.abs(Math.max(H.x,H.y))}function Wt(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,n=Math.min(i.instanceCount,s.count);for(let a=0,c=n;a<c;a++){U.start.fromBufferAttribute(s,a),U.end.fromBufferAttribute(r,a),U.applyMatrix4(t);const u=new w.Vector3,l=new w.Vector3;$.distanceSqToSegment(U.start,U.end,l,u),l.distanceTo(u)<re*.5&&e.push({point:l,pointOnLine:u,distance:$.origin.distanceTo(l),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function Dt(o,e,t){const i=e.projectionMatrix,r=o.material.resolution,n=o.matrixWorld,a=o.geometry,c=a.attributes.instanceStart,u=a.attributes.instanceEnd,l=Math.min(a.instanceCount,c.count),h=-e.near;$.at(1,F),F.w=1,F.applyMatrix4(e.matrixWorldInverse),F.applyMatrix4(i),F.multiplyScalar(1/F.w),F.x*=r.x/2,F.y*=r.y/2,F.z=0,_e.copy(F),Pe.multiplyMatrices(e.matrixWorldInverse,n);for(let p=0,f=l;p<f;p++){if(E.fromBufferAttribute(c,p),z.fromBufferAttribute(u,p),E.w=1,z.w=1,E.applyMatrix4(Pe),z.applyMatrix4(Pe),E.z>h&&z.z>h)continue;if(E.z>h){const _=E.z-z.z,T=(E.z-h)/_;E.lerp(z,T)}else if(z.z>h){const _=z.z-E.z,T=(z.z-h)/_;z.lerp(E,T)}E.applyMatrix4(i),z.applyMatrix4(i),E.multiplyScalar(1/E.w),z.multiplyScalar(1/z.w),E.x*=r.x/2,E.y*=r.y/2,z.x*=r.x/2,z.y*=r.y/2,U.start.copy(E),U.start.z=0,U.end.copy(z),U.end.z=0;const m=U.closestPointToPointParameter(_e,!0);U.at(m,et);const M=w.MathUtils.lerp(E.z,z.z,m),V=M>=-1&&M<=1,B=_e.distanceTo(et)<re*.5;if(V&&B){U.start.fromBufferAttribute(c,p),U.end.fromBufferAttribute(u,p),U.start.applyMatrix4(n),U.end.applyMatrix4(n);const _=new w.Vector3,T=new w.Vector3;$.distanceSqToSegment(U.start,U.end,T,_),t.push({point:T,pointOnLine:_,distance:$.origin.distanceTo(T),object:o,face:null,faceIndex:p,uv:null,uv1:null})}}}class Rt extends w.Mesh{constructor(e=new je.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 n=0,a=0,c=t.count;n<c;n++,a+=2)Qe.fromBufferAttribute(t,n),Ye.fromBufferAttribute(i,n),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+Qe.distanceTo(Ye);const r=new w.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new w.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new w.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 n=this.matrixWorld,a=this.geometry,c=this.material;re=c.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),ve.copy(a.boundingSphere).applyMatrix4(n);let u;if(i)u=re*.5;else{const h=Math.max(s.near,ve.distanceToPoint($.origin));u=tt(s,h,c.resolution)}if(ve.radius+=u,$.intersectsSphere(ve)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),ye.copy(a.boundingBox).applyMatrix4(n);let l;if(i)l=re*.5;else{const h=Math.max(s.near,ye.distanceToPoint($.origin));l=tt(s,h,c.resolution)}ye.expandByScalar(l),$.intersectsBox(ye)!==!1&&(i?Wt(this,t):Dt(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=o=>{const{points:e}=o,t=e.reduce((s,r,n)=>(n<e.length-1&&s.push(r,e[n+1]),s),[]);return new y.BufferGeometry().setFromPoints(t)};let Nt=class extends te.BaseObject{constructor(e={}){super(),this.options=I({},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:i,geometryArr:s,material:r,useGroups:n,setPointWidth:a,lineWidthArr:c,materialParameters:u,instanceCount:l}=this.options;let h=r,p=i;!h&&u&&(h=this.getMaterial(u)),!p&&e?p=it({points:e}):!p&&t?p=ee(t.map(d=>it({points:d})),n!=null?n:0):!p&&s&&s.length>1?p=ee(s,n!=null?n:0):!p&&s&&s.length===1&&([p]=s);const f=new je.LineSegmentsGeometry().fromLineSegments(new y.LineSegments(p));if(this.pencil.options.WebGPUTHREE){l&&(f.instanceCount=l);const d=new Rt(f,h);d.computeLineDistances(),this.object3d=d}else{const d=new Vt.LineSegments2(f,h);d.computeLineDistances(),this.object3d=d}})}getMaterial(e){return new lt.LineMaterial(I({color:new y.Color("#ffffff")},e))}};function Ve(o,e,t,i,s){let r;if(o=o.subarray||o.slice?o:o.buffer,t=t.subarray||t.slice?t:t.buffer,o=e?o.subarray?o.subarray(e,s&&e+s):o.slice(e,s&&e+s):o,t.set)t.set(o,i);else for(r=0;r<o.length;r++)t[r+i]=o[r];return t}function kt(o){return o instanceof Float32Array?o:o instanceof y.BufferGeometry?o.getAttribute("position").array:o.map(e=>{const t=Array.isArray(e);return e instanceof y.Vector3?[e.x,e.y,e.z]:e instanceof y.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 ft extends y.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 y.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=kt(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof y.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 y.BufferAttribute(new Float32Array(this.positions),3),previous:new y.BufferAttribute(new Float32Array(this.previous),3),next:new y.BufferAttribute(new Float32Array(this.next),3),side:new y.BufferAttribute(new Float32Array(this.side),1),width:new y.BufferAttribute(new Float32Array(this.width),1),uv:new y.BufferAttribute(new Float32Array(this.uvs),2),index:new y.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new y.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,n=this._attributes.next.array,a=s.length;Ve(s,0,r,0,a),Ve(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,Ve(s,6,n,0,a-6),n[a-6]=e,n[a-5]=t,n[a-4]=i,n[a-3]=e,n[a-2]=t,n[a-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const st=["encodings_fragment","colorspace_fragment"],qt=`
|
|
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 <${+y.REVISION<154?st[0]:st[1]}>
|
|
145
145
|
}
|
|
146
|
-
`;class pt extends y.ShaderMaterial{constructor(e){super({uniforms:Ae(E({},y.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new y.Color(16777215)},opacity:{value:1},resolution:{value:new y.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 y.Vector2(1,1)},offset:{value:new y.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new y.Vector2(0,0)},lightColor:{value:new y.Color(16777215)}}),vertexShader:Nt,fragmentShader:Ft}),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 Ht(o,e){const t=new y.Matrix4,i=new y.Ray,s=new y.Sphere,r=new y.Vector3,n=this.geometry;if(s.copy(n.boundingSphere),s.applyMatrix4(this.matrixWorld),!o.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),i.copy(o.ray).applyMatrix4(t);const a=new y.Vector3,c=new y.Vector3,u=new y.Vector3,l=this instanceof y.LineSegments?2:1,h=n.index,p=n.attributes;if(h!==null){const f=h.array,d=p.position.array,m=p.width.array;for(let A=0,V=f.length-1;A<V;A+=l){const B=f[A],_=f[A+1];a.fromArray(d,B*3),c.fromArray(d,_*3);const T=m[Math.floor(A/3)]!=null?m[Math.floor(A/3)]:1,O=o.params.Line.threshold+this.material.lineWidth*T/2,j=O*O;if(i.distanceSqToSegment(a,c,r,u)>j)continue;r.applyMatrix4(this.matrixWorld);const R=o.ray.origin.distanceTo(r);R<o.near||R>o.far||(e.push({distance:R,point:u.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=V)}}}const Te=o=>{const{setPointWidth:e,nodes:t}=o,i=new ft;return i.setPoints(t,e),i};class $t extends te.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:i,geometryArr:s,material:r,useGroups:n,setPointWidth:a,lineWidthArr:c,materialParameters:u}=this.options;let l=r,h=i;!l&&u&&(l=this.getMaterial(u)),!h&&e?h=Te({nodes:e,setPointWidth:a}):!h&&t?h=ee(t.map((p,f)=>{let d=a;return!d&&c&&(d=()=>{var m;return(m=c[f])!=null?m:c[0]}),Te({nodes:p,setPointWidth:d})}),n!=null?n:0):!h&&s&&s.length>1?h=ee(s,n!=null?n:0):!h&&s&&s.length===1&&([h]=s),this.createMesh(h,l)})}setGeometry(e,t){const i=Te({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 pt(E({color:new y.Color("#ffffff"),resolution:new y.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:n,onComplete:a}={}){const{offset:c,offsetLoop:u}=this.material.uniforms;if(this.material.userData.tween)return;const l=s!=null?s:!0;c.value.x=1,u.value=0;let h=0;const p=new ae.Tween(c.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:f})=>{l&&f<=0&&u.value===0&&(u.value=1),n&&n(f)}).onRepeat(()=>{h+=1,r&&r(h)}).onComplete(()=>{a&&a()}).start();this.material.userData.tween=p}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(e=!0){e&&this.material.userData.tween&&(this.material.userData.tween.stop(),ae.remove(this.material.userData.tween)),super.dispose(e)}}function Zt(o,e){return o.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const n=he.geoDistance(r,s)*180/Math.PI;if(n>e){const a=he.geoInterpolate(s,r),c=1/Math.ceil(n/e);let u=c;for(;u<1;)i.push(a(u)),u+=c}}i.push(s=r)}),i})}function Jt(o,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Je(360/o,2)/Math.PI),n=(1+Math.sqrt(5))/2,a=f=>f/n*360%360-180,c=f=>Math.acos(2*f/r-1)/Math.PI*180-90,u=f=>r*(Math.cos((f+90)*Math.PI/180)+1)/2,l=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):r-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,p=[];for(let f=l[0];f<=l[1];f++){const d=a(f);h(d)&&p.push([d,c(f)])}return p}function Ce(o,e,t=!1){return t?he.geoContains(e,o):Lt(o,e)}function Xt(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[r,n]]=he.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(n-s))<e)return[];const a=i>r||n>=89||s<=-89;return Jt(e,{minLng:i,maxLng:r,minLat:s,maxLat:n}).filter(c=>Ce(c,t,a))}function Kt(o,{resolution:e=1/0,bbox:t}={}){const i=Zt(o,e),s=oe.merge(i),r=Xt(o,e),n=[...s,...r],a={type:"Polygon",coordinates:o},[[c,u],[l,h]]=he.geoBounds(a),p=c>l||h>=89||u<=-89;let f=[];if(p){const B=Ct.geoVoronoi(n).triangles(),_=new Map(n.map(([T,O],j)=>[`${T}-${O}`,j]));B.features.forEach(T=>{const O=T.geometry.coordinates[0].slice(0,3).reverse(),j=[];if(O.forEach(([C,R])=>{const q=`${C}-${R}`;_.has(q)&&j.push(_.get(q))}),j.length===3){if(j.some(C=>C<s.length)){const C=T.properties.circumcenter;if(!Ce(C,a,p))return}f.push(...j)}})}else if(r.length){const B=Bt.from(n);for(let _=0,T=B.triangles.length;_<T;_+=3){const O=[2,1,0].map(C=>B.triangles[_+C]),j=O.map(C=>n[C]);if(O.some(C=>C<s.length)){const C=[0,1].map(R=>oe.mean(j,q=>q[R]));if(!Ce(C,a,p))continue}f.push(...O)}}else{const{vertices:B,holes:_=[]}=Be.flatten(i);f=Be(B,_,2)}const d=Xe.scaleLinear(t?[t[0],t[2]]:oe.extent(n,B=>B[0]),[0,1]),m=Xe.scaleLinear(t?[t[1],t[3]]:oe.extent(n,B=>B[1]),[0,1]),A=n.map(([B,_])=>[d(B),m(_)]);return{contour:i,triangles:{points:n,indices:f,uvs:A}}}const rt=new y.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function be(o,e,t,i){const s=o.map(r=>r.map(([n,a])=>{if(i){const[c,u]=i([n,a]);return[c,-u,e]}return t?Le.polar2Cartesian(n,a,e):[n,a,e]}));return Be.flatten(s)}function Qt(o,e,t,i,s){const{vertices:r,holes:n}=be(o,e,i,s),{vertices:a}=be(o,t,i,s),c=oe.merge([a,r]),u=Math.round(a.length/3),l=new Set(n);let h=0;const p=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(l.has(m)){const A=m;m=h,h=A}p.push(d,d+u,m+u),p.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:p,vertices:c,uvs:f,topVerts:a}}function nt(o,e,t,i,s,r){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:be([o.points],e,s,r).vertices,uvs:t}}const dt=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:n=!1,hasTop:a=!1,projection:c,bbox:u})=>{o.forEach(V=>{Tt(V)||V.reverse()});const{contour:l,triangles:h}=Kt(o,{resolution:i,bbox:u});let p={},f;r&&(p=Qt(l,e!=null?e:t,t!=null?t:e,s,c),f=p.topVerts);let d=[];(n||a)&&(d=oe.merge(h.uvs));let m={};n&&(m=nt(h,e,d,!1,s,c));let A={};return a&&(A=nt(h,t,d,!0,s,c)),{contour:l,triangles:h,sideTorso:p,bottomCap:m,topCap:A,topVerts:f}};class mt extends y.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=E({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,hasBottom:r,hasSide:n,cartesian:a,userDataRsoOffset:c,projection:u}=this.parameters,{contour:l,sideTorso:h,topVerts:p,bottomCap:f,topCap:d}=dt(E({},this.parameters));let m=[],A=[],V=[],B=0;const _=T=>{const O=Math.round(m.length/3),j=V.length;m=m.concat(T.vertices),A=A.concat(T.uvs),V=V.concat(O?T.indices.map(C=>C+O):T.indices),this.addGroup(j,V.length-j,B++)};n&&(_(h),this.userData.topVerts=c?be(l,i+c,a,u).vertices:p),r&&_(f),s&&_(d),this.setIndex(V),this[rt]("position",new y.Float32BufferAttribute(m,3)),this[rt]("uv",new y.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const ot=o=>{const a=o,{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 mt([e],Ae(E({},s),{startHeight:t,endHeight:r}))};class Yt extends te.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const c=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=c,n=Me(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&i)a=ot(E({coordinate:i},n));else if(!a&&t){const u=t.map(l=>ot(E({coordinate:l},n)));a=ee(u,r!=null?r:0)}this.createMesh(a,s)}}class Ee extends w.BufferGeometry{constructor(e=new w.Shape([new w.Vector2(.5,.5),new w.Vector2(-.5,.5),new w.Vector2(-.5,-.5),new w.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,c=e.length;a<c;a++){const u=e[a];n(u)}this.setAttribute("position",new w.Float32BufferAttribute(s,3)),this.setAttribute("uv",new w.Float32BufferAttribute(r,2)),this.computeVertexNormals();function n(a){var Oe,We,De;const c=[],u=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,d=t.bevelSize!==void 0?t.bevelSize:f-.1,m=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const V=t.extrudePath,B=t.UVGenerator!==void 0?t.UVGenerator:ei,_=(Oe=t.hasTop)!=null?Oe:!0,T=(We=t.hasBottom)!=null?We:!0,O=(De=t.hasSide)!=null?De:!0;let j,C=!1,R,q,le,Z;V&&(j=V.getSpacedPoints(l),C=!0,p=!1,R=V.computeFrenetFrames(l,!1),q=new w.Vector3,le=new w.Vector3,Z=new w.Vector3),p||(A=0,f=0,d=0,m=0);const Ge=a.extractPoints(u);let k=Ge.shape;const D=Ge.holes;if(!w.ShapeUtils.isClockWise(k)){k=k.reverse();for(let g=0,v=D.length;g<v;g++){const b=D[g];w.ShapeUtils.isClockWise(b)&&(D[g]=b.reverse())}}const ce=w.ShapeUtils.triangulateShape(k,D),N=k;for(let g=0,v=D.length;g<v;g++){const b=D[g];k=k.concat(b)}function ne(g,v,b){return v||console.error("THREE.ExtrudeGeometry: vec does not exist"),g.clone().addScaledVector(v,b)}const J=k.length,fe=ce.length;function Ie(g,v,b){let M,x,S;const P=g.x-v.x,L=g.y-v.y,W=b.x-g.x,G=b.y-g.y,ue=P*P+L*L,we=P*G-L*W;if(Math.abs(we)>Number.EPSILON){const Y=Math.sqrt(ue),Re=Math.sqrt(W*W+G*G),ke=v.x-L/Y,qe=v.y+P/Y,bt=b.x-G/Re,xt=b.y+W/Re,Ne=((bt-ke)*G-(xt-qe)*W)/(P*G-L*W);M=ke+P*Ne-g.x,x=qe+L*Ne-g.y;const Fe=M*M+x*x;if(Fe<=2)return new w.Vector2(M,x);S=Math.sqrt(Fe/2)}else{let Y=!1;P>Number.EPSILON?W>Number.EPSILON&&(Y=!0):P<-Number.EPSILON?W<-Number.EPSILON&&(Y=!0):Math.sign(L)===Math.sign(G)&&(Y=!0),Y?(M=-L,x=P,S=Math.sqrt(ue)):(M=P,x=L,S=Math.sqrt(ue/2))}return new w.Vector2(M/S,x/S)}const pe=[];for(let g=0,v=N.length,b=v-1,M=g+1;g<v;g++,b++,M++)b===v&&(b=0),M===v&&(M=0),pe[g]=Ie(N[g],N[b],N[M]);const xe=[];let ie,de=pe.concat();for(let g=0,v=D.length;g<v;g++){const b=D[g];ie=[];for(let M=0,x=b.length,S=x-1,P=M+1;M<x;M++,S++,P++)S===x&&(S=0),P===x&&(P=0),ie[M]=Ie(b[M],b[S],b[P]);xe.push(ie),de=de.concat(ie)}for(let g=0;g<A;g++){const v=g/A,b=f*Math.cos(v*Math.PI/2),M=d*Math.sin(v*Math.PI/2)+m;for(let x=0,S=N.length;x<S;x++){const P=ne(N[x],pe[x],M);X(P.x,P.y,-b)}for(let x=0,S=D.length;x<S;x++){const P=D[x];ie=xe[x];for(let L=0,W=P.length;L<W;L++){const G=ne(P[L],ie[L],M);X(G.x,G.y,-b)}}}const ze=d+m;for(let g=0;g<J;g++){const v=p?ne(k[g],de[g],ze):k[g];C?(le.copy(R.normals[0]).multiplyScalar(v.x),q.copy(R.binormals[0]).multiplyScalar(v.y),Z.copy(j[0]).add(le).add(q),X(Z.x,Z.y,Z.z)):X(v.x,v.y,0)}for(let g=1;g<=l;g++)for(let v=0;v<J;v++){const b=p?ne(k[v],de[v],ze):k[v];C?(le.copy(R.normals[g]).multiplyScalar(b.x),q.copy(R.binormals[g]).multiplyScalar(b.y),Z.copy(j[g]).add(le).add(q),X(Z.x,Z.y,Z.z)):X(b.x,b.y,h/l*g)}for(let g=A-1;g>=0;g--){const v=g/A,b=f*Math.cos(v*Math.PI/2),M=d*Math.sin(v*Math.PI/2)+m;for(let x=0,S=N.length;x<S;x++){const P=ne(N[x],pe[x],M);X(P.x,P.y,h+b)}for(let x=0,S=D.length;x<S;x++){const P=D[x];ie=xe[x];for(let L=0,W=P.length;L<W;L++){const G=ne(P[L],ie[L],M);C?X(G.x,G.y+j[l-1].y,j[l-1].x+b):X(G.x,G.y,h+b)}}}gt(),O&&yt();function gt(){const g=s.length/3;if(p){let v=0,b=J*v;if(T)for(let M=0;M<fe;M++){const x=ce[M];me(x[2]+b,x[1]+b,x[0]+b)}if(v=l+A*2,b=J*v,_)for(let M=0;M<fe;M++){const x=ce[M];me(x[0]+b,x[1]+b,x[2]+b)}}else{if(T)for(let v=0;v<fe;v++){const b=ce[v];me(b[2],b[1],b[0])}if(_)for(let v=0;v<fe;v++){const b=ce[v];me(b[0]+J*l,b[1]+J*l,b[2]+J*l)}}i.addGroup(g,s.length/3-g,0)}function yt(){const g=s.length/3;let v=0;Ue(N,v),v+=N.length;for(let b=0,M=D.length;b<M;b++){const x=D[b];Ue(x,v),v+=x.length}i.addGroup(g,s.length/3-g,1)}function Ue(g,v){let b=g.length;for(;--b>=0;){const M=b;let x=b-1;x<0&&(x=g.length-1);for(let S=0,P=l+A*2;S<P;S++){const L=J*S,W=J*(S+1),G=v+M+L,ue=v+x+L,we=v+x+W,Y=v+M+W;vt(G,ue,we,Y)}}}function X(g,v,b){c.push(g),c.push(v),c.push(b)}function me(g,v,b){K(g),K(v),K(b);const M=s.length/3,x=B.generateTopUV(i,s,M-3,M-2,M-1);Q(x[0]),Q(x[1]),Q(x[2])}function vt(g,v,b,M){K(g),K(v),K(M),K(v),K(b),K(M);const x=s.length/3,S=B.generateSideWallUV(i,s,x-6,x-3,x-2,x-1);Q(S[0]),Q(S[1]),Q(S[3]),Q(S[1]),Q(S[2]),Q(S[3])}function K(g){s.push(c[g*3+0]),s.push(c[g*3+1]),s.push(c[g*3+2])}function Q(g){r.push(g.x),r.push(g.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 ti(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,n=e.shapes.length;r<n;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 y[`${s.type}Curve`]().fromJSON(s)),new Ee(i,e.options)}}const ei={generateTopUV:function(o,e,t,i,s){const r=e[t*3],n=e[t*3+1],a=e[i*3],c=e[i*3+1],u=e[s*3],l=e[s*3+1];return[new w.Vector2(r,n),new w.Vector2(a,c),new w.Vector2(u,l)]},generateSideWallUV:function(o,e,t,i,s,r){const n=e[t*3],a=e[t*3+1],c=e[t*3+2],u=e[i*3],l=e[i*3+1],h=e[i*3+2],p=e[s*3],f=e[s*3+1],d=e[s*3+2],m=e[r*3],A=e[r*3+1],V=e[r*3+2];return Math.abs(a-l)<Math.abs(n-u)?[new w.Vector2(n,1-c),new w.Vector2(u,1-h),new w.Vector2(p,1-d),new w.Vector2(m,1-V)]:[new w.Vector2(a,1-c),new w.Vector2(l,1-h),new w.Vector2(f,1-d),new w.Vector2(A,1-V)]}};function ti(o,e,t){if(t.shapes=[],Array.isArray(o))for(let i=0,s=o.length;i<s;i++){const r=o[i];t.shapes.push(r.uuid)}else t.shapes.push(o.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}const at=o=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:n,hasSide:a,sideRepeat:c}=o,u=new Ee(new y.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:Le.getUVGenerator({split:e,box3:s,sideRepeat:c}),hasTop:r,hasBottom:n,hasSide:a});return Le.claerUVGenerator(),u};class ii extends te.BaseObject{constructor(e){super(),this.options=E({depth:1},e)}create(){return se(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:n,material:a,box3:c,split:u,hasTop:l,hasBottom:h,hasSide:p}=this.options,f=Array.isArray(s)?s:[s],d=Array.isArray(c)?c:[c],m=a;let A=r;m||console.log("material is null"),!A&&e?A=at({points:e,depth:f[0],box3:d[0],split:u,hasTop:l,hasBottom:h,hasSide:p}):!A&&t?A=ee(t.map((V,B)=>{var _,T;return at({points:V,depth:(_=f[B])!=null?_:f[0],box3:(T=d[B])!=null?T:d[0],split:u,hasTop:l,hasBottom:h,hasSide:p})}),i!=null?i:0):!A&&n&&n.length>1?A=ee(n,i!=null?i:0):!A&&n&&n.length===1&&([A]=n),this.createMesh(A,m)})}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 si=o=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:n}=o;return new Promise(a=>{const c=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const u=r,l=document.createElement("canvas"),h=l.getContext("2d");l.height=c.height/(1-u),l.width=c.width,u&&e&&(h.fillStyle=e,h.fillRect(0,0,c.width,l.height*u)),i&&c instanceof HTMLImageElement?h.drawImage(c,0,l.height*u,c.width,c.height):t&&(h.fillStyle=t,h.fillRect(0,l.height*u,c.width,c.height)),s&&l.toBlob(f=>{console.log(URL.createObjectURL(f))});const p=new y.CanvasTexture(l);a(p)},i?c.src=i:c instanceof HTMLImageElement||c.onload()})};exports.Group=_t.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>je.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>lt.LineMaterial});exports.ConicPolygon=Yt;exports.ExtrudePolygon=ii;exports.Image=ht;exports.Light=Ut;exports.Line=$t;exports.Line2=kt;exports.MeshLineGeometry=ft;exports.MeshLineMaterial=pt;exports.MeshLineRaycast=Ht;exports.Node=It;exports.Pie=zt;exports.Text=Et;exports.Video=Gt;exports.getConicPolygonGeometry=mt;exports.getConicPolygonGeometryMetas=dt;exports.getSplitTexture=si;
|
|
146
|
+
`;class pt extends y.ShaderMaterial{constructor(e){super({uniforms:Me(I({},y.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new y.Color(16777215)},opacity:{value:1},resolution:{value:new y.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 y.Vector2(1,1)},offset:{value:new y.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new y.Vector2(0,0)},lightColor:{value:new y.Color(16777215)}}),vertexShader:qt,fragmentShader:Ft}),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 Ht(o,e){const t=new y.Matrix4,i=new y.Ray,s=new y.Sphere,r=new y.Vector3,n=this.geometry;if(s.copy(n.boundingSphere),s.applyMatrix4(this.matrixWorld),!o.ray.intersectSphere(s,r))return;t.copy(this.matrixWorld).invert(),i.copy(o.ray).applyMatrix4(t);const a=new y.Vector3,c=new y.Vector3,u=new y.Vector3,l=this instanceof y.LineSegments?2:1,h=n.index,p=n.attributes;if(h!==null){const f=h.array,d=p.position.array,m=p.width.array;for(let M=0,V=f.length-1;M<V;M+=l){const B=f[M],_=f[M+1];a.fromArray(d,B*3),c.fromArray(d,_*3);const T=m[Math.floor(M/3)]!=null?m[Math.floor(M/3)]:1,O=o.params.Line.threshold+this.material.lineWidth*T/2,j=O*O;if(i.distanceSqToSegment(a,c,r,u)>j)continue;r.applyMatrix4(this.matrixWorld);const R=o.ray.origin.distanceTo(r);R<o.near||R>o.far||(e.push({distance:R,point:u.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:void 0,object:this}),M=V)}}}const Te=o=>{const{setPointWidth:e,nodes:t}=o,i=new ft;return i.setPoints(t,e),i};class $t extends te.BaseObject{constructor(e={}){super(),this.options=I({},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:i,geometryArr:s,material:r,useGroups:n,setPointWidth:a,lineWidthArr:c,materialParameters:u}=this.options;let l=r,h=i;!l&&u&&(l=this.getMaterial(u)),!h&&e?h=Te({nodes:e,setPointWidth:a}):!h&&t?h=ee(t.map((p,f)=>{let d=a;return!d&&c&&(d=()=>{var m;return(m=c[f])!=null?m:c[0]}),Te({nodes:p,setPointWidth:d})}),n!=null?n:0):!h&&s&&s.length>1?h=ee(s,n!=null?n:0):!h&&s&&s.length===1&&([h]=s),this.createMesh(h,l)})}setGeometry(e,t){const i=Te({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 pt(I({color:new y.Color("#ffffff"),resolution:new y.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:n,onComplete:a}={}){const{offset:c,offsetLoop:u}=this.material.uniforms;if(this.material.userData.tween)return;const l=s!=null?s:!0;c.value.x=1,u.value=0;let h=0;const p=new ae.Tween(c.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:f})=>{l&&f<=0&&u.value===0&&(u.value=1),n&&n(f)}).onRepeat(()=>{h+=1,r&&r(h)}).onComplete(()=>{a&&a()}).start();this.material.userData.tween=p}render(){const{width:e,height:t}=this.pencil.getSize();this.resize(e,t)}dispose(e=!0){e&&this.material.userData.tween&&(this.material.userData.tween.stop(),ae.remove(this.material.userData.tween)),super.dispose(e)}}function Zt(o,e){return o.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const n=he.geoDistance(r,s)*180/Math.PI;if(n>e){const a=he.geoInterpolate(s,r),c=1/Math.ceil(n/e);let u=c;for(;u<1;)i.push(a(u)),u+=c}}i.push(s=r)}),i})}function Jt(o,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Je(360/o,2)/Math.PI),n=(1+Math.sqrt(5))/2,a=f=>f/n*360%360-180,c=f=>Math.acos(2*f/r-1)/Math.PI*180-90,u=f=>r*(Math.cos((f+90)*Math.PI/180)+1)/2,l=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):r-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,p=[];for(let f=l[0];f<=l[1];f++){const d=a(f);h(d)&&p.push([d,c(f)])}return p}function Ce(o,e,t=!1){return t?he.geoContains(e,o):Lt(o,e)}function Xt(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[r,n]]=he.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(n-s))<e)return[];const a=i>r||n>=89||s<=-89;return Jt(e,{minLng:i,maxLng:r,minLat:s,maxLat:n}).filter(c=>Ce(c,t,a))}function Kt(o,{resolution:e=1/0,bbox:t}={}){const i=Zt(o,e),s=oe.merge(i),r=Xt(o,e),n=[...s,...r],a={type:"Polygon",coordinates:o},[[c,u],[l,h]]=he.geoBounds(a),p=c>l||h>=89||u<=-89;let f=[];if(p){const B=Ct.geoVoronoi(n).triangles(),_=new Map(n.map(([T,O],j)=>[`${T}-${O}`,j]));B.features.forEach(T=>{const O=T.geometry.coordinates[0].slice(0,3).reverse(),j=[];if(O.forEach(([C,R])=>{const k=`${C}-${R}`;_.has(k)&&j.push(_.get(k))}),j.length===3){if(j.some(C=>C<s.length)){const C=T.properties.circumcenter;if(!Ce(C,a,p))return}f.push(...j)}})}else if(r.length){const B=Bt.from(n);for(let _=0,T=B.triangles.length;_<T;_+=3){const O=[2,1,0].map(C=>B.triangles[_+C]),j=O.map(C=>n[C]);if(O.some(C=>C<s.length)){const C=[0,1].map(R=>oe.mean(j,k=>k[R]));if(!Ce(C,a,p))continue}f.push(...O)}}else{const{vertices:B,holes:_=[]}=Be.flatten(i);f=Be(B,_,2)}const d=Xe.scaleLinear(t?[t[0],t[2]]:oe.extent(n,B=>B[0]),[0,1]),m=Xe.scaleLinear(t?[t[1],t[3]]:oe.extent(n,B=>B[1]),[0,1]),M=n.map(([B,_])=>[d(B),m(_)]);return{contour:i,triangles:{points:n,indices:f,uvs:M}}}const rt=new y.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function be(o,e,t,i){const s=o.map(r=>r.map(([n,a])=>{if(i){const[c,u]=i([n,a]);return[c,-u,e]}return t?Le.polar2Cartesian(n,a,e):[n,a,e]}));return Be.flatten(s)}function Qt(o,e,t,i,s){const{vertices:r,holes:n}=be(o,e,i,s),{vertices:a}=be(o,t,i,s),c=oe.merge([a,r]),u=Math.round(a.length/3),l=new Set(n);let h=0;const p=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(l.has(m)){const M=m;m=h,h=M}p.push(d,d+u,m+u),p.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:p,vertices:c,uvs:f,topVerts:a}}function nt(o,e,t,i,s,r){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:be([o.points],e,s,r).vertices,uvs:t}}const dt=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:n=!1,hasTop:a=!1,projection:c,bbox:u})=>{o.forEach(V=>{Tt(V)||V.reverse()});const{contour:l,triangles:h}=Kt(o,{resolution:i,bbox:u});let p={},f;r&&(p=Qt(l,e!=null?e:t,t!=null?t:e,s,c),f=p.topVerts);let d=[];(n||a)&&(d=oe.merge(h.uvs));let m={};n&&(m=nt(h,e,d,!1,s,c));let M={};return a&&(M=nt(h,t,d,!0,s,c)),{contour:l,triangles:h,sideTorso:p,bottomCap:m,topCap:M,topVerts:f}};class mt extends y.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=I({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,hasBottom:r,hasSide:n,cartesian:a,userDataRsoOffset:c,projection:u}=this.parameters,{contour:l,sideTorso:h,topVerts:p,bottomCap:f,topCap:d}=dt(I({},this.parameters));let m=[],M=[],V=[],B=0;const _=T=>{const O=Math.round(m.length/3),j=V.length;m=m.concat(T.vertices),M=M.concat(T.uvs),V=V.concat(O?T.indices.map(C=>C+O):T.indices),this.addGroup(j,V.length-j,B++)};n&&(_(h),this.userData.topVerts=c?be(l,i+c,a,u).vertices:p),r&&_(f),s&&_(d),this.setIndex(V),this[rt]("position",new y.Float32BufferAttribute(m,3)),this[rt]("uv",new y.Float32BufferAttribute(M,2)),this.computeVertexNormals()}}const ot=o=>{const a=o,{coordinate:e,startHeight:t,height:i}=a,s=Ae(a,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(r=t+i),new mt([e],Me(I({},s),{startHeight:t,endHeight:r}))};class Yt extends te.BaseObject{constructor(e){super(),this.options=I({},e)}create(){const c=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=c,n=Ae(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let a=e;if(!a&&i)a=ot(I({coordinate:i},n));else if(!a&&t){const u=t.map(l=>ot(I({coordinate:l},n)));a=ee(u,r!=null?r:0)}this.createMesh(a,s)}}class Ie extends w.BufferGeometry{constructor(e=new w.Shape([new w.Vector2(.5,.5),new w.Vector2(-.5,.5),new w.Vector2(-.5,-.5),new w.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,c=e.length;a<c;a++){const u=e[a];n(u)}this.setAttribute("position",new w.Float32BufferAttribute(s,3)),this.setAttribute("uv",new w.Float32BufferAttribute(r,2)),this.computeVertexNormals();function n(a){var Oe,We,De;const c=[],u=t.curveSegments!==void 0?t.curveSegments:12,l=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,d=t.bevelSize!==void 0?t.bevelSize:f-.1,m=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const V=t.extrudePath,B=t.UVGenerator!==void 0?t.UVGenerator:ei,_=(Oe=t.hasTop)!=null?Oe:!0,T=(We=t.hasBottom)!=null?We:!0,O=(De=t.hasSide)!=null?De:!0;let j,C=!1,R,k,le,Z;V&&(j=V.getSpacedPoints(l),C=!0,p=!1,R=V.computeFrenetFrames(l,!1),k=new w.Vector3,le=new w.Vector3,Z=new w.Vector3),p||(M=0,f=0,d=0,m=0);const Ge=a.extractPoints(u);let N=Ge.shape;const D=Ge.holes;if(!w.ShapeUtils.isClockWise(N)){N=N.reverse();for(let g=0,v=D.length;g<v;g++){const b=D[g];w.ShapeUtils.isClockWise(b)&&(D[g]=b.reverse())}}const ce=w.ShapeUtils.triangulateShape(N,D),q=N;for(let g=0,v=D.length;g<v;g++){const b=D[g];N=N.concat(b)}function ne(g,v,b){return v||console.error("THREE.ExtrudeGeometry: vec does not exist"),g.clone().addScaledVector(v,b)}const J=N.length,fe=ce.length;function Ee(g,v,b){let A,x,S;const P=g.x-v.x,L=g.y-v.y,W=b.x-g.x,G=b.y-g.y,ue=P*P+L*L,we=P*G-L*W;if(Math.abs(we)>Number.EPSILON){const Y=Math.sqrt(ue),Re=Math.sqrt(W*W+G*G),Ne=v.x-L/Y,ke=v.y+P/Y,bt=b.x-G/Re,xt=b.y+W/Re,qe=((bt-Ne)*G-(xt-ke)*W)/(P*G-L*W);A=Ne+P*qe-g.x,x=ke+L*qe-g.y;const Fe=A*A+x*x;if(Fe<=2)return new w.Vector2(A,x);S=Math.sqrt(Fe/2)}else{let Y=!1;P>Number.EPSILON?W>Number.EPSILON&&(Y=!0):P<-Number.EPSILON?W<-Number.EPSILON&&(Y=!0):Math.sign(L)===Math.sign(G)&&(Y=!0),Y?(A=-L,x=P,S=Math.sqrt(ue)):(A=P,x=L,S=Math.sqrt(ue/2))}return new w.Vector2(A/S,x/S)}const pe=[];for(let g=0,v=q.length,b=v-1,A=g+1;g<v;g++,b++,A++)b===v&&(b=0),A===v&&(A=0),pe[g]=Ee(q[g],q[b],q[A]);const xe=[];let ie,de=pe.concat();for(let g=0,v=D.length;g<v;g++){const b=D[g];ie=[];for(let A=0,x=b.length,S=x-1,P=A+1;A<x;A++,S++,P++)S===x&&(S=0),P===x&&(P=0),ie[A]=Ee(b[A],b[S],b[P]);xe.push(ie),de=de.concat(ie)}for(let g=0;g<M;g++){const v=g/M,b=f*Math.cos(v*Math.PI/2),A=d*Math.sin(v*Math.PI/2)+m;for(let x=0,S=q.length;x<S;x++){const P=ne(q[x],pe[x],A);X(P.x,P.y,-b)}for(let x=0,S=D.length;x<S;x++){const P=D[x];ie=xe[x];for(let L=0,W=P.length;L<W;L++){const G=ne(P[L],ie[L],A);X(G.x,G.y,-b)}}}const ze=d+m;for(let g=0;g<J;g++){const v=p?ne(N[g],de[g],ze):N[g];C?(le.copy(R.normals[0]).multiplyScalar(v.x),k.copy(R.binormals[0]).multiplyScalar(v.y),Z.copy(j[0]).add(le).add(k),X(Z.x,Z.y,Z.z)):X(v.x,v.y,0)}for(let g=1;g<=l;g++)for(let v=0;v<J;v++){const b=p?ne(N[v],de[v],ze):N[v];C?(le.copy(R.normals[g]).multiplyScalar(b.x),k.copy(R.binormals[g]).multiplyScalar(b.y),Z.copy(j[g]).add(le).add(k),X(Z.x,Z.y,Z.z)):X(b.x,b.y,h/l*g)}for(let g=M-1;g>=0;g--){const v=g/M,b=f*Math.cos(v*Math.PI/2),A=d*Math.sin(v*Math.PI/2)+m;for(let x=0,S=q.length;x<S;x++){const P=ne(q[x],pe[x],A);X(P.x,P.y,h+b)}for(let x=0,S=D.length;x<S;x++){const P=D[x];ie=xe[x];for(let L=0,W=P.length;L<W;L++){const G=ne(P[L],ie[L],A);C?X(G.x,G.y+j[l-1].y,j[l-1].x+b):X(G.x,G.y,h+b)}}}gt(),O&&yt();function gt(){const g=s.length/3;if(p){let v=0,b=J*v;if(T)for(let A=0;A<fe;A++){const x=ce[A];me(x[2]+b,x[1]+b,x[0]+b)}if(v=l+M*2,b=J*v,_)for(let A=0;A<fe;A++){const x=ce[A];me(x[0]+b,x[1]+b,x[2]+b)}}else{if(T)for(let v=0;v<fe;v++){const b=ce[v];me(b[2],b[1],b[0])}if(_)for(let v=0;v<fe;v++){const b=ce[v];me(b[0]+J*l,b[1]+J*l,b[2]+J*l)}}i.addGroup(g,s.length/3-g,0)}function yt(){const g=s.length/3;let v=0;Ue(q,v),v+=q.length;for(let b=0,A=D.length;b<A;b++){const x=D[b];Ue(x,v),v+=x.length}i.addGroup(g,s.length/3-g,1)}function Ue(g,v){let b=g.length;for(;--b>=0;){const A=b;let x=b-1;x<0&&(x=g.length-1);for(let S=0,P=l+M*2;S<P;S++){const L=J*S,W=J*(S+1),G=v+A+L,ue=v+x+L,we=v+x+W,Y=v+A+W;vt(G,ue,we,Y)}}}function X(g,v,b){c.push(g),c.push(v),c.push(b)}function me(g,v,b){K(g),K(v),K(b);const A=s.length/3,x=B.generateTopUV(i,s,A-3,A-2,A-1);Q(x[0]),Q(x[1]),Q(x[2])}function vt(g,v,b,A){K(g),K(v),K(A),K(v),K(b),K(A);const x=s.length/3,S=B.generateSideWallUV(i,s,x-6,x-3,x-2,x-1);Q(S[0]),Q(S[1]),Q(S[3]),Q(S[1]),Q(S[2]),Q(S[3])}function K(g){s.push(c[g*3+0]),s.push(c[g*3+1]),s.push(c[g*3+2])}function Q(g){r.push(g.x),r.push(g.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 ti(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,n=e.shapes.length;r<n;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 y[`${s.type}Curve`]().fromJSON(s)),new Ie(i,e.options)}}const ei={generateTopUV:function(o,e,t,i,s){const r=e[t*3],n=e[t*3+1],a=e[i*3],c=e[i*3+1],u=e[s*3],l=e[s*3+1];return[new w.Vector2(r,n),new w.Vector2(a,c),new w.Vector2(u,l)]},generateSideWallUV:function(o,e,t,i,s,r){const n=e[t*3],a=e[t*3+1],c=e[t*3+2],u=e[i*3],l=e[i*3+1],h=e[i*3+2],p=e[s*3],f=e[s*3+1],d=e[s*3+2],m=e[r*3],M=e[r*3+1],V=e[r*3+2];return Math.abs(a-l)<Math.abs(n-u)?[new w.Vector2(n,1-c),new w.Vector2(u,1-h),new w.Vector2(p,1-d),new w.Vector2(m,1-V)]:[new w.Vector2(a,1-c),new w.Vector2(l,1-h),new w.Vector2(f,1-d),new w.Vector2(M,1-V)]}};function ti(o,e,t){if(t.shapes=[],Array.isArray(o))for(let i=0,s=o.length;i<s;i++){const r=o[i];t.shapes.push(r.uuid)}else t.shapes.push(o.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}const at=o=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:n,hasSide:a,sideRepeat:c}=o,u=new Ie(new y.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:Le.getUVGenerator({split:e,box3:s,sideRepeat:c}),hasTop:r,hasBottom:n,hasSide:a});return Le.claerUVGenerator(),u};class ii extends te.BaseObject{constructor(e){super(),this.options=I({depth:1},e)}create(){return se(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:n,material:a,box3:c,split:u,hasTop:l,hasBottom:h,hasSide:p}=this.options,f=Array.isArray(s)?s:[s],d=Array.isArray(c)?c:[c],m=a;let M=r;m||console.log("material is null"),!M&&e?M=at({points:e,depth:f[0],box3:d[0],split:u,hasTop:l,hasBottom:h,hasSide:p}):!M&&t?M=ee(t.map((V,B)=>{var _,T;return at({points:V,depth:(_=f[B])!=null?_:f[0],box3:(T=d[B])!=null?T:d[0],split:u,hasTop:l,hasBottom:h,hasSide:p})}),i!=null?i:0):!M&&n&&n.length>1?M=ee(n,i!=null?i:0):!M&&n&&n.length===1&&([M]=n),this.createMesh(M,m)})}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 si=o=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:n}=o;return new Promise(a=>{const c=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const u=r,l=document.createElement("canvas"),h=l.getContext("2d");l.height=c.height/(1-u),l.width=c.width,u&&e&&(h.fillStyle=e,h.fillRect(0,0,c.width,l.height*u)),i&&c instanceof HTMLImageElement?h.drawImage(c,0,l.height*u,c.width,c.height):t&&(h.fillStyle=t,h.fillRect(0,l.height*u,c.width,c.height)),s&&l.toBlob(f=>{console.log(URL.createObjectURL(f))});const p=new y.CanvasTexture(l);a(p)},i?c.src=i:c instanceof HTMLImageElement||c.onload()})};exports.Group=_t.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>je.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>lt.LineMaterial});exports.ConicPolygon=Yt;exports.ExtrudePolygon=ii;exports.Image=ht;exports.Light=Ut;exports.Line=$t;exports.Line2=Nt;exports.MeshLineGeometry=ft;exports.MeshLineMaterial=pt;exports.MeshLineRaycast=Ht;exports.Node=Et;exports.Pie=zt;exports.Text=It;exports.Video=Gt;exports.getConicPolygonGeometry=mt;exports.getConicPolygonGeometryMetas=dt;exports.getSplitTexture=si;
|