@mapvx/web-js 1.8.0 → 2.0.0-dev.2
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/dist/cjs/config/draco.js +15 -0
- package/dist/cjs/config/draco.js.map +1 -0
- package/dist/cjs/domain/models/mapConfig.js.map +1 -1
- package/dist/cjs/domain/models/scene3D.js +3 -0
- package/dist/cjs/domain/models/scene3D.js.map +1 -0
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/infrastructure/logging/{CountlyLogger.js → MVXLogger.js} +15 -13
- package/dist/cjs/infrastructure/logging/MVXLogger.js.map +1 -0
- package/dist/cjs/logger/logger.js +30 -54
- package/dist/cjs/logger/logger.js.map +1 -1
- package/dist/cjs/logger/sentry.js +76 -0
- package/dist/cjs/logger/sentry.js.map +1 -0
- package/dist/cjs/map/map.js +40 -9
- package/dist/cjs/map/map.js.map +1 -1
- package/dist/cjs/map/scene3DController.js +448 -0
- package/dist/cjs/map/scene3DController.js.map +1 -0
- package/dist/cjs/utils/3d.js +133 -0
- package/dist/cjs/utils/3d.js.map +1 -0
- package/dist/cjs/utils/deckLayers.js +153 -0
- package/dist/cjs/utils/deckLayers.js.map +1 -0
- package/dist/cjs/utils/loadGlb.js +45 -0
- package/dist/cjs/utils/loadGlb.js.map +1 -0
- package/dist/cjs/utils/three.js +75 -0
- package/dist/cjs/utils/three.js.map +1 -0
- package/dist/cjs/utils/threeScene.js +45 -0
- package/dist/cjs/utils/threeScene.js.map +1 -0
- package/dist/es/config/draco.d.ts +12 -0
- package/dist/es/config/draco.d.ts.map +1 -0
- package/dist/es/config/draco.js +12 -0
- package/dist/es/config/draco.js.map +1 -0
- package/dist/es/domain/models/loggeable.d.ts +1 -1
- package/dist/es/domain/models/loggeable.d.ts.map +1 -1
- package/dist/es/domain/models/mapConfig.d.ts +23 -0
- package/dist/es/domain/models/mapConfig.d.ts.map +1 -1
- package/dist/es/domain/models/mapConfig.js.map +1 -1
- package/dist/es/domain/models/scene3D.d.ts +308 -0
- package/dist/es/domain/models/scene3D.d.ts.map +1 -0
- package/dist/es/domain/models/scene3D.js +2 -0
- package/dist/es/domain/models/scene3D.js.map +1 -0
- package/dist/es/domain/ports/ILogger.d.ts +2 -2
- package/dist/es/index.d.ts +2 -1
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/infrastructure/logging/{CountlyLogger.d.ts → MVXLogger.d.ts} +13 -11
- package/dist/es/infrastructure/logging/MVXLogger.d.ts.map +1 -0
- package/dist/es/infrastructure/logging/{CountlyLogger.js → MVXLogger.js} +13 -11
- package/dist/es/infrastructure/logging/MVXLogger.js.map +1 -0
- package/dist/es/logger/logger.d.ts +2 -3
- package/dist/es/logger/logger.d.ts.map +1 -1
- package/dist/es/logger/logger.js +30 -51
- package/dist/es/logger/logger.js.map +1 -1
- package/dist/es/logger/sentry.d.ts +26 -0
- package/dist/es/logger/sentry.d.ts.map +1 -0
- package/dist/es/logger/sentry.js +72 -0
- package/dist/es/logger/sentry.js.map +1 -0
- package/dist/es/map/map.d.ts +12 -0
- package/dist/es/map/map.d.ts.map +1 -1
- package/dist/es/map/map.js +40 -9
- package/dist/es/map/map.js.map +1 -1
- package/dist/es/map/scene3DController.d.ts +74 -0
- package/dist/es/map/scene3DController.d.ts.map +1 -0
- package/dist/es/map/scene3DController.js +444 -0
- package/dist/es/map/scene3DController.js.map +1 -0
- package/dist/es/utils/3d.d.ts +54 -0
- package/dist/es/utils/3d.d.ts.map +1 -0
- package/dist/es/utils/3d.js +120 -0
- package/dist/es/utils/3d.js.map +1 -0
- package/dist/es/utils/deckLayers.d.ts +51 -0
- package/dist/es/utils/deckLayers.d.ts.map +1 -0
- package/dist/es/utils/deckLayers.js +144 -0
- package/dist/es/utils/deckLayers.js.map +1 -0
- package/dist/es/utils/loadGlb.d.ts +11 -0
- package/dist/es/utils/loadGlb.d.ts.map +1 -0
- package/dist/es/utils/loadGlb.js +42 -0
- package/dist/es/utils/loadGlb.js.map +1 -0
- package/dist/es/utils/three.d.ts +51 -0
- package/dist/es/utils/three.d.ts.map +1 -0
- package/dist/es/utils/three.js +38 -0
- package/dist/es/utils/three.js.map +1 -0
- package/dist/es/utils/threeScene.d.ts +24 -0
- package/dist/es/utils/threeScene.d.ts.map +1 -0
- package/dist/es/utils/threeScene.js +41 -0
- package/dist/es/utils/threeScene.js.map +1 -0
- package/dist/umd/index.js +17882 -12615
- package/dist/umd/index.js.map +1 -1
- package/package.json +15 -5
- package/dist/cjs/infrastructure/logging/CountlyLogger.js.map +0 -1
- package/dist/cjs/logger/rollbar.js +0 -37
- package/dist/cjs/logger/rollbar.js.map +0 -1
- package/dist/es/infrastructure/logging/CountlyLogger.d.ts.map +0 -1
- package/dist/es/infrastructure/logging/CountlyLogger.js.map +0 -1
- package/dist/es/logger/rollbar.d.ts +0 -4
- package/dist/es/logger/rollbar.d.ts.map +0 -1
- package/dist/es/logger/rollbar.js +0 -33
- package/dist/es/logger/rollbar.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d.js","sourceRoot":"","sources":["../../../src/utils/3d.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkC;IACnE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;IAC1F,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE;IAC7F,EAAE,IAAI,EAAE,SAAS,EA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conData } from "../domain/models/scene3D";
|
|
3
|
+
/**
|
|
4
|
+
* Pure data builders for the deck.gl indoor overlay sublayers.
|
|
5
|
+
*
|
|
6
|
+
* These functions contain the feature-filtering and coordinate/height mapping logic used inside the
|
|
7
|
+
* deck.gl `renderSubLayers` callbacks in {@link InternalMapVXMap}. They are kept free of any deck.gl
|
|
8
|
+
* / WebGL imports so the logic is unit-testable without a GL context.
|
|
9
|
+
*
|
|
10
|
+
* @group Utils
|
|
11
|
+
*/
|
|
12
|
+
/** Extracts polygon coordinate rings from a GeoJSON geometry (Polygon or MultiPolygon). */
|
|
13
|
+
export declare function extractPolygonRings(geom: Feature["geometry"]): number[][][][];
|
|
14
|
+
export interface ElevatedPathDatum {
|
|
15
|
+
path: number[][];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds elevated room-outline paths from indoor "room" features on the given floor.
|
|
19
|
+
* Each ring is lifted to `z` (feature `height` when present, otherwise `defaultHeight`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildElevatedPaths(features: Feature[], floorKey: string, defaultHeight: number): ElevatedPathDatum[];
|
|
22
|
+
export interface LabelDatum {
|
|
23
|
+
position: number[];
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Builds indoor label text data from `area_name` / `poi` point features on the given floor.
|
|
28
|
+
* A feature is skipped when a matching `logo-{name}` sprite exists (icon takes priority over text).
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildLabelData(features: Feature[], floorKey: string, hasImage: (imageId: string) => boolean, defaultHeight: number): LabelDatum[];
|
|
31
|
+
/** Resolves the POI icon id from a feature's `tags` and `subclass`. */
|
|
32
|
+
export declare function resolvePoiIcon(tags: string, subclass: string): string;
|
|
33
|
+
export interface PoiIconDatum {
|
|
34
|
+
position: number[];
|
|
35
|
+
icon: string;
|
|
36
|
+
}
|
|
37
|
+
/** Builds POI icon data (elevators / toilets) from point features on the given floor. */
|
|
38
|
+
export declare function buildPoiIconData(features: Feature[], floorKey: string, defaultHeight: number): PoiIconDatum[];
|
|
39
|
+
export interface StoreLogoDatum {
|
|
40
|
+
position: number[];
|
|
41
|
+
icon: string;
|
|
42
|
+
rotation: number;
|
|
43
|
+
}
|
|
44
|
+
/** Builds store-logo icon data from point features that have a matching `logo-{name}` sprite. */
|
|
45
|
+
export declare function buildStoreLogoData(features: Feature[], floorKey: string, spriteMapping: Record<string, SpriteIconData>, defaultHeight: number): StoreLogoDatum[];
|
|
46
|
+
/**
|
|
47
|
+
* Computes the display size for a store-logo icon from its sprite dimensions and an optional
|
|
48
|
+
* per-logo scale factor. Returns a fallback of `10` when the icon is missing from the sprite atlas.
|
|
49
|
+
*/
|
|
50
|
+
export declare function computeStoreLogoSize(mapping: Record<string, SpriteIconData>, icon: string, logoScale: Record<string, number>): number;
|
|
51
|
+
//# sourceMappingURL=deckLayers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deckLayers.d.ts","sourceRoot":"","sources":["../../../src/utils/deckLayers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D;;;;;;;;GAQG;AAEH,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,CAQ7E;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CACjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,iBAAiB,EAAE,CAiBrB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,EACtC,aAAa,EAAE,MAAM,GACpB,UAAU,EAAE,CAkBd;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrE;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,yFAAyF;AACzF,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,YAAY,EAAE,CAehB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,iGAAiG;AACjG,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC7C,aAAa,EAAE,MAAM,GACpB,cAAc,EAAE,CAoBlB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACvC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAQR"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure data builders for the deck.gl indoor overlay sublayers.
|
|
3
|
+
*
|
|
4
|
+
* These functions contain the feature-filtering and coordinate/height mapping logic used inside the
|
|
5
|
+
* deck.gl `renderSubLayers` callbacks in {@link InternalMapVXMap}. They are kept free of any deck.gl
|
|
6
|
+
* / WebGL imports so the logic is unit-testable without a GL context.
|
|
7
|
+
*
|
|
8
|
+
* @group Utils
|
|
9
|
+
*/
|
|
10
|
+
/** Extracts polygon coordinate rings from a GeoJSON geometry (Polygon or MultiPolygon). */
|
|
11
|
+
export function extractPolygonRings(geom) {
|
|
12
|
+
if (geom.type === "Polygon") {
|
|
13
|
+
return [geom.coordinates];
|
|
14
|
+
}
|
|
15
|
+
if (geom.type === "MultiPolygon") {
|
|
16
|
+
return geom.coordinates;
|
|
17
|
+
}
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds elevated room-outline paths from indoor "room" features on the given floor.
|
|
22
|
+
* Each ring is lifted to `z` (feature `height` when present, otherwise `defaultHeight`).
|
|
23
|
+
*/
|
|
24
|
+
export function buildElevatedPaths(features, floorKey, defaultHeight) {
|
|
25
|
+
var _a;
|
|
26
|
+
const rooms = features.filter((f) => {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
return ((_a = f.properties) === null || _a === void 0 ? void 0 : _a.class) === "room" &&
|
|
29
|
+
((_b = f.properties) === null || _b === void 0 ? void 0 : _b.subclass) !== "empty" &&
|
|
30
|
+
((_c = f.properties) === null || _c === void 0 ? void 0 : _c.floor_key) === floorKey;
|
|
31
|
+
});
|
|
32
|
+
const paths = [];
|
|
33
|
+
for (const f of rooms) {
|
|
34
|
+
const z = ((_a = f.properties) === null || _a === void 0 ? void 0 : _a.height) ? Number(f.properties.height) : defaultHeight;
|
|
35
|
+
for (const rings of extractPolygonRings(f.geometry)) {
|
|
36
|
+
for (const ring of rings) {
|
|
37
|
+
paths.push({ path: ring.map(([lon, lat]) => [lon, lat, z]) });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return paths;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds indoor label text data from `area_name` / `poi` point features on the given floor.
|
|
45
|
+
* A feature is skipped when a matching `logo-{name}` sprite exists (icon takes priority over text).
|
|
46
|
+
*/
|
|
47
|
+
export function buildLabelData(features, floorKey, hasImage, defaultHeight) {
|
|
48
|
+
const labelFeatures = features.filter((f) => {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
if (((_a = f.properties) === null || _a === void 0 ? void 0 : _a.layerName) !== "area_name" && ((_b = f.properties) === null || _b === void 0 ? void 0 : _b.layerName) !== "poi")
|
|
51
|
+
return false;
|
|
52
|
+
if (((_c = f.geometry) === null || _c === void 0 ? void 0 : _c.type) !== "Point")
|
|
53
|
+
return false;
|
|
54
|
+
const name = ((_d = f.properties) === null || _d === void 0 ? void 0 : _d["name:latin"]) || ((_e = f.properties) === null || _e === void 0 ? void 0 : _e.name);
|
|
55
|
+
if (!name)
|
|
56
|
+
return false;
|
|
57
|
+
if (((_f = f.properties) === null || _f === void 0 ? void 0 : _f.floor_key) && f.properties.floor_key !== floorKey)
|
|
58
|
+
return false;
|
|
59
|
+
if (hasImage("logo-" + name))
|
|
60
|
+
return false; // icon has priority
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
return labelFeatures.map((f) => {
|
|
64
|
+
var _a, _b, _c;
|
|
65
|
+
return ({
|
|
66
|
+
position: [
|
|
67
|
+
...f.geometry.coordinates.slice(0, 2),
|
|
68
|
+
((_a = f.properties) === null || _a === void 0 ? void 0 : _a.height) ? Number(f.properties.height) : defaultHeight,
|
|
69
|
+
],
|
|
70
|
+
text: ((_b = f.properties) === null || _b === void 0 ? void 0 : _b["name:latin"]) || ((_c = f.properties) === null || _c === void 0 ? void 0 : _c.name) || "",
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** Resolves the POI icon id from a feature's `tags` and `subclass`. */
|
|
75
|
+
export function resolvePoiIcon(tags, subclass) {
|
|
76
|
+
if (tags.includes("wheelchair"))
|
|
77
|
+
return "accessible_toilets";
|
|
78
|
+
if (tags.includes("changing_table"))
|
|
79
|
+
return "changing_table";
|
|
80
|
+
return subclass;
|
|
81
|
+
}
|
|
82
|
+
/** Builds POI icon data (elevators / toilets) from point features on the given floor. */
|
|
83
|
+
export function buildPoiIconData(features, floorKey, defaultHeight) {
|
|
84
|
+
const poi = features.filter((f) => {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
if (((_a = f.geometry) === null || _a === void 0 ? void 0 : _a.type) !== "Point")
|
|
87
|
+
return false;
|
|
88
|
+
if (((_b = f.properties) === null || _b === void 0 ? void 0 : _b.floor_key) && f.properties.floor_key !== floorKey)
|
|
89
|
+
return false;
|
|
90
|
+
const sub = (_c = f.properties) === null || _c === void 0 ? void 0 : _c.subclass;
|
|
91
|
+
return sub === "elevator" || sub === "toilets";
|
|
92
|
+
});
|
|
93
|
+
return poi.map((f) => {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
return ({
|
|
96
|
+
position: [
|
|
97
|
+
...f.geometry.coordinates.slice(0, 2),
|
|
98
|
+
((_a = f.properties) === null || _a === void 0 ? void 0 : _a.height) ? Number(f.properties.height) : defaultHeight,
|
|
99
|
+
],
|
|
100
|
+
icon: resolvePoiIcon(((_b = f.properties) === null || _b === void 0 ? void 0 : _b.tags) || "", ((_c = f.properties) === null || _c === void 0 ? void 0 : _c.subclass) || ""),
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** Builds store-logo icon data from point features that have a matching `logo-{name}` sprite. */
|
|
105
|
+
export function buildStoreLogoData(features, floorKey, spriteMapping, defaultHeight) {
|
|
106
|
+
const logos = features.filter((f) => {
|
|
107
|
+
var _a, _b, _c;
|
|
108
|
+
if (((_a = f.geometry) === null || _a === void 0 ? void 0 : _a.type) !== "Point")
|
|
109
|
+
return false;
|
|
110
|
+
if (((_b = f.properties) === null || _b === void 0 ? void 0 : _b.floor_key) && f.properties.floor_key !== floorKey)
|
|
111
|
+
return false;
|
|
112
|
+
const name = (_c = f.properties) === null || _c === void 0 ? void 0 : _c.name;
|
|
113
|
+
if (!name)
|
|
114
|
+
return false;
|
|
115
|
+
return !!spriteMapping["logo-" + name];
|
|
116
|
+
});
|
|
117
|
+
return logos.map((f) => {
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
const name = (_a = f.properties) === null || _a === void 0 ? void 0 : _a.name;
|
|
120
|
+
return {
|
|
121
|
+
position: [
|
|
122
|
+
...f.geometry.coordinates.slice(0, 2),
|
|
123
|
+
((_b = f.properties) === null || _b === void 0 ? void 0 : _b.height) ? Number(f.properties.height) : defaultHeight,
|
|
124
|
+
],
|
|
125
|
+
icon: "logo-" + name,
|
|
126
|
+
rotation: ((_c = f.properties) === null || _c === void 0 ? void 0 : _c.rotation_icon) ? Number(f.properties.rotation_icon) : 0,
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Computes the display size for a store-logo icon from its sprite dimensions and an optional
|
|
132
|
+
* per-logo scale factor. Returns a fallback of `10` when the icon is missing from the sprite atlas.
|
|
133
|
+
*/
|
|
134
|
+
export function computeStoreLogoSize(mapping, icon, logoScale) {
|
|
135
|
+
const m = mapping[icon];
|
|
136
|
+
if (!m)
|
|
137
|
+
return 10;
|
|
138
|
+
const pr = m.pixelRatio;
|
|
139
|
+
const w = m.width / pr;
|
|
140
|
+
const h = m.height / pr;
|
|
141
|
+
const base = 10 * (h / Math.max(w, h));
|
|
142
|
+
return base * (logoScale[icon] || 1);
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=deckLayers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deckLayers.js","sourceRoot":"","sources":["../../../src/utils/deckLayers.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,2FAA2F;AAC3F,MAAM,UAAU,mBAAmB,CAAC,IAAyB;IAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,C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,CAAA,MAAA,CAAC,CAAC,UAAU,0CAAE,aAAa,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/E,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAuC,EACvC,IAAY,EACZ,SAAiC;IAEjC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvB,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAA;IACjB,MAAM,EAAE,GAAG,CAAC,CAAC,UAAU,CAAA;IACvB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAA;IACtB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,EAAE,CAAA;IACvB,MAAM,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACtC,OAAO,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
/**
|
|
3
|
+
* Loads a GLB/GLTF from URL and returns the root scene group.
|
|
4
|
+
* Central entry point so the loader implementation can be swapped later (e.g. Draco, KTX2, custom fetch).
|
|
5
|
+
*
|
|
6
|
+
* @param url - GLB URL
|
|
7
|
+
* @returns Root `THREE.Group` from the loaded glTF scene
|
|
8
|
+
* @group Utils
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadGlbRoot(url: string): Promise<THREE.Group>;
|
|
11
|
+
//# sourceMappingURL=loadGlb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadGlb.d.ts","sourceRoot":"","sources":["../../../src/utils/loadGlb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAiCnC;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAcnE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DEFAULT_DRACO_DECODER_PATH, DEFAULT_KTX2_TRANSCODER_PATH } from "../config/draco";
|
|
2
|
+
import { loadThree } from "./three";
|
|
3
|
+
/**
|
|
4
|
+
* Lazily-initialized, cached GLTF loader configured with Draco + KTX2 support.
|
|
5
|
+
*
|
|
6
|
+
* The loaders (and their WebGLRenderer for KTX2 support detection) are heavy and pull in Three.js,
|
|
7
|
+
* so they are created on first use inside the dynamic-import boundary rather than at module load.
|
|
8
|
+
*/
|
|
9
|
+
let gltfLoaderPromise;
|
|
10
|
+
function getGltfLoader() {
|
|
11
|
+
gltfLoaderPromise !== null && gltfLoaderPromise !== void 0 ? gltfLoaderPromise : (gltfLoaderPromise = loadThree().then((mod) => {
|
|
12
|
+
const dracoLoader = new mod.DRACOLoader();
|
|
13
|
+
dracoLoader.setDecoderPath(DEFAULT_DRACO_DECODER_PATH);
|
|
14
|
+
const gltfLoader = new mod.GLTFLoader();
|
|
15
|
+
gltfLoader.setDRACOLoader(dracoLoader);
|
|
16
|
+
const ktx2Loader = new mod.KTX2Loader();
|
|
17
|
+
ktx2Loader.setTranscoderPath(DEFAULT_KTX2_TRANSCODER_PATH);
|
|
18
|
+
gltfLoader.setKTX2Loader(ktx2Loader);
|
|
19
|
+
ktx2Loader.detectSupport(new mod.THREE.WebGLRenderer({ antialias: true }));
|
|
20
|
+
return gltfLoader;
|
|
21
|
+
}));
|
|
22
|
+
return gltfLoaderPromise;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Loads a GLB/GLTF from URL and returns the root scene group.
|
|
26
|
+
* Central entry point so the loader implementation can be swapped later (e.g. Draco, KTX2, custom fetch).
|
|
27
|
+
*
|
|
28
|
+
* @param url - GLB URL
|
|
29
|
+
* @returns Root `THREE.Group` from the loaded glTF scene
|
|
30
|
+
* @group Utils
|
|
31
|
+
*/
|
|
32
|
+
export async function loadGlbRoot(url) {
|
|
33
|
+
const gltfLoader = await getGltfLoader();
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
gltfLoader.load(url, (gltf) => {
|
|
36
|
+
resolve(gltf.scene);
|
|
37
|
+
}, undefined, (error) => {
|
|
38
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=loadGlb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadGlb.js","sourceRoot":"","sources":["../../../src/utils/loadGlb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC;;;;;GAKG;AACH,IAAI,iBAES,CAAA;AAEb,SAAS,aAAa;IACpB,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,IAAjB,iBAAiB,GAAK,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAA;QACzC,WAAW,CAAC,cAAc,CAAC,0BAA0B,CAAC,CAAA;QAEtD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAA;QACvC,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QAEtC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAA;QACvC,UAAU,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CAAA;QAC1D,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;QACpC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAE1E,OAAO,UAAU,CAAA;IACnB,CAAC,CAAC,EAAA;IACF,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,UAAU,GAAG,MAAM,aAAa,EAAE,CAAA;IACxC,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAClD,UAAU,CAAC,IAAI,CACb,GAAG,EACH,CAAC,IAAU,EAAE,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC,EACD,SAAS,EACT,CAAC,KAAc,EAAE,EAAE;YACjB,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnE,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy, single-instance access to Three.js / deck.gl and the glTF loaders.
|
|
3
|
+
*
|
|
4
|
+
* Why: Three.js and deck.gl are heavy and only needed when the map runs in 3D mode. They are
|
|
5
|
+
* declared as `optionalDependencies` and pulled in on demand via dynamic `import()` so the base
|
|
6
|
+
* 2D bundle never includes them. Routing every import through this module also guarantees a single
|
|
7
|
+
* shared Three.js instance, avoiding the runtime warning:
|
|
8
|
+
* "THREE.WARNING: Multiple instances of Three.js being imported."
|
|
9
|
+
*
|
|
10
|
+
* Consumers use the exported `type`-only `THREE` namespace for annotations (erased at compile time)
|
|
11
|
+
* and `loadThree()` / `loadDeck()` for the runtime instances.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import type * as THREE from "three"
|
|
16
|
+
* import { loadThree } from "../utils/three"
|
|
17
|
+
*
|
|
18
|
+
* const { THREE: three } = await loadThree()
|
|
19
|
+
* const geometry: THREE.BufferGeometry = new three.BoxGeometry(1, 1, 1)
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @group Utils
|
|
23
|
+
*/
|
|
24
|
+
import type { DRACOLoader } from "three/addons/loaders/DRACOLoader.js";
|
|
25
|
+
import type { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
|
26
|
+
import type { KTX2Loader } from "three/addons/loaders/KTX2Loader.js";
|
|
27
|
+
/** Runtime handle to Three.js plus its glTF loader classes. */
|
|
28
|
+
export interface ThreeModule {
|
|
29
|
+
THREE: typeof import("three");
|
|
30
|
+
GLTFLoader: typeof GLTFLoader;
|
|
31
|
+
DRACOLoader: typeof DRACOLoader;
|
|
32
|
+
KTX2Loader: typeof KTX2Loader;
|
|
33
|
+
}
|
|
34
|
+
/** Runtime handle to the deck.gl classes used by the 3D scene. */
|
|
35
|
+
export interface DeckModule {
|
|
36
|
+
MapboxOverlay: typeof import("@deck.gl/mapbox").MapboxOverlay;
|
|
37
|
+
MVTLayer: typeof import("@deck.gl/geo-layers").MVTLayer;
|
|
38
|
+
IconLayer: typeof import("@deck.gl/layers").IconLayer;
|
|
39
|
+
PathLayer: typeof import("@deck.gl/layers").PathLayer;
|
|
40
|
+
TextLayer: typeof import("@deck.gl/layers").TextLayer;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Dynamically imports Three.js and the GLTF/DRACO/KTX2 loaders once and caches the result.
|
|
44
|
+
* Subsequent calls return the same promise, so a single Three.js instance is shared.
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadThree(): Promise<ThreeModule>;
|
|
47
|
+
/**
|
|
48
|
+
* Dynamically imports the deck.gl overlay and layer classes once and caches the result.
|
|
49
|
+
*/
|
|
50
|
+
export declare function loadDeck(): Promise<DeckModule>;
|
|
51
|
+
//# sourceMappingURL=three.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"three.d.ts","sourceRoot":"","sources":["../../../src/utils/three.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAEpE,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,cAAc,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,WAAW,EAAE,OAAO,WAAW,CAAA;IAC/B,UAAU,EAAE,OAAO,UAAU,CAAA;CAC9B;AAED,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,cAAc,iBAAiB,EAAE,aAAa,CAAA;IAC7D,QAAQ,EAAE,cAAc,qBAAqB,EAAE,QAAQ,CAAA;IACvD,SAAS,EAAE,cAAc,iBAAiB,EAAE,SAAS,CAAA;IACrD,SAAS,EAAE,cAAc,iBAAiB,EAAE,SAAS,CAAA;IACrD,SAAS,EAAE,cAAc,iBAAiB,EAAE,SAAS,CAAA;CACtD;AAKD;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,CAahD;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAa9C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
let threePromise;
|
|
2
|
+
let deckPromise;
|
|
3
|
+
/**
|
|
4
|
+
* Dynamically imports Three.js and the GLTF/DRACO/KTX2 loaders once and caches the result.
|
|
5
|
+
* Subsequent calls return the same promise, so a single Three.js instance is shared.
|
|
6
|
+
*/
|
|
7
|
+
export function loadThree() {
|
|
8
|
+
threePromise !== null && threePromise !== void 0 ? threePromise : (threePromise = Promise.all([
|
|
9
|
+
import("three"),
|
|
10
|
+
import("three/addons/loaders/GLTFLoader.js"),
|
|
11
|
+
import("three/addons/loaders/DRACOLoader.js"),
|
|
12
|
+
import("three/addons/loaders/KTX2Loader.js"),
|
|
13
|
+
]).then(([three, gltf, draco, ktx2]) => ({
|
|
14
|
+
THREE: three,
|
|
15
|
+
GLTFLoader: gltf.GLTFLoader,
|
|
16
|
+
DRACOLoader: draco.DRACOLoader,
|
|
17
|
+
KTX2Loader: ktx2.KTX2Loader,
|
|
18
|
+
})));
|
|
19
|
+
return threePromise;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Dynamically imports the deck.gl overlay and layer classes once and caches the result.
|
|
23
|
+
*/
|
|
24
|
+
export function loadDeck() {
|
|
25
|
+
deckPromise !== null && deckPromise !== void 0 ? deckPromise : (deckPromise = Promise.all([
|
|
26
|
+
import("@deck.gl/mapbox"),
|
|
27
|
+
import("@deck.gl/geo-layers"),
|
|
28
|
+
import("@deck.gl/layers"),
|
|
29
|
+
]).then(([mapbox, geoLayers, layers]) => ({
|
|
30
|
+
MapboxOverlay: mapbox.MapboxOverlay,
|
|
31
|
+
MVTLayer: geoLayers.MVTLayer,
|
|
32
|
+
IconLayer: layers.IconLayer,
|
|
33
|
+
PathLayer: layers.PathLayer,
|
|
34
|
+
TextLayer: layers.TextLayer,
|
|
35
|
+
})));
|
|
36
|
+
return deckPromise;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=three.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"three.js","sourceRoot":"","sources":["../../../src/utils/three.ts"],"names":[],"mappings":"AA4CA,IAAI,YAA8C,CAAA;AAClD,IAAI,WAA4C,CAAA;AAEhD;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,YAAY,aAAZ,YAAY,cAAZ,YAAY,IAAZ,YAAY,GAAK,OAAO,CAAC,GAAG,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC;QACf,MAAM,CAAC,oCAAoC,CAAC;QAC5C,MAAM,CAAC,qCAAqC,CAAC;QAC7C,MAAM,CAAC,oCAAoC,CAAC;KAC7C,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACvC,KAAK,EAAE,KAAK;QACZ,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC,EAAA;IACH,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,WAAW,aAAX,WAAW,cAAX,WAAW,IAAX,WAAW,GAAK,OAAO,CAAC,GAAG,CAAC;QAC1B,MAAM,CAAC,iBAAiB,CAAC;QACzB,MAAM,CAAC,qBAAqB,CAAC;QAC7B,MAAM,CAAC,iBAAiB,CAAC;KAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC,CAAC,EAAA;IACH,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
import type { Scene3DLightConfig } from "../domain/models/scene3D";
|
|
3
|
+
/**
|
|
4
|
+
* Pure Three.js scene helpers. They receive the resolved Three.js module (from {@link loadThree})
|
|
5
|
+
* as their first argument instead of importing it, so they add nothing to the base bundle and can be
|
|
6
|
+
* unit-tested by passing a real Three.js instance (Three.js core math/scene classes need no WebGL).
|
|
7
|
+
*
|
|
8
|
+
* @group Utils
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Computes the anchor point used for bottom-aligned GLB placement: XZ from the bounding-box center,
|
|
12
|
+
* Y from the bounding-box minimum.
|
|
13
|
+
*
|
|
14
|
+
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function computeGlbBottomAnchor(three: typeof import("three"), root: THREE.Object3D): THREE.Vector3;
|
|
17
|
+
/**
|
|
18
|
+
* Instantiates Three.js lights from declarative config and adds them to the scene.
|
|
19
|
+
*
|
|
20
|
+
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
21
|
+
* @returns Number of light objects added (used to keep lights when clearing meshes).
|
|
22
|
+
*/
|
|
23
|
+
export declare function addScene3DLights(three: typeof import("three"), scene: THREE.Scene, lights: readonly Scene3DLightConfig[]): number;
|
|
24
|
+
//# sourceMappingURL=threeScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threeScene.d.ts","sourceRoot":"","sources":["../../../src/utils/threeScene.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE;;;;;;GAMG;AAEH;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,CAAC,QAAQ,GACnB,KAAK,CAAC,OAAO,CAKf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,OAAO,CAAC,EAC7B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,SAAS,kBAAkB,EAAE,GACpC,MAAM,CAcR"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure Three.js scene helpers. They receive the resolved Three.js module (from {@link loadThree})
|
|
3
|
+
* as their first argument instead of importing it, so they add nothing to the base bundle and can be
|
|
4
|
+
* unit-tested by passing a real Three.js instance (Three.js core math/scene classes need no WebGL).
|
|
5
|
+
*
|
|
6
|
+
* @group Utils
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Computes the anchor point used for bottom-aligned GLB placement: XZ from the bounding-box center,
|
|
10
|
+
* Y from the bounding-box minimum.
|
|
11
|
+
*
|
|
12
|
+
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
13
|
+
*/
|
|
14
|
+
export function computeGlbBottomAnchor(three, root) {
|
|
15
|
+
const box = new three.Box3().setFromObject(root);
|
|
16
|
+
const center = box.getCenter(new three.Vector3());
|
|
17
|
+
center.y = box.min.y;
|
|
18
|
+
return center;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Instantiates Three.js lights from declarative config and adds them to the scene.
|
|
22
|
+
*
|
|
23
|
+
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
24
|
+
* @returns Number of light objects added (used to keep lights when clearing meshes).
|
|
25
|
+
*/
|
|
26
|
+
export function addScene3DLights(three, scene, lights) {
|
|
27
|
+
let count = 0;
|
|
28
|
+
for (const light of lights) {
|
|
29
|
+
if (light.type === "ambient") {
|
|
30
|
+
scene.add(new three.AmbientLight(light.color, light.intensity));
|
|
31
|
+
count++;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const directional = new three.DirectionalLight(light.color, light.intensity);
|
|
35
|
+
directional.position.set(light.position.x, light.position.y, light.position.z);
|
|
36
|
+
scene.add(directional);
|
|
37
|
+
count++;
|
|
38
|
+
}
|
|
39
|
+
return count;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=threeScene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threeScene.js","sourceRoot":"","sources":["../../../src/utils/threeScene.ts"],"names":[],"mappings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