@openglobus/og 0.22.2 → 0.24.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 (205) hide show
  1. package/css/og.css +137 -1
  2. package/lib/@openglobus/js/Globe.d.ts +0 -1
  3. package/lib/@openglobus/js/Object3d.d.ts +20 -10
  4. package/lib/@openglobus/js/camera/Camera.d.ts +57 -15
  5. package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
  6. package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
  7. package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
  8. package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
  9. package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
  10. package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
  11. package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  12. package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  13. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  14. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  15. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  16. package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  17. package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  18. package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  19. package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
  20. package/lib/@openglobus/js/control/index.d.ts +3 -2
  21. package/lib/@openglobus/js/entity/Entity.d.ts +282 -19
  22. package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
  23. package/lib/@openglobus/js/entity/GeoObject.d.ts +135 -39
  24. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
  25. package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
  26. package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
  27. package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
  28. package/lib/@openglobus/js/index.d.ts +2 -1
  29. package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
  30. package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
  31. package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
  32. package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
  33. package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
  34. package/lib/@openglobus/js/math/Plane.d.ts +3 -1
  35. package/lib/@openglobus/js/math/Quat.d.ts +47 -33
  36. package/lib/@openglobus/js/math/Ray.d.ts +10 -14
  37. package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
  38. package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
  39. package/lib/@openglobus/js/math.d.ts +2 -2
  40. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
  41. package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
  42. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  43. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  44. package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
  45. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +2 -0
  46. package/lib/@openglobus/js/scene/Planet.d.ts +15 -7
  47. package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
  48. package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
  49. package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
  50. package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
  51. package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
  52. package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
  53. package/lib/@openglobus/js/ui/Input.d.ts +32 -0
  54. package/lib/@openglobus/js/ui/View.d.ts +3 -1
  55. package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
  56. package/lib/@openglobus/js/utils/shared.d.ts +22 -0
  57. package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
  58. package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
  59. package/lib/@openglobus/js/webgl/Handler.d.ts +22 -12
  60. package/lib/@openglobus/og.css +1 -1
  61. package/lib/@openglobus/og.esm.js +1 -1
  62. package/lib/@openglobus/og.esm.js.map +1 -1
  63. package/lib/@openglobus/og.umd.js +1 -1
  64. package/lib/@openglobus/og.umd.js.map +1 -1
  65. package/lib/js/Globe.d.ts +0 -1
  66. package/lib/js/Globe.js +4 -2
  67. package/lib/js/Object3d.d.ts +20 -10
  68. package/lib/js/Object3d.js +124 -48
  69. package/lib/js/Popup.js +1 -1
  70. package/lib/js/camera/Camera.d.ts +57 -15
  71. package/lib/js/camera/Camera.js +109 -29
  72. package/lib/js/camera/Frustum.d.ts +3 -0
  73. package/lib/js/camera/Frustum.js +7 -0
  74. package/lib/js/camera/PlanetCamera.d.ts +13 -0
  75. package/lib/js/camera/PlanetCamera.js +52 -5
  76. package/lib/js/control/Atmosphere.js +10 -6
  77. package/lib/js/control/CameraLock.d.ts +38 -0
  78. package/lib/js/control/CameraLock.js +216 -0
  79. package/lib/js/control/Control.js +1 -1
  80. package/lib/js/control/DebugInfo.js +38 -8
  81. package/lib/js/control/KeyboardNavigation.js +9 -9
  82. package/lib/js/control/MouseNavigation.d.ts +62 -51
  83. package/lib/js/control/MouseNavigation.js +361 -305
  84. package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
  85. package/lib/js/control/MouseWheelZoomControl.js +270 -181
  86. package/lib/js/control/OldMouseNavigation.d.ts +64 -0
  87. package/lib/js/control/OldMouseNavigation.js +368 -0
  88. package/lib/js/control/ScaleControl.js +11 -5
  89. package/lib/js/control/SimpleNavigation.d.ts +27 -10
  90. package/lib/js/control/SimpleNavigation.js +149 -49
  91. package/lib/js/control/Sun.js +6 -6
  92. package/lib/js/control/TouchNavigation.js +11 -8
  93. package/lib/js/control/elevationProfile/ElevationProfileScene.js +6 -5
  94. package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  95. package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
  96. package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  97. package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
  98. package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  99. package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
  100. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  101. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +488 -0
  102. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  103. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
  104. package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  105. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +107 -0
  106. package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  107. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +31 -0
  108. package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  109. package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
  110. package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
  111. package/lib/js/control/geoObjectEditor/colors.js +8 -0
  112. package/lib/js/control/index.d.ts +3 -2
  113. package/lib/js/control/index.js +3 -2
  114. package/lib/js/control/timeline/TimelineControl.js +2 -0
  115. package/lib/js/control/visibleExtent/Segment.js +4 -4
  116. package/lib/js/entity/Entity.d.ts +282 -19
  117. package/lib/js/entity/Entity.js +497 -62
  118. package/lib/js/entity/EntityCollection.d.ts +8 -9
  119. package/lib/js/entity/EntityCollection.js +48 -45
  120. package/lib/js/entity/GeoObject.d.ts +135 -39
  121. package/lib/js/entity/GeoObject.js +150 -90
  122. package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
  123. package/lib/js/entity/GeoObjectHandler.js +198 -295
  124. package/lib/js/entity/InstanceData.d.ts +76 -0
  125. package/lib/js/entity/InstanceData.js +347 -0
  126. package/lib/js/entity/Polyline.d.ts +19 -6
  127. package/lib/js/entity/Polyline.js +76 -36
  128. package/lib/js/entity/PolylineHandler.d.ts +7 -0
  129. package/lib/js/entity/PolylineHandler.js +26 -1
  130. package/lib/js/index.d.ts +2 -1
  131. package/lib/js/index.js +2 -1
  132. package/lib/js/input/MouseHandler.d.ts +1 -0
  133. package/lib/js/input/MouseHandler.js +12 -1
  134. package/lib/js/layer/Bing.js +2 -2
  135. package/lib/js/layer/Vector.d.ts +4 -0
  136. package/lib/js/layer/Vector.js +16 -0
  137. package/lib/js/light/LightSource.d.ts +1 -139
  138. package/lib/js/light/LightSource.js +21 -227
  139. package/lib/js/math/Mat3.d.ts +1 -1
  140. package/lib/js/math/Mat3.js +1 -1
  141. package/lib/js/math/Mat4.d.ts +10 -1
  142. package/lib/js/math/Mat4.js +17 -1
  143. package/lib/js/math/Plane.d.ts +3 -1
  144. package/lib/js/math/Plane.js +11 -1
  145. package/lib/js/math/Quat.d.ts +47 -33
  146. package/lib/js/math/Quat.js +92 -90
  147. package/lib/js/math/Ray.d.ts +10 -14
  148. package/lib/js/math/Ray.js +56 -33
  149. package/lib/js/math/Vec2.d.ts +22 -0
  150. package/lib/js/math/Vec2.js +32 -0
  151. package/lib/js/math/Vec3.d.ts +15 -0
  152. package/lib/js/math/Vec3.js +30 -1
  153. package/lib/js/math.d.ts +2 -2
  154. package/lib/js/math.js +3 -3
  155. package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
  156. package/lib/js/quadTree/EntityCollectionNode.js +8 -8
  157. package/lib/js/quadTree/Node.d.ts +1 -1
  158. package/lib/js/quadTree/Node.js +2 -2
  159. package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
  160. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  161. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
  162. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  163. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
  164. package/lib/js/renderer/Renderer.d.ts +63 -44
  165. package/lib/js/renderer/Renderer.js +267 -266
  166. package/lib/js/renderer/RendererEvents.d.ts +2 -0
  167. package/lib/js/renderer/RendererEvents.js +5 -2
  168. package/lib/js/scene/Planet.d.ts +15 -7
  169. package/lib/js/scene/Planet.js +133 -90
  170. package/lib/js/scene/RenderNode.d.ts +10 -25
  171. package/lib/js/scene/RenderNode.js +70 -58
  172. package/lib/js/segment/Segment.js +4 -4
  173. package/lib/js/shaders/depth.js +2 -5
  174. package/lib/js/shaders/drawnode.d.ts +1 -0
  175. package/lib/js/shaders/drawnode.js +51 -52
  176. package/lib/js/shaders/geoObject.d.ts +1 -0
  177. package/lib/js/shaders/geoObject.js +154 -91
  178. package/lib/js/shaders/polyline.js +68 -51
  179. package/lib/js/shaders/utils.d.ts +1 -1
  180. package/lib/js/shaders/utils.js +11 -0
  181. package/lib/js/terrain/GlobusTerrain.js +2 -2
  182. package/lib/js/ui/Checkbox.d.ts +31 -0
  183. package/lib/js/ui/Checkbox.js +110 -0
  184. package/lib/js/ui/Color.js +2 -1
  185. package/lib/js/ui/Dialog.d.ts +3 -0
  186. package/lib/js/ui/Dialog.js +20 -0
  187. package/lib/js/ui/Input.d.ts +32 -0
  188. package/lib/js/ui/Input.js +107 -0
  189. package/lib/js/ui/View.d.ts +3 -1
  190. package/lib/js/ui/View.js +6 -0
  191. package/lib/js/utils/objParser.d.ts +44 -12
  192. package/lib/js/utils/objParser.js +241 -149
  193. package/lib/js/utils/shared.d.ts +22 -0
  194. package/lib/js/utils/shared.js +34 -0
  195. package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
  196. package/lib/js/webgl/Framebuffer.d.ts +35 -8
  197. package/lib/js/webgl/Framebuffer.js +136 -29
  198. package/lib/js/webgl/Handler.d.ts +22 -12
  199. package/lib/js/webgl/Handler.js +53 -34
  200. package/lib/js/webgl/Program.js +0 -8
  201. package/package.json +5 -3
  202. package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
  203. package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
  204. package/lib/js/control/EarthNavigation.d.ts +0 -50
  205. package/lib/js/control/EarthNavigation.js +0 -202
@@ -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(name: string, params: ILightSourceParams);
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(name, params) {
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._position.x = position.x;
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
- let index = 9 * rn._lightsNames.indexOf(this._name);
186
- if (index != -1) {
187
- rn._lightsParamsv[index] = r;
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
- let index = 9 * rn._lightsNames.indexOf(this._name);
202
- if (index != -1) {
203
- rn._lightsParamsv[index + 3] = r;
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
- let index = 9 * rn._lightsNames.indexOf(this._name);
218
- if (index != -1) {
219
- rn._lightsParamsv[index + 6] = r;
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
- let index = rn._lightsNames.indexOf(this._name);
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
- renderNode._lights.push(this);
266
- renderNode._lightsNames.push(this._name);
267
- renderNode._lightsParamsf.push(this._shininess);
268
- renderNode._lightsParamsv.push.apply(renderNode._lightsParamsv, this._ambient.toArray());
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 };
@@ -67,7 +67,7 @@ export declare class Mat3 {
67
67
  * @public
68
68
  * @returns {Mat4}
69
69
  */
70
- toMatrix4(): Mat4;
70
+ getMat4(): Mat4;
71
71
  }
72
72
  /**
73
73
  * Mat3 factory.
@@ -106,7 +106,7 @@ export class Mat3 {
106
106
  * @public
107
107
  * @returns {Mat4}
108
108
  */
109
- toMatrix4() {
109
+ getMat4() {
110
110
  let res = new Mat4();
111
111
  let b = res._m;
112
112
  let a = this._m;
@@ -37,6 +37,15 @@ export declare class Mat4 {
37
37
  * @returns {Mat4} -
38
38
  */
39
39
  static identity(): Mat4;
40
+ /**
41
+ * Get rotation matrix around the point
42
+ * @public
43
+ * @param {number} angle - Rotation angle in radians
44
+ * @param {Vec3} [center] - Point that the camera rotates around
45
+ * @param {Vec3} [up] - Camera up vector
46
+ */
47
+ static getRotationAroundPoint(angle: number, center?: Vec3, up?: Vec3): Mat4;
48
+ static getRotation(angle: number, up?: Vec3): Mat4;
40
49
  /**
41
50
  * Sets column-major order array matrix.
42
51
  * @public
@@ -62,7 +71,7 @@ export declare class Mat4 {
62
71
  * @public
63
72
  * @returns {Mat3} -
64
73
  */
65
- toMatrix3(): Mat3;
74
+ getMat3(): Mat3;
66
75
  /**
67
76
  * Multiply to 3d vector.
68
77
  * @public
@@ -45,6 +45,22 @@ export class Mat4 {
45
45
  res._m[15] = 1;
46
46
  return res;
47
47
  }
48
+ /**
49
+ * Get rotation matrix around the point
50
+ * @public
51
+ * @param {number} angle - Rotation angle in radians
52
+ * @param {Vec3} [center] - Point that the camera rotates around
53
+ * @param {Vec3} [up] - Camera up vector
54
+ */
55
+ static getRotationAroundPoint(angle, center = Vec3.ZERO, up = Vec3.UP) {
56
+ let rot = Mat4.getRotation(angle, up);
57
+ let tr = new Mat4().setIdentity().translate(center);
58
+ let ntr = new Mat4().setIdentity().translate(center.negateTo());
59
+ return tr.mul(rot).mul(ntr);
60
+ }
61
+ static getRotation(angle, up = Vec3.UP) {
62
+ return new Mat4().setRotation(up, angle);
63
+ }
48
64
  /**
49
65
  * Sets column-major order array matrix.
50
66
  * @public
@@ -94,7 +110,7 @@ export class Mat4 {
94
110
  * @public
95
111
  * @returns {Mat3} -
96
112
  */
97
- toMatrix3() {
113
+ getMat3() {
98
114
  let res = new Mat3();
99
115
  let a = this._m, b = res._m;
100
116
  b[0] = a[0];
@@ -9,7 +9,9 @@ import { Line3 } from "./Line3";
9
9
  declare class Plane {
10
10
  p: Vec3;
11
11
  n: Vec3;
12
- constructor(p: Vec3, n: Vec3);
12
+ constructor(p?: Vec3, n?: Vec3);
13
+ setByPoints(v0: Vec3, v1: Vec3, v2: Vec3): Plane;
14
+ static fromPoints(v0: Vec3, v1: Vec3, v2: Vec3): Plane;
13
15
  set(p: Vec3, n: Vec3): void;
14
16
  getNormal(): Vec3;
15
17
  distance(p: Vec3): number;
@@ -12,7 +12,17 @@ const INTERSECT = 2;
12
12
  class Plane {
13
13
  constructor(p, n) {
14
14
  this.p = p ? p.clone() : new Vec3();
15
- this.n = n ? n.clone() : this.p.normal();
15
+ this.n = n ? n.clone() : (this.p.isZero() ? Vec3.UP : this.p.getNormal());
16
+ }
17
+ setByPoints(v0, v1, v2) {
18
+ let u = Vec3.sub(v1, v0);
19
+ let v = Vec3.sub(v2, v0);
20
+ this.n = u.cross(v);
21
+ this.p.copy(v0);
22
+ return this;
23
+ }
24
+ static fromPoints(v0, v1, v2) {
25
+ return new Plane().setByPoints(v0, v1, v2);
16
26
  }
17
27
  set(p, n) {
18
28
  this.p.copy(p);