threejs-instancing

Implements scalable RTS rendering with Three.js InstancedMesh and batched draw calls.

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/Ohmnia/site-build --skill threejs-instancing-ohmnia
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-instancing
Source: https://github.com/Ohmnia/site-build/tree/main/.opencode/skills/threejs-instancing
Command: npx skills add https://github.com/Ohmnia/site-build --skill threejs-instancing-ohmnia

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Real-time strategy games with hundreds of units suffer from excessive draw calls and unstable frametimes when each unit is rendered as a separate mesh. This Skill provides rendering rules and patterns for building scalable Three.js rendering pipelines using instancing and batching. ## Core Features & Use Cases - Instanced Rendering Rules: Enforces use of InstancedMesh, shared geometry, shared materials, and batched transform updates instead of one mesh per unit. - Decoupled Render Pipeline: Defines a Simulation → Render Extraction → Visibility Filtering → Instance Updates → GPU Submission pipeline that keeps rendering separate from game logic. - API Constraints: Prevents common bugs such as forgetting instancedMesh.instanceMatrix.needsUpdate = true or creating new THREE.Mesh objects inside the game loop. - Use Case: When building an RTS with thousands of units on screen, apply these rules to keep draw calls low and frametimes stable using texture atlases, frustum culling, and lightweight shaders. ## Quick Start Use the threejs-instancing skill to design the rendering layer for my RTS game so thousands of units render with minimal draw calls.

Frequently Asked Questions about threejs-instancing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I render thousands of units in Three.js?

Use THREE.InstancedMesh with shared geometry and shared materials so all units of a type render in a single draw call. Update transforms by writing matrices into the instance buffer and setting instanceMatrix.needsUpdate = true each frame.

How to reduce draw calls in a Three.js RTS game?

Reduce draw calls by batching units into InstancedMesh groups, using texture atlases to share materials, and applying frustum culling before instance updates. Avoid creating one Mesh per unit or deep Object3D hierarchies.

Why is my InstancedMesh not updating positions in Three.js?

Instance transforms do not upload to the GPU unless you set instancedMesh.instanceMatrix.needsUpdate = true after modifying matrices. This flag must be set during the GPU submission phase of every frame that changes transforms.

Should rendering be decoupled from game simulation?

Yes, rendering should remain decoupled from simulation. The recommended pipeline is Simulation → Render Extraction → Visibility Filtering → Instance Updates → GPU Submission, so game logic never directly manipulates scene objects.

When should I avoid per-unit skinned meshes in Three.js?

Avoid per-unit skinned meshes in large-scale RTS rendering because skinning and per-unit draw calls destroy frametime stability at scale. Prefer instanced meshes with lightweight shaders, and reserve skinning for a small number of hero units.