@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.4
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/lib/cjs/index.js +9 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +40 -41
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +170 -196
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +861 -1170
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +166 -159
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +523 -610
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +149 -154
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
- package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
- package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +809 -1033
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +363 -491
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +127 -0
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
- package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
- package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/cjs/react/hooks/useFocus/index.js +48 -55
- package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +40 -47
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
- package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
- package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
- package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/cjs/react/hooks/useRouting/index.js +21 -20
- package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
- package/lib/cjs/react/hooks/useSearch/index.js +35 -34
- package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +26 -23
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/index.js +31 -31
- package/lib/cjs/react/index.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +47 -62
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
- package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
- package/lib/esm/index.js +3 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +4 -3
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +14 -12
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +204 -200
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +6 -6
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +53 -42
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +18 -16
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +73 -79
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +16 -15
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +148 -124
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +120 -0
- package/lib/esm/react/MetaAtlasMap.js.map +1 -0
- package/lib/esm/react/hooks/useDrawing/index.js +2 -2
- package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/esm/react/hooks/useFocus/index.js +4 -3
- package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
- package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/esm/react/hooks/useRouting/index.js +2 -2
- package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
- package/lib/esm/react/hooks/useSearch/index.js +2 -2
- package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +15 -12
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/esm/react/index.js +11 -15
- package/lib/esm/react/index.js.map +1 -1
- package/lib/esm/react/stores/useMapDataStore.js +17 -21
- package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
- package/package.json +10 -7
package/lib/cjs/index.js
CHANGED
|
@@ -8,32 +8,32 @@ var _exportNames = {
|
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "ManeuverType", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function
|
|
11
|
+
get: function () {
|
|
12
12
|
return _routingHelpers.ManeuverType;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
var _metaAtlasSdk = require("./meta-atlas-sdk/meta-atlas-sdk");
|
|
15
|
+
var _metaAtlasSdk = require("./meta-atlas-sdk/meta-atlas-sdk.js");
|
|
16
16
|
Object.keys(_metaAtlasSdk).forEach(function (key) {
|
|
17
17
|
if (key === "default" || key === "__esModule") return;
|
|
18
18
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
19
|
if (key in exports && exports[key] === _metaAtlasSdk[key]) return;
|
|
20
20
|
Object.defineProperty(exports, key, {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function
|
|
22
|
+
get: function () {
|
|
23
23
|
return _metaAtlasSdk[key];
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
var _routingHelpers = require("./meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers");
|
|
28
|
-
var
|
|
29
|
-
Object.keys(
|
|
27
|
+
var _routingHelpers = require("./meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js");
|
|
28
|
+
var _index = require("./react/index.js");
|
|
29
|
+
Object.keys(_index).forEach(function (key) {
|
|
30
30
|
if (key === "default" || key === "__esModule") return;
|
|
31
31
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
-
if (key in exports && exports[key] ===
|
|
32
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
33
33
|
Object.defineProperty(exports, key, {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function
|
|
36
|
-
return
|
|
35
|
+
get: function () {
|
|
36
|
+
return _index[key];
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
});
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `js` appendix has been added as the typesciript compilation does add it\n * when transpilling to JavaScript\n *\n * See https://stackoverflow.com/questions/44979976/typescript-compiler-is-forgetting-to-add-file-extensions-to-es6-module-imports\n * and https://github.com/microsoft/TypeScript/issues/40878\n *\n * Rollup\n * https://www.mixmax.com/engineering/rollup-externals\n * https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module\n */\n\n// Vanilla exports (existing)\nexport * from './meta-atlas-sdk/meta-atlas-sdk';\n\n// Core types that need to be re-exported\nexport type { metaFeature, clickedMetaFeature, MetaFeatureProperties } from './meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\n\n// Routing types\nexport { ManeuverType } from './meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers';\nexport type { Route, RouteSegment } from './meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers';\n\n// React exports (new)\nexport * from './react';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -3,29 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _three = require("three");
|
|
8
8
|
var _constants = _interopRequireDefault(require("./utility/constants.js"));
|
|
9
9
|
var _CameraSync = _interopRequireDefault(require("./utility/CameraSync.js"));
|
|
10
10
|
var _utils = require("./utility/utils.js");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
15
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
16
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
17
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
19
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
20
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
|
-
var CustomThreeJSWrapper = /*#__PURE__*/function () {
|
|
23
|
-
function CustomThreeJSWrapper(map) {
|
|
24
|
-
_classCallCheck(this, CustomThreeJSWrapper);
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
class CustomThreeJSWrapper {
|
|
13
|
+
constructor(map) {
|
|
25
14
|
this.scene = new _three.Scene();
|
|
26
15
|
this.map = map;
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
const c = map === null || map === void 0 ? void 0 : map.getCanvas();
|
|
17
|
+
const gl = (c === null || c === void 0 ? void 0 : c.getContext('webgl')) || (c === null || c === void 0 ? void 0 : c.getContext('webgl2'));
|
|
29
18
|
if (!gl && !this.isWebglSupported()) {
|
|
30
19
|
console.error(map.getCanvas(), 'WebGL 2 is not supported in this environment');
|
|
31
20
|
return;
|
|
@@ -44,310 +33,240 @@ var CustomThreeJSWrapper = /*#__PURE__*/function () {
|
|
|
44
33
|
this.renderer.autoClear = false;
|
|
45
34
|
this.renderer.toneMapping = _three.ACESFilmicToneMapping;
|
|
46
35
|
this.renderer.outputColorSpace = _three.SRGBColorSpace;
|
|
47
|
-
this.fov = _constants
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
this.fov = _constants.default.FOV_DEGREES;
|
|
37
|
+
const h = this.map.getCanvas().clientHeight;
|
|
38
|
+
const w = this.map.getCanvas().clientWidth;
|
|
50
39
|
this.camera = new _three.PerspectiveCamera(this.fov, w / h, 0.1, 1000);
|
|
51
|
-
this.cameraSync = new _CameraSync
|
|
40
|
+
this.cameraSync = new _CameraSync.default(map, this.camera, this.scene);
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// for more details.
|
|
72
|
-
var context = canvas.getContext('webgl2') || canvas.getContext('webgl');
|
|
73
|
-
if (context && typeof context.getParameter == 'function') {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
} catch (e) {
|
|
77
|
-
// WebGL is supported, but disabled
|
|
42
|
+
resize() {
|
|
43
|
+
const w = this.map.getCanvas().clientWidth;
|
|
44
|
+
const h = this.map.getCanvas().clientHeight;
|
|
45
|
+
this.camera.aspect = w / h;
|
|
46
|
+
this.camera.updateProjectionMatrix();
|
|
47
|
+
this.renderer.setSize(w, h);
|
|
48
|
+
}
|
|
49
|
+
isWebglSupported() {
|
|
50
|
+
if (window.WebGLRenderingContext) {
|
|
51
|
+
const canvas = document.createElement('canvas');
|
|
52
|
+
try {
|
|
53
|
+
// Note that { failIfMajorPerformanceCaveat: true } can be passed as a second argument
|
|
54
|
+
// to canvas.getContext(), causing the check to fail if hardware rendering is not available. See
|
|
55
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
|
|
56
|
+
// for more details.
|
|
57
|
+
const context = canvas.getContext('webgl2') || canvas.getContext('webgl');
|
|
58
|
+
if (context && typeof context.getParameter == 'function') {
|
|
59
|
+
return true;
|
|
78
60
|
}
|
|
79
|
-
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// WebGL is supported, but disabled
|
|
80
63
|
}
|
|
81
|
-
// WebGL not supported
|
|
82
64
|
return false;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
objects.push(object);
|
|
104
|
-
});
|
|
105
|
-
for (var i = 0; i < objects.length; i++) {
|
|
106
|
-
var obj = objects[i];
|
|
107
|
-
//if layerId, check the layer to remove, otherwise always remove
|
|
108
|
-
if (obj.layers === layerId || !layerId) {
|
|
109
|
-
_this.remove(obj);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
resolve('clear');
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
}, _callee);
|
|
116
|
-
}));
|
|
117
|
-
function clear() {
|
|
118
|
-
return _clear.apply(this, arguments);
|
|
66
|
+
// WebGL not supported
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
repaint() {
|
|
70
|
+
this.map.repaint = true;
|
|
71
|
+
}
|
|
72
|
+
async clear() {
|
|
73
|
+
let layerId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const objects = [];
|
|
76
|
+
this.scene.children.forEach(function (object) {
|
|
77
|
+
objects.push(object);
|
|
78
|
+
});
|
|
79
|
+
for (let i = 0; i < objects.length; i++) {
|
|
80
|
+
const obj = objects[i];
|
|
81
|
+
//if layerId, check the layer to remove, otherwise always remove
|
|
82
|
+
if (obj.layers === layerId || !layerId) {
|
|
83
|
+
this.remove(obj);
|
|
84
|
+
}
|
|
119
85
|
}
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
_this2.scene.children.forEach(function (object) {
|
|
133
|
-
if (object.type === 'Mesh') objects.push(object);
|
|
134
|
-
});
|
|
135
|
-
console.log('Mesh Objects:', objects);
|
|
136
|
-
for (var i = 0; i < objects.length; i++) {
|
|
137
|
-
_this2.remove(objects[i]);
|
|
138
|
-
}
|
|
139
|
-
resolve('clear');
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
|
-
}, _callee2);
|
|
143
|
-
}));
|
|
144
|
-
function clearMeshes() {
|
|
145
|
-
return _clearMeshes.apply(this, arguments);
|
|
86
|
+
resolve('clear');
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async clearMeshes() {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
const objects = [];
|
|
92
|
+
this.scene.children.forEach(function (object) {
|
|
93
|
+
if (object.type === 'Mesh') objects.push(object);
|
|
94
|
+
});
|
|
95
|
+
console.log('Mesh Objects:', objects);
|
|
96
|
+
for (let i = 0; i < objects.length; i++) {
|
|
97
|
+
this.remove(objects[i]);
|
|
146
98
|
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (object.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
object.visible = true;
|
|
164
|
-
}
|
|
99
|
+
resolve('clear');
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
filter3DObjects(whatTaxonomies) {
|
|
103
|
+
if (!Array.isArray(whatTaxonomies)) return;
|
|
104
|
+
if (whatTaxonomies.length === 0) {
|
|
105
|
+
this.scene.children.forEach(function (object) {
|
|
106
|
+
object.visible = true;
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
this.scene.children.forEach(function (object) {
|
|
110
|
+
if (object.type === 'Mesh') {
|
|
111
|
+
if (whatTaxonomies.includes(object.userData.whatDimension)) {
|
|
112
|
+
object.visible = false;
|
|
113
|
+
} else {
|
|
114
|
+
object.visible = true;
|
|
165
115
|
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "add",
|
|
171
|
-
value: function add(object) {
|
|
172
|
-
this.scene.add(object);
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "setEnvironment",
|
|
176
|
-
value: function setEnvironment() {
|
|
177
|
-
var dirLight = new _three.DirectionalLight(0xffffff, 2);
|
|
178
|
-
dirLight.position.set(10, 10, 10);
|
|
179
|
-
dirLight.castShadow = true;
|
|
180
|
-
var hemiLight = new _three.HemisphereLight('white', 'white', 1.5);
|
|
181
|
-
var ambientLight = new _three.AmbientLight('white', 1);
|
|
182
|
-
this.scene.add(dirLight);
|
|
183
|
-
this.scene.add(hemiLight);
|
|
184
|
-
this.scene.add(ambientLight);
|
|
185
|
-
}
|
|
186
|
-
}, {
|
|
187
|
-
key: "buildPoints",
|
|
188
|
-
value: function buildPoints(coords, initCoords) {
|
|
189
|
-
var points = [];
|
|
190
|
-
var init = (0, _utils.projectToWorld)([initCoords[0][0], initCoords[0][1], 0]);
|
|
191
|
-
for (var i = 0; i < coords.length; i++) {
|
|
192
|
-
var pos = (0, _utils.projectToWorld)([coords[i][0], coords[i][1], 0]);
|
|
193
|
-
points.push(new _three.Vector2((0, _utils.toDecimal)(pos.x - init.x, 9), (0, _utils.toDecimal)(pos.y - init.y, 9)));
|
|
194
|
-
}
|
|
195
|
-
return points;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
196
118
|
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
119
|
+
}
|
|
120
|
+
add(object) {
|
|
121
|
+
this.scene.add(object);
|
|
122
|
+
}
|
|
123
|
+
setEnvironment() {
|
|
124
|
+
const dirLight = new _three.DirectionalLight(0xffffff, 2);
|
|
125
|
+
dirLight.position.set(10, 10, 10);
|
|
126
|
+
dirLight.castShadow = true;
|
|
127
|
+
const hemiLight = new _three.HemisphereLight('white', 'white', 1.5);
|
|
128
|
+
const ambientLight = new _three.AmbientLight('white', 1);
|
|
129
|
+
this.scene.add(dirLight);
|
|
130
|
+
this.scene.add(hemiLight);
|
|
131
|
+
this.scene.add(ambientLight);
|
|
132
|
+
}
|
|
133
|
+
buildPoints(coords, initCoords) {
|
|
134
|
+
const points = [];
|
|
135
|
+
const init = (0, _utils.projectToWorld)([initCoords[0][0], initCoords[0][1], 0]);
|
|
136
|
+
for (let i = 0; i < coords.length; i++) {
|
|
137
|
+
const pos = (0, _utils.projectToWorld)([coords[i][0], coords[i][1], 0]);
|
|
138
|
+
points.push(new _three.Vector2((0, _utils.toDecimal)(pos.x - init.x, 9), (0, _utils.toDecimal)(pos.y - init.y, 9)));
|
|
203
139
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
140
|
+
return points;
|
|
141
|
+
}
|
|
142
|
+
buildGeometry(shape, settings) {
|
|
143
|
+
const geometry = new _three.ExtrudeGeometry(shape, settings);
|
|
144
|
+
geometry.computeBoundingBox();
|
|
145
|
+
return geometry;
|
|
146
|
+
}
|
|
147
|
+
buildShape(coords) {
|
|
148
|
+
if (coords[0] instanceof (_three.Vector2 || _three.Vector3)) return new _three.Shape(coords);
|
|
149
|
+
let shape = new _three.Shape();
|
|
150
|
+
for (let i = 0; i < coords.length; i++) {
|
|
151
|
+
if (i === 0) {
|
|
152
|
+
shape = new _three.Shape(this.buildPoints(coords[0], coords[0]));
|
|
153
|
+
} else {
|
|
154
|
+
shape.holes.push(new _three.Path(this.buildPoints(coords[i], coords[0])));
|
|
215
155
|
}
|
|
216
|
-
return shape;
|
|
217
156
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
mesh.geometry.computeBoundingBox();
|
|
233
|
-
bbox.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);
|
|
157
|
+
return shape;
|
|
158
|
+
}
|
|
159
|
+
extrusion(opt) {
|
|
160
|
+
const shape = this.buildShape(opt.coordinates);
|
|
161
|
+
const geometry = this.buildGeometry(shape, opt.geometryOptions);
|
|
162
|
+
const mesh = new _three.Mesh(geometry, opt.materials);
|
|
163
|
+
if (!opt.visible) mesh.visible = false;
|
|
164
|
+
return mesh;
|
|
165
|
+
}
|
|
166
|
+
centerMesh(mesh) {
|
|
167
|
+
// Compute the bounding box
|
|
168
|
+
const bbox = new _three.Box3();
|
|
169
|
+
mesh.geometry.computeBoundingBox();
|
|
170
|
+
bbox.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);
|
|
234
171
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
172
|
+
// Get the center of the bounding box
|
|
173
|
+
let center = new _three.Vector3();
|
|
174
|
+
bbox.getCenter(center);
|
|
238
175
|
|
|
239
|
-
|
|
240
|
-
|
|
176
|
+
// Create a dummy object
|
|
177
|
+
const dummy = new _three.Object3D();
|
|
241
178
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
target.material.dispose();
|
|
264
|
-
target.material._isDisposed = true;
|
|
265
|
-
}
|
|
266
|
-
target.material = null;
|
|
179
|
+
// Attach mesh to dummy
|
|
180
|
+
dummy.add(mesh);
|
|
181
|
+
center = mesh.localToWorld(center);
|
|
182
|
+
// const geometry = new BoxGeometry( 0.25, 0.25, 0.25 );
|
|
183
|
+
// const material = new MeshBasicMaterial( {color: 0xff0000} );
|
|
184
|
+
// const cube = new Mesh( geometry, material );
|
|
185
|
+
// cube.position.set(center.x, center.y, center.z);
|
|
186
|
+
// this.add( cube );
|
|
187
|
+
// // Move the mesh within the dummy
|
|
188
|
+
const diff = mesh.position.clone().sub(center);
|
|
189
|
+
mesh.geometry.translate(diff.x, diff.y, 0);
|
|
190
|
+
return dummy; // Return the new parent object
|
|
191
|
+
}
|
|
192
|
+
dispose(target) {
|
|
193
|
+
if (target instanceof _three.Mesh) {
|
|
194
|
+
// If the target is a Mesh
|
|
195
|
+
// Dispose materials and geometry of the mesh
|
|
196
|
+
if (target.material) {
|
|
197
|
+
if (typeof target.material.dispose === 'function' && !target.material._isDisposed) {
|
|
198
|
+
target.material.dispose();
|
|
199
|
+
target.material._isDisposed = true;
|
|
267
200
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
target.geometry =
|
|
201
|
+
target.material = null;
|
|
202
|
+
}
|
|
203
|
+
if (target.geometry) {
|
|
204
|
+
if (typeof target.geometry.dispose === 'function' && !target.geometry._isDisposed) {
|
|
205
|
+
target.geometry.dispose();
|
|
206
|
+
target.geometry._isDisposed = true;
|
|
274
207
|
}
|
|
275
|
-
|
|
276
|
-
// If the target is an Object3D
|
|
277
|
-
target.removeFromParent();
|
|
278
|
-
this.disposeObject(target);
|
|
208
|
+
target.geometry = null;
|
|
279
209
|
}
|
|
210
|
+
} else if (target instanceof _three.Object3D) {
|
|
211
|
+
// If the target is an Object3D
|
|
212
|
+
target.removeFromParent();
|
|
213
|
+
this.disposeObject(target);
|
|
280
214
|
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
} else {
|
|
292
|
-
_this3.disposeMaterial(child.material);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
if (child instanceof _three.Mesh && child.geometry) {
|
|
296
|
-
_this3.disposeGeometry(child.geometry);
|
|
297
|
-
}
|
|
298
|
-
if (child instanceof _three.Mesh && child.material && child.material.map) {
|
|
299
|
-
_this3.disposeTexture(child.material.map);
|
|
215
|
+
}
|
|
216
|
+
disposeObject(object) {
|
|
217
|
+
object.traverse(child => {
|
|
218
|
+
if (child instanceof _three.Mesh && child.material) {
|
|
219
|
+
if (Array.isArray(child.material)) {
|
|
220
|
+
child.material.forEach(material => {
|
|
221
|
+
this.disposeMaterial(material);
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
this.disposeMaterial(child.material);
|
|
300
225
|
}
|
|
301
|
-
requestAnimationFrame(function () {
|
|
302
|
-
return child.children.length = 0;
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
if (object.parent) {
|
|
306
|
-
object.parent.remove(object);
|
|
307
226
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
key: "disposeMaterial",
|
|
311
|
-
value: function disposeMaterial(material) {
|
|
312
|
-
if (material.dispose) {
|
|
313
|
-
material.dispose();
|
|
227
|
+
if (child instanceof _three.Mesh && child.geometry) {
|
|
228
|
+
this.disposeGeometry(child.geometry);
|
|
314
229
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
// to dispose of a texture
|
|
318
|
-
}, {
|
|
319
|
-
key: "disposeTexture",
|
|
320
|
-
value: function disposeTexture(texture) {
|
|
321
|
-
if (texture.dispose) {
|
|
322
|
-
texture.dispose();
|
|
230
|
+
if (child instanceof _three.Mesh && child.material && child.material.map) {
|
|
231
|
+
this.disposeTexture(child.material.map);
|
|
323
232
|
}
|
|
233
|
+
requestAnimationFrame(() => child.children.length = 0);
|
|
234
|
+
});
|
|
235
|
+
if (object.parent) {
|
|
236
|
+
object.parent.remove(object);
|
|
324
237
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
value: function disposeGeometry(geometry) {
|
|
330
|
-
if (geometry.dispose) {
|
|
331
|
-
geometry.dispose();
|
|
332
|
-
}
|
|
238
|
+
}
|
|
239
|
+
disposeMaterial(material) {
|
|
240
|
+
if (material.dispose) {
|
|
241
|
+
material.dispose();
|
|
333
242
|
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// to dispose of a texture
|
|
246
|
+
disposeTexture(texture) {
|
|
247
|
+
if (texture.dispose) {
|
|
248
|
+
texture.dispose();
|
|
339
249
|
}
|
|
340
|
-
}
|
|
341
|
-
key: "update",
|
|
342
|
-
value: function update() {
|
|
343
|
-
if (this.map.repaint) this.map.repaint = false;
|
|
344
|
-
this.scene.updateMatrixWorld(true);
|
|
250
|
+
}
|
|
345
251
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
252
|
+
// to dispose of a geometry
|
|
253
|
+
disposeGeometry(geometry) {
|
|
254
|
+
if (geometry.dispose) {
|
|
255
|
+
geometry.dispose();
|
|
349
256
|
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
257
|
+
}
|
|
258
|
+
remove(object) {
|
|
259
|
+
this.scene.remove(object);
|
|
260
|
+
object = null;
|
|
261
|
+
}
|
|
262
|
+
update() {
|
|
263
|
+
if (this.map.repaint) this.map.repaint = false;
|
|
264
|
+
this.scene.updateMatrixWorld(true);
|
|
265
|
+
|
|
266
|
+
// Render the scene and repaint the map
|
|
267
|
+
this.renderer.resetState(); //update threejs r126
|
|
268
|
+
this.renderer.render(this.scene, this.camera);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
var _default = exports.default = CustomThreeJSWrapper;
|
|
353
272
|
//# sourceMappingURL=CustomThreeJsWrapper.js.map
|