/3dcodeverse:3d-lang-scene-threejsfrom 3dcodeverse
Provides the module structure, conventions, and constraints for building three.js scenes in a harnessed headless Chrome environment: ESM modules, Y-up metre frame, scene graph, cameras, env, zones, assets, shaders, and the 3dcode build loop.
Ships in 3dcodeverse. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You write RAW ESM modules: import * as THREE from 'three', three/addons/*, your own
relative files and the harness-owned src/lib/*.js — nothing else. The build owns the
renderer, the render loop and the export; you build the scene graph and the cameras.
src/scene.js export async function createScene({ THREE, renderer, loaders }) → { scene, cameras, update(t, dt) }
src/env.js export function heightAt(x, z); export function buildEnv(ctx) → { update(t, dt) }; export const SUN_AZIMUTH_DEG
src/zones/<snake>.js export function build(ctx) → THREE.Group (ctx = { THREE, scene, renderer, loaders, heightAt, env, assets })
src/assets/<snake>.js export function build<Asset>(THREE, opts = {}) → THREE.Group (procedural; lowest point on y = 0)
src/shaders/<snake>.js export function make<Name>Material(THREE, opts = {}) → ShaderMaterial | patched material
src/lib/*.js HARNESS-OWNED effect library: import and call, NEVER read — the project's creation (`validate-plan`'s first call or `init`) printed every export with its parameters and references/effects-catalog.md says what each is for; edits are reverted
public/assets/<snake>.glb optional Blender-built heroes; scene.js preloads each into ctx.assets['<snake>']
The build serves the workspace over http (public/assets/ at /assets/), imports
src/scene.js in headless Chrome with the real THREE, a configured WebGLRenderer and
loaders = { gltf, texture, cube, manager }, awaits createScene, validates the return
value, renders every camera at t = 0 and t = 1.5 s (calling update) and probes (tris, draw
calls, console/shader errors, camera checks, exposure, content, the frame difference). The
library's surface is the index printed when the project was created plus the catalog: open a src/lib file only for
ONE signature the index lacks, and read only that function's lines — never a lib file whole. The
plan's bounds are what the census and placement gate measure against; the world a camera
sees extends past them as far as the brief needs. references/interface.md has the wiring
of scene.js and the env module's shape.
scene: a THREE.Scene; scene.fog and scene.background set (unset = no_fog /
no_background, ERROR); scene.environment an environment texture (metals and glass render
near black without one). Whatever a camera sees ends in something the brief justifies.group.userData.c3d_zone = group.name before scene.add — the
placement gate and the judge find zones by it.cameras: every camera the plan lists (its list decides how many), as PLAIN objects
{ name, position: [x, y, z], lookAt: [x, y, z], fov } (the build makes the
PerspectiveCameras: aspect 16/9, near 0.1, far from the bounds). PascalCase names from the
plan; cameras[0] is the establishing view (≥ 20 % content; others ≥ 10 %, content_small)
and need not contain the whole bounds. The overview rig (scene-views without authored
cameras) is a fallback, not your picture: a scene judged only on the rig is a scene you did
not frame. Eye ≥ 0.3 m above the ground under it (camera_low WARN; camera_high
above 80 m), ≥ 0.5 m from every surface and not inside geometry (camera_in_geometry, ERROR,
cap 0.50), at most 5 of its 9 sight rays ending within 1.5 m (camera_blocked, cap 0.50), the
line of sight to lookAt not cut in its first half; below the terrain is camera_underground
(cap 0.50) — compute y from heightAt(x, z), never guess.update(t, dt): cheap (no allocations, traversals or material creation — cache lists at
build time and hoist scratch objects such as new Vector3 / getSize to module scope) and
deterministic (same t → same frame). It fans out to env.update and every
zone's group.userData.update; tickEnv, userData.tick and build<Zone>(ctx) are never
called — a hook nobody calls stands still, and calling a missing hook throws.src/env.js: heightAt(x, z) is the surface every zone seats on — deterministic, cheap,
0 for a flat floor; every walkable surface (a path, a deck) is part of it, and it must agree
with the ground mesh. SUN_AZIMUTH_DEG is a plain numeric export const (read by regex to
put the overview rig on the sun side; omitted, the rig guesses 45°). Anything else it exports is a convention between it
and the zones.Only three, three/addons/*, relative files and src/lib/*.js resolve; no CDN, no other
package, no three/webgpu / three/tsl. Shader text: .vert / .frag / .glsl files under
src/shaders/, loaded in async createScene with
new THREE.FileLoader(loaders.manager).loadAsync(new URL('./shaders/x.frag', import.meta.url).href)
— no bundler ?raw, no #include of your own files (Three's #include <chunk> is its
built-ins only); never load or compile during update. Forbidden: document.* / window.*
except window.innerWidth and document.createElement('canvas') for a procedural texture;
network, arbitrary fetch / XHR; Math.random() (mulberry32(seed) from lib/noise.js);
Date.now() / performance.now() (use t); requestAnimationFrame; creating a renderer or
changing its settings; environment sniffing; EffectComposer (nothing reads one). Textures:
procedural (incl. DataTextures) or loaders.texture for files present in the workspace.
3dcode check-placement; runs on every build): each direct child of a zone
group is ONE placed object; from its lowest vertices the probe looks down for the nearest
surface and up for one passing through it. Gap under the foot > 0.05 m outdoors / 0.02 m
indoors = floating (ERROR at 0.08 m, or more than two floaters); buried > 0.10 m = sunken
(ERROR at 0.20 m and > 20 % of the height; buried, slope-following and water-level feet are
exempt); a bbox touching nothing = unsupported; two boxes sharing > 10 % of the smaller =
interpenetration (ERROR at 35 %). A Group of several props is ONE box, their union, and
every prop inside reads as interpenetrating it: one placed thing = one direct child; many of
one thing = one InstancedMesh (a scattered instance inside a placed thing is that thing's
interpenetration). obj.userData.placement = 'free' for things meant to hang (WARN when
25 % are tagged, ERROR past 50 %). Four or more foot columns with at most one touching and a gap > 0.05 m is
cantilevered(WARN). A placed asset is measured against the plan'sapprox_size_m: WARN beyond 2.5 × (or under 1 / 2.5), ERROR beyond 4 × — never re-scale to fit or stretch a clone; a chimney or cable that must reach further is a separate object. The judge'swrong_scale(cap 0.75) is perceptual, on top of that gate.
out_of_bounds (WARN; scenery past them is never reported); a zone group missing or
empty zone_empty; a planned asset not placed missing_content.world_edge, WARN); fog far ≥ 2 × the plan span, or for FogExp2
1 / density ≥ span / 1.5 (fog_short); ≥ 8 same-size copies evenly on a ring is
stamped_ring.3dcode scene-views, per authored camera): mean luminance < 0.12 or > 35 %
near-black pixels = dark_frame (unless luminance std ≥ 0.12 with ≤ 35 % near-black: low-key
but lit); > 20 % blown = blown_frame; > 85 % of the pixels in one band = flat_frame
(ERROR above 92 %); plus the camera checks and content_small above. Exposure is gated
before anything is judged: a frame that fails scores nothing for what is in it. Non-solid
cards near a camera read as geometry to the raycast — mesh.raycast = () => {};.no_motion (ERROR) and the judge's nothing_moves. Sub-centimetre sway is
invisible at 1024 × 576: foliage ±0.10–0.20 rad, particles ≥ 0.6 m per 1.5 s, water a bob
≥ 0.04 m with a scrolling uv/normal have passed.hero_unseen): a public/assets/*.glb covering < 0.5 % of the frame in EVERY
camera is an ERROR; < 2 % in the camera the plan names for it a WARN. A hero is visible only
if a zone clones ctx.assets['<snake>'] (its pivot is at its base; clips play by themselves;
clone.userData.clipOffset = <s> de-phases a copy).3dcode scene-probe): WARN above 5 000 draw calls, ERROR above 15 000;
3 000 000 unique triangles. InstancedMesh and merged static geometry are the cheap repeats;
practicals are allowed, but a shadow-casting light per practical is the usual blow-out.3dcode shader-probe compiles a material before it renders black.FileLoader / loaders.* / await: shader text is loaded in
createScene and passed in through opts); one instance ≤ 15 000 triangles, lowest point
y = 0, footprint centred, size the plan's (ERROR beyond 2.5 × or under 0.4 × on any axis, and
on a single-box blockout); every sub-shape overlaps a neighbour by ≥ 2 mm. Zones place the
Group by its ORIGIN, so an off-origin footprint misplaces every copy. Set
group.userData.size = [w, h, d]; optional group.userData.update = (t, dt) => {} which the
placing zone caches and calls. opts.seed / opts.variant vary details deterministically;
variant changes the SILHOUETTE, and opts.hue / opts.seed vary the colour so many copies
are not one colour.Zones are Groups named PascalCase (plan names); assets PascalCase; every animated object has a
stable .name; mat.name = 'Water' on ShaderMaterials; the ground mesh Ground; backdrop
geometry beyond the content Sky… (classified as sky, so it does not inflate the content box);
an interior's lid meshes Ceiling… / RoomShell… (the overview rig lifts them).
AmbientLight, a hemisphere with no key) turns a lit night into a grey wash: add light where
the brief's sources are, give dark materials a low but non-zero albedo (albedos in 0.02–0.8
linear; ACES at exposure 1.0). Shade may stay dark but must carry colour.brief_fidelity, lighting_atmosphere,
flat_ground, diorama_look): a default sky over default green ground is unfinished.
Distant forms pre-tinted toward the fog render BRIGHTER than the terrain and read as cardboard
(placeholder_material); natural colour, darkened, left to the fog, reads as haze. Fog
gives the aerial perspective thin_atmosphere looks for — kept subtle, or the frame reads
milky (blown_frac).interior: true) must read enclosed from every camera — walls and a ceiling
exist in every frame, lit from the sources the brief names (a closed room with no openings and
no practicals renders black). roomShell in lib/environment.js is one option. Env cuts
windows and doors as openings; zones put glazing and door leaves IN the opening and wall
fixtures flush against the inner face, and never build walls or a roof.castShadow on the light AND the meshes, receiveShadow on what they fall on; a
shadow texel larger than ~0.05 m over the content reads as jagged (judged) — sunRig({ bounds })
with the CONTENT radius fits frustum, map size and bias; a hand-set sun.shadow.* must meet
the same texel size.scene.userData.grade is set): author practicals at peak 1.5–4, not 20;
material.userData.bloom = false | true | <colour> opts a material in or out.fog: false, side: THREE.BackSide, depthWrite: false (and the
tonemap / colorspace chunks makeShaderMaterial adds) or it renders black or fogged.
mergeGeometries returns null on mismatched attributes. Inside a shoreline the terrain
lies below the water level or the shore z-fights.PointsMaterial
squares, spheres or polygon sparks are hard_edged_particles.blender_glb hero is built in its own workspace (track static_object, language
blender) and its artifacts/object.glb copied to public/assets/<snake>.glb.write every module → 3dcode check (build, shader preflight, placement rows with the metres to
move each floater / sunken / overlapping thing, asset modules, census) → fix each ERROR →
3dcode check again until no ERROR → 3dcode judge. Exposure, camera and motion are measured
at the judge (scene_frames) and come back in score's list with the numbers; 3dcode scene-views is the refine round's one look. A module that throws takes the whole frame black;
a zone that throws is dropped and scores nothing — never wrap it in try/catch to hide it. A
simple scene that is seated, lit and legible beats an elaborate one that floats in the dark.
The round's hand-over, the one look at renders per refine round and the stop rules are the 3dcodeverse skill's ## The loop.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub gaoypeng/3dcodeverse --plugin 3dcodeverse29 skills in this plugin
/3dcodeverseUse for ANY request to make, measure, judge or improve a 3D thing in code: a model, object or prop, a mechanism or robot with joints, a scene or environment, a shader or OpenGL effect — in Blender bpy, CadQuery, Three.js, URDF, GLSL or moderngl. This is 3D coding with the 3dcodeverse plugin: raw executable 3D code that the 3dcode instruments build, measure, render, gate and score. First step, all in ONE read: this file, skills/3d-lang-<language, hyphenated>/SKILL.md and skills/3dcodeverse/references/plan-<static|articulated|scene|graphics>.md (urdf_blender: also skills/3d-lang-blender/SKILL.md and plan-static.md, which it builds on); no c3d-* skill until a 3dcode finding or score item names its topic./3d-lang-blenderUse when writing, refining or repairing a static_object in Blender bpy (language blender): the files and builder names the lint expects, the Z-up metre frame, naming, the sandbox (allowed imports, forbidden bpy calls), the exact thresholds check-contract / check-connectivity / detail_budget measure, what the GLB exporter keeps, the Blender 5.2.2 API traps, and the 3dcode loop that ships it./3d-lang-cadqueryUse when writing, refining or repairing a static_object in CadQuery (language cadquery): the module-level `result` assembly the wrapper reads, named parts and instances, the Z-up metre frame, the lint's import and call lists, the thresholds check-contract / check-connectivity / detail_budget measure, the OCC kernel facts that fail a build, and the 3dcode loop./3d-lang-glsl-shaderUse when writing, refining or repairing a graphics-track fragment shader (language glsl_shader): the files (one include file per layer, pasted above shader.frag), the uniform block the build prepends (never redeclare it), the two entry points, the gl-frames gate thresholds (NaN, black/blown, static, flicker, low detail) with their score caps, the lint's GLSL 330 rules, the feedback buffer, the judge's named defects, and the 3dcode loop./3d-lang-opengl-pythonUse when writing, refining or repairing a graphics-track moderngl program (language opengl_python): the two entry points setup/render and their exact signatures, the sampled-time trap (render is called at t = 0, 1, 2.5, 4, 6 s, in any order), the final pass into the supplied fbo, the AST lint's import allow-list and forbidden calls, the moderngl facts that decide whether the build runs, the gl-frames gate caps, and the 3dcode loop./3d-lang-scene-blenderUse when writing, refining or repairing a scene in Blender bpy (language scene_blender): the module files and their exact functions (env height_at/build_env, zone build, asset build_<snake>), the ctx every builder receives, the Z-up frame and the Y-up plan conversion, allowed imports and the lint's forbidden table, Blender 5.2 API facts, what Cycles does with what you build, motion as keyframes/drivers, the placement and frame gate thresholds, and the 3dcode loop.Other plugins' skills for the same job