Skip to content

Commit

Permalink
Apply suggestions and npm run fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetoguzderin committed Mar 28, 2024
1 parent e0beefb commit 8c55151
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions sample/volumeRenderingTexture3D/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mat4, vec3 } from 'wgpu-matrix';
import { mat4 } from 'wgpu-matrix';
import { GUI } from 'dat.gui';
import volumeWGSL from './volume.wgsl';

Expand Down Expand Up @@ -143,9 +143,7 @@ const uniformBindGroup = device.createBindGroup({
},
{
binding: 2,
resource: volumeTexture.createView({
dimension: '3d',
}),
resource: volumeTexture.createView(),
},
],
});
Expand All @@ -166,13 +164,13 @@ let rotation = 0;

function getInverseModelViewProjectionMatrix(deltaTime: number) {
const viewMatrix = mat4.identity();
mat4.translate(viewMatrix, vec3.fromValues(0, 0, -4), viewMatrix);
mat4.translate(viewMatrix, [0, 0, -4], viewMatrix);
if (params.rotateCamera) {
rotation += deltaTime;
}
mat4.rotate(
viewMatrix,
vec3.fromValues(Math.sin(rotation), Math.cos(rotation), 0),
[Math.sin(rotation), Math.cos(rotation), 0],
1,
viewMatrix
);
Expand All @@ -184,9 +182,7 @@ function getInverseModelViewProjectionMatrix(deltaTime: number) {
params.near,
params.far
);
const modelViewProjectionMatrix = mat4.create();

mat4.multiply(projectionMatrix, viewMatrix, modelViewProjectionMatrix);
const modelViewProjectionMatrix = mat4.multiply(projectionMatrix, viewMatrix);

return mat4.invert(modelViewProjectionMatrix) as Float32Array;
}
Expand All @@ -200,13 +196,7 @@ function frame() {

const inverseModelViewProjection =
getInverseModelViewProjectionMatrix(deltaTime);
device.queue.writeBuffer(
uniformBuffer,
0,
inverseModelViewProjection.buffer,
inverseModelViewProjection.byteOffset,
inverseModelViewProjection.byteLength
);
device.queue.writeBuffer(uniformBuffer, 0, inverseModelViewProjection);
renderPassDescriptor.colorAttachments[0].view = view;
renderPassDescriptor.colorAttachments[0].resolveTarget = context
.getCurrentTexture()
Expand Down

0 comments on commit 8c55151

Please sign in to comment.