@openglobus/og 0.22.2 → 0.23.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/css/og.css +137 -1
- package/lib/@openglobus/js/Object3d.d.ts +20 -10
- package/lib/@openglobus/js/camera/Camera.d.ts +9 -0
- package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
- package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
- package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/@openglobus/js/control/index.d.ts +2 -0
- package/lib/@openglobus/js/entity/Entity.d.ts +278 -19
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
- package/lib/@openglobus/js/entity/GeoObject.d.ts +141 -36
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
- package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
- package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/@openglobus/js/index.d.ts +2 -1
- package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
- package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
- package/lib/@openglobus/js/math/Quat.d.ts +46 -33
- package/lib/@openglobus/js/math/Ray.d.ts +10 -4
- package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
- package/lib/@openglobus/js/math.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +11 -7
- package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
- package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
- package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
- package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
- package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
- package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
- package/lib/@openglobus/js/ui/Input.d.ts +32 -0
- package/lib/@openglobus/js/ui/View.d.ts +3 -1
- package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
- package/lib/@openglobus/js/utils/shared.d.ts +22 -0
- package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/@openglobus/js/webgl/Handler.d.ts +1 -0
- package/lib/@openglobus/og.css +1 -1
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Object3d.d.ts +20 -10
- package/lib/js/Object3d.js +124 -48
- package/lib/js/camera/Camera.d.ts +9 -0
- package/lib/js/camera/Camera.js +27 -1
- package/lib/js/camera/Frustum.d.ts +3 -0
- package/lib/js/camera/Frustum.js +7 -0
- package/lib/js/control/Atmosphere.js +10 -6
- package/lib/js/control/CameraLock.d.ts +38 -0
- package/lib/js/control/CameraLock.js +216 -0
- package/lib/js/control/Control.js +1 -1
- package/lib/js/control/DebugInfo.js +13 -3
- package/lib/js/control/KeyboardNavigation.js +1 -1
- package/lib/js/control/ScaleControl.js +9 -3
- package/lib/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/js/control/SimpleNavigation.js +148 -49
- package/lib/js/control/Sun.js +1 -1
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +4 -4
- package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +502 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +106 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +34 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
- package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/js/control/geoObjectEditor/colors.js +8 -0
- package/lib/js/control/index.d.ts +2 -0
- package/lib/js/control/index.js +2 -0
- package/lib/js/control/timeline/TimelineControl.js +2 -0
- package/lib/js/entity/Entity.d.ts +278 -19
- package/lib/js/entity/Entity.js +483 -63
- package/lib/js/entity/EntityCollection.d.ts +8 -9
- package/lib/js/entity/EntityCollection.js +48 -45
- package/lib/js/entity/GeoObject.d.ts +141 -36
- package/lib/js/entity/GeoObject.js +153 -90
- package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/js/entity/GeoObjectHandler.js +198 -295
- package/lib/js/entity/InstanceData.d.ts +76 -0
- package/lib/js/entity/InstanceData.js +344 -0
- package/lib/js/entity/Polyline.d.ts +19 -6
- package/lib/js/entity/Polyline.js +76 -36
- package/lib/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/js/entity/PolylineHandler.js +26 -1
- package/lib/js/index.d.ts +2 -1
- package/lib/js/index.js +2 -1
- package/lib/js/layer/Bing.js +2 -2
- package/lib/js/layer/Vector.d.ts +4 -0
- package/lib/js/layer/Vector.js +16 -0
- package/lib/js/light/LightSource.d.ts +1 -139
- package/lib/js/light/LightSource.js +21 -227
- package/lib/js/math/Quat.d.ts +46 -33
- package/lib/js/math/Quat.js +91 -90
- package/lib/js/math/Ray.d.ts +10 -4
- package/lib/js/math/Ray.js +20 -4
- package/lib/js/math/Vec3.d.ts +15 -0
- package/lib/js/math/Vec3.js +30 -1
- package/lib/js/math.d.ts +2 -2
- package/lib/js/math.js +3 -3
- package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/js/quadTree/EntityCollectionNode.js +8 -8
- package/lib/js/quadTree/Node.d.ts +1 -1
- package/lib/js/quadTree/Node.js +2 -2
- package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/renderer/Renderer.d.ts +63 -44
- package/lib/js/renderer/Renderer.js +260 -263
- package/lib/js/renderer/RendererEvents.d.ts +1 -0
- package/lib/js/renderer/RendererEvents.js +2 -1
- package/lib/js/scene/Planet.d.ts +11 -7
- package/lib/js/scene/Planet.js +109 -87
- package/lib/js/scene/RenderNode.d.ts +10 -25
- package/lib/js/scene/RenderNode.js +70 -58
- package/lib/js/shaders/depth.js +2 -5
- package/lib/js/shaders/drawnode.d.ts +1 -0
- package/lib/js/shaders/drawnode.js +51 -52
- package/lib/js/shaders/geoObject.d.ts +1 -0
- package/lib/js/shaders/geoObject.js +154 -91
- package/lib/js/shaders/polyline.js +68 -51
- package/lib/js/shaders/utils.d.ts +1 -1
- package/lib/js/shaders/utils.js +11 -0
- package/lib/js/ui/Checkbox.d.ts +31 -0
- package/lib/js/ui/Checkbox.js +110 -0
- package/lib/js/ui/Color.js +2 -1
- package/lib/js/ui/Dialog.d.ts +3 -0
- package/lib/js/ui/Dialog.js +20 -0
- package/lib/js/ui/Input.d.ts +32 -0
- package/lib/js/ui/Input.js +107 -0
- package/lib/js/ui/View.d.ts +3 -1
- package/lib/js/ui/View.js +6 -0
- package/lib/js/utils/objParser.d.ts +44 -12
- package/lib/js/utils/objParser.js +241 -149
- package/lib/js/utils/shared.d.ts +22 -0
- package/lib/js/utils/shared.js +34 -0
- package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/js/webgl/Framebuffer.js +136 -29
- package/lib/js/webgl/Handler.d.ts +1 -0
- package/lib/js/webgl/Handler.js +11 -1
- package/lib/js/webgl/Program.js +0 -8
- package/package.json +4 -2
|
@@ -2,173 +2,35 @@ import { Vec3 } from "../math/Vec3";
|
|
|
2
2
|
import { RenderNode } from "../scene/RenderNode";
|
|
3
3
|
export interface ILightSourceParams {
|
|
4
4
|
position?: Vec3;
|
|
5
|
-
directional?: boolean;
|
|
6
5
|
ambient?: Vec3;
|
|
7
6
|
diffuse?: Vec3;
|
|
8
7
|
specular?: Vec3;
|
|
9
8
|
shininess?: number;
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Represents basic light source.
|
|
13
|
-
* @class
|
|
14
|
-
* @param {string} [name] - Light source name.
|
|
15
|
-
* @param {ILightSourceParams} [params] - Light parameters:
|
|
16
|
-
* @param {Vec3} [params.position] - Light source position if it is a point light, otherwise it is a light direction vector.
|
|
17
|
-
* @param {Vec3} [params.ambient] - Ambient RGB color.
|
|
18
|
-
* @param {Vec3} [params.diffuse] - Diffuse RGB color.
|
|
19
|
-
* @param {Vec3} [params.specular] - Specular RGB color.
|
|
20
|
-
* @param {number} [params.shininess] - Specular shininess.
|
|
21
|
-
*/
|
|
22
10
|
declare class LightSource {
|
|
23
|
-
static __counter__: number;
|
|
24
|
-
/**
|
|
25
|
-
* Light name.
|
|
26
|
-
* @protected
|
|
27
|
-
* @type {string}
|
|
28
|
-
*/
|
|
29
|
-
protected _name: string;
|
|
30
|
-
/**
|
|
31
|
-
* Render node where light is shines.
|
|
32
|
-
* @protected
|
|
33
|
-
* @type {RenderNode}
|
|
34
|
-
*/
|
|
35
11
|
protected _renderNode: RenderNode | null;
|
|
36
|
-
/**
|
|
37
|
-
* Light position.
|
|
38
|
-
* @public
|
|
39
|
-
* @type {Vec3}
|
|
40
|
-
*/
|
|
41
12
|
_position: Vec3;
|
|
42
|
-
/**
|
|
43
|
-
* True if the light is directional.
|
|
44
|
-
* @public
|
|
45
|
-
* @type {boolean}
|
|
46
|
-
*/
|
|
47
|
-
directional: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Ambient color.
|
|
50
|
-
* @protected
|
|
51
|
-
* @type {Vec3}
|
|
52
|
-
*/
|
|
53
13
|
protected _ambient: Vec3;
|
|
54
|
-
/**
|
|
55
|
-
* Diffuse color.
|
|
56
|
-
* @protected
|
|
57
|
-
* @type {Vec3}
|
|
58
|
-
*/
|
|
59
14
|
protected _diffuse: Vec3;
|
|
60
|
-
/**
|
|
61
|
-
* Specular color.
|
|
62
|
-
* @protected
|
|
63
|
-
* @type {Vec3}
|
|
64
|
-
*/
|
|
65
15
|
protected _specular: Vec3;
|
|
66
|
-
/**
|
|
67
|
-
* Shininess.
|
|
68
|
-
* @protected
|
|
69
|
-
* @type {number}
|
|
70
|
-
*/
|
|
71
16
|
protected _shininess: number;
|
|
72
|
-
/**
|
|
73
|
-
* Light activity.
|
|
74
|
-
* @protected
|
|
75
|
-
* @type {boolean}
|
|
76
|
-
*/
|
|
77
17
|
protected _active: boolean;
|
|
78
18
|
protected _tempAmbient: Vec3;
|
|
79
19
|
protected _tempDiffuse: Vec3;
|
|
80
20
|
protected _tempSpecular: Vec3;
|
|
81
21
|
protected _tempShininess: number;
|
|
82
|
-
constructor(
|
|
83
|
-
/**
|
|
84
|
-
* Creates clone of the current light object.
|
|
85
|
-
* @todo: TODO
|
|
86
|
-
* @public
|
|
87
|
-
* @returns {LightSource}
|
|
88
|
-
*/
|
|
89
|
-
clone(): void;
|
|
90
|
-
/**
|
|
91
|
-
* Set light activity. If activity is false the light doesn't shine.
|
|
92
|
-
* @public
|
|
93
|
-
* @param {boolean} active - Light activity.
|
|
94
|
-
*/
|
|
95
|
-
setActive(active: boolean): void;
|
|
96
|
-
/**
|
|
97
|
-
* Gets light activity.
|
|
98
|
-
* @public
|
|
99
|
-
* @returns {boolean}
|
|
100
|
-
*/
|
|
22
|
+
constructor(params: ILightSourceParams);
|
|
101
23
|
isActive(): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Set light source position, or if it is a directional type sets light direction vector.
|
|
104
|
-
* @public
|
|
105
|
-
* @param {Vec3} position - Light position or direction vector.
|
|
106
|
-
*/
|
|
107
24
|
setPosition3v(position: Vec3): void;
|
|
108
|
-
/**
|
|
109
|
-
* Set light source position, or if it is a directional type sets light direction vector.
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
25
|
setPosition(x: number, y: number, z: number): void;
|
|
113
|
-
/**
|
|
114
|
-
* Returns light source position, or if it is a directional type sets light direction vector.
|
|
115
|
-
* @public
|
|
116
|
-
* @returns {Vec3} - Light source position/direction.
|
|
117
|
-
*/
|
|
118
26
|
getPosition(): Vec3;
|
|
119
|
-
/**
|
|
120
|
-
* Set ambient color.
|
|
121
|
-
* @public
|
|
122
|
-
* @param {Vec3} rgb - Ambient color.
|
|
123
|
-
*/
|
|
124
27
|
setAmbient3v(rgb: Vec3): void;
|
|
125
|
-
/**
|
|
126
|
-
* Set diffuse color.
|
|
127
|
-
* @public
|
|
128
|
-
* @param {Vec3} rgb - Diffuse color.
|
|
129
|
-
*/
|
|
130
28
|
setDiffuse3v(rgb: Vec3): void;
|
|
131
|
-
/**
|
|
132
|
-
* Set specular color.
|
|
133
|
-
* @public
|
|
134
|
-
* @param {Vec3} rgb - Specular color.
|
|
135
|
-
*/
|
|
136
29
|
setSpecular3v(rgb: Vec3): void;
|
|
137
|
-
/**
|
|
138
|
-
* Set ambient color.
|
|
139
|
-
* @public
|
|
140
|
-
*/
|
|
141
30
|
setAmbient(r: number, g: number, b: number): void;
|
|
142
|
-
/**
|
|
143
|
-
* Set diffuse color.
|
|
144
|
-
* @public
|
|
145
|
-
*/
|
|
146
31
|
setDiffuse(r: number, g: number, b: number): void;
|
|
147
|
-
/**
|
|
148
|
-
* Set specular color.
|
|
149
|
-
* @public
|
|
150
|
-
*/
|
|
151
32
|
setSpecular(r: number, g: number, b: number): void;
|
|
152
|
-
/**
|
|
153
|
-
* Set material shininess.
|
|
154
|
-
* @public
|
|
155
|
-
*/
|
|
156
33
|
setShininess(shininess: number): void;
|
|
157
|
-
/**
|
|
158
|
-
* Sets light to black.
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
|
-
setBlack(): void;
|
|
162
|
-
/**
|
|
163
|
-
* Adds current light to the render node scene.
|
|
164
|
-
* @public
|
|
165
|
-
* @param {RenderNode} renderNode - Render node scene.
|
|
166
|
-
*/
|
|
167
34
|
addTo(renderNode: RenderNode): void;
|
|
168
|
-
/**
|
|
169
|
-
* Removes from render node scene.
|
|
170
|
-
* @public
|
|
171
|
-
*/
|
|
172
|
-
remove(): void;
|
|
173
35
|
}
|
|
174
36
|
export { LightSource };
|
|
@@ -1,292 +1,86 @@
|
|
|
1
1
|
import { Vec3 } from "../math/Vec3";
|
|
2
|
-
/**
|
|
3
|
-
* Represents basic light source.
|
|
4
|
-
* @class
|
|
5
|
-
* @param {string} [name] - Light source name.
|
|
6
|
-
* @param {ILightSourceParams} [params] - Light parameters:
|
|
7
|
-
* @param {Vec3} [params.position] - Light source position if it is a point light, otherwise it is a light direction vector.
|
|
8
|
-
* @param {Vec3} [params.ambient] - Ambient RGB color.
|
|
9
|
-
* @param {Vec3} [params.diffuse] - Diffuse RGB color.
|
|
10
|
-
* @param {Vec3} [params.specular] - Specular RGB color.
|
|
11
|
-
* @param {number} [params.shininess] - Specular shininess.
|
|
12
|
-
*/
|
|
13
2
|
class LightSource {
|
|
14
|
-
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* Light name.
|
|
17
|
-
* @protected
|
|
18
|
-
* @type {string}
|
|
19
|
-
*/
|
|
20
|
-
this._name = name || "light_" + LightSource.__counter__++;
|
|
21
|
-
/**
|
|
22
|
-
* Render node where light is shines.
|
|
23
|
-
* @protected
|
|
24
|
-
* @type {RenderNode}
|
|
25
|
-
*/
|
|
3
|
+
constructor(params) {
|
|
26
4
|
this._renderNode = null;
|
|
27
|
-
/**
|
|
28
|
-
* Light position.
|
|
29
|
-
* @public
|
|
30
|
-
* @type {Vec3}
|
|
31
|
-
*/
|
|
32
5
|
this._position = params.position || new Vec3();
|
|
33
|
-
/**
|
|
34
|
-
* True if the light is directional.
|
|
35
|
-
* @public
|
|
36
|
-
* @type {boolean}
|
|
37
|
-
*/
|
|
38
|
-
this.directional = params.directional != undefined ? params.directional : true;
|
|
39
|
-
/**
|
|
40
|
-
* Ambient color.
|
|
41
|
-
* @protected
|
|
42
|
-
* @type {Vec3}
|
|
43
|
-
*/
|
|
44
6
|
this._ambient = params.ambient || new Vec3();
|
|
45
|
-
/**
|
|
46
|
-
* Diffuse color.
|
|
47
|
-
* @protected
|
|
48
|
-
* @type {Vec3}
|
|
49
|
-
*/
|
|
50
7
|
this._diffuse = params.diffuse || new Vec3(0.8, 0.8, 0.8);
|
|
51
|
-
/**
|
|
52
|
-
* Specular color.
|
|
53
|
-
* @protected
|
|
54
|
-
* @type {Vec3}
|
|
55
|
-
*/
|
|
56
8
|
this._specular = params.specular || new Vec3(0.18, 0.18, 0.18);
|
|
57
|
-
/**
|
|
58
|
-
* Shininess.
|
|
59
|
-
* @protected
|
|
60
|
-
* @type {number}
|
|
61
|
-
*/
|
|
62
9
|
this._shininess = params.shininess != undefined ? params.shininess : 3.3;
|
|
63
|
-
/**
|
|
64
|
-
* Light activity.
|
|
65
|
-
* @protected
|
|
66
|
-
* @type {boolean}
|
|
67
|
-
*/
|
|
68
10
|
this._active = true;
|
|
69
11
|
this._tempAmbient = this._ambient.clone();
|
|
70
12
|
this._tempDiffuse = this._diffuse.clone();
|
|
71
13
|
this._tempSpecular = this._specular.clone();
|
|
72
14
|
this._tempShininess = this._shininess;
|
|
73
15
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates clone of the current light object.
|
|
76
|
-
* @todo: TODO
|
|
77
|
-
* @public
|
|
78
|
-
* @returns {LightSource}
|
|
79
|
-
*/
|
|
80
|
-
clone() {
|
|
81
|
-
// TODO
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Set light activity. If activity is false the light doesn't shine.
|
|
85
|
-
* @public
|
|
86
|
-
* @param {boolean} active - Light activity.
|
|
87
|
-
*/
|
|
88
|
-
setActive(active) {
|
|
89
|
-
if (active && !this._active) {
|
|
90
|
-
const rn = this._renderNode;
|
|
91
|
-
if (rn) {
|
|
92
|
-
let index = rn._lightsNames.indexOf(this._name);
|
|
93
|
-
this._shininess = rn._lightsParamsf[index] = this._tempShininess;
|
|
94
|
-
if (index != -1) {
|
|
95
|
-
index *= 9;
|
|
96
|
-
this._ambient.x = rn._lightsParamsv[index] = this._tempAmbient.x;
|
|
97
|
-
this._ambient.y = rn._lightsParamsv[index + 1] = this._tempAmbient.y;
|
|
98
|
-
this._ambient.z = rn._lightsParamsv[index + 2] = this._tempAmbient.z;
|
|
99
|
-
this._diffuse.x = rn._lightsParamsv[index + 3] = this._tempDiffuse.x;
|
|
100
|
-
this._diffuse.y = rn._lightsParamsv[index + 4] = this._tempDiffuse.y;
|
|
101
|
-
this._diffuse.z = rn._lightsParamsv[index + 5] = this._tempDiffuse.z;
|
|
102
|
-
this._specular.x = rn._lightsParamsv[index + 6] = this._tempSpecular.x;
|
|
103
|
-
this._specular.y = rn._lightsParamsv[index + 7] = this._tempSpecular.y;
|
|
104
|
-
this._specular.z = rn._lightsParamsv[index + 8] = this._tempSpecular.z;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
this._active = true;
|
|
108
|
-
}
|
|
109
|
-
else if (!active && this._active) {
|
|
110
|
-
this._tempAmbient = this._ambient.clone();
|
|
111
|
-
this._tempDiffuse = this._diffuse.clone();
|
|
112
|
-
this._tempSpecular = this._specular.clone();
|
|
113
|
-
this._tempShininess = this._shininess;
|
|
114
|
-
this.setBlack();
|
|
115
|
-
this._active = false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Gets light activity.
|
|
120
|
-
* @public
|
|
121
|
-
* @returns {boolean}
|
|
122
|
-
*/
|
|
123
16
|
isActive() {
|
|
124
17
|
return this._active;
|
|
125
18
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Set light source position, or if it is a directional type sets light direction vector.
|
|
128
|
-
* @public
|
|
129
|
-
* @param {Vec3} position - Light position or direction vector.
|
|
130
|
-
*/
|
|
131
19
|
setPosition3v(position) {
|
|
132
|
-
this.
|
|
133
|
-
this._position.y = position.y;
|
|
134
|
-
this._position.z = position.z;
|
|
20
|
+
this.setPosition(position.x, position.y, position.z);
|
|
135
21
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Set light source position, or if it is a directional type sets light direction vector.
|
|
138
|
-
* @public
|
|
139
|
-
*/
|
|
140
22
|
setPosition(x, y, z) {
|
|
141
23
|
this._position.x = x;
|
|
142
24
|
this._position.y = y;
|
|
143
25
|
this._position.z = z;
|
|
26
|
+
if (this._renderNode) {
|
|
27
|
+
this._renderNode._lightPosition[0] = x;
|
|
28
|
+
this._renderNode._lightPosition[1] = y;
|
|
29
|
+
this._renderNode._lightPosition[2] = z;
|
|
30
|
+
}
|
|
144
31
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Returns light source position, or if it is a directional type sets light direction vector.
|
|
147
|
-
* @public
|
|
148
|
-
* @returns {Vec3} - Light source position/direction.
|
|
149
|
-
*/
|
|
150
32
|
getPosition() {
|
|
151
33
|
return this._position.clone();
|
|
152
34
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Set ambient color.
|
|
155
|
-
* @public
|
|
156
|
-
* @param {Vec3} rgb - Ambient color.
|
|
157
|
-
*/
|
|
158
35
|
setAmbient3v(rgb) {
|
|
159
36
|
this.setAmbient(rgb.x, rgb.y, rgb.z);
|
|
160
37
|
}
|
|
161
|
-
/**
|
|
162
|
-
* Set diffuse color.
|
|
163
|
-
* @public
|
|
164
|
-
* @param {Vec3} rgb - Diffuse color.
|
|
165
|
-
*/
|
|
166
38
|
setDiffuse3v(rgb) {
|
|
167
39
|
this.setDiffuse(rgb.x, rgb.y, rgb.z);
|
|
168
40
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Set specular color.
|
|
171
|
-
* @public
|
|
172
|
-
* @param {Vec3} rgb - Specular color.
|
|
173
|
-
*/
|
|
174
41
|
setSpecular3v(rgb) {
|
|
175
42
|
this.setSpecular(rgb.x, rgb.y, rgb.z);
|
|
176
43
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Set ambient color.
|
|
179
|
-
* @public
|
|
180
|
-
*/
|
|
181
44
|
setAmbient(r, g, b) {
|
|
182
45
|
this._ambient.set(r, g, b);
|
|
183
46
|
const rn = this._renderNode;
|
|
184
47
|
if (rn) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
rn._lightsParamsv[index + 1] = g;
|
|
189
|
-
rn._lightsParamsv[index + 2] = b;
|
|
190
|
-
}
|
|
48
|
+
rn._lightParams[0] = r;
|
|
49
|
+
rn._lightParams[1] = g;
|
|
50
|
+
rn._lightParams[2] = b;
|
|
191
51
|
}
|
|
192
52
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Set diffuse color.
|
|
195
|
-
* @public
|
|
196
|
-
*/
|
|
197
53
|
setDiffuse(r, g, b) {
|
|
198
54
|
this._diffuse.set(r, g, b);
|
|
199
55
|
const rn = this._renderNode;
|
|
200
56
|
if (rn) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
rn._lightsParamsv[index + 4] = g;
|
|
205
|
-
rn._lightsParamsv[index + 5] = b;
|
|
206
|
-
}
|
|
57
|
+
rn._lightParams[3] = r;
|
|
58
|
+
rn._lightParams[4] = g;
|
|
59
|
+
rn._lightParams[5] = b;
|
|
207
60
|
}
|
|
208
61
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Set specular color.
|
|
211
|
-
* @public
|
|
212
|
-
*/
|
|
213
62
|
setSpecular(r, g, b) {
|
|
214
63
|
this._specular.set(r, g, b);
|
|
215
64
|
const rn = this._renderNode;
|
|
216
65
|
if (rn) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
rn._lightsParamsv[index + 7] = g;
|
|
221
|
-
rn._lightsParamsv[index + 8] = b;
|
|
222
|
-
}
|
|
66
|
+
rn._lightParams[6] = r;
|
|
67
|
+
rn._lightParams[7] = g;
|
|
68
|
+
rn._lightParams[8] = b;
|
|
223
69
|
}
|
|
224
70
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Set material shininess.
|
|
227
|
-
* @public
|
|
228
|
-
*/
|
|
229
71
|
setShininess(shininess) {
|
|
230
72
|
this._shininess = shininess;
|
|
231
73
|
const rn = this._renderNode;
|
|
232
74
|
if (rn) {
|
|
233
|
-
|
|
234
|
-
if (index != -1) {
|
|
235
|
-
rn._lightsParamsf[index] = shininess;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Sets light to black.
|
|
241
|
-
* @public
|
|
242
|
-
*/
|
|
243
|
-
setBlack() {
|
|
244
|
-
this._ambient.clear();
|
|
245
|
-
this._diffuse.clear();
|
|
246
|
-
this._specular.clear();
|
|
247
|
-
this._shininess = 0;
|
|
248
|
-
const rn = this._renderNode;
|
|
249
|
-
if (rn) {
|
|
250
|
-
let index = 9 * rn._lightsNames.indexOf(this._name);
|
|
251
|
-
if (index !== -1) {
|
|
252
|
-
rn._lightsParamsv[index] = rn._lightsParamsv[index + 1] = rn._lightsParamsv[index + 2] =
|
|
253
|
-
rn._lightsParamsv[index + 3] = rn._lightsParamsv[index + 4] = rn._lightsParamsv[index + 5] =
|
|
254
|
-
rn._lightsParamsv[index + 6] = rn._lightsParamsv[index + 7] = rn._lightsParamsv[index + 8] = 0;
|
|
255
|
-
}
|
|
75
|
+
rn._lightShininess = shininess;
|
|
256
76
|
}
|
|
257
77
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Adds current light to the render node scene.
|
|
260
|
-
* @public
|
|
261
|
-
* @param {RenderNode} renderNode - Render node scene.
|
|
262
|
-
*/
|
|
263
78
|
addTo(renderNode) {
|
|
264
79
|
this._renderNode = renderNode;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
renderNode._lightsParamsv.push.apply(renderNode._lightsParamsv, this._diffuse.toArray());
|
|
270
|
-
renderNode._lightsParamsv.push.apply(renderNode._lightsParamsv, this._specular.toArray());
|
|
271
|
-
renderNode.transformLights();
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Removes from render node scene.
|
|
275
|
-
* @public
|
|
276
|
-
*/
|
|
277
|
-
remove() {
|
|
278
|
-
const rn = this._renderNode;
|
|
279
|
-
if (rn) {
|
|
280
|
-
// let li = rn.getLightById(this._name);
|
|
281
|
-
// if (li != -1) {
|
|
282
|
-
// rn._lights.splice(li, 1);
|
|
283
|
-
// rn._lightsNames.splice(li, 1);
|
|
284
|
-
// rn._lightsParamsf.splice(li, 1);
|
|
285
|
-
// rn._lightsParamsv.splice(li, 9);
|
|
286
|
-
// }
|
|
287
|
-
}
|
|
288
|
-
this._renderNode = null;
|
|
80
|
+
this.setShininess(this._shininess);
|
|
81
|
+
this.setAmbient3v(this._ambient);
|
|
82
|
+
this.setDiffuse3v(this._diffuse);
|
|
83
|
+
this.setSpecular3v(this._specular);
|
|
289
84
|
}
|
|
290
85
|
}
|
|
291
|
-
LightSource.__counter__ = 0;
|
|
292
86
|
export { LightSource };
|
package/lib/js/math/Quat.d.ts
CHANGED
|
@@ -118,13 +118,18 @@ export declare class Quat {
|
|
|
118
118
|
* @returns {Quat} -
|
|
119
119
|
*/
|
|
120
120
|
static getRotationBetweenVectorsUp(source: Vec3, dest: Vec3, up: Vec3): Quat;
|
|
121
|
-
static setFromEulerAngles(pitch: number, yaw: number, roll: number): Quat;
|
|
122
121
|
/**
|
|
123
122
|
* Returns true if the components are zero.
|
|
124
123
|
* @public
|
|
125
124
|
* @returns {boolean} -
|
|
126
125
|
*/
|
|
127
126
|
isZero(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Returns true if a component is NaN.
|
|
129
|
+
* @public
|
|
130
|
+
* @returns {boolean} -
|
|
131
|
+
*/
|
|
132
|
+
isNaN(): boolean;
|
|
128
133
|
/**
|
|
129
134
|
* Clear Quat. Sets zeroes.
|
|
130
135
|
* @public
|
|
@@ -167,6 +172,13 @@ export declare class Quat {
|
|
|
167
172
|
* @returns {Quat} -
|
|
168
173
|
*/
|
|
169
174
|
add(q: Quat): Quat;
|
|
175
|
+
/**
|
|
176
|
+
* Computes the componentwise sum of two Quats.
|
|
177
|
+
* @public
|
|
178
|
+
* @param {Quat} q - Quat to add.
|
|
179
|
+
* @returns {Quat} -
|
|
180
|
+
*/
|
|
181
|
+
addRes(q: Quat, res: Quat): Quat;
|
|
170
182
|
/**
|
|
171
183
|
* Computes the componentwise difference of two Quats.
|
|
172
184
|
* @public
|
|
@@ -194,6 +206,15 @@ export declare class Quat {
|
|
|
194
206
|
* @returns {Array.<number>} - (exactly 4 entries)
|
|
195
207
|
*/
|
|
196
208
|
toVec(): [number, number, number, number];
|
|
209
|
+
get xyz(): Vec3;
|
|
210
|
+
/**
|
|
211
|
+
* Sets rotation with the given heading and up vectors.
|
|
212
|
+
* @static
|
|
213
|
+
* @param {Vec3} forward - Heading target coordinates.
|
|
214
|
+
* @param {Vec3} up - Up vector.
|
|
215
|
+
* @returns {Quat} -
|
|
216
|
+
*/
|
|
217
|
+
setLookRotation(forward: Vec3, up: Vec3): Quat;
|
|
197
218
|
/**
|
|
198
219
|
* Sets current quaternion by spherical coordinates.
|
|
199
220
|
* @public
|
|
@@ -203,20 +224,12 @@ export declare class Quat {
|
|
|
203
224
|
* @returns {Quat} -
|
|
204
225
|
*/
|
|
205
226
|
setFromSphericalCoords(lat: number, lon: number, angle: number): Quat;
|
|
206
|
-
/**
|
|
207
|
-
* Sets rotation with the given heading and up vectors.
|
|
208
|
-
* @static
|
|
209
|
-
* @param {Vec3} forward - Heading target coordinates.
|
|
210
|
-
* @param {Vec3} up - Up vector.
|
|
211
|
-
* @returns {Quat} -
|
|
212
|
-
*/
|
|
213
|
-
setLookRotation(forward: Vec3, up: Vec3): Quat;
|
|
214
227
|
/**
|
|
215
228
|
* Gets spherical coordinates.
|
|
216
229
|
* @public
|
|
217
230
|
* @returns {Object} Returns object with latitude, longitude and alpha.
|
|
218
231
|
*/
|
|
219
|
-
|
|
232
|
+
getSphericalCoords(): any;
|
|
220
233
|
/**
|
|
221
234
|
* Sets current Quat representing a rotation around an axis.
|
|
222
235
|
* @public
|
|
@@ -228,9 +241,16 @@ export declare class Quat {
|
|
|
228
241
|
/**
|
|
229
242
|
* Returns axis and angle of the current Quat.
|
|
230
243
|
* @public
|
|
231
|
-
* @returns {
|
|
244
|
+
* @returns { axis: Vec3, angle: number } -
|
|
232
245
|
*/
|
|
233
|
-
getAxisAngle():
|
|
246
|
+
getAxisAngle(): {
|
|
247
|
+
axis: Vec3;
|
|
248
|
+
angle: number;
|
|
249
|
+
};
|
|
250
|
+
getPitch(): number;
|
|
251
|
+
getYaw(): number;
|
|
252
|
+
getRoll(): number;
|
|
253
|
+
setPitchYawRoll(pitchRad: number, yawRad: number, rollRad: number, frame?: Quat): Quat;
|
|
234
254
|
/**
|
|
235
255
|
* Sets current Quat by Euler's angles.
|
|
236
256
|
* @public
|
|
@@ -274,6 +294,13 @@ export declare class Quat {
|
|
|
274
294
|
* @returns {Vec3} -
|
|
275
295
|
*/
|
|
276
296
|
mulVec3(v: Vec3): Vec3;
|
|
297
|
+
/**
|
|
298
|
+
* Returns quaternion and vector production.
|
|
299
|
+
* @public
|
|
300
|
+
* @param {Vec3} v - 3d Vector.
|
|
301
|
+
* @returns {Vec3} -
|
|
302
|
+
*/
|
|
303
|
+
mulVec3Res(v: Vec3, res: Vec3): Vec3;
|
|
277
304
|
/**
|
|
278
305
|
* Computes the product of two Quats.
|
|
279
306
|
* @public
|
|
@@ -281,6 +308,13 @@ export declare class Quat {
|
|
|
281
308
|
* @returns {Quat} -
|
|
282
309
|
*/
|
|
283
310
|
mul(q: Quat): Quat;
|
|
311
|
+
/**
|
|
312
|
+
* Computes the product of two Quats.
|
|
313
|
+
* @public
|
|
314
|
+
* @param {Quat} q - Quat to multiply.
|
|
315
|
+
* @returns {Quat} -
|
|
316
|
+
*/
|
|
317
|
+
mulRes(q: Quat, res: Quat): Quat;
|
|
284
318
|
/**
|
|
285
319
|
* Computes the product of two Quats.
|
|
286
320
|
* @public
|
|
@@ -340,27 +374,6 @@ export declare class Quat {
|
|
|
340
374
|
* @returns {Quat} -
|
|
341
375
|
*/
|
|
342
376
|
slerp(b: Quat, t: number): Quat;
|
|
343
|
-
/**
|
|
344
|
-
* Returns a roll angle in radians.
|
|
345
|
-
* @public
|
|
346
|
-
* @param {Boolean} [reprojectAxis] -
|
|
347
|
-
* @returns {Number} -
|
|
348
|
-
*/
|
|
349
|
-
getRoll(reprojectAxis?: boolean): number;
|
|
350
|
-
/**
|
|
351
|
-
* Returns a pitch angle in radians.
|
|
352
|
-
* @public
|
|
353
|
-
* @param {Boolean} [reprojectAxis] -
|
|
354
|
-
* @returns {number} -
|
|
355
|
-
*/
|
|
356
|
-
getPitch(reprojectAxis?: boolean): number;
|
|
357
|
-
/**
|
|
358
|
-
* Returns a yaw angle in radians.
|
|
359
|
-
* @public
|
|
360
|
-
* @param {Boolean} [reprojectAxis] -
|
|
361
|
-
* @returns {number} -
|
|
362
|
-
*/
|
|
363
|
-
getYaw(reprojectAxis?: boolean): number;
|
|
364
377
|
}
|
|
365
378
|
/**
|
|
366
379
|
* Creates Quat instance.
|