@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
@@ -1,5 +1,26 @@
1
1
  import { BaseFramebuffer } from "./BaseFramebuffer";
2
2
  import { ImageCanvas } from "../ImageCanvas";
3
+ const TypeArrayConstructor = {
4
+ "UNSIGNED_BYTE": Uint8Array,
5
+ "FLOAT": Float32Array
6
+ };
7
+ export function clientWaitAsync(gl, sync, flags) {
8
+ return new Promise((resolve, reject) => {
9
+ function check() {
10
+ const res = gl.clientWaitSync(sync, flags, 0);
11
+ if (res == gl.WAIT_FAILED) {
12
+ reject();
13
+ }
14
+ else if (res == gl.TIMEOUT_EXPIRED) {
15
+ requestAnimationFrame(check);
16
+ }
17
+ else {
18
+ resolve();
19
+ }
20
+ }
21
+ check();
22
+ });
23
+ }
3
24
  /**
4
25
  * Class represents framebuffer.
5
26
  * @class
@@ -9,24 +30,75 @@ import { ImageCanvas } from "../ImageCanvas";
9
30
  export class Framebuffer extends BaseFramebuffer {
10
31
  constructor(handler, options = {}) {
11
32
  super(handler, options);
12
- this._isBare = options.isBare || false;
13
- this._internalFormatArr = options.internalFormat instanceof Array ? options.internalFormat : [options.internalFormat || "RGBA"];
14
- this._formatArr = options.format instanceof Array ? options.format : [options.format || "RGBA"];
15
- this._typeArr = options.type instanceof Array ? options.type : [options.type || "UNSIGNED_BYTE"];
16
- if (options.attachment instanceof Array) {
17
- this._attachmentArr = options.attachment.map((a, i) => {
18
- let res = a.toUpperCase();
19
- if (res === "COLOR_ATTACHMENT") {
20
- return `${res}${i.toString()}`;
33
+ this.readPixelBuffersAsync = () => {
34
+ const gl = this.handler.gl;
35
+ if (this._skipFrame)
36
+ return;
37
+ this._skipFrame = true;
38
+ let w = this.width, h = this.height;
39
+ let pb = this.pixelBuffers;
40
+ this.activate();
41
+ for (let i = 0; i < pb.length; i++) {
42
+ let pbi = pb[i];
43
+ gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pbi.buffer);
44
+ gl.bufferData(gl.PIXEL_PACK_BUFFER, pbi.data.byteLength, gl.STREAM_READ);
45
+ gl.readBuffer(pbi.glAttachment);
46
+ gl.readPixels(0, 0, w, h, gl.RGBA, pbi.glType, 0);
47
+ gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
48
+ }
49
+ this.deactivate();
50
+ const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
51
+ gl.flush();
52
+ clientWaitAsync(gl, sync, 0).then(() => {
53
+ this._skipFrame = false;
54
+ gl.deleteSync(sync);
55
+ for (let i = 0; i < pb.length; i++) {
56
+ let pbi = pb[i];
57
+ if (pbi.data) {
58
+ gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pbi.buffer);
59
+ gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, pbi.data);
60
+ }
21
61
  }
22
- return res;
62
+ gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
23
63
  });
24
- }
25
- else {
26
- this._attachmentArr = [options.attachment || "COLOR_ATTACHMENT0"];
27
- }
64
+ };
65
+ this._targets = Framebuffer.createTargets(options.targets);
66
+ this._size = this._targets.length;
28
67
  this._renderbufferTarget = options.renderbufferTarget != undefined ? options.renderbufferTarget : "DEPTH_ATTACHMENT";
29
68
  this.textures = options.textures || new Array(this._size);
69
+ this.pixelBuffers = [];
70
+ this._skipFrame = false;
71
+ }
72
+ static createTargets(targets) {
73
+ let attInd = 0;
74
+ let pbInd = 0;
75
+ if (targets) {
76
+ return targets.map((ti) => {
77
+ let attachment = ti.attachment || "COLOR_ATTACHMENT";
78
+ if (attachment === "COLOR_ATTACHMENT") {
79
+ attachment = `COLOR_ATTACHMENT${attInd++}`;
80
+ }
81
+ let type = ti.type || "UNSIGNED_BYTE";
82
+ return {
83
+ internalFormat: ti.internalFormat || "RGBA",
84
+ format: ti.format || "RGBA",
85
+ type,
86
+ attachment,
87
+ filter: ti.filter || "NEAREST",
88
+ pixelBufferIndex: ti.readAsync ? pbInd++ : -1,
89
+ TypeArrayConstructor: TypeArrayConstructor[type]
90
+ };
91
+ });
92
+ }
93
+ return [{
94
+ internalFormat: "RGBA",
95
+ format: "RGBA",
96
+ type: "UNSIGNED_BYTE",
97
+ attachment: "COLOR_ATTACHMENT0",
98
+ filter: "NEAREST",
99
+ pixelBufferIndex: -1,
100
+ TypeArrayConstructor: TypeArrayConstructor.UNSIGNED_BYTE
101
+ }];
30
102
  }
31
103
  // static blit(sourceFramebuffer: Framebuffer, destFramebuffer: Framebuffer, glAttachment: number, glMask: number, glFilter: number) {
32
104
  // let gl = sourceFramebuffer.handler.gl!;
@@ -51,6 +123,11 @@ export class Framebuffer extends BaseFramebuffer {
51
123
  gl.deleteTexture(this.textures[i]);
52
124
  }
53
125
  this.textures = new Array(this._size);
126
+ for (let i = 0; i < this.pixelBuffers.length; i++) {
127
+ this.pixelBuffers[i].data = null;
128
+ gl.deleteBuffer(this.pixelBuffers[i].buffer);
129
+ }
130
+ this.pixelBuffers = [];
54
131
  gl.deleteFramebuffer(this._fbo);
55
132
  gl.deleteRenderbuffer(this._depthRenderbuffer);
56
133
  this._depthRenderbuffer = null;
@@ -68,21 +145,23 @@ export class Framebuffer extends BaseFramebuffer {
68
145
  return;
69
146
  this._fbo = gl.createFramebuffer();
70
147
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
71
- if (!this._isBare) {
72
- let attachmentArr = [];
73
- for (let i = 0; i < this.textures.length; i++) {
74
- let ti = this.textures[i] || this.handler.createEmptyTexture2DExt(this._width, this._height, this._filter, this._internalFormatArr[i], this._formatArr[i], this._typeArr[i]);
75
- let att_i = gl[this._attachmentArr[i]];
76
- if (ti) {
77
- this.bindOutputTexture(ti, att_i);
78
- this.textures[i] = ti;
79
- }
80
- if (this._attachmentArr[i] != "DEPTH_ATTACHMENT") {
81
- attachmentArr.push(att_i);
82
- }
148
+ let attachmentArr = [];
149
+ for (let i = 0; i < this._targets.length; i++) {
150
+ let tr = this._targets[i];
151
+ let ti = this.textures[i] || this.handler.createEmptyTexture2DExt(this._width, this._height, tr.filter, tr.internalFormat, tr.format, tr.type);
152
+ let att_i = gl[tr.attachment];
153
+ if (ti) {
154
+ this.bindOutputTexture(ti, att_i);
155
+ this.textures[i] = ti;
156
+ }
157
+ if (tr.attachment !== "DEPTH_ATTACHMENT") {
158
+ attachmentArr.push(att_i);
159
+ }
160
+ if (tr.pixelBufferIndex !== -1) {
161
+ this._createPixelBuffer(tr);
83
162
  }
84
- gl.drawBuffers && gl.drawBuffers(attachmentArr);
85
163
  }
164
+ gl.drawBuffers && gl.drawBuffers(attachmentArr);
86
165
  if (this._useDepth) {
87
166
  this._depthRenderbuffer = gl.createRenderbuffer();
88
167
  gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderbuffer);
@@ -92,6 +171,34 @@ export class Framebuffer extends BaseFramebuffer {
92
171
  }
93
172
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
94
173
  }
174
+ getPixelBufferData(targetIndex) {
175
+ let pbInd = this._targets[targetIndex].pixelBufferIndex;
176
+ return pbInd !== -1 ? this.pixelBuffers[pbInd].data : null;
177
+ }
178
+ _createPixelBuffer(target) {
179
+ let gl = this.handler.gl;
180
+ let pbInd = target.pixelBufferIndex;
181
+ let pb = this.pixelBuffers[pbInd];
182
+ if (!pb) {
183
+ pb = this.pixelBuffers[pbInd] = {
184
+ buffer: null,
185
+ data: null,
186
+ glType: -1,
187
+ glAttachment: -1
188
+ };
189
+ }
190
+ let size = this.width * this.height * 4;
191
+ // clear current pixel buffer
192
+ pb.data = null;
193
+ pb.data = new target.TypeArrayConstructor(size);
194
+ //gl.deleteBuffer(pb.buffer);
195
+ pb.buffer = gl.createBuffer();
196
+ gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pb.buffer);
197
+ gl.bufferData(gl.PIXEL_PACK_BUFFER, size, gl.STREAM_READ);
198
+ gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
199
+ pb.glType = gl[target.type];
200
+ pb.glAttachment = gl[target.attachment];
201
+ }
95
202
  /**
96
203
  * Bind buffer texture.
97
204
  * @public
@@ -118,7 +225,7 @@ export class Framebuffer extends BaseFramebuffer {
118
225
  let gl = this.handler.gl;
119
226
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
120
227
  gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + index || 0);
121
- gl.readPixels(nx * this._width, ny * this._height, w, h, gl.RGBA, gl[this._typeArr[index]], res);
228
+ gl.readPixels(nx * this._width, ny * this._height, w, h, gl.RGBA, gl[this._targets[index].type], res);
122
229
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
123
230
  }
124
231
  /**
@@ -131,7 +238,7 @@ export class Framebuffer extends BaseFramebuffer {
131
238
  let gl = this.handler.gl;
132
239
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
133
240
  gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + attachmentIndex);
134
- gl.readPixels(0, 0, this._width, this._height, gl.RGBA, gl[this._typeArr[attachmentIndex]], res);
241
+ gl.readPixels(0, 0, this._width, this._height, gl.RGBA, gl[this._targets[attachmentIndex].type], res);
135
242
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
136
243
  }
137
244
  /**
@@ -17,7 +17,7 @@ export type WebGLTextureExt = {
17
17
  default?: boolean;
18
18
  } & WebGLTexture;
19
19
  export type ImageSource = HTMLCanvasElement | ImageBitmap | ImageData | HTMLImageElement | HTMLVideoElement;
20
- type CreateTextureFunc = (image: ImageSource, internalFormat?: number, texture?: WebGLTextureExt) => WebGLTextureExt | null;
20
+ type CreateTextureFunc = (image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTextureExt) => WebGLTextureExt | null;
21
21
  export interface IHandlerParameters {
22
22
  anisotropy?: number;
23
23
  width?: number;
@@ -82,6 +82,7 @@ declare class Handler {
82
82
  * @type {number}
83
83
  */
84
84
  deltaTime: number;
85
+ prevDeltaTime: number;
85
86
  /**
86
87
  * WebGL rendering canvas element.
87
88
  * @public
@@ -196,7 +197,7 @@ declare class Handler {
196
197
  * @param {number} [level=0] - Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
197
198
  * @returns {WebGLTexture | null} - WebGL texture object.
198
199
  */
199
- createEmptyTexture2DExt(width?: number, height?: number, filter?: string, internalFormat?: string, format?: string, type?: string, level?: number): WebGLTexture | null;
200
+ createEmptyTexture2DExt(width?: number, height?: number, filter?: string, internalFormat?: string, format?: string, type?: string, param?: string, level?: number): WebGLTexture | null;
200
201
  /**
201
202
  * Creates Empty NEAREST filtered texture.
202
203
  * @public
@@ -205,88 +206,97 @@ declare class Handler {
205
206
  * @param {number} [internalFormat]
206
207
  * @returns {WebGLTexture | null} - WebGL texture object.
207
208
  */
208
- createEmptyTexture_n(width: number, height: number, internalFormat?: number): WebGLTexture | null;
209
+ createEmptyTexture_n(width: number, height: number, internalFormat?: number | null, texParami?: number | null): WebGLTexture | null;
209
210
  /**
210
211
  * Creates empty LINEAR filtered texture.
211
212
  * @public
212
213
  * @param {number} width - Empty texture width.
213
214
  * @param {number} height - Empty texture height.
214
215
  * @param {number} [internalFormat]
216
+ * @param {number} [texParami]
215
217
  * @returns {WebGLTexture | null} - WebGL texture object.
216
218
  */
217
- createEmptyTexture_l(width: number, height: number, internalFormat?: number): WebGLTexture | null;
219
+ createEmptyTexture_l(width: number, height: number, internalFormat?: number | null, texParami?: number | null): WebGLTexture | null;
218
220
  /**
219
221
  * Creates NEAREST filter texture.
220
222
  * @public
221
223
  * @param {HTMLCanvasElement | Image} image - Image or Canvas object.
222
224
  * @param {number} [internalFormat]
225
+ * @param {number} [texParami]
223
226
  * @param {WebGLTexture | null} [texture=null]
224
227
  * @returns {WebGLTexture | null} - WebGL texture object.
225
228
  */
226
- createTexture_n_webgl1(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
229
+ createTexture_n_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
227
230
  /**
228
231
  * Creates LINEAR filter texture.
229
232
  * @public
230
233
  * @param {ImageSource} image - Image or Canvas object.
231
234
  * @param {number} [internalFormat]
235
+ * @param {number} [texParami]
232
236
  * @param {WebGLTexture | null} [texture]
233
237
  * @returns {WebGLTexture | null} - WebGL texture object.
234
238
  */
235
- createTexture_l_webgl1(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
239
+ createTexture_l_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
236
240
  /**
237
241
  * Creates MIPMAP filter texture.
238
242
  * @public
239
243
  * @param {ImageSource} image - Image or Canvas object.
240
244
  * @param {number} [internalFormat]
245
+ * @param {number} [texParami]
241
246
  * @param {WebGLTexture | null} [texture]
242
247
  * @returns {WebGLTexture | null} - WebGL texture object.
243
248
  */
244
- createTexture_mm_webgl1(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
249
+ createTexture_mm_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
245
250
  /**
246
251
  * Creates ANISOTROPY filter texture.
247
252
  * @public
248
253
  * @param {ImageSource} image - Image or Canvas object.
249
254
  * @param {number} [internalFormat]
255
+ * @param {number} [texParami]
250
256
  * @param {WebGLTexture | null} [texture]
251
257
  * @returns {WebGLTexture | null} - WebGL texture object.
252
258
  */
253
- createTexture_a_webgl1(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
259
+ createTexture_a_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
254
260
  /**
255
261
  * Creates NEAREST filter texture.
256
262
  * @public
257
263
  * @param {ImageSource} image - Image or Canvas object.
258
264
  * @param {number} [internalFormat]
265
+ * @param {number} [texParami]
259
266
  * @param {WebGLTexture | null} [texture]
260
267
  * @returns {WebGLTexture | null} - WebGL texture object.
261
268
  */
262
- createTexture_n_webgl2(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
269
+ createTexture_n_webgl2(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
263
270
  /**
264
271
  * Creates LINEAR filter texture.
265
272
  * @public
266
273
  * @param {ImageSource} image - Image or Canvas object.
267
274
  * @param {number} [internalFormat]
275
+ * @param {number} [texParami]
268
276
  * @param {WebGLTexture | null} [texture]
269
277
  * @returns {WebGLTexture | null} - WebGL texture object.
270
278
  */
271
- createTexture_l_webgl2(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
279
+ createTexture_l_webgl2(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
272
280
  /**
273
281
  * Creates MIPMAP filter texture.
274
282
  * @public
275
283
  * @param {ImageSource} image - Image or Canvas object.
276
284
  * @param {number} [internalFormat]
285
+ * @param {number} [texParami]
277
286
  * @param {WebGLTexture | null} [texture]
278
287
  * @returns {WebGLTexture | null} - WebGL texture object.
279
288
  */
280
- createTexture_mm_webgl2(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
289
+ createTexture_mm_webgl2(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
281
290
  /**
282
291
  * Creates ANISOTROPY filter texture.
283
292
  * @public
284
293
  * @param {ImageSource} image - Image or Canvas object.
285
294
  * @param {number} [internalFormat]
295
+ * @param {number} [texParami]
286
296
  * @param {WebGLTexture | null} [texture]
287
297
  * @returns {WebGLTexture | null} - WebGL texture object.
288
298
  */
289
- createTexture_a_webgl2(image: ImageSource, internalFormat?: number, texture?: WebGLTexture | null): WebGLTexture | null;
299
+ createTexture_a_webgl2(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
290
300
  /**
291
301
  * Creates cube texture.
292
302
  * @public
@@ -33,7 +33,16 @@ class Handler {
33
33
  this.drawFrame = () => {
34
34
  /** Calculating frame time */
35
35
  let now = window.performance.now();
36
- this.deltaTime = now - this._lastAnimationFrameTime;
36
+ let prevDeltaTime = this.deltaTime;
37
+ //Make some filter:)
38
+ this.deltaTime = (now - this._lastAnimationFrameTime + this.prevDeltaTime) * 0.5;
39
+ if (this.deltaTime > 3) {
40
+ this.deltaTime = 3;
41
+ }
42
+ else if (this.deltaTime < 1) {
43
+ this.deltaTime = 1;
44
+ }
45
+ this.prevDeltaTime = prevDeltaTime;
37
46
  this._lastAnimationFrameTime = now;
38
47
  this.defaultClock.tick(this.deltaTime);
39
48
  for (let i = 0; i < this._clocks.length; i++) {
@@ -57,6 +66,7 @@ class Handler {
57
66
  this._throttledDrawFrame = this.drawFrame;
58
67
  this.defaultClock = new Clock();
59
68
  this._clocks = [];
69
+ this.prevDeltaTime = 0;
60
70
  this.deltaTime = 0;
61
71
  this.canvas = null;
62
72
  this.gl = null;
@@ -196,7 +206,7 @@ class Handler {
196
206
  * @param {number} [level=0] - Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
197
207
  * @returns {WebGLTexture | null} - WebGL texture object.
198
208
  */
199
- createEmptyTexture2DExt(width = 1, height = 1, filter = "NEAREST", internalFormat = "RGBA", format = "RGBA", type = "UNSIGNED_BYTE", level = 0) {
209
+ createEmptyTexture2DExt(width = 1, height = 1, filter = "NEAREST", internalFormat = "RGBA", format = "RGBA", type = "UNSIGNED_BYTE", param = "CLAMP_TO_EDGE", level = 0) {
200
210
  let gl = this.gl;
201
211
  let texture = gl.createTexture();
202
212
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -204,8 +214,8 @@ class Handler {
204
214
  gl.texImage2D(gl.TEXTURE_2D, level, gl[internalFormat.toUpperCase()], width, height, 0, gl[format.toUpperCase()], gl[type.toUpperCase()], null);
205
215
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl[filter.toUpperCase()]);
206
216
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl[filter.toUpperCase()]);
207
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
208
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
217
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl[param.toUpperCase()]);
218
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl[param.toUpperCase()]);
209
219
  gl.bindTexture(gl.TEXTURE_2D, null);
210
220
  return texture;
211
221
  }
@@ -217,7 +227,7 @@ class Handler {
217
227
  * @param {number} [internalFormat]
218
228
  * @returns {WebGLTexture | null} - WebGL texture object.
219
229
  */
220
- createEmptyTexture_n(width, height, internalFormat) {
230
+ createEmptyTexture_n(width, height, internalFormat, texParami) {
221
231
  let gl = this.gl;
222
232
  let texture = gl.createTexture();
223
233
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -225,8 +235,8 @@ class Handler {
225
235
  gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
226
236
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
227
237
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
228
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
229
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
238
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
239
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
230
240
  gl.bindTexture(gl.TEXTURE_2D, null);
231
241
  return texture;
232
242
  }
@@ -236,9 +246,10 @@ class Handler {
236
246
  * @param {number} width - Empty texture width.
237
247
  * @param {number} height - Empty texture height.
238
248
  * @param {number} [internalFormat]
249
+ * @param {number} [texParami]
239
250
  * @returns {WebGLTexture | null} - WebGL texture object.
240
251
  */
241
- createEmptyTexture_l(width, height, internalFormat) {
252
+ createEmptyTexture_l(width, height, internalFormat, texParami) {
242
253
  let gl = this.gl;
243
254
  let texture = gl.createTexture();
244
255
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -246,8 +257,8 @@ class Handler {
246
257
  gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
247
258
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
248
259
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
249
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
250
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
260
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
261
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
251
262
  gl.bindTexture(gl.TEXTURE_2D, null);
252
263
  return texture;
253
264
  }
@@ -256,10 +267,11 @@ class Handler {
256
267
  * @public
257
268
  * @param {HTMLCanvasElement | Image} image - Image or Canvas object.
258
269
  * @param {number} [internalFormat]
270
+ * @param {number} [texParami]
259
271
  * @param {WebGLTexture | null} [texture=null]
260
272
  * @returns {WebGLTexture | null} - WebGL texture object.
261
273
  */
262
- createTexture_n_webgl1(image, internalFormat, texture = null) {
274
+ createTexture_n_webgl1(image, internalFormat, texParami, texture = null) {
263
275
  let gl = this.gl;
264
276
  texture = texture || gl.createTexture();
265
277
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -267,8 +279,8 @@ class Handler {
267
279
  gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
268
280
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
269
281
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
270
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
271
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
282
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
283
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
272
284
  gl.bindTexture(gl.TEXTURE_2D, null);
273
285
  return texture;
274
286
  }
@@ -277,18 +289,19 @@ class Handler {
277
289
  * @public
278
290
  * @param {ImageSource} image - Image or Canvas object.
279
291
  * @param {number} [internalFormat]
292
+ * @param {number} [texParami]
280
293
  * @param {WebGLTexture | null} [texture]
281
294
  * @returns {WebGLTexture | null} - WebGL texture object.
282
295
  */
283
- createTexture_l_webgl1(image, internalFormat, texture = null) {
296
+ createTexture_l_webgl1(image, internalFormat, texParami, texture = null) {
284
297
  let gl = this.gl;
285
298
  texture = texture || gl.createTexture();
286
299
  gl.bindTexture(gl.TEXTURE_2D, texture);
287
300
  gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
288
301
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
289
302
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
290
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
291
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
303
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
304
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
292
305
  gl.bindTexture(gl.TEXTURE_2D, null);
293
306
  return texture;
294
307
  }
@@ -297,10 +310,11 @@ class Handler {
297
310
  * @public
298
311
  * @param {ImageSource} image - Image or Canvas object.
299
312
  * @param {number} [internalFormat]
313
+ * @param {number} [texParami]
300
314
  * @param {WebGLTexture | null} [texture]
301
315
  * @returns {WebGLTexture | null} - WebGL texture object.
302
316
  */
303
- createTexture_mm_webgl1(image, internalFormat, texture = null) {
317
+ createTexture_mm_webgl1(image, internalFormat, texParami, texture = null) {
304
318
  let gl = this.gl;
305
319
  texture = texture || gl.createTexture();
306
320
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -308,8 +322,8 @@ class Handler {
308
322
  gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
309
323
  gl.generateMipmap(gl.TEXTURE_2D);
310
324
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
311
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
312
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
325
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
326
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
313
327
  gl.bindTexture(gl.TEXTURE_2D, null);
314
328
  return texture;
315
329
  }
@@ -318,10 +332,11 @@ class Handler {
318
332
  * @public
319
333
  * @param {ImageSource} image - Image or Canvas object.
320
334
  * @param {number} [internalFormat]
335
+ * @param {number} [texParami]
321
336
  * @param {WebGLTexture | null} [texture]
322
337
  * @returns {WebGLTexture | null} - WebGL texture object.
323
338
  */
324
- createTexture_a_webgl1(image, internalFormat, texture = null) {
339
+ createTexture_a_webgl1(image, internalFormat, texParami, texture = null) {
325
340
  let gl = this.gl;
326
341
  texture = texture || gl.createTexture();
327
342
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -330,8 +345,8 @@ class Handler {
330
345
  gl.generateMipmap(gl.TEXTURE_2D);
331
346
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
332
347
  gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
333
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
334
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
348
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
349
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
335
350
  gl.bindTexture(gl.TEXTURE_2D, null);
336
351
  return texture;
337
352
  }
@@ -340,10 +355,11 @@ class Handler {
340
355
  * @public
341
356
  * @param {ImageSource} image - Image or Canvas object.
342
357
  * @param {number} [internalFormat]
358
+ * @param {number} [texParami]
343
359
  * @param {WebGLTexture | null} [texture]
344
360
  * @returns {WebGLTexture | null} - WebGL texture object.
345
361
  */
346
- createTexture_n_webgl2(image, internalFormat, texture = null) {
362
+ createTexture_n_webgl2(image, internalFormat, texParami, texture = null) {
347
363
  let gl = this.gl;
348
364
  texture = texture || gl.createTexture();
349
365
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -353,8 +369,8 @@ class Handler {
353
369
  gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
354
370
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
355
371
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
356
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
357
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
372
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
373
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
358
374
  gl.bindTexture(gl.TEXTURE_2D, null);
359
375
  return texture;
360
376
  }
@@ -363,10 +379,11 @@ class Handler {
363
379
  * @public
364
380
  * @param {ImageSource} image - Image or Canvas object.
365
381
  * @param {number} [internalFormat]
382
+ * @param {number} [texParami]
366
383
  * @param {WebGLTexture | null} [texture]
367
384
  * @returns {WebGLTexture | null} - WebGL texture object.
368
385
  */
369
- createTexture_l_webgl2(image, internalFormat, texture = null) {
386
+ createTexture_l_webgl2(image, internalFormat, texParami, texture = null) {
370
387
  let gl = this.gl;
371
388
  texture = texture || gl.createTexture();
372
389
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -376,8 +393,8 @@ class Handler {
376
393
  gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
377
394
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
378
395
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
379
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
380
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
396
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
397
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
381
398
  gl.bindTexture(gl.TEXTURE_2D, null);
382
399
  return texture;
383
400
  }
@@ -386,10 +403,11 @@ class Handler {
386
403
  * @public
387
404
  * @param {ImageSource} image - Image or Canvas object.
388
405
  * @param {number} [internalFormat]
406
+ * @param {number} [texParami]
389
407
  * @param {WebGLTexture | null} [texture]
390
408
  * @returns {WebGLTexture | null} - WebGL texture object.
391
409
  */
392
- createTexture_mm_webgl2(image, internalFormat, texture = null) {
410
+ createTexture_mm_webgl2(image, internalFormat, texParami, texture = null) {
393
411
  let gl = this.gl;
394
412
  texture = texture || gl.createTexture();
395
413
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -398,8 +416,8 @@ class Handler {
398
416
  gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
399
417
  gl.generateMipmap(gl.TEXTURE_2D);
400
418
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
401
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
402
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
419
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
420
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
403
421
  gl.bindTexture(gl.TEXTURE_2D, null);
404
422
  return texture;
405
423
  }
@@ -408,10 +426,11 @@ class Handler {
408
426
  * @public
409
427
  * @param {ImageSource} image - Image or Canvas object.
410
428
  * @param {number} [internalFormat]
429
+ * @param {number} [texParami]
411
430
  * @param {WebGLTexture | null} [texture]
412
431
  * @returns {WebGLTexture | null} - WebGL texture object.
413
432
  */
414
- createTexture_a_webgl2(image, internalFormat, texture = null) {
433
+ createTexture_a_webgl2(image, internalFormat, texParami, texture = null) {
415
434
  let gl = this.gl;
416
435
  texture = texture || gl.createTexture();
417
436
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -422,8 +441,8 @@ class Handler {
422
441
  gl.generateMipmap(gl.TEXTURE_2D);
423
442
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
424
443
  gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
425
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
426
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
444
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParami || gl.CLAMP_TO_EDGE);
445
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParami || gl.CLAMP_TO_EDGE);
427
446
  gl.bindTexture(gl.TEXTURE_2D, null);
428
447
  return texture;
429
448
  }
@@ -222,10 +222,6 @@ class Program {
222
222
  this.drawElementsInstanced = ext.drawElementsInstancedANGLE.bind(ext);
223
223
  }
224
224
  }
225
- // this.drawElementsInstanced =
226
- // gl.drawElementsInstanced ?
227
- // gl.drawElementsInstanced.bind(gl) :
228
- // gl.getExtension('ANGLE_instanced_arrays').drawElementsInstancedANGLE.bind(gl.getExtension('ANGLE_instanced_arrays'));
229
225
  }
230
226
  if (!this.vertexAttribDivisor) {
231
227
  if (gl.vertexAttribDivisor) {
@@ -237,10 +233,6 @@ class Program {
237
233
  this.vertexAttribDivisor = ext.vertexAttribDivisorANGLE.bind(ext);
238
234
  }
239
235
  }
240
- // this.vertexAttribDivisor =
241
- // gl.vertexAttribDivisor ?
242
- // gl.vertexAttribDivisor.bind(gl) :
243
- // gl.getExtension('ANGLE_instanced_arrays').vertexAttribDivisorANGLE.bind(gl.getExtension('ANGLE_instanced_arrays'));
244
236
  }
245
237
  if (!gl.getProgramParameter(this._p, gl.LINK_STATUS)) {
246
238
  cons.logErr(`Shader program "${this.name}": initialization failed. ${gl.getProgramInfoLog(this._p)}.`);