@dvt3d/maplibre-three-plugin 1.3.0 → 1.4.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 CHANGED
@@ -1,272 +1,293 @@
1
- # maplibre-three-plugin
2
-
3
- `maplibre-three-plugin` is a bridge plugin that cleverly connects [MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/) with [Three.js](https://threejs.org/), enabling developers to implement 3D rendering and animation on maps.
4
-
5
- ## Install
6
-
7
- ```shell
8
- npm install @dvt3d/maplibre-three-plugin
9
- ----------------------------------------
10
- yarn add @dvt3d/maplibre-three-plugin
11
- ```
12
-
13
- ## Quickly Start
14
-
15
- `maplibre-three-plugin` depends on three, please make sure three is installed before using it.
16
-
17
- ```html
18
- <div id="map-container" ></div>
19
- ```
20
-
21
- ```javascript
22
-
23
- import maplibregl from 'maplibre-gl'
24
- import * as THREE from 'three'
25
- import { GLTFLoader } from 'three/addons'
26
- import * as MTP from '@dvt3d/maplibre-three-plugin'
27
-
28
- const map = new maplibregl.Map({
29
- container: 'map-container', // container id
30
- style: 'https://api.maptiler.com/maps/basic-v2/style.json?key=get_access_key',
31
- zoom: 18,
32
- center: [148.9819, -35.3981],
33
- pitch: 60,
34
- canvasContextAttributes: { antialias: true },
35
- maxPitch: 85,
36
- })
37
-
38
- //init three scene
39
- const mapScene = new MTP.MapScene(map)
40
-
41
- //add light
42
- mapScene.addLight(new THREE.AmbientLight())
43
-
44
- // add model
45
- const glTFLoader = new GLTFLoader()
46
-
47
- glTFLoader.load('./assets/34M_17/34M_17.gltf', (gltf) => {
48
- let rtcGroup = MTP.Creator.createRTCGroup([148.9819, -35.39847])
49
- rtcGroup.add(gltf.scene)
50
- mapScene.addObject(rtcGroup)
51
- })
52
- ```
53
-
54
- ## Examples
55
- | ![pic](./examples/index.png) | ![pic](./examples/point.png) | ![pic](./examples/point-collection.png) | ![pic](./examples/billboard.png) |
56
- |:--------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------:|
57
- | [model](https://dvt3d.github.io/maplibre-three-plugin/examples/index.html) | [point](https://dvt3d.github.io/maplibre-three-plugin/examples/point.html) | [point-collection](https://dvt3d.github.io/maplibre-three-plugin/examples/point-collection.html) | [billboard](https://dvt3d.github.io/maplibre-three-plugin/examples/billboard.html) |
58
- | ![pic](./examples/div-icon.png) | ![pic](./examples/3d-tiles.png) | ![pic](./examples/3d-tiles-osgb.png) | ![pic](./examples/sun-light.png) |
59
- | [div-icon](https://dvt3d.github.io/maplibre-three-plugin/examples/div-icon.html) | [3d-tiles](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-tiles.html) | [3d-tiles-osgb](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-tiles-osgb.html) | [sun-light](https://dvt3d.github.io/maplibre-three-plugin/examples/sun-light.html) |
60
-
61
-
62
- ## Docs
63
-
64
- ### MapScene
65
-
66
- #### examples
67
-
68
- ```js
69
- const mapScene = new MapScene(map)
70
- ```
71
-
72
- #### creation
73
- - constructor(map,[options])
74
- - params
75
- - `{Map} map ` : map instance
76
- - `{Object} options ` : config
77
- ```js
78
- // config
79
- Object({
80
- scene: null, //THREE.Scene,if not passed in, the default scene will be used
81
- camera: null, //THREE.Camera, if not passed in, the default camera will be used
82
- renderer: null, //THREE.WebGLRenderer if not passed in, the default renderer will be used
83
- preserveDrawingBuffer: false,
84
- renderLoop: (ins) =>{} //Frame animation rendering function, if not passed in, the default function will be used,the params is an instance for MapScene
85
- })
86
- ```
87
-
88
- #### event hooks
89
-
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
- - `preRender`: A hook that calls `renderer.render` before each animation frame
93
- - `postRender`: A hook that calls `renderer.render` after each animation frame
94
-
95
- #### properties
96
-
97
- - `{maplibregl.Map} map ` : `readonly`
98
- - `{HTMLCanvasElement} canvas ` : `readonly`
99
- - `{THREE.Camera} camera `: `readonly`
100
- - `{THREE.Sence} scene` : `readonly`
101
- - `{THREE.Group} lights`: `readonly`
102
- - `{THREE.Group} world` : `readonly`
103
- - `{THREE.WebGLRenderer} renderer` : `readonly`
104
-
105
- #### methods
106
-
107
- - **_addLight(light)_**
108
-
109
- Add light to the scene, support custom light objects, but the custom light objects need to support the `delegate` property, and the `delegate` type is `THREE.Object3D`
110
- - params
111
- - `{THREE.Object3D | Sun | CustomLight } light `
112
- - returns
113
- - `this`
114
-
115
- - **_removeLight(light)_**
116
-
117
- Remove light from the scene
118
-
119
- - params
120
- - `{THREE.Object3D | Sun | CustomLight } light `
121
- - returns
122
- - `this`
123
-
124
- - **_addObject(object)_**
125
-
126
- Add an object to world,support custom object, but the custom object need to support the `delegate` property, and the `delegate` type is `THREE.Object3D`
127
-
128
- - params
129
- - `{THREE.Object3D | CustomObject} object `
130
- - returns
131
- - `this`
132
- - **_removeObject(object)_**
133
-
134
- Remove an object from world
135
-
136
- - params
137
- - `{THREE.Object3D | CustomObject} object `
138
- - returns
139
- - `this`
140
-
141
- - **_flyTo(target,[completed],[duration])_**
142
-
143
- Fly the map to the provided target over a period of time, the completion callback will be triggered when the flight is complete, the target needs to contain the `position` property
144
-
145
- - params
146
- - `{THREE.Object3D | CustomObject} target `
147
- - `{Function} completed `:
148
- - `{Number} duration `:
149
- - returns
150
- - `this`
151
-
152
- - **_zoomTo(target,[completed])_**
153
-
154
- Zoom the map to the provided target
155
-
156
- - params
157
- - `{Ojbect} target `
158
- - `{Function} completed `:
159
- - returns
160
- - `this`
161
-
162
- - **_on(type,callback)_**
163
- - params
164
- - `{String} type `
165
- - `{Function} callback `:
166
- - returns
167
- - `this`
168
-
169
- - **_off(type,callback)_**
170
- - params
171
- - `{String} type `
172
- - `{Function} callback `:
173
- - returns
174
- - `this`
175
-
176
- ### SceneTransform
177
-
178
- #### examples
179
-
180
- ```js
181
- const scale = new SceneTransform.projectedUnitsPerMeter(24)
182
- ```
183
-
184
- #### static methods
185
-
186
- - **_projectedMercatorUnitsPerMeter()_**
187
- - params
188
- - returns
189
- - `{Number} value`
190
-
191
- - **_projectedUnitsPerMeter(lat)_**
192
- - params
193
- - `{Number} lat `
194
- - returns
195
- - `{Number} value`
196
-
197
- - **_lngLatToVector3(lng, [lat], [alt] )_**
198
- - params
199
- - `{Array | Number} lng `
200
- - `{ Number} lat `
201
- - `{ Number} alt `
202
- - returns
203
- - `{THREE.Vector3} v`
204
-
205
- - **_vector3ToLngLat(v)_**
206
- - params
207
- - `{THREE.Vector3} v`
208
- - returns
209
- - `{Array} value`
210
-
211
- ### Sun
212
-
213
- #### examples
214
-
215
- ```js
216
- const sun= new Sun()
217
- ```
218
-
219
- #### creation
220
- - constructor()
221
- - params
222
-
223
-
224
- #### properties
225
-
226
- - `{THREE.Group} delegate ` : `readonly`
227
- - `{Boolean} castShadow `
228
- - `{Date || String} currentTime `
229
- - `{THREE.DirectionalLight} sunLight` : `readonly`
230
- - `{THREE.HemisphereLight} hemiLight`: `readonly`
231
-
232
- #### methods
233
-
234
- - **_update(frameState)_**
235
- - params
236
- - `{Object} frameState`:
237
- - returns
238
- - `this`
239
-
240
- ### Creator
241
-
242
- #### examples
243
-
244
- ```js
245
- const rtcGroup = Creator.createRTCGroup([-1000,0,0])
246
- ```
247
-
248
- #### static methods
249
-
250
- - **_createRTCGroup(center, [rotation], [scale])_**
251
- - params
252
- - `{Array} center`
253
- - `{Array} rotation`: default value is [0,0,0]
254
- - `{Array} scale`: scale corresponding to the current latitude
255
- - returns
256
- - `{THREE.Group} rtc`
257
-
258
- - **_createMercatorRTCGroup(center, [rotation], [scale])_**
259
- - params
260
- - `{Array} center`
261
- - `{Array} rotation`: default value is [0,0,0]
262
- - `{Array} scale`: scale corresponding to the current latitude
263
- - returns
264
- - `{THREE.Group} rtc`
265
-
266
- - **_createShadowGround(center, [width], [height])_**
267
- - params
268
- - `{THREE.Vector3} center`
269
- - `{Number} width`: default value is 100
270
- - `{Number} height` : default value is 100
271
- - returns
272
- - `{Object} rtc`
1
+ # maplibre-three-plugin
2
+
3
+ `maplibre-three-plugin` is a bridge plugin that cleverly
4
+ connects [MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/) with [Three.js](https://threejs.org/), enabling
5
+ developers to implement 3D rendering and animation on maps.
6
+
7
+ ## Install
8
+
9
+ ```shell
10
+ npm install @dvt3d/maplibre-three-plugin
11
+ ----------------------------------------
12
+ yarn add @dvt3d/maplibre-three-plugin
13
+ ```
14
+
15
+ ## Quickly Start
16
+
17
+ `maplibre-three-plugin` depends on three, please make sure three is installed before using it.
18
+
19
+ ```html
20
+
21
+ <div id="map-container"></div>
22
+ ```
23
+
24
+ ```javascript
25
+
26
+ import maplibregl from 'maplibre-gl'
27
+ import * as THREE from 'three'
28
+ import { GLTFLoader } from 'three/addons'
29
+ import * as MTP from '@dvt3d/maplibre-three-plugin'
30
+
31
+ const map = new maplibregl.Map({
32
+ container: 'map-container', // container id
33
+ style: 'https://api.maptiler.com/maps/basic-v2/style.json?key=get_access_key',
34
+ zoom: 18,
35
+ center: [148.9819, -35.3981],
36
+ pitch: 60,
37
+ canvasContextAttributes: { antialias: true },
38
+ maxPitch: 85,
39
+ })
40
+
41
+ //init three scene
42
+ const mapScene = new MTP.MapScene(map)
43
+
44
+ //add light
45
+ mapScene.addLight(new THREE.AmbientLight())
46
+
47
+ // add model
48
+ const glTFLoader = new GLTFLoader()
49
+
50
+ glTFLoader.load('./assets/34M_17/34M_17.gltf', (gltf) => {
51
+ let rtcGroup = MTP.Creator.createRTCGroup([148.9819, -35.39847])
52
+ rtcGroup.add(gltf.scene)
53
+ mapScene.addObject(rtcGroup)
54
+ })
55
+ ```
56
+
57
+ ## Examples
58
+
59
+ | ![pic](./examples/index.png) | ![pic](./examples/sun-light.png) | ![pic](./examples/point.png) | ![pic](./examples/point-collection.png) |
60
+ |:------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------:|
61
+ | [model](https://dvt3d.github.io/maplibre-three-plugin/examples/index.html) | [sun-light](https://dvt3d.github.io/maplibre-three-plugin/examples/sun-light.html) | [point](https://dvt3d.github.io/maplibre-three-plugin/examples/point.html) | [point-collection](https://dvt3d.github.io/maplibre-three-plugin/examples/point-collection.html) |
62
+ | ![pic](./examples/billboard.png) | ![pic](./examples/div-icon.png) | ![pic](./examples/3d-tiles.png) | ![pic](./examples/3d-tiles-osgb.png) |
63
+ | [billboard](https://dvt3d.github.io/maplibre-three-plugin/examples/billboard.html) | [div-icon](https://dvt3d.github.io/maplibre-three-plugin/examples/div-icon.html) | [3d-tiles](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-tiles.html) | [3d-tiles-osgb](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-tiles-osgb.html) |
64
+ | ![pic](./examples/3d-tiles-cesium-ion.png) | ![pic](./examples/3d-gs-cesium-ion.png) | ![pic](./examples/3d-gs-splat.png) | ![pic](./examples/heat-map.png) |
65
+ | [3d-tiles-cesium-ion](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-tiles-cesium-ion.html) | [3d-gs-cesium-ion](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-gs-cesium-ion.html) | [3d-gs-splat](https://dvt3d.github.io/maplibre-three-plugin/examples/3d-gs-splat.html) | [heat-map](https://dvt3d.github.io/maplibre-three-plugin/examples/heat-map.html) |
66
+
67
+ ## Docs
68
+
69
+ ### MapScene
70
+
71
+ #### examples
72
+
73
+ ```js
74
+ const mapScene = new MapScene(map)
75
+ ```
76
+
77
+ #### creation
78
+
79
+ - constructor(map,[options])
80
+ - params
81
+ - `{Map} map ` : map instance
82
+ - `{Object} options ` : config
83
+
84
+ ```js
85
+ // config
86
+ Object({
87
+ scene: null, //THREE.Scene,if not passed in, the default scene will be used
88
+ camera: null, //THREE.Camera, if not passed in, the default camera will be used
89
+ renderer: null, //THREE.WebGLRenderer if not passed in, the default renderer will be used
90
+ preserveDrawingBuffer: false,
91
+ renderLoop: (ins) => {
92
+ } //Frame animation rendering function, if not passed in, the default function will be used,the params is an instance for MapScene
93
+ })
94
+ ```
95
+
96
+ #### event hooks
97
+
98
+ - `preReset` : A hook that calls `renderer.resetState` before each animation frame
99
+ - `postReset`: A hook that calls `renderer.resetState` after each animation frame
100
+ - `preRender`: A hook that calls `renderer.render` before each animation frame
101
+ - `postRender`: A hook that calls `renderer.render` after each animation frame
102
+
103
+ #### properties
104
+
105
+ - `{maplibregl.Map} map ` : `readonly`
106
+ - `{HTMLCanvasElement} canvas ` : `readonly`
107
+ - `{THREE.Camera} camera `: `readonly`
108
+ - `{THREE.Sence} scene` : `readonly`
109
+ - `{THREE.Group} lights`: `readonly`
110
+ - `{THREE.Group} world` : `readonly`
111
+ - `{THREE.WebGLRenderer} renderer` : `readonly`
112
+
113
+ #### methods
114
+
115
+ - **_addLight(light)_**
116
+
117
+ Add light to the scene, support custom light objects, but the custom light objects need to support the `delegate`
118
+ property, and the `delegate` type is `THREE.Object3D`
119
+ - params
120
+ - `{THREE.Object3D | Sun | CustomLight } light `
121
+ - returns
122
+ - `this`
123
+
124
+ - **_removeLight(light)_**
125
+
126
+ Remove light from the scene
127
+
128
+ - params
129
+ - `{THREE.Object3D | Sun | CustomLight } light `
130
+ - returns
131
+ - `this`
132
+
133
+ - **_addObject(object)_**
134
+
135
+ Add an object to world,support custom object, but the custom object need to support the `delegate` property, and the
136
+ `delegate` type is `THREE.Object3D`
137
+
138
+ - params
139
+ - `{THREE.Object3D | CustomObject} object `
140
+ - returns
141
+ - `this`
142
+ - **_removeObject(object)_**
143
+
144
+ Remove an object from world
145
+
146
+ - params
147
+ - `{THREE.Object3D | CustomObject} object `
148
+ - returns
149
+ - `this`
150
+
151
+ - **_flyTo(target,[completed],[duration])_**
152
+
153
+ Fly the map to the provided target over a period of time, the completion callback will be triggered when the flight is
154
+ complete, the target needs to contain the `position` property
155
+
156
+ - params
157
+ - `{THREE.Object3D | CustomObject} target `
158
+ - `{Function} completed `:
159
+ - `{Number} duration `:
160
+ - returns
161
+ - `this`
162
+
163
+ - **_zoomTo(target,[completed])_**
164
+
165
+ Zoom the map to the provided target
166
+
167
+ - params
168
+ - `{Ojbect} target `
169
+ - `{Function} completed `:
170
+ - returns
171
+ - `this`
172
+
173
+ - **_on(type,callback)_**
174
+ - params
175
+ - `{String} type `
176
+ - `{Function} callback `:
177
+ - returns
178
+ - `this`
179
+
180
+ - **_off(type,callback)_**
181
+ - params
182
+ - `{String} type `
183
+ - `{Function} callback `:
184
+ - returns
185
+ - `this`
186
+
187
+ - **_layerBeforeTo([beforeId])_**
188
+
189
+ Moves the three to a different z-position, If beforeId is omitted, the layer will be appended to the end of the layers
190
+ array and appear above all other layers on the map.
191
+
192
+ - params
193
+ - `{String} beforeId `
194
+ - returns
195
+ - `this`
196
+
197
+ ### SceneTransform
198
+
199
+ #### examples
200
+
201
+ ```js
202
+ const scale = new SceneTransform.projectedUnitsPerMeter(24)
203
+ ```
204
+
205
+ #### static methods
206
+
207
+ - **_projectedMercatorUnitsPerMeter()_**
208
+ - params
209
+ - returns
210
+ - `{Number} value`
211
+
212
+ - **_projectedUnitsPerMeter(lat)_**
213
+ - params
214
+ - `{Number} lat `
215
+ - returns
216
+ - `{Number} value`
217
+
218
+ - **_lngLatToVector3(lng, [lat], [alt] )_**
219
+ - params
220
+ - `{Array | Number} lng `
221
+ - `{Number} lat `
222
+ - `{Number} alt `
223
+ - returns
224
+ - `{THREE.Vector3} v`
225
+
226
+ - **_vector3ToLngLat(v)_**
227
+ - params
228
+ - `{THREE.Vector3} v`
229
+ - returns
230
+ - `{Array} value`
231
+
232
+ ### Sun
233
+
234
+ #### examples
235
+
236
+ ```js
237
+ const sun = new Sun()
238
+ ```
239
+
240
+ #### creation
241
+
242
+ - constructor()
243
+ - params
244
+
245
+ #### properties
246
+
247
+ - `{THREE.Group} delegate ` : `readonly`
248
+ - `{Boolean} castShadow `
249
+ - `{Date || String} currentTime `
250
+ - `{THREE.DirectionalLight} sunLight` : `readonly`
251
+ - `{THREE.HemisphereLight} hemiLight`: `readonly`
252
+
253
+ #### methods
254
+
255
+ - **_update(frameState)_**
256
+ - params
257
+ - `{Object} frameState`:
258
+ - returns
259
+ - `this`
260
+
261
+ ### Creator
262
+
263
+ #### examples
264
+
265
+ ```js
266
+ const rtcGroup = Creator.createRTCGroup([-1000, 0, 0])
267
+ ```
268
+
269
+ #### static methods
270
+
271
+ - **_createRTCGroup(center, [rotation], [scale])_**
272
+ - params
273
+ - `{Array} center`
274
+ - `{Array} rotation`: default value is [0,0,0]
275
+ - `{Array} scale`: scale corresponding to the current latitude
276
+ - returns
277
+ - `{THREE.Group} rtc`
278
+
279
+ - **_createMercatorRTCGroup(center, [rotation], [scale])_**
280
+ - params
281
+ - `{Array} center`
282
+ - `{Array} rotation`: default value is [0,0,0]
283
+ - `{Array} scale`: scale corresponding to the current latitude
284
+ - returns
285
+ - `{THREE.Group} rtc`
286
+
287
+ - **_createShadowGround(center, [width], [height])_**
288
+ - params
289
+ - `{THREE.Vector3} center`
290
+ - `{Number} width`: default value is 100
291
+ - `{Number} height` : default value is 100
292
+ - returns
293
+ - `{Object} rtc`
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ interface IMap {
19
19
  pitch: number;
20
20
  duration: number;
21
21
  }): void;
22
+ moveLayer(id: String, beforeId?: String): void;
22
23
  }
23
24
  /**
24
25
  * Configuration options for initializing a MapScene
@@ -184,6 +185,11 @@ declare class MapScene {
184
185
  * @returns {MapScene}
185
186
  */
186
187
  off(type: string, callback: () => void): MapScene;
188
+ /**
189
+ *
190
+ * @param beforeId
191
+ */
192
+ layerBeforeTo(beforeId?: String): MapScene;
187
193
  }
188
194
 
189
195
  declare class SceneTransform {
@@ -272,14 +278,14 @@ declare class Creator {
272
278
  * @param rotation
273
279
  * @param scale
274
280
  */
275
- static createRTCGroup(center: number | number[], rotation: number[], scale: number[]): Group;
281
+ static createRTCGroup(center: number[], rotation: number[], scale: number[]): Group;
276
282
  /**
277
283
  *
278
284
  * @param center
279
285
  * @param rotation
280
286
  * @param scale
281
287
  */
282
- static createMercatorRTCGroup(center: number | number[], rotation: number[], scale: number[]): Group;
288
+ static createMercatorRTCGroup(center: number[], rotation: number[], scale: number[]): Group;
283
289
  /**
284
290
  *
285
291
  * @param center
@@ -287,7 +293,7 @@ declare class Creator {
287
293
  * @param height
288
294
  * @returns {Mesh}
289
295
  */
290
- static createShadowGround(center: number | number[], width?: number, height?: number): Mesh;
296
+ static createShadowGround(center: number[], width?: number, height?: number): Mesh;
291
297
  }
292
298
 
293
299
  export { Creator, MapScene, SceneTransform, Sun };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Group as re,PerspectiveCamera as Ie,Scene as De,WebGLRenderer as Te,EventDispatcher as Re,Box3 as xe,Vector3 as Ce}from"three";var R=63710088e-1,C=2*Math.PI*R,l=Math.PI/180,Ve=180/Math.PI,P=1024e3/C,K=512;var Z=class{static clamp(e,t,r){return Math.min(r,Math.max(t,e))}static makePerspectiveMatrix(e,t,r,n){let s=1/Math.tan(e/2),i=1/(r-n);return[s/t,0,0,0,0,s,0,0,0,0,(n+r)*i,-1,0,0,2*n*r*i,0]}static mercatorXFromLng(e){return(180+e)/360}static mercatorYFromLat(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}static getViewInfo(e,t,r){let n=e.fov*l,s=e.pitch*l,i=null;if(Array.isArray(t)&&(i={lng:t[0],lat:t[1],alt:t[2]||0}),typeof t=="string"){let p=t.split(",");i={lng:+p[0],lat:+p[1],alt:+p[2]||0}}let c=Math.max(r.x,r.y,r.z)/(2*Math.tan(n/2))*Math.cos(s)+i.alt,h=Math.abs(Math.cos(s)*e.cameraToCenterDistance),b=C*Math.abs(Math.cos(i.lat*l)),g=h/c*b,f=Math.round(Math.log2(g/e.tileSize));return{center:[i.lng,i.lat],cameraHeight:c,zoom:f}}static getHeightByZoom(e,t,r,n){let s=Math.abs(Math.cos(n*l)*e.cameraToCenterDistance),i=C*Math.abs(Math.cos(r*l)),o=Math.pow(2,t)*e.tileSize;return s*i/o}static getZoomByHeight(e,t,r,n){let s=Math.abs(Math.cos(n*l)*e.cameraToCenterDistance),i=C*Math.abs(Math.cos(r*l)),o=s/t*i;return Math.round(Math.log2(o/e.tileSize))}},I=Z;import{Matrix4 as y,Vector3 as ve}from"three";var Q=new y,$=new y,ee=85.051129,F=class{_map;_world;_camera;_translateCenter;_worldSizeRatio;constructor(e,t,r){this._map=e,this._world=t,this._camera=r,this._translateCenter=new y().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(e){let t=this._map.transform,r=t.pitch*l,n=t.bearing*l;if(e){let f=t.fov*l,p=t.centerOffset||new ve;this._camera.aspect=t.width/t.height,Q.elements=I.makePerspectiveMatrix(f,this._camera.aspect,t.height/50,t.farZ),this._camera.projectionMatrix=Q,this._camera.projectionMatrix.elements[8]=-p.x*2/t.width,this._camera.projectionMatrix.elements[9]=p.y*2/t.height}$.makeTranslation(0,0,t.cameraToCenterDistance);let s=new y().premultiply($).premultiply(new y().makeRotationX(r)).premultiply(new y().makeRotationZ(-n));t.elevation&&(s.elements[14]=t.cameraToCenterDistance*Math.cos(r)),this._camera.matrixWorld.copy(s);let i=t.scale*this._worldSizeRatio,o=new y().makeScale(i,i,i),c=t.x,h=t.y;if(!c||!h){let f=t.center,p=I.clamp(f.lat,-ee,ee);c=I.mercatorXFromLng(f.lng)*t.worldSize,h=I.mercatorYFromLat(p)*t.worldSize}let b=new y().makeTranslation(-c,h,0),g=new y().makeRotationZ(Math.PI);this._world.matrix=new y().premultiply(g).premultiply(this._translateCenter).premultiply(o).premultiply(b)}},te=F;var k=class{_id;_mapScene;_cameraSync;constructor(e,t){this._id=e,this._mapScene=t,this._cameraSync=new te(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},ne=k;import{Vector3 as Le}from"three";var J=class{static projectedMercatorUnitsPerMeter(){return this.projectedUnitsPerMeter(0)}static projectedUnitsPerMeter(e){return Math.abs(1024e3/Math.cos(l*e)/C)}static lngLatToVector3(e,t,r){let n=[0,0,0];return Array.isArray(e)?(n=[-R*l*e[0]*P,-R*Math.log(Math.tan(Math.PI*.25+.5*l*e[1]))*P],e[2]?n.push(e[2]*this.projectedUnitsPerMeter(e[1])):n.push(0)):(n=[-R*l*e*P,-R*Math.log(Math.tan(Math.PI*.25+.5*l*(t||0)))*P],r?n.push(r*this.projectedUnitsPerMeter(t||0)):n.push(0)),new Le(n[0],n[1],n[2])}static vector3ToLngLat(e){let t=[0,0,0];return e&&(t[0]=-e.x/(R*l*P),t[1]=2*(Math.atan(Math.exp(e.y/(P*-R)))-Math.PI/4)/l,t[2]=e.z/this.projectedUnitsPerMeter(t[1])),t}},w=J;var Pe={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},O=class{_map;_options;_canvas;_scene;_camera;_renderer;_lights;_world;_event;constructor(e,t={}){if(!e)throw"missing map";this._map=e,this._options={...Pe,...t},this._canvas=e.getCanvas(),this._scene=this._options.scene||new De,this._camera=this._options.camera||new Ie(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.001,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new Te({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 re,this._lights.name="lights",this._scene.add(this._lights),this._world=new re,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 Re}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 ne("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let e={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:e}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:e}),this._event.dispatchEvent({type:"preRender",frameState:e}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:e})}return this}addLight(e){return this._lights.add(e.delegate||e),this}removeLight(e){return this._lights.remove(e.delegate||e),this}addObject(e){let t="delegate"in e?e.delegate:e;return this._world.add(t),this}removeObject(e){let t="delegate"in e?e.delegate:e;return this._world.remove(t),t.traverse(r=>{r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(n=>n.dispose()):r.material.dispose()),r.texture&&r.texture.dispose()}),this}getViewPosition(){let e=this._map.transform,t=e.center;return{position:[t.lng,t.lat,I.getHeightByZoom(e,e.zoom,t.lat,e.pitch)],heading:e.bearing,pitch:e.pitch}}flyTo(e,t,r){if(e&&e.position){r&&this._map.once("moveend",r);let n=e.size;n||(n=new Ce,new xe().setFromObject(e.delegate||e,!0).getSize(n));let s=I.getViewInfo(this._map.transform,w.vector3ToLngLat(e.position),n);this._map.flyTo({center:s.center,zoom:s.zoom,duration:(t||3)*1e3})}return this}zoomTo(e,t){return this.flyTo(e,0,t)}flyToPosition(e,t=[0,0,0],r,n=3){return r&&this._map.once("moveend",r),this._map.flyTo({center:[e[0],e[1]],zoom:I.getZoomByHeight(this._map.transform,e[2],e[1],t[1]||0),bearing:t[0],pitch:t[1],duration:n*1e3}),this}zoomToPosition(e,t=[0,0,0],r){return this.flyToPosition(e,t,r,0)}on(e,t){return this._event.addEventListener(e,t),this}off(e,t){return this._event.removeEventListener(e,t),this}};import{Group as je,DirectionalLight as Ue,HemisphereLight as We,Color as Se}from"three";var U=Math.PI,m=Math.sin,u=Math.cos,B=Math.tan,ae=Math.asin,A=Math.atan2,ie=Math.acos,d=U/180,N=1e3*60*60*24,se=2440588,oe=2451545;function ze(a){return a.valueOf()/N-.5+se}function G(a){return new Date((a+.5-se)*N)}function W(a){return ze(a)-oe}var j=d*23.4397;function me(a,e){return A(m(a)*u(j)-B(e)*m(j),u(a))}function X(a,e){return ae(m(e)*u(j)+u(e)*m(j)*m(a))}function ce(a,e,t){return A(m(a),u(a)*m(e)-B(t)*u(e))}function ue(a,e,t){return ae(m(e)*m(t)+u(e)*u(t)*u(a))}function he(a,e){return d*(280.16+360.9856235*a)-e}function Ee(a){return a<0&&(a=0),2967e-7/Math.tan(a+.00312536/(a+.08901179))}function le(a){return d*(357.5291+.98560028*a)}function pe(a){let e=d*(1.9148*m(a)+.02*m(2*a)+3e-4*m(3*a)),t=d*102.9372;return a+e+t+U}function de(a){let e=le(a),t=pe(e);return{dec:X(t,0),ra:me(t,0)}}var M={};M.getPosition=function(a,e,t){let r=d*-t,n=d*e,s=W(a),i=de(s),o=he(s,r)-i.ra;return{azimuth:ce(o,n,i.dec),altitude:ue(o,n,i.dec)}};var V=M.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];M.addTime=function(a,e,t){V.push([a,e,t])};var be=9e-4;function Ae(a,e){return Math.round(a-be-e/(2*U))}function fe(a,e,t){return be+(a+e)/(2*U)+t}function ge(a,e,t){return oe+a+.0053*m(e)-.0069*m(2*t)}function Oe(a,e,t){return ie((m(a)-m(e)*m(t))/(u(e)*u(t)))}function Ge(a){return-2.076*Math.sqrt(a)/60}function He(a,e,t,r,n,s,i){let o=Oe(a,t,r),c=fe(o,e,n);return ge(c,s,i)}M.getTimes=function(a,e,t,r=0){let n=d*-t,s=d*e,i=Ge(r),o=W(a),c=Ae(o,n),h=fe(0,n,c),b=le(h),g=pe(b),f=X(g,0),p=ge(h,b,g),v,z,S,_,L,E,D={solarNoon:G(p),nadir:G(p-.5)};for(v=0,z=V.length;v<z;v+=1)S=V[v],_=(S[0]+i)*d,L=He(_,n,s,f,c,b,g),E=p-(L-p),D[S[1]]=G(E),D[S[2]]=G(L);return D};function _e(a){let e=d*(218.316+13.176396*a),t=d*(134.963+13.064993*a),r=d*(93.272+13.22935*a),n=e+d*6.289*m(t),s=d*5.128*m(r),i=385001-20905*u(t);return{ra:me(n,s),dec:X(n,s),dist:i}}M.getMoonPosition=function(a,e,t){let r=d*-t,n=d*e,s=W(a),i=_e(s),o=he(s,r)-i.ra,c=ue(o,n,i.dec),h=A(m(o),B(n)*u(i.dec)-m(i.dec)*u(o));return c=c+Ee(c),{azimuth:ce(o,n,i.dec),altitude:c,distance:i.dist,parallacticAngle:h}};M.getMoonIllumination=function(a){let e=W(a||new Date),t=de(e),r=_e(e),n=149598e3,s=ie(m(t.dec)*m(r.dec)+u(t.dec)*u(r.dec)*u(t.ra-r.ra)),i=A(n*m(s),r.dist-n*u(s)),o=A(u(t.dec)*m(t.ra-r.ra),m(t.dec)*u(r.dec)-u(t.dec)*m(r.dec)*u(t.ra-r.ra));return{fraction:(1+u(i))/2,phase:.5+.5*i*(o<0?-1:1)/Math.PI,angle:o}};function H(a,e){return new Date(a.valueOf()+e*N/24)}M.getMoonTimes=function(a,e,t,r=!1){let n=new Date(a);r?n.setUTCHours(0,0,0,0):n.setHours(0,0,0,0);let s=.133*d,i=M.getMoonPosition(n,e,t).altitude-s,o,c,h,b,g,f,p,v,z,S,_,L,E;for(let T=1;T<=24&&(o=M.getMoonPosition(H(n,T),e,t).altitude-s,c=M.getMoonPosition(H(n,T+1),e,t).altitude-s,g=(i+c)/2-o,f=(c-i)/2,p=-f/(2*g),v=(g*p+f)*p+o,z=f*f-4*g*o,S=0,z>=0&&(E=Math.sqrt(z)/(Math.abs(g)*2),_=p-E,L=p+E,Math.abs(_)<=1&&S++,Math.abs(L)<=1&&S++,_<-1&&(_=L)),S===1?i<0?h=T+_:b=T+_:S===2&&(h=T+(v<0?L:_),b=T+(v<0?_:L)),!(h&&b));T+=2)i=c;let D={};return h&&(D.rise=H(n,h)),b&&(D.set=H(n,b)),!h&&!b&&(D[v>0?"alwaysUp":"alwaysDown"]=!0),D};var Me=M;var Y=class{_delegate;_sunLight;_hemiLight;_currentTime;constructor(){this._delegate=new je,this._delegate.name="Sun",this._sunLight=new Ue(16777215,1),this._hemiLight=new We(new Se(16777215),new Se(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=new Date().getTime()}get delegate(){return this._delegate}set castShadow(e){this._sunLight.castShadow=e}get castShadow(){return this._sunLight.castShadow}set currentTime(e){this._currentTime=e}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(e={}){return this._sunLight.shadow.radius=e.radius||2,this._sunLight.shadow.mapSize.width=e.mapSize?e.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=e.mapSize?e.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=e.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=e.bottomLeft||-1e3,this._sunLight.shadow.camera.near=e.near||1,this._sunLight.shadow.camera.far=e.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(e){let r=new Date(this._currentTime||new Date().getTime()),n=e.center,s=Me.getPosition(r,n.lat,n.lng),i=s.altitude,o=Math.PI+s.azimuth,c=1024e3/2,h=Math.sin(i),b=Math.cos(i),g=Math.cos(o)*b,f=Math.sin(o)*b;this._sunLight.position.set(f,g,h),this._sunLight.position.multiplyScalar(c),this._sunLight.intensity=Math.max(h,0),this._hemiLight.intensity=Math.max(h*1,.1),this._sunLight.updateMatrixWorld()}},ye=Y;import{Group as Ze,Mesh as Fe,PlaneGeometry as ke,ShadowMaterial as Je}from"three";var q=class{static createRTCGroup(e,t,r){let n=new Ze;if(n.name="rtc",n.position.copy(w.lngLatToVector3(e)),t?(n.rotateX(t[0]||0),n.rotateY(t[1]||0),n.rotateZ(t[2]||0)):(n.rotateX(Math.PI/2),n.rotateY(Math.PI)),r)n.scale.set(r[0]||1,r[1]||1,r[2]||1);else{let s=1;Array.isArray(e)&&(s=w.projectedUnitsPerMeter(e[1])),n.scale.set(s,s,s)}return n}static createMercatorRTCGroup(e,t,r){let n=this.createRTCGroup(e,t,r);if(!r){let s=1,i=w.projectedMercatorUnitsPerMeter();Array.isArray(e)&&(s=w.projectedUnitsPerMeter(e[1])),n.scale.set(i,i,s)}return n}static createShadowGround(e,t,r){let n=new ke(t||100,r||100),s=new Je({opacity:.5,transparent:!0}),i=new Fe(n,s);return i.position.copy(w.lngLatToVector3(e)),i.receiveShadow=!0,i.name="shadow-ground",i}},we=q;export{we as Creator,O as MapScene,w as SceneTransform,ye as Sun};
1
+ import{Group as ae,PerspectiveCamera as De,Scene as Te,WebGLRenderer as Re,EventDispatcher as xe,Box3 as Ce,Vector3 as Pe}from"three";var R=63710088e-1,C=2*Math.PI*R,l=Math.PI/180,Be=180/Math.PI,P=1024e3/C,Q=512;var W=class{static clamp(e,t,r){return Math.min(r,Math.max(t,e))}static makePerspectiveMatrix(e,t,r,n){let s=1/Math.tan(e/2),i=1/(r-n);return[s/t,0,0,0,0,s,0,0,0,0,(n+r)*i,-1,0,0,2*n*r*i,0]}static mercatorXFromLng(e){return(180+e)/360}static mercatorYFromLat(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}static getViewInfo(e,t,r){let n=e.fov*l,s=e.pitch*l,i=null;if(Array.isArray(t)&&(i={lng:t[0],lat:t[1],alt:t[2]||0}),typeof t=="string"){let p=t.split(",");i={lng:+p[0],lat:+p[1],alt:+p[2]||0}}let c=Math.max(r.x,r.y,r.z)/(2*Math.tan(n/2))*Math.cos(s)+i.alt,h=Math.abs(Math.cos(s)*e.cameraToCenterDistance),b=C*Math.abs(Math.cos(i.lat*l)),f=h/c*b,g=Math.round(Math.log2(f/e.tileSize));return{center:[i.lng,i.lat],cameraHeight:c,zoom:Math.min(g,e.maxZoom)}}static getHeightByZoom(e,t,r,n){let s=Math.abs(Math.cos(n*l)*e.cameraToCenterDistance),i=C*Math.abs(Math.cos(r*l)),o=Math.pow(2,t)*e.tileSize;return s*i/o}static getZoomByHeight(e,t,r,n){let s=Math.abs(Math.cos(n*l)*e.cameraToCenterDistance),i=C*Math.abs(Math.cos(r*l)),o=s/t*i;return Math.round(Math.log2(o/e.tileSize))}},I=W;import{Matrix4 as y,Vector3 as Le}from"three";var $=new y,ee=new y,te=85.051129,F=class{_map;_world;_camera;_translateCenter;_worldSizeRatio;constructor(e,t,r){this._map=e,this._world=t,this._camera=r,this._translateCenter=new y().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=Q/1024e3,this._map.on("move",()=>{this.syncCamera(!1)}),this._map.on("resize",()=>{this.syncCamera(!0)})}syncCamera(e){let t=this._map.transform,r=t.pitch*l,n=t.bearing*l;if(e){let g=t.fov*l,p=t.centerOffset||new Le;this._camera.aspect=t.width/t.height,$.elements=I.makePerspectiveMatrix(g,this._camera.aspect,t.height/50,t.farZ),this._camera.projectionMatrix=$,this._camera.projectionMatrix.elements[8]=-p.x*2/t.width,this._camera.projectionMatrix.elements[9]=p.y*2/t.height}ee.makeTranslation(0,0,t.cameraToCenterDistance);let s=new y().premultiply(ee).premultiply(new y().makeRotationX(r)).premultiply(new y().makeRotationZ(-n));t.elevation&&(s.elements[14]=t.cameraToCenterDistance*Math.cos(r)),this._camera.matrixWorld.copy(s);let i=t.scale*this._worldSizeRatio,o=new y().makeScale(i,i,i),c=t.x,h=t.y;if(!c||!h){let g=t.center,p=I.clamp(g.lat,-te,te);c=I.mercatorXFromLng(g.lng)*t.worldSize,h=I.mercatorYFromLat(p)*t.worldSize}let b=new y().makeTranslation(-c,h,0),f=new y().makeRotationZ(Math.PI);this._world.matrix=new y().premultiply(f).premultiply(this._translateCenter).premultiply(o).premultiply(b)}},ne=F;var k=class{_id;_mapScene;_cameraSync;constructor(e,t){this._id=e,this._mapScene=t,this._cameraSync=new ne(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},re=k;import{Vector3 as Ie}from"three";var J=class{static projectedMercatorUnitsPerMeter(){return this.projectedUnitsPerMeter(0)}static projectedUnitsPerMeter(e){return Math.abs(1024e3/Math.cos(l*e)/C)}static lngLatToVector3(e,t,r){let n=[0,0,0];return Array.isArray(e)?(n=[-R*l*e[0]*P,-R*Math.log(Math.tan(Math.PI*.25+.5*l*e[1]))*P],e[2]?n.push(e[2]*this.projectedUnitsPerMeter(e[1])):n.push(0)):(n=[-R*l*e*P,-R*Math.log(Math.tan(Math.PI*.25+.5*l*(t||0)))*P],r?n.push(r*this.projectedUnitsPerMeter(t||0)):n.push(0)),new Ie(n[0],n[1],n[2])}static vector3ToLngLat(e){let t=[0,0,0];return e&&(t[0]=-e.x/(R*l*P),t[1]=2*(Math.atan(Math.exp(e.y/(P*-R)))-Math.PI/4)/l,t[2]=e.z/this.projectedUnitsPerMeter(t[1])),t}},w=J;var ze={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},V="map_scene_layer",O=class{_map;_options;_canvas;_scene;_camera;_renderer;_lights;_world;_event;constructor(e,t={}){if(!e)throw"missing map";this._map=e,this._options={...ze,...t},this._canvas=e.getCanvas(),this._scene=this._options.scene||new Te,this._camera=this._options.camera||new De(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.001,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new Re({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 ae,this._lights.name="lights",this._scene.add(this._lights),this._world=new ae,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 xe}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(V)||this._map.addLayer(new re(V,this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let e={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:e}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:e}),this._event.dispatchEvent({type:"preRender",frameState:e}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:e})}return this}addLight(e){return this._lights.add(e.delegate||e),this}removeLight(e){return this._lights.remove(e.delegate||e),this}addObject(e){let t="delegate"in e?e.delegate:e;return this._world.add(t),this}removeObject(e){let t="delegate"in e?e.delegate:e;return this._world.remove(t),t.traverse(r=>{r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(n=>n.dispose()):r.material.dispose()),r.texture&&r.texture.dispose()}),this}getViewPosition(){let e=this._map.transform,t=e.center;return{position:[t.lng,t.lat,I.getHeightByZoom(e,e.zoom,t.lat,e.pitch)],heading:e.bearing,pitch:e.pitch}}flyTo(e,t,r){if(e&&e.position){r&&this._map.once("moveend",r);let n=e.size;n||(n=new Pe,new Ce().setFromObject(e.delegate||e,!0).getSize(n));let s=I.getViewInfo(this._map.transform,w.vector3ToLngLat(e.position),n);this._map.flyTo({center:s.center,zoom:s.zoom,duration:(t||3)*1e3})}return this}zoomTo(e,t){return this.flyTo(e,0,t)}flyToPosition(e,t=[0,0,0],r,n=3){return r&&this._map.once("moveend",r),this._map.flyTo({center:[e[0],e[1]],zoom:I.getZoomByHeight(this._map.transform,e[2],e[1],t[1]||0),bearing:t[0],pitch:t[1],duration:n*1e3}),this}zoomToPosition(e,t=[0,0,0],r){return this.flyToPosition(e,t,r,0)}on(e,t){return this._event.addEventListener(e,t),this}off(e,t){return this._event.removeEventListener(e,t),this}layerBeforeTo(e){return this._map.moveLayer(V,e),this}};import{Group as Ue,DirectionalLight as Ze,HemisphereLight as We,Color as ye}from"three";var U=Math.PI,m=Math.sin,u=Math.cos,N=Math.tan,ie=Math.asin,A=Math.atan2,se=Math.acos,d=U/180,X=1e3*60*60*24,oe=2440588,me=2451545;function Ee(a){return a.valueOf()/X-.5+oe}function G(a){return new Date((a+.5-oe)*X)}function Z(a){return Ee(a)-me}var j=d*23.4397;function ce(a,e){return A(m(a)*u(j)-N(e)*m(j),u(a))}function Y(a,e){return ie(m(e)*u(j)+u(e)*m(j)*m(a))}function ue(a,e,t){return A(m(a),u(a)*m(e)-N(t)*u(e))}function he(a,e,t){return ie(m(e)*m(t)+u(e)*u(t)*u(a))}function le(a,e){return d*(280.16+360.9856235*a)-e}function Ae(a){return a<0&&(a=0),2967e-7/Math.tan(a+.00312536/(a+.08901179))}function pe(a){return d*(357.5291+.98560028*a)}function de(a){let e=d*(1.9148*m(a)+.02*m(2*a)+3e-4*m(3*a)),t=d*102.9372;return a+e+t+U}function be(a){let e=pe(a),t=de(e);return{dec:Y(t,0),ra:ce(t,0)}}var M={};M.getPosition=function(a,e,t){let r=d*-t,n=d*e,s=Z(a),i=be(s),o=le(s,r)-i.ra;return{azimuth:ue(o,n,i.dec),altitude:he(o,n,i.dec)}};var B=M.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];M.addTime=function(a,e,t){B.push([a,e,t])};var ge=9e-4;function Oe(a,e){return Math.round(a-ge-e/(2*U))}function fe(a,e,t){return ge+(a+e)/(2*U)+t}function _e(a,e,t){return me+a+.0053*m(e)-.0069*m(2*t)}function Ge(a,e,t){return se((m(a)-m(e)*m(t))/(u(e)*u(t)))}function He(a){return-2.076*Math.sqrt(a)/60}function je(a,e,t,r,n,s,i){let o=Ge(a,t,r),c=fe(o,e,n);return _e(c,s,i)}M.getTimes=function(a,e,t,r=0){let n=d*-t,s=d*e,i=He(r),o=Z(a),c=Oe(o,n),h=fe(0,n,c),b=pe(h),f=de(b),g=Y(f,0),p=_e(h,b,f),v,z,S,_,L,E,D={solarNoon:G(p),nadir:G(p-.5)};for(v=0,z=B.length;v<z;v+=1)S=B[v],_=(S[0]+i)*d,L=je(_,n,s,g,c,b,f),E=p-(L-p),D[S[1]]=G(E),D[S[2]]=G(L);return D};function Me(a){let e=d*(218.316+13.176396*a),t=d*(134.963+13.064993*a),r=d*(93.272+13.22935*a),n=e+d*6.289*m(t),s=d*5.128*m(r),i=385001-20905*u(t);return{ra:ce(n,s),dec:Y(n,s),dist:i}}M.getMoonPosition=function(a,e,t){let r=d*-t,n=d*e,s=Z(a),i=Me(s),o=le(s,r)-i.ra,c=he(o,n,i.dec),h=A(m(o),N(n)*u(i.dec)-m(i.dec)*u(o));return c=c+Ae(c),{azimuth:ue(o,n,i.dec),altitude:c,distance:i.dist,parallacticAngle:h}};M.getMoonIllumination=function(a){let e=Z(a||new Date),t=be(e),r=Me(e),n=149598e3,s=se(m(t.dec)*m(r.dec)+u(t.dec)*u(r.dec)*u(t.ra-r.ra)),i=A(n*m(s),r.dist-n*u(s)),o=A(u(t.dec)*m(t.ra-r.ra),m(t.dec)*u(r.dec)-u(t.dec)*m(r.dec)*u(t.ra-r.ra));return{fraction:(1+u(i))/2,phase:.5+.5*i*(o<0?-1:1)/Math.PI,angle:o}};function H(a,e){return new Date(a.valueOf()+e*X/24)}M.getMoonTimes=function(a,e,t,r=!1){let n=new Date(a);r?n.setUTCHours(0,0,0,0):n.setHours(0,0,0,0);let s=.133*d,i=M.getMoonPosition(n,e,t).altitude-s,o,c,h,b,f,g,p,v,z,S,_,L,E;for(let T=1;T<=24&&(o=M.getMoonPosition(H(n,T),e,t).altitude-s,c=M.getMoonPosition(H(n,T+1),e,t).altitude-s,f=(i+c)/2-o,g=(c-i)/2,p=-g/(2*f),v=(f*p+g)*p+o,z=g*g-4*f*o,S=0,z>=0&&(E=Math.sqrt(z)/(Math.abs(f)*2),_=p-E,L=p+E,Math.abs(_)<=1&&S++,Math.abs(L)<=1&&S++,_<-1&&(_=L)),S===1?i<0?h=T+_:b=T+_:S===2&&(h=T+(v<0?L:_),b=T+(v<0?_:L)),!(h&&b));T+=2)i=c;let D={};return h&&(D.rise=H(n,h)),b&&(D.set=H(n,b)),!h&&!b&&(D[v>0?"alwaysUp":"alwaysDown"]=!0),D};var Se=M;var q=class{_delegate;_sunLight;_hemiLight;_currentTime;constructor(){this._delegate=new Ue,this._delegate.name="Sun",this._sunLight=new Ze(16777215,1),this._hemiLight=new We(new ye(16777215),new ye(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=new Date().getTime()}get delegate(){return this._delegate}set castShadow(e){this._sunLight.castShadow=e}get castShadow(){return this._sunLight.castShadow}set currentTime(e){this._currentTime=e}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(e={}){return this._sunLight.shadow.radius=e.radius||2,this._sunLight.shadow.mapSize.width=e.mapSize?e.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=e.mapSize?e.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=e.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=e.bottomLeft||-1e3,this._sunLight.shadow.camera.near=e.near||1,this._sunLight.shadow.camera.far=e.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(e){let r=new Date(this._currentTime||new Date().getTime()),n=e.center,s=Se.getPosition(r,n.lat,n.lng),i=s.altitude,o=Math.PI+s.azimuth,c=1024e3/2,h=Math.sin(i),b=Math.cos(i),f=Math.cos(o)*b,g=Math.sin(o)*b;this._sunLight.position.set(g,f,h),this._sunLight.position.multiplyScalar(c),this._sunLight.intensity=Math.max(h,0),this._hemiLight.intensity=Math.max(h*1,.1),this._sunLight.updateMatrixWorld()}},we=q;import{Group as Fe,Mesh as ke,PlaneGeometry as Je,ShadowMaterial as Ve}from"three";var K=class{static createRTCGroup(e,t,r){let n=new Fe;if(n.name="rtc",n.position.copy(w.lngLatToVector3(e)),t?(n.rotateX(t[0]||0),n.rotateY(t[1]||0),n.rotateZ(t[2]||0)):(n.rotateX(Math.PI/2),n.rotateY(Math.PI)),r)n.scale.set(r[0]||1,r[1]||1,r[2]||1);else{let s=1;Array.isArray(e)&&(s=w.projectedUnitsPerMeter(e[1])),n.scale.set(s,s,s)}return n}static createMercatorRTCGroup(e,t,r){let n=this.createRTCGroup(e,t,r);if(!r){let s=1,i=w.projectedMercatorUnitsPerMeter();Array.isArray(e)&&(s=w.projectedUnitsPerMeter(e[1])),n.scale.set(i,i,s)}return n}static createShadowGround(e,t,r){let n=new Je(t||100,r||100),s=new Ve({opacity:.5,transparent:!0}),i=new ke(n,s);return i.position.copy(w.lngLatToVector3(e)),i.receiveShadow=!0,i.name="shadow-ground",i}},ve=K;export{ve as Creator,O as MapScene,w as SceneTransform,we as Sun};
package/dist/mtp.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var MTP=(()=>{var Ce=Object.create;var Z=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Oe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ge=(n,e)=>{for(var t in e)Z(n,t,{get:e[t],enumerable:!0})},ie=(n,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ee(e))!Ae.call(n,r)&&r!==t&&Z(n,r,{get:()=>e[r],enumerable:!(a=Pe(e,r))||a.enumerable});return n};var j=(n,e,t)=>(t=n!=null?Ce(ze(n)):{},ie(e||!n||!n.__esModule?Z(t,"default",{value:n,enumerable:!0}):t,n)),He=n=>ie(Z({},"__esModule",{value:!0}),n);var H=Oe((Ne,se)=>{"use strict";se.exports=THREE});var Ve={};Ge(Ve,{Creator:()=>ae,MapScene:()=>U,SceneTransform:()=>y,Sun:()=>ne});var _=j(H(),1);var C=63710088e-1,z=2*Math.PI*C,l=Math.PI/180,Xe=180/Math.PI,A=1024e3/z,oe=512;var N=class{static clamp(e,t,a){return Math.min(a,Math.max(t,e))}static makePerspectiveMatrix(e,t,a,r){let s=1/Math.tan(e/2),i=1/(a-r);return[s/t,0,0,0,0,s,0,0,0,0,(r+a)*i,-1,0,0,2*r*a*i,0]}static mercatorXFromLng(e){return(180+e)/360}static mercatorYFromLat(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}static getViewInfo(e,t,a){let r=e.fov*l,s=e.pitch*l,i=null;if(Array.isArray(t)&&(i={lng:t[0],lat:t[1],alt:t[2]||0}),typeof t=="string"){let p=t.split(",");i={lng:+p[0],lat:+p[1],alt:+p[2]||0}}let c=Math.max(a.x,a.y,a.z)/(2*Math.tan(r/2))*Math.cos(s)+i.alt,h=Math.abs(Math.cos(s)*e.cameraToCenterDistance),b=z*Math.abs(Math.cos(i.lat*l)),g=h/c*b,f=Math.round(Math.log2(g/e.tileSize));return{center:[i.lng,i.lat],cameraHeight:c,zoom:f}}static getHeightByZoom(e,t,a,r){let s=Math.abs(Math.cos(r*l)*e.cameraToCenterDistance),i=z*Math.abs(Math.cos(a*l)),o=Math.pow(2,t)*e.tileSize;return s*i/o}static getZoomByHeight(e,t,a,r){let s=Math.abs(Math.cos(r*l)*e.cameraToCenterDistance),i=z*Math.abs(Math.cos(a*l)),o=s/t*i;return Math.round(Math.log2(o/e.tileSize))}},D=N;var M=j(H(),1),me=new M.Matrix4,ce=new M.Matrix4,ue=85.051129,X=class{_map;_world;_camera;_translateCenter;_worldSizeRatio;constructor(e,t,a){this._map=e,this._world=t,this._camera=a,this._translateCenter=new M.Matrix4().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=oe/1024e3,this._map.on("move",()=>{this.syncCamera(!1)}),this._map.on("resize",()=>{this.syncCamera(!0)})}syncCamera(e){let t=this._map.transform,a=t.pitch*l,r=t.bearing*l;if(e){let f=t.fov*l,p=t.centerOffset||new M.Vector3;this._camera.aspect=t.width/t.height,me.elements=D.makePerspectiveMatrix(f,this._camera.aspect,t.height/50,t.farZ),this._camera.projectionMatrix=me,this._camera.projectionMatrix.elements[8]=-p.x*2/t.width,this._camera.projectionMatrix.elements[9]=p.y*2/t.height}ce.makeTranslation(0,0,t.cameraToCenterDistance);let s=new M.Matrix4().premultiply(ce).premultiply(new M.Matrix4().makeRotationX(a)).premultiply(new M.Matrix4().makeRotationZ(-r));t.elevation&&(s.elements[14]=t.cameraToCenterDistance*Math.cos(a)),this._camera.matrixWorld.copy(s);let i=t.scale*this._worldSizeRatio,o=new M.Matrix4().makeScale(i,i,i),c=t.x,h=t.y;if(!c||!h){let f=t.center,p=D.clamp(f.lat,-ue,ue);c=D.mercatorXFromLng(f.lng)*t.worldSize,h=D.mercatorYFromLat(p)*t.worldSize}let b=new M.Matrix4().makeTranslation(-c,h,0),g=new M.Matrix4().makeRotationZ(Math.PI);this._world.matrix=new M.Matrix4().premultiply(g).premultiply(this._translateCenter).premultiply(o).premultiply(b)}},he=X;var Y=class{_id;_mapScene;_cameraSync;constructor(e,t){this._id=e,this._mapScene=t,this._cameraSync=new he(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},le=Y;var pe=j(H(),1);var q=class{static projectedMercatorUnitsPerMeter(){return this.projectedUnitsPerMeter(0)}static projectedUnitsPerMeter(e){return Math.abs(1024e3/Math.cos(l*e)/z)}static lngLatToVector3(e,t,a){let r=[0,0,0];return Array.isArray(e)?(r=[-C*l*e[0]*A,-C*Math.log(Math.tan(Math.PI*.25+.5*l*e[1]))*A],e[2]?r.push(e[2]*this.projectedUnitsPerMeter(e[1])):r.push(0)):(r=[-C*l*e*A,-C*Math.log(Math.tan(Math.PI*.25+.5*l*(t||0)))*A],a?r.push(a*this.projectedUnitsPerMeter(t||0)):r.push(0)),new pe.Vector3(r[0],r[1],r[2])}static vector3ToLngLat(e){let t=[0,0,0];return e&&(t[0]=-e.x/(C*l*A),t[1]=2*(Math.atan(Math.exp(e.y/(A*-C)))-Math.PI/4)/l,t[2]=e.z/this.projectedUnitsPerMeter(t[1])),t}},y=q;var je={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},U=class{_map;_options;_canvas;_scene;_camera;_renderer;_lights;_world;_event;constructor(e,t={}){if(!e)throw"missing map";this._map=e,this._options={...je,...t},this._canvas=e.getCanvas(),this._scene=this._options.scene||new _.Scene,this._camera=this._options.camera||new _.PerspectiveCamera(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.001,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new _.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 _.Group,this._lights.name="lights",this._scene.add(this._lights),this._world=new _.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 _.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 le("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let e={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:e}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:e}),this._event.dispatchEvent({type:"preRender",frameState:e}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:e})}return this}addLight(e){return this._lights.add(e.delegate||e),this}removeLight(e){return this._lights.remove(e.delegate||e),this}addObject(e){let t="delegate"in e?e.delegate:e;return this._world.add(t),this}removeObject(e){let t="delegate"in e?e.delegate:e;return this._world.remove(t),t.traverse(a=>{a.geometry&&a.geometry.dispose(),a.material&&(Array.isArray(a.material)?a.material.forEach(r=>r.dispose()):a.material.dispose()),a.texture&&a.texture.dispose()}),this}getViewPosition(){let e=this._map.transform,t=e.center;return{position:[t.lng,t.lat,D.getHeightByZoom(e,e.zoom,t.lat,e.pitch)],heading:e.bearing,pitch:e.pitch}}flyTo(e,t,a){if(e&&e.position){a&&this._map.once("moveend",a);let r=e.size;r||(r=new _.Vector3,new _.Box3().setFromObject(e.delegate||e,!0).getSize(r));let s=D.getViewInfo(this._map.transform,y.vector3ToLngLat(e.position),r);this._map.flyTo({center:s.center,zoom:s.zoom,duration:(t||3)*1e3})}return this}zoomTo(e,t){return this.flyTo(e,0,t)}flyToPosition(e,t=[0,0,0],a,r=3){return a&&this._map.once("moveend",a),this._map.flyTo({center:[e[0],e[1]],zoom:D.getZoomByHeight(this._map.transform,e[2],e[1],t[1]||0),bearing:t[0],pitch:t[1],duration:r*1e3}),this}zoomToPosition(e,t=[0,0,0],a){return this.flyToPosition(e,t,a,0)}on(e,t){return this._event.addEventListener(e,t),this}off(e,t){return this._event.removeEventListener(e,t),this}};var T=j(H(),1);var V=Math.PI,m=Math.sin,u=Math.cos,Q=Math.tan,de=Math.asin,W=Math.atan2,be=Math.acos,d=V/180,$=1e3*60*60*24,fe=2440588,ge=2451545;function Ue(n){return n.valueOf()/$-.5+fe}function F(n){return new Date((n+.5-fe)*$)}function B(n){return Ue(n)-ge}var J=d*23.4397;function _e(n,e){return W(m(n)*u(J)-Q(e)*m(J),u(n))}function ee(n,e){return de(m(e)*u(J)+u(e)*m(J)*m(n))}function Me(n,e,t){return W(m(n),u(n)*m(e)-Q(t)*u(e))}function Se(n,e,t){return de(m(e)*m(t)+u(e)*u(t)*u(n))}function ye(n,e){return d*(280.16+360.9856235*n)-e}function We(n){return n<0&&(n=0),2967e-7/Math.tan(n+.00312536/(n+.08901179))}function we(n){return d*(357.5291+.98560028*n)}function ve(n){let e=d*(1.9148*m(n)+.02*m(2*n)+3e-4*m(3*n)),t=d*102.9372;return n+e+t+V}function Le(n){let e=we(n),t=ve(e);return{dec:ee(t,0),ra:_e(t,0)}}var w={};w.getPosition=function(n,e,t){let a=d*-t,r=d*e,s=B(n),i=Le(s),o=ye(s,a)-i.ra;return{azimuth:Me(o,r,i.dec),altitude:Se(o,r,i.dec)}};var K=w.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];w.addTime=function(n,e,t){K.push([n,e,t])};var Ie=9e-4;function Ze(n,e){return Math.round(n-Ie-e/(2*V))}function De(n,e,t){return Ie+(n+e)/(2*V)+t}function Te(n,e,t){return ge+n+.0053*m(e)-.0069*m(2*t)}function Fe(n,e,t){return be((m(n)-m(e)*m(t))/(u(e)*u(t)))}function ke(n){return-2.076*Math.sqrt(n)/60}function Je(n,e,t,a,r,s,i){let o=Fe(n,t,a),c=De(o,e,r);return Te(c,s,i)}w.getTimes=function(n,e,t,a=0){let r=d*-t,s=d*e,i=ke(a),o=B(n),c=Ze(o,r),h=De(0,r,c),b=we(h),g=ve(b),f=ee(g,0),p=Te(h,b,g),L,O,v,S,I,G,R={solarNoon:F(p),nadir:F(p-.5)};for(L=0,O=K.length;L<O;L+=1)v=K[L],S=(v[0]+i)*d,I=Je(S,r,s,f,c,b,g),G=p-(I-p),R[v[1]]=F(G),R[v[2]]=F(I);return R};function Re(n){let e=d*(218.316+13.176396*n),t=d*(134.963+13.064993*n),a=d*(93.272+13.22935*n),r=e+d*6.289*m(t),s=d*5.128*m(a),i=385001-20905*u(t);return{ra:_e(r,s),dec:ee(r,s),dist:i}}w.getMoonPosition=function(n,e,t){let a=d*-t,r=d*e,s=B(n),i=Re(s),o=ye(s,a)-i.ra,c=Se(o,r,i.dec),h=W(m(o),Q(r)*u(i.dec)-m(i.dec)*u(o));return c=c+We(c),{azimuth:Me(o,r,i.dec),altitude:c,distance:i.dist,parallacticAngle:h}};w.getMoonIllumination=function(n){let e=B(n||new Date),t=Le(e),a=Re(e),r=149598e3,s=be(m(t.dec)*m(a.dec)+u(t.dec)*u(a.dec)*u(t.ra-a.ra)),i=W(r*m(s),a.dist-r*u(s)),o=W(u(t.dec)*m(t.ra-a.ra),m(t.dec)*u(a.dec)-u(t.dec)*m(a.dec)*u(t.ra-a.ra));return{fraction:(1+u(i))/2,phase:.5+.5*i*(o<0?-1:1)/Math.PI,angle:o}};function k(n,e){return new Date(n.valueOf()+e*$/24)}w.getMoonTimes=function(n,e,t,a=!1){let r=new Date(n);a?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);let s=.133*d,i=w.getMoonPosition(r,e,t).altitude-s,o,c,h,b,g,f,p,L,O,v,S,I,G;for(let x=1;x<=24&&(o=w.getMoonPosition(k(r,x),e,t).altitude-s,c=w.getMoonPosition(k(r,x+1),e,t).altitude-s,g=(i+c)/2-o,f=(c-i)/2,p=-f/(2*g),L=(g*p+f)*p+o,O=f*f-4*g*o,v=0,O>=0&&(G=Math.sqrt(O)/(Math.abs(g)*2),S=p-G,I=p+G,Math.abs(S)<=1&&v++,Math.abs(I)<=1&&v++,S<-1&&(S=I)),v===1?i<0?h=x+S:b=x+S:v===2&&(h=x+(L<0?I:S),b=x+(L<0?S:I)),!(h&&b));x+=2)i=c;let R={};return h&&(R.rise=k(r,h)),b&&(R.set=k(r,b)),!h&&!b&&(R[L>0?"alwaysUp":"alwaysDown"]=!0),R};var xe=w;var te=class{_delegate;_sunLight;_hemiLight;_currentTime;constructor(){this._delegate=new T.Group,this._delegate.name="Sun",this._sunLight=new T.DirectionalLight(16777215,1),this._hemiLight=new T.HemisphereLight(new T.Color(16777215),new T.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=new Date().getTime()}get delegate(){return this._delegate}set castShadow(e){this._sunLight.castShadow=e}get castShadow(){return this._sunLight.castShadow}set currentTime(e){this._currentTime=e}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(e={}){return this._sunLight.shadow.radius=e.radius||2,this._sunLight.shadow.mapSize.width=e.mapSize?e.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=e.mapSize?e.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=e.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=e.bottomLeft||-1e3,this._sunLight.shadow.camera.near=e.near||1,this._sunLight.shadow.camera.far=e.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(e){let a=new Date(this._currentTime||new Date().getTime()),r=e.center,s=xe.getPosition(a,r.lat,r.lng),i=s.altitude,o=Math.PI+s.azimuth,c=1024e3/2,h=Math.sin(i),b=Math.cos(i),g=Math.cos(o)*b,f=Math.sin(o)*b;this._sunLight.position.set(f,g,h),this._sunLight.position.multiplyScalar(c),this._sunLight.intensity=Math.max(h,0),this._hemiLight.intensity=Math.max(h*1,.1),this._sunLight.updateMatrixWorld()}},ne=te;var E=j(H(),1);var re=class{static createRTCGroup(e,t,a){let r=new E.Group;if(r.name="rtc",r.position.copy(y.lngLatToVector3(e)),t?(r.rotateX(t[0]||0),r.rotateY(t[1]||0),r.rotateZ(t[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(e)&&(s=y.projectedUnitsPerMeter(e[1])),r.scale.set(s,s,s)}return r}static createMercatorRTCGroup(e,t,a){let r=this.createRTCGroup(e,t,a);if(!a){let s=1,i=y.projectedMercatorUnitsPerMeter();Array.isArray(e)&&(s=y.projectedUnitsPerMeter(e[1])),r.scale.set(i,i,s)}return r}static createShadowGround(e,t,a){let r=new E.PlaneGeometry(t||100,a||100),s=new E.ShadowMaterial({opacity:.5,transparent:!0}),i=new E.Mesh(r,s);return i.position.copy(y.lngLatToVector3(e)),i.receiveShadow=!0,i.name="shadow-ground",i}},ae=re;return He(Ve);})();
1
+ "use strict";var MTP=(()=>{var Pe=Object.create;var W=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var Ge=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),He=(n,e)=>{for(var t in e)W(n,t,{get:e[t],enumerable:!0})},se=(n,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ze(e))!Oe.call(n,r)&&r!==t&&W(n,r,{get:()=>e[r],enumerable:!(a=Ee(e,r))||a.enumerable});return n};var j=(n,e,t)=>(t=n!=null?Pe(Ae(n)):{},se(e||!n||!n.__esModule?W(t,"default",{value:n,enumerable:!0}):t,n)),je=n=>se(W({},"__esModule",{value:!0}),n);var H=Ge((Xe,oe)=>{"use strict";oe.exports=THREE});var Be={};He(Be,{Creator:()=>ie,MapScene:()=>U,SceneTransform:()=>y,Sun:()=>re});var _=j(H(),1);var C=63710088e-1,z=2*Math.PI*C,l=Math.PI/180,Ye=180/Math.PI,A=1024e3/z,me=512;var N=class{static clamp(e,t,a){return Math.min(a,Math.max(t,e))}static makePerspectiveMatrix(e,t,a,r){let s=1/Math.tan(e/2),i=1/(a-r);return[s/t,0,0,0,0,s,0,0,0,0,(r+a)*i,-1,0,0,2*r*a*i,0]}static mercatorXFromLng(e){return(180+e)/360}static mercatorYFromLat(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}static getViewInfo(e,t,a){let r=e.fov*l,s=e.pitch*l,i=null;if(Array.isArray(t)&&(i={lng:t[0],lat:t[1],alt:t[2]||0}),typeof t=="string"){let p=t.split(",");i={lng:+p[0],lat:+p[1],alt:+p[2]||0}}let c=Math.max(a.x,a.y,a.z)/(2*Math.tan(r/2))*Math.cos(s)+i.alt,h=Math.abs(Math.cos(s)*e.cameraToCenterDistance),b=z*Math.abs(Math.cos(i.lat*l)),f=h/c*b,g=Math.round(Math.log2(f/e.tileSize));return{center:[i.lng,i.lat],cameraHeight:c,zoom:Math.min(g,e.maxZoom)}}static getHeightByZoom(e,t,a,r){let s=Math.abs(Math.cos(r*l)*e.cameraToCenterDistance),i=z*Math.abs(Math.cos(a*l)),o=Math.pow(2,t)*e.tileSize;return s*i/o}static getZoomByHeight(e,t,a,r){let s=Math.abs(Math.cos(r*l)*e.cameraToCenterDistance),i=z*Math.abs(Math.cos(a*l)),o=s/t*i;return Math.round(Math.log2(o/e.tileSize))}},D=N;var M=j(H(),1),ce=new M.Matrix4,ue=new M.Matrix4,he=85.051129,X=class{_map;_world;_camera;_translateCenter;_worldSizeRatio;constructor(e,t,a){this._map=e,this._world=t,this._camera=a,this._translateCenter=new M.Matrix4().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=me/1024e3,this._map.on("move",()=>{this.syncCamera(!1)}),this._map.on("resize",()=>{this.syncCamera(!0)})}syncCamera(e){let t=this._map.transform,a=t.pitch*l,r=t.bearing*l;if(e){let g=t.fov*l,p=t.centerOffset||new M.Vector3;this._camera.aspect=t.width/t.height,ce.elements=D.makePerspectiveMatrix(g,this._camera.aspect,t.height/50,t.farZ),this._camera.projectionMatrix=ce,this._camera.projectionMatrix.elements[8]=-p.x*2/t.width,this._camera.projectionMatrix.elements[9]=p.y*2/t.height}ue.makeTranslation(0,0,t.cameraToCenterDistance);let s=new M.Matrix4().premultiply(ue).premultiply(new M.Matrix4().makeRotationX(a)).premultiply(new M.Matrix4().makeRotationZ(-r));t.elevation&&(s.elements[14]=t.cameraToCenterDistance*Math.cos(a)),this._camera.matrixWorld.copy(s);let i=t.scale*this._worldSizeRatio,o=new M.Matrix4().makeScale(i,i,i),c=t.x,h=t.y;if(!c||!h){let g=t.center,p=D.clamp(g.lat,-he,he);c=D.mercatorXFromLng(g.lng)*t.worldSize,h=D.mercatorYFromLat(p)*t.worldSize}let b=new M.Matrix4().makeTranslation(-c,h,0),f=new M.Matrix4().makeRotationZ(Math.PI);this._world.matrix=new M.Matrix4().premultiply(f).premultiply(this._translateCenter).premultiply(o).premultiply(b)}},le=X;var Y=class{_id;_mapScene;_cameraSync;constructor(e,t){this._id=e,this._mapScene=t,this._cameraSync=new le(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},pe=Y;var de=j(H(),1);var q=class{static projectedMercatorUnitsPerMeter(){return this.projectedUnitsPerMeter(0)}static projectedUnitsPerMeter(e){return Math.abs(1024e3/Math.cos(l*e)/z)}static lngLatToVector3(e,t,a){let r=[0,0,0];return Array.isArray(e)?(r=[-C*l*e[0]*A,-C*Math.log(Math.tan(Math.PI*.25+.5*l*e[1]))*A],e[2]?r.push(e[2]*this.projectedUnitsPerMeter(e[1])):r.push(0)):(r=[-C*l*e*A,-C*Math.log(Math.tan(Math.PI*.25+.5*l*(t||0)))*A],a?r.push(a*this.projectedUnitsPerMeter(t||0)):r.push(0)),new de.Vector3(r[0],r[1],r[2])}static vector3ToLngLat(e){let t=[0,0,0];return e&&(t[0]=-e.x/(C*l*A),t[1]=2*(Math.atan(Math.exp(e.y/(A*-C)))-Math.PI/4)/l,t[2]=e.z/this.projectedUnitsPerMeter(t[1])),t}},y=q;var Ue={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},K="map_scene_layer",U=class{_map;_options;_canvas;_scene;_camera;_renderer;_lights;_world;_event;constructor(e,t={}){if(!e)throw"missing map";this._map=e,this._options={...Ue,...t},this._canvas=e.getCanvas(),this._scene=this._options.scene||new _.Scene,this._camera=this._options.camera||new _.PerspectiveCamera(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.001,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new _.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 _.Group,this._lights.name="lights",this._scene.add(this._lights),this._world=new _.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 _.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(K)||this._map.addLayer(new pe(K,this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let e={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:e}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:e}),this._event.dispatchEvent({type:"preRender",frameState:e}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:e})}return this}addLight(e){return this._lights.add(e.delegate||e),this}removeLight(e){return this._lights.remove(e.delegate||e),this}addObject(e){let t="delegate"in e?e.delegate:e;return this._world.add(t),this}removeObject(e){let t="delegate"in e?e.delegate:e;return this._world.remove(t),t.traverse(a=>{a.geometry&&a.geometry.dispose(),a.material&&(Array.isArray(a.material)?a.material.forEach(r=>r.dispose()):a.material.dispose()),a.texture&&a.texture.dispose()}),this}getViewPosition(){let e=this._map.transform,t=e.center;return{position:[t.lng,t.lat,D.getHeightByZoom(e,e.zoom,t.lat,e.pitch)],heading:e.bearing,pitch:e.pitch}}flyTo(e,t,a){if(e&&e.position){a&&this._map.once("moveend",a);let r=e.size;r||(r=new _.Vector3,new _.Box3().setFromObject(e.delegate||e,!0).getSize(r));let s=D.getViewInfo(this._map.transform,y.vector3ToLngLat(e.position),r);this._map.flyTo({center:s.center,zoom:s.zoom,duration:(t||3)*1e3})}return this}zoomTo(e,t){return this.flyTo(e,0,t)}flyToPosition(e,t=[0,0,0],a,r=3){return a&&this._map.once("moveend",a),this._map.flyTo({center:[e[0],e[1]],zoom:D.getZoomByHeight(this._map.transform,e[2],e[1],t[1]||0),bearing:t[0],pitch:t[1],duration:r*1e3}),this}zoomToPosition(e,t=[0,0,0],a){return this.flyToPosition(e,t,a,0)}on(e,t){return this._event.addEventListener(e,t),this}off(e,t){return this._event.removeEventListener(e,t),this}layerBeforeTo(e){return this._map.moveLayer(K,e),this}};var T=j(H(),1);var V=Math.PI,m=Math.sin,u=Math.cos,$=Math.tan,be=Math.asin,Z=Math.atan2,ge=Math.acos,d=V/180,ee=1e3*60*60*24,fe=2440588,_e=2451545;function Ze(n){return n.valueOf()/ee-.5+fe}function F(n){return new Date((n+.5-fe)*ee)}function B(n){return Ze(n)-_e}var J=d*23.4397;function Me(n,e){return Z(m(n)*u(J)-$(e)*m(J),u(n))}function te(n,e){return be(m(e)*u(J)+u(e)*m(J)*m(n))}function Se(n,e,t){return Z(m(n),u(n)*m(e)-$(t)*u(e))}function ye(n,e,t){return be(m(e)*m(t)+u(e)*u(t)*u(n))}function we(n,e){return d*(280.16+360.9856235*n)-e}function We(n){return n<0&&(n=0),2967e-7/Math.tan(n+.00312536/(n+.08901179))}function ve(n){return d*(357.5291+.98560028*n)}function Le(n){let e=d*(1.9148*m(n)+.02*m(2*n)+3e-4*m(3*n)),t=d*102.9372;return n+e+t+V}function Ie(n){let e=ve(n),t=Le(e);return{dec:te(t,0),ra:Me(t,0)}}var w={};w.getPosition=function(n,e,t){let a=d*-t,r=d*e,s=B(n),i=Ie(s),o=we(s,a)-i.ra;return{azimuth:Se(o,r,i.dec),altitude:ye(o,r,i.dec)}};var Q=w.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];w.addTime=function(n,e,t){Q.push([n,e,t])};var De=9e-4;function Fe(n,e){return Math.round(n-De-e/(2*V))}function Te(n,e,t){return De+(n+e)/(2*V)+t}function Re(n,e,t){return _e+n+.0053*m(e)-.0069*m(2*t)}function ke(n,e,t){return ge((m(n)-m(e)*m(t))/(u(e)*u(t)))}function Je(n){return-2.076*Math.sqrt(n)/60}function Ve(n,e,t,a,r,s,i){let o=ke(n,t,a),c=Te(o,e,r);return Re(c,s,i)}w.getTimes=function(n,e,t,a=0){let r=d*-t,s=d*e,i=Je(a),o=B(n),c=Fe(o,r),h=Te(0,r,c),b=ve(h),f=Le(b),g=te(f,0),p=Re(h,b,f),L,O,v,S,I,G,R={solarNoon:F(p),nadir:F(p-.5)};for(L=0,O=Q.length;L<O;L+=1)v=Q[L],S=(v[0]+i)*d,I=Ve(S,r,s,g,c,b,f),G=p-(I-p),R[v[1]]=F(G),R[v[2]]=F(I);return R};function xe(n){let e=d*(218.316+13.176396*n),t=d*(134.963+13.064993*n),a=d*(93.272+13.22935*n),r=e+d*6.289*m(t),s=d*5.128*m(a),i=385001-20905*u(t);return{ra:Me(r,s),dec:te(r,s),dist:i}}w.getMoonPosition=function(n,e,t){let a=d*-t,r=d*e,s=B(n),i=xe(s),o=we(s,a)-i.ra,c=ye(o,r,i.dec),h=Z(m(o),$(r)*u(i.dec)-m(i.dec)*u(o));return c=c+We(c),{azimuth:Se(o,r,i.dec),altitude:c,distance:i.dist,parallacticAngle:h}};w.getMoonIllumination=function(n){let e=B(n||new Date),t=Ie(e),a=xe(e),r=149598e3,s=ge(m(t.dec)*m(a.dec)+u(t.dec)*u(a.dec)*u(t.ra-a.ra)),i=Z(r*m(s),a.dist-r*u(s)),o=Z(u(t.dec)*m(t.ra-a.ra),m(t.dec)*u(a.dec)-u(t.dec)*m(a.dec)*u(t.ra-a.ra));return{fraction:(1+u(i))/2,phase:.5+.5*i*(o<0?-1:1)/Math.PI,angle:o}};function k(n,e){return new Date(n.valueOf()+e*ee/24)}w.getMoonTimes=function(n,e,t,a=!1){let r=new Date(n);a?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);let s=.133*d,i=w.getMoonPosition(r,e,t).altitude-s,o,c,h,b,f,g,p,L,O,v,S,I,G;for(let x=1;x<=24&&(o=w.getMoonPosition(k(r,x),e,t).altitude-s,c=w.getMoonPosition(k(r,x+1),e,t).altitude-s,f=(i+c)/2-o,g=(c-i)/2,p=-g/(2*f),L=(f*p+g)*p+o,O=g*g-4*f*o,v=0,O>=0&&(G=Math.sqrt(O)/(Math.abs(f)*2),S=p-G,I=p+G,Math.abs(S)<=1&&v++,Math.abs(I)<=1&&v++,S<-1&&(S=I)),v===1?i<0?h=x+S:b=x+S:v===2&&(h=x+(L<0?I:S),b=x+(L<0?S:I)),!(h&&b));x+=2)i=c;let R={};return h&&(R.rise=k(r,h)),b&&(R.set=k(r,b)),!h&&!b&&(R[L>0?"alwaysUp":"alwaysDown"]=!0),R};var Ce=w;var ne=class{_delegate;_sunLight;_hemiLight;_currentTime;constructor(){this._delegate=new T.Group,this._delegate.name="Sun",this._sunLight=new T.DirectionalLight(16777215,1),this._hemiLight=new T.HemisphereLight(new T.Color(16777215),new T.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=new Date().getTime()}get delegate(){return this._delegate}set castShadow(e){this._sunLight.castShadow=e}get castShadow(){return this._sunLight.castShadow}set currentTime(e){this._currentTime=e}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(e={}){return this._sunLight.shadow.radius=e.radius||2,this._sunLight.shadow.mapSize.width=e.mapSize?e.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=e.mapSize?e.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=e.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=e.bottomLeft||-1e3,this._sunLight.shadow.camera.near=e.near||1,this._sunLight.shadow.camera.far=e.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(e){let a=new Date(this._currentTime||new Date().getTime()),r=e.center,s=Ce.getPosition(a,r.lat,r.lng),i=s.altitude,o=Math.PI+s.azimuth,c=1024e3/2,h=Math.sin(i),b=Math.cos(i),f=Math.cos(o)*b,g=Math.sin(o)*b;this._sunLight.position.set(g,f,h),this._sunLight.position.multiplyScalar(c),this._sunLight.intensity=Math.max(h,0),this._hemiLight.intensity=Math.max(h*1,.1),this._sunLight.updateMatrixWorld()}},re=ne;var E=j(H(),1);var ae=class{static createRTCGroup(e,t,a){let r=new E.Group;if(r.name="rtc",r.position.copy(y.lngLatToVector3(e)),t?(r.rotateX(t[0]||0),r.rotateY(t[1]||0),r.rotateZ(t[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(e)&&(s=y.projectedUnitsPerMeter(e[1])),r.scale.set(s,s,s)}return r}static createMercatorRTCGroup(e,t,a){let r=this.createRTCGroup(e,t,a);if(!a){let s=1,i=y.projectedMercatorUnitsPerMeter();Array.isArray(e)&&(s=y.projectedUnitsPerMeter(e[1])),r.scale.set(i,i,s)}return r}static createShadowGround(e,t,a){let r=new E.PlaneGeometry(t||100,a||100),s=new E.ShadowMaterial({opacity:.5,transparent:!0}),i=new E.Mesh(r,s);return i.position.copy(y.lngLatToVector3(e)),i.receiveShadow=!0,i.name="shadow-ground",i}},ie=ae;return je(Be);})();
package/package.json CHANGED
@@ -1,55 +1,55 @@
1
- {
2
- "name": "@dvt3d/maplibre-three-plugin",
3
- "version": "1.3.0",
4
- "repository": "https://github.com/dvt3d/maplibre-three-plugin.git",
5
- "author": "cavencj <cavencj@gmail.com>",
6
- "license": "MIT",
7
- "type": "module",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- }
13
- },
14
- "main": "dist/index.js",
15
- "types": "dist/index.d.ts",
16
- "scripts": {
17
- "dev": "rimraf dist && gulp dev",
18
- "build": "rimraf dist && gulp build",
19
- "build:node": "rimraf dist && gulp buildNode",
20
- "build:iife": "rimraf dist && gulp buildIIFE",
21
- "build:release": "rimraf dist && gulp buildRelease",
22
- "prepublishOnly": "yarn run build:release",
23
- "lint": "eslint --fix src"
24
- },
25
- "devDependencies": {
26
- "@babel/core": "^7.21.4",
27
- "@babel/eslint-parser": "^7.21.8",
28
- "@babel/plugin-proposal-class-properties": "^7.18.6",
29
- "@babel/plugin-transform-runtime": "^7.21.4",
30
- "@babel/preset-env": "^7.21.5",
31
- "@types/three": "^0.179.0",
32
- "chalk": "^5.2.0",
33
- "esbuild-plugin-globals": "^0.2.0",
34
- "eslint": "^8.40.0",
35
- "eslint-config-prettier": "^8.8.0",
36
- "eslint-plugin-import": "^2.27.5",
37
- "eslint-plugin-node": "^11.1.0",
38
- "eslint-plugin-prettier": "^4.2.1",
39
- "eslint-plugin-promise": "^6.1.1",
40
- "express": "^4.18.2",
41
- "fs-extra": "^11.1.1",
42
- "gulp": "^4.0.2",
43
- "prettier": "^2.8.8",
44
- "rimraf": "^5.0.0",
45
- "shelljs": "^0.8.5",
46
- "tsup": "^8.5.0",
47
- "typescript": "^5.9.2"
48
- },
49
- "peerDependencies": {
50
- "three": "^0.178.0"
51
- },
52
- "files": [
53
- "dist"
54
- ]
55
- }
1
+ {
2
+ "name": "@dvt3d/maplibre-three-plugin",
3
+ "version": "1.4.0",
4
+ "repository": "https://github.com/dvt3d/maplibre-three-plugin.git",
5
+ "author": "cavencj <cavencj@gmail.com>",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "main": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "scripts": {
17
+ "dev": "rimraf dist && gulp dev",
18
+ "build": "rimraf dist && gulp build",
19
+ "build:node": "rimraf dist && gulp buildNode",
20
+ "build:iife": "rimraf dist && gulp buildIIFE",
21
+ "build:release": "rimraf dist && gulp buildRelease",
22
+ "prepublishOnly": "yarn run build:release",
23
+ "lint": "eslint --fix src"
24
+ },
25
+ "devDependencies": {
26
+ "@babel/core": "^7.21.4",
27
+ "@babel/eslint-parser": "^7.21.8",
28
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
29
+ "@babel/plugin-transform-runtime": "^7.21.4",
30
+ "@babel/preset-env": "^7.21.5",
31
+ "@types/three": "^0.179.0",
32
+ "chalk": "^5.2.0",
33
+ "esbuild-plugin-globals": "^0.2.0",
34
+ "eslint": "^8.40.0",
35
+ "eslint-config-prettier": "^8.8.0",
36
+ "eslint-plugin-import": "^2.27.5",
37
+ "eslint-plugin-node": "^11.1.0",
38
+ "eslint-plugin-prettier": "^4.2.1",
39
+ "eslint-plugin-promise": "^6.1.1",
40
+ "express": "^4.18.2",
41
+ "fs-extra": "^11.1.1",
42
+ "gulp": "^4.0.2",
43
+ "prettier": "^2.8.8",
44
+ "rimraf": "^5.0.0",
45
+ "shelljs": "^0.8.5",
46
+ "tsup": "^8.5.0",
47
+ "typescript": "^5.9.2"
48
+ },
49
+ "peerDependencies": {
50
+ "three": "^0.178.0"
51
+ },
52
+ "files": [
53
+ "dist"
54
+ ]
55
+ }