diff --git a/sdk/r3f/src/input/kinds.ts b/sdk/r3f/src/input/kinds.ts index 0ba6fb03..4f494dd4 100644 --- a/sdk/r3f/src/input/kinds.ts +++ b/sdk/r3f/src/input/kinds.ts @@ -64,7 +64,7 @@ export const CLASSES: Record [k, { status: "drawn" as const, raea: "its classic material, or its graph as WGSL (ThreeShaderMaterial)", note: "a graph needing more than 4 textures, 254 vec4s of uniforms (uniformArrays included) or 4 attributes of the mesh's own, a storage buffer or a render target is named and drawn flat" }])), + ...Object.fromEntries(["NodeMaterial", "MeshBasicNodeMaterial", "MeshLambertNodeMaterial", "MeshPhongNodeMaterial", "MeshStandardNodeMaterial", "MeshPhysicalNodeMaterial", "MeshSSSNodeMaterial", "MeshToonNodeMaterial", "MeshMatcapNodeMaterial", "MeshNormalNodeMaterial", "VolumeNodeMaterial"].map((k) => [k, { status: "drawn" as const, raea: "its classic material, or its graph as WGSL (ThreeShaderMaterial): a lit one's surface (colour, normal, roughness, metalness, emission, opacity, positionNode) lit by Bevy's lights and shadows", note: "a graph needing more than 4 textures, 254 vec4s of uniforms (uniformArrays included) or 4 attributes of the mesh's own, a storage buffer or a render target is named and drawn flat" }])), ...Object.fromEntries(["LineBasicNodeMaterial", "LineDashedNodeMaterial", "Line2NodeMaterial", "PointsNodeMaterial", "SpriteNodeMaterial", "ShadowNodeMaterial"].map((k) => [k, { status: "near" as const, raea: "its classic material (lines, points, a sprite, a shadow catcher)", note: "a graph of its own on lines, points or a sprite is drawn flat" }])), // helpers: lines (and a plane's mesh), drawn as any lines are ...Object.fromEntries(["ArrowHelper", "AxesHelper", "Box3Helper", "BoxHelper", "CameraHelper", "DirectionalLightHelper", "GridHelper", "HemisphereLightHelper", "PlaneHelper", "PointLightHelper", "PolarGridHelper", "SkeletonHelper", "SpotLightHelper"].map((k) => [k, { status: "drawn" as const, raea: "its lines as Gizmo lines (an arrow's head and a plane's face as meshes)" }])), diff --git a/sdk/r3f/test/parity/tsl.tsx b/sdk/r3f/test/parity/tsl.tsx new file mode 100644 index 00000000..1a5e2d2a --- /dev/null +++ b/sdk/r3f/test/parity/tsl.tsx @@ -0,0 +1,53 @@ +// The TSL parity cases (docs/r3f.feature R3F21, R3F22): node materials three/webgpu draws in Chrome and raea's engine +// draws from three's own WGSL (src/input/tsl.ts, tsl-lit.ts). A graph's motion comes from a uniform R3F's clock sets in +// useFrame, never TSL's `time` (three's renderer counts that from performance.now(), so Chrome's frame would differ). +import { useFrame } from "@react-three/fiber"; +import { MeshStandardNodeMaterial } from "three/webgpu"; +import * as TSLTyped from "three/tsl"; +import type { InputCase } from "./fixtures"; + +// untyped: @types/three's chained TSL types make tsc take minutes and gigabytes +const { color, mix, mx_noise_float, normalLocal, positionLocal, uniform } = TSLTyped as unknown as Record any> & { normalLocal: any; positionLocal: any }; + +/** three's WebGPURenderer for a TSL scene: its WebGL 2 backend (headless Chrome may have no WebGPU) */ +async function nodeRenderer(props: object) { + const { WebGPURenderer } = await import("three/webgpu"); + const r = new WebGPURenderer({ ...props, forceWebGL: true, antialias: true }); + await r.init(); + return r; +} + +// the noise blob people post: an icosahedron its positionNode pushes out along the normal by 3D noise, coloured by the +// same noise, lit by the scene's lights (a MeshStandardNodeMaterial with nodes of its own: R3F21) +const blob = (() => { + const t = uniform(0); + const m = new MeshStandardNodeMaterial({ roughness: 0.4, metalness: 0.1 }); + const n = mx_noise_float(positionLocal.mul(1.6).add(t.mul(0.5))); + m.positionNode = positionLocal.add(normalLocal.mul(n.mul(0.3))); + m.colorNode = mix(color("#ff7744"), color("#3355ff"), n.mul(0.5).add(0.5)); + return { m, t }; +})(); + +function Blob() { + useFrame(({ clock }) => void (blob.t.value = clock.elapsedTime)); + return ( + + + + ); +} + +export const TSL_INPUTS: Record = { + "tsl-lit": { + canvas: { camera: { position: [0, 0.4, 4], fov: 45 }, gl: nodeRenderer }, + frame: 12, + scene: () => ( + <> + + + + + + ), + }, +};