Update helpers

This commit is contained in:
Andras Schmelczer 2023-05-21 11:01:31 +01:00
commit a76b515b80
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
4 changed files with 18 additions and 7 deletions

View file

@ -11,7 +11,6 @@ const setIndexAlias = (name: string, index: number, type: any) => {
}
};
/** @internal */
export const applyArrayPlugins = () => {
setIndexAlias('x', 0, Array);
setIndexAlias('y', 1, Array);

View file

@ -0,0 +1,17 @@
export const initializeContext = ({
device,
canvas,
}: {
device: GPUDevice;
canvas: HTMLCanvasElement;
}): GPUCanvasContext => {
const context = canvas.getContext('webgpu') as any as GPUCanvasContext;
context.configure({
device: device,
format: navigator.gpu.getPreferredCanvasFormat(),
alphaMode: 'premultiplied',
});
return context;
};

View file

@ -1,4 +0,0 @@
export const prettyPrint = (o: any): string =>
JSON.stringify(o, (_, v) => (v?.toFixed ? Number(v.toFixed(3)) : v), ' ')
.replace(/("|,|{|^\n)/g, '')
.replace(/(\W*}\n?)+/g, '\n\n');

View file

@ -1,6 +1,5 @@
export abstract class Random {
// https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript, Mulberry32
export abstract class Random {
private static _seed = 42;
public static set seed(value: number) {