@dvt3d/maplibre-three-plugin 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.js +1 -1
- package/dist/mtp.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```shell
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @dvt3d/maplibre-three-plugin
|
|
9
9
|
----------------------------------------
|
|
10
|
-
yarn add @
|
|
10
|
+
yarn add @dvt3d/maplibre-three-plugin
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quickly Start
|
|
@@ -87,8 +87,8 @@ Object({
|
|
|
87
87
|
|
|
88
88
|
#### event hooks
|
|
89
89
|
|
|
90
|
-
- `
|
|
91
|
-
- `
|
|
90
|
+
- `preReset` : A hook that calls `renderer.resetState` before each animation frame
|
|
91
|
+
- `postReset`: A hook that calls `renderer.resetState` after each animation frame
|
|
92
92
|
- `preRender`: A hook that calls `renderer.render` before each animation frame
|
|
93
93
|
- `postRender`: A hook that calls `renderer.render` after each animation frame
|
|
94
94
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Group as it,PerspectiveCamera as vt,Scene as Et,WebGLRenderer as It,EventDispatcher as Pt,Box3 as Dt,Vector3 as Ct}from"three";var P=63710088e-1,D=2*Math.PI*P,m=Math.PI/180,Bt=180/Math.PI,C=1024e3/D,K=512;var j=class{static clamp(t,e,a){return Math.min(a,Math.max(e,t))}static makePerspectiveMatrix(t,e,a,r){let s=1/Math.tan(t/2),n=1/(a-r);return[s/e,0,0,0,0,s,0,0,0,0,(r+a)*n,-1,0,0,2*r*a*n,0]}static mercatorXFromLng(t){return(180+t)/360}static mercatorYFromLat(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}static getViewInfo(t,e,a){let r=t.fov*m,s=t.pitch*m;if(Array.isArray(e)&&(e={lng:e[0],lat:e[1],alt:e[2]||0}),typeof e=="string"){let _=e.split(",");e={lng:_[0],lat:_[1],alt:_[2]||0}}let o=Math.max(a.x,a.y,a.z)/(2*Math.tan(r/2))*Math.cos(s)+e.alt,u=Math.abs(Math.cos(s)*t.cameraToCenterDistance),l=D*Math.abs(Math.cos(e.lat*m)),d=u/o*l,f=Math.round(Math.log2(d/t.tileSize));return{center:[e.lng,e.lat],cameraHeight:o,zoom:f}}static getHeightByZoom(t,e,a,r){let s=Math.abs(Math.cos(r*m)*t.cameraToCenterDistance),n=D*Math.abs(Math.cos(a*m)),o=Math.pow(2,e)*t.tileSize;return s*n/o}static getZoomByHeight(t,e,a,r){let s=Math.abs(Math.cos(r*m)*t.cameraToCenterDistance),n=D*Math.abs(Math.cos(a*m)),o=s/e*n;return Math.round(Math.log2(o/t.tileSize))}},T=j;import{Matrix4 as x,Vector3 as Rt}from"three";var Q=new x,$=new x,tt=85.051129,G=class{constructor(t,e,a){this._map=t,this._world=e,this._camera=a,this._translateCenter=new x().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=K/1024e3,this._map.on("move",this.syncCamera.bind(this)),this._map.on("resize",this.syncCamera.bind(this))}syncCamera(){let t=this._map.transform;this._camera.aspect=t.width/t.height;let e=t.centerOffset||new Rt,a=t.fov*m,r=t.pitch*m,s=t.bearing*m;Q.elements=T.makePerspectiveMatrix(a,this._camera.aspect,t.height/50,t.farZ),this._camera.projectionMatrix=Q,this._camera.projectionMatrix.elements[8]=-e.x*2/t.width,this._camera.projectionMatrix.elements[9]=e.y*2/t.height,$.makeTranslation(0,0,t.cameraToCenterDistance);let n=new x().premultiply($).premultiply(new x().makeRotationX(r)).premultiply(new x().makeRotationZ(-s));t.elevation&&(n.elements[14]=t.cameraToCenterDistance*Math.cos(r)),this._camera.matrixWorld.copy(n);let o=t.scale*this._worldSizeRatio,u=new x().makeScale(o,o,o),l=t.x,d=t.y;if(!l||!d){let g=t.center,w=T.clamp(g.lat,-tt,tt);l=T.mercatorXFromLng(g.lng)*t.worldSize,d=T.mercatorYFromLat(w)*t.worldSize}let f=new x().makeTranslation(-l,d,0),_=new x().makeRotationZ(Math.PI);this._world.matrix=new x().premultiply(_).premultiply(this._translateCenter).premultiply(u).premultiply(f)}},et=G;var k=class{constructor(t,e){this._id=t,this._mapScene=e,this._cameraSync=new et(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(t,e){this._cameraSync.syncCamera()}render(){this._mapScene.render()}},rt=k;import{Vector3 as Tt}from"three";var J=class{static projectedMercatorUnitsPerMeter(){return Math.abs(1024e3/D)}static projectedUnitsPerMeter(t){return Math.abs(1024e3/Math.cos(m*t)/D)}static lngLatToVector3(t,e,a=0){let r=[0,0,0];return Array.isArray(t)?(r=[-P*m*t[0]*C,-P*Math.log(Math.tan(Math.PI*.25+.5*m*t[1]))*C],t[2]?r.push(t[2]*this.projectedUnitsPerMeter(t[1])):r.push(0)):(r=[-P*m*t*C,-P*Math.log(Math.tan(Math.PI*.25+.5*m*e))*C],a?r.push(a*this.projectedUnitsPerMeter(e)):r.push(0)),new Tt(r[0],r[1],r[2])}static vector3ToLngLat(t){let e=[0,0,0];return t&&(e[0]=-t.x/(P*m*C),e[1]=2*(Math.atan(Math.exp(t.y/(C*-P)))-Math.PI/4)/m,e[2]=t.z/this.projectedUnitsPerMeter(e[1])),e}},M=J;var At={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},F=class{constructor(t,e={}){if(!t)throw"missing map";this._map=t,this._options={...At,...e},this._canvas=t.getCanvas(),this._scene=this._options.scene||new Et,this._camera=this._options.camera||new vt(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.1,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new It({alpha:!0,antialias:!0,preserveDrawingBuffer:this._options.preserveDrawingBuffer,canvas:this._canvas,context:this._canvas.getContext("webgl2")}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._canvas.clientWidth,this._canvas.clientHeight),this._renderer.autoClear=!1,this._lights=new it,this._lights.name="lights",this._scene.add(this._lights),this._world=new it,this._world.name="world",this._world.userData={isWorld:!0,name:"world"},this._world.position.set(1024e3/2,1024e3/2,0),this._world.matrixAutoUpdate=!1,this._scene.add(this._world),this._map.on("style.load",this._onStyleLoad.bind(this)),this._event=new Pt}get map(){return this._map}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get lights(){return this._lights}get world(){return this._world}get renderer(){return this._renderer}_onStyleLoad(){this._map.addLayer(new rt("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let t={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preRest",frameState:t}),this.renderer.resetState(),this._event.dispatchEvent({type:"postRest",frameState:t}),this._event.dispatchEvent({type:"preRender",frameState:t}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:t})}return this}addLight(t){return this._lights.add(t.delegate||t),this}removeLight(t){return this._lights.remove(t.delegate||t),this}addObject(t){return this._world.add(t.delegate||t),this}removeObject(t){return this._world.remove(t),t.traverse(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(a=>a.dispose()):e.material.dispose()),e.texture&&e.texture.dispose()}),this}getViewPosition(){let t=this._map.transform,e=t.center;return{position:[e.lng,e.lat,T.getHeightByZoom(t,t.zoom,e.lat,t.pitch)],heading:t.bearing,pitch:t.pitch}}flyTo(t,e=null,a=3){if(t&&t.position){e&&this._map.once("moveend",e);let r=t.size;r||(r=new Ct,new Dt().setFromObject(t.delegate||t,!0).getSize(r));let s=T.getViewInfo(this._map.transform,M.vector3ToLngLat(t.position),r);this._map.flyTo({center:s.center,zoom:s.zoom,duration:a*1e3})}return this}zoomTo(t,e){return this.flyTo(t,e,0)}flyToPosition(t,e=[0,0,0],a=null,r=3){return a&&this._map.once("moveend",a),this._map.flyTo({center:[t[0],t[1]],zoom:T.getZoomByHeight(this._map.transform,t[2],t[1],e[1]||0),bearing:e[0],pitch:e[1],duration:r*1e3}),this}zoomToPosition(t,e=[0,0,0],a=null,r=3){return this.flyToPosition(t,e,a,0)}on(t,e){return this._event.addEventListener(t,e),this}off(t,e){return this._event.removeEventListener(t,e),this}},at=F;import{Group as Wt,DirectionalLight as jt,HemisphereLight as Gt,Color as yt}from"three";var Z=Math.PI,h=Math.sin,c=Math.cos,B=Math.tan,st=Math.asin,b=Math.atan2,nt=Math.acos,p=Z/180,N=1e3*60*60*24,ot=2440588,ht=2451545;function zt(i){return i.valueOf()/N-.5+ot}function U(i){return new Date((i+.5-ot)*N)}function W(i){return zt(i)-ht}var H=p*23.4397;function ct(i,t){return b(h(i)*c(H)-B(t)*h(H),c(i))}function X(i,t){return st(h(t)*c(H)+c(t)*h(H)*h(i))}function lt(i,t,e){return b(h(i),c(i)*h(t)-B(e)*c(t))}function ut(i,t,e){return st(h(t)*h(e)+c(t)*c(e)*c(i))}function mt(i,t){return p*(280.16+360.9856235*i)-t}function bt(i){return i<0&&(i=0),2967e-7/Math.tan(i+.00312536/(i+.08901179))}function dt(i){return p*(357.5291+.98560028*i)}function pt(i){let t=p*(1.9148*h(i)+.02*h(2*i)+3e-4*h(3*i)),e=p*102.9372;return i+t+e+Z}function ft(i){let t=dt(i),e=pt(t);return{dec:X(e,0),ra:ct(e,0)}}var y={};y.getPosition=function(i,t,e){let a=p*-e,r=p*t,s=W(i),n=ft(s),o=mt(s,a)-n.ra;return{azimuth:lt(o,r,n.dec),altitude:ut(o,r,n.dec)}};var V=y.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];y.addTime=function(i,t,e){V.push([i,t,e])};var _t=9e-4;function Ut(i,t){return Math.round(i-_t-t/(2*Z))}function gt(i,t,e){return _t+(i+t)/(2*Z)+e}function Mt(i,t,e){return ht+i+.0053*h(t)-.0069*h(2*e)}function Ot(i,t,e){return nt((h(i)-h(t)*h(e))/(c(t)*c(e)))}function Ht(i){return-2.076*Math.sqrt(i)/60}function Zt(i,t,e,a,r,s,n){let o=Ot(i,e,a),u=gt(o,t,r);return Mt(u,s,n)}y.getTimes=function(i,t,e,a){a=a||0;let r=p*-e,s=p*t,n=Ht(a),o=W(i),u=Ut(o,r),l=gt(0,r,u),d=dt(l),f=pt(d),_=X(f,0),g=Mt(l,d,f),w,A,S,L,R,z,E={solarNoon:U(g),nadir:U(g-.5)};for(w=0,A=V.length;w<A;w+=1)S=V[w],L=(S[0]+n)*p,R=Zt(L,r,s,_,u,d,f),z=g-(R-g),E[S[1]]=U(z),E[S[2]]=U(R);return E};function wt(i){let t=p*(218.316+13.176396*i),e=p*(134.963+13.064993*i),a=p*(93.272+13.22935*i),r=t+p*6.289*h(e),s=p*5.128*h(a),n=385001-20905*c(e);return{ra:ct(r,s),dec:X(r,s),dist:n}}y.getMoonPosition=function(i,t,e){let a=p*-e,r=p*t,s=W(i),n=wt(s),o=mt(s,a)-n.ra,u=ut(o,r,n.dec),l=b(h(o),B(r)*c(n.dec)-h(n.dec)*c(o));return u=u+bt(u),{azimuth:lt(o,r,n.dec),altitude:u,distance:n.dist,parallacticAngle:l}};y.getMoonIllumination=function(i){let t=W(i||new Date),e=ft(t),a=wt(t),r=149598e3,s=nt(h(e.dec)*h(a.dec)+c(e.dec)*c(a.dec)*c(e.ra-a.ra)),n=b(r*h(s),a.dist-r*c(s)),o=b(c(e.dec)*h(e.ra-a.ra),h(e.dec)*c(a.dec)-c(e.dec)*h(a.dec)*c(e.ra-a.ra));return{fraction:(1+c(n))/2,phase:.5+.5*n*(o<0?-1:1)/Math.PI,angle:o}};function O(i,t){return new Date(i.valueOf()+t*N/24)}y.getMoonTimes=function(i,t,e,a){let r=new Date(i);a?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);let s=.133*p,n=y.getMoonPosition(r,t,e).altitude-s,o,u,l,d,f,_,g,w,A,S,L,R,z;for(let I=1;I<=24&&(o=y.getMoonPosition(O(r,I),t,e).altitude-s,u=y.getMoonPosition(O(r,I+1),t,e).altitude-s,f=(n+u)/2-o,_=(u-n)/2,g=-_/(2*f),w=(f*g+_)*g+o,A=_*_-4*f*o,S=0,A>=0&&(z=Math.sqrt(A)/(Math.abs(f)*2),L=g-z,R=g+z,Math.abs(L)<=1&&S++,Math.abs(R)<=1&&S++,L<-1&&(L=R)),S===1?n<0?l=I+L:d=I+L:S===2&&(l=I+(w<0?R:L),d=I+(w<0?L:R)),!(l&&d));I+=2)n=u;let E={};return l&&(E.rise=O(r,l)),d&&(E.set=O(r,d)),!l&&!d&&(E[w>0?"alwaysUp":"alwaysDown"]=!0),E};var Lt=y;var Y=class{constructor(){this._delegate=new Wt,this._delegate.name="Sun",this._sunLight=new jt(16777215,1),this._hemiLight=new Gt(new yt(16777215),new yt(16777215),.6),this._hemiLight.color.setHSL(.661,.96,.12),this._hemiLight.groundColor.setHSL(.11,.96,.14),this._hemiLight.position.set(0,0,50),this._delegate.add(this._sunLight),this._delegate.add(this._hemiLight),this._currentTime=null}get delegate(){return this._delegate}set castShadow(t){this._sunLight.castShadow=t}get castShadow(){return this._sunLight.castShadow}set currentTime(t){this._currentTime=t}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(t={}){return this._sunLight.shadow.radius=t.radius||2,this._sunLight.shadow.mapSize.width=t.mapSize?t.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=t.mapSize?t.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=t.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=t.bottomLeft||-1e3,this._sunLight.shadow.camera.near=t.near||1,this._sunLight.shadow.camera.far=t.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(t){let a=new Date(this._currentTime||new Date().getTime()),r=t.center,s=Lt.getPosition(a,r.lat,r.lng),n=s.altitude,o=Math.PI+s.azimuth,u=1024e3/2,l=Math.sin(n),d=Math.cos(n),f=Math.cos(o)*d,_=Math.sin(o)*d;this._sunLight.position.set(_,f,l),this._sunLight.position.multiplyScalar(u),this._sunLight.intensity=Math.max(l,0),this._hemiLight.intensity=Math.max(l*1,.1),this._sunLight.updateMatrixWorld()}},St=Y;import{Group as kt,Mesh as Jt,PlaneGeometry as Ft,ShadowMaterial as Vt}from"three";var q=class{static createRTCGroup(t,e,a){let r=new kt;if(r.name="rtc",r.position.copy(M.lngLatToVector3(t)),e?(r.rotateX(e[0]||0),r.rotateY(e[1]||0),r.rotateZ(e[2]||0)):(r.rotateX(Math.PI/2),r.rotateY(Math.PI)),a)r.scale.set(a[0]||1,a[1]||1,a[2]||1);else{let s=1;Array.isArray(t)?s=M.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(s=M.projectedUnitsPerMeter(t.split(",")[1])),r.scale.set(s,s,s)}return r}static createMercatorRTCGroup(t,e,a){let r=this.createRTCGroup(t,e,a);if(!a){let s=1,n=M.projectedMercatorUnitsPerMeter();Array.isArray(t)?s=M.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(s=M.projectedUnitsPerMeter(t.split(",")[1])),r.scale.set(n,n,s)}return r}static createShadowGround(t,e=100,a=100){let r=new Ft(e,a),s=new Vt({opacity:.5,transparent:!0}),n=new Jt(r,s);return n.position.copy(M.lngLatToVector3(t)),n.receiveShadow=!0,n.name="shadow-ground",n}},xt=q;export{xt as Creator,at as MapScene,M as SceneTransform,St as Sun};
|
|
1
|
+
import{Group as at,PerspectiveCamera as vt,Scene as It,WebGLRenderer as Pt,EventDispatcher as Et,Box3 as Dt,Vector3 as Ct}from"three";var E=63710088e-1,D=2*Math.PI*E,m=Math.PI/180,Bt=180/Math.PI,C=1024e3/D,K=512;var j=class{static clamp(t,e,i){return Math.min(i,Math.max(e,t))}static makePerspectiveMatrix(t,e,i,r){let s=1/Math.tan(t/2),n=1/(i-r);return[s/e,0,0,0,0,s,0,0,0,0,(r+i)*n,-1,0,0,2*r*i*n,0]}static mercatorXFromLng(t){return(180+t)/360}static mercatorYFromLat(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}static getViewInfo(t,e,i){let r=t.fov*m,s=t.pitch*m;if(Array.isArray(e)&&(e={lng:e[0],lat:e[1],alt:e[2]||0}),typeof e=="string"){let d=e.split(",");e={lng:d[0],lat:d[1],alt:d[2]||0}}let o=Math.max(i.x,i.y,i.z)/(2*Math.tan(r/2))*Math.cos(s)+e.alt,l=Math.abs(Math.cos(s)*t.cameraToCenterDistance),u=D*Math.abs(Math.cos(e.lat*m)),f=l/o*u,_=Math.round(Math.log2(f/t.tileSize));return{center:[e.lng,e.lat],cameraHeight:o,zoom:_}}static getHeightByZoom(t,e,i,r){let s=Math.abs(Math.cos(r*m)*t.cameraToCenterDistance),n=D*Math.abs(Math.cos(i*m)),o=Math.pow(2,e)*t.tileSize;return s*n/o}static getZoomByHeight(t,e,i,r){let s=Math.abs(Math.cos(r*m)*t.cameraToCenterDistance),n=D*Math.abs(Math.cos(i*m)),o=s/e*n;return Math.round(Math.log2(o/t.tileSize))}},T=j;import{Matrix4 as S,Vector3 as Rt}from"three";var Q=new S,$=new S,tt=85.051129,G=class{constructor(t,e,i){this._map=t,this._world=e,this._camera=i,this._translateCenter=new S().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=K/1024e3,this._map.on("move",()=>{this.syncCamera(!1)}),this._map.on("resize",()=>{this.syncCamera(!0)})}syncCamera(t){let e=this._map.transform,i=e.pitch*m,r=e.bearing*m;if(t){let d=e.fov*m,g=e.centerOffset||new Rt;this._camera.aspect=e.width/e.height,Q.elements=T.makePerspectiveMatrix(d,this._camera.aspect,e.height/50,e.farZ),this._camera.projectionMatrix=Q,this._camera.projectionMatrix.elements[8]=-g.x*2/e.width,this._camera.projectionMatrix.elements[9]=g.y*2/e.height}$.makeTranslation(0,0,e.cameraToCenterDistance);let s=new S().premultiply($).premultiply(new S().makeRotationX(i)).premultiply(new S().makeRotationZ(-r));e.elevation&&(s.elements[14]=e.cameraToCenterDistance*Math.cos(i)),this._camera.matrixWorld.copy(s);let n=e.scale*this._worldSizeRatio,o=new S().makeScale(n,n,n),l=e.x,u=e.y;if(!l||!u){let d=e.center,g=T.clamp(d.lat,-tt,tt);l=T.mercatorXFromLng(d.lng)*e.worldSize,u=T.mercatorYFromLat(g)*e.worldSize}let f=new S().makeTranslation(-l,u,0),_=new S().makeRotationZ(Math.PI);this._world.matrix=new S().premultiply(_).premultiply(this._translateCenter).premultiply(o).premultiply(f)}},et=G;var k=class{constructor(t,e){this._id=t,this._mapScene=e,this._cameraSync=new et(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(t,e){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},rt=k;import{Vector3 as Tt}from"three";var J=class{static projectedMercatorUnitsPerMeter(){return Math.abs(1024e3/D)}static projectedUnitsPerMeter(t){return Math.abs(1024e3/Math.cos(m*t)/D)}static lngLatToVector3(t,e,i=0){let r=[0,0,0];return Array.isArray(t)?(r=[-E*m*t[0]*C,-E*Math.log(Math.tan(Math.PI*.25+.5*m*t[1]))*C],t[2]?r.push(t[2]*this.projectedUnitsPerMeter(t[1])):r.push(0)):(r=[-E*m*t*C,-E*Math.log(Math.tan(Math.PI*.25+.5*m*e))*C],i?r.push(i*this.projectedUnitsPerMeter(e)):r.push(0)),new Tt(r[0],r[1],r[2])}static vector3ToLngLat(t){let e=[0,0,0];return t&&(e[0]=-t.x/(E*m*C),e[1]=2*(Math.atan(Math.exp(t.y/(C*-E)))-Math.PI/4)/m,e[2]=t.z/this.projectedUnitsPerMeter(e[1])),e}},M=J;var At={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},F=class{constructor(t,e={}){if(!t)throw"missing map";this._map=t,this._options={...At,...e},this._canvas=t.getCanvas(),this._scene=this._options.scene||new It,this._camera=this._options.camera||new vt(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.1,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new Pt({alpha:!0,antialias:!0,preserveDrawingBuffer:this._options.preserveDrawingBuffer,canvas:this._canvas,context:this._canvas.getContext("webgl2")}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._canvas.clientWidth,this._canvas.clientHeight),this._renderer.autoClear=!1,this._lights=new at,this._lights.name="lights",this._scene.add(this._lights),this._world=new at,this._world.name="world",this._world.userData={isWorld:!0,name:"world"},this._world.position.set(1024e3/2,1024e3/2,0),this._world.matrixAutoUpdate=!1,this._scene.add(this._world),this._map.on("render",this._onMapRender.bind(this)),this._event=new Et}get map(){return this._map}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get lights(){return this._lights}get world(){return this._world}get renderer(){return this._renderer}_onMapRender(){this._map.getLayer("map_scene_layer")||this._map.addLayer(new rt("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let t={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:t}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:t}),this._event.dispatchEvent({type:"preRender",frameState:t}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:t})}return this}addLight(t){return this._lights.add(t.delegate||t),this}removeLight(t){return this._lights.remove(t.delegate||t),this}addObject(t){return this._world.add(t.delegate||t),this}removeObject(t){return this._world.remove(t),t.traverse(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>i.dispose()):e.material.dispose()),e.texture&&e.texture.dispose()}),this}getViewPosition(){let t=this._map.transform,e=t.center;return{position:[e.lng,e.lat,T.getHeightByZoom(t,t.zoom,e.lat,t.pitch)],heading:t.bearing,pitch:t.pitch}}flyTo(t,e=null,i=3){if(t&&t.position){e&&this._map.once("moveend",e);let r=t.size;r||(r=new Ct,new Dt().setFromObject(t.delegate||t,!0).getSize(r));let s=T.getViewInfo(this._map.transform,M.vector3ToLngLat(t.position),r);this._map.flyTo({center:s.center,zoom:s.zoom,duration:i*1e3})}return this}zoomTo(t,e){return this.flyTo(t,e,0)}flyToPosition(t,e=[0,0,0],i=null,r=3){return i&&this._map.once("moveend",i),this._map.flyTo({center:[t[0],t[1]],zoom:T.getZoomByHeight(this._map.transform,t[2],t[1],e[1]||0),bearing:e[0],pitch:e[1],duration:r*1e3}),this}zoomToPosition(t,e=[0,0,0],i=null,r=3){return this.flyToPosition(t,e,i,0)}on(t,e){return this._event.addEventListener(t,e),this}off(t,e){return this._event.removeEventListener(t,e),this}},it=F;import{Group as Wt,DirectionalLight as jt,HemisphereLight as Gt,Color as yt}from"three";var H=Math.PI,h=Math.sin,c=Math.cos,B=Math.tan,st=Math.asin,b=Math.atan2,nt=Math.acos,p=H/180,N=1e3*60*60*24,ot=2440588,ht=2451545;function zt(a){return a.valueOf()/N-.5+ot}function O(a){return new Date((a+.5-ot)*N)}function W(a){return zt(a)-ht}var Z=p*23.4397;function ct(a,t){return b(h(a)*c(Z)-B(t)*h(Z),c(a))}function X(a,t){return st(h(t)*c(Z)+c(t)*h(Z)*h(a))}function lt(a,t,e){return b(h(a),c(a)*h(t)-B(e)*c(t))}function ut(a,t,e){return st(h(t)*h(e)+c(t)*c(e)*c(a))}function mt(a,t){return p*(280.16+360.9856235*a)-t}function bt(a){return a<0&&(a=0),2967e-7/Math.tan(a+.00312536/(a+.08901179))}function dt(a){return p*(357.5291+.98560028*a)}function pt(a){let t=p*(1.9148*h(a)+.02*h(2*a)+3e-4*h(3*a)),e=p*102.9372;return a+t+e+H}function ft(a){let t=dt(a),e=pt(t);return{dec:X(e,0),ra:ct(e,0)}}var L={};L.getPosition=function(a,t,e){let i=p*-e,r=p*t,s=W(a),n=ft(s),o=mt(s,i)-n.ra;return{azimuth:lt(o,r,n.dec),altitude:ut(o,r,n.dec)}};var V=L.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];L.addTime=function(a,t,e){V.push([a,t,e])};var _t=9e-4;function Ot(a,t){return Math.round(a-_t-t/(2*H))}function gt(a,t,e){return _t+(a+t)/(2*H)+e}function Mt(a,t,e){return ht+a+.0053*h(t)-.0069*h(2*e)}function Ut(a,t,e){return nt((h(a)-h(t)*h(e))/(c(t)*c(e)))}function Zt(a){return-2.076*Math.sqrt(a)/60}function Ht(a,t,e,i,r,s,n){let o=Ut(a,e,i),l=gt(o,t,r);return Mt(l,s,n)}L.getTimes=function(a,t,e,i){i=i||0;let r=p*-e,s=p*t,n=Zt(i),o=W(a),l=Ot(o,r),u=gt(0,r,l),f=dt(u),_=pt(f),d=X(_,0),g=Mt(u,f,_),x,A,y,w,R,z,I={solarNoon:O(g),nadir:O(g-.5)};for(x=0,A=V.length;x<A;x+=1)y=V[x],w=(y[0]+n)*p,R=Ht(w,r,s,d,l,f,_),z=g-(R-g),I[y[1]]=O(z),I[y[2]]=O(R);return I};function wt(a){let t=p*(218.316+13.176396*a),e=p*(134.963+13.064993*a),i=p*(93.272+13.22935*a),r=t+p*6.289*h(e),s=p*5.128*h(i),n=385001-20905*c(e);return{ra:ct(r,s),dec:X(r,s),dist:n}}L.getMoonPosition=function(a,t,e){let i=p*-e,r=p*t,s=W(a),n=wt(s),o=mt(s,i)-n.ra,l=ut(o,r,n.dec),u=b(h(o),B(r)*c(n.dec)-h(n.dec)*c(o));return l=l+bt(l),{azimuth:lt(o,r,n.dec),altitude:l,distance:n.dist,parallacticAngle:u}};L.getMoonIllumination=function(a){let t=W(a||new Date),e=ft(t),i=wt(t),r=149598e3,s=nt(h(e.dec)*h(i.dec)+c(e.dec)*c(i.dec)*c(e.ra-i.ra)),n=b(r*h(s),i.dist-r*c(s)),o=b(c(e.dec)*h(e.ra-i.ra),h(e.dec)*c(i.dec)-c(e.dec)*h(i.dec)*c(e.ra-i.ra));return{fraction:(1+c(n))/2,phase:.5+.5*n*(o<0?-1:1)/Math.PI,angle:o}};function U(a,t){return new Date(a.valueOf()+t*N/24)}L.getMoonTimes=function(a,t,e,i){let r=new Date(a);i?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);let s=.133*p,n=L.getMoonPosition(r,t,e).altitude-s,o,l,u,f,_,d,g,x,A,y,w,R,z;for(let P=1;P<=24&&(o=L.getMoonPosition(U(r,P),t,e).altitude-s,l=L.getMoonPosition(U(r,P+1),t,e).altitude-s,_=(n+l)/2-o,d=(l-n)/2,g=-d/(2*_),x=(_*g+d)*g+o,A=d*d-4*_*o,y=0,A>=0&&(z=Math.sqrt(A)/(Math.abs(_)*2),w=g-z,R=g+z,Math.abs(w)<=1&&y++,Math.abs(R)<=1&&y++,w<-1&&(w=R)),y===1?n<0?u=P+w:f=P+w:y===2&&(u=P+(x<0?R:w),f=P+(x<0?w:R)),!(u&&f));P+=2)n=l;let I={};return u&&(I.rise=U(r,u)),f&&(I.set=U(r,f)),!u&&!f&&(I[x>0?"alwaysUp":"alwaysDown"]=!0),I};var Lt=L;var Y=class{constructor(){this._delegate=new Wt,this._delegate.name="Sun",this._sunLight=new jt(16777215,1),this._hemiLight=new Gt(new yt(16777215),new yt(16777215),.6),this._hemiLight.color.setHSL(.661,.96,.12),this._hemiLight.groundColor.setHSL(.11,.96,.14),this._hemiLight.position.set(0,0,50),this._delegate.add(this._sunLight),this._delegate.add(this._hemiLight),this._currentTime=null}get delegate(){return this._delegate}set castShadow(t){this._sunLight.castShadow=t}get castShadow(){return this._sunLight.castShadow}set currentTime(t){this._currentTime=t}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(t={}){return this._sunLight.shadow.radius=t.radius||2,this._sunLight.shadow.mapSize.width=t.mapSize?t.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=t.mapSize?t.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=t.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=t.bottomLeft||-1e3,this._sunLight.shadow.camera.near=t.near||1,this._sunLight.shadow.camera.far=t.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(t){let i=new Date(this._currentTime||new Date().getTime()),r=t.center,s=Lt.getPosition(i,r.lat,r.lng),n=s.altitude,o=Math.PI+s.azimuth,l=1024e3/2,u=Math.sin(n),f=Math.cos(n),_=Math.cos(o)*f,d=Math.sin(o)*f;this._sunLight.position.set(d,_,u),this._sunLight.position.multiplyScalar(l),this._sunLight.intensity=Math.max(u,0),this._hemiLight.intensity=Math.max(u*1,.1),this._sunLight.updateMatrixWorld()}},St=Y;import{Group as kt,Mesh as Jt,PlaneGeometry as Ft,ShadowMaterial as Vt}from"three";var q=class{static createRTCGroup(t,e,i){let r=new kt;if(r.name="rtc",r.position.copy(M.lngLatToVector3(t)),e?(r.rotateX(e[0]||0),r.rotateY(e[1]||0),r.rotateZ(e[2]||0)):(r.rotateX(Math.PI/2),r.rotateY(Math.PI)),i)r.scale.set(i[0]||1,i[1]||1,i[2]||1);else{let s=1;Array.isArray(t)?s=M.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(s=M.projectedUnitsPerMeter(t.split(",")[1])),r.scale.set(s,s,s)}return r}static createMercatorRTCGroup(t,e,i){let r=this.createRTCGroup(t,e,i);if(!i){let s=1,n=M.projectedMercatorUnitsPerMeter();Array.isArray(t)?s=M.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(s=M.projectedUnitsPerMeter(t.split(",")[1])),r.scale.set(n,n,s)}return r}static createShadowGround(t,e=100,i=100){let r=new Ft(e,i),s=new Vt({opacity:.5,transparent:!0}),n=new Jt(r,s);return n.position.copy(M.lngLatToVector3(t)),n.receiveShadow=!0,n.name="shadow-ground",n}},xt=q;export{xt as Creator,it as MapScene,M as SceneTransform,St as Sun};
|
package/dist/mtp.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var Dt=Object.create;var rt=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,bt=Object.prototype.hasOwnProperty;var Ut=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var Ht=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of At(t))!bt.call(i,r)&&r!==e&&rt(i,r,{get:()=>t[r],enumerable:!(s=Ct(t,r))||s.enumerable});return i};var Z=(i,t,e)=>(e=i!=null?Dt(zt(i)):{},Ht(t||!i||!i.__esModule?rt(e,"default",{value:i,enumerable:!0}):e,i));var O=Ut((Vt,it)=>{it.exports=THREE});var g=Z(O(),1);var C=63710088e-1,A=2*Math.PI*C,m=Math.PI/180,Bt=180/Math.PI,b=1024e3/A,st=512;var V=class{static clamp(t,e,s){return Math.min(s,Math.max(e,t))}static makePerspectiveMatrix(t,e,s,r){let a=1/Math.tan(t/2),n=1/(s-r);return[a/e,0,0,0,0,a,0,0,0,0,(r+s)*n,-1,0,0,2*r*s*n,0]}static mercatorXFromLng(t){return(180+t)/360}static mercatorYFromLat(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}static getViewInfo(t,e,s){let r=t.fov*m,a=t.pitch*m;if(Array.isArray(e)&&(e={lng:e[0],lat:e[1],alt:e[2]||0}),typeof e=="string"){let _=e.split(",");e={lng:_[0],lat:_[1],alt:_[2]||0}}let o=Math.max(s.x,s.y,s.z)/(2*Math.tan(r/2))*Math.cos(a)+e.alt,u=Math.abs(Math.cos(a)*t.cameraToCenterDistance),l=A*Math.abs(Math.cos(e.lat*m)),d=u/o*l,f=Math.round(Math.log2(d/t.tileSize));return{center:[e.lng,e.lat],cameraHeight:o,zoom:f}}static getHeightByZoom(t,e,s,r){let a=Math.abs(Math.cos(r*m)*t.cameraToCenterDistance),n=A*Math.abs(Math.cos(s*m)),o=Math.pow(2,e)*t.tileSize;return a*n/o}static getZoomByHeight(t,e,s,r){let a=Math.abs(Math.cos(r*m)*t.cameraToCenterDistance),n=A*Math.abs(Math.cos(s*m)),o=a/e*n;return Math.round(Math.log2(o/t.tileSize))}},E=V;var w=Z(O(),1),at=new w.Matrix4,nt=new w.Matrix4,ot=85.051129,B=class{constructor(t,e,s){this._map=t,this._world=e,this._camera=s,this._translateCenter=new w.Matrix4().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=st/1024e3,this._map.on("move",this.syncCamera.bind(this)),this._map.on("resize",this.syncCamera.bind(this))}syncCamera(){let t=this._map.transform;this._camera.aspect=t.width/t.height;let e=t.centerOffset||new w.Vector3,s=t.fov*m,r=t.pitch*m,a=t.bearing*m;at.elements=E.makePerspectiveMatrix(s,this._camera.aspect,t.height/50,t.farZ),this._camera.projectionMatrix=at,this._camera.projectionMatrix.elements[8]=-e.x*2/t.width,this._camera.projectionMatrix.elements[9]=e.y*2/t.height,nt.makeTranslation(0,0,t.cameraToCenterDistance);let n=new w.Matrix4().premultiply(nt).premultiply(new w.Matrix4().makeRotationX(r)).premultiply(new w.Matrix4().makeRotationZ(-a));t.elevation&&(n.elements[14]=t.cameraToCenterDistance*Math.cos(r)),this._camera.matrixWorld.copy(n);let o=t.scale*this._worldSizeRatio,u=new w.Matrix4().makeScale(o,o,o),l=t.x,d=t.y;if(!l||!d){let M=t.center,y=E.clamp(M.lat,-ot,ot);l=E.mercatorXFromLng(M.lng)*t.worldSize,d=E.mercatorYFromLat(y)*t.worldSize}let f=new w.Matrix4().makeTranslation(-l,d,0),_=new w.Matrix4().makeRotationZ(Math.PI);this._world.matrix=new w.Matrix4().premultiply(_).premultiply(this._translateCenter).premultiply(u).premultiply(f)}},ht=B;var N=class{constructor(t,e){this._id=t,this._mapScene=e,this._cameraSync=new ht(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(t,e){this._cameraSync.syncCamera()}render(){this._mapScene.render()}},ct=N;var lt=Z(O(),1);var X=class{static projectedMercatorUnitsPerMeter(){return Math.abs(1024e3/A)}static projectedUnitsPerMeter(t){return Math.abs(1024e3/Math.cos(m*t)/A)}static lngLatToVector3(t,e,s=0){let r=[0,0,0];return Array.isArray(t)?(r=[-C*m*t[0]*b,-C*Math.log(Math.tan(Math.PI*.25+.5*m*t[1]))*b],t[2]?r.push(t[2]*this.projectedUnitsPerMeter(t[1])):r.push(0)):(r=[-C*m*t*b,-C*Math.log(Math.tan(Math.PI*.25+.5*m*e))*b],s?r.push(s*this.projectedUnitsPerMeter(e)):r.push(0)),new lt.Vector3(r[0],r[1],r[2])}static vector3ToLngLat(t){let e=[0,0,0];return t&&(e[0]=-t.x/(C*m*b),e[1]=2*(Math.atan(Math.exp(t.y/(b*-C)))-Math.PI/4)/m,e[2]=t.z/this.projectedUnitsPerMeter(e[1])),e}},L=X;var Ot={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},Y=class{constructor(t,e={}){if(!t)throw"missing map";this._map=t,this._options={...Ot,...e},this._canvas=t.getCanvas(),this._scene=this._options.scene||new g.Scene,this._camera=this._options.camera||new g.PerspectiveCamera(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.1,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new g.WebGLRenderer({alpha:!0,antialias:!0,preserveDrawingBuffer:this._options.preserveDrawingBuffer,canvas:this._canvas,context:this._canvas.getContext("webgl2")}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._canvas.clientWidth,this._canvas.clientHeight),this._renderer.autoClear=!1,this._lights=new g.Group,this._lights.name="lights",this._scene.add(this._lights),this._world=new g.Group,this._world.name="world",this._world.userData={isWorld:!0,name:"world"},this._world.position.set(1024e3/2,1024e3/2,0),this._world.matrixAutoUpdate=!1,this._scene.add(this._world),this._map.on("style.load",this._onStyleLoad.bind(this)),this._event=new g.EventDispatcher}get map(){return this._map}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get lights(){return this._lights}get world(){return this._world}get renderer(){return this._renderer}_onStyleLoad(){this._map.addLayer(new ct("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let t={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preRest",frameState:t}),this.renderer.resetState(),this._event.dispatchEvent({type:"postRest",frameState:t}),this._event.dispatchEvent({type:"preRender",frameState:t}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:t})}return this}addLight(t){return this._lights.add(t.delegate||t),this}removeLight(t){return this._lights.remove(t.delegate||t),this}addObject(t){return this._world.add(t.delegate||t),this}removeObject(t){return this._world.remove(t),t.traverse(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(s=>s.dispose()):e.material.dispose()),e.texture&&e.texture.dispose()}),this}getViewPosition(){let t=this._map.transform,e=t.center;return{position:[e.lng,e.lat,E.getHeightByZoom(t,t.zoom,e.lat,t.pitch)],heading:t.bearing,pitch:t.pitch}}flyTo(t,e=null,s=3){if(t&&t.position){e&&this._map.once("moveend",e);let r=t.size;r||(r=new g.Vector3,new g.Box3().setFromObject(t.delegate||t,!0).getSize(r));let a=E.getViewInfo(this._map.transform,L.vector3ToLngLat(t.position),r);this._map.flyTo({center:a.center,zoom:a.zoom,duration:s*1e3})}return this}zoomTo(t,e){return this.flyTo(t,e,0)}flyToPosition(t,e=[0,0,0],s=null,r=3){return s&&this._map.once("moveend",s),this._map.flyTo({center:[t[0],t[1]],zoom:E.getZoomByHeight(this._map.transform,t[2],t[1],e[1]||0),bearing:e[0],pitch:e[1],duration:r*1e3}),this}zoomToPosition(t,e=[0,0,0],s=null,r=3){return this.flyToPosition(t,e,s,0)}on(t,e){return this._event.addEventListener(t,e),this}off(t,e){return this._event.removeEventListener(t,e),this}},ut=Y;var I=Z(O(),1);var J=Math.PI,h=Math.sin,c=Math.cos,K=Math.tan,mt=Math.asin,W=Math.atan2,dt=Math.acos,p=J/180,Q=1e3*60*60*24,pt=2440588,ft=2451545;function Zt(i){return i.valueOf()/Q-.5+pt}function j(i){return new Date((i+.5-pt)*Q)}function F(i){return Zt(i)-ft}var k=p*23.4397;function _t(i,t){return W(h(i)*c(k)-K(t)*h(k),c(i))}function $(i,t){return mt(h(t)*c(k)+c(t)*h(k)*h(i))}function gt(i,t,e){return W(h(i),c(i)*h(t)-K(e)*c(t))}function Mt(i,t,e){return mt(h(t)*h(e)+c(t)*c(e)*c(i))}function wt(i,t){return p*(280.16+360.9856235*i)-t}function Wt(i){return i<0&&(i=0),2967e-7/Math.tan(i+.00312536/(i+.08901179))}function Lt(i){return p*(357.5291+.98560028*i)}function yt(i){let t=p*(1.9148*h(i)+.02*h(2*i)+3e-4*h(3*i)),e=p*102.9372;return i+t+e+J}function St(i){let t=Lt(i),e=yt(t);return{dec:$(e,0),ra:_t(e,0)}}var x={};x.getPosition=function(i,t,e){let s=p*-e,r=p*t,a=F(i),n=St(a),o=wt(a,s)-n.ra;return{azimuth:gt(o,r,n.dec),altitude:Mt(o,r,n.dec)}};var q=x.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];x.addTime=function(i,t,e){q.push([i,t,e])};var xt=9e-4;function jt(i,t){return Math.round(i-xt-t/(2*J))}function Rt(i,t,e){return xt+(i+t)/(2*J)+e}function Tt(i,t,e){return ft+i+.0053*h(t)-.0069*h(2*e)}function Gt(i,t,e){return dt((h(i)-h(t)*h(e))/(c(t)*c(e)))}function kt(i){return-2.076*Math.sqrt(i)/60}function Jt(i,t,e,s,r,a,n){let o=Gt(i,e,s),u=Rt(o,t,r);return Tt(u,a,n)}x.getTimes=function(i,t,e,s){s=s||0;let r=p*-e,a=p*t,n=kt(s),o=F(i),u=jt(o,r),l=Rt(0,r,u),d=Lt(l),f=yt(d),_=$(f,0),M=Tt(l,d,f),y,U,R,S,T,H,P={solarNoon:j(M),nadir:j(M-.5)};for(y=0,U=q.length;y<U;y+=1)R=q[y],S=(R[0]+n)*p,T=Jt(S,r,a,_,u,d,f),H=M-(T-M),P[R[1]]=j(H),P[R[2]]=j(T);return P};function Et(i){let t=p*(218.316+13.176396*i),e=p*(134.963+13.064993*i),s=p*(93.272+13.22935*i),r=t+p*6.289*h(e),a=p*5.128*h(s),n=385001-20905*c(e);return{ra:_t(r,a),dec:$(r,a),dist:n}}x.getMoonPosition=function(i,t,e){let s=p*-e,r=p*t,a=F(i),n=Et(a),o=wt(a,s)-n.ra,u=Mt(o,r,n.dec),l=W(h(o),K(r)*c(n.dec)-h(n.dec)*c(o));return u=u+Wt(u),{azimuth:gt(o,r,n.dec),altitude:u,distance:n.dist,parallacticAngle:l}};x.getMoonIllumination=function(i){let t=F(i||new Date),e=St(t),s=Et(t),r=149598e3,a=dt(h(e.dec)*h(s.dec)+c(e.dec)*c(s.dec)*c(e.ra-s.ra)),n=W(r*h(a),s.dist-r*c(a)),o=W(c(e.dec)*h(e.ra-s.ra),h(e.dec)*c(s.dec)-c(e.dec)*h(s.dec)*c(e.ra-s.ra));return{fraction:(1+c(n))/2,phase:.5+.5*n*(o<0?-1:1)/Math.PI,angle:o}};function G(i,t){return new Date(i.valueOf()+t*Q/24)}x.getMoonTimes=function(i,t,e,s){let r=new Date(i);s?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);let a=.133*p,n=x.getMoonPosition(r,t,e).altitude-a,o,u,l,d,f,_,M,y,U,R,S,T,H;for(let D=1;D<=24&&(o=x.getMoonPosition(G(r,D),t,e).altitude-a,u=x.getMoonPosition(G(r,D+1),t,e).altitude-a,f=(n+u)/2-o,_=(u-n)/2,M=-_/(2*f),y=(f*M+_)*M+o,U=_*_-4*f*o,R=0,U>=0&&(H=Math.sqrt(U)/(Math.abs(f)*2),S=M-H,T=M+H,Math.abs(S)<=1&&R++,Math.abs(T)<=1&&R++,S<-1&&(S=T)),R===1?n<0?l=D+S:d=D+S:R===2&&(l=D+(y<0?T:S),d=D+(y<0?S:T)),!(l&&d));D+=2)n=u;let P={};return l&&(P.rise=G(r,l)),d&&(P.set=G(r,d)),!l&&!d&&(P[y>0?"alwaysUp":"alwaysDown"]=!0),P};var vt=x;var tt=class{constructor(){this._delegate=new I.Group,this._delegate.name="Sun",this._sunLight=new I.DirectionalLight(16777215,1),this._hemiLight=new I.HemisphereLight(new I.Color(16777215),new I.Color(16777215),.6),this._hemiLight.color.setHSL(.661,.96,.12),this._hemiLight.groundColor.setHSL(.11,.96,.14),this._hemiLight.position.set(0,0,50),this._delegate.add(this._sunLight),this._delegate.add(this._hemiLight),this._currentTime=null}get delegate(){return this._delegate}set castShadow(t){this._sunLight.castShadow=t}get castShadow(){return this._sunLight.castShadow}set currentTime(t){this._currentTime=t}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(t={}){return this._sunLight.shadow.radius=t.radius||2,this._sunLight.shadow.mapSize.width=t.mapSize?t.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=t.mapSize?t.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=t.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=t.bottomLeft||-1e3,this._sunLight.shadow.camera.near=t.near||1,this._sunLight.shadow.camera.far=t.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(t){let s=new Date(this._currentTime||new Date().getTime()),r=t.center,a=vt.getPosition(s,r.lat,r.lng),n=a.altitude,o=Math.PI+a.azimuth,u=1024e3/2,l=Math.sin(n),d=Math.cos(n),f=Math.cos(o)*d,_=Math.sin(o)*d;this._sunLight.position.set(_,f,l),this._sunLight.position.multiplyScalar(u),this._sunLight.intensity=Math.max(l,0),this._hemiLight.intensity=Math.max(l*1,.1),this._sunLight.updateMatrixWorld()}},It=tt;var z=Z(O(),1);var et=class{static createRTCGroup(t,e,s){let r=new z.Group;if(r.name="rtc",r.position.copy(L.lngLatToVector3(t)),e?(r.rotateX(e[0]||0),r.rotateY(e[1]||0),r.rotateZ(e[2]||0)):(r.rotateX(Math.PI/2),r.rotateY(Math.PI)),s)r.scale.set(s[0]||1,s[1]||1,s[2]||1);else{let a=1;Array.isArray(t)?a=L.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(a=L.projectedUnitsPerMeter(t.split(",")[1])),r.scale.set(a,a,a)}return r}static createMercatorRTCGroup(t,e,s){let r=this.createRTCGroup(t,e,s);if(!s){let a=1,n=L.projectedMercatorUnitsPerMeter();Array.isArray(t)?a=L.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(a=L.projectedUnitsPerMeter(t.split(",")[1])),r.scale.set(n,n,a)}return r}static createShadowGround(t,e=100,s=100){let r=new z.PlaneGeometry(e,s),a=new z.ShadowMaterial({opacity:.5,transparent:!0}),n=new z.Mesh(r,a);return n.position.copy(L.lngLatToVector3(t)),n.receiveShadow=!0,n.name="shadow-ground",n}},Pt=et;})();
|
|
1
|
+
(()=>{var Dt=Object.create;var rt=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,bt=Object.prototype.hasOwnProperty;var Ot=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var Ut=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of At(t))!bt.call(r,a)&&a!==e&&rt(r,a,{get:()=>t[a],enumerable:!(i=Ct(t,a))||i.enumerable});return r};var Z=(r,t,e)=>(e=r!=null?Dt(zt(r)):{},Ut(t||!r||!r.__esModule?rt(e,"default",{value:r,enumerable:!0}):e,r));var H=Ot((Vt,at)=>{at.exports=THREE});var M=Z(H(),1);var C=63710088e-1,A=2*Math.PI*C,m=Math.PI/180,Bt=180/Math.PI,b=1024e3/A,it=512;var V=class{static clamp(t,e,i){return Math.min(i,Math.max(e,t))}static makePerspectiveMatrix(t,e,i,a){let s=1/Math.tan(t/2),n=1/(i-a);return[s/e,0,0,0,0,s,0,0,0,0,(a+i)*n,-1,0,0,2*a*i*n,0]}static mercatorXFromLng(t){return(180+t)/360}static mercatorYFromLat(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}static getViewInfo(t,e,i){let a=t.fov*m,s=t.pitch*m;if(Array.isArray(e)&&(e={lng:e[0],lat:e[1],alt:e[2]||0}),typeof e=="string"){let d=e.split(",");e={lng:d[0],lat:d[1],alt:d[2]||0}}let o=Math.max(i.x,i.y,i.z)/(2*Math.tan(a/2))*Math.cos(s)+e.alt,l=Math.abs(Math.cos(s)*t.cameraToCenterDistance),u=A*Math.abs(Math.cos(e.lat*m)),f=l/o*u,_=Math.round(Math.log2(f/t.tileSize));return{center:[e.lng,e.lat],cameraHeight:o,zoom:_}}static getHeightByZoom(t,e,i,a){let s=Math.abs(Math.cos(a*m)*t.cameraToCenterDistance),n=A*Math.abs(Math.cos(i*m)),o=Math.pow(2,e)*t.tileSize;return s*n/o}static getZoomByHeight(t,e,i,a){let s=Math.abs(Math.cos(a*m)*t.cameraToCenterDistance),n=A*Math.abs(Math.cos(i*m)),o=s/e*n;return Math.round(Math.log2(o/t.tileSize))}},v=V;var w=Z(H(),1),st=new w.Matrix4,nt=new w.Matrix4,ot=85.051129,B=class{constructor(t,e,i){this._map=t,this._world=e,this._camera=i,this._translateCenter=new w.Matrix4().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=it/1024e3,this._map.on("move",()=>{this.syncCamera(!1)}),this._map.on("resize",()=>{this.syncCamera(!0)})}syncCamera(t){let e=this._map.transform,i=e.pitch*m,a=e.bearing*m;if(t){let d=e.fov*m,g=e.centerOffset||new w.Vector3;this._camera.aspect=e.width/e.height,st.elements=v.makePerspectiveMatrix(d,this._camera.aspect,e.height/50,e.farZ),this._camera.projectionMatrix=st,this._camera.projectionMatrix.elements[8]=-g.x*2/e.width,this._camera.projectionMatrix.elements[9]=g.y*2/e.height}nt.makeTranslation(0,0,e.cameraToCenterDistance);let s=new w.Matrix4().premultiply(nt).premultiply(new w.Matrix4().makeRotationX(i)).premultiply(new w.Matrix4().makeRotationZ(-a));e.elevation&&(s.elements[14]=e.cameraToCenterDistance*Math.cos(i)),this._camera.matrixWorld.copy(s);let n=e.scale*this._worldSizeRatio,o=new w.Matrix4().makeScale(n,n,n),l=e.x,u=e.y;if(!l||!u){let d=e.center,g=v.clamp(d.lat,-ot,ot);l=v.mercatorXFromLng(d.lng)*e.worldSize,u=v.mercatorYFromLat(g)*e.worldSize}let f=new w.Matrix4().makeTranslation(-l,u,0),_=new w.Matrix4().makeRotationZ(Math.PI);this._world.matrix=new w.Matrix4().premultiply(_).premultiply(this._translateCenter).premultiply(o).premultiply(f)}},ht=B;var N=class{constructor(t,e){this._id=t,this._mapScene=e,this._cameraSync=new ht(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(t,e){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},ct=N;var lt=Z(H(),1);var X=class{static projectedMercatorUnitsPerMeter(){return Math.abs(1024e3/A)}static projectedUnitsPerMeter(t){return Math.abs(1024e3/Math.cos(m*t)/A)}static lngLatToVector3(t,e,i=0){let a=[0,0,0];return Array.isArray(t)?(a=[-C*m*t[0]*b,-C*Math.log(Math.tan(Math.PI*.25+.5*m*t[1]))*b],t[2]?a.push(t[2]*this.projectedUnitsPerMeter(t[1])):a.push(0)):(a=[-C*m*t*b,-C*Math.log(Math.tan(Math.PI*.25+.5*m*e))*b],i?a.push(i*this.projectedUnitsPerMeter(e)):a.push(0)),new lt.Vector3(a[0],a[1],a[2])}static vector3ToLngLat(t){let e=[0,0,0];return t&&(e[0]=-t.x/(C*m*b),e[1]=2*(Math.atan(Math.exp(t.y/(b*-C)))-Math.PI/4)/m,e[2]=t.z/this.projectedUnitsPerMeter(e[1])),e}},L=X;var Ht={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},Y=class{constructor(t,e={}){if(!t)throw"missing map";this._map=t,this._options={...Ht,...e},this._canvas=t.getCanvas(),this._scene=this._options.scene||new M.Scene,this._camera=this._options.camera||new M.PerspectiveCamera(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.1,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new M.WebGLRenderer({alpha:!0,antialias:!0,preserveDrawingBuffer:this._options.preserveDrawingBuffer,canvas:this._canvas,context:this._canvas.getContext("webgl2")}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._canvas.clientWidth,this._canvas.clientHeight),this._renderer.autoClear=!1,this._lights=new M.Group,this._lights.name="lights",this._scene.add(this._lights),this._world=new M.Group,this._world.name="world",this._world.userData={isWorld:!0,name:"world"},this._world.position.set(1024e3/2,1024e3/2,0),this._world.matrixAutoUpdate=!1,this._scene.add(this._world),this._map.on("render",this._onMapRender.bind(this)),this._event=new M.EventDispatcher}get map(){return this._map}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get lights(){return this._lights}get world(){return this._world}get renderer(){return this._renderer}_onMapRender(){this._map.getLayer("map_scene_layer")||this._map.addLayer(new ct("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let t={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:t}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:t}),this._event.dispatchEvent({type:"preRender",frameState:t}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:t})}return this}addLight(t){return this._lights.add(t.delegate||t),this}removeLight(t){return this._lights.remove(t.delegate||t),this}addObject(t){return this._world.add(t.delegate||t),this}removeObject(t){return this._world.remove(t),t.traverse(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>i.dispose()):e.material.dispose()),e.texture&&e.texture.dispose()}),this}getViewPosition(){let t=this._map.transform,e=t.center;return{position:[e.lng,e.lat,v.getHeightByZoom(t,t.zoom,e.lat,t.pitch)],heading:t.bearing,pitch:t.pitch}}flyTo(t,e=null,i=3){if(t&&t.position){e&&this._map.once("moveend",e);let a=t.size;a||(a=new M.Vector3,new M.Box3().setFromObject(t.delegate||t,!0).getSize(a));let s=v.getViewInfo(this._map.transform,L.vector3ToLngLat(t.position),a);this._map.flyTo({center:s.center,zoom:s.zoom,duration:i*1e3})}return this}zoomTo(t,e){return this.flyTo(t,e,0)}flyToPosition(t,e=[0,0,0],i=null,a=3){return i&&this._map.once("moveend",i),this._map.flyTo({center:[t[0],t[1]],zoom:v.getZoomByHeight(this._map.transform,t[2],t[1],e[1]||0),bearing:e[0],pitch:e[1],duration:a*1e3}),this}zoomToPosition(t,e=[0,0,0],i=null,a=3){return this.flyToPosition(t,e,i,0)}on(t,e){return this._event.addEventListener(t,e),this}off(t,e){return this._event.removeEventListener(t,e),this}},ut=Y;var E=Z(H(),1);var J=Math.PI,h=Math.sin,c=Math.cos,K=Math.tan,mt=Math.asin,W=Math.atan2,dt=Math.acos,p=J/180,Q=1e3*60*60*24,pt=2440588,ft=2451545;function Zt(r){return r.valueOf()/Q-.5+pt}function j(r){return new Date((r+.5-pt)*Q)}function F(r){return Zt(r)-ft}var k=p*23.4397;function _t(r,t){return W(h(r)*c(k)-K(t)*h(k),c(r))}function $(r,t){return mt(h(t)*c(k)+c(t)*h(k)*h(r))}function gt(r,t,e){return W(h(r),c(r)*h(t)-K(e)*c(t))}function Mt(r,t,e){return mt(h(t)*h(e)+c(t)*c(e)*c(r))}function wt(r,t){return p*(280.16+360.9856235*r)-t}function Wt(r){return r<0&&(r=0),2967e-7/Math.tan(r+.00312536/(r+.08901179))}function Lt(r){return p*(357.5291+.98560028*r)}function yt(r){let t=p*(1.9148*h(r)+.02*h(2*r)+3e-4*h(3*r)),e=p*102.9372;return r+t+e+J}function St(r){let t=Lt(r),e=yt(t);return{dec:$(e,0),ra:_t(e,0)}}var S={};S.getPosition=function(r,t,e){let i=p*-e,a=p*t,s=F(r),n=St(s),o=wt(s,i)-n.ra;return{azimuth:gt(o,a,n.dec),altitude:Mt(o,a,n.dec)}};var q=S.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];S.addTime=function(r,t,e){q.push([r,t,e])};var xt=9e-4;function jt(r,t){return Math.round(r-xt-t/(2*J))}function Rt(r,t,e){return xt+(r+t)/(2*J)+e}function Tt(r,t,e){return ft+r+.0053*h(t)-.0069*h(2*e)}function Gt(r,t,e){return dt((h(r)-h(t)*h(e))/(c(t)*c(e)))}function kt(r){return-2.076*Math.sqrt(r)/60}function Jt(r,t,e,i,a,s,n){let o=Gt(r,e,i),l=Rt(o,t,a);return Tt(l,s,n)}S.getTimes=function(r,t,e,i){i=i||0;let a=p*-e,s=p*t,n=kt(i),o=F(r),l=jt(o,a),u=Rt(0,a,l),f=Lt(u),_=yt(f),d=$(_,0),g=Tt(u,f,_),R,O,x,y,T,U,P={solarNoon:j(g),nadir:j(g-.5)};for(R=0,O=q.length;R<O;R+=1)x=q[R],y=(x[0]+n)*p,T=Jt(y,a,s,d,l,f,_),U=g-(T-g),P[x[1]]=j(U),P[x[2]]=j(T);return P};function vt(r){let t=p*(218.316+13.176396*r),e=p*(134.963+13.064993*r),i=p*(93.272+13.22935*r),a=t+p*6.289*h(e),s=p*5.128*h(i),n=385001-20905*c(e);return{ra:_t(a,s),dec:$(a,s),dist:n}}S.getMoonPosition=function(r,t,e){let i=p*-e,a=p*t,s=F(r),n=vt(s),o=wt(s,i)-n.ra,l=Mt(o,a,n.dec),u=W(h(o),K(a)*c(n.dec)-h(n.dec)*c(o));return l=l+Wt(l),{azimuth:gt(o,a,n.dec),altitude:l,distance:n.dist,parallacticAngle:u}};S.getMoonIllumination=function(r){let t=F(r||new Date),e=St(t),i=vt(t),a=149598e3,s=dt(h(e.dec)*h(i.dec)+c(e.dec)*c(i.dec)*c(e.ra-i.ra)),n=W(a*h(s),i.dist-a*c(s)),o=W(c(e.dec)*h(e.ra-i.ra),h(e.dec)*c(i.dec)-c(e.dec)*h(i.dec)*c(e.ra-i.ra));return{fraction:(1+c(n))/2,phase:.5+.5*n*(o<0?-1:1)/Math.PI,angle:o}};function G(r,t){return new Date(r.valueOf()+t*Q/24)}S.getMoonTimes=function(r,t,e,i){let a=new Date(r);i?a.setUTCHours(0,0,0,0):a.setHours(0,0,0,0);let s=.133*p,n=S.getMoonPosition(a,t,e).altitude-s,o,l,u,f,_,d,g,R,O,x,y,T,U;for(let D=1;D<=24&&(o=S.getMoonPosition(G(a,D),t,e).altitude-s,l=S.getMoonPosition(G(a,D+1),t,e).altitude-s,_=(n+l)/2-o,d=(l-n)/2,g=-d/(2*_),R=(_*g+d)*g+o,O=d*d-4*_*o,x=0,O>=0&&(U=Math.sqrt(O)/(Math.abs(_)*2),y=g-U,T=g+U,Math.abs(y)<=1&&x++,Math.abs(T)<=1&&x++,y<-1&&(y=T)),x===1?n<0?u=D+y:f=D+y:x===2&&(u=D+(R<0?T:y),f=D+(R<0?y:T)),!(u&&f));D+=2)n=l;let P={};return u&&(P.rise=G(a,u)),f&&(P.set=G(a,f)),!u&&!f&&(P[R>0?"alwaysUp":"alwaysDown"]=!0),P};var It=S;var tt=class{constructor(){this._delegate=new E.Group,this._delegate.name="Sun",this._sunLight=new E.DirectionalLight(16777215,1),this._hemiLight=new E.HemisphereLight(new E.Color(16777215),new E.Color(16777215),.6),this._hemiLight.color.setHSL(.661,.96,.12),this._hemiLight.groundColor.setHSL(.11,.96,.14),this._hemiLight.position.set(0,0,50),this._delegate.add(this._sunLight),this._delegate.add(this._hemiLight),this._currentTime=null}get delegate(){return this._delegate}set castShadow(t){this._sunLight.castShadow=t}get castShadow(){return this._sunLight.castShadow}set currentTime(t){this._currentTime=t}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(t={}){return this._sunLight.shadow.radius=t.radius||2,this._sunLight.shadow.mapSize.width=t.mapSize?t.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=t.mapSize?t.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=t.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=t.bottomLeft||-1e3,this._sunLight.shadow.camera.near=t.near||1,this._sunLight.shadow.camera.far=t.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(t){let i=new Date(this._currentTime||new Date().getTime()),a=t.center,s=It.getPosition(i,a.lat,a.lng),n=s.altitude,o=Math.PI+s.azimuth,l=1024e3/2,u=Math.sin(n),f=Math.cos(n),_=Math.cos(o)*f,d=Math.sin(o)*f;this._sunLight.position.set(d,_,u),this._sunLight.position.multiplyScalar(l),this._sunLight.intensity=Math.max(u,0),this._hemiLight.intensity=Math.max(u*1,.1),this._sunLight.updateMatrixWorld()}},Et=tt;var z=Z(H(),1);var et=class{static createRTCGroup(t,e,i){let a=new z.Group;if(a.name="rtc",a.position.copy(L.lngLatToVector3(t)),e?(a.rotateX(e[0]||0),a.rotateY(e[1]||0),a.rotateZ(e[2]||0)):(a.rotateX(Math.PI/2),a.rotateY(Math.PI)),i)a.scale.set(i[0]||1,i[1]||1,i[2]||1);else{let s=1;Array.isArray(t)?s=L.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(s=L.projectedUnitsPerMeter(t.split(",")[1])),a.scale.set(s,s,s)}return a}static createMercatorRTCGroup(t,e,i){let a=this.createRTCGroup(t,e,i);if(!i){let s=1,n=L.projectedMercatorUnitsPerMeter();Array.isArray(t)?s=L.projectedUnitsPerMeter(t[1]):typeof t=="string"&&(s=L.projectedUnitsPerMeter(t.split(",")[1])),a.scale.set(n,n,s)}return a}static createShadowGround(t,e=100,i=100){let a=new z.PlaneGeometry(e,i),s=new z.ShadowMaterial({opacity:.5,transparent:!0}),n=new z.Mesh(a,s);return n.position.copy(L.lngLatToVector3(t)),n.receiveShadow=!0,n.name="shadow-ground",n}},Pt=et;})();
|