@shapediver/viewer.rendering-engine.light-engine 2.12.8 → 3.0.0

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 (36) hide show
  1. package/dist/implementation/AbstractLight.d.ts +4 -4
  2. package/dist/implementation/AbstractLight.d.ts.map +1 -1
  3. package/dist/implementation/AbstractLight.js +13 -13
  4. package/dist/implementation/AbstractLight.js.map +1 -1
  5. package/dist/implementation/LightEngine.d.ts +1 -1
  6. package/dist/implementation/LightEngine.d.ts.map +1 -1
  7. package/dist/implementation/LightEngine.js +15 -15
  8. package/dist/implementation/LightEngine.js.map +1 -1
  9. package/dist/implementation/types/AmbientLight.d.ts +1 -5
  10. package/dist/implementation/types/AmbientLight.d.ts.map +1 -1
  11. package/dist/implementation/types/AmbientLight.js +1 -16
  12. package/dist/implementation/types/AmbientLight.js.map +1 -1
  13. package/dist/implementation/types/DirectionalLight.d.ts +2 -5
  14. package/dist/implementation/types/DirectionalLight.d.ts.map +1 -1
  15. package/dist/implementation/types/DirectionalLight.js +6 -10
  16. package/dist/implementation/types/DirectionalLight.js.map +1 -1
  17. package/dist/implementation/types/HemisphereLight.d.ts +1 -4
  18. package/dist/implementation/types/HemisphereLight.d.ts.map +1 -1
  19. package/dist/implementation/types/HemisphereLight.js +5 -9
  20. package/dist/implementation/types/HemisphereLight.js.map +1 -1
  21. package/dist/implementation/types/PointLight.d.ts +2 -5
  22. package/dist/implementation/types/PointLight.d.ts.map +1 -1
  23. package/dist/implementation/types/PointLight.js +6 -10
  24. package/dist/implementation/types/PointLight.js.map +1 -1
  25. package/dist/implementation/types/SpotLight.d.ts +2 -5
  26. package/dist/implementation/types/SpotLight.d.ts.map +1 -1
  27. package/dist/implementation/types/SpotLight.js +6 -10
  28. package/dist/implementation/types/SpotLight.js.map +1 -1
  29. package/package.json +7 -7
  30. package/src/implementation/AbstractLight.ts +21 -23
  31. package/src/implementation/LightEngine.ts +98 -83
  32. package/src/implementation/types/AmbientLight.ts +6 -22
  33. package/src/implementation/types/DirectionalLight.ts +15 -22
  34. package/src/implementation/types/HemisphereLight.ts +5 -13
  35. package/src/implementation/types/PointLight.ts +8 -15
  36. package/src/implementation/types/SpotLight.ts +11 -18
@@ -1,22 +1,37 @@
1
- import { vec3 } from 'gl-matrix'
2
- import { Converter, UuidGenerator, SettingsEngine, StateEngine } from '@shapediver/viewer.shared.services'
3
-
4
- import { AmbientLight } from './types/AmbientLight'
5
- import { DirectionalLight } from './types/DirectionalLight'
6
- import { HemisphereLight } from './types/HemisphereLight'
7
- import { PointLight } from './types/PointLight'
8
- import { SpotLight } from './types/SpotLight'
9
- import { LightScene } from './LightScene'
10
- import { AbstractLight } from './AbstractLight'
11
- import { ILightEngine } from '../interface/ILightEngine'
12
- import { ILight, LIGHT_TYPE } from '../interface/ILight'
13
- import { ILightScene } from '../interface/ILightScene'
14
- import { IAmbientLightPropertiesV3, IDirectionalLightPropertiesV3, IHemisphereLightPropertiesV3, ILightSceneSettingsV3, IPointLightPropertiesV3, ISpotLightPropertiesV3 } from '@shapediver/viewer.settings'
15
- import { ITree, ITreeNode, Tree, TreeNode } from '@shapediver/viewer.shared.node-tree'
16
- import { IRenderingEngine } from '@shapediver/viewer.rendering-engine.rendering-engine'
1
+ import { AbstractLight } from './AbstractLight';
2
+ import { AmbientLight } from './types/AmbientLight';
3
+ import {
4
+ Converter,
5
+ SettingsEngine,
6
+ UuidGenerator
7
+ } from '@shapediver/viewer.shared.services';
8
+ import { DirectionalLight } from './types/DirectionalLight';
9
+ import { HemisphereLight } from './types/HemisphereLight';
10
+ import {
11
+ IAmbientLightProperties,
12
+ IDirectionalLightProperties,
13
+ IHemisphereLightProperties,
14
+ ILightSceneSettings,
15
+ IPointLightProperties,
16
+ ISpotLightProperties
17
+ } from '@shapediver/viewer.settings';
18
+ import { LIGHT_TYPE } from '../interface/ILight';
19
+ import { ILightEngine } from '../interface/ILightEngine';
20
+ import { ILightScene } from '../interface/ILightScene';
21
+ import { IRenderingEngine } from '@shapediver/viewer.rendering-engine.rendering-engine';
22
+ import {
23
+ ITree,
24
+ ITreeNode,
25
+ Tree,
26
+ TreeNode
27
+ } from '@shapediver/viewer.shared.node-tree';
28
+ import { LightScene } from './LightScene';
29
+ import { PointLight } from './types/PointLight';
30
+ import { SpotLight } from './types/SpotLight';
31
+ import { vec3 } from 'gl-matrix';
17
32
 
18
33
  export class LightEngine implements ILightEngine {
19
- // #region Properties (6)
34
+ // #region Properties (7)
20
35
 
21
36
  private readonly _converter: Converter = Converter.instance;
22
37
  private readonly _lightNode: ITreeNode = new TreeNode('lights');
@@ -27,7 +42,7 @@ export class LightEngine implements ILightEngine {
27
42
  private _lightScenes: { [key: string]: LightScene; } = {};
28
43
  private _update?: () => void;
29
44
 
30
- // #endregion Properties (6)
45
+ // #endregion Properties (7)
31
46
 
32
47
  // #region Constructors (1)
33
48
 
@@ -38,7 +53,7 @@ export class LightEngine implements ILightEngine {
38
53
 
39
54
  // #endregion Constructors (1)
40
55
 
41
- // #region Public Accessors (2)
56
+ // #region Public Getters And Setters (4)
42
57
 
43
58
  public get lightScene(): LightScene | null {
44
59
  return this._lightScene;
@@ -58,28 +73,28 @@ export class LightEngine implements ILightEngine {
58
73
  this._update = value;
59
74
  }
60
75
 
61
- // #endregion Public Accessors (2)
76
+ // #endregion Public Getters And Setters (4)
62
77
 
63
78
  // #region Public Methods (6)
64
79
 
65
80
  public applySettings(settingsEngine: SettingsEngine): void {
66
81
  this._lightScenes = {};
67
82
 
68
- for (let lightSceneId in settingsEngine.light.lightScenes) {
83
+ for (const lightSceneId in settingsEngine.light.lightScenes) {
69
84
  const lightSceneUUID = this._uuidGenerator.validate(lightSceneId) ? lightSceneId : this._uuidGenerator.create();
70
85
  const lightSceneName = settingsEngine.light.lightScenes[lightSceneId].name ? settingsEngine.light.lightScenes[lightSceneId].name : lightSceneId;
71
- const ls = new LightScene(this._renderingEngine, {id: lightSceneUUID, name: lightSceneName});
72
- for (let lightId in settingsEngine.light.lightScenes[lightSceneId].lights) {
86
+ const ls = new LightScene(this._renderingEngine, { id: lightSceneUUID, name: lightSceneName });
87
+ for (const lightId in settingsEngine.light.lightScenes[lightSceneId].lights) {
73
88
  const lightUUID = this._uuidGenerator.validate(lightId) ? lightId : this._uuidGenerator.create();
74
89
  const light = settingsEngine.light.lightScenes[lightSceneId].lights[lightId];
75
90
  let l: AbstractLight;
76
91
  switch (light.type) {
77
92
  case LIGHT_TYPE.DIRECTIONAL:
78
93
  l = new DirectionalLight({
79
- color: this._converter.toHexColor((<IDirectionalLightPropertiesV3>light.properties).color),
80
- intensity: (<IDirectionalLightPropertiesV3>light.properties).intensity,
81
- direction: this._converter.toVec3((<IDirectionalLightPropertiesV3>light.properties).direction),
82
- castShadow: (<IDirectionalLightPropertiesV3>light.properties).castShadow,
94
+ color: this._converter.toHexColor((<IDirectionalLightProperties>light.properties).color),
95
+ intensity: (<IDirectionalLightProperties>light.properties).intensity,
96
+ direction: this._converter.toVec3((<IDirectionalLightProperties>light.properties).direction),
97
+ castShadow: (<IDirectionalLightProperties>light.properties).castShadow,
83
98
  name: light.name ? light.name : lightId,
84
99
  order: light.order,
85
100
  id: lightUUID
@@ -87,9 +102,9 @@ export class LightEngine implements ILightEngine {
87
102
  break;
88
103
  case LIGHT_TYPE.HEMISPHERE:
89
104
  l = new HemisphereLight({
90
- color: this._converter.toHexColor((<IHemisphereLightPropertiesV3>light.properties).skyColor),
91
- intensity: (<IHemisphereLightPropertiesV3>light.properties).intensity,
92
- groundColor: this._converter.toHexColor((<IHemisphereLightPropertiesV3>light.properties).groundColor),
105
+ color: this._converter.toHexColor((<IHemisphereLightProperties>light.properties).skyColor),
106
+ intensity: (<IHemisphereLightProperties>light.properties).intensity,
107
+ groundColor: this._converter.toHexColor((<IHemisphereLightProperties>light.properties).groundColor),
93
108
  name: light.name ? light.name : lightId,
94
109
  order: light.order,
95
110
  id: lightUUID
@@ -97,11 +112,11 @@ export class LightEngine implements ILightEngine {
97
112
  break;
98
113
  case LIGHT_TYPE.POINT:
99
114
  l = new PointLight({
100
- color: this._converter.toHexColor((<IPointLightPropertiesV3>light.properties).color),
101
- intensity: (<IPointLightPropertiesV3>light.properties).intensity,
102
- position: this._converter.toVec3((<IPointLightPropertiesV3>light.properties).position),
103
- distance: (<IPointLightPropertiesV3>light.properties).distance,
104
- decay: (<IPointLightPropertiesV3>light.properties).decay,
115
+ color: this._converter.toHexColor((<IPointLightProperties>light.properties).color),
116
+ intensity: (<IPointLightProperties>light.properties).intensity,
117
+ position: this._converter.toVec3((<IPointLightProperties>light.properties).position),
118
+ distance: (<IPointLightProperties>light.properties).distance,
119
+ decay: (<IPointLightProperties>light.properties).decay,
105
120
  name: light.name ? light.name : lightId,
106
121
  order: light.order,
107
122
  id: lightUUID
@@ -109,14 +124,14 @@ export class LightEngine implements ILightEngine {
109
124
  break;
110
125
  case LIGHT_TYPE.SPOT:
111
126
  l = new SpotLight({
112
- color: this._converter.toHexColor((<ISpotLightPropertiesV3>light.properties).color),
113
- intensity: (<ISpotLightPropertiesV3>light.properties).intensity,
114
- position: this._converter.toVec3((<ISpotLightPropertiesV3>light.properties).position),
115
- target: this._converter.toVec3((<ISpotLightPropertiesV3>light.properties).target),
116
- distance: (<ISpotLightPropertiesV3>light.properties).distance,
117
- decay: (<ISpotLightPropertiesV3>light.properties).decay,
118
- angle: (<ISpotLightPropertiesV3>light.properties).angle,
119
- penumbra: (<ISpotLightPropertiesV3>light.properties).penumbra,
127
+ color: this._converter.toHexColor((<ISpotLightProperties>light.properties).color),
128
+ intensity: (<ISpotLightProperties>light.properties).intensity,
129
+ position: this._converter.toVec3((<ISpotLightProperties>light.properties).position),
130
+ target: this._converter.toVec3((<ISpotLightProperties>light.properties).target),
131
+ distance: (<ISpotLightProperties>light.properties).distance,
132
+ decay: (<ISpotLightProperties>light.properties).decay,
133
+ angle: (<ISpotLightProperties>light.properties).angle,
134
+ penumbra: (<ISpotLightProperties>light.properties).penumbra,
120
135
  name: light.name ? light.name : lightId,
121
136
  order: light.order,
122
137
  id: lightUUID
@@ -125,8 +140,8 @@ export class LightEngine implements ILightEngine {
125
140
  case LIGHT_TYPE.AMBIENT:
126
141
  default:
127
142
  l = new AmbientLight({
128
- color: this._converter.toHexColor((<IAmbientLightPropertiesV3>light.properties).color),
129
- intensity: (<IAmbientLightPropertiesV3>light.properties).intensity,
143
+ color: this._converter.toHexColor((<IAmbientLightProperties>light.properties).color),
144
+ intensity: (<IAmbientLightProperties>light.properties).intensity,
130
145
  name: light.name ? light.name : lightId,
131
146
  order: light.order,
132
147
  id: lightUUID
@@ -138,41 +153,41 @@ export class LightEngine implements ILightEngine {
138
153
  }
139
154
 
140
155
  // there is a light scene but no id is saved (old viewer)
141
- if(settingsEngine.light.lightSceneId === undefined && Object.values(settingsEngine.light.lightScenes).length > 0) {
156
+ if (settingsEngine.light.lightSceneId === undefined && Object.values(settingsEngine.light.lightScenes).length > 0) {
142
157
  const res = this.assignLightScene(Object.keys(settingsEngine.light.lightScenes)[0]);
143
- if(res === false){
158
+ if (res === false) {
144
159
  const ls = <LightScene>this.createLightScene({ name: settingsEngine.light.lightSceneId === 'default' ? 'default' : 'standard' });
145
- ls.addLight(new AmbientLight({color: '#ffffff', intensity: 0.5, name: 'ambient0'}));
146
- ls.addLight(new DirectionalLight({color: '#ffffff', intensity: 0.75, direction: vec3.fromValues(.5774, -.5774, .5774), castShadow: true, name: 'directional0'}));
147
- ls.addLight(new DirectionalLight({color: '#ffffff', intensity: 0.35, direction: vec3.fromValues(.25, -1, 1), castShadow: false, name: 'directional1'}));
160
+ ls.addLight(new AmbientLight({ color: '#ffffff', intensity: 0.5, name: 'ambient0' }));
161
+ ls.addLight(new DirectionalLight({ color: '#ffffff', intensity: 0.75, direction: vec3.fromValues(.5774, -.5774, .5774), castShadow: true, name: 'directional0' }));
162
+ ls.addLight(new DirectionalLight({ color: '#ffffff', intensity: 0.35, direction: vec3.fromValues(.25, -1, 1), castShadow: false, name: 'directional1' }));
148
163
  this._lightScenes[ls.id] = ls;
149
164
  }
150
165
  } // there is no standard light scene in the light scenes, but a light scene name is specified (old viewer)
151
166
  else if (settingsEngine.light.lightSceneId) {
152
167
  const res = this.assignLightScene(settingsEngine.light.lightSceneId);
153
- if(res === false){
168
+ if (res === false) {
154
169
  const ls = <LightScene>this.createLightScene({ name: settingsEngine.light.lightSceneId === 'default' ? 'default' : 'standard' });
155
- ls.addLight(new AmbientLight({color: '#ffffff', intensity: 0.5, name: 'ambient0'}));
156
- ls.addLight(new DirectionalLight({color: '#ffffff', intensity: 0.75, direction: vec3.fromValues(.5774, -.5774, .5774), castShadow: true, name: 'directional0'}));
157
- ls.addLight(new DirectionalLight({color: '#ffffff', intensity: 0.35, direction: vec3.fromValues(.25, -1, 1), castShadow: false, name: 'directional1'}));
170
+ ls.addLight(new AmbientLight({ color: '#ffffff', intensity: 0.5, name: 'ambient0' }));
171
+ ls.addLight(new DirectionalLight({ color: '#ffffff', intensity: 0.75, direction: vec3.fromValues(.5774, -.5774, .5774), castShadow: true, name: 'directional0' }));
172
+ ls.addLight(new DirectionalLight({ color: '#ffffff', intensity: 0.35, direction: vec3.fromValues(.25, -1, 1), castShadow: false, name: 'directional1' }));
158
173
  this._lightScenes[ls.id] = ls;
159
174
  }
160
- }
175
+ }
161
176
  // this can only be the case if the settings were completely empty, therefore we assign the new light scene
162
- else if(JSON.stringify(settingsEngine.settingsJson) == JSON.stringify({})) {
177
+ else if (JSON.stringify(settingsEngine.settingsJson) == JSON.stringify({})) {
163
178
  const ls = <LightScene>this.createLightScene({ name: 'standard', standard: true });
164
179
  this._lightScenes[ls.id] = ls;
165
180
  }
166
181
 
167
- if(this._update) this._update();
182
+ if (this._update) this._update();
168
183
  }
169
184
 
170
185
  public assignLightScene(id: string): boolean {
171
186
  if (!this._lightScenes[id]) {
172
- for(let lightSceneId in this._lightScenes) {
187
+ for (const lightSceneId in this._lightScenes) {
173
188
  const lightScene = this._lightScenes[lightSceneId];
174
189
  const lightSceneName = lightScene.name || lightSceneId;
175
- if(lightSceneName === id) {
190
+ if (lightSceneName === id) {
176
191
  const res = this.assignLightScene(lightSceneId);
177
192
  return res;
178
193
  }
@@ -180,11 +195,11 @@ export class LightEngine implements ILightEngine {
180
195
  return false;
181
196
  }
182
197
  this._lightScene = this._lightScenes[id];
183
- while(this._lightNode.children.length > 0)
198
+ while (this._lightNode.children.length > 0)
184
199
  this._lightNode.removeChild(this._lightNode.children[0]);
185
200
  this._lightNode.addChild(this._lightScene!.node);
186
201
  this._lightNode.updateVersion();
187
-
202
+
188
203
  return true;
189
204
  }
190
205
 
@@ -192,30 +207,30 @@ export class LightEngine implements ILightEngine {
192
207
  this._tree.root.removeChild(this._lightNode);
193
208
  }
194
209
 
195
- public createLightScene(properties: {name?: string, standard?: boolean}): ILightScene {
210
+ public createLightScene(properties: { name?: string, standard?: boolean }): ILightScene {
196
211
  const lightSceneId = this._uuidGenerator.create();
197
- const lightScene = new LightScene(this._renderingEngine, {id: lightSceneId, name: properties.name});
212
+ const lightScene = new LightScene(this._renderingEngine, { id: lightSceneId, name: properties.name });
198
213
  if (properties.standard === true) {
199
- lightScene.addLight(new DirectionalLight({color: '#ffffff', intensity: 2.5, direction: vec3.fromValues(.5774, -.5774, .5774), castShadow: true, name: 'directional0'}));
200
- lightScene.addLight(new AmbientLight({color: '#ffffff', intensity: 0.3, name: 'ambient0'}));
214
+ lightScene.addLight(new DirectionalLight({ color: '#ffffff', intensity: 2.5, direction: vec3.fromValues(.5774, -.5774, .5774), castShadow: true, name: 'directional0' }));
215
+ lightScene.addLight(new AmbientLight({ color: '#ffffff', intensity: 0.3, name: 'ambient0' }));
201
216
  }
202
217
  this._lightScenes[lightSceneId] = lightScene;
203
218
  this._lightScene = lightScene;
204
- while(this._lightNode.children.length > 0)
219
+ while (this._lightNode.children.length > 0)
205
220
  this._lightNode.removeChild(this._lightNode.children[0]);
206
- this._lightNode.addChild(this._lightScene!.node)
221
+ this._lightNode.addChild(this._lightScene!.node);
207
222
  this._lightNode.updateVersion();
208
223
 
209
- if(this._update) this._update();
224
+ if (this._update) this._update();
210
225
  return lightScene;
211
226
  }
212
227
 
213
228
  public removeLightScene(id: string): boolean {
214
229
  if (!this._lightScenes[id]) {
215
- for(let lightSceneId in this._lightScenes) {
230
+ for (const lightSceneId in this._lightScenes) {
216
231
  const lightScene = this._lightScenes[lightSceneId];
217
232
  const lightSceneName = lightScene.name || lightSceneId;
218
- if(lightSceneName === id) {
233
+ if (lightSceneName === id) {
219
234
  const res = this.removeLightScene(lightSceneId);
220
235
  return res;
221
236
  }
@@ -223,7 +238,7 @@ export class LightEngine implements ILightEngine {
223
238
  return false;
224
239
  }
225
240
 
226
- if(this._lightScene && this._lightScene.id === id) {
241
+ if (this._lightScene && this._lightScene.id === id) {
227
242
  (<any>this._lightScene) = undefined;
228
243
 
229
244
  while (this._lightNode.children.length > 0)
@@ -238,18 +253,18 @@ export class LightEngine implements ILightEngine {
238
253
 
239
254
  public saveSettings(settingsEngine: SettingsEngine) {
240
255
  settingsEngine.light.lightSceneId = this.lightScene ? this.lightScene.id : undefined;
241
-
242
- const converted: ILightSceneSettingsV3 = {};
243
- for(let lightSceneId in this._lightScenes) {
256
+
257
+ const converted: ILightSceneSettings = {};
258
+ for (const lightSceneId in this._lightScenes) {
244
259
  const lightScene = this._lightScenes[lightSceneId];
245
260
  const lightSceneName = lightScene.name || lightSceneId;
246
261
  converted[lightSceneId] = {
247
262
  name: lightSceneName,
248
263
  lights: {}
249
264
  };
250
- for(let lightId in lightScene.lights) {
265
+ for (const lightId in lightScene.lights) {
251
266
  const light = lightScene.lights[lightId];
252
-
267
+
253
268
  let properties;
254
269
  switch (light.type) {
255
270
  case LIGHT_TYPE.DIRECTIONAL:
@@ -260,14 +275,14 @@ export class LightEngine implements ILightEngine {
260
275
  castShadow: (<DirectionalLight>light).castShadow,
261
276
  shadowMapResolution: (<DirectionalLight>light).shadowMapResolution,
262
277
  shadowMapBias: (<DirectionalLight>light).shadowMapBias
263
- }
278
+ };
264
279
  break;
265
280
  case LIGHT_TYPE.HEMISPHERE:
266
281
  properties = {
267
282
  skyColor: this._converter.toHexColor(light.color),
268
283
  intensity: light.intensity,
269
284
  groundColor: this._converter.toHexColor((<HemisphereLight>light).groundColor)
270
- }
285
+ };
271
286
  break;
272
287
  case LIGHT_TYPE.POINT:
273
288
  properties = {
@@ -276,7 +291,7 @@ export class LightEngine implements ILightEngine {
276
291
  position: { x: (<PointLight>light).position[0], y: (<PointLight>light).position[1], z: (<PointLight>light).position[2] },
277
292
  distance: (<PointLight>light).distance,
278
293
  decay: (<PointLight>light).decay
279
- }
294
+ };
280
295
  break;
281
296
  case LIGHT_TYPE.SPOT:
282
297
  properties = {
@@ -288,21 +303,21 @@ export class LightEngine implements ILightEngine {
288
303
  decay: (<SpotLight>light).decay,
289
304
  angle: (<SpotLight>light).angle,
290
305
  penumbra: (<SpotLight>light).penumbra
291
- }
306
+ };
292
307
  break;
293
308
  case LIGHT_TYPE.AMBIENT:
294
309
  default:
295
310
  properties = {
296
311
  color: this._converter.toHexColor(light.color),
297
312
  intensity: light.intensity
298
- }
313
+ };
299
314
  }
300
315
  converted[lightSceneId].lights[lightId] = {
301
316
  name: light.name,
302
317
  type: light.type,
303
318
  properties
304
- }
305
- if(light.order !== undefined)
319
+ };
320
+ if (light.order !== undefined)
306
321
  converted[lightSceneId].lights[lightId].order = light.order;
307
322
  }
308
323
  }
@@ -1,17 +1,9 @@
1
- import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
1
+ import { AbstractLight } from '../AbstractLight';
2
2
  import { Color } from '@shapediver/viewer.shared.types';
3
-
4
- import { LIGHT_TYPE } from '../../interface/ILight'
5
3
  import { IAmbientLight } from '../../interface/types/IAmbientLight';
6
- import { AbstractLight } from '../AbstractLight'
4
+ import { LIGHT_TYPE } from '../../interface/ILight';
7
5
 
8
6
  export class AmbientLight extends AbstractLight implements IAmbientLight {
9
- // #region Properties (1)
10
-
11
- #threeJsObject: { [key: string]: THREE.AmbientLight } = {};
12
-
13
- // #endregion Properties (1)
14
-
15
7
  // #region Constructors (1)
16
8
 
17
9
  constructor(properties: {
@@ -23,8 +15,8 @@ export class AmbientLight extends AbstractLight implements IAmbientLight {
23
15
  version?: string
24
16
  }) {
25
17
  super({
26
- color: properties.color || '#ffffff',
27
- intensity: properties.intensity !== undefined ? properties.intensity : 1,
18
+ color: properties.color || '#ffffff',
19
+ intensity: properties.intensity !== undefined ? properties.intensity : 1,
28
20
  type: LIGHT_TYPE.AMBIENT,
29
21
  name: properties.name,
30
22
  order: properties.order,
@@ -35,20 +27,12 @@ export class AmbientLight extends AbstractLight implements IAmbientLight {
35
27
 
36
28
  // #endregion Constructors (1)
37
29
 
38
- // #region Public Accessors (1)
39
-
40
- public get threeJsObject(): { [key: string]: THREE.AmbientLight } {
41
- return this.#threeJsObject;
42
- }
43
-
44
- // #endregion Public Accessors (1)
45
-
46
30
  // #region Public Methods (1)
47
31
 
48
32
  public clone(): IAmbientLight {
49
33
  return new AmbientLight({
50
- color: this.color || '#ffffff',
51
- intensity: this.intensity || 0.5,
34
+ color: this.color || '#ffffff',
35
+ intensity: this.intensity || 0.5,
52
36
  name: this.name,
53
37
  order: this.order,
54
38
  id: this.id,
@@ -1,10 +1,8 @@
1
- import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
2
- import { vec3 } from 'gl-matrix'
1
+ import { AbstractLight } from '../AbstractLight';
3
2
  import { Color } from '@shapediver/viewer.shared.types';
4
-
5
- import { LIGHT_TYPE } from '../../interface/ILight'
6
3
  import { IDirectionalLight } from '../../interface/types/IDirectionalLight';
7
- import { AbstractLight } from '../AbstractLight'
4
+ import { LIGHT_TYPE } from '../../interface/ILight';
5
+ import { vec3 } from 'gl-matrix';
8
6
 
9
7
  export class DirectionalLight extends AbstractLight implements IDirectionalLight {
10
8
  // #region Properties (4)
@@ -13,7 +11,6 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
13
11
  #direction: vec3 = vec3.fromValues(-1, 0, 1);
14
12
  #shadowMapBias: number = -0.003;
15
13
  #shadowMapResolution: number = 1024;
16
- #threeJsObject: { [key: string]: THREE.DirectionalLight } = {};
17
14
 
18
15
  // #endregion Properties (4)
19
16
 
@@ -32,8 +29,8 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
32
29
  version?: string
33
30
  }) {
34
31
  super({
35
- color: properties.color || '#ffffff',
36
- intensity: properties.intensity !== undefined ? properties.intensity : 1,
32
+ color: properties.color || '#ffffff',
33
+ intensity: properties.intensity !== undefined ? properties.intensity : 1,
37
34
  type: LIGHT_TYPE.DIRECTIONAL,
38
35
  name: properties.name,
39
36
  order: properties.order,
@@ -41,15 +38,15 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
41
38
  version: properties.version
42
39
  });
43
40
 
44
- if(properties.direction) this.#direction = properties.direction;
45
- if(properties.castShadow !== undefined) this.#castShadow = properties.castShadow;
46
- if(properties.shadowMapResolution) this.#shadowMapResolution = properties.shadowMapResolution;
47
- if(properties.shadowMapBias) this.#shadowMapBias = properties.shadowMapBias;
41
+ if (properties.direction) this.#direction = properties.direction;
42
+ if (properties.castShadow !== undefined) this.#castShadow = properties.castShadow;
43
+ if (properties.shadowMapResolution) this.#shadowMapResolution = properties.shadowMapResolution;
44
+ if (properties.shadowMapBias) this.#shadowMapBias = properties.shadowMapBias;
48
45
  }
49
46
 
50
47
  // #endregion Constructors (1)
51
48
 
52
- // #region Public Accessors (8)
49
+ // #region Public Getters And Setters (8)
53
50
 
54
51
  public get castShadow(): boolean {
55
52
  return this.#castShadow;
@@ -58,7 +55,7 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
58
55
  public set castShadow(value: boolean) {
59
56
  this.#castShadow = value;
60
57
  this.updateVersion();
61
- if(this.parentNode) this.parentNode.updateVersion();
58
+ if (this.parentNode) this.parentNode.updateVersion();
62
59
  }
63
60
 
64
61
  public get direction(): vec3 {
@@ -68,7 +65,7 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
68
65
  public set direction(value: vec3) {
69
66
  this.#direction = value;
70
67
  this.updateVersion();
71
- if(this.parentNode) this.parentNode.updateVersion();
68
+ if (this.parentNode) this.parentNode.updateVersion();
72
69
  }
73
70
 
74
71
  public get shadowMapBias(): number {
@@ -78,7 +75,7 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
78
75
  public set shadowMapBias(value: number) {
79
76
  this.#shadowMapBias = value;
80
77
  this.updateVersion();
81
- if(this.parentNode) this.parentNode.updateVersion();
78
+ if (this.parentNode) this.parentNode.updateVersion();
82
79
  }
83
80
 
84
81
  public get shadowMapResolution(): number {
@@ -88,14 +85,10 @@ export class DirectionalLight extends AbstractLight implements IDirectionalLight
88
85
  public set shadowMapResolution(value: number) {
89
86
  this.#shadowMapResolution = value;
90
87
  this.updateVersion();
91
- if(this.parentNode) this.parentNode.updateVersion();
92
- }
93
-
94
- public get threeJsObject(): { [key: string]: THREE.DirectionalLight } {
95
- return this.#threeJsObject;
88
+ if (this.parentNode) this.parentNode.updateVersion();
96
89
  }
97
90
 
98
- // #endregion Public Accessors (8)
91
+ // #endregion Public Getters And Setters (8)
99
92
 
100
93
  // #region Public Methods (1)
101
94
 
@@ -1,16 +1,12 @@
1
- import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
2
- import { vec3 } from 'gl-matrix'
1
+ import { AbstractLight } from '../AbstractLight';
3
2
  import { Color } from '@shapediver/viewer.shared.types';
4
-
5
- import { LIGHT_TYPE } from '../../interface/ILight'
6
3
  import { IHemisphereLight } from '../../interface/types/IHemisphereLight';
7
- import { AbstractLight } from '../AbstractLight'
4
+ import { LIGHT_TYPE } from '../../interface/ILight';
8
5
 
9
6
  export class HemisphereLight extends AbstractLight implements IHemisphereLight {
10
7
  // #region Properties (1)
11
8
 
12
9
  #groundColor: Color = '#000000';
13
- #threeJsObject: { [key: string]: THREE.HemisphereLight } = {};
14
10
 
15
11
  // #endregion Properties (1)
16
12
 
@@ -40,7 +36,7 @@ export class HemisphereLight extends AbstractLight implements IHemisphereLight {
40
36
 
41
37
  // #endregion Constructors (1)
42
38
 
43
- // #region Public Accessors (2)
39
+ // #region Public Getters And Setters (2)
44
40
 
45
41
  public get groundColor(): Color {
46
42
  return this.#groundColor;
@@ -49,14 +45,10 @@ export class HemisphereLight extends AbstractLight implements IHemisphereLight {
49
45
  public set groundColor(value: Color) {
50
46
  this.#groundColor = value;
51
47
  this.updateVersion();
52
- if(this.parentNode) this.parentNode.updateVersion();
53
- }
54
-
55
- public get threeJsObject(): { [key: string]: THREE.HemisphereLight } {
56
- return this.#threeJsObject;
48
+ if (this.parentNode) this.parentNode.updateVersion();
57
49
  }
58
50
 
59
- // #endregion Public Accessors (2)
51
+ // #endregion Public Getters And Setters (2)
60
52
 
61
53
  // #region Public Methods (1)
62
54
 
@@ -1,10 +1,8 @@
1
- import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
2
- import { vec3 } from 'gl-matrix'
1
+ import { AbstractLight } from '../AbstractLight';
3
2
  import { Color } from '@shapediver/viewer.shared.types';
4
-
5
- import { LIGHT_TYPE } from '../../interface/ILight'
6
3
  import { IPointLight } from '../../interface/types/IPointLight';
7
- import { AbstractLight } from '../AbstractLight'
4
+ import { LIGHT_TYPE } from '../../interface/ILight';
5
+ import { vec3 } from 'gl-matrix';
8
6
 
9
7
  export class PointLight extends AbstractLight implements IPointLight {
10
8
  // #region Properties (3)
@@ -12,7 +10,6 @@ export class PointLight extends AbstractLight implements IPointLight {
12
10
  #decay: number = 0;
13
11
  #distance: number = 0;
14
12
  #position: vec3 = vec3.fromValues(0, 0, 0);
15
- #threeJsObject: { [key: string]: THREE.PointLight } = {};
16
13
 
17
14
  // #endregion Properties (3)
18
15
 
@@ -45,7 +42,7 @@ export class PointLight extends AbstractLight implements IPointLight {
45
42
 
46
43
  // #endregion Constructors (1)
47
44
 
48
- // #region Public Accessors (6)
45
+ // #region Public Getters And Setters (6)
49
46
 
50
47
  public get decay(): number {
51
48
  return this.#decay;
@@ -54,7 +51,7 @@ export class PointLight extends AbstractLight implements IPointLight {
54
51
  public set decay(value: number) {
55
52
  this.#decay = value;
56
53
  this.updateVersion();
57
- if(this.parentNode) this.parentNode.updateVersion();
54
+ if (this.parentNode) this.parentNode.updateVersion();
58
55
  }
59
56
 
60
57
  public get distance(): number {
@@ -64,7 +61,7 @@ export class PointLight extends AbstractLight implements IPointLight {
64
61
  public set distance(value: number) {
65
62
  this.#distance = value;
66
63
  this.updateVersion();
67
- if(this.parentNode) this.parentNode.updateVersion();
64
+ if (this.parentNode) this.parentNode.updateVersion();
68
65
  }
69
66
 
70
67
  public get position(): vec3 {
@@ -74,14 +71,10 @@ export class PointLight extends AbstractLight implements IPointLight {
74
71
  public set position(value: vec3) {
75
72
  this.#position = value;
76
73
  this.updateVersion();
77
- if(this.parentNode) this.parentNode.updateVersion();
78
- }
79
-
80
- public get threeJsObject(): { [key: string]: THREE.PointLight } {
81
- return this.#threeJsObject;
74
+ if (this.parentNode) this.parentNode.updateVersion();
82
75
  }
83
76
 
84
- // #endregion Public Accessors (6)
77
+ // #endregion Public Getters And Setters (6)
85
78
 
86
79
  // #region Public Methods (1)
87
80