@bigmistqke/view.gl 0.1.3 → 0.1.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.
- package/.claude/settings.local.json +4 -1
- package/.prettierignore +1 -0
- package/README.md +429 -213
- package/dev/src/examples/bezier.ts +3 -9
- package/dev/src/examples/{game_of_life.ts → game-of-life.ts} +2 -9
- package/dev/src/examples/glsl-composition.ts +131 -0
- package/dev/src/examples/grid.ts +4 -3
- package/dev/src/examples/overview.ts +7 -6
- package/dev/src/examples/{pix_sim.ts → pix-sim.ts} +3 -14
- package/dev/src/examples/symbol.ts +4 -3
- package/dev/src/index.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/tag.d.mts +39 -21
- package/dist/tag.mjs +395 -47
- package/dist/tag.mjs.map +1 -1
- package/dist/{types-DoFAJoh-.d.mts → types-DIIqZ8e6.d.mts} +34 -11
- package/package.json +3 -2
- package/src/index.ts +4 -4
- package/src/tag.ts +251 -110
- package/src/types.ts +65 -5
- package/src/utils/index.ts +9 -9
- package/test/tag.test.ts +800 -82
package/src/utils/index.ts
CHANGED
|
@@ -71,26 +71,26 @@ export const kindToUniformFnName = <T extends UniformKind>(
|
|
|
71
71
|
switch (kind[0]) {
|
|
72
72
|
// mat
|
|
73
73
|
case 'm':
|
|
74
|
-
return 'Matrix' + kind.slice(3) + 'fv'
|
|
74
|
+
return ('Matrix' + kind.slice(3) + 'fv') as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
75
75
|
// sampler/booleans/integer
|
|
76
76
|
case 's':
|
|
77
77
|
case 'b':
|
|
78
78
|
case 'i':
|
|
79
|
-
return (kind.match(/\d/)?.[0] ?? '1') + 'i'
|
|
79
|
+
return ((kind.match(/\d/)?.[0] ?? '1') + 'i') as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
80
80
|
// unsigned integers
|
|
81
81
|
case 'u':
|
|
82
|
-
return (kind[4] || '1') + 'ui'
|
|
82
|
+
return ((kind[4] || '1') + 'ui') as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
83
83
|
// vec
|
|
84
84
|
case 'v':
|
|
85
|
-
return kind[3] + 'f'
|
|
85
|
+
return (kind[3] + 'f') as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
86
86
|
default:
|
|
87
87
|
switch (kind) {
|
|
88
88
|
case 'float':
|
|
89
|
-
return '1f'
|
|
89
|
+
return '1f' as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
90
90
|
case 'uint':
|
|
91
|
-
return '1ui'
|
|
91
|
+
return '1ui' as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
92
92
|
default:
|
|
93
|
-
return '1i'
|
|
93
|
+
return '1i' as KIND_TO_UNIFORM_FN_NAME_MAP[T]
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -167,7 +167,7 @@ export function createTexture(
|
|
|
167
167
|
if (!(name in gl)) {
|
|
168
168
|
throw new Error(`Attempted to create webgl2-only texture (${name}) in webgl1`)
|
|
169
169
|
}
|
|
170
|
-
return gl[name]
|
|
170
|
+
return gl[name as keyof typeof gl] as any
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
gl.bindTexture(gl[target], texture)
|
|
@@ -268,7 +268,7 @@ export function createFramebuffer(gl: GL, { attachment, texture, ...options }: F
|
|
|
268
268
|
/* */
|
|
269
269
|
/**********************************************************************************/
|
|
270
270
|
|
|
271
|
-
type UpsertMapKind<T, U> = Map<T, U> | WeakMap<T, U>
|
|
271
|
+
type UpsertMapKind<T, U> = Map<T, U> | (T extends WeakKey ? WeakMap<T, U> : never)
|
|
272
272
|
|
|
273
273
|
export function createUpsertMap<T extends UpsertMapKind<any, any> = Map<any, any>>(
|
|
274
274
|
constructor?: new () => T,
|