@thi.ng/webgl 6.3.11 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/README.md +1 -1
- package/api/buffers.d.ts +9 -0
- package/api/model.d.ts +9 -0
- package/buffer.d.ts +1 -1
- package/buffer.js +2 -2
- package/canvas.d.ts +11 -0
- package/canvas.js +16 -0
- package/matrices.js +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-04-
|
|
3
|
+
- **Last updated**: 2023-04-19T09:28:07Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,17 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [6.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/webgl@6.4.0) (2023-04-19)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add retain option to ModelAttributeSpec/IndexBufferSpec ([3db4463](https://github.com/thi-ng/umbrella/commit/3db4463))
|
|
17
|
+
- update defBuffer()/initBuffer()
|
|
18
|
+
- add clearCanvas() ([ad362f9](https://github.com/thi-ng/umbrella/commit/ad362f9))
|
|
19
|
+
- update glCanvas() return type ([4af5e04](https://github.com/thi-ng/umbrella/commit/4af5e04))
|
|
20
|
+
- add `resize` handler to result which can later be called to
|
|
21
|
+
resize the canvas (with DPR) and update the GL viewport
|
|
22
|
+
|
|
12
23
|
## [6.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/webgl@6.3.0) (2023-02-05)
|
|
13
24
|
|
|
14
25
|
#### 🚀 Features
|
package/README.md
CHANGED
package/api/buffers.d.ts
CHANGED
|
@@ -27,6 +27,15 @@ export interface IndexBufferSpec {
|
|
|
27
27
|
* Raw attribute data from which `buffer` will be initialized
|
|
28
28
|
*/
|
|
29
29
|
data: IndexBufferData;
|
|
30
|
+
/**
|
|
31
|
+
* Only used if {@link IndexBufferSpec.buffer} is being auto-generated.
|
|
32
|
+
* If true (default: false), the buffer will retain a handler to the given
|
|
33
|
+
* {@link IndexBufferSpec.data} array and can be later conveniently
|
|
34
|
+
* updated via {@link WebGLArrayBuffer.update}.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue false
|
|
37
|
+
*/
|
|
38
|
+
retain?: boolean;
|
|
30
39
|
}
|
|
31
40
|
export interface FboOpts {
|
|
32
41
|
/**
|
package/api/model.d.ts
CHANGED
|
@@ -98,6 +98,15 @@ export interface ModelAttributeSpec {
|
|
|
98
98
|
* https://www.khronos.org/registry/OpenGL/extensions/ANGLE/ANGLE_instanced_arrays.txt
|
|
99
99
|
*/
|
|
100
100
|
divisor?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Only used if {@link ModelAttributeSpec.buffer} is being auto-generated.
|
|
103
|
+
* If true (default: false), the buffer will retain a handler to the given
|
|
104
|
+
* {@link ModelAttributeSpec.data} array and can be later conveniently
|
|
105
|
+
* updated via {@link WebGLArrayBuffer.update}.
|
|
106
|
+
*
|
|
107
|
+
* @defaultValue false
|
|
108
|
+
*/
|
|
109
|
+
retain?: boolean;
|
|
101
110
|
}
|
|
102
111
|
export interface InstancingSpec {
|
|
103
112
|
attribs: IObjectOf<ModelAttributeSpec>;
|
package/buffer.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare class WebGLArrayBuffer<T extends TypedArray> implements IWebGLBuf
|
|
|
24
24
|
set(data: T, mode?: number): void;
|
|
25
25
|
setChunk(data: T, byteOffset?: number): void;
|
|
26
26
|
}
|
|
27
|
-
export declare const defBuffer: (gl: WebGLRenderingContext, data?: TypedArray, target?: 34962, mode?: 35044) => WebGLArrayBuffer<Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>;
|
|
27
|
+
export declare const defBuffer: (gl: WebGLRenderingContext, data?: TypedArray, target?: 34962, mode?: 35044, retain?: boolean) => WebGLArrayBuffer<Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>;
|
|
28
28
|
export declare const compileModel: (gl: WebGLRenderingContext, spec: ModelSpec, mode?: 35044) => ModelSpec;
|
|
29
29
|
export declare const compileIndices: (gl: WebGLRenderingContext, index: IndexBufferSpec | undefined, mode?: GLenum) => IndexBufferSpec | undefined;
|
|
30
30
|
export declare const compileVAO: (gl: WebGLRenderingContext, spec: ModelSpec) => WebGLVertexArrayObject | undefined;
|
package/buffer.js
CHANGED
|
@@ -55,7 +55,7 @@ export class WebGLArrayBuffer {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
export const defBuffer = (gl, data, target = gl.ARRAY_BUFFER, mode = gl.STATIC_DRAW) => new WebGLArrayBuffer(gl, data, target, mode);
|
|
58
|
+
export const defBuffer = (gl, data, target = gl.ARRAY_BUFFER, mode = gl.STATIC_DRAW, retain = false) => new WebGLArrayBuffer(gl, data, target, mode, retain);
|
|
59
59
|
export const compileModel = (gl, spec, mode = gl.STATIC_DRAW) => {
|
|
60
60
|
if (spec.attribPool) {
|
|
61
61
|
spec.attribs = compileAttribPool(gl, spec.attribPool, undefined, gl.ARRAY_BUFFER, mode);
|
|
@@ -74,7 +74,7 @@ const initBuffer = (gl, src, type, mode) => {
|
|
|
74
74
|
src.data && src.buffer.set(src.data);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
|
-
src.buffer = new WebGLArrayBuffer(gl, src.data, type, mode);
|
|
77
|
+
src.buffer = new WebGLArrayBuffer(gl, src.data, type, mode, src.retain);
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
const compileAttribs = (gl, attribs, mode) => {
|
package/canvas.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
1
2
|
import type { WeblGLCanvasOpts } from "./api/canvas.js";
|
|
2
3
|
import type { WebGLExtensionMap } from "./api/ext.js";
|
|
3
4
|
export declare const glCanvas: (opts?: Partial<WeblGLCanvasOpts>) => {
|
|
4
5
|
canvas: HTMLCanvasElement;
|
|
5
6
|
gl: WebGLRenderingContext;
|
|
6
7
|
ext: Pick<WebGLExtensionMap, keyof WebGLExtensionMap>;
|
|
8
|
+
resize: (width: number, height: number) => void;
|
|
7
9
|
};
|
|
8
10
|
export declare const getExtensions: <K extends keyof WebGLExtensionMap>(gl: WebGLRenderingContext, ids: K[], required?: boolean) => Pick<WebGLExtensionMap, K>;
|
|
11
|
+
/**
|
|
12
|
+
* Sets clear color to given RGBA `color` and clears viewport's
|
|
13
|
+
* `COLOR_BUFFER_BIT` and (by default) also `DEPTH_BUFFER_BIT`.
|
|
14
|
+
*
|
|
15
|
+
* @param gl
|
|
16
|
+
* @param color
|
|
17
|
+
* @param depth
|
|
18
|
+
*/
|
|
19
|
+
export declare const clearCanvas: (gl: WebGLRenderingContext, [r, g, b, a]: ReadonlyVec, depth?: boolean) => void;
|
|
9
20
|
//# sourceMappingURL=canvas.d.ts.map
|
package/canvas.js
CHANGED
|
@@ -32,6 +32,10 @@ export const glCanvas = (opts = {}) => {
|
|
|
32
32
|
canvas,
|
|
33
33
|
gl,
|
|
34
34
|
ext: getExtensions(gl, opts.ext),
|
|
35
|
+
resize: (width, height) => {
|
|
36
|
+
adaptDPI(canvas, width, height, opts.autoScale !== false ? window.devicePixelRatio : 1);
|
|
37
|
+
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
38
|
+
},
|
|
35
39
|
};
|
|
36
40
|
};
|
|
37
41
|
export const getExtensions = (gl, ids, required = true) => {
|
|
@@ -44,3 +48,15 @@ export const getExtensions = (gl, ids, required = true) => {
|
|
|
44
48
|
}
|
|
45
49
|
return ext;
|
|
46
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Sets clear color to given RGBA `color` and clears viewport's
|
|
53
|
+
* `COLOR_BUFFER_BIT` and (by default) also `DEPTH_BUFFER_BIT`.
|
|
54
|
+
*
|
|
55
|
+
* @param gl
|
|
56
|
+
* @param color
|
|
57
|
+
* @param depth
|
|
58
|
+
*/
|
|
59
|
+
export const clearCanvas = (gl, [r, g, b, a], depth = true) => {
|
|
60
|
+
gl.clearColor(r, g, b, a);
|
|
61
|
+
gl.clear(gl.COLOR_BUFFER_BIT | (depth ? gl.DEPTH_BUFFER_BIT : 0));
|
|
62
|
+
};
|
package/matrices.js
CHANGED
|
@@ -3,7 +3,7 @@ import { IDENT44 } from "@thi.ng/matrices/constants";
|
|
|
3
3
|
import { mulM44 } from "@thi.ng/matrices/mulm";
|
|
4
4
|
import { normal44 } from "@thi.ng/matrices/normal-mat";
|
|
5
5
|
import { ortho } from "@thi.ng/matrices/ortho";
|
|
6
|
-
const $ = (a, b, id) => a[id] || b[id]
|
|
6
|
+
const $ = (a, b, id) => a[id] || b[id]?.defaultVal || IDENT44;
|
|
7
7
|
/**
|
|
8
8
|
* Computes the inverse transpose of given 4x4 matrix uniform, i.e.
|
|
9
9
|
* `transpose(invert(m))`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/webgl",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.1",
|
|
4
4
|
"description": "WebGL & GLSL abstraction layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@thi.ng/adapt-dpi": "^2.2.11",
|
|
42
|
-
"@thi.ng/api": "^8.
|
|
43
|
-
"@thi.ng/associative": "^6.2.
|
|
42
|
+
"@thi.ng/api": "^8.8.0",
|
|
43
|
+
"@thi.ng/associative": "^6.2.36",
|
|
44
44
|
"@thi.ng/checks": "^3.3.12",
|
|
45
45
|
"@thi.ng/equiv": "^2.1.22",
|
|
46
46
|
"@thi.ng/errors": "^2.2.15",
|
|
47
47
|
"@thi.ng/logger": "^1.4.13",
|
|
48
|
-
"@thi.ng/matrices": "^2.1.
|
|
49
|
-
"@thi.ng/memoize": "^3.1.
|
|
50
|
-
"@thi.ng/pixel": "^4.2.
|
|
51
|
-
"@thi.ng/shader-ast": "^0.12.
|
|
52
|
-
"@thi.ng/shader-ast-glsl": "^0.4.
|
|
53
|
-
"@thi.ng/shader-ast-stdlib": "^0.13.
|
|
54
|
-
"@thi.ng/transducers": "^8.4.
|
|
55
|
-
"@thi.ng/vector-pools": "^3.1.
|
|
56
|
-
"@thi.ng/vectors": "^7.6.
|
|
48
|
+
"@thi.ng/matrices": "^2.1.54",
|
|
49
|
+
"@thi.ng/memoize": "^3.1.30",
|
|
50
|
+
"@thi.ng/pixel": "^4.2.2",
|
|
51
|
+
"@thi.ng/shader-ast": "^0.12.50",
|
|
52
|
+
"@thi.ng/shader-ast-glsl": "^0.4.50",
|
|
53
|
+
"@thi.ng/shader-ast-stdlib": "^0.13.13",
|
|
54
|
+
"@thi.ng/transducers": "^8.4.4",
|
|
55
|
+
"@thi.ng/vector-pools": "^3.1.55",
|
|
56
|
+
"@thi.ng/vectors": "^7.6.13"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@microsoft/api-extractor": "^7.34.4",
|
|
@@ -219,5 +219,5 @@
|
|
|
219
219
|
],
|
|
220
220
|
"year": 2014
|
|
221
221
|
},
|
|
222
|
-
"gitHead": "
|
|
222
|
+
"gitHead": "ca22f02a137c0a4e3a38ef81e82e2bc7e3c43849\n"
|
|
223
223
|
}
|