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
R3F22: test/targets.test.tsx: a MeshBasicNodeMaterial reading a target drawn in useFrame names the camera's image, read as sRGB, its samples turned over in v (texture.ts flipsY, targets.ts onGpu in tsl.ts)
shinyobjectz47a93b740ae4
diff --git a/sdk/r3f/test/targets.test.tsx b/sdk/r3f/test/targets.test.tsxindex 153be5da..5cd84b08 100644--- a/sdk/r3f/test/targets.test.tsx+++ b/sdk/r3f/test/targets.test.tsx@@ -6,6 +6,10 @@ import { createPortal, useFrame } from "@react-three/fiber";import { useMemo, type ReactNode } from "react";import * as THREE from "three";import { GPUComputationRenderer } from "three/examples/jsm/misc/GPUComputationRenderer.js";+import { MeshBasicNodeMaterial } from "three/webgpu";+import * as TSLTyped from "three/tsl";+// untyped: @types/three's chained TSL types make tsc take minutes and gigabytes+const { texture, uv } = TSLTyped as unknown as Record<string, any>;import { convert } from "../src/input/scene";import { end, stepTo } from "../src/input/session";import type { Part } from "../src/parts";@@ -143,6 +147,27 @@ describe("a render into a target, drawn by raea's engine", () => {expect(later[0].props.name).not.toBe(first[0].props.name);});+ test("is read by a TSL node material as its camera draws it: the image itself, v turned over, as sRGB", () => {+ function Read() {+ const t = useMemo(() => new THREE.WebGLRenderTarget(32, 32), []);+ const scene = useMemo(() => Object.assign(new THREE.Scene(), { background: new THREE.Color("#336699") }), []);+ const cam = useMemo(() => new THREE.PerspectiveCamera(), []);+ const mat = useMemo(() => Object.assign(new MeshBasicNodeMaterial(), { colorNode: texture(t.texture, uv()) }), [t]);+ useFrame(({ gl }) => {+ gl.setRenderTarget(t);+ gl.render(scene, cam);+ gl.setRenderTarget(null);+ });+ return <mesh name="screen" material={mat}><planeGeometry args={[2, 2]} /></mesh>;+ }+ const out = partsOf(() => <Read />);+ const target = out.find((p) => typeof p.props.target === "string")!.props.target as string;+ const shader = flat(out.find((p) => p.type === "Mesh" && String(p.props.name).includes("screen"))!.children ?? []).find((c) => c.props.wgsl)!;+ const textures = Object.values(shader.props.textures as Record<string, { src: string; colorSpace: string }>);+ expect(textures).toEqual([{ src: target, colorSpace: "srgb" }]);+ expect((shader.props.wgsl as { fragment: string }).fragment).toMatch(/textureSample\( tex_\w+, samp_\w+, tsl_flip_v\(/);+ });+test("is read by a ShaderMaterial as its camera draws it: the image itself, v turned over, never a raw copy", () => {// a raw copy ({colorSpace: "linear"}: three-shader's linear::raw) is taken once, before any pass has drawnfunction Read() {