@shapediver/viewer.rendering-engine.light-engine 1.15.5 → 2.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.
- package/dist/implementation/AbstractLight.d.ts +3 -3
- package/dist/implementation/AbstractLight.d.ts.map +1 -1
- package/dist/implementation/LightEngine.d.ts +9 -5
- package/dist/implementation/LightEngine.d.ts.map +1 -1
- package/dist/implementation/LightEngine.js +41 -30
- package/dist/implementation/LightEngine.js.map +1 -1
- package/dist/implementation/LightScene.d.ts +8 -3
- package/dist/implementation/LightScene.d.ts.map +1 -1
- package/dist/implementation/LightScene.js +12 -1
- package/dist/implementation/LightScene.js.map +1 -1
- package/dist/implementation/types/AmbientLight.d.ts +3 -3
- package/dist/implementation/types/AmbientLight.d.ts.map +1 -1
- package/dist/implementation/types/AmbientLight.js +1 -1
- package/dist/implementation/types/AmbientLight.js.map +1 -1
- package/dist/implementation/types/DirectionalLight.d.ts +3 -3
- package/dist/implementation/types/DirectionalLight.d.ts.map +1 -1
- package/dist/implementation/types/DirectionalLight.js +1 -1
- package/dist/implementation/types/DirectionalLight.js.map +1 -1
- package/dist/implementation/types/HemisphereLight.d.ts +3 -3
- package/dist/implementation/types/HemisphereLight.d.ts.map +1 -1
- package/dist/implementation/types/HemisphereLight.js +1 -1
- package/dist/implementation/types/HemisphereLight.js.map +1 -1
- package/dist/implementation/types/PointLight.d.ts +3 -3
- package/dist/implementation/types/PointLight.d.ts.map +1 -1
- package/dist/implementation/types/PointLight.js +1 -1
- package/dist/implementation/types/PointLight.js.map +1 -1
- package/dist/implementation/types/SpotLight.d.ts +3 -3
- package/dist/implementation/types/SpotLight.d.ts.map +1 -1
- package/dist/implementation/types/SpotLight.js +1 -1
- package/dist/implementation/types/SpotLight.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interface/ILight.d.ts +4 -3
- package/dist/interface/ILight.d.ts.map +1 -1
- package/dist/interface/ILight.js +10 -10
- package/dist/interface/ILight.js.map +1 -1
- package/dist/interface/ILightEngine.d.ts +1 -0
- package/dist/interface/ILightEngine.d.ts.map +1 -1
- package/dist/interface/ILightScene.d.ts +3 -2
- package/dist/interface/ILightScene.d.ts.map +1 -1
- package/dist/interface/types/IAmbientLight.d.ts +5 -0
- package/dist/interface/types/IAmbientLight.d.ts.map +1 -0
- package/dist/interface/types/IAmbientLight.js +3 -0
- package/dist/interface/types/IAmbientLight.js.map +1 -0
- package/dist/interface/types/IDirectionalLight.d.ts +10 -0
- package/dist/interface/types/IDirectionalLight.d.ts.map +1 -0
- package/dist/interface/types/IDirectionalLight.js +3 -0
- package/dist/interface/types/IDirectionalLight.js.map +1 -0
- package/dist/interface/types/IHemisphereLight.d.ts +7 -0
- package/dist/interface/types/IHemisphereLight.d.ts.map +1 -0
- package/dist/interface/types/IHemisphereLight.js +3 -0
- package/dist/interface/types/IHemisphereLight.js.map +1 -0
- package/dist/interface/types/IPointLight.d.ts +9 -0
- package/dist/interface/types/IPointLight.d.ts.map +1 -0
- package/dist/interface/types/IPointLight.js +3 -0
- package/dist/interface/types/IPointLight.js.map +1 -0
- package/dist/interface/types/ISpotLight.d.ts +12 -0
- package/dist/interface/types/ISpotLight.d.ts.map +1 -0
- package/dist/interface/types/ISpotLight.js +3 -0
- package/dist/interface/types/ISpotLight.js.map +1 -0
- package/package.json +14 -10
- package/src/implementation/AbstractLight.ts +94 -0
- package/src/implementation/LightEngine.ts +312 -0
- package/src/implementation/LightScene.ts +128 -0
- package/src/implementation/types/AmbientLight.ts +41 -0
- package/src/implementation/types/DirectionalLight.ts +104 -0
- package/src/implementation/types/HemisphereLight.ts +65 -0
- package/src/implementation/types/PointLight.ts +90 -0
- package/src/implementation/types/SpotLight.ts +129 -0
- package/src/index.ts +28 -0
- package/src/interface/ILight.ts +24 -0
- package/src/interface/ILightEngine.ts +17 -0
- package/src/interface/ILightScene.ts +27 -0
- package/src/interface/types/IAmbientLight.ts +5 -0
- package/src/interface/types/IDirectionalLight.ts +12 -0
- package/src/interface/types/IHemisphereLight.ts +9 -0
- package/src/interface/types/IPointLight.ts +11 -0
- package/src/interface/types/ISpotLight.ts +14 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
|
|
2
|
+
import { vec3 } from 'gl-matrix'
|
|
3
|
+
|
|
4
|
+
import { LIGHT_TYPE } from '../../interface/ILight'
|
|
5
|
+
import { IPointLight } from '../../interface/types/IPointLight';
|
|
6
|
+
import { AbstractLight } from '../AbstractLight'
|
|
7
|
+
|
|
8
|
+
export class PointLight extends AbstractLight implements IPointLight {
|
|
9
|
+
// #region Properties (3)
|
|
10
|
+
|
|
11
|
+
private _decay: number = 2;
|
|
12
|
+
private _distance: number = 0;
|
|
13
|
+
private _position: vec3 = vec3.fromValues(0, 0, 0);
|
|
14
|
+
|
|
15
|
+
// #endregion Properties (3)
|
|
16
|
+
|
|
17
|
+
// #region Constructors (1)
|
|
18
|
+
|
|
19
|
+
constructor(properties: {
|
|
20
|
+
color?: string,
|
|
21
|
+
intensity?: number,
|
|
22
|
+
position?: vec3,
|
|
23
|
+
distance?: number,
|
|
24
|
+
decay?: number,
|
|
25
|
+
name?: string,
|
|
26
|
+
order?: number,
|
|
27
|
+
id?: string
|
|
28
|
+
}) {
|
|
29
|
+
super({
|
|
30
|
+
color: properties.color || '#ffffff',
|
|
31
|
+
intensity: properties.intensity !== undefined ? properties.intensity : 0.5,
|
|
32
|
+
type: LIGHT_TYPE.POINT,
|
|
33
|
+
name: properties.name,
|
|
34
|
+
order: properties.order,
|
|
35
|
+
id: properties.id
|
|
36
|
+
});
|
|
37
|
+
if (properties.position) this._position = properties.position;
|
|
38
|
+
if (properties.distance) this._distance = properties.distance;
|
|
39
|
+
if (properties.decay) this._decay = properties.decay;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// #endregion Constructors (1)
|
|
43
|
+
|
|
44
|
+
// #region Public Accessors (6)
|
|
45
|
+
|
|
46
|
+
public get decay(): number {
|
|
47
|
+
return this._decay;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public set decay(value: number) {
|
|
51
|
+
this._decay = value;
|
|
52
|
+
this.updateVersion();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get distance(): number {
|
|
56
|
+
return this._distance;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public set distance(value: number) {
|
|
60
|
+
this._distance = value;
|
|
61
|
+
this.updateVersion();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public get position(): vec3 {
|
|
65
|
+
return this._position;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public set position(value: vec3) {
|
|
69
|
+
this._position = value;
|
|
70
|
+
this.updateVersion();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// #endregion Public Accessors (6)
|
|
74
|
+
|
|
75
|
+
// #region Public Methods (1)
|
|
76
|
+
|
|
77
|
+
public clone(): IPointLight {
|
|
78
|
+
return new PointLight({
|
|
79
|
+
color: this.color,
|
|
80
|
+
position: this.position,
|
|
81
|
+
distance: this.distance,
|
|
82
|
+
decay: this.decay,
|
|
83
|
+
intensity: this.intensity,
|
|
84
|
+
name: this.name,
|
|
85
|
+
order: this.order
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// #endregion Public Methods (1)
|
|
90
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
|
|
2
|
+
import { vec3 } from 'gl-matrix'
|
|
3
|
+
|
|
4
|
+
import { LIGHT_TYPE } from '../../interface/ILight'
|
|
5
|
+
import { ISpotLight } from '../../interface/types/ISpotLight';
|
|
6
|
+
import { AbstractLight } from '../AbstractLight'
|
|
7
|
+
|
|
8
|
+
export class SpotLight extends AbstractLight implements ISpotLight {
|
|
9
|
+
// #region Properties (6)
|
|
10
|
+
|
|
11
|
+
private _angle: number = Math.PI / 4.0;
|
|
12
|
+
private _decay: number = 1;
|
|
13
|
+
private _distance: number = 0;
|
|
14
|
+
private _penumbra: number = 0.5;
|
|
15
|
+
private _position: vec3 = vec3.fromValues(-1, 0, 1);
|
|
16
|
+
private _target: vec3 = vec3.fromValues(0, 0, 0);
|
|
17
|
+
|
|
18
|
+
// #endregion Properties (6)
|
|
19
|
+
|
|
20
|
+
// #region Constructors (1)
|
|
21
|
+
|
|
22
|
+
constructor(properties: {
|
|
23
|
+
color?: string,
|
|
24
|
+
intensity?: number,
|
|
25
|
+
position?: vec3,
|
|
26
|
+
target?: vec3,
|
|
27
|
+
distance?: number,
|
|
28
|
+
decay?: number,
|
|
29
|
+
angle?: number,
|
|
30
|
+
penumbra?: number,
|
|
31
|
+
name?: string,
|
|
32
|
+
order?: number,
|
|
33
|
+
id?: string
|
|
34
|
+
}) {
|
|
35
|
+
super({
|
|
36
|
+
color: properties.color || '#ffffff',
|
|
37
|
+
intensity: properties.intensity !== undefined ? properties.intensity : 0.5,
|
|
38
|
+
type: LIGHT_TYPE.SPOT,
|
|
39
|
+
name: properties.name,
|
|
40
|
+
order: properties.order,
|
|
41
|
+
id: properties.id
|
|
42
|
+
});
|
|
43
|
+
if (properties.position) this._position = properties.position;
|
|
44
|
+
if (properties.target) this._target = properties.target;
|
|
45
|
+
if (properties.distance) this._distance = properties.distance;
|
|
46
|
+
if (properties.decay) this._decay = properties.decay;
|
|
47
|
+
if (properties.angle) this._angle = properties.angle;
|
|
48
|
+
if (properties.penumbra) this._penumbra = properties.penumbra;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// #endregion Constructors (1)
|
|
52
|
+
|
|
53
|
+
// #region Public Accessors (12)
|
|
54
|
+
|
|
55
|
+
public get angle(): number {
|
|
56
|
+
return this._angle;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public set angle(value: number) {
|
|
60
|
+
this._angle = value;
|
|
61
|
+
this.updateVersion();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public get decay(): number {
|
|
65
|
+
return this._decay;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public set decay(value: number) {
|
|
69
|
+
this._decay = value;
|
|
70
|
+
this.updateVersion();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public get distance(): number {
|
|
74
|
+
return this._distance;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public set distance(value: number) {
|
|
78
|
+
this._distance = value;
|
|
79
|
+
this.updateVersion();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get penumbra(): number {
|
|
83
|
+
return this._penumbra;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public set penumbra(value: number) {
|
|
87
|
+
this._penumbra = value;
|
|
88
|
+
this.updateVersion();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public get position(): vec3 {
|
|
92
|
+
return this._position;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public set position(value: vec3) {
|
|
96
|
+
this._position = value;
|
|
97
|
+
this.updateVersion();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public get target(): vec3 {
|
|
101
|
+
return this._target;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public set target(value: vec3) {
|
|
105
|
+
this._target = value;
|
|
106
|
+
this.updateVersion();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// #endregion Public Accessors (12)
|
|
110
|
+
|
|
111
|
+
// #region Public Methods (1)
|
|
112
|
+
|
|
113
|
+
public clone(): ISpotLight {
|
|
114
|
+
return new SpotLight({
|
|
115
|
+
color: this.color,
|
|
116
|
+
position: this.position,
|
|
117
|
+
target: this.target,
|
|
118
|
+
distance: this.distance,
|
|
119
|
+
decay: this.decay,
|
|
120
|
+
angle: this.angle,
|
|
121
|
+
penumbra: this.penumbra,
|
|
122
|
+
intensity: this.intensity,
|
|
123
|
+
name: this.name,
|
|
124
|
+
order: this.order
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// #endregion Public Methods (1)
|
|
129
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AbstractLight } from './implementation/AbstractLight'
|
|
2
|
+
import { LightEngine } from './implementation/LightEngine'
|
|
3
|
+
import { LightScene } from './implementation/LightScene'
|
|
4
|
+
import { AmbientLight } from './implementation/types/AmbientLight'
|
|
5
|
+
import { DirectionalLight } from './implementation/types/DirectionalLight'
|
|
6
|
+
import { HemisphereLight } from './implementation/types/HemisphereLight'
|
|
7
|
+
import { PointLight } from './implementation/types/PointLight'
|
|
8
|
+
import { SpotLight } from './implementation/types/SpotLight'
|
|
9
|
+
import { ILight, LIGHT_TYPE } from './interface/ILight'
|
|
10
|
+
import { ILightEngine } from './interface/ILightEngine'
|
|
11
|
+
import { ILightScene } from './interface/ILightScene'
|
|
12
|
+
import { IAmbientLight } from './interface/types/IAmbientLight'
|
|
13
|
+
import { IDirectionalLight } from './interface/types/IDirectionalLight'
|
|
14
|
+
import { IHemisphereLight } from './interface/types/IHemisphereLight'
|
|
15
|
+
import { IPointLight } from './interface/types/IPointLight'
|
|
16
|
+
import { ISpotLight } from './interface/types/ISpotLight'
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
ILightEngine, LightEngine, LIGHT_TYPE, ILightScene, LightScene, ILight
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
IAmbientLight, IDirectionalLight, IHemisphereLight, IPointLight, ISpotLight
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
AbstractLight, AmbientLight, DirectionalLight, HemisphereLight, PointLight, SpotLight
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
|
|
2
|
+
import { vec3 } from 'gl-matrix'
|
|
3
|
+
|
|
4
|
+
export enum LIGHT_TYPE {
|
|
5
|
+
AMBIENT = 'ambient',
|
|
6
|
+
DIRECTIONAL = 'directional',
|
|
7
|
+
HEMISPHERE = 'hemisphere',
|
|
8
|
+
POINT = 'point',
|
|
9
|
+
RECTANGLE = 'rectangle',
|
|
10
|
+
SPOT = 'spot'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ILight extends ITreeNodeData {
|
|
14
|
+
// #region Properties (5)
|
|
15
|
+
|
|
16
|
+
id: string;
|
|
17
|
+
color: string | number | vec3,
|
|
18
|
+
intensity: number,
|
|
19
|
+
name?: string
|
|
20
|
+
order?: number
|
|
21
|
+
type: LIGHT_TYPE,
|
|
22
|
+
|
|
23
|
+
// #endregion Properties (5)
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ILightScene } from './ILightScene'
|
|
2
|
+
|
|
3
|
+
export interface ILightEngine {
|
|
4
|
+
// #region Properties (1)
|
|
5
|
+
|
|
6
|
+
update?: () => void;
|
|
7
|
+
|
|
8
|
+
// #endregion Properties (1)
|
|
9
|
+
|
|
10
|
+
// #region Public Methods (3)
|
|
11
|
+
|
|
12
|
+
assignLightScene(id: string): boolean;
|
|
13
|
+
createLightScene(properties: {name?: string, id?: string, standard?: boolean}): ILightScene;
|
|
14
|
+
removeLightScene(id: string): boolean;
|
|
15
|
+
|
|
16
|
+
// #endregion Public Methods (3)
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree'
|
|
2
|
+
import { vec3 } from 'gl-matrix'
|
|
3
|
+
|
|
4
|
+
import { ILight } from './ILight'
|
|
5
|
+
|
|
6
|
+
export interface ILightScene {
|
|
7
|
+
// #region Properties (4)
|
|
8
|
+
|
|
9
|
+
id: string;
|
|
10
|
+
lights: { [key: string]: ILight; };
|
|
11
|
+
name?: string
|
|
12
|
+
node: ITreeNode;
|
|
13
|
+
update?: () => void;
|
|
14
|
+
|
|
15
|
+
// #endregion Properties (4)
|
|
16
|
+
|
|
17
|
+
// #region Public Methods (6)
|
|
18
|
+
|
|
19
|
+
addAmbientLight(properties: {color?: string | number | vec3, intensity?: number, id?: string, name?: string}): ILight;
|
|
20
|
+
addDirectionalLight(properties: {color?: string | number | vec3, intensity?: number, direction?: vec3, castShadow?: boolean, shadowMapResolution?: number, shadowMapBias?: number, id?: string, name?: string}): ILight;
|
|
21
|
+
addHemisphereLight(properties: {color?: string | number | vec3, intensity?: number, groundColor?: string | number | vec3, id?: string, name?: string}): ILight;
|
|
22
|
+
addPointLight(properties: {color?: string | number | vec3, intensity?: number, position?: vec3, distance?: number, decay?: number, id?: string, name?: string}): ILight;
|
|
23
|
+
addSpotLight(properties: {color?: string | number | vec3, intensity?: number, position?: vec3, target?: vec3, distance?: number, decay?: number, angle?: number, penumbra?: number, id?: string, name?: string}): ILight;
|
|
24
|
+
removeLight(id: string): boolean;
|
|
25
|
+
|
|
26
|
+
// #endregion Public Methods (6)
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix'
|
|
2
|
+
|
|
3
|
+
import { ILight } from '../ILight'
|
|
4
|
+
|
|
5
|
+
export interface IDirectionalLight extends ILight {
|
|
6
|
+
castShadow: boolean;
|
|
7
|
+
direction: vec3;
|
|
8
|
+
shadowMapBias: number;
|
|
9
|
+
shadowMapResolution: number;
|
|
10
|
+
|
|
11
|
+
clone(): IDirectionalLight;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix'
|
|
2
|
+
|
|
3
|
+
import { ILight } from '../ILight'
|
|
4
|
+
|
|
5
|
+
export interface ISpotLight extends ILight {
|
|
6
|
+
angle: number;
|
|
7
|
+
decay: number;
|
|
8
|
+
distance: number;
|
|
9
|
+
penumbra: number;
|
|
10
|
+
position: vec3;
|
|
11
|
+
target: vec3;
|
|
12
|
+
|
|
13
|
+
clone(): ISpotLight;
|
|
14
|
+
}
|
package/tsconfig.json
ADDED