Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
R3F20: test/parity in-instanced (2,000 copies moved and recoloured each frame, lit by a sun) and speed.tsx (the 2k and 20k bars' compositions, with and without colours)
shinyobjectz12f0eb09a0d1
diff --git a/sdk/r3f/test/parity/fixtures.tsx b/sdk/r3f/test/parity/fixtures.tsxindex cac7b265..f99b3bd9 100644--- a/sdk/r3f/test/parity/fixtures.tsx+++ b/sdk/r3f/test/parity/fixtures.tsx@@ -50,6 +50,34 @@ const instanced = (() => {return m;})();+// R3F20: 2,000 copies moved and recoloured every frame (a wave over a grid), lit by a sun+function Wave({ n }: { n: number }) {+ const ref = useRef<THREE.InstancedMesh>(null!);+ const o = useMemo(() => new THREE.Object3D(), []);+ const c = useMemo(() => new THREE.Color(), []);+ const side = Math.ceil(Math.sqrt(n));+ useFrame(({ clock }) => {+ const t = clock.elapsedTime;+ for (let i = 0; i < n; i++) {+ const x = (i % side) - side / 2, z = Math.floor(i / side) - side / 2;+ const y = Math.sin(x * 0.3 + t * 2) * Math.cos(z * 0.3) * 0.4;+ o.position.set(x * 0.12, y, z * 0.12);+ o.rotation.set(0, x * 0.1 + t, 0);+ o.updateMatrix();+ ref.current.setMatrixAt(i, o.matrix);+ ref.current.setColorAt(i, c.setHSL((x / side + z / side * 0.5 + t * 0.1) % 1, 0.7, 0.45 + y * 0.4));+ }+ ref.current.instanceMatrix.needsUpdate = true;+ ref.current.instanceColor!.needsUpdate = true;+ });+ return (+ <instancedMesh ref={ref} args={[undefined as never, undefined as never, n]}>+ <boxGeometry args={[0.08, 0.08, 0.08]} />+ <meshStandardMaterial color="#ffffff" roughness={0.5} />+ </instancedMesh>+ );+}+export interface InputCase {canvas: Record<string, unknown>;scene: () => ReactNode;@@ -87,6 +115,18 @@ const probe = (() => {const clipPlane = new THREE.Plane(new THREE.Vector3(-0.3, -1, 0.2).normalize(), 0.95);export const INPUTS: Record<string, InputCase> = {+ instanced: {+ canvas: { camera: { position: [0, 3.2, 4.2], fov: 45 } },+ frame: 12,+ scene: () => (+ <>+ <color attach="background" args={["#0a0a12"]} />+ <ambientLight intensity={0.4} />+ <directionalLight position={[3, 6, 2]} intensity={2} />+ <Wave n={2000} />+ </>+ ),+ },basic: {canvas: { camera: { position: [3, 2.5, 4], fov: 45 }, shadows: true },frame: 24,diff --git a/sdk/r3f/test/parity/speed.tsx b/sdk/r3f/test/parity/speed.tsxnew file mode 100644index 00000000..a72498c8--- /dev/null+++ b/sdk/r3f/test/parity/speed.tsx@@ -0,0 +1,55 @@+// R3F20's speed bars (docs/r3f.feature): an InstancedMesh of 2,000 and 20,000 copies moved every frame, 48 frames at+// 640x360, as the 11-15 audit drew them on 0.1.4 (1,220 ms a frame at 20,000, 94 at 2,000). `raea render speed.tsx+// --composition inst-20k-48f -o out.mp4` prints the ms a frame; the bars are 100 and 40. The -tint compositions colour+// every copy every frame too.+import { useMemo, useRef } from "react";+import { Composition, registerRoot } from "raea";+import { R3F } from "raea/r3f";+import { useFrame } from "@react-three/fiber";+import * as THREE from "three";+import { SIZE } from "./fixtures";++function Field({ n, tint }: { n: number; tint: boolean }) {+ const ref = useRef<THREE.InstancedMesh>(null!);+ const o = useMemo(() => new THREE.Object3D(), []);+ const c = useMemo(() => new THREE.Color(), []);+ const side = Math.ceil(Math.sqrt(n));+ useFrame(({ clock }) => {+ const t = clock.elapsedTime;+ for (let i = 0; i < n; i++) {+ const x = (i % side) - side / 2, z = Math.floor(i / side) - side / 2;+ o.position.set(x * 0.12, Math.sin(x * 0.3 + t * 2) * Math.cos(z * 0.3) * 0.4, z * 0.12);+ o.updateMatrix();+ ref.current.setMatrixAt(i, o.matrix);+ if (tint) ref.current.setColorAt(i, c.setHSL((x / side + t * 0.1) % 1, 0.7, 0.5));+ }+ ref.current.instanceMatrix.needsUpdate = true;+ if (tint) ref.current.instanceColor!.needsUpdate = true;+ });+ return (+ <>+ <color attach="background" args={["#0a0a12"]} />+ <ambientLight intensity={0.3} />+ <directionalLight position={[3, 5, 2]} intensity={2.5} />+ <instancedMesh ref={ref} args={[undefined as never, undefined as never, n]}>+ <boxGeometry args={[0.08, 0.08, 0.08]} />+ <meshStandardMaterial color="#66ccff" />+ </instancedMesh>+ </>+ );+}++const CASES: Record<string, { n: number; tint: boolean; camera: [number, number, number] }> = {+ "inst-2k-48f": { n: 2000, tint: false, camera: [0, 4, 6] },+ "inst-20k-48f": { n: 20000, tint: false, camera: [0, 8, 12] },+ "inst-2k-tint-48f": { n: 2000, tint: true, camera: [0, 4, 6] },+ "inst-20k-tint-48f": { n: 20000, tint: true, camera: [0, 8, 12] },+};++registerRoot(() => (+ <>+ {Object.entries(CASES).map(([id, k]) => (+ <Composition key={id} id={id} component={() => <R3F camera={{ position: k.camera, fov: 45 }}><Field n={k.n} tint={k.tint} /></R3F>} width={SIZE.width} height={SIZE.height} fps={SIZE.fps} durationInFrames={48} />+ ))}+ </>+));diff --git a/sdk/r3f/tools/parity.sh b/sdk/r3f/tools/parity.shindex 0d6fd3ca..a4778fee 100755--- a/sdk/r3f/tools/parity.sh+++ b/sdk/r3f/tools/parity.sh@@ -9,7 +9,7 @@ OUT=${1:-$(mktemp -d)}URL=${R3F_PARITY_URL:-serve}[ -f wasm/raea_shape_web.js ] || tools/shape-wasm.shMIN=${MIN:-0.92}-CASES=(in-basic:24 in-lights:0 in-things:0 in-catch:0 in-lettra:12 in-lettrafx:12 in-shader:12 in-post:0 in-drei:12 in-approx:0 in-glass:0 in-sky:0 out-basic:24 out-tony:24 out-lights:0 out-bloom:0 out-grade:0 out-lens:0 out-catch:0 out-entities:10 src-basic:24 src-tony:24 src-lights:0 src-bloom:0 src-grade:0 src-lens:0 src-catch:0 src-entities:10)+CASES=(in-basic:24 in-instanced:12 in-lights:0 in-things:0 in-catch:0 in-lettra:12 in-lettrafx:12 in-shader:12 in-post:0 in-drei:12 in-approx:0 in-glass:0 in-sky:0 out-basic:24 out-tony:24 out-lights:0 out-bloom:0 out-grade:0 out-lens:0 out-catch:0 out-entities:10 src-basic:24 src-tony:24 src-lights:0 src-bloom:0 src-grade:0 src-lens:0 src-catch:0 src-entities:10)# R3F_CASES="in-sky:0 in-shader:12": just those (a lane checking its own cases)# the TSL cases (test/parity/tsl.tsx): a lit node material (R3F21)CASES+=(in-tsl-lit:12)