@combeenation/3d-viewer 4.0.0-alpha9 → 4.0.0-beta4

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 (105) hide show
  1. package/README.md +112 -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 -130
  7. package/dist/lib-cjs/api/classes/element.js +682 -739
  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 -326
  12. package/dist/lib-cjs/api/classes/event.js +357 -371
  13. package/dist/lib-cjs/api/classes/event.js.map +1 -1
  14. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  15. package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
  16. package/dist/lib-cjs/api/classes/parameter.d.ts +165 -259
  17. package/dist/lib-cjs/api/classes/parameter.js +267 -387
  18. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  19. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  20. package/dist/lib-cjs/api/classes/parameterObservable.js +126 -101
  21. package/dist/lib-cjs/api/classes/parameterObservable.js.map +1 -1
  22. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  23. package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
  24. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
  25. package/dist/lib-cjs/api/classes/placementAnimation.js +138 -138
  26. package/dist/lib-cjs/api/classes/variant.d.ts +190 -224
  27. package/dist/lib-cjs/api/classes/variant.js +873 -1137
  28. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  29. package/dist/lib-cjs/api/classes/variantInstance.d.ts +41 -45
  30. package/dist/lib-cjs/api/classes/variantInstance.js +98 -108
  31. package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
  32. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  33. package/dist/lib-cjs/api/classes/variantParameterizable.js +92 -92
  34. package/dist/lib-cjs/api/classes/viewer.d.ts +128 -131
  35. package/dist/lib-cjs/api/classes/viewer.js +486 -538
  36. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  37. package/dist/lib-cjs/api/classes/viewerLight.d.ts +65 -66
  38. package/dist/lib-cjs/api/classes/viewerLight.js +322 -389
  39. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
  40. package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
  41. package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
  42. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  43. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  44. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +6 -10
  45. package/dist/lib-cjs/api/internal/sceneSetup.js +227 -231
  46. package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
  47. package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
  48. package/dist/lib-cjs/api/manager/animationManager.js +121 -121
  49. package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
  50. package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
  51. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
  52. package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
  53. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  54. package/dist/lib-cjs/api/store/specStorage.js +51 -51
  55. package/dist/lib-cjs/api/util/babylonHelper.d.ts +125 -175
  56. package/dist/lib-cjs/api/util/babylonHelper.js +368 -520
  57. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  58. package/dist/lib-cjs/api/util/globalTypes.d.ts +279 -321
  59. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  60. package/dist/lib-cjs/api/util/resourceHelper.d.ts +51 -26
  61. package/dist/lib-cjs/api/util/resourceHelper.js +243 -237
  62. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  63. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
  64. package/dist/lib-cjs/api/util/stringHelper.js +25 -25
  65. package/dist/lib-cjs/buildinfo.json +3 -3
  66. package/dist/lib-cjs/index.d.ts +46 -48
  67. package/dist/lib-cjs/index.js +82 -86
  68. package/dist/lib-cjs/index.js.map +1 -1
  69. package/dist/webpack-stats.json +0 -0
  70. package/package.json +83 -83
  71. package/src/api/classes/animationInterface.ts +11 -11
  72. package/src/api/classes/dottedPath.ts +189 -189
  73. package/src/api/classes/element.ts +617 -635
  74. package/src/api/classes/{parameterizable.ts → elementParameterizable.ts} +78 -89
  75. package/src/api/classes/event.ts +355 -370
  76. package/src/api/classes/eventBroadcaster.ts +54 -54
  77. package/src/api/classes/parameter.ts +277 -408
  78. package/src/api/classes/parameterObservable.ts +121 -99
  79. package/src/api/classes/placementAnimation.ts +133 -133
  80. package/src/api/classes/variant.ts +670 -806
  81. package/src/api/classes/variantInstance.ts +81 -88
  82. package/src/api/classes/viewer.ts +421 -473
  83. package/src/api/internal/debugViewer.ts +81 -81
  84. package/src/api/internal/lensRendering.ts +10 -10
  85. package/src/api/internal/sceneSetup.ts +204 -194
  86. package/src/api/manager/animationManager.ts +116 -116
  87. package/src/api/manager/sceneManager.ts +105 -105
  88. package/src/api/manager/variantInstanceManager.ts +236 -236
  89. package/src/api/store/specStorage.ts +53 -53
  90. package/src/api/util/babylonHelper.ts +392 -553
  91. package/src/api/util/globalTypes.ts +318 -369
  92. package/src/api/util/resourceHelper.ts +187 -157
  93. package/src/buildinfo.json +2 -2
  94. package/src/commonjs.tsconfig.json +13 -13
  95. package/src/declaration.tsconfig.json +10 -10
  96. package/src/dev.ts +46 -44
  97. package/src/es6.tsconfig.json +13 -13
  98. package/src/index.ts +87 -91
  99. package/src/pagesconfig.json +57 -52
  100. package/src/tsconfig.json +43 -43
  101. package/src/tsconfig.types.json +9 -9
  102. package/src/types.d.ts +4 -4
  103. package/src/api/classes/variantParameterizable.ts +0 -73
  104. package/src/api/classes/viewerLight.ts +0 -330
  105. package/src/api/util/stringHelper.ts +0 -26
@@ -1,122 +1,122 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnimationManager = void 0;
4
- var tslib_1 = require("tslib");
5
- var animation_1 = require("@babylonjs/core/Animations/animation");
6
- //import { CustomEase } from 'gsap/CustomEase';
7
- //import { ExpoScaleEase, RoughEase, SlowMo } from 'gsap/EasePack';
8
- var lodash_es_1 = require("lodash-es");
9
- var placementAnimation_1 = require("../classes/placementAnimation");
10
- //gsap.registerPlugin( CustomEase, ExpoScaleEase, RoughEase, SlowMo );
11
- var AnimationManager = /** @class */ (function () {
12
- /**
13
- * Constructor.
14
- */
15
- function AnimationManager(scene) {
16
- this.scene = scene;
17
- this.animations = [];
18
- }
19
- /**
20
- * Creates an {@link AnimationManager} based on given BabylonJS scene.
21
- */
22
- AnimationManager.create = function (scene) {
23
- return tslib_1.__awaiter(this, void 0, void 0, function () {
24
- return tslib_1.__generator(this, function (_b) {
25
- return [2 /*return*/, new AnimationManager(scene)];
26
- });
27
- });
28
- };
29
- /**
30
- * @deprecated Use viewer.moveCameraTo().
31
- */
32
- AnimationManager.prototype.resetCamera = function (animate) {
33
- if (animate === void 0) { animate = false; }
34
- //TODO currently only works for arcrotate. are there any other cameras?
35
- var activeCamera = this.scene.activeCamera;
36
- if (!activeCamera) {
37
- throw new Error('There is no active camera');
38
- }
39
- var initAlpha = activeCamera.metadata.alpha;
40
- var initBeta = activeCamera.metadata.beta;
41
- var initRadius = activeCamera.metadata.radius;
42
- if (animate) {
43
- this.animateArcRotateCamera(initAlpha, initBeta, initRadius);
44
- }
45
- else {
46
- activeCamera.alpha = initAlpha;
47
- activeCamera.beta = initBeta;
48
- activeCamera.radius = initRadius;
49
- }
50
- };
51
- /**
52
- * @deprecated Use viewer.moveCameraTo().
53
- */
54
- AnimationManager.prototype.animateArcRotateCamera = function (targetAlpha, targetBeta, targetRadius) {
55
- var activeCamera = this.scene.activeCamera;
56
- if (!activeCamera) {
57
- throw new Error('There is no active camera');
58
- }
59
- var alphaAnimation = new animation_1.Animation('alphaAnimation', 'alpha', 30, animation_1.Animation.ANIMATIONTYPE_FLOAT, animation_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
60
- var betaAnimation = new animation_1.Animation('betaAnimation', 'beta', 30, animation_1.Animation.ANIMATIONTYPE_FLOAT, animation_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
61
- var radiusAnimation = new animation_1.Animation('radiusAnimation', 'radius', 30, animation_1.Animation.ANIMATIONTYPE_FLOAT, animation_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
62
- alphaAnimation.setKeys([{
63
- frame: 0,
64
- value: activeCamera.alpha
65
- }, {
66
- frame: 100,
67
- value: targetAlpha
68
- }]);
69
- betaAnimation.setKeys([{
70
- frame: 0,
71
- value: activeCamera.beta
72
- }, {
73
- frame: 100,
74
- value: targetBeta
75
- }]);
76
- radiusAnimation.setKeys([{
77
- frame: 0,
78
- value: activeCamera.radius
79
- }, {
80
- frame: 100,
81
- value: targetRadius
82
- }]);
83
- activeCamera.animations.push(alphaAnimation);
84
- activeCamera.animations.push(betaAnimation);
85
- activeCamera.animations.push(radiusAnimation);
86
- var animation = this.scene.beginAnimation(activeCamera, 0, 100, false, 10);
87
- animation.disposeOnEnd = true;
88
- };
89
- /**
90
- * Stops and kills all running animations.
91
- */
92
- AnimationManager.prototype.killAllAnimations = function () {
93
- this.animations.forEach(function (animation) { return animation.kill(); });
94
- this.animations = [];
95
- };
96
- /**
97
- * @see {@link PlacementAnimation.play}
98
- */
99
- AnimationManager.prototype.animateToPlacement = function (mutable, placement, animation) {
100
- return tslib_1.__awaiter(this, void 0, void 0, function () {
101
- var _animation, animationPromise;
102
- var _this = this;
103
- return tslib_1.__generator(this, function (_b) {
104
- switch (_b.label) {
105
- case 0:
106
- _animation = new placementAnimation_1.PlacementAnimation(mutable, placement, animation);
107
- this.animations.push(_animation);
108
- animationPromise = _animation.play();
109
- animationPromise.then(function (a) {
110
- lodash_es_1.remove(_this.animations, function (_a) { return _a === a; });
111
- a.kill();
112
- });
113
- return [4 /*yield*/, animationPromise];
114
- case 1: return [2 /*return*/, _b.sent()];
115
- }
116
- });
117
- });
118
- };
119
- return AnimationManager;
120
- }());
121
- exports.AnimationManager = AnimationManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnimationManager = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var animation_1 = require("@babylonjs/core/Animations/animation");
6
+ //import { CustomEase } from 'gsap/CustomEase';
7
+ //import { ExpoScaleEase, RoughEase, SlowMo } from 'gsap/EasePack';
8
+ var lodash_es_1 = require("lodash-es");
9
+ var placementAnimation_1 = require("../classes/placementAnimation");
10
+ //gsap.registerPlugin( CustomEase, ExpoScaleEase, RoughEase, SlowMo );
11
+ var AnimationManager = /** @class */ (function () {
12
+ /**
13
+ * Constructor.
14
+ */
15
+ function AnimationManager(scene) {
16
+ this.scene = scene;
17
+ this.animations = [];
18
+ }
19
+ /**
20
+ * Creates an {@link AnimationManager} based on given BabylonJS scene.
21
+ */
22
+ AnimationManager.create = function (scene) {
23
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
24
+ return tslib_1.__generator(this, function (_b) {
25
+ return [2 /*return*/, new AnimationManager(scene)];
26
+ });
27
+ });
28
+ };
29
+ /**
30
+ * @deprecated Use viewer.moveCameraTo().
31
+ */
32
+ AnimationManager.prototype.resetCamera = function (animate) {
33
+ if (animate === void 0) { animate = false; }
34
+ //TODO currently only works for arcrotate. are there any other cameras?
35
+ var activeCamera = this.scene.activeCamera;
36
+ if (!activeCamera) {
37
+ throw new Error('There is no active camera');
38
+ }
39
+ var initAlpha = activeCamera.metadata.alpha;
40
+ var initBeta = activeCamera.metadata.beta;
41
+ var initRadius = activeCamera.metadata.radius;
42
+ if (animate) {
43
+ this.animateArcRotateCamera(initAlpha, initBeta, initRadius);
44
+ }
45
+ else {
46
+ activeCamera.alpha = initAlpha;
47
+ activeCamera.beta = initBeta;
48
+ activeCamera.radius = initRadius;
49
+ }
50
+ };
51
+ /**
52
+ * @deprecated Use viewer.moveCameraTo().
53
+ */
54
+ AnimationManager.prototype.animateArcRotateCamera = function (targetAlpha, targetBeta, targetRadius) {
55
+ var activeCamera = this.scene.activeCamera;
56
+ if (!activeCamera) {
57
+ throw new Error('There is no active camera');
58
+ }
59
+ var alphaAnimation = new animation_1.Animation('alphaAnimation', 'alpha', 30, animation_1.Animation.ANIMATIONTYPE_FLOAT, animation_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
60
+ var betaAnimation = new animation_1.Animation('betaAnimation', 'beta', 30, animation_1.Animation.ANIMATIONTYPE_FLOAT, animation_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
61
+ var radiusAnimation = new animation_1.Animation('radiusAnimation', 'radius', 30, animation_1.Animation.ANIMATIONTYPE_FLOAT, animation_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
62
+ alphaAnimation.setKeys([{
63
+ frame: 0,
64
+ value: activeCamera.alpha
65
+ }, {
66
+ frame: 100,
67
+ value: targetAlpha
68
+ }]);
69
+ betaAnimation.setKeys([{
70
+ frame: 0,
71
+ value: activeCamera.beta
72
+ }, {
73
+ frame: 100,
74
+ value: targetBeta
75
+ }]);
76
+ radiusAnimation.setKeys([{
77
+ frame: 0,
78
+ value: activeCamera.radius
79
+ }, {
80
+ frame: 100,
81
+ value: targetRadius
82
+ }]);
83
+ activeCamera.animations.push(alphaAnimation);
84
+ activeCamera.animations.push(betaAnimation);
85
+ activeCamera.animations.push(radiusAnimation);
86
+ var animation = this.scene.beginAnimation(activeCamera, 0, 100, false, 10);
87
+ animation.disposeOnEnd = true;
88
+ };
89
+ /**
90
+ * Stops and kills all running animations.
91
+ */
92
+ AnimationManager.prototype.killAllAnimations = function () {
93
+ this.animations.forEach(function (animation) { return animation.kill(); });
94
+ this.animations = [];
95
+ };
96
+ /**
97
+ * @see {@link PlacementAnimation.play}
98
+ */
99
+ AnimationManager.prototype.animateToPlacement = function (mutable, placement, animation) {
100
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
101
+ var _animation, animationPromise;
102
+ var _this = this;
103
+ return tslib_1.__generator(this, function (_b) {
104
+ switch (_b.label) {
105
+ case 0:
106
+ _animation = new placementAnimation_1.PlacementAnimation(mutable, placement, animation);
107
+ this.animations.push(_animation);
108
+ animationPromise = _animation.play();
109
+ animationPromise.then(function (a) {
110
+ lodash_es_1.remove(_this.animations, function (_a) { return _a === a; });
111
+ a.kill();
112
+ });
113
+ return [4 /*yield*/, animationPromise];
114
+ case 1: return [2 /*return*/, _b.sent()];
115
+ }
116
+ });
117
+ });
118
+ };
119
+ return AnimationManager;
120
+ }());
121
+ exports.AnimationManager = AnimationManager;
122
122
  //# sourceMappingURL=animationManager.js.map
@@ -1,32 +1,32 @@
1
- import { Camera } from '@babylonjs/core/Cameras/camera';
2
- import { Scene as BabylonScene } from '@babylonjs/core/scene';
3
- import { ParameterObservable } from '../classes/parameterObservable';
4
- export declare class SceneManager extends ParameterObservable {
5
- scene: BabylonScene;
6
- protected readonly _parameterObservers: Map<string, ParameterObserver[]>;
7
- protected readonly parameterDeclaration: ParameterDeclarations;
8
- /**
9
- * Constructor.
10
- */
11
- protected constructor(scene: BabylonScene);
12
- /**
13
- * Creates a {@link SceneManager} based on given BabylonJS scene.
14
- */
15
- static create(scene: BabylonScene): Promise<SceneManager>;
16
- /**
17
- * The active `Camera`.
18
- */
19
- get activeCamera(): Camera;
20
- /**
21
- * Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
22
- * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
23
- *
24
- * @emit {@link Event.SCENE_PARAMETER_COMMITTED}
25
- */
26
- commitParameters(parameters?: ParameterBag): Promise<SceneManager>;
27
- protected addParameterObservers(): SceneManager;
28
- /**
29
- * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
30
- */
31
- protected bootstrapParameters(parameters?: ParameterBag): Promise<SceneManager>;
32
- }
1
+ import { Camera } from '@babylonjs/core/Cameras/camera';
2
+ import { Scene as BabylonScene } from '@babylonjs/core/scene';
3
+ import { ParameterObservable } from '../classes/parameterObservable';
4
+ export declare class SceneManager extends ParameterObservable {
5
+ scene: BabylonScene;
6
+ protected readonly _parameterObservers: Map<string, ParameterObserver[]>;
7
+ protected readonly parameterDeclaration: ParameterDeclarations;
8
+ /**
9
+ * Constructor.
10
+ */
11
+ protected constructor(scene: BabylonScene);
12
+ /**
13
+ * Creates a {@link SceneManager} based on given BabylonJS scene.
14
+ */
15
+ static create(scene: BabylonScene): Promise<SceneManager>;
16
+ /**
17
+ * The active `Camera`.
18
+ */
19
+ get activeCamera(): Camera;
20
+ /**
21
+ * Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
22
+ * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
23
+ *
24
+ * @emit {@link Event.SCENE_PARAMETER_COMMITTED}
25
+ */
26
+ commitParameters(parameters?: ParameterBag): Promise<SceneManager>;
27
+ protected addParameterObservers(): SceneManager;
28
+ /**
29
+ * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
30
+ */
31
+ protected bootstrapParameters(parameters?: ParameterBag): Promise<SceneManager>;
32
+ }
@@ -1,133 +1,133 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SceneManager = void 0;
4
- var tslib_1 = require("tslib");
5
- var cubeTexture_1 = require("@babylonjs/core/Materials/Textures/cubeTexture");
6
- var lodash_es_1 = require("lodash-es");
7
- var parameterObservable_1 = require("../classes/parameterObservable");
8
- var event_1 = require("../classes/event");
9
- var specStorage_1 = require("../store/specStorage");
10
- var resourceHelper_1 = require("../util/resourceHelper");
11
- var SceneManager = /** @class */ (function (_super) {
12
- tslib_1.__extends(SceneManager, _super);
13
- /**
14
- * Constructor.
15
- */
16
- function SceneManager(scene) {
17
- var _this = _super.call(this) || this;
18
- _this.scene = scene;
19
- _this._parameterObservers = new Map();
20
- _this.parameterDeclaration = {
21
- 'environment': { type: 'string' },
22
- 'environment.rotation': { type: 'number' }
23
- };
24
- _this.addParameterObservers();
25
- return _this;
26
- }
27
- /**
28
- * Creates a {@link SceneManager} based on given BabylonJS scene.
29
- */
30
- SceneManager.create = function (scene) {
31
- return tslib_1.__awaiter(this, void 0, void 0, function () {
32
- var sceneManager;
33
- return tslib_1.__generator(this, function (_a) {
34
- switch (_a.label) {
35
- case 0:
36
- sceneManager = new SceneManager(scene);
37
- return [4 /*yield*/, sceneManager.bootstrapParameters(specStorage_1.SpecStorage.get('scene.parameters'))];
38
- case 1:
39
- _a.sent();
40
- return [2 /*return*/, sceneManager];
41
- }
42
- });
43
- });
44
- };
45
- Object.defineProperty(SceneManager.prototype, "activeCamera", {
46
- /**
47
- * The active `Camera`.
48
- */
49
- get: function () {
50
- if (!this.scene.activeCamera) {
51
- throw new Error('Scene has no active camera.');
52
- }
53
- return this.scene.activeCamera;
54
- },
55
- enumerable: false,
56
- configurable: true
57
- });
58
- /**
59
- * Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
60
- * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
61
- *
62
- * @emit {@link Event.SCENE_PARAMETER_COMMITTED}
63
- */
64
- SceneManager.prototype.commitParameters = function (parameters) {
65
- return tslib_1.__awaiter(this, void 0, void 0, function () {
66
- var oldParameters, _loop_1, this_1, parameter;
67
- var _this = this;
68
- return tslib_1.__generator(this, function (_a) {
69
- if (!parameters) {
70
- parameters = {};
71
- }
72
- oldParameters = lodash_es_1.cloneDeep(this.parameters);
73
- lodash_es_1.merge(this.parameters, parameters);
74
- _loop_1 = function (parameter) {
75
- var oldParameterValue = oldParameters[parameter];
76
- var newParameterValue = this_1.parameters[parameter];
77
- this_1.assertParameter(this_1.parameterDeclaration, parameter, newParameterValue);
78
- if (oldParameterValue === newParameterValue) {
79
- return "continue";
80
- }
81
- // parameter changed
82
- var parameterObservers = resourceHelper_1.mergeMaps(this_1._parameterObservers, this_1.parameterObservers);
83
- if (parameterObservers.has(parameter)) {
84
- var observers = parameterObservers.get(parameter);
85
- observers.forEach(function (observer) {
86
- observer(_this, oldParameterValue, newParameterValue);
87
- _this.broadcastEvent(event_1.Event.SCENE_PARAMETER_COMMITTED, _this, parameter, oldParameterValue, newParameterValue);
88
- });
89
- }
90
- };
91
- this_1 = this;
92
- // handle parameter observers
93
- for (parameter in this.parameters) {
94
- _loop_1(parameter);
95
- }
96
- return [2 /*return*/, this];
97
- });
98
- });
99
- };
100
- SceneManager.prototype.addParameterObservers = function () {
101
- this._parameterObservers.set('environment', [
102
- function (manager, oldValue, newValue) {
103
- manager.scene.environmentTexture = cubeTexture_1.CubeTexture.CreateFromPrefilteredData(newValue.toString(), manager.scene);
104
- }
105
- ]);
106
- this._parameterObservers.set('environment.rotation', [
107
- function (manager, oldValue, newValue) {
108
- if (manager.scene.environmentTexture instanceof cubeTexture_1.CubeTexture) {
109
- manager.scene.environmentTexture.rotationY = (parseFloat(newValue.toString()) * Math.PI) / 180;
110
- }
111
- }
112
- ]);
113
- return this;
114
- };
115
- /**
116
- * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
117
- */
118
- SceneManager.prototype.bootstrapParameters = function (parameters) {
119
- return tslib_1.__awaiter(this, void 0, void 0, function () {
120
- return tslib_1.__generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0: return [4 /*yield*/, this.commitParameters(lodash_es_1.merge(lodash_es_1.cloneDeep(this.parameters), parameters))];
123
- case 1:
124
- _a.sent();
125
- return [2 /*return*/, this];
126
- }
127
- });
128
- });
129
- };
130
- return SceneManager;
131
- }(parameterObservable_1.ParameterObservable));
132
- exports.SceneManager = SceneManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SceneManager = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var cubeTexture_1 = require("@babylonjs/core/Materials/Textures/cubeTexture");
6
+ var lodash_es_1 = require("lodash-es");
7
+ var parameterObservable_1 = require("../classes/parameterObservable");
8
+ var event_1 = require("../classes/event");
9
+ var specStorage_1 = require("../store/specStorage");
10
+ var resourceHelper_1 = require("../util/resourceHelper");
11
+ var SceneManager = /** @class */ (function (_super) {
12
+ tslib_1.__extends(SceneManager, _super);
13
+ /**
14
+ * Constructor.
15
+ */
16
+ function SceneManager(scene) {
17
+ var _this = _super.call(this) || this;
18
+ _this.scene = scene;
19
+ _this._parameterObservers = new Map();
20
+ _this.parameterDeclaration = {
21
+ 'environment': { type: 'string' },
22
+ 'environment.rotation': { type: 'number' }
23
+ };
24
+ _this.addParameterObservers();
25
+ return _this;
26
+ }
27
+ /**
28
+ * Creates a {@link SceneManager} based on given BabylonJS scene.
29
+ */
30
+ SceneManager.create = function (scene) {
31
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
32
+ var sceneManager;
33
+ return tslib_1.__generator(this, function (_a) {
34
+ switch (_a.label) {
35
+ case 0:
36
+ sceneManager = new SceneManager(scene);
37
+ return [4 /*yield*/, sceneManager.bootstrapParameters(specStorage_1.SpecStorage.get('scene.parameters'))];
38
+ case 1:
39
+ _a.sent();
40
+ return [2 /*return*/, sceneManager];
41
+ }
42
+ });
43
+ });
44
+ };
45
+ Object.defineProperty(SceneManager.prototype, "activeCamera", {
46
+ /**
47
+ * The active `Camera`.
48
+ */
49
+ get: function () {
50
+ if (!this.scene.activeCamera) {
51
+ throw new Error('Scene has no active camera.');
52
+ }
53
+ return this.scene.activeCamera;
54
+ },
55
+ enumerable: false,
56
+ configurable: true
57
+ });
58
+ /**
59
+ * Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
60
+ * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
61
+ *
62
+ * @emit {@link Event.SCENE_PARAMETER_COMMITTED}
63
+ */
64
+ SceneManager.prototype.commitParameters = function (parameters) {
65
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
66
+ var oldParameters, _loop_1, this_1, parameter;
67
+ var _this = this;
68
+ return tslib_1.__generator(this, function (_a) {
69
+ if (!parameters) {
70
+ parameters = {};
71
+ }
72
+ oldParameters = lodash_es_1.cloneDeep(this.parameters);
73
+ lodash_es_1.merge(this.parameters, parameters);
74
+ _loop_1 = function (parameter) {
75
+ var oldParameterValue = oldParameters[parameter];
76
+ var newParameterValue = this_1.parameters[parameter];
77
+ this_1.assertParameter(this_1.parameterDeclaration, parameter, newParameterValue);
78
+ if (oldParameterValue === newParameterValue) {
79
+ return "continue";
80
+ }
81
+ // parameter changed
82
+ var parameterObservers = resourceHelper_1.mergeMaps(this_1._parameterObservers, this_1.parameterObservers);
83
+ if (parameterObservers.has(parameter)) {
84
+ var observers = parameterObservers.get(parameter);
85
+ observers.forEach(function (observer) {
86
+ observer(_this, oldParameterValue, newParameterValue);
87
+ _this.broadcastEvent(event_1.Event.SCENE_PARAMETER_COMMITTED, _this, parameter, oldParameterValue, newParameterValue);
88
+ });
89
+ }
90
+ };
91
+ this_1 = this;
92
+ // handle parameter observers
93
+ for (parameter in this.parameters) {
94
+ _loop_1(parameter);
95
+ }
96
+ return [2 /*return*/, this];
97
+ });
98
+ });
99
+ };
100
+ SceneManager.prototype.addParameterObservers = function () {
101
+ this._parameterObservers.set('environment', [
102
+ function (manager, oldValue, newValue) {
103
+ manager.scene.environmentTexture = cubeTexture_1.CubeTexture.CreateFromPrefilteredData(newValue.toString(), manager.scene);
104
+ }
105
+ ]);
106
+ this._parameterObservers.set('environment.rotation', [
107
+ function (manager, oldValue, newValue) {
108
+ if (manager.scene.environmentTexture instanceof cubeTexture_1.CubeTexture) {
109
+ manager.scene.environmentTexture.rotationY = (parseFloat(newValue.toString()) * Math.PI) / 180;
110
+ }
111
+ }
112
+ ]);
113
+ return this;
114
+ };
115
+ /**
116
+ * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
117
+ */
118
+ SceneManager.prototype.bootstrapParameters = function (parameters) {
119
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
120
+ return tslib_1.__generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0: return [4 /*yield*/, this.commitParameters(lodash_es_1.merge(lodash_es_1.cloneDeep(this.parameters), parameters))];
123
+ case 1:
124
+ _a.sent();
125
+ return [2 /*return*/, this];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ return SceneManager;
131
+ }(parameterObservable_1.ParameterObservable));
132
+ exports.SceneManager = SceneManager;
133
133
  //# sourceMappingURL=sceneManager.js.map