Threejs Scene logo

Threejs Scene

Community
0xBakeer
threejs-scene

Building a WebGL scene with Three.js - renderer, camera, lights, meshes, controls, resize, animation loop, and performance (draw calls, instancing, disposal).

Overview

Publisher0xBakeer
RepositoryTandemLLM
Skill namethreejs-scene
Stars
75
Forks
14
Bundled files
Instructions only
LicenseAGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by 0xBakeer on GitHub. Read the source before you install it.

Installation

Install the Threejs Scene AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/0xBakeer/TandemLLM/tree/main/packages/library/threejs-scene
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/0xBakeer/TandemLLM.git /tmp/TandemLLM
mkdir -p .claude/skills
cp -r /tmp/TandemLLM/packages/library/threejs-scene .claude/skills/threejs-scene
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Threejs Scene in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Threejs Scene on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Threejs Scene is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Three.js scene

Rules:

  • One version through an import map. Addons are named exports (import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js'); merged parts all indexed or all .toNonIndexed(). Not in three.js: Matrix4.makeRotationXYZ, Matrix4.rotateY, renderer.shadowMap.size (use geometry.rotateY(a).translate(...), light.shadow.mapSize). A geometry has rotateY, translate, scale and no position; a mesh has position, rotation, scale and no translate.
  • ACES tone mapping. Bloom: RenderPass -> UnrealBloomPass (threshold ~0.85) -> OutputPass last, or the frame looks flat.
  • Light since r155: hemisphere ~1.5, sun ~3, the sun on the camera's side so the faces it sees are lit. Golden hour: low warm sun 0xffb070, a sky gradient (warm horizon, blue top), fog the horizon colour. Night: sky 0x0b1530, hemisphere 0.3, moon 0.8, emissive lanterns with point lights. Start in the look asked; the Day/Night control jumps there and stops the cycle.
  • Saturated colours, metalness: 0; foliage clustered icosahedra. Stacked flat surfaces (ground, path, pond) 0.02 apart or they speckle. Water: Reflector (library_read threejs-scene has it), not a hand-made render target.
  • Frame it: controls.target at the subject, camera ~2x its size, further back when aspect < 1.

Check: screenshots at 1280 and 390 in each mode, compared with the request; console 0 errors; window.__state() gives frames, draw calls (under 1,000) and the mode.

Reference

Import map:

html
<script type="importmap">{"imports":{"three":"https://unpkg.com/three@0.170.0/build/three.module.js","three/addons/":"https://unpkg.com/three@0.170.0/examples/jsm/"}}</script>

A day scene:

js
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2)); renderer.setSize(innerWidth, innerHeight);
renderer.toneMapping = THREE.ACESFilmicToneMapping; renderer.shadowMap.enabled = true;
document.body.appendChild(renderer.domElement);
const sky = 0x9fd3ff, scene = new THREE.Scene();
scene.background = new THREE.Color(sky); scene.fog = new THREE.Fog(sky, 30, 120);
const camera = new THREE.PerspectiveCamera(55, innerWidth / innerHeight, 0.1, 300);
camera.position.set(8, 6, 12);
scene.add(new THREE.HemisphereLight(0xdcefff, 0x8a7350, 1.5));
const sun = new THREE.DirectionalLight(0xfff1d6, 3); sun.position.set(10, 18, 6); sun.castShadow = true; scene.add(sun);
const ground = new THREE.Mesh(new THREE.PlaneGeometry(80, 80), new THREE.MeshStandardMaterial({ color: 0x6fa04a }));
ground.rotation.x = -Math.PI / 2; ground.receiveShadow = true; scene.add(ground);
const cube = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshStandardMaterial({ color: 0xc8402c, metalness: 0 }));
cube.position.y = 0.5; cube.castShadow = true; scene.add(cube);
const controls = new OrbitControls(camera, renderer.domElement);
addEventListener('resize', () => { camera.aspect = innerWidth / innerHeight; camera.updateProjectionMatrix(); renderer.setSize(innerWidth, innerHeight); });
let frames = 0;
renderer.setAnimationLoop(() => { frames++; controls.update(); renderer.render(scene, camera); });
window.__state = () => ({ tandem_state: 1, frames, calls: renderer.info.render.calls, cam: camera.position.toArray() });

Night: background and fog 0x0b1530, hemisphere 0.3, moon 0.8 (0xaac4ff), lanterns as PointLights.

Bloom with tone mapping kept, and a mode switch that moves everything together:

js
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
composer.addPass(new UnrealBloomPass(new THREE.Vector2(innerWidth, innerHeight), 0.6, 0.4, 0.85));
composer.addPass(new OutputPass());          // tone mapping and sRGB; without it the frame is flat
function skyTexture(top, horizon) {          // a vertical gradient for scene.background
  const c = document.createElement('canvas'); c.width = 2; c.height = 256;
  const g = c.getContext('2d'), grd = g.createLinearGradient(0, 0, 0, 256);
  grd.addColorStop(0, top); grd.addColorStop(1, horizon); g.fillStyle = grd; g.fillRect(0, 0, 2, 256);
  const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; return t;
}
const MODES = { golden: { top: '#6f8fc8', horizon: '#ffb36b', hemi: 1.2, sun: 3, sunColor: 0xffb070, exp: 1.1, lamps: 0 },
                night: { top: '#050a1c', horizon: '#1a2a55', hemi: 0.3, sun: 0.8, sunColor: 0xaac4ff, exp: 0.9, lamps: 2 } };
let mode = 'golden';
function setMode(m) { const v = MODES[mode = m]; scene.background = skyTexture(v.top, v.horizon);
  scene.fog.color.set(v.horizon); hemi.intensity = v.hemi; sun.intensity = v.sun; sun.color.set(v.sunColor);
  renderer.toneMappingExposure = v.exp; lanternMat.emissiveIntensity = v.lamps; }
// render with composer.render() in the loop; composer.setSize() on resize
window.__state = () => ({ tandem_state: 1, frames, mode, calls: renderer.info.render.calls });

Water that mirrors the scene:

js
import { Reflector } from 'three/addons/objects/Reflector.js';
const pond = new Reflector(new THREE.CircleGeometry(6, 48), { textureWidth: 512, textureHeight: 512, color: 0x6b8a99 });
pond.rotation.x = -Math.PI / 2; pond.position.y = 0.03; scene.add(pond);   // 0.03 above the ground
// tint and ripples: a transparent plane (opacity ~0.35, MeshStandardMaterial, roughness 0.1) 0.01 above it

Merging placed parts: const g = new THREE.BoxGeometry(w, h, d); g.rotateY(a); g.translate(x, y, z); parts.push(g); then mergeGeometries(parts). With a helper object instead: const o = new THREE.Object3D(); o.position.set(x, y, z); o.rotation.y = a; o.updateMatrix(); g.applyMatrix4(o.matrix); (o is an Object3D, g the geometry).

What goes wrong:

  • Dull, grey or dark: lights at 1 or less (dim since r155), a dark or grey background, fog nearer than the subject, metalness above 0. Black: no light, or the camera looks away.
  • A TypeError on a three.js call: the name does not exist in this version. List the class's methods from its readable source of the same version, curl -s https://unpkg.com/three@0.170.0/src/math/Matrix4.js | grep -nP '^\t\w+\(' (addons under examples/jsm/), never by grepping a minified build.
  • Frame rate collapses: shadows on every light, new objects each frame, thousands of meshes instead of an InstancedMesh; dispose what you remove.

Frequently asked questions

What does the Threejs Scene AI skill do?

Building a WebGL scene with Three.js - renderer, camera, lights, meshes, controls, resize, animation loop, and performance (draw calls, instancing, disposal).

Why use Threejs Scene on TypingMind?

Because you install it once and use it with any model. Threejs Scene is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Threejs Scene in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/0xBakeer/TandemLLM/tree/main/packages/library/threejs-scene. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Threejs Scene?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Threejs Scene?

As many as you like. As long as a model supports skills, you can use Threejs Scene with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Threejs Scene AI skill free?

Yes. It is published on GitHub by 0xBakeer under the AGPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇