Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webgpu-rendering-context): import webgpu renderer #99

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/Simulation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import vertexShader from '../shaders/vert.glsl';
import fragmentShader from '../shaders/frag.glsl';
import { OutgoingMessage } from '../workers/modelWorkerMessage';

// WebGPU imports
import { default as WebGPU } from 'three/addons/capabilities/WebGPU.js';
import { default as WebGPURenderer } from 'three/addons/renderers/webgpu/WebGPURenderer.js';

class SimulationParams {
// render options
densityLowColour: t.Color = new t.Color('blue');
Expand Down Expand Up @@ -59,6 +63,15 @@ function DiffusionPlane(
props: ThreeElements['mesh'] & Renderable,
): React.ReactElement {
// INITIALISATION

// WebGPU capability test
if ( WebGPU.isAvailable() === true ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CFlowSim\src\components\Simulation.tsx
  68:8   error  Unsafe call of an `any` typed value  @typescript-eslint/no-unsafe-call
  69:11  error  Unsafe assignment of an `any` value  @typescript-eslint/no-unsafe-assignment

line returns these errors in npm run lint

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also pls make sure that you have configured prettier as the formatter.

const webgpuRenderer = new WebGPURenderer( { antialias: true } );
console.log('browser supports webgpu rendering')
console.log('webgpu renderer context', webgpuRenderer);
} else {
console.log('browser does not support webgpu rendering');
}

// reference to the parent mesh
const ref = useRef<t.Mesh>(null!);
Expand Down
12 changes: 12 additions & 0 deletions src/declaration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@ declare module '*.md' {
const html: string;
export default html;
}

declare module 'three/addons/capabilities/WebGPU.js' {
export class WebGPU {
static isAvailable(): boolean;
static getErrorMessage(): HTMLDivElement;
}
}
declare module 'three/addons/renderers/webgpu/WebGPURenderer.js' {
export class WebGPURenderer {
constructor( parameters: map<string, object> );
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"types": [
Expand Down
8 changes: 8 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ export default defineConfig({
rehypePlugins: [rehypeSanitize],
}),
],
optimizeDeps: {
esbuildOptions: {
target: 'esnext',
},
},
build: {
target: 'esnext',
},
});
Loading