@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,117 +1,117 @@
1
- import { Animation as BabylonAnimation } from '@babylonjs/core/Animations/animation';
2
- import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
3
- import { Scene as BabylonScene, Scene } from '@babylonjs/core/scene';
4
- import { Nullable } from '@babylonjs/core/types';
5
- //import { CustomEase } from 'gsap/CustomEase';
6
- //import { ExpoScaleEase, RoughEase, SlowMo } from 'gsap/EasePack';
7
- import { remove } from 'lodash-es';
8
- import { PlacementAnimation } from '../classes/placementAnimation';
9
-
10
- //gsap.registerPlugin( CustomEase, ExpoScaleEase, RoughEase, SlowMo );
11
-
12
-
13
- export class AnimationManager {
14
-
15
- public animations: AnimationInterface[] = [];
16
-
17
- /**
18
- * Constructor.
19
- */
20
- protected constructor( protected scene: Scene ) {
21
- }
22
-
23
- /**
24
- * Creates an {@link AnimationManager} based on given BabylonJS scene.
25
- */
26
- public static async create( scene: BabylonScene ): Promise<AnimationManager> {
27
- return new AnimationManager( scene );
28
- }
29
-
30
- /**
31
- * @deprecated Use viewer.moveCameraTo().
32
- */
33
- public resetCamera(animate: boolean = false) {
34
- //TODO currently only works for arcrotate. are there any other cameras?
35
- let activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
36
- if( ! activeCamera ) {
37
- throw new Error( 'There is no active camera' );
38
- }
39
-
40
- const initAlpha = activeCamera.metadata.alpha;
41
- const initBeta = activeCamera.metadata.beta;
42
- const initRadius = activeCamera.metadata.radius;
43
-
44
- if( animate ) {
45
- this.animateArcRotateCamera(initAlpha, initBeta, initRadius);
46
- } else {
47
- activeCamera.alpha = initAlpha;
48
- activeCamera.beta = initBeta;
49
- activeCamera.radius = initRadius;
50
- }
51
- }
52
-
53
- /**
54
- * @deprecated Use viewer.moveCameraTo().
55
- */
56
- public animateArcRotateCamera(targetAlpha: number, targetBeta: number, targetRadius: number) {
57
- let activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
58
- if( ! activeCamera ) {
59
- throw new Error( 'There is no active camera' );
60
- }
61
- const alphaAnimation = new BabylonAnimation( 'alphaAnimation', 'alpha', 30, BabylonAnimation.ANIMATIONTYPE_FLOAT, BabylonAnimation.ANIMATIONLOOPMODE_CONSTANT );
62
- const betaAnimation = new BabylonAnimation( 'betaAnimation', 'beta', 30, BabylonAnimation.ANIMATIONTYPE_FLOAT, BabylonAnimation.ANIMATIONLOOPMODE_CONSTANT );
63
- const radiusAnimation = new BabylonAnimation( 'radiusAnimation', 'radius', 30, BabylonAnimation.ANIMATIONTYPE_FLOAT, BabylonAnimation.ANIMATIONLOOPMODE_CONSTANT );
64
- alphaAnimation.setKeys([{
65
- frame : 0,
66
- value : activeCamera.alpha
67
- }, {
68
- frame : 100,
69
- value : targetAlpha
70
- }]);
71
- betaAnimation.setKeys([{
72
- frame : 0,
73
- value : activeCamera.beta
74
- }, {
75
- frame : 100,
76
- value : targetBeta
77
- }]);
78
- radiusAnimation.setKeys( [{
79
- frame : 0,
80
- value : activeCamera.radius
81
- }, {
82
- frame : 100,
83
- value : targetRadius
84
- }]);
85
- activeCamera.animations.push(alphaAnimation);
86
- activeCamera.animations.push(betaAnimation);
87
- activeCamera.animations.push(radiusAnimation);
88
-
89
- let animation = this.scene.beginAnimation(activeCamera, 0, 100, false, 10);
90
- animation.disposeOnEnd = true;
91
- }
92
-
93
- /**
94
- * Stops and kills all running animations.
95
- */
96
- public killAllAnimations() {
97
- this.animations.forEach( animation => animation.kill() );
98
- this.animations = [];
99
- }
100
-
101
- /**
102
- * @see {@link PlacementAnimation.play}
103
- */
104
- public async animateToPlacement( mutable: object,
105
- placement: PlacementDefinition | string,
106
- animation?: AnimationDefinition | string ): Promise<AnimationInterface> {
107
- const _animation = new PlacementAnimation( mutable, placement, animation );
108
- this.animations.push( _animation );
109
- const animationPromise = _animation.play();
110
- animationPromise.then( a => {
111
- remove( this.animations, _a => _a === a );
112
- a.kill();
113
- } );
114
- return await animationPromise;
115
- }
116
-
1
+ import { Animation as BabylonAnimation } from '@babylonjs/core/Animations/animation';
2
+ import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
3
+ import { Scene as BabylonScene, Scene } from '@babylonjs/core/scene';
4
+ import { Nullable } from '@babylonjs/core/types';
5
+ //import { CustomEase } from 'gsap/CustomEase';
6
+ //import { ExpoScaleEase, RoughEase, SlowMo } from 'gsap/EasePack';
7
+ import { remove } from 'lodash-es';
8
+ import { PlacementAnimation } from '../classes/placementAnimation';
9
+
10
+ //gsap.registerPlugin( CustomEase, ExpoScaleEase, RoughEase, SlowMo );
11
+
12
+
13
+ export class AnimationManager {
14
+
15
+ public animations: AnimationInterface[] = [];
16
+
17
+ /**
18
+ * Constructor.
19
+ */
20
+ protected constructor( protected scene: Scene ) {
21
+ }
22
+
23
+ /**
24
+ * Creates an {@link AnimationManager} based on given BabylonJS scene.
25
+ */
26
+ public static async create( scene: BabylonScene ): Promise<AnimationManager> {
27
+ return new AnimationManager( scene );
28
+ }
29
+
30
+ /**
31
+ * @deprecated Use viewer.moveCameraTo().
32
+ */
33
+ public resetCamera(animate: boolean = false) {
34
+ //TODO currently only works for arcrotate. are there any other cameras?
35
+ let activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
36
+ if( ! activeCamera ) {
37
+ throw new Error( 'There is no active camera' );
38
+ }
39
+
40
+ const initAlpha = activeCamera.metadata.alpha;
41
+ const initBeta = activeCamera.metadata.beta;
42
+ const initRadius = activeCamera.metadata.radius;
43
+
44
+ if( animate ) {
45
+ this.animateArcRotateCamera(initAlpha, initBeta, initRadius);
46
+ } else {
47
+ activeCamera.alpha = initAlpha;
48
+ activeCamera.beta = initBeta;
49
+ activeCamera.radius = initRadius;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @deprecated Use viewer.moveCameraTo().
55
+ */
56
+ public animateArcRotateCamera(targetAlpha: number, targetBeta: number, targetRadius: number) {
57
+ let activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
58
+ if( ! activeCamera ) {
59
+ throw new Error( 'There is no active camera' );
60
+ }
61
+ const alphaAnimation = new BabylonAnimation( 'alphaAnimation', 'alpha', 30, BabylonAnimation.ANIMATIONTYPE_FLOAT, BabylonAnimation.ANIMATIONLOOPMODE_CONSTANT );
62
+ const betaAnimation = new BabylonAnimation( 'betaAnimation', 'beta', 30, BabylonAnimation.ANIMATIONTYPE_FLOAT, BabylonAnimation.ANIMATIONLOOPMODE_CONSTANT );
63
+ const radiusAnimation = new BabylonAnimation( 'radiusAnimation', 'radius', 30, BabylonAnimation.ANIMATIONTYPE_FLOAT, BabylonAnimation.ANIMATIONLOOPMODE_CONSTANT );
64
+ alphaAnimation.setKeys([{
65
+ frame : 0,
66
+ value : activeCamera.alpha
67
+ }, {
68
+ frame : 100,
69
+ value : targetAlpha
70
+ }]);
71
+ betaAnimation.setKeys([{
72
+ frame : 0,
73
+ value : activeCamera.beta
74
+ }, {
75
+ frame : 100,
76
+ value : targetBeta
77
+ }]);
78
+ radiusAnimation.setKeys( [{
79
+ frame : 0,
80
+ value : activeCamera.radius
81
+ }, {
82
+ frame : 100,
83
+ value : targetRadius
84
+ }]);
85
+ activeCamera.animations.push(alphaAnimation);
86
+ activeCamera.animations.push(betaAnimation);
87
+ activeCamera.animations.push(radiusAnimation);
88
+
89
+ let animation = this.scene.beginAnimation(activeCamera, 0, 100, false, 10);
90
+ animation.disposeOnEnd = true;
91
+ }
92
+
93
+ /**
94
+ * Stops and kills all running animations.
95
+ */
96
+ public killAllAnimations() {
97
+ this.animations.forEach( animation => animation.kill() );
98
+ this.animations = [];
99
+ }
100
+
101
+ /**
102
+ * @see {@link PlacementAnimation.play}
103
+ */
104
+ public async animateToPlacement( mutable: object,
105
+ placement: PlacementDefinition | string,
106
+ animation?: AnimationDefinition | string ): Promise<AnimationInterface> {
107
+ const _animation = new PlacementAnimation( mutable, placement, animation );
108
+ this.animations.push( _animation );
109
+ const animationPromise = _animation.play();
110
+ animationPromise.then( a => {
111
+ remove( this.animations, _a => _a === a );
112
+ a.kill();
113
+ } );
114
+ return await animationPromise;
115
+ }
116
+
117
117
  }
@@ -1,105 +1,105 @@
1
- import { Camera } from '@babylonjs/core/Cameras/camera';
2
- import { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture';
3
- import { Scene as BabylonScene } from '@babylonjs/core/scene';
4
- import { cloneDeep, merge } from 'lodash-es';
5
- import { ParameterObservable } from '../classes/parameterObservable';
6
- import { Event } from '../classes/event';
7
- import { SpecStorage } from '../store/specStorage';
8
- import { mergeMaps } from '../util/resourceHelper';
9
-
10
- export class SceneManager extends ParameterObservable {
11
-
12
- protected readonly _parameterObservers: Map<string, ParameterObserver[]> = new Map();
13
-
14
- protected readonly parameterDeclaration: ParameterDeclarations = {
15
- 'environment': { type: 'string' },
16
- 'environment.rotation': { type: 'number' }
17
- };
18
-
19
- /**
20
- * Constructor.
21
- */
22
- protected constructor( public scene: BabylonScene ) {
23
- super();
24
- this.addParameterObservers();
25
- }
26
-
27
- /**
28
- * Creates a {@link SceneManager} based on given BabylonJS scene.
29
- */
30
- public static async create( scene: BabylonScene ): Promise<SceneManager> {
31
- const sceneManager = new SceneManager( scene );
32
- await sceneManager.bootstrapParameters( SpecStorage.get<ParameterBag>( 'scene.parameters' ) );
33
- return sceneManager;
34
- }
35
-
36
- /**
37
- * The active `Camera`.
38
- */
39
- get activeCamera(): Camera {
40
- if( !this.scene.activeCamera ) {
41
- throw new Error( 'Scene has no active camera.' );
42
- }
43
- return this.scene.activeCamera;
44
- }
45
-
46
- /**
47
- * Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
48
- * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
49
- *
50
- * @emit {@link Event.SCENE_PARAMETER_COMMITTED}
51
- */
52
- public async commitParameters( parameters?: ParameterBag ): Promise<SceneManager> {
53
- if( !parameters ) {
54
- parameters = {};
55
- }
56
- const oldParameters = cloneDeep( this.parameters );
57
- merge( this.parameters, parameters );
58
-
59
- // handle parameter observers
60
- for( const parameter in this.parameters ) {
61
- const oldParameterValue = oldParameters[parameter];
62
- const newParameterValue = this.parameters[parameter];
63
- this.assertParameter( this.parameterDeclaration, parameter, newParameterValue );
64
- if( oldParameterValue === newParameterValue ) {
65
- continue;
66
- }
67
- // parameter changed
68
- const parameterObservers = mergeMaps( this._parameterObservers, this.parameterObservers );
69
- if( parameterObservers.has( parameter ) ) {
70
- const observers = parameterObservers.get( parameter )!;
71
- observers.forEach( observer => {
72
- observer( this, oldParameterValue, newParameterValue );
73
- this.broadcastEvent( Event.SCENE_PARAMETER_COMMITTED, this, parameter,
74
- oldParameterValue, newParameterValue );
75
- } );
76
- }
77
- }
78
- return this;
79
- }
80
-
81
- protected addParameterObservers(): SceneManager {
82
- this._parameterObservers.set( 'environment', [
83
- ( manager: SceneManager, oldValue: ParameterValue, newValue: ParameterValue ) => {
84
- manager.scene.environmentTexture = CubeTexture.CreateFromPrefilteredData( newValue.toString(), manager.scene );
85
- }
86
- ] );
87
- this._parameterObservers.set( 'environment.rotation', [
88
- ( manager: SceneManager, oldValue: ParameterValue, newValue: ParameterValue ) => {
89
- if( manager.scene.environmentTexture instanceof CubeTexture ) {
90
- manager.scene.environmentTexture.rotationY = (parseFloat( newValue.toString() ) * Math.PI) / 180;
91
- }
92
- }
93
- ] );
94
- return this;
95
- }
96
-
97
- /**
98
- * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
99
- */
100
- protected async bootstrapParameters( parameters?: ParameterBag ): Promise<SceneManager> {
101
- await this.commitParameters( merge( cloneDeep( this.parameters ), parameters ) );
102
- return this;
103
- }
104
-
105
- }
1
+ import { Camera } from '@babylonjs/core/Cameras/camera';
2
+ import { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture';
3
+ import { Scene as BabylonScene } from '@babylonjs/core/scene';
4
+ import { cloneDeep, merge } from 'lodash-es';
5
+ import { ParameterObservable } from '../classes/parameterObservable';
6
+ import { Event } from '../classes/event';
7
+ import { SpecStorage } from '../store/specStorage';
8
+ import { mergeMaps } from '../util/resourceHelper';
9
+
10
+ export class SceneManager extends ParameterObservable {
11
+
12
+ protected readonly _parameterObservers: Map<string, ParameterObserver[]> = new Map();
13
+
14
+ protected readonly parameterDeclaration: ParameterDeclarations = {
15
+ 'environment': { type: 'string' },
16
+ 'environment.rotation': { type: 'number' }
17
+ };
18
+
19
+ /**
20
+ * Constructor.
21
+ */
22
+ protected constructor( public scene: BabylonScene ) {
23
+ super();
24
+ this.addParameterObservers();
25
+ }
26
+
27
+ /**
28
+ * Creates a {@link SceneManager} based on given BabylonJS scene.
29
+ */
30
+ public static async create( scene: BabylonScene ): Promise<SceneManager> {
31
+ const sceneManager = new SceneManager( scene );
32
+ await sceneManager.bootstrapParameters( SpecStorage.get<ParameterBag>( 'scene.parameters' ) );
33
+ return sceneManager;
34
+ }
35
+
36
+ /**
37
+ * The active `Camera`.
38
+ */
39
+ get activeCamera(): Camera {
40
+ if( !this.scene.activeCamera ) {
41
+ throw new Error( 'Scene has no active camera.' );
42
+ }
43
+ return this.scene.activeCamera;
44
+ }
45
+
46
+ /**
47
+ * Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
48
+ * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
49
+ *
50
+ * @emit {@link Event.SCENE_PARAMETER_COMMITTED}
51
+ */
52
+ public async commitParameters( parameters?: ParameterBag ): Promise<SceneManager> {
53
+ if( !parameters ) {
54
+ parameters = {};
55
+ }
56
+ const oldParameters = cloneDeep( this.parameters );
57
+ merge( this.parameters, parameters );
58
+
59
+ // handle parameter observers
60
+ for( const parameter in this.parameters ) {
61
+ const oldParameterValue = oldParameters[parameter];
62
+ const newParameterValue = this.parameters[parameter];
63
+ this.assertParameter( this.parameterDeclaration, parameter, newParameterValue );
64
+ if( oldParameterValue === newParameterValue ) {
65
+ continue;
66
+ }
67
+ // parameter changed
68
+ const parameterObservers = mergeMaps( this._parameterObservers, this.parameterObservers );
69
+ if( parameterObservers.has( parameter ) ) {
70
+ const observers = parameterObservers.get( parameter )!;
71
+ observers.forEach( observer => {
72
+ observer( this, oldParameterValue, newParameterValue );
73
+ this.broadcastEvent( Event.SCENE_PARAMETER_COMMITTED, this, parameter,
74
+ oldParameterValue, newParameterValue );
75
+ } );
76
+ }
77
+ }
78
+ return this;
79
+ }
80
+
81
+ protected addParameterObservers(): SceneManager {
82
+ this._parameterObservers.set( 'environment', [
83
+ ( manager: SceneManager, oldValue: ParameterValue, newValue: ParameterValue ) => {
84
+ manager.scene.environmentTexture = CubeTexture.CreateFromPrefilteredData( newValue.toString(), manager.scene );
85
+ }
86
+ ] );
87
+ this._parameterObservers.set( 'environment.rotation', [
88
+ ( manager: SceneManager, oldValue: ParameterValue, newValue: ParameterValue ) => {
89
+ if( manager.scene.environmentTexture instanceof CubeTexture ) {
90
+ manager.scene.environmentTexture.rotationY = (parseFloat( newValue.toString() ) * Math.PI) / 180;
91
+ }
92
+ }
93
+ ] );
94
+ return this;
95
+ }
96
+
97
+ /**
98
+ * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
99
+ */
100
+ protected async bootstrapParameters( parameters?: ParameterBag ): Promise<SceneManager> {
101
+ await this.commitParameters( merge( cloneDeep( this.parameters ), parameters ) );
102
+ return this;
103
+ }
104
+
105
+ }