Skip to content

Commit

Permalink
types for webgpudemo
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jan 20, 2025
1 parent 7711011 commit 009c97d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "example",
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
19 changes: 14 additions & 5 deletions example/src/demos/WebGPU.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { useState, useMemo } from 'react'
// @ts-ignore
import * as THREE from 'three/webgpu'
// @ts-ignore
import { mix, positionLocal, sin, time, vec3, uniform, color } from 'three/tsl'
import { Canvas, extend, useFrame } from '@react-three/fiber'
import { ThreeElement, Canvas, extend, useFrame, ConstructorRepresentation } from '@react-three/fiber'
import { easing } from 'maath'

type ThreeExports = typeof THREE
type ThreeElementsImpl = {
[K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation
? ThreeElement<ThreeExports[K]>
: never
}

declare module '@react-three/fiber' {
interface ThreeElements extends ThreeElementsImpl {}
}

export default function App() {
return (
<Canvas
gl={(props) => {
extend(THREE)
const renderer = new THREE.WebGPURenderer(props)
extend(THREE as any)
const renderer = new THREE.WebGPURenderer(props as any)
return renderer.init().then(() => renderer)
}}>
<ambientLight intensity={Math.PI} />
Expand Down
4 changes: 2 additions & 2 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"module": "nodenext",
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand Down

0 comments on commit 009c97d

Please sign in to comment.