@pirireis/webglobeplugins 0.9.3 → 0.9.5

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.
@@ -1,59 +0,0 @@
1
-
2
-
3
- class DrawOptionsClient {
4
-
5
- /**
6
- * @typedef DrawOptionsClientAdaptor
7
- * @type {Object}
8
- * @property {function} setElements
9
- * @property {function} setDrawRange
10
- * @property {function} free
11
- *
12
- * @param {*} gl
13
- * @param {*} adaptorsMap
14
- */
15
- constructor(gl, adaptorsMap) {
16
- this.gl = gl;
17
- this.adaptorsMap = adaptorsMap;
18
- this.elementBuffers = new Map();
19
- }
20
-
21
- __init() {
22
- const { gl, adaptorsMap } = this;
23
- // create element buffer for each element buffer type
24
- for (const [key, value] of Object.entries(adaptorsMap)) {
25
- const elementBuffer = gl.createBuffer();
26
- this.elementBuffers.set(key, elementBuffer);
27
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
28
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, value, gl.DYNAMIC_DRAW);
29
- }
30
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
31
-
32
-
33
- }
34
-
35
-
36
- setDrawRange() {
37
-
38
- }
39
-
40
-
41
- /**
42
- *
43
- * @param {null|Int32List|Int32Array} elementIndexes
44
- */
45
- setElements(elementIndexes = null) {
46
-
47
- }
48
-
49
- getDrawOptions() {
50
-
51
- }
52
-
53
-
54
-
55
-
56
- free() {
57
-
58
- }
59
- }
@@ -1,46 +0,0 @@
1
- import './types'
2
-
3
- /**
4
- *
5
- * @param {WebGL2RenderingContext} gl
6
- * @param {WebGL2RenderingContext.DrawMode} mode
7
- * @param {DrawRangeIndexParams} drawOptions
8
- */
9
-
10
-
11
- // first and element effects the vertexID, which is unfortunately not effected
12
- const drawInstanced = (gl, mode, drawOptions, vertexCount) => {
13
- const { drawRange, elementBufferIndexType = gl.UNSIGNED_INT } = drawOptions;
14
- const { first = 0, count: instanceCount = 1 } = drawRange;
15
- if (first > 0 || drawOptions.elementBuffer) {
16
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, drawOptions.elementBuffer);
17
- gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, instanceCount);
18
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
19
- } else {
20
-
21
- gl.drawArraysInstanced(mode, first, vertexCount, instanceCount);
22
- }
23
- }
24
-
25
-
26
- /**
27
- *
28
- * @param {WebGL2RenderingContext} gl
29
- * @param {WebGL2RenderingContext.DrawMode} defaultMode
30
- * @param {DrawRangeIndexParams} drawOptions
31
- */
32
-
33
- const drawArrays = (gl, defaultMode, drawOptions) => {
34
- const { drawRange, elementBuffer, elementBufferIndexType = gl.UNSIGNED_INT, drawMode = null } = drawOptions;
35
- const { first, count } = drawRange;
36
- const mode = drawMode ?? defaultMode;
37
- if (elementBuffer) {
38
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
39
- gl.drawElements(mode, count, elementBufferIndexType, first);
40
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
41
- } else {
42
- gl.drawArrays(mode, first, count);
43
- }
44
- }
45
-
46
- export { drawArrays, drawInstanced }
File without changes