@combeenation/3d-viewer 13.0.1 → 14.0.1-rc1
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/README.md +9 -9
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/dist/lib-cjs/index.d.ts +62 -63
- package/dist/lib-cjs/index.js +94 -95
- package/dist/lib-cjs/index.js.map +1 -1
- package/dist/lib-cjs/internal/cbn-custom-babylon-loader-plugin.d.ts +10 -10
- package/dist/lib-cjs/internal/cbn-custom-babylon-loader-plugin.js +131 -131
- package/dist/lib-cjs/internal/cloning-helper.d.ts +19 -19
- package/dist/lib-cjs/internal/cloning-helper.js +163 -163
- package/dist/lib-cjs/internal/device-helper.d.ts +9 -9
- package/dist/lib-cjs/internal/device-helper.js +24 -24
- package/dist/lib-cjs/internal/geometry-helper.d.ts +21 -21
- package/dist/lib-cjs/internal/geometry-helper.js +145 -145
- package/dist/lib-cjs/internal/metadata-helper.d.ts +26 -26
- package/dist/lib-cjs/internal/metadata-helper.js +50 -50
- package/dist/lib-cjs/internal/paintable-helper.d.ts +40 -40
- package/dist/lib-cjs/internal/paintable-helper.js +286 -286
- package/dist/lib-cjs/internal/tags-helper.d.ts +12 -12
- package/dist/lib-cjs/internal/tags-helper.js +37 -37
- package/dist/lib-cjs/manager/camera-manager.d.ts +110 -51
- package/dist/lib-cjs/manager/camera-manager.js +206 -153
- package/dist/lib-cjs/manager/camera-manager.js.map +1 -1
- package/dist/lib-cjs/manager/debug-manager.d.ts +60 -60
- package/dist/lib-cjs/manager/debug-manager.js +217 -217
- package/dist/lib-cjs/manager/event-manager.d.ts +52 -52
- package/dist/lib-cjs/manager/event-manager.js +71 -71
- package/dist/lib-cjs/manager/gltf-export-manager.d.ts +84 -75
- package/dist/lib-cjs/manager/gltf-export-manager.js +290 -278
- package/dist/lib-cjs/manager/gltf-export-manager.js.map +1 -1
- package/dist/lib-cjs/manager/material-manager.d.ts +35 -35
- package/dist/lib-cjs/manager/material-manager.js +125 -125
- package/dist/lib-cjs/manager/model-manager.d.ts +145 -145
- package/dist/lib-cjs/manager/model-manager.js +382 -382
- package/dist/lib-cjs/manager/parameter-manager.d.ts +210 -210
- package/dist/lib-cjs/manager/parameter-manager.js +514 -514
- package/dist/lib-cjs/manager/scene-manager.d.ts +45 -45
- package/dist/lib-cjs/manager/scene-manager.js +64 -64
- package/dist/lib-cjs/manager/texture-manager.d.ts +12 -12
- package/dist/lib-cjs/manager/texture-manager.js +43 -43
- package/dist/lib-cjs/viewer-error.d.ts +48 -48
- package/dist/lib-cjs/viewer-error.js +60 -60
- package/dist/lib-cjs/viewer.d.ts +115 -117
- package/dist/lib-cjs/viewer.js +217 -221
- package/dist/lib-cjs/viewer.js.map +1 -1
- package/package.json +91 -91
- package/src/buildinfo.json +3 -3
- package/src/dev.ts +47 -47
- package/src/global-types.d.ts +39 -39
- package/src/index.ts +81 -82
- package/src/internal/cbn-custom-babylon-loader-plugin.ts +159 -159
- package/src/internal/cloning-helper.ts +225 -225
- package/src/internal/device-helper.ts +25 -25
- package/src/internal/geometry-helper.ts +181 -181
- package/src/internal/metadata-helper.ts +63 -63
- package/src/internal/paintable-helper.ts +310 -310
- package/src/internal/tags-helper.ts +41 -41
- package/src/manager/camera-manager.ts +365 -236
- package/src/manager/debug-manager.ts +245 -245
- package/src/manager/event-manager.ts +72 -72
- package/src/manager/gltf-export-manager.ts +357 -341
- package/src/manager/material-manager.ts +135 -135
- package/src/manager/model-manager.ts +458 -458
- package/src/manager/parameter-manager.ts +652 -652
- package/src/manager/scene-manager.ts +101 -101
- package/src/manager/texture-manager.ts +32 -32
- package/src/viewer-error.ts +68 -68
- package/src/viewer.ts +290 -296
- package/dist/lib-cjs/manager/screenshot-manager.d.ts +0 -36
- package/dist/lib-cjs/manager/screenshot-manager.js +0 -40
- package/dist/lib-cjs/manager/screenshot-manager.js.map +0 -1
- package/src/manager/screenshot-manager.ts +0 -59
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera-manager.js","sourceRoot":"","sources":["../../../src/manager/camera-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"camera-manager.js","sourceRoot":"","sources":["../../../src/manager/camera-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAWkB;AAClB,iEAA6D;AA6E7D;;GAEG;AACH,MAAa,aAAa;IAsBxB,gBAAgB;IAChB,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C;;OAEG;IACU,qBAAqB,CAAC,QAA4B;;;YAC7D,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;YAEpD,IAAI,CAAC,CAAC,YAAY,YAAY,uBAAe,CAAC,EAAE;gBAC9C,MAAM,IAAI,KAAK,CAAC,gBAAgB,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,EAAE,mDAAmD,CAAC,CAAC;aAClH;YAED,uFAAuF;YACvF,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,CAAC;YAC1E,wDAAwD;YACxD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,mBAAW,CAAC,cAAc,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;YAE5F,MAAM,QAAQ,GAAG,IAAI,CAAC,4BAA4B,CAAC,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;YAC9F,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;YAClD,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;YAElD,oGAAoG;YACpG,YAAY,CAAC,gBAAgB,GAAG,MAAM,CAAC;YAEvC,sBAAsB;YACtB,uEAAuE;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H,MAAM,0BAA0B,GAAG,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC;QAC9G,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,4BAA4B,EAAE,0BAA0B,CAAC,CAAC;QAEpF,OAAO,QAAQ,CAAC;IAClB,CAAC;;AA/QH,sCAgRC;AA/QwB,mCAAqB,GAAG,qBAAqB,CAAC;AAErE,gBAAgB;AACO,qCAAuB,GAAmB;IAC/D,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG;IAC3B,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG;IAC1B,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEwB,kCAAoB,GAAG;IAC/C,IAAI,EAAE,GAAG;IACT,cAAc,EAAE,GAAG;IACnB,kBAAkB,EAAE,IAAI;IACxB,cAAc,EAAE,GAAG;CACpB,CAAC;AAEwB,8CAAgC,GAAG,CAAC,CAAC;AACrC,mCAAqB,GAAG,GAAG,CAAC;AAC5B,qCAAuB,GAAG,sBAAsB,CAAC"}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { AxesViewer, BoundingSphere, Color3, IInspectorOptions, Scene, TransformNode, Vector3, Viewer } from '../index';
|
|
2
|
-
declare type DebugAxisKeys = 'X' | 'Y' | 'Z';
|
|
3
|
-
declare type DebugAxisConfig = {
|
|
4
|
-
color: Color3;
|
|
5
|
-
position: Vector3;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Manager for debugging functionalities
|
|
9
|
-
*/
|
|
10
|
-
export declare class DebugManager {
|
|
11
|
-
protected viewer: Viewer;
|
|
12
|
-
protected static _DEBUG_AXIS_MAP: Record<DebugAxisKeys, DebugAxisConfig>;
|
|
13
|
-
protected static _WORLD_COORD_ROOT_KEY: string;
|
|
14
|
-
protected static _BOUNDING_SPHERE_KEY: string;
|
|
15
|
-
protected _axesViewer: AxesViewer | null;
|
|
16
|
-
protected _showBoundingSphereForAutofocus: boolean;
|
|
17
|
-
/** @internal */
|
|
18
|
-
constructor(viewer: Viewer);
|
|
19
|
-
/**
|
|
20
|
-
* Assign callback for drawing bounding sphere on autofocusing
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
registerAutofocusStartListener(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Enables the Babylon.js [Inspector](https://doc.babylonjs.com/toolsAndResources/tools/inspector).\
|
|
26
|
-
* Due to the additional size of the inspector, this function is only available in "development" builds!
|
|
27
|
-
*
|
|
28
|
-
* @returns Signalizes if inspector could be loaded
|
|
29
|
-
*/
|
|
30
|
-
showInspector(options?: IInspectorOptions): Promise<boolean>;
|
|
31
|
-
hideInspector(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Show world coordinate system with given dimension.\
|
|
34
|
-
* This is especially usefull when working on project with tricky positioning. (e.g. clones)
|
|
35
|
-
*/
|
|
36
|
-
showWorldCoordinates(dimension: number): void;
|
|
37
|
-
hideWorldCoordinates(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Draws a wireframe bounding sphere on the next call of {@link CameraManager.autofocusActiveCamera}.\
|
|
40
|
-
* This is usefull for checking which parts of the scene get centered.
|
|
41
|
-
*/
|
|
42
|
-
showBoundingSphereForAutofocus(): void;
|
|
43
|
-
hideBoundingSphereForAutofocus(): void;
|
|
44
|
-
/**
|
|
45
|
-
* Adjust and enhance coordinate axes to fulfill our needs.
|
|
46
|
-
* - moves nodes into common root
|
|
47
|
-
* - adds text node
|
|
48
|
-
*/
|
|
49
|
-
protected static _prepareWorldCoordinateAxis(text: 'X' | 'Y' | 'Z', axis: TransformNode, root: TransformNode, dimension: number, utilityLayerScene: Scene): void;
|
|
50
|
-
/**
|
|
51
|
-
* Calculate factor for creating world coordinate axes with exactly one unit in length
|
|
52
|
-
*/
|
|
53
|
-
protected static _getWorldCoordinatesAxesUnifyFactor(): number;
|
|
54
|
-
/**
|
|
55
|
-
* Visualize bounding sphere which is used to zoom in via `autofocusActiveCamera` function
|
|
56
|
-
*/
|
|
57
|
-
protected _drawBoundingSphereForAutofocus(boundingSphere: BoundingSphere): void;
|
|
58
|
-
protected _removeBoundingSphereForAutofocus(): void;
|
|
59
|
-
}
|
|
60
|
-
export {};
|
|
1
|
+
import { AxesViewer, BoundingSphere, Color3, IInspectorOptions, Scene, TransformNode, Vector3, Viewer } from '../index';
|
|
2
|
+
declare type DebugAxisKeys = 'X' | 'Y' | 'Z';
|
|
3
|
+
declare type DebugAxisConfig = {
|
|
4
|
+
color: Color3;
|
|
5
|
+
position: Vector3;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Manager for debugging functionalities
|
|
9
|
+
*/
|
|
10
|
+
export declare class DebugManager {
|
|
11
|
+
protected viewer: Viewer;
|
|
12
|
+
protected static _DEBUG_AXIS_MAP: Record<DebugAxisKeys, DebugAxisConfig>;
|
|
13
|
+
protected static _WORLD_COORD_ROOT_KEY: string;
|
|
14
|
+
protected static _BOUNDING_SPHERE_KEY: string;
|
|
15
|
+
protected _axesViewer: AxesViewer | null;
|
|
16
|
+
protected _showBoundingSphereForAutofocus: boolean;
|
|
17
|
+
/** @internal */
|
|
18
|
+
constructor(viewer: Viewer);
|
|
19
|
+
/**
|
|
20
|
+
* Assign callback for drawing bounding sphere on autofocusing
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
registerAutofocusStartListener(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Enables the Babylon.js [Inspector](https://doc.babylonjs.com/toolsAndResources/tools/inspector).\
|
|
26
|
+
* Due to the additional size of the inspector, this function is only available in "development" builds!
|
|
27
|
+
*
|
|
28
|
+
* @returns Signalizes if inspector could be loaded
|
|
29
|
+
*/
|
|
30
|
+
showInspector(options?: IInspectorOptions): Promise<boolean>;
|
|
31
|
+
hideInspector(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Show world coordinate system with given dimension.\
|
|
34
|
+
* This is especially usefull when working on project with tricky positioning. (e.g. clones)
|
|
35
|
+
*/
|
|
36
|
+
showWorldCoordinates(dimension: number): void;
|
|
37
|
+
hideWorldCoordinates(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Draws a wireframe bounding sphere on the next call of {@link CameraManager.autofocusActiveCamera}.\
|
|
40
|
+
* This is usefull for checking which parts of the scene get centered.
|
|
41
|
+
*/
|
|
42
|
+
showBoundingSphereForAutofocus(): void;
|
|
43
|
+
hideBoundingSphereForAutofocus(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Adjust and enhance coordinate axes to fulfill our needs.
|
|
46
|
+
* - moves nodes into common root
|
|
47
|
+
* - adds text node
|
|
48
|
+
*/
|
|
49
|
+
protected static _prepareWorldCoordinateAxis(text: 'X' | 'Y' | 'Z', axis: TransformNode, root: TransformNode, dimension: number, utilityLayerScene: Scene): void;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate factor for creating world coordinate axes with exactly one unit in length
|
|
52
|
+
*/
|
|
53
|
+
protected static _getWorldCoordinatesAxesUnifyFactor(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Visualize bounding sphere which is used to zoom in via `autofocusActiveCamera` function
|
|
56
|
+
*/
|
|
57
|
+
protected _drawBoundingSphereForAutofocus(boundingSphere: BoundingSphere): void;
|
|
58
|
+
protected _removeBoundingSphereForAutofocus(): void;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -1,218 +1,218 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.DebugManager = void 0;
|
|
36
|
-
const index_1 = require("../index");
|
|
37
|
-
/**
|
|
38
|
-
* Manager for debugging functionalities
|
|
39
|
-
*/
|
|
40
|
-
class DebugManager {
|
|
41
|
-
/** @internal */
|
|
42
|
-
constructor(viewer) {
|
|
43
|
-
this.viewer = viewer;
|
|
44
|
-
this._axesViewer = null;
|
|
45
|
-
this._showBoundingSphereForAutofocus = false;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Assign callback for drawing bounding sphere on autofocusing
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
51
|
-
registerAutofocusStartListener() {
|
|
52
|
-
this.viewer.eventManager.addListener(index_1.ViewerEvent.AutofocusStart, boundingSphere => this._drawBoundingSphereForAutofocus(boundingSphere));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Enables the Babylon.js [Inspector](https://doc.babylonjs.com/toolsAndResources/tools/inspector).\
|
|
56
|
-
* Due to the additional size of the inspector, this function is only available in "development" builds!
|
|
57
|
-
*
|
|
58
|
-
* @returns Signalizes if inspector could be loaded
|
|
59
|
-
*/
|
|
60
|
-
showInspector(options) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
if (process.env.NODE_ENV === 'development') {
|
|
63
|
-
const inspModule = yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "inspector"*/ '@babylonjs/inspector')));
|
|
64
|
-
if (!options && window.Cbn) {
|
|
65
|
-
// special case for usage in Combeenation configurator:
|
|
66
|
-
// if no options are set the inspector will be rendered into the parent element of the configurator
|
|
67
|
-
// in this way the configurator layout itself will not be affected by the inspector
|
|
68
|
-
const cfgrParentEl = window.Cbn.utils.Viewer3dHelper.getCfgrParentDomElementForInspector();
|
|
69
|
-
inspModule.Inspector.Show(this.viewer.scene, { globalRoot: cfgrParentEl });
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
inspModule.Inspector.Show(this.viewer.scene, options !== null && options !== void 0 ? options : {});
|
|
73
|
-
}
|
|
74
|
-
// load additional packages for certain inspector features like "node material editor"
|
|
75
|
-
// this is done after showing the debug layer to save time
|
|
76
|
-
yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "node-material-editor" */ '@babylonjs/node-editor')));
|
|
77
|
-
yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "node-geometry-editor" */ '@babylonjs/node-geometry-editor')));
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// inspector not available, set according warning message in console
|
|
82
|
-
if (window.Cbn) {
|
|
83
|
-
console.warn(`Inspector not loaded.
|
|
84
|
-
The inspector can only be used in development builds (e.g. during development with watch mode, in the configurator preview, ...)
|
|
85
|
-
but not in production (e.g. production build of Custom JS, published configurator, ...).`);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
console.warn(`Inspector not loaded.
|
|
89
|
-
The inspector can only be used in development builds.`);
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
hideInspector() {
|
|
96
|
-
var _a;
|
|
97
|
-
(_a = this.viewer.scene.debugLayer) === null || _a === void 0 ? void 0 : _a.hide();
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Show world coordinate system with given dimension.\
|
|
101
|
-
* This is especially usefull when working on project with tricky positioning. (e.g. clones)
|
|
102
|
-
*/
|
|
103
|
-
showWorldCoordinates(dimension) {
|
|
104
|
-
// make sure to remove already existing debug coordinate systems
|
|
105
|
-
this.hideWorldCoordinates();
|
|
106
|
-
// draw in utility layer, so that there is no interaction with the actually scene content
|
|
107
|
-
// (e.g. glb export, autofocus)
|
|
108
|
-
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
109
|
-
const worldCoordRoot = new index_1.TransformNode(DebugManager._WORLD_COORD_ROOT_KEY, utilityLayerScene);
|
|
110
|
-
// axes viewer coordinate system is a bit too large
|
|
111
|
-
// multiply with unify factor to create arrows which exactly match the length of the input dimension
|
|
112
|
-
const factor = DebugManager._getWorldCoordinatesAxesUnifyFactor();
|
|
113
|
-
this._axesViewer = new index_1.AxesViewer(utilityLayerScene, dimension * factor);
|
|
114
|
-
DebugManager._prepareWorldCoordinateAxis('X', this._axesViewer.xAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
115
|
-
DebugManager._prepareWorldCoordinateAxis('Y', this._axesViewer.yAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
116
|
-
DebugManager._prepareWorldCoordinateAxis('Z', this._axesViewer.zAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
117
|
-
}
|
|
118
|
-
hideWorldCoordinates() {
|
|
119
|
-
var _a;
|
|
120
|
-
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
121
|
-
(_a = this._axesViewer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
122
|
-
this._axesViewer = null;
|
|
123
|
-
const worldCoordRoot = utilityLayerScene.getTransformNodeByName(DebugManager._WORLD_COORD_ROOT_KEY);
|
|
124
|
-
if (worldCoordRoot) {
|
|
125
|
-
worldCoordRoot.dispose(false, true);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Draws a wireframe bounding sphere on the next call of {@link CameraManager.autofocusActiveCamera}.\
|
|
130
|
-
* This is usefull for checking which parts of the scene get centered.
|
|
131
|
-
*/
|
|
132
|
-
showBoundingSphereForAutofocus() {
|
|
133
|
-
this._showBoundingSphereForAutofocus = true;
|
|
134
|
-
}
|
|
135
|
-
hideBoundingSphereForAutofocus() {
|
|
136
|
-
this._showBoundingSphereForAutofocus = false;
|
|
137
|
-
this._removeBoundingSphereForAutofocus();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Adjust and enhance coordinate axes to fulfill our needs.
|
|
141
|
-
* - moves nodes into common root
|
|
142
|
-
* - adds text node
|
|
143
|
-
*/
|
|
144
|
-
static _prepareWorldCoordinateAxis(text, axis, root, dimension, utilityLayerScene) {
|
|
145
|
-
// create unique names
|
|
146
|
-
axis.name = `${DebugManager._WORLD_COORD_ROOT_KEY}.${text}`;
|
|
147
|
-
axis.parent = root;
|
|
148
|
-
// create text mesh via dynamic texture
|
|
149
|
-
const dynamicTexture = new index_1.DynamicTexture(`${DebugManager._WORLD_COORD_ROOT_KEY}.${text}`, 50, utilityLayerScene, true);
|
|
150
|
-
dynamicTexture.hasAlpha = true;
|
|
151
|
-
// 42.5 is a magic offset, so that the text is vertically centered for font size 50px
|
|
152
|
-
// horizontal centering works well with the standard behaviour of Babylon.js (setting "null" as "width")
|
|
153
|
-
dynamicTexture.drawText(text, null, 42.5, 'bold 50px Arial', 'white', 'transparent', true);
|
|
154
|
-
const material = new index_1.StandardMaterial(`${DebugManager._WORLD_COORD_ROOT_KEY}.${text}`, utilityLayerScene);
|
|
155
|
-
material.disableLighting = true;
|
|
156
|
-
material.emissiveColor = DebugManager._DEBUG_AXIS_MAP[text].color;
|
|
157
|
-
material.diffuseTexture = dynamicTexture;
|
|
158
|
-
const plane = index_1.MeshBuilder.CreatePlane(`${DebugManager._WORLD_COORD_ROOT_KEY}.${text}.TextPlane`, { size: dimension / 10 }, utilityLayerScene);
|
|
159
|
-
// make sure that text is located outside of arrow
|
|
160
|
-
plane.position = DebugManager._DEBUG_AXIS_MAP[text].position.multiplyByFloats(dimension * 1.05, dimension * 1.05, dimension * 1.05);
|
|
161
|
-
plane.parent = root;
|
|
162
|
-
plane.material = material;
|
|
163
|
-
// will be rendered on top of "default" meshes => taken from Babylon.js repo "AxesViewer" implementation
|
|
164
|
-
plane.renderingGroupId = 2;
|
|
165
|
-
// setting billboard mode ensures, that the text is always readable
|
|
166
|
-
plane.billboardMode = index_1.TransformNode.BILLBOARDMODE_ALL;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Calculate factor for creating world coordinate axes with exactly one unit in length
|
|
170
|
-
*/
|
|
171
|
-
static _getWorldCoordinatesAxesUnifyFactor() {
|
|
172
|
-
// These constants are taken from the Babylon.js repository
|
|
173
|
-
const coneZPosOffset = 0.3;
|
|
174
|
-
const coneHeight = 0.075;
|
|
175
|
-
const baseScaling = 4;
|
|
176
|
-
// cone is moved 0.3 units away from the center
|
|
177
|
-
// the origin of the cone will be located on 1.2, if combined with the base scaling of 4
|
|
178
|
-
// invert that offset to get the origin to 1
|
|
179
|
-
// also consider the cone height to move the tip of the cone to 1 instead the center
|
|
180
|
-
const factor = 1 / ((coneZPosOffset + coneHeight / 2) * baseScaling);
|
|
181
|
-
return factor;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Visualize bounding sphere which is used to zoom in via `autofocusActiveCamera` function
|
|
185
|
-
*/
|
|
186
|
-
_drawBoundingSphereForAutofocus(boundingSphere) {
|
|
187
|
-
if (!this._showBoundingSphereForAutofocus) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
this._removeBoundingSphereForAutofocus();
|
|
191
|
-
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
192
|
-
let boundingMaterial = utilityLayerScene.getMaterialByName(DebugManager._BOUNDING_SPHERE_KEY);
|
|
193
|
-
if (!boundingMaterial) {
|
|
194
|
-
boundingMaterial = new index_1.StandardMaterial(DebugManager._BOUNDING_SPHERE_KEY, utilityLayerScene);
|
|
195
|
-
boundingMaterial.wireframe = true;
|
|
196
|
-
boundingMaterial.alpha = 0.1;
|
|
197
|
-
boundingMaterial.emissiveColor = new index_1.Color3(1, 1, 1);
|
|
198
|
-
}
|
|
199
|
-
const sphere = index_1.MeshBuilder.CreateSphere(DebugManager._BOUNDING_SPHERE_KEY, { diameter: boundingSphere.radius * 2 }, utilityLayerScene);
|
|
200
|
-
sphere.position = boundingSphere.center;
|
|
201
|
-
sphere.material = boundingMaterial;
|
|
202
|
-
sphere.isPickable = false;
|
|
203
|
-
}
|
|
204
|
-
_removeBoundingSphereForAutofocus() {
|
|
205
|
-
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
206
|
-
const existingSphere = utilityLayerScene.getMeshByName(DebugManager._BOUNDING_SPHERE_KEY);
|
|
207
|
-
existingSphere === null || existingSphere === void 0 ? void 0 : existingSphere.dispose();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
exports.DebugManager = DebugManager;
|
|
211
|
-
DebugManager._DEBUG_AXIS_MAP = {
|
|
212
|
-
X: { color: index_1.Color3.Red().scale(0.5), position: new index_1.Vector3(1, 0, 0) },
|
|
213
|
-
Y: { color: index_1.Color3.Green().scale(0.5), position: new index_1.Vector3(0, 1, 0) },
|
|
214
|
-
Z: { color: index_1.Color3.Blue().scale(0.5), position: new index_1.Vector3(0, 0, 1) },
|
|
215
|
-
};
|
|
216
|
-
DebugManager._WORLD_COORD_ROOT_KEY = '__world_coordinates__';
|
|
217
|
-
DebugManager._BOUNDING_SPHERE_KEY = '__bounding_sphere__';
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.DebugManager = void 0;
|
|
36
|
+
const index_1 = require("../index");
|
|
37
|
+
/**
|
|
38
|
+
* Manager for debugging functionalities
|
|
39
|
+
*/
|
|
40
|
+
class DebugManager {
|
|
41
|
+
/** @internal */
|
|
42
|
+
constructor(viewer) {
|
|
43
|
+
this.viewer = viewer;
|
|
44
|
+
this._axesViewer = null;
|
|
45
|
+
this._showBoundingSphereForAutofocus = false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Assign callback for drawing bounding sphere on autofocusing
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
registerAutofocusStartListener() {
|
|
52
|
+
this.viewer.eventManager.addListener(index_1.ViewerEvent.AutofocusStart, boundingSphere => this._drawBoundingSphereForAutofocus(boundingSphere));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Enables the Babylon.js [Inspector](https://doc.babylonjs.com/toolsAndResources/tools/inspector).\
|
|
56
|
+
* Due to the additional size of the inspector, this function is only available in "development" builds!
|
|
57
|
+
*
|
|
58
|
+
* @returns Signalizes if inspector could be loaded
|
|
59
|
+
*/
|
|
60
|
+
showInspector(options) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (process.env.NODE_ENV === 'development') {
|
|
63
|
+
const inspModule = yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "inspector"*/ '@babylonjs/inspector')));
|
|
64
|
+
if (!options && window.Cbn) {
|
|
65
|
+
// special case for usage in Combeenation configurator:
|
|
66
|
+
// if no options are set the inspector will be rendered into the parent element of the configurator
|
|
67
|
+
// in this way the configurator layout itself will not be affected by the inspector
|
|
68
|
+
const cfgrParentEl = window.Cbn.utils.Viewer3dHelper.getCfgrParentDomElementForInspector();
|
|
69
|
+
inspModule.Inspector.Show(this.viewer.scene, { globalRoot: cfgrParentEl });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
inspModule.Inspector.Show(this.viewer.scene, options !== null && options !== void 0 ? options : {});
|
|
73
|
+
}
|
|
74
|
+
// load additional packages for certain inspector features like "node material editor"
|
|
75
|
+
// this is done after showing the debug layer to save time
|
|
76
|
+
yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "node-material-editor" */ '@babylonjs/node-editor')));
|
|
77
|
+
yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "node-geometry-editor" */ '@babylonjs/node-geometry-editor')));
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// inspector not available, set according warning message in console
|
|
82
|
+
if (window.Cbn) {
|
|
83
|
+
console.warn(`Inspector not loaded.
|
|
84
|
+
The inspector can only be used in development builds (e.g. during development with watch mode, in the configurator preview, ...)
|
|
85
|
+
but not in production (e.g. production build of Custom JS, published configurator, ...).`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.warn(`Inspector not loaded.
|
|
89
|
+
The inspector can only be used in development builds.`);
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
hideInspector() {
|
|
96
|
+
var _a;
|
|
97
|
+
(_a = this.viewer.scene.debugLayer) === null || _a === void 0 ? void 0 : _a.hide();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Show world coordinate system with given dimension.\
|
|
101
|
+
* This is especially usefull when working on project with tricky positioning. (e.g. clones)
|
|
102
|
+
*/
|
|
103
|
+
showWorldCoordinates(dimension) {
|
|
104
|
+
// make sure to remove already existing debug coordinate systems
|
|
105
|
+
this.hideWorldCoordinates();
|
|
106
|
+
// draw in utility layer, so that there is no interaction with the actually scene content
|
|
107
|
+
// (e.g. glb export, autofocus)
|
|
108
|
+
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
109
|
+
const worldCoordRoot = new index_1.TransformNode(DebugManager._WORLD_COORD_ROOT_KEY, utilityLayerScene);
|
|
110
|
+
// axes viewer coordinate system is a bit too large
|
|
111
|
+
// multiply with unify factor to create arrows which exactly match the length of the input dimension
|
|
112
|
+
const factor = DebugManager._getWorldCoordinatesAxesUnifyFactor();
|
|
113
|
+
this._axesViewer = new index_1.AxesViewer(utilityLayerScene, dimension * factor);
|
|
114
|
+
DebugManager._prepareWorldCoordinateAxis('X', this._axesViewer.xAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
115
|
+
DebugManager._prepareWorldCoordinateAxis('Y', this._axesViewer.yAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
116
|
+
DebugManager._prepareWorldCoordinateAxis('Z', this._axesViewer.zAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
117
|
+
}
|
|
118
|
+
hideWorldCoordinates() {
|
|
119
|
+
var _a;
|
|
120
|
+
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
121
|
+
(_a = this._axesViewer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
122
|
+
this._axesViewer = null;
|
|
123
|
+
const worldCoordRoot = utilityLayerScene.getTransformNodeByName(DebugManager._WORLD_COORD_ROOT_KEY);
|
|
124
|
+
if (worldCoordRoot) {
|
|
125
|
+
worldCoordRoot.dispose(false, true);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Draws a wireframe bounding sphere on the next call of {@link CameraManager.autofocusActiveCamera}.\
|
|
130
|
+
* This is usefull for checking which parts of the scene get centered.
|
|
131
|
+
*/
|
|
132
|
+
showBoundingSphereForAutofocus() {
|
|
133
|
+
this._showBoundingSphereForAutofocus = true;
|
|
134
|
+
}
|
|
135
|
+
hideBoundingSphereForAutofocus() {
|
|
136
|
+
this._showBoundingSphereForAutofocus = false;
|
|
137
|
+
this._removeBoundingSphereForAutofocus();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Adjust and enhance coordinate axes to fulfill our needs.
|
|
141
|
+
* - moves nodes into common root
|
|
142
|
+
* - adds text node
|
|
143
|
+
*/
|
|
144
|
+
static _prepareWorldCoordinateAxis(text, axis, root, dimension, utilityLayerScene) {
|
|
145
|
+
// create unique names
|
|
146
|
+
axis.name = `${DebugManager._WORLD_COORD_ROOT_KEY}.${text}`;
|
|
147
|
+
axis.parent = root;
|
|
148
|
+
// create text mesh via dynamic texture
|
|
149
|
+
const dynamicTexture = new index_1.DynamicTexture(`${DebugManager._WORLD_COORD_ROOT_KEY}.${text}`, 50, utilityLayerScene, true);
|
|
150
|
+
dynamicTexture.hasAlpha = true;
|
|
151
|
+
// 42.5 is a magic offset, so that the text is vertically centered for font size 50px
|
|
152
|
+
// horizontal centering works well with the standard behaviour of Babylon.js (setting "null" as "width")
|
|
153
|
+
dynamicTexture.drawText(text, null, 42.5, 'bold 50px Arial', 'white', 'transparent', true);
|
|
154
|
+
const material = new index_1.StandardMaterial(`${DebugManager._WORLD_COORD_ROOT_KEY}.${text}`, utilityLayerScene);
|
|
155
|
+
material.disableLighting = true;
|
|
156
|
+
material.emissiveColor = DebugManager._DEBUG_AXIS_MAP[text].color;
|
|
157
|
+
material.diffuseTexture = dynamicTexture;
|
|
158
|
+
const plane = index_1.MeshBuilder.CreatePlane(`${DebugManager._WORLD_COORD_ROOT_KEY}.${text}.TextPlane`, { size: dimension / 10 }, utilityLayerScene);
|
|
159
|
+
// make sure that text is located outside of arrow
|
|
160
|
+
plane.position = DebugManager._DEBUG_AXIS_MAP[text].position.multiplyByFloats(dimension * 1.05, dimension * 1.05, dimension * 1.05);
|
|
161
|
+
plane.parent = root;
|
|
162
|
+
plane.material = material;
|
|
163
|
+
// will be rendered on top of "default" meshes => taken from Babylon.js repo "AxesViewer" implementation
|
|
164
|
+
plane.renderingGroupId = 2;
|
|
165
|
+
// setting billboard mode ensures, that the text is always readable
|
|
166
|
+
plane.billboardMode = index_1.TransformNode.BILLBOARDMODE_ALL;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Calculate factor for creating world coordinate axes with exactly one unit in length
|
|
170
|
+
*/
|
|
171
|
+
static _getWorldCoordinatesAxesUnifyFactor() {
|
|
172
|
+
// These constants are taken from the Babylon.js repository
|
|
173
|
+
const coneZPosOffset = 0.3;
|
|
174
|
+
const coneHeight = 0.075;
|
|
175
|
+
const baseScaling = 4;
|
|
176
|
+
// cone is moved 0.3 units away from the center
|
|
177
|
+
// the origin of the cone will be located on 1.2, if combined with the base scaling of 4
|
|
178
|
+
// invert that offset to get the origin to 1
|
|
179
|
+
// also consider the cone height to move the tip of the cone to 1 instead the center
|
|
180
|
+
const factor = 1 / ((coneZPosOffset + coneHeight / 2) * baseScaling);
|
|
181
|
+
return factor;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Visualize bounding sphere which is used to zoom in via `autofocusActiveCamera` function
|
|
185
|
+
*/
|
|
186
|
+
_drawBoundingSphereForAutofocus(boundingSphere) {
|
|
187
|
+
if (!this._showBoundingSphereForAutofocus) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this._removeBoundingSphereForAutofocus();
|
|
191
|
+
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
192
|
+
let boundingMaterial = utilityLayerScene.getMaterialByName(DebugManager._BOUNDING_SPHERE_KEY);
|
|
193
|
+
if (!boundingMaterial) {
|
|
194
|
+
boundingMaterial = new index_1.StandardMaterial(DebugManager._BOUNDING_SPHERE_KEY, utilityLayerScene);
|
|
195
|
+
boundingMaterial.wireframe = true;
|
|
196
|
+
boundingMaterial.alpha = 0.1;
|
|
197
|
+
boundingMaterial.emissiveColor = new index_1.Color3(1, 1, 1);
|
|
198
|
+
}
|
|
199
|
+
const sphere = index_1.MeshBuilder.CreateSphere(DebugManager._BOUNDING_SPHERE_KEY, { diameter: boundingSphere.radius * 2 }, utilityLayerScene);
|
|
200
|
+
sphere.position = boundingSphere.center;
|
|
201
|
+
sphere.material = boundingMaterial;
|
|
202
|
+
sphere.isPickable = false;
|
|
203
|
+
}
|
|
204
|
+
_removeBoundingSphereForAutofocus() {
|
|
205
|
+
const utilityLayerScene = index_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
206
|
+
const existingSphere = utilityLayerScene.getMeshByName(DebugManager._BOUNDING_SPHERE_KEY);
|
|
207
|
+
existingSphere === null || existingSphere === void 0 ? void 0 : existingSphere.dispose();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.DebugManager = DebugManager;
|
|
211
|
+
DebugManager._DEBUG_AXIS_MAP = {
|
|
212
|
+
X: { color: index_1.Color3.Red().scale(0.5), position: new index_1.Vector3(1, 0, 0) },
|
|
213
|
+
Y: { color: index_1.Color3.Green().scale(0.5), position: new index_1.Vector3(0, 1, 0) },
|
|
214
|
+
Z: { color: index_1.Color3.Blue().scale(0.5), position: new index_1.Vector3(0, 0, 1) },
|
|
215
|
+
};
|
|
216
|
+
DebugManager._WORLD_COORD_ROOT_KEY = '__world_coordinates__';
|
|
217
|
+
DebugManager._BOUNDING_SPHERE_KEY = '__bounding_sphere__';
|
|
218
218
|
//# sourceMappingURL=debug-manager.js.map
|