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