Logo di Threejs Scene

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).

Panoramica

Autore0xBakeer
RepositoryTandemLLM
Nome della skillthreejs-scene
Stelle
75
Fork
14
File inclusi
Solo istruzioni
LicenzaAGPL-3.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da 0xBakeer su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Threejs Scene in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/0xBakeer/TandemLLM/tree/main/packages/library/threejs-scene
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

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
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Threejs Scene in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Threejs Scene non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Threejs Scene non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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.

Domande frequenti

Cosa fa la skill IA Threejs Scene?

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

Perché usare Threejs Scene su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Threejs Scene è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Threejs Scene in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/0xBakeer/TandemLLM/tree/main/packages/library/threejs-scene. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Threejs Scene?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Threejs Scene?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Threejs Scene: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Threejs Scene è gratuita?

Sì. È pubblicata su GitHub da 0xBakeer con licenza AGPL-3.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇