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
An <EffectComposer> with a DepthOfField renders: raea's stand-in WebGL context takes every call
shinyobjectz6684ea7c779d
diff --git a/sdk/r3f/src/input/session.ts b/sdk/r3f/src/input/session.tsindex 20c6e709..84a8e5c1 100644--- a/sdk/r3f/src/input/session.ts+++ b/sdk/r3f/src/input/session.ts@@ -14,11 +14,14 @@ extend(THREE as unknown as Parameters<typeof extend>[0]);export function standInRenderer(): THREE.WebGLRenderer {const noop = () => {};const size = { width: 1, height: 1 };- // a WebGL context that answers what a composer asks as it is made (@react-three/postprocessing, three's own)- const context = {+ // a WebGL context that answers what a composer asks as it is made (@react-three/postprocessing, three's own), and+ // takes every other call as it renders (its depth blit: bindFramebuffer, blitFramebuffer) doing nothing, its+ // constants (READ_FRAMEBUFFER, DEPTH_BUFFER_BIT) 0: raea draws the effect (post.ts)+ const gl = {getContextAttributes: () => ({ alpha: true, depth: true, stencil: false, antialias: false, premultipliedAlpha: true }),getExtension: () => null, getParameter: () => 0, getSupportedExtensions: () => [], isContextLost: () => false,- };+ } as Record<string | symbol, unknown>;+ const context = new Proxy(gl, { get: (t, k) => (k in t ? t[k] : typeof k !== "string" || k === "then" ? undefined : /^[A-Z0-9_]+$/.test(k) ? 0 : /^[a-z]/.test(k) ? noop : undefined) });// a pass an app draws into a render target itself (drei's <ContactShadows>) is done on the CPU (targets.ts)let target: THREE.RenderTarget | null = null;const clear: [number, number, number, number] = [0, 0, 0, 0];diff --git a/sdk/r3f/test/post.test.ts b/sdk/r3f/test/post.test.tsindex 3e11d077..c2d0739c 100644--- a/sdk/r3f/test/post.test.ts+++ b/sdk/r3f/test/post.test.ts@@ -1,9 +1,10 @@// @react-three/postprocessing's effects as raea's (src/input/post.ts, docs/r3f.feature R3F12): pmndrs postprocessing's// own classes, read the way they're found under an <EffectComposer>.import { describe, expect, test } from "bun:test";-import { BloomEffect, ChromaticAberrationEffect, HueSaturationEffect, NoiseEffect, SMAAEffect, ToneMappingEffect, ToneMappingMode, VignetteEffect } from "postprocessing";+import { BloomEffect, ChromaticAberrationEffect, DepthOfFieldEffect, EffectComposer, EffectPass, HueSaturationEffect, NoiseEffect, RenderPass, SMAAEffect, ToneMappingEffect, ToneMappingMode, VignetteEffect } from "postprocessing";import * as THREE from "three";import { postParts } from "../src/input/post";+import { standInRenderer } from "../src/input/session";import { EFFECTS } from "../src/input/kinds";describe("<EffectComposer> → raea's frame effects", () => {@@ -49,3 +50,17 @@ describe("<EffectComposer> → raea's frame effects", () => {expect(effects.filter((k) => !EFFECTS[k])).toEqual([]);});});++describe("<EffectComposer> on raea's stand-in renderer", () => {+ test("a depth of field renders frame after frame: its depth blit is a call that does nothing", () => {+ const gl = standInRenderer();+ const camera = new THREE.PerspectiveCamera();+ const composer = new EffectComposer(gl);+ composer.addPass(new RenderPass(new THREE.Scene(), camera));+ composer.addPass(new EffectPass(camera, new DepthOfFieldEffect(camera, { focusDistance: 0, focalLength: 0.02, bokehScale: 2 })));+ for (let i = 0; i < 3; i++) expect(() => composer.render(1 / 30)).not.toThrow();+ const ctx = gl.getContext() as unknown as Record<string, unknown>;+ expect(ctx.READ_FRAMEBUFFER).toBe(0);+ expect(ctx.then).toBeUndefined();+ });+});