@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.
Files changed (72) hide show
  1. package/README.md +9 -9
  2. package/dist/lib-cjs/buildinfo.json +3 -3
  3. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
  4. package/dist/lib-cjs/index.d.ts +62 -63
  5. package/dist/lib-cjs/index.js +94 -95
  6. package/dist/lib-cjs/index.js.map +1 -1
  7. package/dist/lib-cjs/internal/cbn-custom-babylon-loader-plugin.d.ts +10 -10
  8. package/dist/lib-cjs/internal/cbn-custom-babylon-loader-plugin.js +131 -131
  9. package/dist/lib-cjs/internal/cloning-helper.d.ts +19 -19
  10. package/dist/lib-cjs/internal/cloning-helper.js +163 -163
  11. package/dist/lib-cjs/internal/device-helper.d.ts +9 -9
  12. package/dist/lib-cjs/internal/device-helper.js +24 -24
  13. package/dist/lib-cjs/internal/geometry-helper.d.ts +21 -21
  14. package/dist/lib-cjs/internal/geometry-helper.js +145 -145
  15. package/dist/lib-cjs/internal/metadata-helper.d.ts +26 -26
  16. package/dist/lib-cjs/internal/metadata-helper.js +50 -50
  17. package/dist/lib-cjs/internal/paintable-helper.d.ts +40 -40
  18. package/dist/lib-cjs/internal/paintable-helper.js +286 -286
  19. package/dist/lib-cjs/internal/tags-helper.d.ts +12 -12
  20. package/dist/lib-cjs/internal/tags-helper.js +37 -37
  21. package/dist/lib-cjs/manager/camera-manager.d.ts +110 -51
  22. package/dist/lib-cjs/manager/camera-manager.js +206 -153
  23. package/dist/lib-cjs/manager/camera-manager.js.map +1 -1
  24. package/dist/lib-cjs/manager/debug-manager.d.ts +60 -60
  25. package/dist/lib-cjs/manager/debug-manager.js +217 -217
  26. package/dist/lib-cjs/manager/event-manager.d.ts +52 -52
  27. package/dist/lib-cjs/manager/event-manager.js +71 -71
  28. package/dist/lib-cjs/manager/gltf-export-manager.d.ts +84 -75
  29. package/dist/lib-cjs/manager/gltf-export-manager.js +290 -278
  30. package/dist/lib-cjs/manager/gltf-export-manager.js.map +1 -1
  31. package/dist/lib-cjs/manager/material-manager.d.ts +35 -35
  32. package/dist/lib-cjs/manager/material-manager.js +125 -125
  33. package/dist/lib-cjs/manager/model-manager.d.ts +145 -145
  34. package/dist/lib-cjs/manager/model-manager.js +382 -382
  35. package/dist/lib-cjs/manager/parameter-manager.d.ts +210 -210
  36. package/dist/lib-cjs/manager/parameter-manager.js +514 -514
  37. package/dist/lib-cjs/manager/scene-manager.d.ts +45 -45
  38. package/dist/lib-cjs/manager/scene-manager.js +64 -64
  39. package/dist/lib-cjs/manager/texture-manager.d.ts +12 -12
  40. package/dist/lib-cjs/manager/texture-manager.js +43 -43
  41. package/dist/lib-cjs/viewer-error.d.ts +48 -48
  42. package/dist/lib-cjs/viewer-error.js +60 -60
  43. package/dist/lib-cjs/viewer.d.ts +115 -117
  44. package/dist/lib-cjs/viewer.js +217 -221
  45. package/dist/lib-cjs/viewer.js.map +1 -1
  46. package/package.json +91 -91
  47. package/src/buildinfo.json +3 -3
  48. package/src/dev.ts +47 -47
  49. package/src/global-types.d.ts +39 -39
  50. package/src/index.ts +81 -82
  51. package/src/internal/cbn-custom-babylon-loader-plugin.ts +159 -159
  52. package/src/internal/cloning-helper.ts +225 -225
  53. package/src/internal/device-helper.ts +25 -25
  54. package/src/internal/geometry-helper.ts +181 -181
  55. package/src/internal/metadata-helper.ts +63 -63
  56. package/src/internal/paintable-helper.ts +310 -310
  57. package/src/internal/tags-helper.ts +41 -41
  58. package/src/manager/camera-manager.ts +365 -236
  59. package/src/manager/debug-manager.ts +245 -245
  60. package/src/manager/event-manager.ts +72 -72
  61. package/src/manager/gltf-export-manager.ts +357 -341
  62. package/src/manager/material-manager.ts +135 -135
  63. package/src/manager/model-manager.ts +458 -458
  64. package/src/manager/parameter-manager.ts +652 -652
  65. package/src/manager/scene-manager.ts +101 -101
  66. package/src/manager/texture-manager.ts +32 -32
  67. package/src/viewer-error.ts +68 -68
  68. package/src/viewer.ts +290 -296
  69. package/dist/lib-cjs/manager/screenshot-manager.d.ts +0 -36
  70. package/dist/lib-cjs/manager/screenshot-manager.js +0 -40
  71. package/dist/lib-cjs/manager/screenshot-manager.js.map +0 -1
  72. package/src/manager/screenshot-manager.ts +0 -59
@@ -1,45 +1,45 @@
1
- import { Color4, Vector3, Viewer } from '../index';
2
- /**
3
- * Settings for creating the default scene
4
- */
5
- export declare type DefaultSceneSettings = {
6
- backgroundColor: Color4;
7
- camera: {
8
- create: boolean;
9
- initialPosition: {
10
- alpha: number;
11
- beta: number;
12
- radius: number;
13
- target: Vector3;
14
- };
15
- settings: {
16
- minZ: number;
17
- lowerRadiusLimit: number;
18
- wheelPrecision: number;
19
- panningSensibility: number;
20
- };
21
- };
22
- environment: {
23
- create: boolean;
24
- url: string;
25
- intensity: number;
26
- };
27
- };
28
- /**
29
- * Manager for tasks related to the Babylon.js scene.\
30
- * This contains creating or loading (WIP: Scene Asset) scenes with certain settings for lighting, cameras and
31
- * appearance in genereal.
32
- *
33
- * @internal
34
- */
35
- export declare class SceneManager {
36
- protected viewer: Viewer;
37
- protected static _DEFAULT_SCENE_NAME: string;
38
- protected _defaultSceneSettings: DefaultSceneSettings;
39
- constructor(viewer: Viewer, defaultSceneSettings?: DeepPartial<DefaultSceneSettings>);
40
- /**
41
- * Creates a camera and minimum lighting, so that the scene is set up good enough to show content.\
42
- * Settings can be overwritten in the constructor.
43
- */
44
- applyDefaultSettingsToScene(): void;
45
- }
1
+ import { Color4, Vector3, Viewer } from '../index';
2
+ /**
3
+ * Settings for creating the default scene
4
+ */
5
+ export declare type DefaultSceneSettings = {
6
+ backgroundColor: Color4;
7
+ camera: {
8
+ create: boolean;
9
+ initialPosition: {
10
+ alpha: number;
11
+ beta: number;
12
+ radius: number;
13
+ target: Vector3;
14
+ };
15
+ settings: {
16
+ minZ: number;
17
+ lowerRadiusLimit: number;
18
+ wheelPrecision: number;
19
+ panningSensibility: number;
20
+ };
21
+ };
22
+ environment: {
23
+ create: boolean;
24
+ url: string;
25
+ intensity: number;
26
+ };
27
+ };
28
+ /**
29
+ * Manager for tasks related to the Babylon.js scene.\
30
+ * This contains creating or loading (WIP: Scene Asset) scenes with certain settings for lighting, cameras and
31
+ * appearance in genereal.
32
+ *
33
+ * @internal
34
+ */
35
+ export declare class SceneManager {
36
+ protected viewer: Viewer;
37
+ protected static _DEFAULT_SCENE_NAME: string;
38
+ protected _defaultSceneSettings: DefaultSceneSettings;
39
+ constructor(viewer: Viewer, defaultSceneSettings?: DeepPartial<DefaultSceneSettings>);
40
+ /**
41
+ * Creates a camera and minimum lighting, so that the scene is set up good enough to show content.\
42
+ * Settings can be overwritten in the constructor.
43
+ */
44
+ applyDefaultSettingsToScene(): void;
45
+ }
@@ -1,65 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SceneManager = void 0;
4
- const index_1 = require("../index");
5
- const lodash_es_1 = require("lodash-es");
6
- /**
7
- * Manager for tasks related to the Babylon.js scene.\
8
- * This contains creating or loading (WIP: Scene Asset) scenes with certain settings for lighting, cameras and
9
- * appearance in genereal.
10
- *
11
- * @internal
12
- */
13
- class SceneManager {
14
- constructor(viewer, defaultSceneSettings) {
15
- this.viewer = viewer;
16
- // default scene settings
17
- // will be overwritten in the constructor
18
- this._defaultSceneSettings = {
19
- backgroundColor: new index_1.Color4(0, 0, 0, 0),
20
- camera: {
21
- create: true,
22
- initialPosition: index_1.CameraManager.DEFAULT_CAMERA_POSITION,
23
- settings: {
24
- minZ: 0.1,
25
- lowerRadiusLimit: 2,
26
- wheelPrecision: 100,
27
- panningSensibility: 5000,
28
- },
29
- },
30
- environment: {
31
- create: true,
32
- url: 'https://assets.babylonjs.com/environments/environmentSpecular.env',
33
- intensity: 1,
34
- },
35
- };
36
- (0, lodash_es_1.merge)(this._defaultSceneSettings, defaultSceneSettings);
37
- }
38
- /**
39
- * Creates a camera and minimum lighting, so that the scene is set up good enough to show content.\
40
- * Settings can be overwritten in the constructor.
41
- */
42
- applyDefaultSettingsToScene() {
43
- const cameraSettings = this._defaultSceneSettings.camera;
44
- const envSettings = this._defaultSceneSettings.environment;
45
- this.viewer.scene.clearColor = this._defaultSceneSettings.backgroundColor;
46
- // camera
47
- if (cameraSettings.create) {
48
- const camera = new index_1.ArcRotateCamera(`${SceneManager._DEFAULT_SCENE_NAME}.camera`, cameraSettings.initialPosition.alpha, cameraSettings.initialPosition.beta, cameraSettings.initialPosition.radius, cameraSettings.initialPosition.target, this.viewer.scene);
49
- camera.attachControl(this.viewer.engine._workingCanvas, true);
50
- camera.minZ = cameraSettings.settings.minZ;
51
- camera.lowerRadiusLimit = cameraSettings.settings.lowerRadiusLimit;
52
- camera.wheelPrecision = cameraSettings.settings.wheelPrecision;
53
- camera.panningSensibility = cameraSettings.settings.panningSensibility;
54
- }
55
- // environment
56
- if (envSettings.create) {
57
- const envTexture = index_1.CubeTexture.CreateFromPrefilteredData(envSettings.url, this.viewer.scene);
58
- this.viewer.scene.environmentTexture = envTexture;
59
- this.viewer.scene.environmentIntensity = envSettings.intensity;
60
- }
61
- }
62
- }
63
- exports.SceneManager = SceneManager;
64
- SceneManager._DEFAULT_SCENE_NAME = '__defaultScene__';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SceneManager = void 0;
4
+ const index_1 = require("../index");
5
+ const lodash_es_1 = require("lodash-es");
6
+ /**
7
+ * Manager for tasks related to the Babylon.js scene.\
8
+ * This contains creating or loading (WIP: Scene Asset) scenes with certain settings for lighting, cameras and
9
+ * appearance in genereal.
10
+ *
11
+ * @internal
12
+ */
13
+ class SceneManager {
14
+ constructor(viewer, defaultSceneSettings) {
15
+ this.viewer = viewer;
16
+ // default scene settings
17
+ // will be overwritten in the constructor
18
+ this._defaultSceneSettings = {
19
+ backgroundColor: new index_1.Color4(0, 0, 0, 0),
20
+ camera: {
21
+ create: true,
22
+ initialPosition: index_1.CameraManager.DEFAULT_CAMERA_POSITION,
23
+ settings: {
24
+ minZ: 0.1,
25
+ lowerRadiusLimit: 2,
26
+ wheelPrecision: 100,
27
+ panningSensibility: 5000,
28
+ },
29
+ },
30
+ environment: {
31
+ create: true,
32
+ url: 'https://assets.babylonjs.com/environments/environmentSpecular.env',
33
+ intensity: 1,
34
+ },
35
+ };
36
+ (0, lodash_es_1.merge)(this._defaultSceneSettings, defaultSceneSettings);
37
+ }
38
+ /**
39
+ * Creates a camera and minimum lighting, so that the scene is set up good enough to show content.\
40
+ * Settings can be overwritten in the constructor.
41
+ */
42
+ applyDefaultSettingsToScene() {
43
+ const cameraSettings = this._defaultSceneSettings.camera;
44
+ const envSettings = this._defaultSceneSettings.environment;
45
+ this.viewer.scene.clearColor = this._defaultSceneSettings.backgroundColor;
46
+ // camera
47
+ if (cameraSettings.create) {
48
+ const camera = new index_1.ArcRotateCamera(`${SceneManager._DEFAULT_SCENE_NAME}.camera`, cameraSettings.initialPosition.alpha, cameraSettings.initialPosition.beta, cameraSettings.initialPosition.radius, cameraSettings.initialPosition.target, this.viewer.scene);
49
+ camera.attachControl(this.viewer.engine._workingCanvas, true);
50
+ camera.minZ = cameraSettings.settings.minZ;
51
+ camera.lowerRadiusLimit = cameraSettings.settings.lowerRadiusLimit;
52
+ camera.wheelPrecision = cameraSettings.settings.wheelPrecision;
53
+ camera.panningSensibility = cameraSettings.settings.panningSensibility;
54
+ }
55
+ // environment
56
+ if (envSettings.create) {
57
+ const envTexture = index_1.CubeTexture.CreateFromPrefilteredData(envSettings.url, this.viewer.scene);
58
+ this.viewer.scene.environmentTexture = envTexture;
59
+ this.viewer.scene.environmentIntensity = envSettings.intensity;
60
+ }
61
+ }
62
+ }
63
+ exports.SceneManager = SceneManager;
64
+ SceneManager._DEFAULT_SCENE_NAME = '__defaultScene__';
65
65
  //# sourceMappingURL=scene-manager.js.map
@@ -1,12 +1,12 @@
1
- import { BaseTexture, Viewer } from '../index';
2
- /**
3
- * Manager for texture related tasks, like renaming textures that are based on Combeenation image assets.\
4
- * Doesn't have any public functionalities ATM.
5
- *
6
- * @internal
7
- */
8
- export declare class TextureManager {
9
- protected viewer: Viewer;
10
- constructor(viewer: Viewer);
11
- protected _onTextureAdded(texture: BaseTexture): Promise<void>;
12
- }
1
+ import { BaseTexture, Viewer } from '../index';
2
+ /**
3
+ * Manager for texture related tasks, like renaming textures that are based on Combeenation image assets.\
4
+ * Doesn't have any public functionalities ATM.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare class TextureManager {
9
+ protected viewer: Viewer;
10
+ constructor(viewer: Viewer);
11
+ protected _onTextureAdded(texture: BaseTexture): Promise<void>;
12
+ }
@@ -1,44 +1,44 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TextureManager = void 0;
13
- /**
14
- * Manager for texture related tasks, like renaming textures that are based on Combeenation image assets.\
15
- * Doesn't have any public functionalities ATM.
16
- *
17
- * @internal
18
- */
19
- class TextureManager {
20
- constructor(viewer) {
21
- this.viewer = viewer;
22
- this.viewer.scene.onNewTextureAddedObservable.add(texture => this._onTextureAdded(texture));
23
- }
24
- _onTextureAdded(texture) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- // Workaround:
27
- // The texture object is not fully created when the "added observable" is called. E.g. the function
28
- // `onLoadObservable` is not there at that point and the name is not even set.
29
- // More details: https://forum.babylonjs.com/t/basetexture-whenallready-returns-too-early/34501/4
30
- yield new Promise(resolve => window.setTimeout(resolve, 0));
31
- // textures based CBN image assets are hard to analyse in the inspector, since the asset url is set as name
32
- // with this functionality we try to find these CBN image assets and crop the name accordingly
33
- // => see CB-9558
34
- const isUrl = texture.name.startsWith('https://');
35
- const textureQueryString = '?name=';
36
- const indexOfTextureQueryParam = texture.name.lastIndexOf(textureQueryString);
37
- if (isUrl && indexOfTextureQueryParam > -1) {
38
- texture.name = texture.name.substring(indexOfTextureQueryParam + textureQueryString.length);
39
- }
40
- });
41
- }
42
- }
43
- exports.TextureManager = TextureManager;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TextureManager = void 0;
13
+ /**
14
+ * Manager for texture related tasks, like renaming textures that are based on Combeenation image assets.\
15
+ * Doesn't have any public functionalities ATM.
16
+ *
17
+ * @internal
18
+ */
19
+ class TextureManager {
20
+ constructor(viewer) {
21
+ this.viewer = viewer;
22
+ this.viewer.scene.onNewTextureAddedObservable.add(texture => this._onTextureAdded(texture));
23
+ }
24
+ _onTextureAdded(texture) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ // Workaround:
27
+ // The texture object is not fully created when the "added observable" is called. E.g. the function
28
+ // `onLoadObservable` is not there at that point and the name is not even set.
29
+ // More details: https://forum.babylonjs.com/t/basetexture-whenallready-returns-too-early/34501/4
30
+ yield new Promise(resolve => window.setTimeout(resolve, 0));
31
+ // textures based CBN image assets are hard to analyse in the inspector, since the asset url is set as name
32
+ // with this functionality we try to find these CBN image assets and crop the name accordingly
33
+ // => see CB-9558
34
+ const isUrl = texture.name.startsWith('https://');
35
+ const textureQueryString = '?name=';
36
+ const indexOfTextureQueryParam = texture.name.lastIndexOf(textureQueryString);
37
+ if (isUrl && indexOfTextureQueryParam > -1) {
38
+ texture.name = texture.name.substring(indexOfTextureQueryParam + textureQueryString.length);
39
+ }
40
+ });
41
+ }
42
+ }
43
+ exports.TextureManager = TextureManager;
44
44
  //# sourceMappingURL=texture-manager.js.map
@@ -1,48 +1,48 @@
1
- /**
2
- * Combeenation configurators are explicitly catching and handling some specific errors thrown by the viewer.
3
- * We use this custom error class which adds a unique ID to each error so that we can safely distinguish the different
4
- * errors without having to look at the thrown text.
5
- */
6
- declare type ViewerErrorData = {
7
- /** One of `GlobalViewerErrorIds` */
8
- id: string;
9
- message: string;
10
- };
11
- /**
12
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13
- * !!! Note: Combeenation viewer ctrl needs to be adjusted, whenever changing existing keys here. !!!
14
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15
- *
16
- * IDs here shall only include "word characters" (`/w` in RegEx) as `GetViewerErrorIdFromMsg` wouldn't work correctly
17
- * otherwise.
18
- * @internal
19
- */
20
- export declare const ViewerErrorIds: {
21
- InvalidParameterValue: string;
22
- ModelNotRegistered: string;
23
- ModelAlreadyExists: string;
24
- ModelIsNotAClone: string;
25
- AssetLoadingFailed: string;
26
- MaterialCouldNotBeParsed: string;
27
- };
28
- /** @internal */
29
- export declare class ViewerError extends Error {
30
- viewerErrorId: string;
31
- constructor(data: ViewerErrorData);
32
- /**
33
- * Splits the given error message into a known viewer error id and the message itself.
34
- *
35
- * E.g.:
36
- * Message `[InvalidParameterValue] Some error msg` returns `{ id: 'InvalidParameterValue', msg: 'Some error msg' }`
37
- *
38
- * @param message An error message in the form `[KnownErrorId] Some error msg`
39
- * @returns id = The extracted error id (one of `GlobalViewerErrorIds`) or `undefined` if no valid ID has been found
40
- * msg = The error message without the prefixed ID. Returns the whole given `message` if it isn't prefixed
41
- * with a known ID in the correct format.
42
- */
43
- static SplitViewerErrorMsg(message: string): {
44
- id: string | undefined;
45
- msg: string;
46
- };
47
- }
48
- export {};
1
+ /**
2
+ * Combeenation configurators are explicitly catching and handling some specific errors thrown by the viewer.
3
+ * We use this custom error class which adds a unique ID to each error so that we can safely distinguish the different
4
+ * errors without having to look at the thrown text.
5
+ */
6
+ declare type ViewerErrorData = {
7
+ /** One of `GlobalViewerErrorIds` */
8
+ id: string;
9
+ message: string;
10
+ };
11
+ /**
12
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13
+ * !!! Note: Combeenation viewer ctrl needs to be adjusted, whenever changing existing keys here. !!!
14
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15
+ *
16
+ * IDs here shall only include "word characters" (`/w` in RegEx) as `GetViewerErrorIdFromMsg` wouldn't work correctly
17
+ * otherwise.
18
+ * @internal
19
+ */
20
+ export declare const ViewerErrorIds: {
21
+ InvalidParameterValue: string;
22
+ ModelNotRegistered: string;
23
+ ModelAlreadyExists: string;
24
+ ModelIsNotAClone: string;
25
+ AssetLoadingFailed: string;
26
+ MaterialCouldNotBeParsed: string;
27
+ };
28
+ /** @internal */
29
+ export declare class ViewerError extends Error {
30
+ viewerErrorId: string;
31
+ constructor(data: ViewerErrorData);
32
+ /**
33
+ * Splits the given error message into a known viewer error id and the message itself.
34
+ *
35
+ * E.g.:
36
+ * Message `[InvalidParameterValue] Some error msg` returns `{ id: 'InvalidParameterValue', msg: 'Some error msg' }`
37
+ *
38
+ * @param message An error message in the form `[KnownErrorId] Some error msg`
39
+ * @returns id = The extracted error id (one of `GlobalViewerErrorIds`) or `undefined` if no valid ID has been found
40
+ * msg = The error message without the prefixed ID. Returns the whole given `message` if it isn't prefixed
41
+ * with a known ID in the correct format.
42
+ */
43
+ static SplitViewerErrorMsg(message: string): {
44
+ id: string | undefined;
45
+ msg: string;
46
+ };
47
+ }
48
+ export {};
@@ -1,61 +1,61 @@
1
- "use strict";
2
- /**
3
- * Combeenation configurators are explicitly catching and handling some specific errors thrown by the viewer.
4
- * We use this custom error class which adds a unique ID to each error so that we can safely distinguish the different
5
- * errors without having to look at the thrown text.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ViewerError = exports.ViewerErrorIds = void 0;
9
- /**
10
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
- * !!! Note: Combeenation viewer ctrl needs to be adjusted, whenever changing existing keys here. !!!
12
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13
- *
14
- * IDs here shall only include "word characters" (`/w` in RegEx) as `GetViewerErrorIdFromMsg` wouldn't work correctly
15
- * otherwise.
16
- * @internal
17
- */
18
- exports.ViewerErrorIds = {
19
- InvalidParameterValue: 'InvalidParameterValue',
20
- ModelNotRegistered: 'ModelNotRegistered',
21
- ModelAlreadyExists: 'ModelAlreadyExists',
22
- ModelIsNotAClone: 'ModelIsNotAClone',
23
- AssetLoadingFailed: 'AssetLoadingFailed',
24
- MaterialCouldNotBeParsed: 'MaterialCouldNotBeParsed',
25
- };
26
- /** @internal */
27
- class ViewerError extends Error {
28
- constructor(data) {
29
- // Unfortunately we can't access the custom `viewerErrorId` property when catching global errors in Combeenation so
30
- // we also have to add the ID to the message itself.
31
- super(`[${data.id}] ${data.message}`);
32
- this.viewerErrorId = data.id;
33
- }
34
- /**
35
- * Splits the given error message into a known viewer error id and the message itself.
36
- *
37
- * E.g.:
38
- * Message `[InvalidParameterValue] Some error msg` returns `{ id: 'InvalidParameterValue', msg: 'Some error msg' }`
39
- *
40
- * @param message An error message in the form `[KnownErrorId] Some error msg`
41
- * @returns id = The extracted error id (one of `GlobalViewerErrorIds`) or `undefined` if no valid ID has been found
42
- * msg = The error message without the prefixed ID. Returns the whole given `message` if it isn't prefixed
43
- * with a known ID in the correct format.
44
- */
45
- static SplitViewerErrorMsg(message) {
46
- var _a, _b;
47
- const knownIds = Object.values(exports.ViewerErrorIds).join('|');
48
- // RegEx:
49
- // `^` = Start of string
50
- // `\\[` = Literal `[`
51
- // `(?<id>abc|xyz|...)` = Named capture group `id` which looks for one of the existing error ids
52
- // `] ` = Literal `] `
53
- // `(?<msg>.*)` = Named capture group `msg` which looks for everything after the matched group id
54
- const result = new RegExp('^\\[(?<id>' + knownIds + ')] (?<msg>.*)').exec(message);
55
- const id = (_a = result === null || result === void 0 ? void 0 : result.groups) === null || _a === void 0 ? void 0 : _a.id;
56
- const msg = ((_b = result === null || result === void 0 ? void 0 : result.groups) === null || _b === void 0 ? void 0 : _b.msg) || message;
57
- return { id, msg };
58
- }
59
- }
60
- exports.ViewerError = ViewerError;
1
+ "use strict";
2
+ /**
3
+ * Combeenation configurators are explicitly catching and handling some specific errors thrown by the viewer.
4
+ * We use this custom error class which adds a unique ID to each error so that we can safely distinguish the different
5
+ * errors without having to look at the thrown text.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ViewerError = exports.ViewerErrorIds = void 0;
9
+ /**
10
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
+ * !!! Note: Combeenation viewer ctrl needs to be adjusted, whenever changing existing keys here. !!!
12
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13
+ *
14
+ * IDs here shall only include "word characters" (`/w` in RegEx) as `GetViewerErrorIdFromMsg` wouldn't work correctly
15
+ * otherwise.
16
+ * @internal
17
+ */
18
+ exports.ViewerErrorIds = {
19
+ InvalidParameterValue: 'InvalidParameterValue',
20
+ ModelNotRegistered: 'ModelNotRegistered',
21
+ ModelAlreadyExists: 'ModelAlreadyExists',
22
+ ModelIsNotAClone: 'ModelIsNotAClone',
23
+ AssetLoadingFailed: 'AssetLoadingFailed',
24
+ MaterialCouldNotBeParsed: 'MaterialCouldNotBeParsed',
25
+ };
26
+ /** @internal */
27
+ class ViewerError extends Error {
28
+ constructor(data) {
29
+ // Unfortunately we can't access the custom `viewerErrorId` property when catching global errors in Combeenation so
30
+ // we also have to add the ID to the message itself.
31
+ super(`[${data.id}] ${data.message}`);
32
+ this.viewerErrorId = data.id;
33
+ }
34
+ /**
35
+ * Splits the given error message into a known viewer error id and the message itself.
36
+ *
37
+ * E.g.:
38
+ * Message `[InvalidParameterValue] Some error msg` returns `{ id: 'InvalidParameterValue', msg: 'Some error msg' }`
39
+ *
40
+ * @param message An error message in the form `[KnownErrorId] Some error msg`
41
+ * @returns id = The extracted error id (one of `GlobalViewerErrorIds`) or `undefined` if no valid ID has been found
42
+ * msg = The error message without the prefixed ID. Returns the whole given `message` if it isn't prefixed
43
+ * with a known ID in the correct format.
44
+ */
45
+ static SplitViewerErrorMsg(message) {
46
+ var _a, _b;
47
+ const knownIds = Object.values(exports.ViewerErrorIds).join('|');
48
+ // RegEx:
49
+ // `^` = Start of string
50
+ // `\\[` = Literal `[`
51
+ // `(?<id>abc|xyz|...)` = Named capture group `id` which looks for one of the existing error ids
52
+ // `] ` = Literal `] `
53
+ // `(?<msg>.*)` = Named capture group `msg` which looks for everything after the matched group id
54
+ const result = new RegExp('^\\[(?<id>' + knownIds + ')] (?<msg>.*)').exec(message);
55
+ const id = (_a = result === null || result === void 0 ? void 0 : result.groups) === null || _a === void 0 ? void 0 : _a.id;
56
+ const msg = ((_b = result === null || result === void 0 ? void 0 : result.groups) === null || _b === void 0 ? void 0 : _b.msg) || message;
57
+ return { id, msg };
58
+ }
59
+ }
60
+ exports.ViewerError = ViewerError;
61
61
  //# sourceMappingURL=viewer-error.js.map