@ohuoy/easymap 1.1.8 → 1.1.10

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.
Files changed (43) hide show
  1. package/old/CHANGELOG.md +665 -0
  2. package/old/LICENSE.txt +97 -0
  3. package/old/README.md +199 -0
  4. package/old/dist/threebox.min.js +0 -0
  5. package/old/exports.js +2 -0
  6. package/old/jz.json +497 -0
  7. package/old/main.js +10 -0
  8. package/old/package-lock.json +4638 -0
  9. package/old/package.json +44 -0
  10. package/old/server.stop.js +13 -0
  11. package/old/src/Threebox.js +1216 -0
  12. package/old/src/animation/AnimationManager.js +483 -0
  13. package/old/src/camera/CameraSync.js +302 -0
  14. package/old/src/objects/CSS2DRenderer.js +245 -0
  15. package/old/src/objects/LabelRenderer.js +71 -0
  16. package/old/src/objects/Object3D.js +34 -0
  17. package/old/src/objects/effects/BuildingShadows.js +115 -0
  18. package/old/src/objects/extrusion.js +61 -0
  19. package/old/src/objects/fflate.min.js +15 -0
  20. package/old/src/objects/label.js +29 -0
  21. package/old/src/objects/line.js +1386 -0
  22. package/old/src/objects/loadObj.js +142 -0
  23. package/old/src/objects/loaders/ColladaLoader.js +3751 -0
  24. package/old/src/objects/loaders/FBXLoader.js +3864 -0
  25. package/old/src/objects/loaders/GLTFLoader.js +3857 -0
  26. package/old/src/objects/loaders/MTLLoader.js +498 -0
  27. package/old/src/objects/loaders/OBJLoader.js +818 -0
  28. package/old/src/objects/objects.js +1113 -0
  29. package/old/src/objects/sphere.js +28 -0
  30. package/old/src/objects/tooltip.js +27 -0
  31. package/old/src/objects/tube.js +35 -0
  32. package/old/src/three.js +6 -0
  33. package/old/src/three.module.js +54572 -0
  34. package/old/src/utils/ValueGenerator.js +11 -0
  35. package/old/src/utils/constants.js +21 -0
  36. package/old/src/utils/material.js +52 -0
  37. package/old/src/utils/suncalc.js +322 -0
  38. package/old/src/utils/utils.js +424 -0
  39. package/old/src/utils/validate.js +115 -0
  40. package/old/threebox.min.js +367 -0
  41. package/package.json +1 -1
  42. package/src/components/control/TilesBar.js +1 -1
  43. package/src/components/layer/PathLineLayer.js +373 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohuoy/easymap",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "self map easy use",
5
5
  "main": "main.js",
6
6
  "scripts": {
@@ -146,7 +146,7 @@ export default class TilesBar {
146
146
  // },beforeId)
147
147
  // this._map.theme.value = "dark"
148
148
  // };
149
- this._map.theme.value = "dark"
149
+ this._map.theme.value = this._map.style.stylesheet.theme
150
150
  }
151
151
  if(key == 'satellite'){
152
152
  //移除基本图层
@@ -1,9 +1,6 @@
1
1
  import {Threebox,THREE} from '../../../lib/threebox-plugin/dist/threebox.min.js';
2
2
  // import * as THREE from 'three'
3
3
  import { getBBox } from '../../utils/util.js';
4
- import { sleep } from '../../utils/util.js';
5
- import {hasProperty,transform} from '../../utils/util.js'
6
- import mapboxgl from '../../../lib/mapbox-gl/dist/mapbox-gl.js';
7
4
 
8
5
  export default class PathLineLayer{
9
6
  tb={}
@@ -73,7 +70,379 @@ export default class PathLineLayer{
73
70
  // width: Math.random() + 1 // random width between 1 and 2
74
71
  // }
75
72
 
76
- let lineMesh = this.tb.line(line);
73
+ let lineMesh = this.tb.line(line);
74
+ lineMesh.material.fragmentShader = `
75
+ uniform vec3 diffuse;
76
+ uniform float opacity;
77
+ uniform float linewidth;
78
+
79
+ #ifdef USE_DASH
80
+
81
+ uniform float dashOffset;
82
+ uniform float dashSize;
83
+ uniform float gapSize;
84
+
85
+ #endif
86
+
87
+ varying float vLineDistance;
88
+
89
+ #ifdef WORLD_UNITS
90
+
91
+ varying vec4 worldPos;
92
+ varying vec3 worldStart;
93
+ varying vec3 worldEnd;
94
+
95
+ #ifdef USE_DASH
96
+
97
+ varying vec2 vUv;
98
+
99
+ #endif
100
+
101
+ #else
102
+
103
+ varying vec2 vUv;
104
+
105
+ #endif
106
+
107
+ #include <common>
108
+ #include <color_pars_fragment>
109
+ #include <fog_pars_fragment>
110
+ #include <logdepthbuf_pars_fragment>
111
+ #include <clipping_planes_pars_fragment>
112
+
113
+ vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
114
+
115
+ float mua;
116
+ float mub;
117
+
118
+ vec3 p13 = p1 - p3;
119
+ vec3 p43 = p4 - p3;
120
+
121
+ vec3 p21 = p2 - p1;
122
+
123
+ float d1343 = dot( p13, p43 );
124
+ float d4321 = dot( p43, p21 );
125
+ float d1321 = dot( p13, p21 );
126
+ float d4343 = dot( p43, p43 );
127
+ float d2121 = dot( p21, p21 );
128
+
129
+ float denom = d2121 * d4343 - d4321 * d4321;
130
+
131
+ float numer = d1343 * d4321 - d1321 * d4343;
132
+
133
+ mua = numer / denom;
134
+ mua = clamp( mua, 0.0, 1.0 );
135
+ mub = ( d1343 + d4321 * ( mua ) ) / d4343;
136
+ mub = clamp( mub, 0.0, 1.0 );
137
+
138
+ return vec2( mua, mub );
139
+
140
+ }
141
+
142
+ void main() {
143
+
144
+ #include <clipping_planes_fragment>
145
+
146
+ #ifdef USE_DASH
147
+
148
+ if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
149
+
150
+ if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
151
+
152
+ #endif
153
+
154
+ float alpha = opacity;
155
+
156
+ #ifdef WORLD_UNITS
157
+
158
+ // Find the closest points on the view ray and the line segment
159
+ vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
160
+ vec3 lineDir = worldEnd - worldStart;
161
+ vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
162
+
163
+ vec3 p1 = worldStart + lineDir * params.x;
164
+ vec3 p2 = rayEnd * params.y;
165
+ vec3 delta = p1 - p2;
166
+ float len = length( delta );
167
+ float norm = len / linewidth;
168
+
169
+ #ifndef USE_DASH
170
+
171
+ #ifdef USE_ALPHA_TO_COVERAGE
172
+
173
+ float dnorm = fwidth( norm );
174
+ alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
175
+
176
+ #else
177
+
178
+ if ( norm > 0.5 ) {
179
+
180
+ discard;
181
+
182
+ }
183
+
184
+ #endif
185
+
186
+ #endif
187
+
188
+ #else
189
+
190
+ #ifdef USE_ALPHA_TO_COVERAGE
191
+
192
+ // artifacts appear on some hardware if a derivative is taken within a conditional
193
+ float a = vUv.x;
194
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
195
+ float len2 = a * a + b * b;
196
+ float dlen = fwidth( len2 );
197
+
198
+ if ( abs( vUv.y ) > 1.0 ) {
199
+
200
+ alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
201
+
202
+ }
203
+
204
+ #else
205
+
206
+ if ( abs( vUv.y ) > 1.0 ) {
207
+
208
+ float a = vUv.x;
209
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
210
+ float len2 = a * a + b * b;
211
+
212
+ if ( len2 > 1.0 ) discard;
213
+
214
+ }
215
+
216
+ #endif
217
+
218
+ #endif
219
+
220
+ vec4 diffuseColor = vec4( diffuse, alpha );
221
+
222
+ #include <logdepthbuf_fragment>
223
+ #include <color_fragment>
224
+ vec3 baseColor = diffuseColor.rgb;
225
+ gl_FragColor = vec4( baseColor, alpha );
226
+
227
+ #include <tonemapping_fragment>
228
+ #include <colorspace_fragment>
229
+ #include <fog_fragment>
230
+ #include <premultiplied_alpha_fragment>
231
+
232
+ }
233
+ `
234
+ lineMesh.material.vertexShader = `
235
+ #include <common>
236
+ #include <color_pars_vertex>
237
+ #include <fog_pars_vertex>
238
+ #include <logdepthbuf_pars_vertex>
239
+ #include <clipping_planes_pars_vertex>
240
+
241
+ uniform float linewidth;
242
+ uniform vec2 resolution;
243
+
244
+ attribute vec3 instanceStart;
245
+ attribute vec3 instanceEnd;
246
+
247
+ attribute vec3 instanceColorStart;
248
+ attribute vec3 instanceColorEnd;
249
+
250
+ #ifdef WORLD_UNITS
251
+
252
+ varying vec4 worldPos;
253
+ varying vec3 worldStart;
254
+ varying vec3 worldEnd;
255
+
256
+ #ifdef USE_DASH
257
+
258
+ varying vec2 vUv;
259
+
260
+ #endif
261
+
262
+ #else
263
+
264
+ varying vec2 vUv;
265
+
266
+ #endif
267
+
268
+ #ifdef USE_DASH
269
+
270
+ uniform float dashScale;
271
+ attribute float instanceDistanceStart;
272
+ attribute float instanceDistanceEnd;
273
+ varying float vLineDistance;
274
+
275
+ #endif
276
+
277
+ void trimSegment( const in vec4 start, inout vec4 end ) {
278
+
279
+ // trim end segment so it terminates between the camera plane and the near plane
280
+
281
+ // conservative estimate of the near plane
282
+ float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
283
+ float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
284
+ float nearEstimate = - 0.5 * b / a;
285
+
286
+ float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
287
+
288
+ end.xyz = mix( start.xyz, end.xyz, alpha );
289
+
290
+ }
291
+
292
+ void main() {
293
+
294
+ #ifdef USE_COLOR
295
+
296
+ vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
297
+
298
+ #endif
299
+
300
+ #ifdef USE_DASH
301
+
302
+ vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
303
+ vUv = uv;
304
+
305
+ #endif
306
+
307
+ float aspect = resolution.x / resolution.y;
308
+
309
+ // camera space
310
+ vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
311
+ vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
312
+
313
+ #ifdef WORLD_UNITS
314
+
315
+ worldStart = start.xyz;
316
+ worldEnd = end.xyz;
317
+
318
+ #else
319
+
320
+ vUv = uv;
321
+
322
+ #endif
323
+
324
+ // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
325
+ // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
326
+ // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
327
+ // perhaps there is a more elegant solution -- WestLangley
328
+
329
+ bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
330
+
331
+ if ( perspective ) {
332
+
333
+ if ( start.z < 0.0 && end.z >= 0.0 ) {
334
+
335
+ trimSegment( start, end );
336
+
337
+ } else if ( end.z < 0.0 && start.z >= 0.0 ) {
338
+
339
+ trimSegment( end, start );
340
+
341
+ }
342
+
343
+ }
344
+
345
+ // clip space
346
+ vec4 clipStart = projectionMatrix * start;
347
+ vec4 clipEnd = projectionMatrix * end;
348
+
349
+ // ndc space
350
+ vec3 ndcStart = clipStart.xyz / clipStart.w;
351
+ vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
352
+
353
+ // direction
354
+ vec2 dir = ndcEnd.xy - ndcStart.xy;
355
+
356
+ // account for clip-space aspect ratio
357
+ dir.x *= aspect;
358
+ dir = normalize( dir );
359
+
360
+ #ifdef WORLD_UNITS
361
+
362
+ vec3 worldDir = normalize( end.xyz - start.xyz );
363
+ vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
364
+ vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
365
+ vec3 worldFwd = cross( worldDir, worldUp );
366
+ worldPos = position.y < 0.5 ? start: end;
367
+
368
+ // height offset
369
+ float hw = linewidth * 0.5;
370
+ worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
371
+
372
+ // don't extend the line if we're rendering dashes because we
373
+ // won't be rendering the endcaps
374
+ #ifndef USE_DASH
375
+
376
+ // cap extension
377
+ worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
378
+
379
+ // add width to the box
380
+ worldPos.xyz += worldFwd * hw;
381
+
382
+ // endcaps
383
+ if ( position.y > 1.0 || position.y < 0.0 ) {
384
+
385
+ worldPos.xyz -= worldFwd * 2.0 * hw;
386
+
387
+ }
388
+
389
+ #endif
390
+
391
+ // project the worldpos
392
+ vec4 clip = projectionMatrix * worldPos;
393
+
394
+ // shift the depth of the projected points so the line
395
+ // segments overlap neatly
396
+ vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
397
+ clip.z = clipPose.z * clip.w;
398
+
399
+ #else
400
+
401
+ vec2 offset = vec2( dir.y, - dir.x );
402
+ // undo aspect ratio adjustment
403
+ dir.x /= aspect;
404
+ offset.x /= aspect;
405
+
406
+ // sign flip
407
+ if ( position.x < 0.0 ) offset *= - 1.0;
408
+
409
+ // endcaps
410
+ if ( position.y < 0.0 ) {
411
+
412
+ offset += - dir;
413
+
414
+ } else if ( position.y > 1.0 ) {
415
+
416
+ offset += dir;
417
+
418
+ }
419
+
420
+ // adjust for linewidth
421
+ offset *= linewidth;
422
+
423
+ // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
424
+ offset /= resolution.y;
425
+
426
+ // select end
427
+ vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
428
+
429
+ // back to clip space
430
+ offset *= clip.w;
431
+
432
+ clip.xy += offset;
433
+
434
+ #endif
435
+
436
+ gl_Position = clip;
437
+
438
+ vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
439
+
440
+ #include <logdepthbuf_vertex>
441
+ #include <clipping_planes_vertex>
442
+ #include <fog_vertex>
443
+
444
+ }
445
+ `
77
446
  this.tb.add(lineMesh)
78
447
  this.lines.push(lineMesh)
79
448
  })