typegpu 0.0.0-alpha.4 → 0.0.0-alpha.6
Sign up to get free protection for your applications and to get access to all the features.
- package/chunk-337KOXP7.js +2 -0
- package/chunk-337KOXP7.js.map +1 -0
- package/chunk-6WFXH2OR.js +8 -0
- package/chunk-6WFXH2OR.js.map +1 -0
- package/chunk-G6QA55EY.cjs +8 -0
- package/chunk-G6QA55EY.cjs.map +1 -0
- package/chunk-S55XYV7U.cjs +2 -0
- package/chunk-S55XYV7U.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.d.cts +64 -23
- package/data/index.d.ts +64 -23
- package/data/index.js +1 -1
- package/index.cjs +1 -48
- package/index.cjs.map +1 -1
- package/index.d.cts +54 -330
- package/index.d.ts +54 -330
- package/index.js +1 -48
- package/index.js.map +1 -1
- package/macro/index.cjs +3 -3
- package/macro/index.cjs.map +1 -1
- package/macro/index.d.cts +1 -1
- package/macro/index.d.ts +1 -1
- package/macro/index.js +2 -2
- package/macro/index.js.map +1 -1
- package/package.json +7 -8
- package/types-DU0c7BuW.d.cts +207 -0
- package/types-DU0c7BuW.d.ts +207 -0
- package/chunk-7HTWRNOH.cjs +0 -12
- package/chunk-7HTWRNOH.cjs.map +0 -1
- package/chunk-K2GYQABQ.js +0 -12
- package/chunk-K2GYQABQ.js.map +0 -1
- package/std140-Cv7GDE9w.d.ts +0 -26
- package/std140-DRitCcmc.d.cts +0 -26
- package/types-ENDwr_p9.d.cts +0 -243
- package/types-ENDwr_p9.d.ts +0 -243
package/data/index.d.ts
CHANGED
@@ -1,38 +1,79 @@
|
|
1
|
-
export { S as SimpleWgslData } from '../std140-Cv7GDE9w.js';
|
2
|
-
import { k as AnyWgslData, M as WgslData, R as ResolutionCtx, N as WgslPointer, _ as U32, $ as I32 } from '../types-ENDwr_p9.js';
|
3
|
-
export { a0 as Bool, a4 as F32, ao as Mat4f, aa as Vec2f, a8 as Vec2i, a6 as Vec2u, ag as Vec3f, ae as Vec3i, ac as Vec3u, am as Vec4f, ak as Vec4i, ai as Vec4u, a1 as bool, a5 as f32, a3 as i32, ap as mat4f, a2 as u32, ab as vec2f, a9 as vec2i, a7 as vec2u, ah as vec3f, af as vec3i, ad as vec3u, an as vec4f, al as vec4i, aj as vec4u } from '../types-ENDwr_p9.js';
|
4
1
|
import * as TB from 'typed-binary';
|
5
|
-
import { Schema, Unwrap, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
|
2
|
+
import { AnySchema, Schema, Unwrap, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord, Parsed } from 'typed-binary';
|
6
3
|
export { Parsed, Unwrap } from 'typed-binary';
|
4
|
+
import { g as TgpuData, R as ResolutionCtx, A as AnyTgpuData, b as TgpuNamable, i as TgpuPointer } from '../types-DU0c7BuW.js';
|
5
|
+
export { p as Vec2f, q as Vec2i, r as Vec2u, s as Vec3f, t as Vec3i, u as Vec3u, w as Vec4f, x as Vec4i, y as Vec4u, V as VecKind, j as vec2f, k as vec2i, l as vec2u, d as vec3f, e as vec3i, f as vec3u, m as vec4f, n as vec4i, o as vec4u, v as vecBase } from '../types-DU0c7BuW.js';
|
7
6
|
|
8
|
-
declare class
|
9
|
-
private readonly _elementType;
|
10
|
-
readonly capacity: number;
|
11
|
-
private _label;
|
12
|
-
readonly byteAlignment: number;
|
7
|
+
declare class SimpleTgpuData<TSchema extends AnySchema> extends Schema<Unwrap<TSchema>> implements TgpuData<Unwrap<TSchema>> {
|
13
8
|
readonly size: number;
|
14
|
-
|
15
|
-
|
9
|
+
readonly byteAlignment: number;
|
10
|
+
readonly expressionCode: string;
|
11
|
+
private readonly _innerSchema;
|
12
|
+
/**
|
13
|
+
* byteAlignment has to be a power of 2
|
14
|
+
*/
|
15
|
+
constructor({ schema, byteAlignment, code, }: {
|
16
|
+
schema: TSchema;
|
17
|
+
byteAlignment: number;
|
18
|
+
code: string;
|
19
|
+
});
|
16
20
|
resolveReferences(): void;
|
17
|
-
write(output: ISerialOutput,
|
18
|
-
read(input: ISerialInput): ParseUnwrapped<
|
19
|
-
measure(
|
21
|
+
write(output: ISerialOutput, value: ParseUnwrapped<TSchema>): void;
|
22
|
+
read(input: ISerialInput): ParseUnwrapped<TSchema>;
|
23
|
+
measure(value: ParseUnwrapped<TSchema> | MaxValue, measurer?: IMeasurer): IMeasurer;
|
24
|
+
getUnderlyingTypeString(): string;
|
25
|
+
getUnderlyingType(): SimpleTgpuData<AnySchema>;
|
20
26
|
resolve(ctx: ResolutionCtx): string;
|
21
27
|
}
|
22
|
-
declare const dynamicArrayOf: <TSchema extends AnyWgslData>(elementType: TSchema, capacity: number) => DynamicArrayDataType<TSchema>;
|
23
28
|
|
24
|
-
|
25
|
-
|
29
|
+
type Bool = TgpuData<boolean>;
|
30
|
+
declare const bool: Bool;
|
31
|
+
type U32 = TgpuData<number>;
|
32
|
+
declare const u32: U32;
|
33
|
+
type I32 = TgpuData<number>;
|
34
|
+
declare const i32: I32;
|
35
|
+
type F32 = TgpuData<number>;
|
36
|
+
declare const f32: F32;
|
37
|
+
/**
|
38
|
+
* Array of column vectors
|
39
|
+
*/
|
40
|
+
type Mat4f = TgpuData<number[]>;
|
41
|
+
declare const mat4f: Mat4f;
|
42
|
+
|
43
|
+
interface TgpuStruct<TProps extends Record<string, AnyTgpuData>> extends ISchema<UnwrapRecord<TProps>>, TgpuData<UnwrapRecord<TProps>>, TgpuNamable {
|
26
44
|
}
|
27
|
-
declare const struct: <TProps extends Record<string,
|
45
|
+
declare const struct: <TProps extends Record<string, AnyTgpuData>>(properties: TProps) => TgpuStruct<TProps>;
|
28
46
|
|
29
|
-
|
30
|
-
|
47
|
+
interface TgpuArray<TElement extends AnyTgpuData> extends TgpuData<Unwrap<TElement>[]> {
|
48
|
+
readonly elementType: TElement;
|
49
|
+
readonly elementCount: number;
|
50
|
+
}
|
51
|
+
declare class TgpuArrayImpl<TElement extends AnyTgpuData> extends Schema<Unwrap<TElement>[]> implements TgpuArray<TElement> {
|
52
|
+
readonly elementType: TElement;
|
53
|
+
readonly elementCount: number;
|
54
|
+
readonly byteAlignment: number;
|
55
|
+
readonly size: number;
|
56
|
+
readonly stride: number;
|
57
|
+
constructor(elementType: TElement, count: number);
|
58
|
+
write(output: TB.ISerialOutput, value: Parsed<Unwrap<TElement>>[]): void;
|
59
|
+
read(input: TB.ISerialInput): Parsed<Unwrap<TElement>>[];
|
60
|
+
measure(value: MaxValue | Parsed<Unwrap<TElement>>[], measurer?: IMeasurer): IMeasurer;
|
61
|
+
resolve(ctx: ResolutionCtx): string;
|
62
|
+
}
|
63
|
+
declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
|
31
64
|
|
32
|
-
declare function ptr<TDataType extends
|
65
|
+
declare function ptr<TDataType extends AnyTgpuData>(pointsTo: TDataType): TgpuPointer<'function', TDataType>;
|
33
66
|
|
34
67
|
declare function atomic<TSchema extends U32 | I32>(data: TSchema): Atomic<TSchema>;
|
35
|
-
interface Atomic<TSchema extends U32 | I32> extends
|
68
|
+
interface Atomic<TSchema extends U32 | I32> extends TgpuData<Unwrap<TSchema>> {
|
69
|
+
}
|
70
|
+
|
71
|
+
declare function align<TAlign extends number, TData extends AnyTgpuData>(byteAlignment: TAlign, data: TData): TgpuAligned<TAlign, TData>;
|
72
|
+
interface TgpuAligned<TAlign extends number, TData extends AnyTgpuData> extends TgpuData<Unwrap<TData>> {
|
73
|
+
}
|
74
|
+
|
75
|
+
declare function size<TSize extends number, TData extends AnyTgpuData>(size: TSize, data: TData): TgpuSized<TSize, TData>;
|
76
|
+
interface TgpuSized<TSize extends number, TData extends AnyTgpuData> extends TgpuData<Unwrap<TData>> {
|
36
77
|
}
|
37
78
|
|
38
|
-
export { I32,
|
79
|
+
export { type Bool, type F32, type I32, type Mat4f, SimpleTgpuData, type TgpuAligned, type TgpuArray, TgpuArrayImpl, type TgpuSized, type TgpuStruct, type U32, align, arrayOf, atomic, bool, f32, i32, mat4f, ptr, size, struct, u32 };
|
package/data/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{
|
1
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v}from"../chunk-6WFXH2OR.js";import"../chunk-337KOXP7.js";export{a as SimpleTgpuData,j as TgpuArrayImpl,g as align,k as arrayOf,v as atomic,b as bool,e as f32,d as i32,f as mat4f,u as ptr,h as size,i as struct,c as u32,l as vec2f,m as vec2i,n as vec2u,o as vec3f,p as vec3i,q as vec3u,r as vec4f,s as vec4i,t as vec4u};
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.cjs
CHANGED
@@ -1,49 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
2
|
-
|
3
|
-
`)}${s}`}getIndexFor(e){let t=this._shared.getBindingIndex(e);if(t===void 0)throw new Error("No index found for item");return t}},te=class n{constructor(e,t,r){this._parent=e;this._shared=t;this._slotValuePairs=r;_chunk7HTWRNOHcjs.d.call(void 0, this,"usedSlots",new Set)}addDeclaration(e){this._shared.addDeclaration(this.resolve(e))}addBinding(e,t){if(e.usage==="vertex"){this._shared.registerBindingNoEntry(e);return}let{group:r,idx:s}=this._shared.reserveBindingEntry(e);this.addDeclaration(_chunk7HTWRNOHcjs.O`@group(${r}) @binding(${s}) var<${st[e.usage]}> ${t}: ${e.allocatable.dataType};`)}addRenderResource(e,t){let{group:r,idx:s}=this._shared.reserveRenderResourceEntry(e);if(_chunk7HTWRNOHcjs.k.call(void 0, e.type)||_chunk7HTWRNOHcjs.o.call(void 0, e.type)||_chunk7HTWRNOHcjs.m.call(void 0, e.type)){this.addDeclaration(_chunk7HTWRNOHcjs.O`@group(${r}) @binding(${s}) var ${t}: ${e.type};`);return}if(O(e)){if(e.access!==void 0){this.addDeclaration(_chunk7HTWRNOHcjs.O`@group(${r}) @binding(${s}) var ${t}: ${e.type}<${e.texture.descriptor.format}, ${e.access}>;`);return}this.addDeclaration(_chunk7HTWRNOHcjs.O`@group(${r}) @binding(${s}) var ${t}: ${e.type}<${e.dataType}>;`);return}throw new Error(`Unsupported resource type: ${e.type}`)}addBuiltin(e){this._shared.addBuiltin(e)}nameFor(e){return this._shared.names.nameFor(e)}readSlot(e){let t=this._slotValuePairs.find(([r])=>r===e);return t?(this.usedSlots.add(e),t[1]):(this.usedSlots.add(e),this._parent.readSlot(e))}unwrap(e){let t=e;for(;_chunk7HTWRNOHcjs.j.call(void 0, t);)t=this.readSlot(t);return t}resolve(e,t=[]){if(!_chunk7HTWRNOHcjs.h.call(void 0, e))return String(e);let r=new n(this,this._shared,t);return this._shared.getOrInstantiate(e,r)}};var nt={uniform:"uniform",mutable:"storage",readonly:"read-only-storage"},_= exports.ProgramBuilder =class{constructor(e,t){this.runtime=e;this.root=t}build(e){var x;let t=new P({names:(x=e.nameRegistry)!=null?x:new b,bindingGroup:e.bindingGroup}),r=t.resolve(this.root),s=Array.from(t.usedBindables),l=Array.from(t.usedRenderResources),g=l.filter(F),i=l.filter(O),m=l.filter(ke),p=[];for(let d of i)d.access===void 0?p.push({binding:t.getIndexFor(d),visibility:e.shaderStage,texture:{}}):p.push({binding:t.getIndexFor(d),visibility:e.shaderStage,storageTexture:{format:d.texture.descriptor.format}});for(let d of m)p.push({binding:t.getIndexFor(d),visibility:e.shaderStage,externalTexture:{}});for(let d of g)p.push({binding:t.getIndexFor(d),visibility:e.shaderStage,sampler:{}});for(let d of s)d.usage!=="vertex"&&p.push({binding:t.getIndexFor(d),visibility:e.shaderStage,buffer:{type:nt[d.usage]}});let c=[];for(let d of i)c.push({binding:t.getIndexFor(d),resource:this.runtime.viewFor(d)});for(let d of m)c.push({binding:t.getIndexFor(d),resource:this.runtime.externalTextureFor(d)});for(let d of g)c.push({binding:t.getIndexFor(d),resource:this.runtime.samplerFor(d)});for(let d of s)d.usage!=="vertex"&&c.push({binding:t.getIndexFor(d),resource:{buffer:this.runtime.bufferFor(d.allocatable)}});let f=this.runtime.device.createBindGroupLayout({entries:p}),y=this.runtime.device.createBindGroup({layout:f,entries:c});return{bindGroupLayout:f,bindGroup:y,code:r}}},M=class{constructor(e,t,r,s){this.runtime=e;this.vertexRoot=t;this.fragmentRoot=r;this.vertexOutputFormat=s}build(e){var xe,he,be,We;let t=Object.getOwnPropertySymbols(this.vertexOutputFormat).map(u=>{let h=this.vertexOutputFormat[u];if(typeof h!="string")throw new Error("Output names must be strings.");return{symbol:u,name:h}}),r=Object.fromEntries(t.map(({symbol:u,name:h})=>[u,h])),s=_chunk7HTWRNOHcjs.N.call(void 0, r),g=Object.keys(this.vertexOutputFormat).map((u,h)=>{let R=this.vertexOutputFormat[u];if(!R)throw new Error("Output names must be strings.");return{name:u,varInfo:R,index:h}}),i=[...s.map(u=>_chunk7HTWRNOHcjs.O`
|
4
|
-
@builtin(${u.builtin.name}) ${u.name}: ${u.builtin.type},
|
5
|
-
`),...g.map(({name:u,varInfo:h,index:R})=>_chunk7HTWRNOHcjs.O`
|
6
|
-
@location(${R}) ${u}: ${h},
|
7
|
-
`)],m=new P({names:(xe=e.nameRegistry)!=null?xe:new b,bindingGroup:e.bindingGroup});m.resolve(this.vertexRoot);let p=Array.from(m.usedBindables).filter(u=>u.usage==="vertex"),f=p.map(u=>({bindable:u,underlyingType:u.allocatable.dataType})).map((u,h)=>_chunk7HTWRNOHcjs.O`
|
8
|
-
@location(${h}) ${u.bindable} : ${u.underlyingType.getUnderlyingTypeString()},
|
9
|
-
`),d=[...Array.from(m.usedBuiltins).map(u=>_chunk7HTWRNOHcjs.O`
|
10
|
-
@builtin(${u.name}) ${u.identifier}: ${u.type},
|
11
|
-
`),...f],W=_chunk7HTWRNOHcjs.O`
|
12
|
-
struct VertexOutput {
|
13
|
-
${i}
|
14
|
-
};
|
15
|
-
|
16
|
-
@vertex
|
17
|
-
fn main(${d}) -> VertexOutput {
|
18
|
-
${this.vertexRoot}
|
19
|
-
var output: VertexOutput;
|
20
|
-
${s.map(u=>_chunk7HTWRNOHcjs.O`
|
21
|
-
output.${u.name} = ${u.name};
|
22
|
-
`)}
|
23
|
-
${g.map(({name:u})=>_chunk7HTWRNOHcjs.O`
|
24
|
-
output.${u} = ${u};
|
25
|
-
`)}
|
26
|
-
return output;
|
27
|
-
}
|
28
|
-
`,A=new P({names:(he=e.nameRegistry)!=null?he:new b,bindingGroup:e.bindingGroup});A.resolve(this.fragmentRoot);let D=Array.from(A.usedBuiltins).map(u=>_chunk7HTWRNOHcjs.O`
|
29
|
-
@builtin(${u.name}) ${u.identifier}: ${u.type},
|
30
|
-
`),V=g.map(({name:u,varInfo:h},R)=>_chunk7HTWRNOHcjs.O`
|
31
|
-
@location(${R}) ${u}: ${h},
|
32
|
-
`),v=[...D,...V],B=_chunk7HTWRNOHcjs.O`
|
33
|
-
@fragment
|
34
|
-
fn main(${v}) -> @location(0) vec4f {
|
35
|
-
${this.fragmentRoot}
|
36
|
-
}
|
37
|
-
`,et=new _(this.runtime,W).build({bindingGroup:e.bindingGroup,shaderStage:GPUShaderStage.VERTEX,nameRegistry:(be=e.nameRegistry)!=null?be:new b}),tt=new _(this.runtime,B).build({bindingGroup:e.bindingGroup+1,shaderStage:GPUShaderStage.FRAGMENT,nameRegistry:(We=e.nameRegistry)!=null?We:new b});return[et,tt,p]}},k=class{constructor(e,t,r){this.runtime=e;this.computeRoot=t;this.workgroupSize=r}build(e){var m,p,c,f;let t=new P({names:(m=e.nameRegistry)!=null?m:new b,bindingGroup:e.bindingGroup});t.resolve(this.computeRoot);let s=Array.from(t.usedBuiltins).map(y=>_chunk7HTWRNOHcjs.O`
|
38
|
-
@builtin(${y.name}) ${y.identifier}: ${y.type},
|
39
|
-
`),l=`@workgroup_size(${this.workgroupSize[0]}, ${(p=this.workgroupSize[1])!=null?p:1}, ${(c=this.workgroupSize[2])!=null?c:1})`,g=_chunk7HTWRNOHcjs.O`
|
40
|
-
@compute ${l}
|
41
|
-
fn main(${s}) {
|
42
|
-
${this.computeRoot}
|
43
|
-
}
|
44
|
-
`;return new _(this.runtime,g).build({bindingGroup:e.bindingGroup,shaderStage:GPUShaderStage.COMPUTE,nameRegistry:(f=e.nameRegistry)!=null?f:new b})}};function $(n,e){return new re(n,e)}var re=class{constructor(e,t){this.buffer=e;this.usage=t;_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}get label(){return this._label}get allocatable(){return this.buffer}$name(e){return this._label=e,this}resolve(e){let t=new _chunk7HTWRNOHcjs.F;return e.addBinding(this,t),e.resolve(t)}toString(){var e;return`${this.usage}:${(e=this._label)!=null?e:"<unnamed>"}`}};function Ie(n,e){return new se(n,e)}var se=class{constructor(e,t){this.dataType=e;this.initial=t;_chunk7HTWRNOHcjs.d.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunk7HTWRNOHcjs.d.call(void 0, this,"vertexLayout",null);_chunk7HTWRNOHcjs.d.call(void 0, this,"_allowedUsages",{uniform:null,mutable:null,readonly:null,vertex:null});_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}get label(){return this._label}$name(e){return this._label=e,this}$allowUniform(){this.$addFlags(GPUBufferUsage.UNIFORM);let e=this;return this._allowedUsages.uniform||(this._allowedUsages.uniform=$(e,"uniform")),e}$allowReadonly(){this.$addFlags(GPUBufferUsage.STORAGE);let e=this;return this._allowedUsages.readonly||(this._allowedUsages.readonly=$(e,"readonly")),e}$allowMutable(){this.$addFlags(GPUBufferUsage.STORAGE);let e=this;return this._allowedUsages.mutable||(this._allowedUsages.mutable=$(e,"mutable")),e}$allowVertex(e="vertex"){this.$addFlags(GPUBufferUsage.VERTEX);let t=this;if(!this.vertexLayout){if(!(this.dataType instanceof _chunk7HTWRNOHcjs.q))throw new Error("Only simple data types can be used as vertex buffers");let r=this.dataType;r=r.getUnderlyingType(),this.vertexLayout={arrayStride:r.size,stepMode:e},this._allowedUsages.vertex=$(t,"vertex")}if(this.vertexLayout.stepMode!==e)throw new Error("Cannot change step mode of a vertex buffer");return t}$addFlags(e){return this.flags|=e,this}asUniform(){return this._allowedUsages.uniform}asMutable(){return this._allowedUsages.mutable}asReadonly(){return this._allowedUsages.readonly}asVertex(){return this._allowedUsages.vertex}toString(){var e;return`buffer:${(e=this._label)!=null?e:"<unnamed>"}`}};function Le(n){return new ne(n)}var ne=class{constructor(e){this.expr=e;_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}get label(){return this._label}$name(e){return this._label=e,this}resolve(e){let t=new (0, _chunk7HTWRNOHcjs.F)().$name(this._label);return e.addDeclaration(_chunk7HTWRNOHcjs.O`const ${t} = ${this.expr};`),e.resolve(t)}};function Ne(n,...e){return new ae(_chunk7HTWRNOHcjs.O.call(void 0, n,...e))}var ae=class{constructor(e){this._declaration=e}resolve(e){return e.addDeclaration(_chunk7HTWRNOHcjs.O`${this._declaration}`),""}};function ze(n,...e){return new le(_chunk7HTWRNOHcjs.O.call(void 0, n,...e))}var le=class{constructor(e){this.body=e;_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}get label(){return this._label}$name(e){return this._label=e,this}resolve(e){let t=new (0, _chunk7HTWRNOHcjs.F)().$name(this._label);return e.addDeclaration(_chunk7HTWRNOHcjs.O`fn ${t}${this.body}`.$name(this._label)),e.resolve(t)}with(e,t){return new ie(this,[e,t])}toString(){var e;return`fn:${(e=this.label)!=null?e:"<unnamed>"}`}},ie=class n{constructor(e,t){this._innerFn=e;this._slotValuePair=t}get label(){return this._innerFn.label}with(e,t){return new n(this,[e,t])}resolve(e){return e.resolve(this._innerFn,[this._slotValuePair])}toString(){var r,s;let[e,t]=this._slotValuePair;return`fn:${(r=this.label)!=null?r:"<unnamed>"}[${(s=e.label)!=null?s:"<unnamed>"}=${t}]`}};function qe(n,e){let t=n.map(s=>[new _chunk7HTWRNOHcjs.F,s]),r=t.map(([s,l])=>s);return s=>{let l=s(...r);return new ue(t,e,l)}}var oe=class{constructor(e,t){this.usedFn=e;this.args=t}resolve(e){let t=this.args.map((r,s)=>{let l=s<this.args.length-1?", ":"";return _chunk7HTWRNOHcjs.O`${r}${l}`});return e.resolve(_chunk7HTWRNOHcjs.O`${this.usedFn}(${t})`.$name("internal"))}toString(){var e;return`fun:${(e=this.usedFn.label)!=null?e:"<unnamed>"}()`}},ue=class extends Ve{constructor(t,r,s){super();this.argPairs=t;this.returnType=r;this.body=s;_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}get label(){return this._label}$name(t){return this._label=t,this}resolve(t){let r=new (0, _chunk7HTWRNOHcjs.F)().$name(this._label),s=this.argPairs.map(([l,g],i)=>{let m=i<this.argPairs.length-1?", ":"";return _chunk7HTWRNOHcjs.p.call(void 0, g)?_chunk7HTWRNOHcjs.O`${l}: ptr<${g.scope}, ${g.pointsTo}>${m}`:_chunk7HTWRNOHcjs.O`${l}: ${g}${m}`});return this.returnType!==void 0?t.addDeclaration(_chunk7HTWRNOHcjs.O`fn ${r}(${s}) -> ${this.returnType} {
|
45
|
-
${this.body}
|
46
|
-
}`):t.addDeclaration(_chunk7HTWRNOHcjs.O`fn ${r}(${s}) {
|
47
|
-
${this.body}
|
48
|
-
}`),t.resolve(r)}_call(...t){return new oe(this,t)}toString(){var t;return`fun:${(t=this._label)!=null?t:"<unnamed>"}`}};var je=Symbol("This item can be set, owns its value (does not get value from an external source)");var Ke=Symbol("This plum's value is sourced from outside the runtime.");function I(n){return n[Ke]===!0}function Ye(n){return typeof n=="function"?new ge(n):new de(n)}function Qe(n,e){return new pe(n,e)}function Xe(n){return n.__brand==="WgslPlum"}var at,de=class{constructor(e){this._initial=e;_chunk7HTWRNOHcjs.d.call(void 0, this,"__brand","WgslPlum");_chunk7HTWRNOHcjs.d.call(void 0, this,at,!0);_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}compute(e){return this._initial}$name(e){return this._label=e,this}get label(){return this._label}toString(){var e;return`plum:${(e=this._label)!=null?e:"<unnamed>"}`}};at=je;var ge=class{constructor(e){this._compute=e;_chunk7HTWRNOHcjs.d.call(void 0, this,"__brand","WgslPlum");_chunk7HTWRNOHcjs.d.call(void 0, this,"_label")}$name(e){return this._label=e,this}get label(){return this._label}compute(e){return this._compute(e)}toString(){var e;return`plum:${(e=this._label)!=null?e:"<unnamed>"}`}},lt,pe=class{constructor(e,t){this._subscribe=e;this._getLatest=t;_chunk7HTWRNOHcjs.d.call(void 0, this,"__brand","WgslPlum");_chunk7HTWRNOHcjs.d.call(void 0, this,lt,!0);_chunk7HTWRNOHcjs.d.call(void 0, this,"_label");_chunk7HTWRNOHcjs.d.call(void 0, this,"_prev");_chunk7HTWRNOHcjs.d.call(void 0, this,"_version",0);this._prev=t()}$name(e){return this._label=e,this}get label(){return this._label}get version(){return this._version}subscribe(e){return this._subscribe(e)}compute(){let e=this._getLatest();return Object.is(e,this._prev)||(this._version++,this._prev=e),this._prev}toString(){var e;return`plum:${(e=this._label)!=null?e:"<unnamed>"}`}};lt=Ke;function He(n){return new me(n)}var me=class{constructor(e=void 0){this.defaultValue=e;_chunk7HTWRNOHcjs.d.call(void 0, this,"__brand","WgslSlot");_chunk7HTWRNOHcjs.d.call(void 0, this,"label")}$name(e){return this.label=e,this}areEqual(e,t){return Object.is(e,t)}resolve(e){var r;let t=e.unwrap(this);if(!_chunk7HTWRNOHcjs.i.call(void 0, t))throw new Error(`Cannot inject value of type ${typeof t} of slot '${(r=this.label)!=null?r:"<unnamed>"}' in code.`);return e.resolve(t)}toString(){var e;return`slot:${(e=this.label)!=null?e:"<unnamed>"}`}};var Je=(n,e,t="private")=>new ce(n,e,t),ce=class{constructor(e,t,r){this._dataType=e;this._initialValue=t;this.scope=r;_chunk7HTWRNOHcjs.d.call(void 0, this,"identifier",new _chunk7HTWRNOHcjs.F)}$name(e){return this.identifier.$name(e),this}resolve(e){return this._initialValue?e.addDeclaration(_chunk7HTWRNOHcjs.O`var<${this.scope}> ${this.identifier}: ${this._dataType} = ${this._initialValue};`):e.addDeclaration(_chunk7HTWRNOHcjs.O`var<${this.scope}> ${this.identifier}: ${this._dataType};`),e.resolve(this.identifier)}};var it=Object.assign(_chunk7HTWRNOHcjs.O,{code:_chunk7HTWRNOHcjs.O,fn:ze,fun:qe,buffer:Ie,plum:Ye,plumFromEvent:Qe,slot:He,constant:Le,declare:Ne,var:Je,sampler:Ee,texture:Oe,textureExternal:Me,builtin:_chunk7HTWRNOHcjs.L});var _typedbinary = require('typed-binary');var fe=(n,e)=>{let t=e-1,r=~t;return n&t?(n&r)+e:n};var L=class{constructor(){_chunk7HTWRNOHcjs.d.call(void 0, this,"_stateMap",new WeakMap)}inspect(e){return this._stateMap.get(e)}_getState(e){let t=this._stateMap.get(e);if(!t){let{value:r,dependencies:s}=this._computeAndGatherDependencies(e);t={value:r,dependencies:s,version:0},this._stateMap.set(e,t)}return t}_notifyListeners(e){let t=this._getState(e);if(!t.active)return;let r=[...t.active.listeners];for(let s of r)s(t.value)}_computeAndGatherDependencies(e){let t=new Map,r=s=>{if(!t.has(s)){let l=this._getState(s);t.set(s,l.version)}return this.get(s)};return{value:e.compute(r),dependencies:t}}_recompute(e){let t=this._getState(e);if(t.active)for(let l of t.active.unsubs)l();let{value:r,dependencies:s}=this._computeAndGatherDependencies(e);if(t.dependencies=s,t.active)for(let[l]of t.dependencies)t.active.unsubs.add(this.subscribe(l,()=>{this._recompute(e)}));return Object.is(t.value,r)||(t.value=r,t.version=I(e)?e.version:t.version+1,this._notifyListeners(e)),t.value}get(e){let t=this._getState(e);if(t.active)return t.value;let r=!1;return I(e)?(e.compute(null),r=t.version!==e.version):t.dependencies.size>0&&(r=[...t.dependencies.entries()].some(([s,l])=>(this.get(s),this._getState(s).version!==l))),r?this._recompute(e):t.value}set(e,t){let r=this._getState(e);Object.is(r.value,t)||(r.value=t,r.version++,this._notifyListeners(e))}subscribe(e,t){let r=this._getState(e),s;if(!r.active){let l=new Set;r.active={listeners:new Set,unsubs:l};for(let[g]of r.dependencies)l.add(this.subscribe(g,()=>{this._recompute(e)}));I(e)&&(s=e.subscribe(()=>{this._recompute(e)}))}return r.active.listeners.add(t),()=>{if(r.active&&(r.active.listeners.delete(t),r.active.listeners.size===0)){for(let l of r.active.unsubs)l();s==null||s(),r.active=void 0}}}};var N=class{constructor(){_chunk7HTWRNOHcjs.d.call(void 0, this,"_queue",[]);_chunk7HTWRNOHcjs.d.call(void 0, this,"_pending",!1)}enqueue(e){return new Promise((t,r)=>{this._queue.push(async()=>{try{t(await e())}catch(s){r(s)}}),this._processQueue()})}async _processQueue(){if(!this._pending){for(this._pending=!0;this._queue.length>0;){let e=this._queue.shift();e&&await e()}this._pending=!1}}};var z=class{constructor(e){this.device=e;_chunk7HTWRNOHcjs.d.call(void 0, this,"_entryToBufferMap",new Map);_chunk7HTWRNOHcjs.d.call(void 0, this,"_samplers",new WeakMap);_chunk7HTWRNOHcjs.d.call(void 0, this,"_textures",new WeakMap);_chunk7HTWRNOHcjs.d.call(void 0, this,"_textureViews",new WeakMap);_chunk7HTWRNOHcjs.d.call(void 0, this,"_pipelineExecutors",[]);_chunk7HTWRNOHcjs.d.call(void 0, this,"_commandEncoder",null);_chunk7HTWRNOHcjs.d.call(void 0, this,"_readBuffer",null);_chunk7HTWRNOHcjs.d.call(void 0, this,"_taskQueue",new N);_chunk7HTWRNOHcjs.d.call(void 0, this,"_plumStore",new L);_chunk7HTWRNOHcjs.d.call(void 0, this,"_allocSubscriptions",new Map)}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}dispose(){var e;for(let t of this._allocSubscriptions.values())t();this._allocSubscriptions.clear();for(let t of this._entryToBufferMap.values())t.destroy();this._entryToBufferMap.clear(),(e=this._readBuffer)==null||e.destroy()}bufferFor(e){let t=this._entryToBufferMap.get(e);if(!t){if(t=this.device.createBuffer({usage:e.flags,size:fe(e.dataType.size,e.dataType.byteAlignment),mappedAtCreation:e.initial!==void 0}),!t)throw new Error(`Failed to create buffer for ${e}`);if(e.initial!==void 0){let r=new (0, _typedbinary.BufferWriter)(t.getMappedRange());if(Xe(e.initial)){let s=e.initial;e.dataType.write(r,this._plumStore.get(s)),this._allocSubscriptions.set(e,this._plumStore.subscribe(s,()=>{this.writeBuffer(e,this._plumStore.get(s))}))}else e.dataType.write(r,e.initial);t.unmap()}this._entryToBufferMap.set(e,t)}return t}textureFor(e){let t;"texture"in e?t=e.texture:t=e;let r=this._textures.get(t);if(!r){let s=_chunk7HTWRNOHcjs.b.call(void 0, _chunk7HTWRNOHcjs.a.call(void 0, {},t.descriptor),{usage:t.flags});if(r=this.device.createTexture(s),!r)throw new Error(`Failed to create texture for ${e}`);this._textures.set(t,r)}return r}viewFor(e){let t=this._textureViews.get(e);return t||(t=this.textureFor(e.texture).createView(e.descriptor),this._textureViews.set(e,t)),t}externalTextureFor(e){return this.device.importExternalTexture(e.descriptor)}samplerFor(e){let t=this._samplers.get(e);if(!t){if(t=this.device.createSampler(e.descriptor),!t)throw new Error(`Failed to create sampler for ${e}`);this._samplers.set(e,t)}return t}async readBuffer(e){return this._taskQueue.enqueue(async()=>{var l;this.flush(),(!this._readBuffer||this._readBuffer.size<e.dataType.size)&&((l=this._readBuffer)==null||l.destroy(),this._readBuffer=this.device.createBuffer({usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,size:e.dataType.size}));let t=this.bufferFor(e),r=this.device.createCommandEncoder();r.copyBufferToBuffer(t,0,this._readBuffer,0,e.dataType.size),this.device.queue.submit([r.finish()]),await this.device.queue.onSubmittedWorkDone(),await this._readBuffer.mapAsync(GPUMapMode.READ,0,e.dataType.size);let s=e.dataType.read(new (0, _typedbinary.BufferReader)(this._readBuffer.getMappedRange()));return this._readBuffer.unmap(),s})}writeBuffer(e,t){let r=this.bufferFor(e),s=fe(e.dataType.size,e.dataType.byteAlignment),l=new ArrayBuffer(s);e.dataType.write(new (0, _typedbinary.BufferWriter)(l),t),this.device.queue.writeBuffer(r,0,l,0,s)}readPlum(e){return this._plumStore.get(e)}setPlum(e,t){if(typeof t=="function"){let r=t;this._plumStore.set(e,r(this._plumStore.get(e)))}else this._plumStore.set(e,t)}onPlumChange(e,t){return this._plumStore.subscribe(e,t)}makeRenderPipeline(e){var y,x,d,W,A,j,D,V;let[t,r,s]=new M(this,e.vertex.code,e.fragment.code,e.vertex.output).build({bindingGroup:((y=e.externalLayouts)!=null?y:[]).length}),l=s.map((v,B)=>{if(!v.allocatable.vertexLayout)throw new Error(`Buffer ${v.allocatable} does not have a vertex layout`);return _chunk7HTWRNOHcjs.b.call(void 0, _chunk7HTWRNOHcjs.a.call(void 0, {},v.allocatable.vertexLayout),{attributes:[{shaderLocation:B,offset:0,format:Ge(v.allocatable.dataType)}]})}),g=this.device.createShaderModule({code:t.code}),i=this.device.createShaderModule({code:r.code}),m=this.device.createPipelineLayout({label:(x=e.label)!=null?x:"",bindGroupLayouts:[...(d=e.externalLayouts)!=null?d:[],t.bindGroupLayout,r.bindGroupLayout]}),p=this.device.createRenderPipeline({label:(W=e.label)!=null?W:"",layout:m,vertex:{module:g,buffers:l},fragment:{module:i,targets:(j=(A=e.fragment)==null?void 0:A.target)!=null?j:[]},primitive:e.primitive}),c=s.map((v,B)=>[this.bufferFor(v.allocatable),B]),f=new Te(this,p,t,r,(V=(D=e.externalLayouts)==null?void 0:D.length)!=null?V:0,c);return this._pipelineExecutors.push(f),f}makeComputePipeline(e){var i,m,p,c,f,y,x;let t=new k(this,e.code,(i=e.workgroupSize)!=null?i:[1]).build({bindingGroup:((m=e.externalLayouts)!=null?m:[]).length}),r=this.device.createShaderModule({code:t.code}),s=this.device.createPipelineLayout({label:(p=e.label)!=null?p:"",bindGroupLayouts:[...(c=e.externalLayouts)!=null?c:[],t.bindGroupLayout]}),l=this.device.createComputePipeline({label:(f=e.label)!=null?f:"",layout:s,compute:{module:r}}),g=new ye(this,l,[t],(x=(y=e.externalLayouts)==null?void 0:y.length)!=null?x:0);return this._pipelineExecutors.push(g),g}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}},q=class{constructor(e,t,r,s,l){this._runtime=e;this.pipeline=t;this.programs=r;this.externalLayoutCount=s;this.label=l}},Te=class extends q{constructor(t,r,s,l,g,i){super(t,r,[s,l],g);_chunk7HTWRNOHcjs.d.call(void 0, this,"_vertexProgram");_chunk7HTWRNOHcjs.d.call(void 0, this,"_fragmentProgram");_chunk7HTWRNOHcjs.d.call(void 0, this,"_usedVertexBuffers");this._vertexProgram=s,this._fragmentProgram=l,this._usedVertexBuffers=new Set(i)}execute(t){var f,y,x;let c=t,{vertexCount:r,instanceCount:s,firstVertex:l,firstInstance:g,externalBindGroups:i}=c,m=_chunk7HTWRNOHcjs.c.call(void 0, c,["vertexCount","instanceCount","firstVertex","firstInstance","externalBindGroups"]);if(((f=i==null?void 0:i.length)!=null?f:0)!==this.externalLayoutCount)throw new Error(`External bind group count doesn't match the external bind group layout configuration. Expected ${this.externalLayoutCount}, got: ${(y=i==null?void 0:i.length)!=null?y:0}`);let p=this._runtime.commandEncoder.beginRenderPass(_chunk7HTWRNOHcjs.b.call(void 0, _chunk7HTWRNOHcjs.a.call(void 0, {},m),{label:(x=this.label)!=null?x:""}));p.setPipeline(this.pipeline),(i!=null?i:[]).forEach((d,W)=>p.setBindGroup(W,d)),p.setBindGroup((i!=null?i:[]).length,this._vertexProgram.bindGroup),p.setBindGroup((i!=null?i:[]).length+1,this._fragmentProgram.bindGroup);for(let[d,W]of this._usedVertexBuffers)p.setVertexBuffer(W,d);p.draw(r,s,l,g),p.end()}},ye=class extends q{execute(e){var l,g,i;let{workgroups:t=[1,1],externalBindGroups:r}=e!=null?e:{};if(((l=r==null?void 0:r.length)!=null?l:0)!==this.externalLayoutCount)throw new Error(`External bind group count doesn't match the external bind group layout configuration. Expected ${this.externalLayoutCount}, got: ${(g=r==null?void 0:r.length)!=null?g:0}`);let s=this._runtime.commandEncoder.beginComputePass({label:(i=this.label)!=null?i:""});s.setPipeline(this.pipeline),(r!=null?r:[]).forEach((m,p)=>s.setBindGroup(p,m)),this.programs.forEach((m,p)=>s.setBindGroup((r!=null?r:[]).length+p,m.bindGroup)),s.dispatchWorkgroups(...t),s.end()}};async function ut(n){if(n instanceof GPUDevice)return new z(n);if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let e=await navigator.gpu.requestAdapter(n==null?void 0:n.adapter);if(!e)throw new Error("Could not find a compatible GPU");return new z(await e.requestDevice(n==null?void 0:n.device))}exports.MissingSlotValueError = _chunk7HTWRNOHcjs.f; exports.ProgramBuilder = _; exports.RandomNameRegistry = b; exports.RecursiveDataTypeError = _chunk7HTWRNOHcjs.g; exports.ResolutionError = _chunk7HTWRNOHcjs.e; exports.StrictNameRegistry = X; exports.builtin = _chunk7HTWRNOHcjs.L; exports.createRuntime = ut; exports.deriveVertexFormat = Ge; exports.getBuiltinInfo = _chunk7HTWRNOHcjs.M; exports.getUsedBuiltinsNamed = _chunk7HTWRNOHcjs.N; exports.isDepthTextureType = _chunk7HTWRNOHcjs.m; exports.isExternalTextureType = _chunk7HTWRNOHcjs.o; exports.isPointer = _chunk7HTWRNOHcjs.p; exports.isResolvable = _chunk7HTWRNOHcjs.h; exports.isSamplerType = _chunk7HTWRNOHcjs.k; exports.isSlot = _chunk7HTWRNOHcjs.j; exports.isStorageTextureType = _chunk7HTWRNOHcjs.n; exports.isTypedTextureType = _chunk7HTWRNOHcjs.l; exports.isWgsl = _chunk7HTWRNOHcjs.i; exports.wgsl = it;
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkG6QA55EYcjs = require('./chunk-G6QA55EY.cjs');var _chunkS55XYV7Ucjs = require('./chunk-S55XYV7U.cjs');var _typedbinary = require('typed-binary');function $(e,t){let a=e.buffer,n=e.device;if(a.mapState==="mapped"){let y=a.getMappedRange();e.dataType.write(new (0, _typedbinary.BufferWriter)(y),t);return}let p=_chunkG6QA55EYcjs.a.call(void 0, e.dataType.size,e.dataType.byteAlignment),U=new ArrayBuffer(p);e.dataType.write(new (0, _typedbinary.BufferWriter)(U),t),n.queue.writeBuffer(a,0,U,0,p)}async function V(e){let t=e.buffer,a=e.device;if(t.mapState==="mapped"){let y=t.getMappedRange();return e.dataType.read(new (0, _typedbinary.BufferReader)(y))}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let y=t.getMappedRange(),h=e.dataType.read(new (0, _typedbinary.BufferReader)(y));return t.unmap(),h}let n=a.createBuffer({size:e.dataType.size,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),p=a.createCommandEncoder();p.copyBufferToBuffer(t,0,n,0,e.dataType.size),a.queue.submit([p.finish()]),await a.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,e.dataType.size);let U=e.dataType.read(new (0, _typedbinary.BufferReader)(n.getMappedRange()));return n.unmap(),n.destroy(),U}function f(e,t){return new z(e,t)}var z=class{constructor(t,a){this.buffer=t;this.usage=a}get label(){return this.buffer.label}get allocatable(){return this.buffer}resolve(t){let a=new (0, _chunkS55XYV7Ucjs.c)().$name(this.label);return t.addBinding(this,a),t.resolve(a)}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}};function S(e,t){return new A(e,t)}var A=class{constructor(t,a){this.dataType=t;this.initialOrBuffer=a;_chunkS55XYV7Ucjs.a.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunkS55XYV7Ucjs.a.call(void 0, this,"_device",null);_chunkS55XYV7Ucjs.a.call(void 0, this,"_buffer",null);_chunkS55XYV7Ucjs.a.call(void 0, this,"_usages",{uniform:null,mutable:null,readonly:null,vertex:null});_chunkS55XYV7Ucjs.a.call(void 0, this,"vertexLayout",null);_chunkS55XYV7Ucjs.a.call(void 0, this,"_label");_chunkS55XYV7Ucjs.a.call(void 0, this,"initial");_chunkS55XYV7Ucjs.b.call(void 0, a)?this._buffer=a:this.initial=a}get label(){return this._label}get buffer(){if(!this._device)throw new Error("To use this property, make the buffer unmanaged by passing a GPUDevice to $device");if(!this._buffer&&(this._buffer=this._device.createBuffer({size:this.dataType.size,usage:this.flags,mappedAtCreation:!!this.initial}),this.initial)){let t=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());this.dataType.write(t,this.initial),this._buffer.unmap()}return this._buffer}get device(){if(!this._device)throw new Error("This buffer is managed by TypeGPU and cannot be used directly");return this._device}$name(t){return this._label=t,this}$allowUniform(){return this.$addFlags(GPUBufferUsage.UNIFORM),this._usages.uniform||(this._usages.uniform=f(this,"uniform")),this}$allowReadonly(){return this.$addFlags(GPUBufferUsage.STORAGE),this._usages.readonly||(this._usages.readonly=f(this,"readonly")),this}$allowMutable(){return this.$addFlags(GPUBufferUsage.STORAGE),this._usages.mutable||(this._usages.mutable=f(this,"mutable")),this}$allowVertex(t="vertex"){if(this.$addFlags(GPUBufferUsage.VERTEX),!this.vertexLayout)if(this.dataType instanceof _chunkG6QA55EYcjs.c)this.vertexLayout={arrayStride:this.dataType.size,stepMode:t},this._usages.vertex=f(this,"vertex");else if(this.dataType instanceof _chunkG6QA55EYcjs.l)this.vertexLayout={arrayStride:this.dataType.elementType.size,stepMode:t},this._usages.vertex=f(this,"vertex");else throw new Error("Only simple data types can be used as vertex buffers");if(this.vertexLayout.stepMode!==t)throw new Error("Cannot change step mode of a vertex buffer");return this}$addFlags(t){return this.flags|=t,this}$device(t){return this._device=t,this}toString(){var t;return`buffer:${(t=this._label)!=null?t:"<unnamed>"}`}};function E(e){return e.charAt(0).toUpperCase()+e.slice(1)}function B(e,t){return a=>{if(a._usages[e]===null)throw new Error(`Cannot pass ${a} to as${E(e)} function, as the buffer does not allow ${e} usage. To allow it, use $allow${E(e)} TgpuBuffer method.`);return a._usages[e]}}var H=B("uniform",{uniformAllowed:!0}),J=B("readonly",{readonlyAllowed:!0}),Q=B("mutable",{mutableAllowed:!0}),Z=B("vertex",{vertexAllowed:!0});var F={createBuffer:S,read:V,write:$};var o=e=>Math.sqrt(e.x**2+e.y**2),l=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),d=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),u={length:{vec2f:o,vec2i:o,vec2u:o,vec3f:l,vec3i:l,vec3u:l,vec4f:d,vec4i:d,vec4u:d},add:{vec2f:(e,t)=>_chunkG6QA55EYcjs.n.call(void 0, e.x+t.x,e.y+t.y),vec2i:(e,t)=>_chunkG6QA55EYcjs.o.call(void 0, e.x+t.x,e.y+t.y),vec2u:(e,t)=>_chunkG6QA55EYcjs.p.call(void 0, e.x+t.x,e.y+t.y),vec3f:(e,t)=>_chunkG6QA55EYcjs.q.call(void 0, e.x+t.x,e.y+t.y,e.z+t.z),vec3i:(e,t)=>_chunkG6QA55EYcjs.r.call(void 0, e.x+t.x,e.y+t.y,e.z+t.z),vec3u:(e,t)=>_chunkG6QA55EYcjs.s.call(void 0, e.x+t.x,e.y+t.y,e.z+t.z),vec4f:(e,t)=>_chunkG6QA55EYcjs.t.call(void 0, e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4i:(e,t)=>_chunkG6QA55EYcjs.u.call(void 0, e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4u:(e,t)=>_chunkG6QA55EYcjs.v.call(void 0, e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w)},sub:{vec2f:(e,t)=>_chunkG6QA55EYcjs.n.call(void 0, e.x-t.x,e.y-t.y),vec2i:(e,t)=>_chunkG6QA55EYcjs.o.call(void 0, e.x-t.x,e.y-t.y),vec2u:(e,t)=>_chunkG6QA55EYcjs.p.call(void 0, e.x-t.x,e.y-t.y),vec3f:(e,t)=>_chunkG6QA55EYcjs.q.call(void 0, e.x-t.x,e.y-t.y,e.z-t.z),vec3i:(e,t)=>_chunkG6QA55EYcjs.r.call(void 0, e.x-t.x,e.y-t.y,e.z-t.z),vec3u:(e,t)=>_chunkG6QA55EYcjs.s.call(void 0, e.x-t.x,e.y-t.y,e.z-t.z),vec4f:(e,t)=>_chunkG6QA55EYcjs.t.call(void 0, e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4i:(e,t)=>_chunkG6QA55EYcjs.u.call(void 0, e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4u:(e,t)=>_chunkG6QA55EYcjs.v.call(void 0, e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w)},mul:{vec2f:(e,t)=>_chunkG6QA55EYcjs.n.call(void 0, e*t.x,e*t.y),vec2i:(e,t)=>_chunkG6QA55EYcjs.o.call(void 0, e*t.x,e*t.y),vec2u:(e,t)=>_chunkG6QA55EYcjs.p.call(void 0, e*t.x,e*t.y),vec3f:(e,t)=>_chunkG6QA55EYcjs.q.call(void 0, e*t.x,e*t.y,e*t.z),vec3i:(e,t)=>_chunkG6QA55EYcjs.r.call(void 0, e*t.x,e*t.y,e*t.z),vec3u:(e,t)=>_chunkG6QA55EYcjs.s.call(void 0, e*t.x,e*t.y,e*t.z),vec4f:(e,t)=>_chunkG6QA55EYcjs.t.call(void 0, e*t.x,e*t.y,e*t.z,e*t.w),vec4i:(e,t)=>_chunkG6QA55EYcjs.u.call(void 0, e*t.x,e*t.y,e*t.z,e*t.w),vec4u:(e,t)=>_chunkG6QA55EYcjs.v.call(void 0, e*t.x,e*t.y,e*t.z,e*t.w)},dot:{vec2f:(e,t)=>e.x*t.x+e.y*t.y,vec2i:(e,t)=>e.x*t.x+e.y*t.y,vec2u:(e,t)=>e.x*t.x+e.y*t.y,vec3f:(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,vec3i:(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,vec3u:(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,vec4f:(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,vec4i:(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,vec4u:(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},normalize:{vec2f:e=>{let t=o(e);return _chunkG6QA55EYcjs.n.call(void 0, e.x/t,e.y/t)},vec2i:e=>{let t=o(e);return _chunkG6QA55EYcjs.o.call(void 0, e.x/t,e.y/t)},vec2u:e=>{let t=o(e);return _chunkG6QA55EYcjs.p.call(void 0, e.x/t,e.y/t)},vec3f:e=>{let t=l(e);return _chunkG6QA55EYcjs.q.call(void 0, e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=l(e);return _chunkG6QA55EYcjs.r.call(void 0, e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=l(e);return _chunkG6QA55EYcjs.s.call(void 0, e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=d(e);return _chunkG6QA55EYcjs.t.call(void 0, e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=d(e);return _chunkG6QA55EYcjs.u.call(void 0, e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=d(e);return _chunkG6QA55EYcjs.v.call(void 0, e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>_chunkG6QA55EYcjs.q.call(void 0, e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3i:(e,t)=>_chunkG6QA55EYcjs.r.call(void 0, e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3u:(e,t)=>_chunkG6QA55EYcjs.s.call(void 0, e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)}};var O={add:(e,t)=>u.add[e.kind](e,t),sub:(e,t)=>u.sub[e.kind](e,t),mul:(e,t)=>u.mul[t.kind](e,t),dot:(e,t)=>u.dot[e.kind](e,t),normalize:e=>u.normalize[e.kind](e),cross:(e,t)=>u.cross[e.kind](e,t),fract:e=>e-Math.floor(e),length:e=>u.length[e.kind](e),sin:Math.sin,cos:Math.cos};exports.RecursiveDataTypeError = _chunkG6QA55EYcjs.b; exports.default = F; exports.std = O; exports.tgpu = F;
|
49
2
|
//# sourceMappingURL=index.cjs.map
|