@combeenation/3d-viewer 3.1.1-alpha6 → 3.1.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 (93) hide show
  1. package/README.md +111 -111
  2. package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
  3. package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
  4. package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
  5. package/dist/lib-cjs/api/classes/dottedPath.js +190 -190
  6. package/dist/lib-cjs/api/classes/element.d.ts +125 -126
  7. package/dist/lib-cjs/api/classes/element.js +678 -659
  8. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  9. package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
  10. package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
  11. package/dist/lib-cjs/api/classes/event.d.ts +312 -312
  12. package/dist/lib-cjs/api/classes/event.js +357 -357
  13. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  14. package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
  15. package/dist/lib-cjs/api/classes/parameter.d.ts +165 -165
  16. package/dist/lib-cjs/api/classes/parameter.js +267 -267
  17. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  18. package/dist/lib-cjs/api/classes/parameterObservable.js +126 -126
  19. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  20. package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
  21. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
  22. package/dist/lib-cjs/api/classes/placementAnimation.js +138 -138
  23. package/dist/lib-cjs/api/classes/variant.d.ts +180 -190
  24. package/dist/lib-cjs/api/classes/variant.js +863 -873
  25. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  26. package/dist/lib-cjs/api/classes/variantInstance.d.ts +41 -41
  27. package/dist/lib-cjs/api/classes/variantInstance.js +98 -98
  28. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  29. package/dist/lib-cjs/api/classes/variantParameterizable.js +92 -92
  30. package/dist/lib-cjs/api/classes/viewer.d.ts +128 -128
  31. package/dist/lib-cjs/api/classes/viewer.js +486 -486
  32. package/dist/lib-cjs/api/classes/viewerLight.d.ts +65 -66
  33. package/dist/lib-cjs/api/classes/viewerLight.js +322 -389
  34. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
  35. package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
  36. package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
  37. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  38. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  39. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +6 -6
  40. package/dist/lib-cjs/api/internal/sceneSetup.js +227 -227
  41. package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
  42. package/dist/lib-cjs/api/manager/animationManager.js +121 -121
  43. package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
  44. package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
  45. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
  46. package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
  47. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  48. package/dist/lib-cjs/api/store/specStorage.js +51 -51
  49. package/dist/lib-cjs/api/util/babylonHelper.d.ts +125 -125
  50. package/dist/lib-cjs/api/util/babylonHelper.js +368 -368
  51. package/dist/lib-cjs/api/util/globalTypes.d.ts +275 -275
  52. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  53. package/dist/lib-cjs/api/util/resourceHelper.d.ts +30 -30
  54. package/dist/lib-cjs/api/util/resourceHelper.js +247 -203
  55. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  56. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
  57. package/dist/lib-cjs/api/util/stringHelper.js +25 -25
  58. package/dist/lib-cjs/buildinfo.json +3 -3
  59. package/dist/lib-cjs/index.d.ts +46 -46
  60. package/dist/lib-cjs/index.js +82 -82
  61. package/package.json +83 -83
  62. package/src/api/classes/animationInterface.ts +11 -11
  63. package/src/api/classes/dottedPath.ts +189 -189
  64. package/src/api/classes/element.ts +608 -602
  65. package/src/api/classes/elementParameterizable.ts +78 -78
  66. package/src/api/classes/event.ts +355 -355
  67. package/src/api/classes/eventBroadcaster.ts +54 -54
  68. package/src/api/classes/parameter.ts +277 -277
  69. package/src/api/classes/parameterObservable.ts +121 -121
  70. package/src/api/classes/placementAnimation.ts +133 -133
  71. package/src/api/classes/variant.ts +659 -670
  72. package/src/api/classes/variantInstance.ts +81 -81
  73. package/src/api/classes/viewer.ts +421 -421
  74. package/src/api/internal/debugViewer.ts +81 -81
  75. package/src/api/internal/lensRendering.ts +10 -10
  76. package/src/api/internal/sceneSetup.ts +203 -203
  77. package/src/api/manager/animationManager.ts +116 -116
  78. package/src/api/manager/sceneManager.ts +105 -105
  79. package/src/api/manager/variantInstanceManager.ts +236 -236
  80. package/src/api/store/specStorage.ts +53 -53
  81. package/src/api/util/babylonHelper.ts +392 -392
  82. package/src/api/util/globalTypes.ts +314 -314
  83. package/src/api/util/resourceHelper.ts +168 -155
  84. package/src/buildinfo.json +2 -2
  85. package/src/commonjs.tsconfig.json +13 -13
  86. package/src/declaration.tsconfig.json +10 -10
  87. package/src/dev.ts +44 -46
  88. package/src/es6.tsconfig.json +13 -13
  89. package/src/index.ts +87 -87
  90. package/src/pagesconfig.json +47 -47
  91. package/src/tsconfig.json +43 -43
  92. package/src/tsconfig.types.json +9 -9
  93. package/src/types.d.ts +4 -4
package/README.md CHANGED
@@ -1,111 +1,111 @@
1
- # 3D viewer
2
-
3
- ## Usage
4
-
5
- - Create a label called `JS_3dViewerLbl` which we'll use to render the 3d viewer into:
6
-
7
- - Set its value to `<canvas></canvas>`
8
- - Add CSS class `ViewerLbl`
9
- - Add the following CSS styles to your configurator:
10
-
11
- ```css
12
- .ViewerLbl .cfgrctrl-innerlabel {
13
- height: 100%;
14
- }
15
-
16
- .ViewerLbl canvas {
17
- width: 100%;
18
- height: 100%;
19
- }
20
- ```
21
-
22
- - Install viewer dependencies: `npm i @combeenation/3d-viewer`
23
- - Create specification (example, bare minimum):
24
- ```js
25
- /**
26
- * @return {StructureJson}
27
- */
28
- export function createSpec() {
29
- return {
30
- scene: {
31
- engine: {
32
- antialiasing: true,
33
- options: {
34
- preserveDrawingBuffer: true,
35
- stencil: true,
36
- },
37
- },
38
- scene: {
39
- globals: {},
40
- lights: {
41
- default: {
42
- type: 'hemispheric',
43
- },
44
- },
45
- cameras: {},
46
- },
47
- },
48
- setup: {
49
- instances: [
50
- {
51
- name: 'DirtBikeInstance',
52
- variant: 'DirtBike',
53
- lazy: false,
54
- parameters: {
55
- visible: true,
56
- scaling: '( 1, 1, 1 )',
57
- position: '( 0, 0, 0 )',
58
- rotation: '( 0, 0, 0 )',
59
- },
60
- },
61
- ],
62
- },
63
- variants: {
64
- DirtBike: {
65
- glTF: 'https://combeepublic.blob.core.windows.net/resources/the-3d-file.glb',
66
- elements: {
67
- Main: ['__root__'],
68
- },
69
- },
70
- },
71
- };
72
- }
73
- ```
74
-
75
- - Bootstrap viewer (example code):
76
-
77
- ```js
78
- import { Viewer } from '@combeenation/3d-viewer';
79
- import { CtrlUtils } from '@combeenation/custom-js-utils';
80
- import { createSpec } from 'path/to/spec-file';
81
-
82
- /**
83
- * Bootstraps the viewer using the JSON spec, registers all needed events etc.
84
- */
85
- export async function bootstrapViewer() {
86
- Cbn.utils.Log.add(`Bootstrapping viewer v${Viewer.version}`, Cbn.utils.Log.Type.Misc)();
87
-
88
- const $canvas = $(CtrlUtils.getLabel('JS_3dViewerLbl').el.dom).find('canvas');
89
- const canvas = /** @type {HTMLCanvasElement} */ ($canvas.get(0));
90
- const viewer = new Viewer(canvas, createSpec());
91
- await viewer.bootstrap();
92
-
93
- // The resize listener doesn't seem to work on the canvas itself, therefore we're installing it on its parent
94
- Cbn.utils.ResizeEvents.addResizeListener(canvas.parentElement, () => viewer.resize());
95
- }
96
- ```
97
-
98
- - Call `bootstrapViewer` e.g. somewhere in `onCfgrReady` in your main file:
99
- ```js
100
- CfgrUtils.onCfgrReady(async () => {
101
- // ...
102
-
103
- const viewer = await bootstrapViewer();
104
-
105
- // ...
106
-
107
- // Make some functions accessible in the global window object (e.g. for debugging in the console etc.)
108
- // Can be extended as needed.
109
- window.CfgrJS = { /* ... */ viewer /* ... */ };
110
- });
111
- ```
1
+ # 3D viewer
2
+
3
+ ## Usage
4
+
5
+ - Create a label called `JS_3dViewerLbl` which we'll use to render the 3d viewer into:
6
+
7
+ - Set its value to `<canvas></canvas>`
8
+ - Add CSS class `ViewerLbl`
9
+ - Add the following CSS styles to your configurator:
10
+
11
+ ```css
12
+ .ViewerLbl .cfgrctrl-innerlabel {
13
+ height: 100%;
14
+ }
15
+
16
+ .ViewerLbl canvas {
17
+ width: 100%;
18
+ height: 100%;
19
+ }
20
+ ```
21
+
22
+ - Install viewer dependencies: `npm i @combeenation/3d-viewer`
23
+ - Create specification (example, bare minimum):
24
+ ```js
25
+ /**
26
+ * @return {StructureJson}
27
+ */
28
+ export function createSpec() {
29
+ return {
30
+ scene: {
31
+ engine: {
32
+ antialiasing: true,
33
+ options: {
34
+ preserveDrawingBuffer: true,
35
+ stencil: true,
36
+ },
37
+ },
38
+ scene: {
39
+ globals: {},
40
+ lights: {
41
+ default: {
42
+ type: 'hemispheric',
43
+ },
44
+ },
45
+ cameras: {},
46
+ },
47
+ },
48
+ setup: {
49
+ instances: [
50
+ {
51
+ name: 'DirtBikeInstance',
52
+ variant: 'DirtBike',
53
+ lazy: false,
54
+ parameters: {
55
+ visible: true,
56
+ scaling: '( 1, 1, 1 )',
57
+ position: '( 0, 0, 0 )',
58
+ rotation: '( 0, 0, 0 )',
59
+ },
60
+ },
61
+ ],
62
+ },
63
+ variants: {
64
+ DirtBike: {
65
+ glTF: 'https://combeepublic.blob.core.windows.net/resources/the-3d-file.glb',
66
+ elements: {
67
+ Main: ['__root__'],
68
+ },
69
+ },
70
+ },
71
+ };
72
+ }
73
+ ```
74
+
75
+ - Bootstrap viewer (example code):
76
+
77
+ ```js
78
+ import { Viewer } from '@combeenation/3d-viewer';
79
+ import { CtrlUtils } from '@combeenation/custom-js-utils';
80
+ import { createSpec } from 'path/to/spec-file';
81
+
82
+ /**
83
+ * Bootstraps the viewer using the JSON spec, registers all needed events etc.
84
+ */
85
+ export async function bootstrapViewer() {
86
+ Cbn.utils.Log.add(`Bootstrapping viewer v${Viewer.version}`, Cbn.utils.Log.Type.Misc)();
87
+
88
+ const $canvas = $(CtrlUtils.getLabel('JS_3dViewerLbl').el.dom).find('canvas');
89
+ const canvas = /** @type {HTMLCanvasElement} */ ($canvas.get(0));
90
+ const viewer = new Viewer(canvas, createSpec());
91
+ await viewer.bootstrap();
92
+
93
+ // The resize listener doesn't seem to work on the canvas itself, therefore we're installing it on its parent
94
+ Cbn.utils.ResizeEvents.addResizeListener(canvas.parentElement, () => viewer.resize());
95
+ }
96
+ ```
97
+
98
+ - Call `bootstrapViewer` e.g. somewhere in `onCfgrReady` in your main file:
99
+ ```js
100
+ CfgrUtils.onCfgrReady(async () => {
101
+ // ...
102
+
103
+ const viewer = await bootstrapViewer();
104
+
105
+ // ...
106
+
107
+ // Make some functions accessible in the global window object (e.g. for debugging in the console etc.)
108
+ // Can be extended as needed.
109
+ window.CfgrJS = { /* ... */ viewer /* ... */ };
110
+ });
111
+ ```
@@ -1,8 +1,8 @@
1
- /**
2
- * An Interface defining the basic functionality of an animation.
3
- */
4
- interface AnimationInterface {
5
- play(): Promise<AnimationInterface>;
6
- pause(): AnimationInterface;
7
- kill(): AnimationInterface;
8
- }
1
+ /**
2
+ * An Interface defining the basic functionality of an animation.
3
+ */
4
+ interface AnimationInterface {
5
+ play(): Promise<AnimationInterface>;
6
+ pause(): AnimationInterface;
7
+ kill(): AnimationInterface;
8
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
1
+ "use strict";
2
2
  //# sourceMappingURL=animationInterface.js.map
@@ -1,79 +1,79 @@
1
- export declare class DottedPath {
2
- static DELIMITER: string;
3
- static SAFE_CHAR: string;
4
- parts: string[];
5
- /**
6
- * Magic factory function that creates a DottedPath based on the argument type.
7
- */
8
- static create(dottedPath?: DottedPathArgument): DottedPath;
9
- /**
10
- * Creates a DottedPath from a string.
11
- * Allows patterns with unsafe characters wrapped in apostrophes or quotes.
12
- * E.g. "part1.part2.'part.3'.part_4"
13
- */
14
- static createFromPath(path: string): DottedPath;
15
- /**
16
- * Creates a DottedPath from a string list.
17
- */
18
- static createFromParts(parts: string[]): DottedPath;
19
- /**
20
- * Creates an empty DottedPath.
21
- */
22
- static createEmpty(): DottedPath;
23
- /**
24
- * Sanitizes given part: replaces all characters like {@link DottedPath.DELIMITER}
25
- * with a "safe" character like {@link DottedPath.SAFE_CHAR}.
26
- * (i) Does not trim whitespace.
27
- */
28
- static sanitizePart(part: string): string;
29
- /**
30
- * Constructor
31
- */
32
- private constructor();
33
- /**
34
- * The path.
35
- * (i) Does not return an empty dot for no path.
36
- */
37
- get path(): string;
38
- /**
39
- * The first part.
40
- */
41
- get firstPart(): string | null;
42
- /**
43
- * The last part.
44
- */
45
- get lastPart(): string | null;
46
- /**
47
- * Gets the tokens to each leaf of the DottedPath tree.
48
- * E.g. "part1.part2.part_3" will return an array like
49
- * ["part1", "part1.part2", "part1.part2.part_3"]
50
- */
51
- get leafTokens(): string[];
52
- /**
53
- * Removes the first part and returns it.
54
- */
55
- shiftPart(): string | undefined;
56
- /**
57
- * Adds part to the beginning of parts list.
58
- */
59
- unshiftPart(part: string, duplicateCheck?: boolean): DottedPath;
60
- /**
61
- * Adds part to the end of parts list.
62
- * (i) Does not add a part if the last char already is the delimiter or if an empty string was passed.
63
- */
64
- addPart(part: string, duplicateCheck?: boolean): DottedPath;
65
- /**
66
- * Adds multiple parts to the end of parts list.
67
- */
68
- addParts(parts: string[], duplicateCheck?: boolean): DottedPath;
69
- /**
70
- * Removes the last part and returns it.
71
- */
72
- popPart(): string | undefined;
73
- toString(): string;
74
- valueOf(): string;
75
- /**
76
- * Clones the DottedPath.
77
- */
78
- clone(): DottedPath;
79
- }
1
+ export declare class DottedPath {
2
+ static DELIMITER: string;
3
+ static SAFE_CHAR: string;
4
+ parts: string[];
5
+ /**
6
+ * Magic factory function that creates a DottedPath based on the argument type.
7
+ */
8
+ static create(dottedPath?: DottedPathArgument): DottedPath;
9
+ /**
10
+ * Creates a DottedPath from a string.
11
+ * Allows patterns with unsafe characters wrapped in apostrophes or quotes.
12
+ * E.g. "part1.part2.'part.3'.part_4"
13
+ */
14
+ static createFromPath(path: string): DottedPath;
15
+ /**
16
+ * Creates a DottedPath from a string list.
17
+ */
18
+ static createFromParts(parts: string[]): DottedPath;
19
+ /**
20
+ * Creates an empty DottedPath.
21
+ */
22
+ static createEmpty(): DottedPath;
23
+ /**
24
+ * Sanitizes given part: replaces all characters like {@link DottedPath.DELIMITER}
25
+ * with a "safe" character like {@link DottedPath.SAFE_CHAR}.
26
+ * (i) Does not trim whitespace.
27
+ */
28
+ static sanitizePart(part: string): string;
29
+ /**
30
+ * Constructor
31
+ */
32
+ private constructor();
33
+ /**
34
+ * The path.
35
+ * (i) Does not return an empty dot for no path.
36
+ */
37
+ get path(): string;
38
+ /**
39
+ * The first part.
40
+ */
41
+ get firstPart(): string | null;
42
+ /**
43
+ * The last part.
44
+ */
45
+ get lastPart(): string | null;
46
+ /**
47
+ * Gets the tokens to each leaf of the DottedPath tree.
48
+ * E.g. "part1.part2.part_3" will return an array like
49
+ * ["part1", "part1.part2", "part1.part2.part_3"]
50
+ */
51
+ get leafTokens(): string[];
52
+ /**
53
+ * Removes the first part and returns it.
54
+ */
55
+ shiftPart(): string | undefined;
56
+ /**
57
+ * Adds part to the beginning of parts list.
58
+ */
59
+ unshiftPart(part: string, duplicateCheck?: boolean): DottedPath;
60
+ /**
61
+ * Adds part to the end of parts list.
62
+ * (i) Does not add a part if the last char already is the delimiter or if an empty string was passed.
63
+ */
64
+ addPart(part: string, duplicateCheck?: boolean): DottedPath;
65
+ /**
66
+ * Adds multiple parts to the end of parts list.
67
+ */
68
+ addParts(parts: string[], duplicateCheck?: boolean): DottedPath;
69
+ /**
70
+ * Removes the last part and returns it.
71
+ */
72
+ popPart(): string | undefined;
73
+ toString(): string;
74
+ valueOf(): string;
75
+ /**
76
+ * Clones the DottedPath.
77
+ */
78
+ clone(): DottedPath;
79
+ }