@shapediver/viewer.viewport 3.3.3 → 3.3.6
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.
- package/package.json +21 -22
- package/src/implementation/PostProcessingApi.ts +0 -184
- package/src/implementation/ViewportApi.ts +0 -1071
- package/src/implementation/camera/AbstractCameraApi.ts +0 -560
- package/src/implementation/camera/OrthographicCameraApi.ts +0 -43
- package/src/implementation/camera/PerspectiveCameraApi.ts +0 -43
- package/src/implementation/lights/AbstractLightApi.ts +0 -87
- package/src/implementation/lights/LightSceneApi.ts +0 -198
- package/src/implementation/lights/types/AmbientLightApi.ts +0 -24
- package/src/implementation/lights/types/DirectionalLightApi.ts +0 -80
- package/src/implementation/lights/types/HemisphereLightApi.ts +0 -44
- package/src/implementation/lights/types/PointLightApi.ts +0 -68
- package/src/implementation/lights/types/SpotLightApi.ts +0 -104
- package/src/index.ts +0 -312
- package/src/interfaces/IPostProcessingApi.ts +0 -269
- package/src/interfaces/IViewportApi.ts +0 -640
- package/src/interfaces/camera/ICameraApi.ts +0 -237
- package/src/interfaces/camera/IOrthographicCameraApi.ts +0 -18
- package/src/interfaces/camera/IPerspectiveCameraApi.ts +0 -17
- package/src/interfaces/lights/ILightApi.ts +0 -41
- package/src/interfaces/lights/ILightSceneApi.ts +0 -147
- package/src/interfaces/lights/types/IAmbientLightApi.ts +0 -7
- package/src/interfaces/lights/types/IDirectionalLightApi.ts +0 -29
- package/src/interfaces/lights/types/IHemisphereLightApi.ts +0 -17
- package/src/interfaces/lights/types/IPointLightApi.ts +0 -25
- package/src/interfaces/lights/types/ISpotLightApi.ts +0 -37
- package/src/main.ts +0 -89
- package/tsconfig.json +0 -17
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Color } from '@shapediver/viewer.shared.types';
|
|
2
|
-
import { ILight, LIGHT_TYPE } from '@shapediver/viewer.rendering-engine.light-engine';
|
|
3
|
-
import { ILightApi } from '../../interfaces/lights/ILightApi';
|
|
4
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
5
|
-
import { IViewportApi } from '../../interfaces/IViewportApi';
|
|
6
|
-
|
|
7
|
-
export abstract class AbstractLightApi implements ILightApi {
|
|
8
|
-
// #region Properties (5)
|
|
9
|
-
|
|
10
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
11
|
-
readonly #light: ILight;
|
|
12
|
-
readonly #logger: Logger = Logger.instance;
|
|
13
|
-
readonly #viewportApi: IViewportApi;
|
|
14
|
-
|
|
15
|
-
protected scope: string = 'AbstractLightApi';
|
|
16
|
-
|
|
17
|
-
// #endregion Properties (5)
|
|
18
|
-
|
|
19
|
-
// #region Constructors (1)
|
|
20
|
-
|
|
21
|
-
constructor(viewportApi: IViewportApi, light: ILight) {
|
|
22
|
-
this.#viewportApi = viewportApi;
|
|
23
|
-
this.#light = light;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// #endregion Constructors (1)
|
|
27
|
-
|
|
28
|
-
// #region Public Getters And Setters (10)
|
|
29
|
-
|
|
30
|
-
public get color(): Color {
|
|
31
|
-
return this.#light.color;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public set color(value: Color) {
|
|
35
|
-
const scope = 'color';
|
|
36
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'color');
|
|
37
|
-
this.#light.color = value;
|
|
38
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
39
|
-
this.#viewportApi.update();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public get id(): string {
|
|
43
|
-
return this.#light.id;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public get intensity(): number {
|
|
47
|
-
return this.#light.intensity;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public set intensity(value: number) {
|
|
51
|
-
const scope = 'intensity';
|
|
52
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
53
|
-
this.#light.intensity = value;
|
|
54
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
55
|
-
this.#viewportApi.update();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public get name(): string | undefined {
|
|
59
|
-
return this.#light.name;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public set name(value: string | undefined) {
|
|
63
|
-
const scope = 'name';
|
|
64
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'string', false);
|
|
65
|
-
this.#light.name = value;
|
|
66
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
67
|
-
this.#viewportApi.update();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public get order(): number | undefined {
|
|
71
|
-
return this.#light.order;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public set order(value: number | undefined) {
|
|
75
|
-
const scope = 'order';
|
|
76
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number', false);
|
|
77
|
-
this.#light.order = value;
|
|
78
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
79
|
-
this.#viewportApi.update();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public get type(): LIGHT_TYPE {
|
|
83
|
-
return this.#light.type;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// #endregion Public Getters And Setters (10)
|
|
87
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { AmbientLightApi } from './types/AmbientLightApi';
|
|
2
|
-
import { Color } from '@shapediver/viewer.shared.types';
|
|
3
|
-
import { DirectionalLightApi } from './types/DirectionalLightApi';
|
|
4
|
-
import { HemisphereLightApi } from './types/HemisphereLightApi';
|
|
5
|
-
import {
|
|
6
|
-
IAmbientLight,
|
|
7
|
-
IDirectionalLight,
|
|
8
|
-
IHemisphereLight,
|
|
9
|
-
ILightScene,
|
|
10
|
-
IPointLight,
|
|
11
|
-
ISpotLight,
|
|
12
|
-
LIGHT_TYPE
|
|
13
|
-
} from '@shapediver/viewer.rendering-engine.light-engine';
|
|
14
|
-
import { IAmbientLightApi } from '../../interfaces/lights/types/IAmbientLightApi';
|
|
15
|
-
import { IDirectionalLightApi } from '../../interfaces/lights/types/IDirectionalLightApi';
|
|
16
|
-
import { IHemisphereLightApi } from '../../interfaces/lights/types/IHemisphereLightApi';
|
|
17
|
-
import { ILightApi } from '../../interfaces/lights/ILightApi';
|
|
18
|
-
import { ILightSceneApi } from '../../interfaces/lights/ILightSceneApi';
|
|
19
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
20
|
-
import { IPointLightApi } from '../../interfaces/lights/types/IPointLightApi';
|
|
21
|
-
import { ISpotLightApi } from '../../interfaces/lights/types/ISpotLightApi';
|
|
22
|
-
import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
23
|
-
import { IViewportApi } from '../../interfaces/IViewportApi';
|
|
24
|
-
import { PointLightApi } from './types/PointLightApi';
|
|
25
|
-
import { SpotLightApi } from './types/SpotLightApi';
|
|
26
|
-
import { vec3 } from 'gl-matrix';
|
|
27
|
-
|
|
28
|
-
export class LightSceneApi implements ILightSceneApi {
|
|
29
|
-
// #region Properties (5)
|
|
30
|
-
|
|
31
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
32
|
-
readonly #lightScene: ILightScene;
|
|
33
|
-
readonly #lights: { [key: string]: ILightApi; } = {};
|
|
34
|
-
readonly #logger: Logger = Logger.instance;
|
|
35
|
-
readonly #viewportApi: IViewportApi;
|
|
36
|
-
|
|
37
|
-
// #endregion Properties (5)
|
|
38
|
-
|
|
39
|
-
// #region Constructors (1)
|
|
40
|
-
|
|
41
|
-
constructor(viewportApi: IViewportApi, lightScene: ILightScene) {
|
|
42
|
-
this.#viewportApi = viewportApi;
|
|
43
|
-
this.#lightScene = lightScene;
|
|
44
|
-
|
|
45
|
-
// Whenever a light is added or removed from the light scene, this update is called.
|
|
46
|
-
this.#lightScene.update = () => {
|
|
47
|
-
for (const l in this.#lightScene.lights) {
|
|
48
|
-
if (!this.#lights[l]) {
|
|
49
|
-
switch (this.#lightScene.lights[l].type) {
|
|
50
|
-
case LIGHT_TYPE.AMBIENT:
|
|
51
|
-
this.#lights[l] = new AmbientLightApi(this.#viewportApi, <IAmbientLight>this.#lightScene.lights[l]);
|
|
52
|
-
break;
|
|
53
|
-
case LIGHT_TYPE.DIRECTIONAL:
|
|
54
|
-
this.#lights[l] = new DirectionalLightApi(this.#viewportApi, <IDirectionalLight>this.#lightScene.lights[l]);
|
|
55
|
-
break;
|
|
56
|
-
case LIGHT_TYPE.HEMISPHERE:
|
|
57
|
-
this.#lights[l] = new HemisphereLightApi(this.#viewportApi, <IHemisphereLight>this.#lightScene.lights[l]);
|
|
58
|
-
break;
|
|
59
|
-
case LIGHT_TYPE.POINT:
|
|
60
|
-
this.#lights[l] = new PointLightApi(this.#viewportApi, <IPointLight>this.#lightScene.lights[l]);
|
|
61
|
-
break;
|
|
62
|
-
case LIGHT_TYPE.SPOT:
|
|
63
|
-
this.#lights[l] = new SpotLightApi(this.#viewportApi, <ISpotLight>this.#lightScene.lights[l]);
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
for (const l in this.#lights) {
|
|
71
|
-
if (!this.#lightScene.lights[l]) {
|
|
72
|
-
delete this.#lights[l];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// We call it once in the beginning to get the current state.
|
|
78
|
-
this.#lightScene.update();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// #endregion Constructors (1)
|
|
82
|
-
|
|
83
|
-
// #region Public Getters And Setters (5)
|
|
84
|
-
|
|
85
|
-
public get id(): string {
|
|
86
|
-
return this.#lightScene.id;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public get lights(): { [key: string]: ILightApi; } {
|
|
90
|
-
return this.#lights;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public get name(): string | undefined {
|
|
94
|
-
return this.#lightScene.name;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public set name(value: string | undefined) {
|
|
98
|
-
const scope = 'name';
|
|
99
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, value, 'string', false);
|
|
100
|
-
this.#lightScene.name = value;
|
|
101
|
-
this.#logger.debug(`LightSceneApi.${scope}: ${scope} was set to: ${value}`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public get node(): ITreeNode {
|
|
105
|
-
return this.#lightScene.node;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// #endregion Public Getters And Setters (5)
|
|
109
|
-
|
|
110
|
-
// #region Public Methods (6)
|
|
111
|
-
|
|
112
|
-
public addAmbientLight(properties: { color?: Color | undefined; intensity?: number | undefined; id?: string | undefined; name?: string | undefined; }): IAmbientLightApi {
|
|
113
|
-
const scope = 'addAmbientLight';
|
|
114
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, properties, 'object', false);
|
|
115
|
-
const prop = Object.assign({}, properties);
|
|
116
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.color, 'color', false);
|
|
117
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.intensity, 'number', false);
|
|
118
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.id, 'string', false);
|
|
119
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.name, 'string', false);
|
|
120
|
-
const light = this.#lightScene.addAmbientLight(properties);
|
|
121
|
-
this.#viewportApi.update();
|
|
122
|
-
return <IAmbientLightApi>this.#lights[light.id];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public addDirectionalLight(properties: { color?: Color | undefined; intensity?: number | undefined; direction?: vec3 | undefined; castShadow?: boolean | undefined; shadowMapResolution?: number | undefined; shadowMapBias?: number | undefined; id?: string | undefined; name?: string | undefined; }): IDirectionalLightApi {
|
|
126
|
-
const scope = 'addDirectionalLight';
|
|
127
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, properties, 'object', false);
|
|
128
|
-
const prop = Object.assign({}, properties);
|
|
129
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.color, 'color', false);
|
|
130
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.intensity, 'number', false);
|
|
131
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.direction, 'vec3', false);
|
|
132
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.castShadow, 'boolean', false);
|
|
133
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.shadowMapResolution, 'number', false);
|
|
134
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.shadowMapBias, 'number', false);
|
|
135
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.id, 'string', false);
|
|
136
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.name, 'string', false);
|
|
137
|
-
const light = this.#lightScene.addDirectionalLight(properties);
|
|
138
|
-
this.#viewportApi.update();
|
|
139
|
-
return <IDirectionalLightApi>this.#lights[light.id];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public addHemisphereLight(properties: { color?: Color | undefined; intensity?: number | undefined; groundColor?: Color | undefined; id?: string | undefined; name?: string | undefined; }): IHemisphereLightApi {
|
|
143
|
-
const scope = 'addHemisphereLight';
|
|
144
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, properties, 'object', false);
|
|
145
|
-
const prop = Object.assign({}, properties);
|
|
146
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.color, 'color', false);
|
|
147
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.intensity, 'number', false);
|
|
148
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.groundColor, 'color', false);
|
|
149
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.id, 'string', false);
|
|
150
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.name, 'string', false);
|
|
151
|
-
const light = this.#lightScene.addHemisphereLight(properties);
|
|
152
|
-
this.#viewportApi.update();
|
|
153
|
-
return <IHemisphereLightApi>this.#lights[light.id];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public addPointLight(properties: { color?: Color | undefined; intensity?: number | undefined; position?: vec3 | undefined; distance?: number | undefined; decay?: number | undefined; id?: string | undefined; name?: string | undefined; }): IPointLightApi {
|
|
157
|
-
const scope = 'addPointLight';
|
|
158
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, properties, 'object', false);
|
|
159
|
-
const prop = Object.assign({}, properties);
|
|
160
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.color, 'color', false);
|
|
161
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.intensity, 'number', false);
|
|
162
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.position, 'vec3', false);
|
|
163
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.distance, 'number', false);
|
|
164
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.decay, 'number', false);
|
|
165
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.id, 'string', false);
|
|
166
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.name, 'string', false);
|
|
167
|
-
const light = this.#lightScene.addPointLight(properties);
|
|
168
|
-
this.#viewportApi.update();
|
|
169
|
-
return <IPointLightApi>this.#lights[light.id];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public addSpotLight(properties: { color?: Color | undefined; intensity?: number | undefined; position?: vec3 | undefined; target?: vec3 | undefined; distance?: number | undefined; decay?: number | undefined; angle?: number | undefined; penumbra?: number | undefined; id?: string | undefined; name?: string | undefined; }): ISpotLightApi {
|
|
173
|
-
const scope = 'addSpotLight';
|
|
174
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, properties, 'object', false);
|
|
175
|
-
const prop = Object.assign({}, properties);
|
|
176
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.color, 'color', false);
|
|
177
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.intensity, 'number', false);
|
|
178
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.position, 'vec3', false);
|
|
179
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.target, 'vec3', false);
|
|
180
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.distance, 'number', false);
|
|
181
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.decay, 'number', false);
|
|
182
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.angle, 'number', false);
|
|
183
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.penumbra, 'number', false);
|
|
184
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.id, 'string', false);
|
|
185
|
-
this.#inputValidator.validateAndError(`LightSceneApi.${scope}`, prop.name, 'string', false);
|
|
186
|
-
const light = this.#lightScene.addSpotLight(properties);
|
|
187
|
-
this.#viewportApi.update();
|
|
188
|
-
return <ISpotLightApi>this.#lights[light.id];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
public removeLight(id: string): boolean {
|
|
192
|
-
const check = this.#lightScene.removeLight(id);
|
|
193
|
-
this.#viewportApi.update();
|
|
194
|
-
return check;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// #endregion Public Methods (6)
|
|
198
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { AbstractLightApi } from '../AbstractLightApi';
|
|
2
|
-
import { IAmbientLight } from '@shapediver/viewer.rendering-engine.light-engine';
|
|
3
|
-
import { IAmbientLightApi } from '../../../interfaces/lights/types/IAmbientLightApi';
|
|
4
|
-
import { IViewportApi } from '../../../interfaces/IViewportApi';
|
|
5
|
-
|
|
6
|
-
export class AmbientLightApi extends AbstractLightApi implements IAmbientLightApi {
|
|
7
|
-
// #region Properties (2)
|
|
8
|
-
|
|
9
|
-
readonly #light: IAmbientLight;
|
|
10
|
-
readonly #viewportApi: IViewportApi;
|
|
11
|
-
|
|
12
|
-
// #endregion Properties (2)
|
|
13
|
-
|
|
14
|
-
// #region Constructors (1)
|
|
15
|
-
|
|
16
|
-
constructor(viewportApi: IViewportApi, light: IAmbientLight) {
|
|
17
|
-
super(viewportApi, light);
|
|
18
|
-
this.#viewportApi = viewportApi;
|
|
19
|
-
this.#light = light;
|
|
20
|
-
this.scope = 'AmbientLightApi';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// #endregion Constructors (1)
|
|
24
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { AbstractLightApi } from '../AbstractLightApi';
|
|
2
|
-
import { IDirectionalLight } from '@shapediver/viewer.rendering-engine.light-engine';
|
|
3
|
-
import { IDirectionalLightApi } from '../../../interfaces/lights/types/IDirectionalLightApi';
|
|
4
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
5
|
-
import { IViewportApi } from '../../../interfaces/IViewportApi';
|
|
6
|
-
import { vec3 } from 'gl-matrix';
|
|
7
|
-
|
|
8
|
-
export class DirectionalLightApi extends AbstractLightApi implements IDirectionalLightApi {
|
|
9
|
-
// #region Properties (4)
|
|
10
|
-
|
|
11
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
12
|
-
readonly #light: IDirectionalLight;
|
|
13
|
-
readonly #logger: Logger = Logger.instance;
|
|
14
|
-
readonly #viewportApi: IViewportApi;
|
|
15
|
-
|
|
16
|
-
// #endregion Properties (4)
|
|
17
|
-
|
|
18
|
-
// #region Constructors (1)
|
|
19
|
-
|
|
20
|
-
constructor(viewportApi: IViewportApi, light: IDirectionalLight) {
|
|
21
|
-
super(viewportApi, light);
|
|
22
|
-
this.#viewportApi = viewportApi;
|
|
23
|
-
this.#light = light;
|
|
24
|
-
this.scope = 'DirectionalLightApi';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// #endregion Constructors (1)
|
|
28
|
-
|
|
29
|
-
// #region Public Getters And Setters (8)
|
|
30
|
-
|
|
31
|
-
public get castShadow(): boolean {
|
|
32
|
-
return this.#light.castShadow;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public set castShadow(value: boolean) {
|
|
36
|
-
const scope = 'castShadow';
|
|
37
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'boolean');
|
|
38
|
-
this.#light.castShadow = value;
|
|
39
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
40
|
-
this.#viewportApi.update();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public get direction(): vec3 {
|
|
44
|
-
return this.#light.direction;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public set direction(value: vec3) {
|
|
48
|
-
const scope = 'direction';
|
|
49
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'vec3');
|
|
50
|
-
this.#light.direction = value;
|
|
51
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
52
|
-
this.#viewportApi.update();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public get shadowMapBias(): number {
|
|
56
|
-
return this.#light.shadowMapBias;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public set shadowMapBias(value: number) {
|
|
60
|
-
const scope = 'shadowMapBias';
|
|
61
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
62
|
-
this.#light.shadowMapBias = value;
|
|
63
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
64
|
-
this.#viewportApi.update();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public get shadowMapResolution(): number {
|
|
68
|
-
return this.#light.shadowMapResolution;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public set shadowMapResolution(value: number) {
|
|
72
|
-
const scope = 'shadowMapResolution';
|
|
73
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
74
|
-
this.#light.shadowMapResolution = value;
|
|
75
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
76
|
-
this.#viewportApi.update();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// #endregion Public Getters And Setters (8)
|
|
80
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { AbstractLightApi } from '../AbstractLightApi';
|
|
2
|
-
import { Color } from '@shapediver/viewer.shared.types';
|
|
3
|
-
import { IHemisphereLight } from '@shapediver/viewer.rendering-engine.light-engine';
|
|
4
|
-
import { IHemisphereLightApi } from '../../../interfaces/lights/types/IHemisphereLightApi';
|
|
5
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
6
|
-
import { IViewportApi } from '../../../interfaces/IViewportApi';
|
|
7
|
-
|
|
8
|
-
export class HemisphereLightApi extends AbstractLightApi implements IHemisphereLightApi {
|
|
9
|
-
// #region Properties (4)
|
|
10
|
-
|
|
11
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
12
|
-
readonly #light: IHemisphereLight;
|
|
13
|
-
readonly #logger: Logger = Logger.instance;
|
|
14
|
-
readonly #viewportApi: IViewportApi;
|
|
15
|
-
|
|
16
|
-
// #endregion Properties (4)
|
|
17
|
-
|
|
18
|
-
// #region Constructors (1)
|
|
19
|
-
|
|
20
|
-
constructor(viewportApi: IViewportApi, light: IHemisphereLight) {
|
|
21
|
-
super(viewportApi, light);
|
|
22
|
-
this.#viewportApi = viewportApi;
|
|
23
|
-
this.#light = light;
|
|
24
|
-
this.scope = 'HemisphereLightApi';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// #endregion Constructors (1)
|
|
28
|
-
|
|
29
|
-
// #region Public Getters And Setters (2)
|
|
30
|
-
|
|
31
|
-
public get groundColor(): Color {
|
|
32
|
-
return this.#light.groundColor;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public set groundColor(value: Color) {
|
|
36
|
-
const scope = 'groundColor';
|
|
37
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'color');
|
|
38
|
-
this.#light.groundColor = value;
|
|
39
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
40
|
-
this.#viewportApi.update();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// #endregion Public Getters And Setters (2)
|
|
44
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { AbstractLightApi } from '../AbstractLightApi';
|
|
2
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
3
|
-
import { IPointLight } from '@shapediver/viewer.rendering-engine.light-engine';
|
|
4
|
-
import { IPointLightApi } from '../../../interfaces/lights/types/IPointLightApi';
|
|
5
|
-
import { IViewportApi } from '../../../interfaces/IViewportApi';
|
|
6
|
-
import { vec3 } from 'gl-matrix';
|
|
7
|
-
|
|
8
|
-
export class PointLightApi extends AbstractLightApi implements IPointLightApi {
|
|
9
|
-
// #region Properties (4)
|
|
10
|
-
|
|
11
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
12
|
-
readonly #light: IPointLight;
|
|
13
|
-
readonly #logger: Logger = Logger.instance;
|
|
14
|
-
readonly #viewportApi: IViewportApi;
|
|
15
|
-
|
|
16
|
-
// #endregion Properties (4)
|
|
17
|
-
|
|
18
|
-
// #region Constructors (1)
|
|
19
|
-
|
|
20
|
-
constructor(viewportApi: IViewportApi, light: IPointLight) {
|
|
21
|
-
super(viewportApi, light);
|
|
22
|
-
this.#viewportApi = viewportApi;
|
|
23
|
-
this.#light = light;
|
|
24
|
-
this.scope = 'PointLightApi';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// #endregion Constructors (1)
|
|
28
|
-
|
|
29
|
-
// #region Public Getters And Setters (6)
|
|
30
|
-
|
|
31
|
-
public get decay(): number {
|
|
32
|
-
return this.#light.decay;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public set decay(value: number) {
|
|
36
|
-
const scope = 'decay';
|
|
37
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
38
|
-
this.#light.decay = value;
|
|
39
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
40
|
-
this.#viewportApi.update();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public get distance(): number {
|
|
44
|
-
return this.#light.distance;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public set distance(value: number) {
|
|
48
|
-
const scope = 'distance';
|
|
49
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
50
|
-
this.#light.distance = value;
|
|
51
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
52
|
-
this.#viewportApi.update();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public get position(): vec3 {
|
|
56
|
-
return this.#light.position;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public set position(value: vec3) {
|
|
60
|
-
const scope = 'position';
|
|
61
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'vec3');
|
|
62
|
-
this.#light.position = value;
|
|
63
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
64
|
-
this.#viewportApi.update();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// #endregion Public Getters And Setters (6)
|
|
68
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { AbstractLightApi } from '../AbstractLightApi';
|
|
2
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
3
|
-
import { ISpotLight } from '@shapediver/viewer.rendering-engine.light-engine';
|
|
4
|
-
import { ISpotLightApi } from '../../../interfaces/lights/types/ISpotLightApi';
|
|
5
|
-
import { IViewportApi } from '../../../interfaces/IViewportApi';
|
|
6
|
-
import { vec3 } from 'gl-matrix';
|
|
7
|
-
|
|
8
|
-
export class SpotLightApi extends AbstractLightApi implements ISpotLightApi {
|
|
9
|
-
// #region Properties (4)
|
|
10
|
-
|
|
11
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
12
|
-
readonly #light: ISpotLight;
|
|
13
|
-
readonly #logger: Logger = Logger.instance;
|
|
14
|
-
readonly #viewportApi: IViewportApi;
|
|
15
|
-
|
|
16
|
-
// #endregion Properties (4)
|
|
17
|
-
|
|
18
|
-
// #region Constructors (1)
|
|
19
|
-
|
|
20
|
-
constructor(viewportApi: IViewportApi, light: ISpotLight) {
|
|
21
|
-
super(viewportApi, light);
|
|
22
|
-
this.#viewportApi = viewportApi;
|
|
23
|
-
this.#light = light;
|
|
24
|
-
this.scope = 'SpotLightApi';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// #endregion Constructors (1)
|
|
28
|
-
|
|
29
|
-
// #region Public Getters And Setters (12)
|
|
30
|
-
|
|
31
|
-
public get angle(): number {
|
|
32
|
-
return this.#light.angle;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public set angle(value: number) {
|
|
36
|
-
const scope = 'angle';
|
|
37
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
38
|
-
this.#light.angle = value;
|
|
39
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
40
|
-
this.#viewportApi.update();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public get decay(): number {
|
|
44
|
-
return this.#light.decay;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public set decay(value: number) {
|
|
48
|
-
const scope = 'decay';
|
|
49
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
50
|
-
this.#light.decay = value;
|
|
51
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
52
|
-
this.#viewportApi.update();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public get distance(): number {
|
|
56
|
-
return this.#light.distance;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public set distance(value: number) {
|
|
60
|
-
const scope = 'distance';
|
|
61
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
62
|
-
this.#light.distance = value;
|
|
63
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
64
|
-
this.#viewportApi.update();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public get penumbra(): number {
|
|
68
|
-
return this.#light.penumbra;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public set penumbra(value: number) {
|
|
72
|
-
const scope = 'penumbra';
|
|
73
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'number');
|
|
74
|
-
this.#light.penumbra = value;
|
|
75
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
76
|
-
this.#viewportApi.update();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public get position(): vec3 {
|
|
80
|
-
return this.#light.position;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public set position(value: vec3) {
|
|
84
|
-
const scope = 'position';
|
|
85
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'vec3');
|
|
86
|
-
this.#light.position = value;
|
|
87
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
88
|
-
this.#viewportApi.update();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public get target(): vec3 {
|
|
92
|
-
return this.#light.target;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public set target(value: vec3) {
|
|
96
|
-
const scope = 'target';
|
|
97
|
-
this.#inputValidator.validateAndError(`${this.scope}.${scope}`, value, 'vec3');
|
|
98
|
-
this.#light.target = value;
|
|
99
|
-
this.#logger.debug(`${this.scope}.${scope}: ${scope} was set to: ${value}`);
|
|
100
|
-
this.#viewportApi.update();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// #endregion Public Getters And Setters (12)
|
|
104
|
-
}
|