@openglobus/og 0.11.1 → 0.11.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.
Files changed (255) hide show
  1. package/package.json +18 -20
  2. package/src/og/Clock.js +11 -11
  3. package/src/og/Deferred.js +1 -1
  4. package/src/og/Events.js +9 -7
  5. package/src/og/Extent.js +117 -72
  6. package/src/og/Globe.js +35 -22
  7. package/src/og/ImageCanvas.js +24 -18
  8. package/src/og/Lock.js +2 -2
  9. package/src/og/LonLat.js +40 -37
  10. package/src/og/Popup.js +21 -15
  11. package/src/og/QueueArray.js +7 -3
  12. package/src/og/Rectangle.js +11 -6
  13. package/src/og/Stack.js +8 -5
  14. package/src/og/ajax.js +21 -33
  15. package/src/og/astro/astro.js +5 -5
  16. package/src/og/astro/earth.js +23 -17
  17. package/src/og/astro/jd.js +44 -39
  18. package/src/og/astro/orbit.js +20 -18
  19. package/src/og/astro/rotation.js +17 -8
  20. package/src/og/bv/Box.js +7 -3
  21. package/src/og/bv/Sphere.js +17 -9
  22. package/src/og/camera/Camera.js +137 -86
  23. package/src/og/camera/Frustum.js +30 -19
  24. package/src/og/camera/PlanetCamera.js +30 -26
  25. package/src/og/control/CompassButton.js +8 -2
  26. package/src/og/control/Control.js +13 -11
  27. package/src/og/control/DebugInfo.js +4 -1
  28. package/src/og/control/EarthCoordinates.js +62 -41
  29. package/src/og/control/EarthNavigation.js +20 -22
  30. package/src/og/control/GeoImageDragControl.js +1 -1
  31. package/src/og/control/KeyboardNavigation.js +12 -12
  32. package/src/og/control/LayerSwitcher.js +24 -23
  33. package/src/og/control/Lighting.js +1 -1
  34. package/src/og/control/MouseNavigation.js +1 -1
  35. package/src/og/control/ScaleControl.js +1 -1
  36. package/src/og/control/SegmentBoundVisualization.js +8 -9
  37. package/src/og/control/ShowFps.js +15 -10
  38. package/src/og/control/SimpleNavigation.js +8 -10
  39. package/src/og/control/Sun.js +25 -15
  40. package/src/og/control/ToggleWireframe.js +5 -5
  41. package/src/og/control/TouchNavigation.js +58 -45
  42. package/src/og/control/ZoomControl.js +41 -25
  43. package/src/og/control/index.js +4 -0
  44. package/src/og/ellipsoid/Ellipsoid.js +181 -85
  45. package/src/og/ellipsoid/wgs84.js +4 -4
  46. package/src/og/entity/BaseBillboard.js +97 -44
  47. package/src/og/entity/Billboard.js +15 -11
  48. package/src/og/entity/BillboardHandler.js +314 -64
  49. package/src/og/entity/Entity.js +106 -74
  50. package/src/og/entity/EntityCollection.js +72 -49
  51. package/src/og/entity/GeoObject.js +228 -0
  52. package/src/og/entity/GeoObjectHandler.js +910 -0
  53. package/src/og/entity/Geometry.js +29 -26
  54. package/src/og/entity/GeometryHandler.js +598 -126
  55. package/src/og/entity/Label.js +74 -40
  56. package/src/og/entity/LabelHandler.js +47 -246
  57. package/src/og/entity/LabelWorker.js +213 -0
  58. package/src/og/entity/Object3d.js +504 -0
  59. package/src/og/entity/PointCloud.js +81 -33
  60. package/src/og/entity/PointCloudHandler.js +9 -9
  61. package/src/og/entity/Polyline.js +39 -39
  62. package/src/og/entity/Ray.js +61 -28
  63. package/src/og/entity/ShapeHandler.js +1 -1
  64. package/src/og/entity/Strip.js +77 -48
  65. package/src/og/entity/StripHandler.js +27 -27
  66. package/src/og/entity/index.js +8 -16
  67. package/src/og/input/KeyboardHandler.js +107 -104
  68. package/src/og/input/MouseHandler.js +81 -78
  69. package/src/og/input/TouchHandler.js +55 -51
  70. package/src/og/layer/BaseGeoImage.js +61 -30
  71. package/src/og/layer/CanvasTiles.js +26 -24
  72. package/src/og/layer/GeoImage.js +10 -10
  73. package/src/og/layer/GeoTexture2d.js +1 -1
  74. package/src/og/layer/GeoVideo.js +3 -3
  75. package/src/og/layer/KML.js +66 -40
  76. package/src/og/layer/Layer.js +27 -17
  77. package/src/og/layer/Material.js +93 -61
  78. package/src/og/layer/Vector.js +118 -72
  79. package/src/og/layer/WMS.js +36 -19
  80. package/src/og/layer/XYZ.js +55 -48
  81. package/src/og/light/LightSource.js +47 -40
  82. package/src/og/math/Line2.js +24 -24
  83. package/src/og/math/Line3.js +103 -102
  84. package/src/og/math/Mat3.js +134 -121
  85. package/src/og/math/Mat4.js +603 -459
  86. package/src/og/math/Plane.js +21 -20
  87. package/src/og/math/Quat.js +980 -927
  88. package/src/og/math/Ray.js +195 -187
  89. package/src/og/math/Vec2.js +127 -117
  90. package/src/og/math/Vec3.js +206 -176
  91. package/src/og/math/Vec4.js +49 -53
  92. package/src/og/math/coder.js +18 -18
  93. package/src/og/math.js +12 -12
  94. package/src/og/mercator.js +11 -11
  95. package/src/og/proj/EPSG3857.js +4 -4
  96. package/src/og/proj/EPSG4326.js +4 -4
  97. package/src/og/proj/Proj.js +31 -31
  98. package/src/og/quadTree/EntityCollectionNode.js +310 -300
  99. package/src/og/quadTree/Node.js +1008 -993
  100. package/src/og/renderer/Renderer.js +768 -747
  101. package/src/og/renderer/RendererEvents.js +9 -6
  102. package/src/og/scene/Axes.js +1 -1
  103. package/src/og/scene/BaseNode.js +8 -9
  104. package/src/og/scene/Planet.js +115 -87
  105. package/src/og/scene/RenderNode.js +29 -22
  106. package/src/og/scene/SkyBox.js +1 -1
  107. package/src/og/segment/Segment.js +1886 -1878
  108. package/src/og/segment/SegmentLonLat.js +298 -268
  109. package/src/og/segment/segmentHelper.js +11 -11
  110. package/src/og/shaders/bloom.js +1 -1
  111. package/src/og/shaders/blur.js +2 -2
  112. package/src/og/shaders/depth.js +1 -1
  113. package/src/og/shaders/geoObject.js +211 -0
  114. package/src/og/shaders/label.js +1 -1
  115. package/src/og/shaders/lumFilter.js +1 -1
  116. package/src/og/shaders/pointCloud.js +42 -42
  117. package/src/og/shaders/screenFrame.js +1 -1
  118. package/src/og/shaders/shape.js +15 -21
  119. package/src/og/shaders/skybox.js +37 -37
  120. package/src/og/shaders/toneMapping.js +1 -1
  121. package/src/og/shapes/BaseShape.js +129 -57
  122. package/src/og/shapes/Icosphere.js +30 -15
  123. package/src/og/shapes/Sphere.js +13 -16
  124. package/src/og/terrain/BilTerrain.js +2 -1
  125. package/src/og/terrain/EmptyTerrain.js +2 -2
  126. package/src/og/terrain/Geoid.js +2 -2
  127. package/src/og/terrain/GlobusTerrain.js +10 -10
  128. package/src/og/terrain/MapboxTerrain.js +1 -1
  129. package/src/og/utils/GeoImageCreator.js +9 -9
  130. package/src/og/utils/Loader.js +6 -6
  131. package/src/og/utils/NormalMapCreator.js +13 -13
  132. package/src/og/utils/TerrainWorker.js +1 -1
  133. package/src/og/utils/TextureAtlas.js +20 -22
  134. package/src/og/utils/VectorTileCreator.js +5 -5
  135. package/src/og/utils/earcut.js +1 -1
  136. package/src/og/utils/shared.js +15 -15
  137. package/src/og/webgl/Framebuffer.js +101 -53
  138. package/src/og/webgl/Handler.js +125 -85
  139. package/src/og/webgl/Multisample.js +55 -27
  140. package/src/og/webgl/Program.js +80 -35
  141. package/src/og/webgl/ProgramController.js +27 -23
  142. package/src/og/webgl/callbacks.js +8 -8
  143. package/types/Clock.d.ts +6 -2
  144. package/types/Deferred.d.ts +1 -1
  145. package/types/Events.d.ts +8 -4
  146. package/types/Extent.d.ts +37 -33
  147. package/types/Globe.d.ts +15 -13
  148. package/types/ImageCanvas.d.ts +5 -3
  149. package/types/LonLat.d.ts +24 -24
  150. package/types/Popup.d.ts +4 -0
  151. package/types/QueueArray.d.ts +6 -2
  152. package/types/Rectangle.d.ts +10 -4
  153. package/types/Stack.d.ts +4 -0
  154. package/types/ajax.d.ts +1 -1
  155. package/types/astro/earth.d.ts +3 -2
  156. package/types/bv/Box.d.ts +10 -5
  157. package/types/bv/Sphere.d.ts +13 -7
  158. package/types/camera/Camera.d.ts +90 -81
  159. package/types/camera/Frustum.d.ts +26 -22
  160. package/types/camera/PlanetCamera.d.ts +49 -53
  161. package/types/control/CompassButton.d.ts +4 -4
  162. package/types/control/Control.d.ts +7 -4
  163. package/types/control/DebugInfo.d.ts +3 -4
  164. package/types/control/EarthCoordinates.d.ts +6 -6
  165. package/types/control/EarthNavigation.d.ts +42 -0
  166. package/types/control/KeyboardNavigation.d.ts +3 -4
  167. package/types/control/LayerSwitcher.d.ts +3 -5
  168. package/types/control/Lighting.d.ts +3 -3
  169. package/types/control/MouseNavigation.d.ts +47 -0
  170. package/types/control/ScaleControl.d.ts +3 -3
  171. package/types/control/ShowFps.d.ts +3 -4
  172. package/types/control/SimpleNavigation.d.ts +3 -6
  173. package/types/control/Sun.d.ts +8 -10
  174. package/types/control/ToggleWireframe.d.ts +3 -3
  175. package/types/control/TouchNavigation.d.ts +48 -0
  176. package/types/control/ZoomControl.d.ts +3 -4
  177. package/types/control/index.d.ts +3 -1
  178. package/types/ellipsoid/Ellipsoid.d.ts +47 -43
  179. package/types/ellipsoid/wgs84.d.ts +3 -2
  180. package/types/entity/BaseBillboard.d.ts +41 -34
  181. package/types/entity/Billboard.d.ts +7 -7
  182. package/types/entity/BillboardHandler.d.ts +4 -0
  183. package/types/entity/Entity.d.ts +101 -83
  184. package/types/entity/EntityCollection.d.ts +57 -43
  185. package/types/entity/GeoObject.d.ts +111 -0
  186. package/types/entity/GeoObjectHandler.d.ts +77 -0
  187. package/types/entity/Geometry.d.ts +9 -7
  188. package/types/entity/GeometryHandler.d.ts +2 -2
  189. package/types/entity/Label.d.ts +24 -29
  190. package/types/entity/LabelHandler.d.ts +9 -2
  191. package/types/entity/LabelWorker.d.ts +9 -0
  192. package/types/entity/PointCloud.d.ts +8 -8
  193. package/types/entity/PointCloudHandler.d.ts +3 -3
  194. package/types/entity/Polyline.d.ts +58 -55
  195. package/types/entity/Ray.d.ts +19 -18
  196. package/types/entity/Strip.d.ts +8 -7
  197. package/types/entity/StripHandler.d.ts +3 -3
  198. package/types/entity/index.d.ts +7 -7
  199. package/types/input/KeyboardHandler.d.ts +10 -0
  200. package/types/input/MouseHandler.d.ts +5 -0
  201. package/types/input/TouchHandler.d.ts +5 -0
  202. package/types/layer/BaseGeoImage.d.ts +23 -35
  203. package/types/layer/CanvasTiles.d.ts +15 -22
  204. package/types/layer/GeoImage.d.ts +5 -18
  205. package/types/layer/GeoVideo.d.ts +5 -30
  206. package/types/layer/KML.d.ts +20 -15
  207. package/types/layer/Layer.d.ts +326 -0
  208. package/types/layer/Material.d.ts +45 -0
  209. package/types/layer/Vector.d.ts +208 -0
  210. package/types/layer/WMS.d.ts +4 -7
  211. package/types/layer/XYZ.d.ts +19 -25
  212. package/types/light/LightSource.d.ts +54 -53
  213. package/types/math/Line2.d.ts +11 -0
  214. package/types/math/Line3.d.ts +10 -0
  215. package/types/math/Mat3.d.ts +30 -18
  216. package/types/math/Mat4.d.ts +71 -52
  217. package/types/math/Plane.d.ts +5 -4
  218. package/types/math/Quat.d.ts +379 -0
  219. package/types/math/Ray.d.ts +82 -0
  220. package/types/math/Vec2.d.ts +102 -101
  221. package/types/math/Vec3.d.ts +143 -142
  222. package/types/math/Vec4.d.ts +40 -39
  223. package/types/math/coder.d.ts +12 -11
  224. package/types/math.d.ts +8 -8
  225. package/types/mercator.d.ts +3 -3
  226. package/types/proj/EPSG3857.d.ts +3 -2
  227. package/types/proj/EPSG4326.d.ts +3 -2
  228. package/types/proj/Proj.d.ts +42 -0
  229. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  230. package/types/quadTree/Node.d.ts +61 -0
  231. package/types/renderer/Renderer.d.ts +300 -0
  232. package/types/renderer/RendererEvents.d.ts +10 -7
  233. package/types/scene/BaseNode.d.ts +9 -9
  234. package/types/scene/Planet.d.ts +131 -126
  235. package/types/scene/RenderNode.d.ts +22 -23
  236. package/types/segment/Segment.d.ts +279 -0
  237. package/types/segment/SegmentLonLat.d.ts +16 -0
  238. package/types/shaders/geoObject.d.ts +3 -0
  239. package/types/shapes/BaseShape.d.ts +43 -40
  240. package/types/shapes/Sphere.d.ts +7 -7
  241. package/types/terrain/BilTerrain.d.ts +0 -1
  242. package/types/terrain/EmptyTerrain.d.ts +4 -4
  243. package/types/terrain/GlobusTerrain.d.ts +17 -54
  244. package/types/terrain/MapboxTerrain.d.ts +0 -1
  245. package/types/utils/GeoImageCreator.d.ts +3 -2
  246. package/types/utils/TextureAtlas.d.ts +8 -8
  247. package/types/utils/shared.d.ts +25 -24
  248. package/types/webgl/Framebuffer.d.ts +5 -5
  249. package/types/webgl/Handler.d.ts +68 -43
  250. package/types/webgl/Multisample.d.ts +5 -5
  251. package/types/webgl/Program.d.ts +8 -2
  252. package/types/webgl/ProgramController.d.ts +18 -13
  253. package/src/og/inherits.js +0 -8
  254. package/src/og/utils/polylabel.js +0 -176
  255. package/types/inherits.d.ts +0 -4
@@ -2,12 +2,12 @@
2
2
  * @module og/webgl/Multisample
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
7
  /**
8
8
  * Class represents multisample framebuffer.
9
9
  * @class
10
- * @param {og.webgl.Handler} handler - WebGL handler.
10
+ * @param {Handler} handler - WebGL handler.
11
11
  * @param {Object} [options] - Framebuffer options:
12
12
  * @param {number} [options.width] - Framebuffer width. Default is handler canvas width.
13
13
  * @param {number} [options.height] - Framebuffer height. Default is handler canvas height.
@@ -16,19 +16,19 @@
16
16
  * @param {Boolean} [options.useDepth] - Using depth buffer during the rendering.
17
17
  */
18
18
  export class Multisample {
19
-
20
19
  constructor(handler, options) {
21
-
22
20
  options = options || {};
23
21
 
24
22
  /**
25
23
  * WebGL handler.
26
24
  * @public
27
- * @type {og.webgl.Handler}
25
+ * @type {Handler}
28
26
  */
29
27
  this.handler = handler;
30
28
 
31
- this._internalFormat = options.internalFormat ? options.internalFormat.toUpperCase() : "RGBA8";
29
+ this._internalFormat = options.internalFormat
30
+ ? options.internalFormat.toUpperCase()
31
+ : "RGBA8";
32
32
 
33
33
  /**
34
34
  * Framebuffer object.
@@ -62,10 +62,11 @@ export class Multisample {
62
62
 
63
63
  this._useDepth = options.useDepth != undefined ? options.useDepth : true;
64
64
 
65
- this._depthComponent = options.depthComponent != undefined ? options.depthComponent : "DEPTH_COMPONENT16";
65
+ this._depthComponent =
66
+ options.depthComponent != undefined ? options.depthComponent : "DEPTH_COMPONENT16";
66
67
 
67
68
  /**
68
- * Framebuffer activity.
69
+ * Framebuffer activity.
69
70
  * @private
70
71
  * @type {boolean}
71
72
  */
@@ -78,7 +79,7 @@ export class Multisample {
78
79
  this._glFilter = null;
79
80
 
80
81
  this.renderbuffers = new Array(this._size);
81
- };
82
+ }
82
83
 
83
84
  destroy() {
84
85
  var gl = this.handler.gl;
@@ -95,14 +96,13 @@ export class Multisample {
95
96
  this._fbo = null;
96
97
 
97
98
  this._active = false;
98
- };
99
+ }
99
100
 
100
101
  /**
101
102
  * Framebuffer initialization.
102
103
  * @private
103
104
  */
104
105
  init() {
105
-
106
106
  var gl = this.handler.gl;
107
107
 
108
108
  this._glFilter = gl[this._filter];
@@ -115,8 +115,19 @@ export class Multisample {
115
115
  for (var i = 0; i < this.renderbuffers.length; i++) {
116
116
  let rb = gl.createRenderbuffer();
117
117
  gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
118
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, this._msaa, gl[this._internalFormat], this._width, this._height);
119
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, rb);
118
+ gl.renderbufferStorageMultisample(
119
+ gl.RENDERBUFFER,
120
+ this._msaa,
121
+ gl[this._internalFormat],
122
+ this._width,
123
+ this._height
124
+ );
125
+ gl.framebufferRenderbuffer(
126
+ gl.FRAMEBUFFER,
127
+ gl.COLOR_ATTACHMENT0 + i,
128
+ gl.RENDERBUFFER,
129
+ rb
130
+ );
120
131
  colorAttachments.push(gl.COLOR_ATTACHMENT0 + i);
121
132
  this.renderbuffers[i] = rb;
122
133
  gl.bindRenderbuffer(gl.RENDERBUFFER, null);
@@ -126,18 +137,28 @@ export class Multisample {
126
137
  if (this._useDepth) {
127
138
  this._depthRenderbuffer = gl.createRenderbuffer();
128
139
  gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderbuffer);
129
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, this._msaa, gl[this._depthComponent], this._width, this._height);
130
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderbuffer);
140
+ gl.renderbufferStorageMultisample(
141
+ gl.RENDERBUFFER,
142
+ this._msaa,
143
+ gl[this._depthComponent],
144
+ this._width,
145
+ this._height
146
+ );
147
+ gl.framebufferRenderbuffer(
148
+ gl.FRAMEBUFFER,
149
+ gl.DEPTH_ATTACHMENT,
150
+ gl.RENDERBUFFER,
151
+ this._depthRenderbuffer
152
+ );
131
153
  gl.bindRenderbuffer(gl.RENDERBUFFER, null);
132
154
  }
133
155
 
134
156
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
135
157
 
136
158
  return this;
137
- };
159
+ }
138
160
 
139
161
  blitTo(framebuffer, attachmentIndex = 0) {
140
-
141
162
  let gl = this.handler.gl;
142
163
 
143
164
  gl.bindFramebuffer(gl.READ_FRAMEBUFFER, this._fbo);
@@ -147,15 +168,22 @@ export class Multisample {
147
168
  gl.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 1.0]);
148
169
 
149
170
  gl.blitFramebuffer(
150
- 0, 0, this._width, this._height,
151
- 0, 0, framebuffer._width, framebuffer._height,
152
- gl.COLOR_BUFFER_BIT, this._glFilter
171
+ 0,
172
+ 0,
173
+ this._width,
174
+ this._height,
175
+ 0,
176
+ 0,
177
+ framebuffer._width,
178
+ framebuffer._height,
179
+ gl.COLOR_BUFFER_BIT,
180
+ this._glFilter
153
181
  );
154
182
 
155
183
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
156
184
  gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
157
185
  gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
158
- };
186
+ }
159
187
 
160
188
  /**
161
189
  * Sets framebuffer viewport size.
@@ -175,7 +203,7 @@ export class Multisample {
175
203
  this.destroy();
176
204
  this.init();
177
205
  }
178
- };
206
+ }
179
207
 
180
208
  /**
181
209
  * Returns framebuffer completed.
@@ -188,12 +216,12 @@ export class Multisample {
188
216
  return true;
189
217
  }
190
218
  return false;
191
- };
219
+ }
192
220
 
193
221
  /**
194
222
  * Activate framebuffer frame to draw.
195
223
  * @public
196
- * @returns {og.webgl.Framebuffer} Returns Current framebuffer.
224
+ * @returns {Framebuffer} Returns Current framebuffer.
197
225
  */
198
226
  activate() {
199
227
  var gl = this.handler.gl;
@@ -205,7 +233,7 @@ export class Multisample {
205
233
  c && (c._active = false);
206
234
  this.handler.framebufferStack.push(this);
207
235
  return this;
208
- };
236
+ }
209
237
 
210
238
  /**
211
239
  * Deactivate framebuffer frame.
@@ -228,5 +256,5 @@ export class Multisample {
228
256
  } else {
229
257
  gl.viewport(0, 0, h.canvas.width, h.canvas.height);
230
258
  }
231
- };
232
- }
259
+ }
260
+ }
@@ -2,20 +2,13 @@
2
2
  * @module og/webgl/Program
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { callbacks } from './callbacks.js';
8
- import { cons } from '../cons.js';
9
- import { typeStr } from './types.js';
7
+ import { callbacks } from "./callbacks.js";
8
+ import { cons } from "../cons.js";
9
+ import { typeStr, types } from "./types.js";
10
10
 
11
- const itemTypes = [
12
- "BYTE",
13
- "SHORT",
14
- "UNSIGNED_BYTE",
15
- "UNSIGNED_SHORT",
16
- "FLOAT",
17
- "HALF_FLOAT"
18
- ];
11
+ const itemTypes = ["BYTE", "SHORT", "UNSIGNED_BYTE", "UNSIGNED_SHORT", "FLOAT", "HALF_FLOAT"];
19
12
 
20
13
  /**
21
14
  * Represents more comfortable using WebGL shader program.
@@ -46,9 +39,11 @@ class Program {
46
39
  */
47
40
  this._attributes = {};
48
41
  for (let t in material.attributes) {
49
- if (typeof (material.attributes[t]) === "string" ||
50
- typeof (material.attributes[t]) === "number") {
51
- this._attributes[t] = { 'type': material.attributes[t] };
42
+ if (
43
+ typeof material.attributes[t] === "string" ||
44
+ typeof material.attributes[t] === "number"
45
+ ) {
46
+ this._attributes[t] = { type: material.attributes[t] };
52
47
  } else {
53
48
  this._attributes[t] = material.attributes[t];
54
49
  }
@@ -61,9 +56,11 @@ class Program {
61
56
  */
62
57
  this._uniforms = {};
63
58
  for (let t in material.uniforms) {
64
- if (typeof (material.uniforms[t]) === "string" ||
65
- typeof (material.uniforms[t]) === "number") {
66
- this._uniforms[t] = { 'type': material.uniforms[t] };
59
+ if (
60
+ typeof material.uniforms[t] === "string" ||
61
+ typeof material.uniforms[t] === "number"
62
+ ) {
63
+ this._uniforms[t] = { type: material.uniforms[t] };
67
64
  } else {
68
65
  this._uniforms[t] = material.uniforms[t];
69
66
  }
@@ -117,18 +114,32 @@ class Program {
117
114
  * @type {Array.<Object>}
118
115
  */
119
116
  this._attribArrays = [];
117
+
118
+ /**
119
+ * Program attributes divisor.
120
+ * @private
121
+ * @type {Array.<Object>}
122
+ */
123
+ this._attribDivisor = [];
120
124
  }
121
125
 
122
126
  /**
123
127
  * Bind program buffer.
124
128
  * @function
125
- * @param {og.webgl.Program} program - Used program.
129
+ * @param {Program} program - Used program.
126
130
  * @param {Object} variable - Variable represents buffer data.
127
131
  */
128
132
  static bindBuffer(program, variable) {
129
133
  var gl = program.gl;
130
134
  gl.bindBuffer(gl.ARRAY_BUFFER, variable.value);
131
- gl.vertexAttribPointer(variable._pName, variable.value.itemSize, variable.itemType, variable.normalized, 0, 0);
135
+ gl.vertexAttribPointer(
136
+ variable._pName,
137
+ variable.value.itemSize,
138
+ variable.itemType,
139
+ variable.normalized,
140
+ 0,
141
+ 0
142
+ );
132
143
  }
133
144
 
134
145
  /**
@@ -196,7 +207,9 @@ class Program {
196
207
  this.gl.shaderSource(shader, src);
197
208
  this.gl.compileShader(shader);
198
209
  if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
199
- cons.logErr("og/Program/Program:" + this.name + " - " + this.gl.getShaderInfoLog(shader) + ".");
210
+ cons.logErr(
211
+ "og/Program/Program:" + this.name + " - " + this.gl.getShaderInfoLog(shader) + "."
212
+ );
200
213
  return false;
201
214
  }
202
215
  return true;
@@ -237,9 +250,9 @@ class Program {
237
250
  disableAttribArrays() {
238
251
  var gl = this.gl;
239
252
  var a = this._attribArrays;
240
- var i = a.length;
241
- while (i--) {
253
+ for (let i = 0, len = a.length; i < len; i++) {
242
254
  gl.disableVertexAttribArray(a[i]);
255
+ gl.vertexAttribDivisor(a[i], 0);
243
256
  }
244
257
  }
245
258
 
@@ -250,9 +263,10 @@ class Program {
250
263
  enableAttribArrays() {
251
264
  var gl = this.gl;
252
265
  var a = this._attribArrays;
253
- var i = a.length;
254
- while (i--) {
266
+ var d = this._attribDivisor;
267
+ for (let i = 0, len = a.length; i < len; i++) {
255
268
  gl.enableVertexAttribArray(a[i]);
269
+ gl.vertexAttribDivisor(a[i], d[i]);
256
270
  }
257
271
  }
258
272
 
@@ -280,7 +294,13 @@ class Program {
280
294
  gl.linkProgram(this._p);
281
295
 
282
296
  if (!gl.getProgramParameter(this._p, gl.LINK_STATUS)) {
283
- cons.logErr("og/Program/Program:" + this.name + " - couldn't initialise shaders. " + gl.getProgramInfoLog(this._p) + ".");
297
+ cons.logErr(
298
+ "og/Program/Program:" +
299
+ this.name +
300
+ " - couldn't initialise shaders. " +
301
+ gl.getProgramInfoLog(this._p) +
302
+ "."
303
+ );
284
304
  gl.deleteProgram(this._p);
285
305
  return;
286
306
  }
@@ -293,25 +313,47 @@ class Program {
293
313
 
294
314
  this._attributes[a]._callback = Program.bindBuffer;
295
315
 
296
- let itemTypeStr = this._attributes[a].itemType ? this._attributes[a].itemType.trim().toUpperCase() : "FLOAT";
316
+ let itemTypeStr = this._attributes[a].itemType
317
+ ? this._attributes[a].itemType.trim().toUpperCase()
318
+ : "FLOAT";
319
+
297
320
  if (itemTypes.indexOf(itemTypeStr) == -1) {
298
- cons.logErr(`og/Program/Program: ${this.name}- attribute '${a}', item type ${this._attributes[a].itemType} not exists.`);
321
+ cons.logErr(
322
+ `og/Program/Program: ${this.name}- attribute '${a}', item type ${this._attributes[a].itemType} not exists.`
323
+ );
299
324
  this._attributes[a].itemType = gl.FLOAT;
300
325
  } else {
301
326
  this._attributes[a].itemType = gl[itemTypeStr];
302
327
  }
303
328
 
304
329
  this._attributes[a].normalized = this._attributes[a].normalized || false;
330
+ this._attributes[a].divisor = this._attributes[a].divisor || 0;
305
331
 
306
332
  this._p[a] = gl.getAttribLocation(this._p, a);
307
333
 
308
334
  if (this._p[a] == undefined) {
309
- cons.logErr("og/Program/Program:" + this.name + " - attribute '" + a + "' is not exists.");
335
+ cons.logErr(
336
+ "og/Program/Program:" + this.name + " - attribute '" + a + "' is not exists."
337
+ );
310
338
  gl.deleteProgram(this._p);
311
339
  return;
312
340
  }
313
341
 
314
- this._attribArrays.push(this._p[a]);
342
+ let type = this._attributes[a].type;
343
+ if (typeof type === "string") {
344
+ type = typeStr[type.trim().toLowerCase()];
345
+ }
346
+
347
+ let d = this._attributes[a].divisor;
348
+ if (type === types.MAT4) {
349
+ let loc = this._p[a];
350
+ this._attribArrays.push(loc, loc + 1, loc + 2, loc + 3);
351
+ this._attribDivisor.push(d, d, d, d);
352
+ } else {
353
+ this._attribArrays.push(this._p[a]);
354
+ this._attribDivisor.push(d);
355
+ }
356
+
315
357
  gl.enableVertexAttribArray(this._p[a]);
316
358
 
317
359
  this._attributes[a]._pName = this._p[a];
@@ -321,8 +363,9 @@ class Program {
321
363
  for (var u in this._uniforms) {
322
364
  //this.uniforms[u]._name = u;
323
365
 
324
- if (typeof (this._uniforms[u].type) === "string") {
325
- this._uniforms[u]._callback = callbacks.u[typeStr[this._uniforms[u].type.trim().toLowerCase()]];
366
+ if (typeof this._uniforms[u].type === "string") {
367
+ this._uniforms[u]._callback =
368
+ callbacks.u[typeStr[this._uniforms[u].type.trim().toLowerCase()]];
326
369
  } else {
327
370
  this._uniforms[u]._callback = callbacks.u[this._uniforms[u].type];
328
371
  }
@@ -331,7 +374,9 @@ class Program {
331
374
  this._p[u] = gl.getUniformLocation(this._p, u);
332
375
 
333
376
  if (this._p[u] == undefined) {
334
- cons.logErr("og/Program/Program:" + this.name + " - uniform '" + u + "' is not exists.");
377
+ cons.logErr(
378
+ "og/Program/Program:" + this.name + " - uniform '" + u + "' is not exists."
379
+ );
335
380
  gl.deleteProgram(this._p);
336
381
  return;
337
382
  }
@@ -346,6 +391,6 @@ class Program {
346
391
  gl.deleteShader(fs);
347
392
  gl.deleteShader(vs);
348
393
  }
349
- };
394
+ }
350
395
 
351
- export { Program };
396
+ export { Program };
@@ -1,28 +1,32 @@
1
- 'use strict';
1
+ import { Handler } from "./Handler.js";
2
+ import { Program } from "./Program.js";
3
+
4
+ ("use strict");
2
5
 
3
6
  /**
4
- * This is shader program controller that used by hadler object to access the shader
7
+ * This is shader program controller that used by hadler object to access the shader
5
8
  * program capabilities, like switching program during the rendering.
6
9
  * Get access to the program from ...handler.programs.<program name> etc.
7
10
  * @class
8
- * @param {og.webgl.Handler} handler - Handler.
9
- * @param {og.webgl.Program} program - Shader program.
10
11
  */
11
12
  export class ProgramController {
12
-
13
+ /**
14
+ *
15
+ * @param {Handler} handler - Handler.
16
+ * @param {Program} program - Shader program.
17
+ */
13
18
  constructor(handler, program) {
14
-
15
19
  /**
16
20
  * Shader program.
17
21
  * @private
18
- * @type {og.webgl.Program}
22
+ * @type {Program}
19
23
  */
20
24
  this._program = program;
21
25
 
22
26
  /**
23
27
  * Handler.
24
28
  * @private
25
- * @type {og.webgl.Handler}
29
+ * @type {Handler}
26
30
  */
27
31
  this._handler = handler;
28
32
 
@@ -32,7 +36,7 @@ export class ProgramController {
32
36
  * @type {boolean}
33
37
  */
34
38
  this._activated = false;
35
- };
39
+ }
36
40
 
37
41
  /**
38
42
  * Lazy create program call.
@@ -40,16 +44,16 @@ export class ProgramController {
40
44
  */
41
45
  initialize() {
42
46
  this._program.createProgram(this._handler.gl);
43
- };
47
+ }
44
48
 
45
49
  /**
46
50
  * Returns controller's shader program.
47
51
  * @public
48
- * @return {og.webgl.Program} -
52
+ * @return {Program} -
49
53
  */
50
54
  getProgram() {
51
55
  return this._program;
52
- };
56
+ }
53
57
 
54
58
  /**
55
59
  * Activates current shader program.
@@ -66,7 +70,7 @@ export class ProgramController {
66
70
  p.use();
67
71
  }
68
72
  return this;
69
- };
73
+ }
70
74
 
71
75
  /**
72
76
  * Remove program from handler
@@ -82,7 +86,7 @@ export class ProgramController {
82
86
  p[this._program.name] = null;
83
87
  delete p[this._program.name];
84
88
  }
85
- };
89
+ }
86
90
 
87
91
  /**
88
92
  * Deactivate shader program. This is not necessary while activae function used.
@@ -91,7 +95,7 @@ export class ProgramController {
91
95
  deactivate() {
92
96
  this._program.disableAttribArrays();
93
97
  this._activated = false;
94
- };
98
+ }
95
99
 
96
100
  /**
97
101
  * Returns program activity.
@@ -100,40 +104,40 @@ export class ProgramController {
100
104
  */
101
105
  isActive() {
102
106
  return this._activated;
103
- };
107
+ }
104
108
 
105
109
  /**
106
110
  * Sets program uniforms and attributes values and return controller instance.
107
111
  * @public
108
112
  * @param {Object} params - Object with variable name and value like { value: 12, someArray:[1,2,3], uSampler: texture,... }
109
- * @return {og.webgl.ProgramController} -
113
+ * @return {ProgramController} -
110
114
  */
111
115
  set(params) {
112
116
  this.activate();
113
117
  this._program.set(params);
114
118
  return this;
115
- };
119
+ }
116
120
 
117
121
  /**
118
122
  * Draw index buffer with this program.
119
123
  * @public
120
124
  * @param {number} mode - Gl draw mode
121
125
  * @param {WEBGLBuffer} buffer - Buffer to draw.
122
- * @return {og.webgl.ProgramController} Returns current shader controller instance.
126
+ * @return {ProgramController} Returns current shader controller instance.
123
127
  */
124
128
  drawIndexBuffer(mode, buffer) {
125
129
  this._program.drawIndexBuffer(mode, buffer);
126
130
  return this;
127
- };
131
+ }
128
132
 
129
133
  /**
130
134
  * Calls Gl drawArray function.
131
135
  * @param {number} mode - Gl draw mode.
132
136
  * @param {number} numItems - draw items count.
133
- * @return {og.webgl.ProgramController} Returns current shader controller instance.
137
+ * @return {ProgramController} Returns current shader controller instance.
134
138
  */
135
139
  drawArrays(mode, numItems) {
136
140
  this._program.drawArrays(mode, numItems);
137
141
  return this;
138
- };
139
- }
142
+ }
143
+ }
@@ -2,16 +2,16 @@
2
2
  * @module og/webgl/callbacks
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { types } from './types.js';
7
+ import { types } from "./types.js";
8
8
 
9
9
  /*=========================
10
10
  Uniforms callbacks
11
11
  =========================*/
12
12
  export const callbacks = {
13
- 'u': [],
14
- 'a': []
13
+ u: [],
14
+ a: []
15
15
  };
16
16
 
17
17
  callbacks.u[types.MAT4] = function (program, variable) {
@@ -71,7 +71,7 @@ callbacks.u[types.SAMPLER2DARRAY] = function (program, variable) {
71
71
  };
72
72
 
73
73
  callbacks.u[types.INTXX] = function (program, variable) {
74
- pgl.uniform1iv(variable._pName, variable.value);
74
+ program.gl.uniform1iv(variable._pName, variable.value);
75
75
  };
76
76
 
77
77
  callbacks.u[types.FLOATXX] = function (program, variable) {
@@ -93,6 +93,6 @@ callbacks.a[types.VEC3] = function (program, variable) {
93
93
  program.gl.vertexAttrib3fv(variable._pName, variable.value);
94
94
  };
95
95
 
96
- callbacks.a[types.VEC4] = function (program, variable) {
97
- program.gl.vertexAttrib4fv(variable._pName, variable.value);
98
- };
96
+ //callbacks.a[types.VEC4] = function (program, variable) {
97
+ // program.gl.vertexAttrib4fv(variable._pName, variable.value);
98
+ //};
package/types/Clock.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Class represents application timer that stores custom current julian datetime, and time speed multiplier.
3
3
  * @class
4
- * @param {Object} [params]: - Clock parameters:
4
+ * @param {Object} [params] - Clock parameters:
5
5
  * @param {number} [params.startDate=0.0] - Julian start date.
6
6
  * @param {number} [params.endDate=0.0] - Julian end date.
7
7
  * @param {number} [params.currentDate] - Julian current date. Default: current date.
@@ -10,7 +10,11 @@
10
10
  export class Clock {
11
11
  static set _staticCounter(arg: any);
12
12
  static get _staticCounter(): any;
13
- constructor(params: any);
13
+ /**
14
+ *
15
+ * @param {Object} [params] - Clock parameters:
16
+ */
17
+ constructor(params?: any);
14
18
  _id: number;
15
19
  /**
16
20
  * Clock name.
@@ -2,5 +2,5 @@ export function Deferred(): void;
2
2
  export class Deferred {
3
3
  resolve: any;
4
4
  reject: any;
5
- promise: Promise<any>;
5
+ promise: any;
6
6
  }
package/types/Events.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  /**
2
2
  * Base events class to handle custom events.
3
3
  * @class
4
- * @param {Array.<string>} [eventNames] - Event names that could be dispatched.
5
4
  */
6
5
  export class Events {
7
6
  static set _staticCounter(arg: any);
8
7
  static get _staticCounter(): any;
9
- constructor(eventNames: any, sender: any);
8
+ /**
9
+ *
10
+ * @param {Array.<string>} [eventNames] - Event names that could be dispatched.
11
+ * @param {*} [sender]
12
+ */
13
+ constructor(eventNames?: Array<string>, sender?: any);
10
14
  /**
11
15
  * Registered event names.
12
16
  * @protected
@@ -45,14 +49,14 @@ export class Events {
45
49
  * @param {eventCallback} callback - Event callback function.
46
50
  * @param {Object} sender - Event callback function owner.
47
51
  */
48
- public on(name: string, callback: any, sender: any, priority?: number): void;
52
+ public on(name: string, callback: eventCallback, sender: any, priority?: number): void;
49
53
  /**
50
54
  * Stop listening event name with specified callback function.
51
55
  * @public
52
56
  * @param {string} name - Event name.
53
57
  * @param {eventCallback} callback - Attached event callback.
54
58
  */
55
- public off(name: string, callback: any): void;
59
+ public off(name: string, callback: eventCallback): void;
56
60
  /**
57
61
  * Dispatch event.
58
62
  * @public