@ohuoy/easymap 1.0.19 → 1.0.21

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 (57) hide show
  1. package/dist/bundle.js +318 -290
  2. package/dist/example - /345/211/257/346/234/254/bundle.js" +318 -290
  3. package/dist/example - /345/211/257/346/234/254/index.html" +11 -11
  4. package/index.js +4 -0
  5. package/lib/threebox-plugin/CHANGELOG.md +665 -0
  6. package/lib/threebox-plugin/LICENSE.txt +97 -0
  7. package/lib/threebox-plugin/README.md +199 -0
  8. package/lib/threebox-plugin/exports.js +2 -0
  9. package/lib/threebox-plugin/main.js +8 -0
  10. package/lib/threebox-plugin/package.json +44 -0
  11. package/lib/threebox-plugin/server.stop.js +13 -0
  12. package/lib/threebox-plugin/src/Threebox.js +1216 -0
  13. package/lib/threebox-plugin/src/animation/AnimationManager.js +483 -0
  14. package/lib/threebox-plugin/src/camera/CameraSync.js +302 -0
  15. package/lib/threebox-plugin/src/objects/CSS2DRenderer.js +245 -0
  16. package/lib/threebox-plugin/src/objects/LabelRenderer.js +71 -0
  17. package/lib/threebox-plugin/src/objects/Object3D.js +34 -0
  18. package/lib/threebox-plugin/src/objects/effects/BuildingShadows.js +115 -0
  19. package/lib/threebox-plugin/src/objects/extrusion.js +61 -0
  20. package/lib/threebox-plugin/src/objects/fflate.min.js +15 -0
  21. package/lib/threebox-plugin/src/objects/label.js +29 -0
  22. package/lib/threebox-plugin/src/objects/line.js +1386 -0
  23. package/lib/threebox-plugin/src/objects/loadObj.js +142 -0
  24. package/lib/threebox-plugin/src/objects/loaders/ColladaLoader.js +3751 -0
  25. package/lib/threebox-plugin/src/objects/loaders/FBXLoader.js +3864 -0
  26. package/lib/threebox-plugin/src/objects/loaders/GLTFLoader.js +3857 -0
  27. package/lib/threebox-plugin/src/objects/loaders/MTLLoader.js +498 -0
  28. package/lib/threebox-plugin/src/objects/loaders/OBJLoader.js +818 -0
  29. package/lib/threebox-plugin/src/objects/objects.js +1113 -0
  30. package/lib/threebox-plugin/src/objects/sphere.js +28 -0
  31. package/lib/threebox-plugin/src/objects/tooltip.js +27 -0
  32. package/lib/threebox-plugin/src/objects/tube.js +35 -0
  33. package/lib/threebox-plugin/src/three.js +6 -0
  34. package/lib/threebox-plugin/src/three.module.js +54571 -0
  35. package/lib/threebox-plugin/src/utils/ValueGenerator.js +11 -0
  36. package/lib/threebox-plugin/src/utils/constants.js +21 -0
  37. package/lib/threebox-plugin/src/utils/material.js +52 -0
  38. package/lib/threebox-plugin/src/utils/suncalc.js +322 -0
  39. package/lib/threebox-plugin/src/utils/utils.js +424 -0
  40. package/lib/threebox-plugin/src/utils/validate.js +115 -0
  41. package/package.json +18 -18
  42. package/src/components/EasyMapMarker.js +8 -0
  43. package/src/components/control/DrawBar.js +5 -0
  44. package/src/components/control/TilesBar.js +116 -27
  45. package/src/components/control/Toobars.js +20 -1
  46. package/src/components/layer/AlarmLayer.js +4 -1
  47. package/src/components/layer/AnimationBarbsLayer.js +1 -1
  48. package/src/components/layer/AnimationLayer copy.js +1 -1
  49. package/src/components/layer/AnimationLayer.js +11 -3
  50. package/src/components/layer/CustomIconLayer.js +1 -1
  51. package/src/components/layer/ExtrusionLayer.js +1 -1
  52. package/src/components/layer/ExtrusionLayerold.js +2 -1
  53. package/src/components/layer/MarkerAreaLayer.js +1 -1
  54. package/src/components/layer/PathLineLayer.js +1 -1
  55. package/src/components/layer/ThreeScanLayer.js +51 -14
  56. package/src/components/layer/ThreeWallLayer.js +1 -1
  57. package/webpack.config.js +2 -1
@@ -0,0 +1,498 @@
1
+ import * as THREE from '../../three.module.js'
2
+
3
+ // (function () {
4
+
5
+ /**
6
+ * Loads a Wavefront .mtl file specifying materials
7
+ */
8
+
9
+ class MTLLoader extends THREE.Loader {
10
+
11
+ constructor(manager) {
12
+
13
+ super(manager);
14
+
15
+ }
16
+ /**
17
+ * Loads and parses a MTL asset from a URL.
18
+ *
19
+ * @param {String} url - URL to the MTL file.
20
+ * @param {Function} [onLoad] - Callback invoked with the loaded object.
21
+ * @param {Function} [onProgress] - Callback for download progress.
22
+ * @param {Function} [onError] - Callback for download errors.
23
+ *
24
+ * @see setPath setResourcePath
25
+ *
26
+ * @note In order for relative texture references to resolve correctly
27
+ * you must call setResourcePath() explicitly prior to load.
28
+ */
29
+
30
+
31
+ load(url, onLoad, onProgress, onError) {
32
+
33
+ const scope = this;
34
+ const path = this.path === '' ? THREE.LoaderUtils.extractUrlBase(url || '') : this.path;
35
+ const loader = new THREE.FileLoader(this.manager);
36
+ loader.setPath(this.path);
37
+ loader.setRequestHeader(this.requestHeader);
38
+ loader.setWithCredentials(this.withCredentials);
39
+ loader.load(url, function (text) {
40
+
41
+ try {
42
+
43
+ onLoad(scope.parse(text, path));
44
+
45
+ } catch (e) {
46
+
47
+ if (onError) {
48
+
49
+ onError(e);
50
+
51
+ } else {
52
+
53
+ console.error(e);
54
+
55
+ }
56
+
57
+ scope.manager.itemError(url);
58
+
59
+ }
60
+
61
+ }, onProgress, onError);
62
+
63
+ }
64
+
65
+ setMaterialOptions(value) {
66
+
67
+ this.materialOptions = value;
68
+ return this;
69
+
70
+ }
71
+ /**
72
+ * Parses a MTL file.
73
+ *
74
+ * @param {String} text - Content of MTL file
75
+ * @return {MaterialCreator}
76
+ *
77
+ * @see setPath setResourcePath
78
+ *
79
+ * @note In order for relative texture references to resolve correctly
80
+ * you must call setResourcePath() explicitly prior to parse.
81
+ */
82
+
83
+
84
+ parse(text, path) {
85
+
86
+ const lines = text.split('\n');
87
+ let info = {};
88
+ const delimiter_pattern = /\s+/;
89
+ const materialsInfo = {};
90
+
91
+ for (let i = 0; i < lines.length; i++) {
92
+
93
+ let line = lines[i];
94
+ line = line.trim();
95
+
96
+ if (line.length === 0 || line.charAt(0) === '#') {
97
+
98
+ // Blank line or comment ignore
99
+ continue;
100
+
101
+ }
102
+
103
+ const pos = line.indexOf(' ');
104
+ let key = pos >= 0 ? line.substring(0, pos) : line;
105
+ key = key.toLowerCase();
106
+ let value = pos >= 0 ? line.substring(pos + 1) : '';
107
+ value = value.trim();
108
+
109
+ if (key === 'newmtl') {
110
+
111
+ // New material
112
+ info = {
113
+ name: value
114
+ };
115
+ materialsInfo[value] = info;
116
+
117
+ } else {
118
+
119
+ if (key === 'ka' || key === 'kd' || key === 'ks' || key === 'ke') {
120
+
121
+ const ss = value.split(delimiter_pattern, 3);
122
+ info[key] = [parseFloat(ss[0]), parseFloat(ss[1]), parseFloat(ss[2])];
123
+
124
+ } else {
125
+
126
+ info[key] = value;
127
+
128
+ }
129
+
130
+ }
131
+
132
+ }
133
+
134
+ const materialCreator = new MaterialCreator(this.resourcePath || path, this.materialOptions);
135
+ materialCreator.setCrossOrigin(this.crossOrigin);
136
+ materialCreator.setManager(this.manager);
137
+ materialCreator.setMaterials(materialsInfo);
138
+ return materialCreator;
139
+
140
+ }
141
+
142
+ }
143
+ /**
144
+ * Create a new MTLLoader.MaterialCreator
145
+ * @param baseUrl - Url relative to which textures are loaded
146
+ * @param options - Set of options on how to construct the materials
147
+ * side: Which side to apply the material
148
+ * THREE.FrontSide (default), THREE.BackSide, THREE.DoubleSide
149
+ * wrap: What type of wrapping to apply for textures
150
+ * THREE.RepeatWrapping (default), THREE.ClampToEdgeWrapping, THREE.MirroredRepeatWrapping
151
+ * normalizeRGB: RGBs need to be normalized to 0-1 from 0-255
152
+ * Default: false, assumed to be already normalized
153
+ * ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's
154
+ * Default: false
155
+ * @constructor
156
+ */
157
+
158
+
159
+ class MaterialCreator {
160
+
161
+ constructor(baseUrl = '', options = {}) {
162
+
163
+ this.baseUrl = baseUrl;
164
+ this.options = options;
165
+ this.materialsInfo = {};
166
+ this.materials = {};
167
+ this.materialsArray = [];
168
+ this.nameLookup = {};
169
+ this.crossOrigin = 'anonymous';
170
+ this.side = this.options.side !== undefined ? this.options.side : THREE.FrontSide;
171
+ this.wrap = this.options.wrap !== undefined ? this.options.wrap : THREE.RepeatWrapping;
172
+
173
+ }
174
+
175
+ setCrossOrigin(value) {
176
+
177
+ this.crossOrigin = value;
178
+ return this;
179
+
180
+ }
181
+
182
+ setManager(value) {
183
+
184
+ this.manager = value;
185
+
186
+ }
187
+
188
+ setMaterials(materialsInfo) {
189
+
190
+ this.materialsInfo = this.convert(materialsInfo);
191
+ this.materials = {};
192
+ this.materialsArray = [];
193
+ this.nameLookup = {};
194
+
195
+ }
196
+
197
+ convert(materialsInfo) {
198
+
199
+ if (!this.options) return materialsInfo;
200
+ const converted = {};
201
+
202
+ for (const mn in materialsInfo) {
203
+
204
+ // Convert materials info into normalized form based on options
205
+ const mat = materialsInfo[mn];
206
+ const covmat = {};
207
+ converted[mn] = covmat;
208
+
209
+ for (const prop in mat) {
210
+
211
+ let save = true;
212
+ let value = mat[prop];
213
+ const lprop = prop.toLowerCase();
214
+
215
+ switch (lprop) {
216
+
217
+ case 'kd':
218
+ case 'ka':
219
+ case 'ks':
220
+ // Diffuse color (color under white light) using RGB values
221
+ if (this.options && this.options.normalizeRGB) {
222
+
223
+ value = [value[0] / 255, value[1] / 255, value[2] / 255];
224
+
225
+ }
226
+
227
+ if (this.options && this.options.ignoreZeroRGBs) {
228
+
229
+ if (value[0] === 0 && value[1] === 0 && value[2] === 0) {
230
+
231
+ // ignore
232
+ save = false;
233
+
234
+ }
235
+
236
+ }
237
+
238
+ break;
239
+
240
+ default:
241
+ break;
242
+
243
+ }
244
+
245
+ if (save) {
246
+
247
+ covmat[lprop] = value;
248
+
249
+ }
250
+
251
+ }
252
+
253
+ }
254
+
255
+ return converted;
256
+
257
+ }
258
+
259
+ preload() {
260
+
261
+ for (const mn in this.materialsInfo) {
262
+
263
+ this.create(mn);
264
+
265
+ }
266
+
267
+ }
268
+
269
+ getIndex(materialName) {
270
+
271
+ return this.nameLookup[materialName];
272
+
273
+ }
274
+
275
+ getAsArray() {
276
+
277
+ let index = 0;
278
+
279
+ for (const mn in this.materialsInfo) {
280
+
281
+ this.materialsArray[index] = this.create(mn);
282
+ this.nameLookup[mn] = index;
283
+ index++;
284
+
285
+ }
286
+
287
+ return this.materialsArray;
288
+
289
+ }
290
+
291
+ create(materialName) {
292
+
293
+ if (this.materials[materialName] === undefined) {
294
+
295
+ this.createMaterial_(materialName);
296
+
297
+ }
298
+
299
+ return this.materials[materialName];
300
+
301
+ }
302
+
303
+ createMaterial_(materialName) {
304
+
305
+ // Create material
306
+ const scope = this;
307
+ const mat = this.materialsInfo[materialName];
308
+ const params = {
309
+ name: materialName,
310
+ side: this.side
311
+ };
312
+
313
+ function resolveURL(baseUrl, url) {
314
+
315
+ if (typeof url !== 'string' || url === '') return ''; // Absolute URL
316
+
317
+ if (/^https?:\/\//i.test(url)) return url;
318
+ return baseUrl + url;
319
+
320
+ }
321
+
322
+ function setMapForType(mapType, value) {
323
+
324
+ if (params[mapType]) return; // Keep the first encountered texture
325
+
326
+ const texParams = scope.getTextureParams(value, params);
327
+ const map = scope.loadTexture(resolveURL(scope.baseUrl, texParams.url));
328
+ map.repeat.copy(texParams.scale);
329
+ map.offset.copy(texParams.offset);
330
+ map.wrapS = scope.wrap;
331
+ map.wrapT = scope.wrap;
332
+ params[mapType] = map;
333
+
334
+ }
335
+
336
+ for (const prop in mat) {
337
+
338
+ const value = mat[prop];
339
+ let n;
340
+ if (value === '') continue;
341
+
342
+ switch (prop.toLowerCase()) {
343
+
344
+ // Ns is material specular exponent
345
+ case 'kd':
346
+ // Diffuse color (color under white light) using RGB values
347
+ params.color = new THREE.Color().fromArray(value);
348
+ break;
349
+
350
+ case 'ks':
351
+ // Specular color (color when light is reflected from shiny surface) using RGB values
352
+ params.specular = new THREE.Color().fromArray(value);
353
+ break;
354
+
355
+ case 'ke':
356
+ // Emissive using RGB values
357
+ params.emissive = new THREE.Color().fromArray(value);
358
+ break;
359
+
360
+ case 'map_kd':
361
+ // Diffuse texture map
362
+ setMapForType('map', value);
363
+ break;
364
+
365
+ case 'map_ks':
366
+ // Specular map
367
+ setMapForType('specularMap', value);
368
+ break;
369
+
370
+ case 'map_ke':
371
+ // Emissive map
372
+ setMapForType('emissiveMap', value);
373
+ break;
374
+
375
+ case 'norm':
376
+ setMapForType('normalMap', value);
377
+ break;
378
+
379
+ case 'map_bump':
380
+ case 'bump':
381
+ // Bump texture map
382
+ setMapForType('bumpMap', value);
383
+ break;
384
+
385
+ case 'map_d':
386
+ // Alpha map
387
+ setMapForType('alphaMap', value);
388
+ params.transparent = true;
389
+ break;
390
+
391
+ case 'ns':
392
+ // The specular exponent (defines the focus of the specular highlight)
393
+ // A high exponent results in a tight, concentrated highlight. Ns values normally range from 0 to 1000.
394
+ params.shininess = parseFloat(value);
395
+ break;
396
+
397
+ case 'd':
398
+ n = parseFloat(value);
399
+
400
+ if (n < 1) {
401
+
402
+ params.opacity = n;
403
+ params.transparent = true;
404
+
405
+ }
406
+
407
+ break;
408
+
409
+ case 'tr':
410
+ n = parseFloat(value);
411
+ if (this.options && this.options.invertTrProperty) n = 1 - n;
412
+
413
+ if (n > 0) {
414
+
415
+ params.opacity = 1 - n;
416
+ params.transparent = true;
417
+
418
+ }
419
+
420
+ break;
421
+
422
+ default:
423
+ break;
424
+
425
+ }
426
+
427
+ }
428
+
429
+ this.materials[materialName] = new THREE.MeshPhongMaterial(params);
430
+ return this.materials[materialName];
431
+
432
+ }
433
+
434
+ getTextureParams(value, matParams) {
435
+
436
+ const texParams = {
437
+ scale: new THREE.Vector2(1, 1),
438
+ offset: new THREE.Vector2(0, 0)
439
+ };
440
+ const items = value.split(/\s+/);
441
+ let pos;
442
+ pos = items.indexOf('-bm');
443
+
444
+ if (pos >= 0) {
445
+
446
+ matParams.bumpScale = parseFloat(items[pos + 1]);
447
+ items.splice(pos, 2);
448
+
449
+ }
450
+
451
+ pos = items.indexOf('-s');
452
+
453
+ if (pos >= 0) {
454
+
455
+ texParams.scale.set(parseFloat(items[pos + 1]), parseFloat(items[pos + 2]));
456
+ items.splice(pos, 4); // we expect 3 parameters here!
457
+
458
+ }
459
+
460
+ pos = items.indexOf('-o');
461
+
462
+ if (pos >= 0) {
463
+
464
+ texParams.offset.set(parseFloat(items[pos + 1]), parseFloat(items[pos + 2]));
465
+ items.splice(pos, 4); // we expect 3 parameters here!
466
+
467
+ }
468
+
469
+ texParams.url = items.join(' ').trim();
470
+ return texParams;
471
+
472
+ }
473
+
474
+ loadTexture(url, mapping, onLoad, onProgress, onError) {
475
+
476
+ const manager = this.manager !== undefined ? this.manager : THREE.DefaultLoadingManager;
477
+ let loader = manager.getHandler(url);
478
+
479
+ if (loader === null) {
480
+
481
+ loader = new THREE.TextureLoader(manager);
482
+
483
+ }
484
+
485
+ if (loader.setCrossOrigin) loader.setCrossOrigin(this.crossOrigin);
486
+ const texture = loader.load(url, onLoad, onProgress, onError);
487
+ if (mapping !== undefined) texture.mapping = mapping;
488
+ return texture;
489
+
490
+ }
491
+
492
+ }
493
+ let OBJTHREE = Object.assign({},THREE)
494
+ OBJTHREE.MTLLoader = MTLLoader;
495
+
496
+ // })();
497
+ export default OBJTHREE.MTLLoader
498
+ // module.exports = exports = THREE.MTLLoader;