Skip to content

Commit

Permalink
fix(eslint): fix the errors after merging main
Browse files Browse the repository at this point in the history
Signed-off-by: Bill ZHANG <[email protected]>
  • Loading branch information
Lutra-Fs committed Sep 14, 2023
1 parent f463a37 commit 9ee8226
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/Simulation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function DiffusionPlane(
// INITIALISATION

// WebGPU capability test
if (WebGPU.isAvailable() === true) {
if (WebGPU.isAvailable()) {
const webgpuRenderer = new WebGPURenderer({ antialias: true });
console.log('browser supports webgpu rendering');
console.log('webgpu renderer context', webgpuRenderer);
Expand Down
1 change: 1 addition & 0 deletions src/services/model/ONNXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export default class ONNXService implements ModelService {
private roundFloat(value: number, decimal = 4): number {
return Math.round(value * 10 ** decimal) / 10 ** decimal;
}

getInputTensor(): Float32Array {
return this.matrixArray;
}
Expand Down
4 changes: 4 additions & 0 deletions src/services/model/TfjsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,14 @@ export class TfjsService implements ModelService {
}
}, 1000);
}

getInput(): tf.Tensor<tf.Rank> {
const pressure = this.pressure.toTensor();
const input = tf.concat([this.density, this.velocity, pressure], 3);
pressure.dispose();
return input;
}

private iterate(): void {
if (this.isPaused) {
return;
Expand Down Expand Up @@ -204,12 +206,14 @@ export class TfjsService implements ModelService {
4,
);
}

getInputTensor(): Float32Array {
const input = this.getInput();
const data = input.dataSync();
input.dispose();
return data as Float32Array;
}

dispose(): void {
this.density.dispose();
this.velocity.dispose();
Expand Down
4 changes: 2 additions & 2 deletions src/services/model/modelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function createModelService(
const modelType = modelPath.split('.').pop();
switch (modelType) {
case 'json':
return TfjsService.createService(
return await TfjsService.createService(
modelPath,
gridSize,
batchSize,
Expand All @@ -34,7 +34,7 @@ export async function createModelService(
fpsLimit,
);
case 'onnx':
return ONNXService.createService(
return await ONNXService.createService(
modelPath,
gridSize,
batchSize,
Expand Down
6 changes: 3 additions & 3 deletions src/workers/modelWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { type Vector2 } from 'three';
import {
ModelService,
type ModelService,
createModelService,
} from '../services/model/modelService';
import { type IncomingMessage } from './modelWorkerMessage';
Expand Down Expand Up @@ -94,8 +94,8 @@ async function initModelService(
const modelService = await createModelService(modelPath, [64, 64], 1);
modelService.bindOutput(outputCallback);
// fetch the data
const data = (await fetch(dataPath).then((res) =>
res.json(),
const data = (await fetch(dataPath).then(async (res) =>
await res.json(),
)) as number[][][][];
modelService.loadDataArray(data);
return modelService;
Expand Down

0 comments on commit 9ee8226

Please sign in to comment.