@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,142 @@
1
+ /**
2
+ * @author peterqliu / https://github.com/peterqliu
3
+ * @author jscastro / https://github.com/jscastro76
4
+ */
5
+ import utils from '../utils/utils.js';
6
+ import Objects from './objects.js';
7
+ import OBJLoader from './loaders/OBJLoader.js';
8
+ import MTLLoader from './loaders/MTLLoader.js';
9
+ import FBXLoader from './loaders/FBXLoader.js';
10
+ import GLTFLoader from './loaders/GLTFLoader.js';
11
+ import ColladaLoader from './loaders/ColladaLoader.js';
12
+ // const utils = require("../utils/utils.js");
13
+ // const Objects = require('./objects.js');
14
+ // const OBJLoader = require("./loaders/OBJLoader.js");
15
+ // const MTLLoader = require("./loaders/MTLLoader.js");
16
+ // const FBXLoader = require("./loaders/FBXLoader.js");
17
+ // const GLTFLoader = require("./loaders/GLTFLoader.js");
18
+ // const ColladaLoader = require("./loaders/ColladaLoader.js");
19
+ const objLoader = new OBJLoader();
20
+ const materialLoader = new MTLLoader();
21
+ const gltfLoader = new GLTFLoader();
22
+ const fbxLoader = new FBXLoader();
23
+ const daeLoader = new ColladaLoader();
24
+
25
+ function loadObj(options, cb, promise) {
26
+
27
+ if (options === undefined) return console.error("Invalid options provided to loadObj()");
28
+ options = utils._validate(options, Objects.prototype._defaults.loadObj);
29
+
30
+ let loader;
31
+ if (!options.type) { options.type = 'mtl'; };
32
+ //[jscastro] support other models
33
+ switch (options.type) {
34
+ case "mtl":
35
+ // TODO: Support formats other than OBJ/MTL
36
+ loader = objLoader;
37
+ break;
38
+ case "gltf":
39
+ case "glb":
40
+ // [jscastro] Support for GLTF/GLB
41
+ loader = gltfLoader;
42
+ break;
43
+ case "fbx":
44
+ loader = fbxLoader;
45
+ break;
46
+ case "dae":
47
+ loader = daeLoader;
48
+ break;
49
+ }
50
+
51
+ materialLoader.load(options.mtl, loadObject, () => (null), error => {
52
+ console.warn("No material file found " + error.stack);
53
+ });
54
+
55
+ function loadObject(materials) {
56
+
57
+ if (materials && options.type == "mtl") {
58
+ materials.preload();
59
+ loader.setMaterials(materials);
60
+ }
61
+
62
+ loader.load(options.obj, obj => {
63
+
64
+ //[jscastro] MTL/GLTF/FBX models have a different structure
65
+ let animations = [];
66
+ switch (options.type) {
67
+ case "mtl":
68
+ obj = obj.children[0];
69
+ break;
70
+ case "gltf":
71
+ case "glb":
72
+ case "dae":
73
+ animations = obj.animations;
74
+ obj = obj.scene;
75
+ break;
76
+ case "fbx":
77
+ animations = obj.animations;
78
+ break;
79
+ }
80
+ obj.animations = animations;
81
+ // [jscastro] options.rotation was wrongly used
82
+ const r = utils.types.rotation(options.rotation, [0, 0, 0]);
83
+ const s = utils.types.scale(options.scale, [1, 1, 1]);
84
+ obj.rotation.set(r[0], r[1], r[2]);
85
+ obj.scale.set(s[0], s[1], s[2]);
86
+ // [jscastro] normalize specular/metalness/shininess from meshes in FBX and GLB model as it would need 5 lights to illuminate them properly
87
+ if (options.normalize) { normalizeSpecular(obj); }
88
+ obj.name = "model";
89
+ let userScaleGroup = Objects.prototype._makeGroup(obj, options);
90
+ Objects.prototype._addMethods(userScaleGroup);
91
+ //[jscastro] calculate automatically the pivotal center of the object
92
+ userScaleGroup.setAnchor(options.anchor);
93
+ //[jscastro] override the center calculated if the object has adjustments
94
+ userScaleGroup.setCenter(options.adjustment);
95
+ //[jscastro] if the object is excluded from raycasting
96
+ userScaleGroup.raycasted = options.raycasted;
97
+ //[jscastro] return to cache
98
+ promise(userScaleGroup);
99
+ //[jscastro] then return to the client-side callback
100
+ cb(userScaleGroup);
101
+ //[jscastro] apply the fixed zoom scale if needed
102
+ userScaleGroup.setFixedZoom(options.mapScale);
103
+ //[jscastro] initialize the default animation to avoid issues with skeleton position
104
+ userScaleGroup.idle();
105
+
106
+ }, () => (null), error => {
107
+ console.error("Could not load model file: " + options.obj + " \n " + error.stack);
108
+ promise("Error loading the model");
109
+ });
110
+
111
+ };
112
+
113
+ //[jscastro] some FBX/GLTF models have too much specular effects for mapbox
114
+ function normalizeSpecular(model) {
115
+ model.traverse(function (c) {
116
+
117
+ if (c.isMesh) {
118
+ //c.castShadow = true;
119
+ let specularColor;
120
+ if (c.material.type == 'MeshStandardMaterial') {
121
+
122
+ if (c.material.metalness) { c.material.metalness *= 0.1; }
123
+ if (c.material.glossiness) { c.material.glossiness *= 0.25; }
124
+ specularColor = new THREE.Color(12, 12, 12);
125
+
126
+ } else if (c.material.type == 'MeshPhongMaterial') {
127
+ c.material.shininess = 0.1;
128
+ specularColor = new THREE.Color(20, 20, 20);
129
+ }
130
+ if (c.material.specular && c.material.specular.isColor) {
131
+ c.material.specular = specularColor;
132
+ }
133
+ //c.material.needsUpdate = true;
134
+
135
+ }
136
+
137
+ });
138
+ }
139
+
140
+ }
141
+ export default loadObj
142
+ // module.exports = exports = loadObj;