gl-draw 0.10.0 → 0.10.2
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/index.js +1 -1
- package/dist/index.module.js +1 -1
- package/dist/objects/extrudePolygon/index.d.ts +0 -1
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +3 -3
- package/dist/objects/index.module.js +430 -440
- package/dist/objects/line/index.d.ts +0 -1
- package/dist/objects/line2/index.d.ts +0 -1
- package/dist/plugins/Worker/index.d.ts +0 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +84 -109
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.module.js +65 -58
- package/package.json +1 -1
- package/dist/getProjection.js +0 -1
- package/dist/getProjection.module.js +0 -12
package/dist/index.js
CHANGED
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
void main() {
|
|
12
12
|
gl_FragColor = ( texture2D( baseTexture, vUv ) + vec4( 1.0 ) * texture2D( bloomTexture, vUv ) );
|
|
13
13
|
}
|
|
14
|
-
`,defines:{}}),"baseTexture");l.needsSwap=!0,this.bloomComposer=a,this.finalComposer.addPass(l),this.bloomLayer.set(ut)}addBloomGui(t){if(!this.bloomComposer)return;new ft({bloom:{threshold:{min:0,max:
|
|
14
|
+
`,defines:{}}),"baseTexture");l.needsSwap=!0,this.bloomComposer=a,this.finalComposer.addPass(l),this.bloomLayer.set(ut)}addBloomGui(t){if(!this.bloomComposer)return;new ft({bloom:{threshold:{min:0,max:1,step:.01,target:()=>this.bloomPass},radius:{min:0,max:1,step:.001,target:()=>this.bloomPass},strength:{min:0,max:10,step:.001,target:()=>this.bloomPass}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}const{object3d:s}=t;if(!s)return;let i=e;e===void 0&&(i=!this.bloomSelection.has(s)),i?(this.bloomSelection.add(s),s.layers.enable(ut)):(this.bloomSelection.delete(s),s.layers.disable(ut)),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){var s;(s=this.bloomComposer)==null||s.setSize(t,e),this.finalComposer.setSize(t,e)}render(){this.active&&(this.bloomComposerActive&&this.bloomComposer&&(this.scene.traverse(t=>{const e=t;e.isMesh&&this.bloomLayer.test(e.layers)===!1&&(this.bloomMaterials[e.uuid]=e.material,e.material=ge)}),this.bloomComposer.render(),this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]&&(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid])})),this.finalComposer.render())}render2(){this.active}dispose(){var t;this.bloomMaterials={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const nt=class nt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new Lt.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=Nt(nt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new jt;a.open(!1),this.gui=a}if(i){const a=new qt;a.showPanel(0),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.renderer.capabilities.getMaxAnisotropy()}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new x.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new x.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,helper:s,renderer:i,scene:o,camera:r,control:a}=this.options,{width:l,height:c}=this.getSize(),g=new ce({isdev:e,width:l,height:c,cameraParams:r,cameraControls:a===!0});this.gui&&g.setGui(this.gui);const _=g.camera,O=new me({camera:_,sceneParams:o}),p=O.scene,w=new he({width:l,height:c,scene:p,camera:_,isdev:e,rendererParams:ht(j({},i),{antialias:!1})});if(s){const f=new _e({scene:p});f.add(p),this.helperController=f}this.sceneController=O,this.rendererController=w,this.cameraController=g,t.appendChild(w.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,multisampling:s}=this.options,i=new Ce({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:s}});this.composerController=i,t&&(i.addBloomPass(e),this.gui&&i.addBloomGui(this.gui)),i.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new fe(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new pe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ue({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(l=>{var c;(c=l.setSize)==null||c.call(l,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!1){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,l=r.getBoundingClientRect();if(a.x=(t.clientX-l.left)/(l.right-l.left)*2-1,a.y=-((t.clientY-l.top)/(l.bottom-l.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,l,c,g,_;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Ot.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(O=>{var p;(p=O.update)==null||p.call(O,i,o)}),(a=this.helperController)==null||a.update(),this.cameraController.syncCamera&&!(this.camera.matrixWorld.equals(this.cameraController.syncCamera.matrixWorld)&&this.camera.far===this.cameraController.syncCamera.far&&this.camera.near===this.cameraController.syncCamera.near&&this.camera.fov===this.cameraController.syncCamera.fov&&this.camera.aspect===this.cameraController.syncCamera.aspect)&&this.camera.copy(this.cameraController.syncCamera),(l=this.composerController)!=null&&l.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(g=this.cssRendererController)==null||g.render(t,e),(_=this.stats)==null||_.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,l=this.cameraController.camera2;l&&l.aspect!==a&&(l.aspect=a,l.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,l,c,g,_;this.stop(),Ot.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(O=>{var p;(p=O.dispose)==null||p.call(O)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(g=this.stats)==null||g.dom.remove(),(_=this.renderer)==null||_.domElement.remove()}};nt.options={isdev:J,stats:J,gui:J,helper:J,control:!0,transformControls:J,resizeObserver:!0,renderer:ae,multisampling:4,scene:de,camera:le,bloom:!1,bloomParams:ye,css2DRenderer:!1,css2DRendererParams:j({},Ut),css3DRenderer:!1,css3DRendererParams:j({},Ut)};let rt=nt;const Oe=Y.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=ft;exports.Pencil=rt;exports.cameraControlsAction=Oe;exports.default=rt;
|
package/dist/index.module.js
CHANGED
package/dist/objects/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { default as Group } from './group';
|
|
|
6
6
|
export { default as Pie } from './pie';
|
|
7
7
|
export { default as Light } from './light';
|
|
8
8
|
export { default as Line2 } from './line2';
|
|
9
|
-
export {
|
|
9
|
+
export { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry';
|
|
10
10
|
export { LineMaterial as Line2Material } from 'three/examples/jsm/lines/LineMaterial';
|
|
11
11
|
export { MeshLineGeometry, MeshLineMaterial, raycast as MeshLineRaycast, } from './line/meshLine';
|
|
12
12
|
export { default as Line } from './line';
|
package/dist/objects/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var nt=Object.defineProperty,ot=Object.defineProperties;var at=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var Ue=Math.pow,Ge=(o,e,t)=>e in o?nt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,B=(o,e)=>{for(var t in e||(e={}))Be.call(e,t)&&Ge(o,t,e[t]);if(ue)for(var t of ue(e))Ie.call(e,t)&&Ge(o,t,e[t]);return o},pe=(o,e)=>ot(o,at(e));var de=(o,e)=>{var t={};for(var i in o)Be.call(o,i)&&e.indexOf(i)<0&&(t[i]=o[i]);if(o!=null&&ue)for(var i of ue(o))e.indexOf(i)<0&&Ie.call(o,i)&&(t[i]=o[i]);return t};var K=(o,e,t)=>new Promise((i,s)=>{var r=u=>{try{l(t.next(u))}catch(c){s(c)}},n=u=>{try{l(t.throw(u))}catch(c){s(c)}},l=u=>u.done?i(u.value):Promise.resolve(u.value).then(r,n);l((t=t.apply(o,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("three"),J=require("../BaseObject.js"),lt=require("esus-lite"),ut=require("../index2.js"),ct=require("@tweenjs/tween.js"),ht=require("three/examples/jsm/lines/Line2.js"),Ne=require("three/examples/jsm/lines/LineGeometry"),He=require("three/examples/jsm/lines/LineMaterial"),Y=require("d3-array"),ve=require("earcut"),ft=require("@turf/boolean-clockwise"),ye=require("../uvGenerator.js"),pt=require("delaunator"),dt=require("@turf/boolean-point-in-polygon"),re=require("d3-geo"),mt=require("d3-geo-voronoi"),ze=require("d3-scale");function $e(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 g=$e(S),ee=$e(ct),gt=+g.REVISION<144,Ze=gt?"PlaneBufferGeometry":"PlaneGeometry";class Je extends J.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=B({scale:1},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}getMaterial(){return K(this,null,function*(){const{src:e,texture:t,transparent:i,opacity:s,blending:r,depthWrite:n,depthTest:l,alphaTest:u,sprite:c,sizeAttenuation:a,color:p}=this.options,h=t||(yield new g.TextureLoader().loadAsync(e));return c?new g.SpriteMaterial({map:h,transparent:i!=null?i:!1,blending:r!=null?r:g.NormalBlending,depthWrite:n!=null?n:!0,depthTest:l!=null?l:!0,alphaTest:u!=null?u:0,opacity:s!=null?s:1,sizeAttenuation:a!=null?a:!0}):new g.MeshBasicMaterial({color:p!=null?p:16777215,map:h,transparent:i!=null?i:!1,blending:r!=null?r:g.NormalBlending,depthWrite:n!=null?n:!0,depthTest:l!=null?l:!0,alphaTest:u!=null?u:0,opacity:s!=null?s:1})})}create(){return K(this,null,function*(){const{position:e,material:t,sprite:i}=this.options,s=t||(yield this.getMaterial());i?this.createSprite(s):this.createMesh(new g[Ze](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 vt extends Je{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:l,setCtx:u}=B({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:f=>{}},t||{}),{canvas:c}=this;c.width=i*e.length*2,c.height=i;let a=c.getContext("2d");a.font=`${r} ${i}px/1 ${s}`;const{width:p}=a.measureText(e);c.width=p,a=c.getContext("2d"),a.clearRect(0,0,c.width,c.height),n&&a.scale(-1,1),a.font=`${r} ${i}px/1 ${s}`,a.textBaseline="middle",a.fillStyle=l,u&&u(a),a.fillText(e,n?p*-1:0,c.height/2),a.restore();const h=new g.Texture(c);return h.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),h.needsUpdate=!0,Promise.resolve(h)}}class yt extends J.BaseObject{constructor(e){super(),this.scaleValue=1,this.options=B({scale:1,autoPlay:!0,loop:!0},e)}getMaterial(){const{src:e,transparent:t,blending:i,depthWrite:s,depthTest:r,format:n,autoPlay:l,loop:u,alphaTest:c,sprite:a}=this.options,p=lt.makePromiseCreator();if(!e)return Promise.reject("src is required");const h=document.createElement("video");return h.addEventListener("loadedmetadata",()=>{const f=new g.VideoTexture(h);f.format=n!=null?n:g.RGBAFormat,f.needsUpdate=!0;const v=a?new g.SpriteMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:g.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:c!=null?c:0}):new g.MeshBasicMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:g.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:c!=null?c:0});p.resolve(v)},!1),h.src=e,h.muted=!0,h.autoplay=l,h.loop=u,h.preload="auto",p.promise}create(){return K(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 g[Ze](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 bt extends J.BaseObject{constructor(e){super(),this.objectType="BaseObject#Node",this.drawGroupShow=!0,this.visibleCache=!0,this.options=B({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 l=Array.isArray(s)?s:[s],u=Array.isArray(i)?i:[i];l.forEach((c,a)=>{const p=u[a];p&&n.addEventListener(c,p)})})}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,l)=>{const u=r[l];u&&i.removeEventListener(n,u)})}),super.dispose()}}class xt extends J.BaseObject{constructor(e){super(),this.options=B({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return K(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:i,material:s,percentDepth:r,activeIndex:n}=this.options,l=Math.max(...e),u=e.reduce((a,p)=>a+p,0);let c=Math.PI/2;e.forEach((a,p)=>{if(a===0)return;const h=Math.PI*2*(a/u),f=i[p],v=r?t*(a/l):t,d=this.createGeometry(v,h),A=s?s.clone():new g.MeshBasicMaterial({color:f});s&&A.color.set(f);const M=new g.Mesh(d,A);M.userData.depth=v,M.userData.index=p,M.rotateZ(c),c+=h,this.add(M)}),n!==-1&&this.setActive(n)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new g.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 g.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 ee.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 ee.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 ee.Tween(this.object3d.scale).to({z:1},1e3).easing(ee.Easing.Sinusoidal.InOut).start()}}class wt extends J.BaseObject{constructor(e){super(),this.options=e}create(){var t,i,s,r,n,l,u,c,a,p,h,f,v;const e=this.options;if(e.type==="AmbientLight"){const d=new g.AmbientLight(e.color);d.name="AmbientLight",this.object3d=d}else if(e.type==="DirectionalLight"){const d=new g.DirectionalLight(e.color,e.intensity);d.name="DirectionalLight",d.target.position.set(0,0,0),this.object3d=d,this.pencil.scene.add(d.target),this.directionalLight=d}else if(e.type==="PointLight"){const d=new g.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);d.name="PointLight",this.object3d=d,this.pointLight=d}else if(e.type==="SpotLight"){const d=new g.SpotLight((n=e.color)!=null?n:16777215,(l=e.intensity)!=null?l:1,(u=e.distance)!=null?u:0,(c=e.angle)!=null?c:Math.PI/3,(a=e.penumbra)!=null?a:1,(p=e.decay)!=null?p:2);d.name="SpotLight",this.object3d=d,this.spotLight=d,this.pencil.scene.add(d.target)}else if(e.type==="HemisphereLight"){const d=new g.HemisphereLight((h=e.color)!=null?h:16777215,(f=e.groundColor)!=null?f:16777215,(v=e.intensity)!=null?v:1);d.name="HemisphereLight",this.object3d=d,this.hemisphereLight=d}}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 Z(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={},l=o[0].morphTargetsRelative,u=new S.BufferGeometry;let c=0;for(let a=0;a<o.length;++a){const p=o[a];let h=0;if(t!==(p.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in p.attributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+'. 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(p.attributes[f]),h++}if(h!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". Make sure all geometries have the same number of attributes."),null;if(l!==p.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in p.morphAttributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphAttributes must be consistent throughout all geometries."),null;n[f]===void 0&&(n[f]=[]),n[f].push(p.morphAttributes[f])}if(e){let f;if(t)f=p.index.count;else if(p.attributes.position!==void 0)f=p.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". The geometry must have either an index or a position attribute"),null;if(e===1)u.addGroup(c,f,a);else if(e===2&&p.groups.length>0)for(let v of p.groups){let d=v.materialIndex;u.addGroup(c+v.start,Math.min(v.count,f),d)}c+=f}}if(t){let a=0;const p=[];for(let h=0;h<o.length;++h){const f=o[h].index;for(let v=0;v<f.count;++v)p.push(f.getX(v)+a);a+=o[h].attributes.position.count}u.setIndex(p)}for(const a in r){const p=Oe(r[a]);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" attribute."),null;u.setAttribute(a,p)}for(const a in n){const p=n[a][0].length;if(p===0)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[a]=[];for(let h=0;h<p;++h){const f=[];for(let d=0;d<n[a].length;++d)f.push(n[a][d][h]);const v=Oe(f);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" morphAttribute."),null;u.morphAttributes[a].push(v)}}return e===2?At(u):u}function Oe(o){let e,t,i,s=-1,r=0;for(let c=0;c<o.length;++c){const a=o[c];if(e===void 0&&(e=a.array.constructor),e!==a.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=a.itemSize),t!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=a.normalized),i!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=a.gpuType),s!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=a.count*t}const n=new e(r),l=new S.BufferAttribute(n,t,i);let u=0;for(let c=0;c<o.length;++c){const a=o[c];if(a.isInterleavedBufferAttribute){const p=u/t;for(let h=0,f=a.count;h<f;h++)for(let v=0;v<t;v++){const d=a.getComponent(h,v);l.setComponent(h+p,v,d)}}else n.set(a.array,u);u+=a.count*t}return s!==void 0&&(l.gpuType=s),l}function At(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,l)=>n.materialIndex!==l.materialIndex?n.materialIndex-l.materialIndex:n.start-l.start),o.getIndex()===null){const n=o.getAttribute("position"),l=[];for(let u=0;u<n.count;u+=3)l.push(u,u+1,u+2);o.setIndex(l)}const t=o.getIndex(),i=[];for(let n=0;n<e.length;n++){const l=e[n],u=l.start,c=u+l.count;for(let a=u;a<c;a++)i.push(t.getX(a))}o.dispose(),o.setIndex(i);let s=0;for(let n=0;n<e.length;n++){const l=e[n];l.start=s,s+=l.count}let r=e[0];o.groups=[r];for(let n=1;n<e.length;n++){const l=e[n];r.materialIndex===l.materialIndex?r.count+=l.count:(r=l,o.groups.push(r))}return o}const De=o=>{const{points:e}=o;return new g.BufferGeometry().setFromPoints(e)};let Mt=class extends J.BaseObject{constructor(e={}){super(),this.options=B({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return K(this,null,function*(){const{points:e,pointsArr:t,geometry:i,geometryArr:s,material:r,useGroups:n,setPointWidth:l,lineWidthArr:u,useUserDataPos:c,materialParameters:a}=this.options;let p=r,h=i;!p&&a&&(p=this.getMaterial(a)),!h&&e?h=De({points:e}):!h&&t?h=Z(t.map(d=>De({points:d})),n!=null?n:0):!h&&s&&s.length>1?h=Z(s,n!=null?n:0):!h&&s&&s.length===1&&([h]=s);const f=new Ne.LineGeometry().fromLine(new g.Line(h)),v=new ht.Line2(f,p);if(this.object3d=v,c&&(h!=null&&h.userData.position)){const{x:d,y:A,z:M}=h.userData.position;this.object3d.position.set(d,A,M)}})}getMaterial(e){return new He.LineMaterial(B({color:new g.Color("#ffffff")},e))}};function me(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 _t(o){return o instanceof Float32Array?o:o instanceof g.BufferGeometry?o.getAttribute("position").array:o.map(e=>{const t=Array.isArray(e);return e instanceof g.Vector3?[e.x,e.y,e.z]:e instanceof g.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 Xe extends g.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 g.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=_t(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof g.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 g.BufferAttribute(new Float32Array(this.positions),3),previous:new g.BufferAttribute(new Float32Array(this.previous),3),next:new g.BufferAttribute(new Float32Array(this.next),3),side:new g.BufferAttribute(new Float32Array(this.side),1),width:new g.BufferAttribute(new Float32Array(this.width),1),uv:new g.BufferAttribute(new Float32Array(this.uvs),2),index:new g.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new g.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,l=s.length;me(s,0,r,0,l),me(s,6,s,0,l-6),s[l-6]=e,s[l-5]=t,s[l-4]=i,s[l-3]=e,s[l-2]=t,s[l-1]=i,me(s,6,n,0,l-6),n[l-6]=e,n[l-5]=t,n[l-4]=i,n[l-3]=e,n[l-2]=t,n[l-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const Re=["encodings_fragment","colorspace_fragment"],St=`
|
|
1
|
+
"use strict";var nt=Object.defineProperty,ot=Object.defineProperties;var at=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var Oe=Math.pow,Ee=(o,e,t)=>e in o?nt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,E=(o,e)=>{for(var t in e||(e={}))Be.call(e,t)&&Ee(o,t,e[t]);if(ue)for(var t of ue(e))Ie.call(e,t)&&Ee(o,t,e[t]);return o},pe=(o,e)=>ot(o,at(e));var de=(o,e)=>{var t={};for(var i in o)Be.call(o,i)&&e.indexOf(i)<0&&(t[i]=o[i]);if(o!=null&&ue)for(var i of ue(o))e.indexOf(i)<0&&Ie.call(o,i)&&(t[i]=o[i]);return t};var K=(o,e,t)=>new Promise((i,s)=>{var r=u=>{try{l(t.next(u))}catch(c){s(c)}},n=u=>{try{l(t.throw(u))}catch(c){s(c)}},l=u=>u.done?i(u.value):Promise.resolve(u.value).then(r,n);l((t=t.apply(o,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("three"),J=require("../BaseObject.js"),lt=require("esus-lite"),ut=require("../index2.js"),ct=require("@tweenjs/tween.js"),ht=require("three/examples/jsm/lines/LineSegments2"),Ne=require("three/examples/jsm/lines/LineSegmentsGeometry"),He=require("three/examples/jsm/lines/LineMaterial"),Y=require("d3-array"),ye=require("earcut"),ft=require("@turf/boolean-clockwise"),ve=require("../uvGenerator.js"),pt=require("delaunator"),dt=require("@turf/boolean-point-in-polygon"),re=require("d3-geo"),mt=require("d3-geo-voronoi"),Ue=require("d3-scale");function $e(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 g=$e(S),ee=$e(ct),gt=+g.REVISION<144,Ze=gt?"PlaneBufferGeometry":"PlaneGeometry";class Je extends J.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 K(this,null,function*(){const{src:e,texture:t,transparent:i,opacity:s,blending:r,depthWrite:n,depthTest:l,alphaTest:u,sprite:c,sizeAttenuation:a,color:h}=this.options,p=t||(yield new g.TextureLoader().loadAsync(e));return c?new g.SpriteMaterial({map:p,transparent:i!=null?i:!1,blending:r!=null?r:g.NormalBlending,depthWrite:n!=null?n:!0,depthTest:l!=null?l:!0,alphaTest:u!=null?u:0,opacity:s!=null?s:1,sizeAttenuation:a!=null?a:!0}):new g.MeshBasicMaterial({color:h!=null?h:16777215,map:p,transparent:i!=null?i:!1,blending:r!=null?r:g.NormalBlending,depthWrite:n!=null?n:!0,depthTest:l!=null?l:!0,alphaTest:u!=null?u:0,opacity:s!=null?s:1})})}create(){return K(this,null,function*(){const{position:e,material:t,sprite:i}=this.options,s=t||(yield this.getMaterial());i?this.createSprite(s):this.createMesh(new g[Ze](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 yt extends Je{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:l,setCtx:u}=E({fontSize:28,fontFamily:"system-ui,-apple-system,BlinkMacSystemFont,sans-serif",fontWeight:"normal",flipX:!1,color:"#ffffff",setCtx:f=>{}},t||{}),{canvas:c}=this;c.width=i*e.length*2,c.height=i;let a=c.getContext("2d");a.font=`${r} ${i}px/1 ${s}`;const{width:h}=a.measureText(e);c.width=h,a=c.getContext("2d"),a.clearRect(0,0,c.width,c.height),n&&a.scale(-1,1),a.font=`${r} ${i}px/1 ${s}`,a.textBaseline="middle",a.fillStyle=l,u&&u(a),a.fillText(e,n?h*-1:0,c.height/2),a.restore();const p=new g.Texture(c);return p.anisotropy=this.pencil.renderer.capabilities.getMaxAnisotropy(),p.needsUpdate=!0,Promise.resolve(p)}}class vt extends J.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:l,loop:u,alphaTest:c,sprite:a}=this.options,h=lt.makePromiseCreator();if(!e)return Promise.reject("src is required");const p=document.createElement("video");return p.addEventListener("loadedmetadata",()=>{const f=new g.VideoTexture(p);f.format=n!=null?n:g.RGBAFormat,f.needsUpdate=!0;const y=a?new g.SpriteMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:g.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:c!=null?c:0}):new g.MeshBasicMaterial({map:f,transparent:t!=null?t:!1,blending:i!=null?i:g.NormalBlending,depthWrite:s!=null?s:!0,depthTest:r!=null?r:!0,alphaTest:c!=null?c:0});h.resolve(y)},!1),p.src=e,p.muted=!0,p.autoplay=l,p.loop=u,p.preload="auto",h.promise}create(){return K(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 g[Ze](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 bt extends J.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 l=Array.isArray(s)?s:[s],u=Array.isArray(i)?i:[i];l.forEach((c,a)=>{const h=u[a];h&&n.addEventListener(c,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,l)=>{const u=r[l];u&&i.removeEventListener(n,u)})}),super.dispose()}}class xt extends J.BaseObject{constructor(e){super(),this.options=E({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},e)}create(){return K(this,null,function*(){this.createGroup();const{data:e,maxDepth:t,colors:i,material:s,percentDepth:r,activeIndex:n}=this.options,l=Math.max(...e),u=e.reduce((a,h)=>a+h,0);let c=Math.PI/2;e.forEach((a,h)=>{if(a===0)return;const p=Math.PI*2*(a/u),f=i[h],y=r?t*(a/l):t,d=this.createGeometry(y,p),A=s?s.clone():new g.MeshBasicMaterial({color:f});s&&A.color.set(f);const P=new g.Mesh(d,A);P.userData.depth=y,P.userData.index=h,P.rotateZ(c),c+=p,this.add(P)}),n!==-1&&this.setActive(n)})}createGeometry(e,t){const{outRadius:i,innerRadius:s}=this.options,r=new g.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 g.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 ee.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 ee.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 ee.Tween(this.object3d.scale).to({z:1},1e3).easing(ee.Easing.Sinusoidal.InOut).start()}}class wt extends J.BaseObject{constructor(e){super(),this.options=e}create(){var t,i,s,r,n,l,u,c,a,h,p,f,y;const e=this.options;if(e.type==="AmbientLight"){const d=new g.AmbientLight(e.color);d.name="AmbientLight",this.object3d=d}else if(e.type==="DirectionalLight"){const d=new g.DirectionalLight(e.color,e.intensity);d.name="DirectionalLight",d.target.position.set(0,0,0),this.object3d=d,this.pencil.scene.add(d.target),this.directionalLight=d}else if(e.type==="PointLight"){const d=new g.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);d.name="PointLight",this.object3d=d,this.pointLight=d}else if(e.type==="SpotLight"){const d=new g.SpotLight((n=e.color)!=null?n:16777215,(l=e.intensity)!=null?l:1,(u=e.distance)!=null?u:0,(c=e.angle)!=null?c:Math.PI/3,(a=e.penumbra)!=null?a:1,(h=e.decay)!=null?h:2);d.name="SpotLight",this.object3d=d,this.spotLight=d,this.pencil.scene.add(d.target)}else if(e.type==="HemisphereLight"){const d=new g.HemisphereLight((p=e.color)!=null?p:16777215,(f=e.groundColor)!=null?f:16777215,(y=e.intensity)!=null?y:1);d.name="HemisphereLight",this.object3d=d,this.hemisphereLight=d}}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 Z(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={},l=o[0].morphTargetsRelative,u=new S.BufferGeometry;let c=0;for(let a=0;a<o.length;++a){const h=o[a];let p=0;if(t!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". 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 "+a+'. 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 "+a+". Make sure all geometries have the same number of attributes."),null;if(l!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .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 "+a+". .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 "+a+". The geometry must have either an index or a position attribute"),null;if(e===1)u.addGroup(c,f,a);else if(e===2&&h.groups.length>0)for(let y of h.groups){let d=y.materialIndex;u.addGroup(c+y.start,Math.min(y.count,f),d)}c+=f}}if(t){let a=0;const h=[];for(let p=0;p<o.length;++p){const f=o[p].index;for(let y=0;y<f.count;++y)h.push(f.getX(y)+a);a+=o[p].attributes.position.count}u.setIndex(h)}for(const a in r){const h=ze(r[a]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" attribute."),null;u.setAttribute(a,h)}for(const a in n){const h=n[a][0].length;if(h===0)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[a]=[];for(let p=0;p<h;++p){const f=[];for(let d=0;d<n[a].length;++d)f.push(n[a][d][p]);const y=ze(f);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" morphAttribute."),null;u.morphAttributes[a].push(y)}}return e===2?At(u):u}function ze(o){let e,t,i,s=-1,r=0;for(let c=0;c<o.length;++c){const a=o[c];if(e===void 0&&(e=a.array.constructor),e!==a.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=a.itemSize),t!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=a.normalized),i!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=a.gpuType),s!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=a.count*t}const n=new e(r),l=new S.BufferAttribute(n,t,i);let u=0;for(let c=0;c<o.length;++c){const a=o[c];if(a.isInterleavedBufferAttribute){const h=u/t;for(let p=0,f=a.count;p<f;p++)for(let y=0;y<t;y++){const d=a.getComponent(p,y);l.setComponent(p+h,y,d)}}else n.set(a.array,u);u+=a.count*t}return s!==void 0&&(l.gpuType=s),l}function At(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,l)=>n.materialIndex!==l.materialIndex?n.materialIndex-l.materialIndex:n.start-l.start),o.getIndex()===null){const n=o.getAttribute("position"),l=[];for(let u=0;u<n.count;u+=3)l.push(u,u+1,u+2);o.setIndex(l)}const t=o.getIndex(),i=[];for(let n=0;n<e.length;n++){const l=e[n],u=l.start,c=u+l.count;for(let a=u;a<c;a++)i.push(t.getX(a))}o.dispose(),o.setIndex(i);let s=0;for(let n=0;n<e.length;n++){const l=e[n];l.start=s,s+=l.count}let r=e[0];o.groups=[r];for(let n=1;n<e.length;n++){const l=e[n];r.materialIndex===l.materialIndex?r.count+=l.count:(r=l,o.groups.push(r))}return o}const Re=o=>{const{points:e}=o,t=e.reduce((s,r,n)=>(n<e.length-1&&s.push(r,e[n+1]),s),[]);return new g.BufferGeometry().setFromPoints(t)};let Mt=class extends J.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return K(this,null,function*(){const{points:e,pointsArr:t,geometry:i,geometryArr:s,material:r,useGroups:n,setPointWidth:l,lineWidthArr:u,materialParameters:c}=this.options;let a=r,h=i;!a&&c&&(a=this.getMaterial(c)),!h&&e?h=Re({points:e}):!h&&t?h=Z(t.map(y=>Re({points:y})),n!=null?n:0):!h&&s&&s.length>1?h=Z(s,n!=null?n:0):!h&&s&&s.length===1&&([h]=s);const p=new Ne.LineSegmentsGeometry().fromLineSegments(new g.LineSegments(h)),f=new ht.LineSegments2(p,a);f.computeLineDistances(),this.object3d=f})}getMaterial(e){return new He.LineMaterial(E({color:new g.Color("#ffffff")},e))}};function me(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 St(o){return o instanceof Float32Array?o:o instanceof g.BufferGeometry?o.getAttribute("position").array:o.map(e=>{const t=Array.isArray(e);return e instanceof g.Vector3?[e.x,e.y,e.z]:e instanceof g.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 Xe extends g.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 g.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=St(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof g.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 g.BufferAttribute(new Float32Array(this.positions),3),previous:new g.BufferAttribute(new Float32Array(this.previous),3),next:new g.BufferAttribute(new Float32Array(this.next),3),side:new g.BufferAttribute(new Float32Array(this.side),1),width:new g.BufferAttribute(new Float32Array(this.width),1),uv:new g.BufferAttribute(new Float32Array(this.uvs),2),index:new g.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new g.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,l=s.length;me(s,0,r,0,l),me(s,6,s,0,l-6),s[l-6]=e,s[l-5]=t,s[l-4]=i,s[l-3]=e,s[l-2]=t,s[l-1]=i,me(s,6,n,0,l-6),n[l-6]=e,n[l-5]=t,n[l-4]=i,n[l-3]=e,n[l-2]=t,n[l-1]=i,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}const De=["encodings_fragment","colorspace_fragment"],_t=`
|
|
2
2
|
#include <common>
|
|
3
3
|
#include <logdepthbuf_pars_vertex>
|
|
4
4
|
#include <fog_pars_vertex>
|
|
@@ -141,6 +141,6 @@
|
|
|
141
141
|
|
|
142
142
|
#include <fog_fragment>
|
|
143
143
|
#include <tonemapping_fragment>
|
|
144
|
-
#include <${+g.REVISION<154?
|
|
144
|
+
#include <${+g.REVISION<154?De[0]:De[1]}>
|
|
145
145
|
}
|
|
146
|
-
`;class Ke extends g.ShaderMaterial{constructor(e){super({uniforms:pe(B({},g.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new g.Color(16777215)},opacity:{value:1},resolution:{value:new g.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 g.Vector2(1,1)},offset:{value:new g.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new g.Vector2(0,0)},lightColor:{value:new g.Color(16777215)}}),vertexShader:St,fragmentShader:Pt}),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 Tt(o,e){const t=new g.Matrix4,i=new g.Ray,s=new g.Sphere,r=new g.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 l=new g.Vector3,u=new g.Vector3,c=new g.Vector3,a=this instanceof g.LineSegments?2:1,p=n.index,h=n.attributes;if(p!==null){const f=p.array,v=h.position.array,d=h.width.array;for(let A=0,M=f.length-1;A<M;A+=a){const V=f[A],T=f[A+1];l.fromArray(v,V*3),u.fromArray(v,T*3);const L=d[Math.floor(A/3)]!=null?d[Math.floor(A/3)]:1,G=o.params.Line.threshold+this.material.lineWidth*L/2,E=G*G;if(i.distanceSqToSegment(l,u,r,c)>E)continue;r.applyMatrix4(this.matrixWorld);const O=o.ray.origin.distanceTo(r);O<o.near||O>o.far||(e.push({distance:O,point:c.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=M)}}}const ge=o=>{const{setPointWidth:e,nodes:t}=o,i=new Xe;return i.setPoints(t,e),i};class Vt extends J.BaseObject{constructor(e={}){super(),this.options=B({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return K(this,null,function*(){const{nodes:e,nodesArr:t,geometry:i,geometryArr:s,material:r,useGroups:n,setPointWidth:l,lineWidthArr:u,useUserDataPos:c,materialParameters:a}=this.options;let p=r,h=i;if(!p&&a&&(p=this.getMaterial(a)),!h&&e?h=ge({nodes:e,setPointWidth:l}):!h&&t?h=Z(t.map((f,v)=>{let d=l;return!d&&u&&(d=()=>{var A;return(A=u[v])!=null?A:u[0]}),ge({nodes:f,setPointWidth:d})}),n!=null?n:0):!h&&s&&s.length>1?h=Z(s,n!=null?n:0):!h&&s&&s.length===1&&([h]=s),this.createMesh(h,p),c&&(h!=null&&h.userData.position)){const{x:f,y:v,z:d}=h.userData.position;this.object3d.position.set(f,v,d)}})}setGeometry(e,t){const i=ge({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 Ke(B({color:new g.Color("#ffffff"),resolution:new g.Vector2(t,i)},e))}addGeometries(e){const t=this.object3d,i=Z([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:l}={}){const{offset:u,offsetLoop:c}=this.material.uniforms;if(this.material.userData.tween)return;const a=s!=null?s:!0;u.value.x=1,c.value=0;let p=0;const h=new ee.Tween(u.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:f})=>{a&&f<=0&&c.value===0&&(c.value=1),n&&n(f)}).onRepeat(()=>{p+=1,r&&r(p)}).onComplete(()=>{l&&l()}).start();this.material.userData.tween=h}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(),ee.remove(this.material.userData.tween)),super.dispose(e)}}function jt(o,e){return o.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const n=re.geoDistance(r,s)*180/Math.PI;if(n>e){const l=re.geoInterpolate(s,r),u=1/Math.ceil(n/e);let c=u;for(;c<1;)i.push(l(c)),c+=u}}i.push(s=r)}),i})}function Lt(o,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Ue(360/o,2)/Math.PI),n=(1+Math.sqrt(5))/2,l=f=>f/n*360%360-180,u=f=>Math.acos(2*f/r-1)/Math.PI*180-90,c=f=>r*(Math.cos((f+90)*Math.PI/180)+1)/2,a=[s!==void 0?Math.ceil(c(s)):0,i!==void 0?Math.floor(c(i)):r-1],p=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,h=[];for(let f=a[0];f<=a[1];f++){const v=l(f);p(v)&&h.push([v,u(f)])}return h}function be(o,e,t=!1){return t?re.geoContains(e,o):dt(o,e)}function Ct(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[r,n]]=re.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(n-s))<e)return[];const l=i>r||n>=89||s<=-89;return Lt(e,{minLng:i,maxLng:r,minLat:s,maxLat:n}).filter(u=>be(u,t,l))}function Et(o,{resolution:e=1/0,bbox:t}={}){const i=jt(o,e),s=Y.merge(i),r=Ct(o,e),n=[...s,...r],l={type:"Polygon",coordinates:o},[[u,c],[a,p]]=re.geoBounds(l),h=u>a||p>=89||c<=-89;let f=[];if(h){const V=mt.geoVoronoi(n).triangles(),T=new Map(n.map(([L,G],E)=>[`${L}-${G}`,E]));V.features.forEach(L=>{const G=L.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(G.forEach(([C,O])=>{const R=`${C}-${O}`;T.has(R)&&E.push(T.get(R))}),E.length===3){if(E.some(C=>C<s.length)){const C=L.properties.circumcenter;if(!be(C,l,h))return}f.push(...E)}})}else if(r.length){const V=pt.from(n);for(let T=0,L=V.triangles.length;T<L;T+=3){const G=[2,1,0].map(C=>V.triangles[T+C]),E=G.map(C=>n[C]);if(G.some(C=>C<s.length)){const C=[0,1].map(O=>Y.mean(E,R=>R[O]));if(!be(C,l,h))continue}f.push(...G)}}else{const{vertices:V,holes:T=[]}=ve.flatten(i);f=ve(V,T,2)}const v=ze.scaleLinear(t?[t[0],t[2]]:Y.extent(n,V=>V[0]),[0,1]),d=ze.scaleLinear(t?[t[1],t[3]]:Y.extent(n,V=>V[1]),[0,1]),A=n.map(([V,T])=>[v(V),d(T)]);return{contour:i,triangles:{points:n,indices:f,uvs:A}}}const We=new g.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function ce(o,e,t,i){const s=o.map(r=>r.map(([n,l])=>{if(i){const[u,c]=i([n,l]);return[u,-c,e]}return t?ye.polar2Cartesian(n,l,e):[n,l,e]}));return ve.flatten(s)}function Gt(o,e,t,i,s){const{vertices:r,holes:n}=ce(o,e,i,s),{vertices:l}=ce(o,t,i,s),u=Y.merge([l,r]),c=Math.round(l.length/3),a=new Set(n);let p=0;const h=[];for(let v=0;v<c;v++){let d=v+1;if(d===c)d=p;else if(a.has(d)){const A=d;d=p,p=A}h.push(v,v+c,d+c),h.push(d+c,d,v)}const f=[];for(let v=1;v>=0;v--)for(let d=0;d<c;d+=1)f.push(d/(c-1),v);return{indices:h,vertices:u,uvs:f,topVerts:l}}function ke(o,e,t,i,s,r){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:ce([o.points],e,s,r).vertices,uvs:t}}const Qe=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:n=!1,hasTop:l=!1,projection:u,bbox:c})=>{o.forEach(M=>{ft(M)||M.reverse()});const{contour:a,triangles:p}=Et(o,{resolution:i,bbox:c});let h={},f;r&&(h=Gt(a,e!=null?e:t,t!=null?t:e,s,u),f=h.topVerts);let v=[];(n||l)&&(v=Y.merge(p.uvs));let d={};n&&(d=ke(p,e,v,!1,s,u));let A={};return l&&(A=ke(p,t,v,!0,s,u)),{contour:a,triangles:p,sideTorso:h,bottomCap:d,topCap:A,topVerts:f}};class Ye extends g.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=B({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:l,userDataRsoOffset:u,projection:c}=this.parameters,{contour:a,sideTorso:p,topVerts:h,bottomCap:f,topCap:v}=Qe(B({},this.parameters));let d=[],A=[],M=[],V=0;const T=L=>{const G=Math.round(d.length/3),E=M.length;d=d.concat(L.vertices),A=A.concat(L.uvs),M=M.concat(G?L.indices.map(C=>C+G):L.indices),this.addGroup(E,M.length-E,V++)};n&&(T(p),this.userData.topVerts=u?ce(a,i+u,l,c).vertices:h),r&&T(f),s&&T(v),this.setIndex(M),this[We]("position",new g.Float32BufferAttribute(d,3)),this[We]("uv",new g.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const qe=o=>{const l=o,{coordinate:e,startHeight:t,height:i}=l,s=de(l,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(r=t+i),new Ye([e],pe(B({},s),{startHeight:t,endHeight:r}))};class Bt extends J.BaseObject{constructor(e){super(),this.options=B({},e)}create(){const u=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=u,n=de(u,["geometry","coordinateArr","coordinate","material","useGroups"]);let l=e;if(!l&&i)l=qe(B({coordinate:i},n));else if(!l&&t){const c=t.map(a=>qe(B({coordinate:a},n)));l=Z(c,r!=null?r:0)}this.createMesh(l,s)}}class xe extends S.BufferGeometry{constructor(e=new S.Shape([new S.Vector2(.5,.5),new S.Vector2(-.5,.5),new S.Vector2(-.5,-.5),new S.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 l=0,u=e.length;l<u;l++){const c=e[l];n(c)}this.setAttribute("position",new S.Float32BufferAttribute(s,3)),this.setAttribute("uv",new S.Float32BufferAttribute(r,2)),this.computeVertexNormals();function n(l){var Se,Pe,Te;const u=[],c=t.curveSegments!==void 0?t.curveSegments:12,a=t.steps!==void 0?t.steps:1,p=t.depth!==void 0?t.depth:1;let h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,v=t.bevelSize!==void 0?t.bevelSize:f-.1,d=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const M=t.extrudePath,V=t.UVGenerator!==void 0?t.UVGenerator:It,T=(Se=t.hasTop)!=null?Se:!0,L=(Pe=t.hasBottom)!=null?Pe:!0,G=(Te=t.hasSide)!=null?Te:!0;let E,C=!1,O,R,te,k;M&&(E=M.getSpacedPoints(a),C=!0,h=!1,O=M.computeFrenetFrames(a,!1),R=new S.Vector3,te=new S.Vector3,k=new S.Vector3),h||(A=0,f=0,v=0,d=0);const we=l.extractPoints(c);let D=we.shape;const z=we.holes;if(!S.ShapeUtils.isClockWise(D)){D=D.reverse();for(let m=0,y=z.length;m<y;m++){const b=z[m];S.ShapeUtils.isClockWise(b)&&(z[m]=b.reverse())}}const ie=S.ShapeUtils.triangulateShape(D,z),W=D;for(let m=0,y=z.length;m<y;m++){const b=z[m];D=D.concat(b)}function Q(m,y,b){return y||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(y,b)}const q=D.length,ne=ie.length;function Ae(m,y,b){let w,x,_;const P=m.x-y.x,j=m.y-y.y,U=b.x-m.x,I=b.y-m.y,se=P*P+j*j,fe=P*I-j*U;if(Math.abs(fe)>Number.EPSILON){const $=Math.sqrt(se),Ve=Math.sqrt(U*U+I*I),je=y.x-j/$,Le=y.y+P/$,st=b.x-I/Ve,rt=b.y+U/Ve,Ce=((st-je)*I-(rt-Le)*U)/(P*I-j*U);w=je+P*Ce-m.x,x=Le+j*Ce-m.y;const Ee=w*w+x*x;if(Ee<=2)return new S.Vector2(w,x);_=Math.sqrt(Ee/2)}else{let $=!1;P>Number.EPSILON?U>Number.EPSILON&&($=!0):P<-Number.EPSILON?U<-Number.EPSILON&&($=!0):Math.sign(j)===Math.sign(I)&&($=!0),$?(w=-j,x=P,_=Math.sqrt(se)):(w=P,x=j,_=Math.sqrt(se/2))}return new S.Vector2(w/_,x/_)}const oe=[];for(let m=0,y=W.length,b=y-1,w=m+1;m<y;m++,b++,w++)b===y&&(b=0),w===y&&(w=0),oe[m]=Ae(W[m],W[b],W[w]);const he=[];let X,ae=oe.concat();for(let m=0,y=z.length;m<y;m++){const b=z[m];X=[];for(let w=0,x=b.length,_=x-1,P=w+1;w<x;w++,_++,P++)_===x&&(_=0),P===x&&(P=0),X[w]=Ae(b[w],b[_],b[P]);he.push(X),ae=ae.concat(X)}for(let m=0;m<A;m++){const y=m/A,b=f*Math.cos(y*Math.PI/2),w=v*Math.sin(y*Math.PI/2)+d;for(let x=0,_=W.length;x<_;x++){const P=Q(W[x],oe[x],w);F(P.x,P.y,-b)}for(let x=0,_=z.length;x<_;x++){const P=z[x];X=he[x];for(let j=0,U=P.length;j<U;j++){const I=Q(P[j],X[j],w);F(I.x,I.y,-b)}}}const Me=v+d;for(let m=0;m<q;m++){const y=h?Q(D[m],ae[m],Me):D[m];C?(te.copy(O.normals[0]).multiplyScalar(y.x),R.copy(O.binormals[0]).multiplyScalar(y.y),k.copy(E[0]).add(te).add(R),F(k.x,k.y,k.z)):F(y.x,y.y,0)}for(let m=1;m<=a;m++)for(let y=0;y<q;y++){const b=h?Q(D[y],ae[y],Me):D[y];C?(te.copy(O.normals[m]).multiplyScalar(b.x),R.copy(O.binormals[m]).multiplyScalar(b.y),k.copy(E[m]).add(te).add(R),F(k.x,k.y,k.z)):F(b.x,b.y,p/a*m)}for(let m=A-1;m>=0;m--){const y=m/A,b=f*Math.cos(y*Math.PI/2),w=v*Math.sin(y*Math.PI/2)+d;for(let x=0,_=W.length;x<_;x++){const P=Q(W[x],oe[x],w);F(P.x,P.y,p+b)}for(let x=0,_=z.length;x<_;x++){const P=z[x];X=he[x];for(let j=0,U=P.length;j<U;j++){const I=Q(P[j],X[j],w);C?F(I.x,I.y+E[a-1].y,E[a-1].x+b):F(I.x,I.y,p+b)}}}et(),G&&tt();function et(){const m=s.length/3;if(h){let y=0,b=q*y;if(L)for(let w=0;w<ne;w++){const x=ie[w];le(x[2]+b,x[1]+b,x[0]+b)}if(y=a+A*2,b=q*y,T)for(let w=0;w<ne;w++){const x=ie[w];le(x[0]+b,x[1]+b,x[2]+b)}}else{if(L)for(let y=0;y<ne;y++){const b=ie[y];le(b[2],b[1],b[0])}if(T)for(let y=0;y<ne;y++){const b=ie[y];le(b[0]+q*a,b[1]+q*a,b[2]+q*a)}}i.addGroup(m,s.length/3-m,0)}function tt(){const m=s.length/3;let y=0;_e(W,y),y+=W.length;for(let b=0,w=z.length;b<w;b++){const x=z[b];_e(x,y),y+=x.length}i.addGroup(m,s.length/3-m,1)}function _e(m,y){let b=m.length;for(;--b>=0;){const w=b;let x=b-1;x<0&&(x=m.length-1);for(let _=0,P=a+A*2;_<P;_++){const j=q*_,U=q*(_+1),I=y+w+j,se=y+x+j,fe=y+x+U,$=y+w+U;it(I,se,fe,$)}}}function F(m,y,b){u.push(m),u.push(y),u.push(b)}function le(m,y,b){N(m),N(y),N(b);const w=s.length/3,x=V.generateTopUV(i,s,w-3,w-2,w-1);H(x[0]),H(x[1]),H(x[2])}function it(m,y,b,w){N(m),N(y),N(w),N(y),N(b),N(w);const x=s.length/3,_=V.generateSideWallUV(i,s,x-6,x-3,x-2,x-1);H(_[0]),H(_[1]),H(_[3]),H(_[1]),H(_[2]),H(_[3])}function N(m){s.push(u[m*3+0]),s.push(u[m*3+1]),s.push(u[m*3+2])}function H(m){r.push(m.x),r.push(m.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return Ut(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,n=e.shapes.length;r<n;r++){const l=t[e.shapes[r]];i.push(l)}const s=e.options.extrudePath;return console.log(s.type),s!==void 0&&(e.options.extrudePath=new g[`${s.type}Curve`]().fromJSON(s)),new xe(i,e.options)}}const It={generateTopUV:function(o,e,t,i,s){const r=e[t*3],n=e[t*3+1],l=e[i*3],u=e[i*3+1],c=e[s*3],a=e[s*3+1];return[new S.Vector2(r,n),new S.Vector2(l,u),new S.Vector2(c,a)]},generateSideWallUV:function(o,e,t,i,s,r){const n=e[t*3],l=e[t*3+1],u=e[t*3+2],c=e[i*3],a=e[i*3+1],p=e[i*3+2],h=e[s*3],f=e[s*3+1],v=e[s*3+2],d=e[r*3],A=e[r*3+1],M=e[r*3+2];return Math.abs(l-a)<Math.abs(n-c)?[new S.Vector2(n,1-u),new S.Vector2(c,1-p),new S.Vector2(h,1-v),new S.Vector2(d,1-M)]:[new S.Vector2(l,1-u),new S.Vector2(a,1-p),new S.Vector2(f,1-v),new S.Vector2(A,1-M)]}};function Ut(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 Fe=o=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:n,hasSide:l,sideRepeat:u}=o,c=new xe(new g.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:ye.getUVGenerator({split:e,box3:s,sideRepeat:u}),hasTop:r,hasBottom:n,hasSide:l});return ye.claerUVGenerator(),c};class zt extends J.BaseObject{constructor(e){super(),this.options=B({depth:1},e)}create(){return K(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:n,material:l,box3:u,split:c,hasTop:a,hasBottom:p,hasSide:h,useUserDataPos:f}=this.options,v=Array.isArray(s)?s:[s],d=Array.isArray(u)?u:[u],A=l;let M=r;if(A||console.log("material is null"),!M&&e?M=Fe({points:e,depth:v[0],box3:d[0],split:c,hasTop:a,hasBottom:p,hasSide:h}):!M&&t?M=Z(t.map((V,T)=>{var L,G;return Fe({points:V,depth:(L=v[T])!=null?L:v[0],box3:(G=d[T])!=null?G:d[0],split:c,hasTop:a,hasBottom:p,hasSide:h})}),i!=null?i:0):!M&&n&&n.length>1?M=Z(n,i!=null?i:0):!M&&n&&n.length===1&&([M]=n),this.createMesh(M,A),f&&(M!=null&&M.userData.position)){const{x:V,y:T,z:L}=M.userData.position;this.object3d.position.set(V,T,L)}})}addGeometries(e){const t=this.object3d,i=Z([t.geometry,...e]);t.geometry=i}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const Ot=o=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:n}=o;return new Promise(l=>{const u=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};u.onload=()=>{const c=r,a=document.createElement("canvas"),p=a.getContext("2d");a.height=u.height/(1-c),a.width=u.width,c&&e&&(p.fillStyle=e,p.fillRect(0,0,u.width,a.height*c)),i&&u instanceof HTMLImageElement?p.drawImage(u,0,a.height*c,u.width,u.height):t&&(p.fillStyle=t,p.fillRect(0,a.height*c,u.width,u.height)),s&&a.toBlob(f=>{console.log(URL.createObjectURL(f))});const h=new g.CanvasTexture(a);l(h)},i?u.src=i:u instanceof HTMLImageElement||u.onload()})};exports.Group=ut.Group;Object.defineProperty(exports,"Line2Geometry",{enumerable:!0,get:()=>Ne.LineGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>He.LineMaterial});exports.ConicPolygon=Bt;exports.ExtrudePolygon=zt;exports.Image=Je;exports.Light=wt;exports.Line=Vt;exports.Line2=Mt;exports.MeshLineGeometry=Xe;exports.MeshLineMaterial=Ke;exports.MeshLineRaycast=Tt;exports.Node=bt;exports.Pie=xt;exports.Text=vt;exports.Video=yt;exports.getConicPolygonGeometry=Ye;exports.getConicPolygonGeometryMetas=Qe;exports.getSplitTexture=Ot;
|
|
146
|
+
`;class Ke extends g.ShaderMaterial{constructor(e){super({uniforms:pe(E({},g.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new g.Color(16777215)},opacity:{value:1},resolution:{value:new g.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 g.Vector2(1,1)},offset:{value:new g.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new g.Vector2(0,0)},lightColor:{value:new g.Color(16777215)}}),vertexShader:_t,fragmentShader:Pt}),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 Tt(o,e){const t=new g.Matrix4,i=new g.Ray,s=new g.Sphere,r=new g.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 l=new g.Vector3,u=new g.Vector3,c=new g.Vector3,a=this instanceof g.LineSegments?2:1,h=n.index,p=n.attributes;if(h!==null){const f=h.array,y=p.position.array,d=p.width.array;for(let A=0,P=f.length-1;A<P;A+=a){const T=f[A],V=f[A+1];l.fromArray(y,T*3),u.fromArray(y,V*3);const G=d[Math.floor(A/3)]!=null?d[Math.floor(A/3)]:1,I=o.params.Line.threshold+this.material.lineWidth*G/2,j=I*I;if(i.distanceSqToSegment(l,u,r,c)>j)continue;r.applyMatrix4(this.matrixWorld);const z=o.ray.origin.distanceTo(r);z<o.near||z>o.far||(e.push({distance:z,point:c.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=P)}}}const ge=o=>{const{setPointWidth:e,nodes:t}=o,i=new Xe;return i.setPoints(t,e),i};class Vt extends J.BaseObject{constructor(e={}){super(),this.options=E({},e)}get material(){var e;return(e=this.object3d)==null?void 0:e.material}create(){return K(this,null,function*(){const{nodes:e,nodesArr:t,geometry:i,geometryArr:s,material:r,useGroups:n,setPointWidth:l,lineWidthArr:u,materialParameters:c}=this.options;let a=r,h=i;!a&&c&&(a=this.getMaterial(c)),!h&&e?h=ge({nodes:e,setPointWidth:l}):!h&&t?h=Z(t.map((p,f)=>{let y=l;return!y&&u&&(y=()=>{var d;return(d=u[f])!=null?d:u[0]}),ge({nodes:p,setPointWidth:y})}),n!=null?n:0):!h&&s&&s.length>1?h=Z(s,n!=null?n:0):!h&&s&&s.length===1&&([h]=s),this.createMesh(h,a)})}setGeometry(e,t){const i=ge({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 Ke(E({color:new g.Color("#ffffff"),resolution:new g.Vector2(t,i)},e))}addGeometries(e){const t=this.object3d,i=Z([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:l}={}){const{offset:u,offsetLoop:c}=this.material.uniforms;if(this.material.userData.tween)return;const a=s!=null?s:!0;u.value.x=1,c.value=0;let h=0;const p=new ee.Tween(u.value).to({x:-1},e).delay(t).repeat(i).onUpdate(({x:f})=>{a&&f<=0&&c.value===0&&(c.value=1),n&&n(f)}).onRepeat(()=>{h+=1,r&&r(h)}).onComplete(()=>{l&&l()}).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(),ee.remove(this.material.userData.tween)),super.dispose(e)}}function Lt(o,e){return o.map(t=>{const i=[];let s;return t.forEach(r=>{if(s){const n=re.geoDistance(r,s)*180/Math.PI;if(n>e){const l=re.geoInterpolate(s,r),u=1/Math.ceil(n/e);let c=u;for(;c<1;)i.push(l(c)),c+=u}}i.push(s=r)}),i})}function Ct(o,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const r=Math.round(Oe(360/o,2)/Math.PI),n=(1+Math.sqrt(5))/2,l=f=>f/n*360%360-180,u=f=>Math.acos(2*f/r-1)/Math.PI*180-90,c=f=>r*(Math.cos((f+90)*Math.PI/180)+1)/2,a=[s!==void 0?Math.ceil(c(s)):0,i!==void 0?Math.floor(c(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=a[0];f<=a[1];f++){const y=l(f);h(y)&&p.push([y,u(f)])}return p}function be(o,e,t=!1){return t?re.geoContains(e,o):dt(o,e)}function Gt(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[r,n]]=re.geoBounds(t);if(Math.min(Math.abs(r-i),Math.abs(n-s))<e)return[];const l=i>r||n>=89||s<=-89;return Ct(e,{minLng:i,maxLng:r,minLat:s,maxLat:n}).filter(u=>be(u,t,l))}function jt(o,{resolution:e=1/0,bbox:t}={}){const i=Lt(o,e),s=Y.merge(i),r=Gt(o,e),n=[...s,...r],l={type:"Polygon",coordinates:o},[[u,c],[a,h]]=re.geoBounds(l),p=u>a||h>=89||c<=-89;let f=[];if(p){const T=mt.geoVoronoi(n).triangles(),V=new Map(n.map(([G,I],j)=>[`${G}-${I}`,j]));T.features.forEach(G=>{const I=G.geometry.coordinates[0].slice(0,3).reverse(),j=[];if(I.forEach(([C,z])=>{const D=`${C}-${z}`;V.has(D)&&j.push(V.get(D))}),j.length===3){if(j.some(C=>C<s.length)){const C=G.properties.circumcenter;if(!be(C,l,p))return}f.push(...j)}})}else if(r.length){const T=pt.from(n);for(let V=0,G=T.triangles.length;V<G;V+=3){const I=[2,1,0].map(C=>T.triangles[V+C]),j=I.map(C=>n[C]);if(I.some(C=>C<s.length)){const C=[0,1].map(z=>Y.mean(j,D=>D[z]));if(!be(C,l,p))continue}f.push(...I)}}else{const{vertices:T,holes:V=[]}=ye.flatten(i);f=ye(T,V,2)}const y=Ue.scaleLinear(t?[t[0],t[2]]:Y.extent(n,T=>T[0]),[0,1]),d=Ue.scaleLinear(t?[t[1],t[3]]:Y.extent(n,T=>T[1]),[0,1]),A=n.map(([T,V])=>[y(T),d(V)]);return{contour:i,triangles:{points:n,indices:f,uvs:A}}}const We=new g.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function ce(o,e,t,i){const s=o.map(r=>r.map(([n,l])=>{if(i){const[u,c]=i([n,l]);return[u,-c,e]}return t?ve.polar2Cartesian(n,l,e):[n,l,e]}));return ye.flatten(s)}function Et(o,e,t,i,s){const{vertices:r,holes:n}=ce(o,e,i,s),{vertices:l}=ce(o,t,i,s),u=Y.merge([l,r]),c=Math.round(l.length/3),a=new Set(n);let h=0;const p=[];for(let y=0;y<c;y++){let d=y+1;if(d===c)d=h;else if(a.has(d)){const A=d;d=h,h=A}p.push(y,y+c,d+c),p.push(d+c,d,y)}const f=[];for(let y=1;y>=0;y--)for(let d=0;d<c;d+=1)f.push(d/(c-1),y);return{indices:p,vertices:u,uvs:f,topVerts:l}}function ke(o,e,t,i,s,r){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:ce([o.points],e,s,r).vertices,uvs:t}}const Qe=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:r=!0,hasBottom:n=!1,hasTop:l=!1,projection:u,bbox:c})=>{o.forEach(P=>{ft(P)||P.reverse()});const{contour:a,triangles:h}=jt(o,{resolution:i,bbox:c});let p={},f;r&&(p=Et(a,e!=null?e:t,t!=null?t:e,s,u),f=p.topVerts);let y=[];(n||l)&&(y=Y.merge(h.uvs));let d={};n&&(d=ke(h,e,y,!1,s,u));let A={};return l&&(A=ke(h,t,y,!0,s,u)),{contour:a,triangles:h,sideTorso:p,bottomCap:d,topCap:A,topVerts:f}};class Ye extends g.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:l,userDataRsoOffset:u,projection:c}=this.parameters,{contour:a,sideTorso:h,topVerts:p,bottomCap:f,topCap:y}=Qe(E({},this.parameters));let d=[],A=[],P=[],T=0;const V=G=>{const I=Math.round(d.length/3),j=P.length;d=d.concat(G.vertices),A=A.concat(G.uvs),P=P.concat(I?G.indices.map(C=>C+I):G.indices),this.addGroup(j,P.length-j,T++)};n&&(V(h),this.userData.topVerts=u?ce(a,i+u,l,c).vertices:p),r&&V(f),s&&V(y),this.setIndex(P),this[We]("position",new g.Float32BufferAttribute(d,3)),this[We]("uv",new g.Float32BufferAttribute(A,2)),this.computeVertexNormals()}}const qe=o=>{const l=o,{coordinate:e,startHeight:t,height:i}=l,s=de(l,["coordinate","startHeight","height"]);let r=t||0;return typeof t!="undefined"&&typeof i!="undefined"&&(r=t+i),new Ye([e],pe(E({},s),{startHeight:t,endHeight:r}))};class Bt extends J.BaseObject{constructor(e){super(),this.options=E({},e)}create(){const u=this.options,{geometry:e,coordinateArr:t,coordinate:i,material:s,useGroups:r}=u,n=de(u,["geometry","coordinateArr","coordinate","material","useGroups"]);let l=e;if(!l&&i)l=qe(E({coordinate:i},n));else if(!l&&t){const c=t.map(a=>qe(E({coordinate:a},n)));l=Z(c,r!=null?r:0)}this.createMesh(l,s)}}class xe extends S.BufferGeometry{constructor(e=new S.Shape([new S.Vector2(.5,.5),new S.Vector2(-.5,.5),new S.Vector2(-.5,-.5),new S.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 l=0,u=e.length;l<u;l++){const c=e[l];n(c)}this.setAttribute("position",new S.Float32BufferAttribute(s,3)),this.setAttribute("uv",new S.Float32BufferAttribute(r,2)),this.computeVertexNormals();function n(l){var _e,Pe,Te;const u=[],c=t.curveSegments!==void 0?t.curveSegments:12,a=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,y=t.bevelSize!==void 0?t.bevelSize:f-.1,d=t.bevelOffset!==void 0?t.bevelOffset:0,A=t.bevelSegments!==void 0?t.bevelSegments:3;const P=t.extrudePath,T=t.UVGenerator!==void 0?t.UVGenerator:It,V=(_e=t.hasTop)!=null?_e:!0,G=(Pe=t.hasBottom)!=null?Pe:!0,I=(Te=t.hasSide)!=null?Te:!0;let j,C=!1,z,D,te,k;P&&(j=P.getSpacedPoints(a),C=!0,p=!1,z=P.computeFrenetFrames(a,!1),D=new S.Vector3,te=new S.Vector3,k=new S.Vector3),p||(A=0,f=0,y=0,d=0);const we=l.extractPoints(c);let R=we.shape;const U=we.holes;if(!S.ShapeUtils.isClockWise(R)){R=R.reverse();for(let m=0,v=U.length;m<v;m++){const b=U[m];S.ShapeUtils.isClockWise(b)&&(U[m]=b.reverse())}}const ie=S.ShapeUtils.triangulateShape(R,U),W=R;for(let m=0,v=U.length;m<v;m++){const b=U[m];R=R.concat(b)}function Q(m,v,b){return v||console.error("THREE.ExtrudeGeometry: vec does not exist"),m.clone().addScaledVector(v,b)}const q=R.length,ne=ie.length;function Ae(m,v,b){let w,x,M;const _=m.x-v.x,L=m.y-v.y,O=b.x-m.x,B=b.y-m.y,se=_*_+L*L,fe=_*B-L*O;if(Math.abs(fe)>Number.EPSILON){const $=Math.sqrt(se),Ve=Math.sqrt(O*O+B*B),Le=v.x-L/$,Ce=v.y+_/$,st=b.x-B/Ve,rt=b.y+O/Ve,Ge=((st-Le)*B-(rt-Ce)*O)/(_*B-L*O);w=Le+_*Ge-m.x,x=Ce+L*Ge-m.y;const je=w*w+x*x;if(je<=2)return new S.Vector2(w,x);M=Math.sqrt(je/2)}else{let $=!1;_>Number.EPSILON?O>Number.EPSILON&&($=!0):_<-Number.EPSILON?O<-Number.EPSILON&&($=!0):Math.sign(L)===Math.sign(B)&&($=!0),$?(w=-L,x=_,M=Math.sqrt(se)):(w=_,x=L,M=Math.sqrt(se/2))}return new S.Vector2(w/M,x/M)}const oe=[];for(let m=0,v=W.length,b=v-1,w=m+1;m<v;m++,b++,w++)b===v&&(b=0),w===v&&(w=0),oe[m]=Ae(W[m],W[b],W[w]);const he=[];let X,ae=oe.concat();for(let m=0,v=U.length;m<v;m++){const b=U[m];X=[];for(let w=0,x=b.length,M=x-1,_=w+1;w<x;w++,M++,_++)M===x&&(M=0),_===x&&(_=0),X[w]=Ae(b[w],b[M],b[_]);he.push(X),ae=ae.concat(X)}for(let m=0;m<A;m++){const v=m/A,b=f*Math.cos(v*Math.PI/2),w=y*Math.sin(v*Math.PI/2)+d;for(let x=0,M=W.length;x<M;x++){const _=Q(W[x],oe[x],w);F(_.x,_.y,-b)}for(let x=0,M=U.length;x<M;x++){const _=U[x];X=he[x];for(let L=0,O=_.length;L<O;L++){const B=Q(_[L],X[L],w);F(B.x,B.y,-b)}}}const Me=y+d;for(let m=0;m<q;m++){const v=p?Q(R[m],ae[m],Me):R[m];C?(te.copy(z.normals[0]).multiplyScalar(v.x),D.copy(z.binormals[0]).multiplyScalar(v.y),k.copy(j[0]).add(te).add(D),F(k.x,k.y,k.z)):F(v.x,v.y,0)}for(let m=1;m<=a;m++)for(let v=0;v<q;v++){const b=p?Q(R[v],ae[v],Me):R[v];C?(te.copy(z.normals[m]).multiplyScalar(b.x),D.copy(z.binormals[m]).multiplyScalar(b.y),k.copy(j[m]).add(te).add(D),F(k.x,k.y,k.z)):F(b.x,b.y,h/a*m)}for(let m=A-1;m>=0;m--){const v=m/A,b=f*Math.cos(v*Math.PI/2),w=y*Math.sin(v*Math.PI/2)+d;for(let x=0,M=W.length;x<M;x++){const _=Q(W[x],oe[x],w);F(_.x,_.y,h+b)}for(let x=0,M=U.length;x<M;x++){const _=U[x];X=he[x];for(let L=0,O=_.length;L<O;L++){const B=Q(_[L],X[L],w);C?F(B.x,B.y+j[a-1].y,j[a-1].x+b):F(B.x,B.y,h+b)}}}et(),I&&tt();function et(){const m=s.length/3;if(p){let v=0,b=q*v;if(G)for(let w=0;w<ne;w++){const x=ie[w];le(x[2]+b,x[1]+b,x[0]+b)}if(v=a+A*2,b=q*v,V)for(let w=0;w<ne;w++){const x=ie[w];le(x[0]+b,x[1]+b,x[2]+b)}}else{if(G)for(let v=0;v<ne;v++){const b=ie[v];le(b[2],b[1],b[0])}if(V)for(let v=0;v<ne;v++){const b=ie[v];le(b[0]+q*a,b[1]+q*a,b[2]+q*a)}}i.addGroup(m,s.length/3-m,0)}function tt(){const m=s.length/3;let v=0;Se(W,v),v+=W.length;for(let b=0,w=U.length;b<w;b++){const x=U[b];Se(x,v),v+=x.length}i.addGroup(m,s.length/3-m,1)}function Se(m,v){let b=m.length;for(;--b>=0;){const w=b;let x=b-1;x<0&&(x=m.length-1);for(let M=0,_=a+A*2;M<_;M++){const L=q*M,O=q*(M+1),B=v+w+L,se=v+x+L,fe=v+x+O,$=v+w+O;it(B,se,fe,$)}}}function F(m,v,b){u.push(m),u.push(v),u.push(b)}function le(m,v,b){N(m),N(v),N(b);const w=s.length/3,x=T.generateTopUV(i,s,w-3,w-2,w-1);H(x[0]),H(x[1]),H(x[2])}function it(m,v,b,w){N(m),N(v),N(w),N(v),N(b),N(w);const x=s.length/3,M=T.generateSideWallUV(i,s,x-6,x-3,x-2,x-1);H(M[0]),H(M[1]),H(M[3]),H(M[1]),H(M[2]),H(M[3])}function N(m){s.push(u[m*3+0]),s.push(u[m*3+1]),s.push(u[m*3+2])}function H(m){r.push(m.x),r.push(m.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return Ot(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,n=e.shapes.length;r<n;r++){const l=t[e.shapes[r]];i.push(l)}const s=e.options.extrudePath;return console.log(s.type),s!==void 0&&(e.options.extrudePath=new g[`${s.type}Curve`]().fromJSON(s)),new xe(i,e.options)}}const It={generateTopUV:function(o,e,t,i,s){const r=e[t*3],n=e[t*3+1],l=e[i*3],u=e[i*3+1],c=e[s*3],a=e[s*3+1];return[new S.Vector2(r,n),new S.Vector2(l,u),new S.Vector2(c,a)]},generateSideWallUV:function(o,e,t,i,s,r){const n=e[t*3],l=e[t*3+1],u=e[t*3+2],c=e[i*3],a=e[i*3+1],h=e[i*3+2],p=e[s*3],f=e[s*3+1],y=e[s*3+2],d=e[r*3],A=e[r*3+1],P=e[r*3+2];return Math.abs(l-a)<Math.abs(n-c)?[new S.Vector2(n,1-u),new S.Vector2(c,1-h),new S.Vector2(p,1-y),new S.Vector2(d,1-P)]:[new S.Vector2(l,1-u),new S.Vector2(a,1-h),new S.Vector2(f,1-y),new S.Vector2(A,1-P)]}};function Ot(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 Fe=o=>{const{split:e,depth:t,points:i,box3:s,hasTop:r,hasBottom:n,hasSide:l,sideRepeat:u}=o,c=new xe(new g.Shape(i),{depth:t,bevelEnabled:!1,UVGenerator:ve.getUVGenerator({split:e,box3:s,sideRepeat:u}),hasTop:r,hasBottom:n,hasSide:l});return ve.claerUVGenerator(),c};class Ut extends J.BaseObject{constructor(e){super(),this.options=E({depth:1},e)}create(){return K(this,null,function*(){const{points:e,pointsArr:t,useGroups:i,depth:s,geometry:r,geometryArr:n,material:l,box3:u,split:c,hasTop:a,hasBottom:h,hasSide:p}=this.options,f=Array.isArray(s)?s:[s],y=Array.isArray(u)?u:[u],d=l;let A=r;d||console.log("material is null"),!A&&e?A=Fe({points:e,depth:f[0],box3:y[0],split:c,hasTop:a,hasBottom:h,hasSide:p}):!A&&t?A=Z(t.map((P,T)=>{var V,G;return Fe({points:P,depth:(V=f[T])!=null?V:f[0],box3:(G=y[T])!=null?G:y[0],split:c,hasTop:a,hasBottom:h,hasSide:p})}),i!=null?i:0):!A&&n&&n.length>1?A=Z(n,i!=null?i:0):!A&&n&&n.length===1&&([A]=n),this.createMesh(A,d)})}addGeometries(e){const t=this.object3d,i=Z([t.geometry,...e]);t.geometry=i}setTextureAnisotropic(e,t){e.anisotropy=t||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const zt=o=>{const{topColor:e,sideColor:t,sideMap:i,createCanvasObjectURL:s,split:r,maxAnisotropy:n}=o;return new Promise(l=>{const u=i?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};u.onload=()=>{const c=r,a=document.createElement("canvas"),h=a.getContext("2d");a.height=u.height/(1-c),a.width=u.width,c&&e&&(h.fillStyle=e,h.fillRect(0,0,u.width,a.height*c)),i&&u instanceof HTMLImageElement?h.drawImage(u,0,a.height*c,u.width,u.height):t&&(h.fillStyle=t,h.fillRect(0,a.height*c,u.width,u.height)),s&&a.toBlob(f=>{console.log(URL.createObjectURL(f))});const p=new g.CanvasTexture(a);l(p)},i?u.src=i:u instanceof HTMLImageElement||u.onload()})};exports.Group=ut.Group;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Ne.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>He.LineMaterial});exports.ConicPolygon=Bt;exports.ExtrudePolygon=Ut;exports.Image=Je;exports.Light=wt;exports.Line=Vt;exports.Line2=Mt;exports.MeshLineGeometry=Xe;exports.MeshLineMaterial=Ke;exports.MeshLineRaycast=Tt;exports.Node=bt;exports.Pie=xt;exports.Text=yt;exports.Video=vt;exports.getConicPolygonGeometry=Ye;exports.getConicPolygonGeometryMetas=Qe;exports.getSplitTexture=zt;
|