Refactor
This commit is contained in:
parent
de7fcc15d0
commit
9e582110ea
27 changed files with 248 additions and 123 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import { CommonParameters } from '../common-parameters';
|
||||
import { BrushSettings } from './brush-settings';
|
||||
import shader from './brush.wgsl';
|
||||
|
||||
import { vec2 } from 'gl-matrix';
|
||||
|
||||
export class BrushPipeline {
|
||||
private static readonly UNIFORM_COUNT = 2;
|
||||
private static readonly UNIFORM_COUNT = 4;
|
||||
private static readonly MAX_LINE_COUNT = 100;
|
||||
private static readonly VERTICES_PER_LINE_SEGMENT = 6;
|
||||
|
||||
|
|
@ -85,8 +87,16 @@ export class BrushPipeline {
|
|||
this.linePoints.length = 0;
|
||||
}
|
||||
|
||||
public setParameters({ width, height }: { width: number; height: number }) {
|
||||
this.device.queue.writeBuffer(this.uniforms, 0, new Float32Array([width, height]));
|
||||
public setParameters({
|
||||
canvasSize,
|
||||
deltaTime,
|
||||
time,
|
||||
}: CommonParameters & BrushSettings) {
|
||||
this.device.queue.writeBuffer(
|
||||
this.uniforms,
|
||||
0,
|
||||
new Float32Array([canvasSize[0], canvasSize[1], deltaTime, time])
|
||||
);
|
||||
|
||||
this.device.queue.writeBuffer(
|
||||
this.vertexBuffer,
|
||||
|
|
|
|||
1
src/pipelines/brush/brush-settings.ts
Normal file
1
src/pipelines/brush/brush-settings.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export interface BrushSettings {}
|
||||
|
|
@ -12,7 +12,9 @@ fn vertex(
|
|||
}
|
||||
|
||||
struct Settings {
|
||||
size : vec2<f32>
|
||||
size : vec2<f32>,
|
||||
deltaTime : f32,
|
||||
time : f32
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> settings : Settings;
|
||||
|
|
|
|||
Loading…
Reference in a new issue