Files
2nd/10_Wiki/Topics/Domain_Programming/AI_and_ML/agargaro의 오픈 소스 라이브러리.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

7.1 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, inferred_by, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit inferred_by tech_stack
wiki-2026-0508-agargaro의-오픈-소스-라이브러리 agargaro Open Source Libraries (Three.js Extensions) 10_Wiki/Topics verified self
InstancedMesh2
batched-mesh-extensions
three.js performance
Three Examples Pmndrs
none B 0.85 conceptual
three-js
webgl
performance
instancing
lod
bvh
frustum-culling
open-source-library
2026-05-09 pending Claude Opus 4.7 (manual cleanup 2026-05-09)
language framework
TypeScript Three.js / WebGL / WebGPU

agargaro Open Source Libraries (Three.js Extensions)

📌 한 줄 통찰

Three.js 의 native InstancedMesh 의 limit → InstancedMesh2 + batched-mesh-extensions. 매 instance 의 frustum culling / LOD / BVH raycasting 의 native. 큰 scene (10k-100k instance) 의 60fps.

📖 핵심

Library 의 family

InstancedMesh2 (main)

  • Three.js native InstancedMesh 의 superset.
  • 매 instance 의 individual control.
  • Frustum culling per-instance.
  • LOD per-instance.
  • BVH-based raycasting.
  • Radix sort 의 depth sorting.

batched-mesh-extensions

  • Three.js BatchedMesh 의 extension.
  • 매 different geometry 의 batch.
  • Open world 친화.

매 packages

  • @three.ez/instanced-mesh.
  • @three.ez/main (framework).
  • @three.ez/batched-mesh-extensions.

InstancedMesh vs InstancedMesh2

InstancedMesh (native) InstancedMesh2
Per-instance visibility
Frustum culling
LOD (per instance)
Raycasting Slow Fast (BVH)
Depth sort (radix sort)
Partial update Manual (SquareDataTexture)
Capacity < 10k 100k+

매 핵심 mechanism

1. Indirection (instance index)

  • 매 InstancedBufferAttribute 의 index.
  • 매 buffer reorder 없이 selective render.

2. SquareDataTexture

  • 매 data + matrix 의 texture 저장.
  • 매 partial update.
  • CPU → GPU transfer optimize.

3. BVH (Bounding Volume Hierarchy)

  • 매 raycast 의 logarithmic.
  • 매 click detection.

4. Radix sort

  • 매 transparent 의 back-to-front.
  • 매 GPU 친화.

매 use case

Forest / vegetation

  • 매 tree (10k+).
  • 매 grass instance (100k+).
  • 매 LOD distance.

City / building

  • 매 modular building.
  • 매 instance 의 different LOD.

Particle system

  • 매 sparkle / dust.
  • 매 dynamic position.

Crowd simulation

  • 매 character (1k-10k).
  • 매 individual control.

매 performance

Scene Native IM InstancedMesh2
10k tree, no culling 30 FPS 60 FPS (with culling)
100k grass 5 FPS 60 FPS (LOD + culling)
1k character + raycast 20 FPS 60 FPS (BVH)

→ 매 culling + LOD = 큰 boost.

매 author

  • agargaro (Andrea Gargaro, Italy).
  • Three.js community 의 active contributor.
  • @three.ez ecosystem 의 maintainer.

💻 Code

Install

npm install @three.ez/instanced-mesh

Basic InstancedMesh2

import { InstancedMesh2 } from '@three.ez/instanced-mesh';
import * as THREE from 'three';

const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardMaterial();

const instancedMesh = new InstancedMesh2(geometry, material, {
  capacity: 10_000,   // max instance count
  createEntities: true,   // 매 instance 의 entity 의 wrap
});

// Add instance
for (let i = 0; i < 10_000; i++) {
  instancedMesh.addInstances(1, (instance, i) => {
    instance.position.set(
      Math.random() * 100 - 50,
      Math.random() * 100 - 50,
      Math.random() * 100 - 50
    );
    instance.scale.setScalar(Math.random() * 2 + 0.5);
  });
}

scene.add(instancedMesh);

Frustum culling

// 자동: 매 frame 의 camera frustum 의 outside instance 의 skip
instancedMesh.computeBVH();   // 매 BVH 의 build (1번)

// 매 frame
function animate() {
  instancedMesh.performFrustumCulling(camera);   // 자동
  renderer.render(scene, camera);
}

LOD (per instance)

const highLOD = new THREE.SphereGeometry(1, 32, 32);
const midLOD = new THREE.SphereGeometry(1, 16, 16);
const lowLOD = new THREE.SphereGeometry(1, 8, 8);

const instancedMesh = new InstancedMesh2(highLOD, material);
instancedMesh.addLOD(midLOD, midMaterial, 50);    // distance 50+
instancedMesh.addLOD(lowLOD, lowMaterial, 100);    // distance 100+

→ 매 instance 의 distance 의 LOD switch.

BVH raycasting

const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);

const intersects = raycaster.intersectObject(instancedMesh);

if (intersects.length > 0) {
  const instanceId = intersects[0].instanceId;
  console.log(`Clicked instance ${instanceId}`);
}

→ Native보다 100x 빠름 (1k+ instance).

Per-instance update

const instance = instancedMesh.instances[42];
instance.position.x += 0.1;
instance.scale.y *= 1.1;
instance.color.setHex(0xff0000);

// 매 frame end 의 commit
instancedMesh.update();

batched-mesh-extensions

import { BatchedMesh } from 'three';
import { addBVH, computeBVH } from '@three.ez/batched-mesh-extensions';

const batched = new BatchedMesh(maxGeometries, maxVertices, maxIndices, material);

// 매 different geometry 의 batch
const geo1Id = batched.addGeometry(treeGeometry);
const geo2Id = batched.addGeometry(buildingGeometry);

batched.addInstance(geo1Id);
batched.addInstance(geo2Id);

addBVH(batched);
computeBVH(batched);

→ 매 different geometry 도 1 draw call.

React Three Fiber 의 통합

import { extend } from '@react-three/fiber';
import { InstancedMesh2 } from '@three.ez/instanced-mesh';

extend({ InstancedMesh2 });

function Forest() {
  return (
    <instancedMesh2 args={[boxGeo, mat, { capacity: 10000 }]}>
      {/* ... */}
    </instancedMesh2>
  );
}

🤔 결정 기준

Scene size 추천
< 1k same geometry Native InstancedMesh
1k-10k same InstancedMesh2 (frustum)
10k-100k + LOD InstancedMesh2 (culling + LOD)
Different geometries BatchedMesh + extensions
Particle system InstancedMesh2 + custom shader

기본값: InstancedMesh2 (10k+ scene). 매 specific 의 BatchedMesh.

🔗 Graph

🤖 LLM 활용

언제: 매 large 3D scene optimize. 매 vegetation / crowd / city. 언제 X: 매 simple scene (< 1k). 매 specific custom shader 의 unrelated.

안티패턴

  • Native InstancedMesh + 100k instance: 30 FPS.
  • 매 instance 의 manual frustum check: CPU heavy.
  • No LOD + 큰 distance variation: GPU waste.
  • No BVH + raycasting: O(N) per click.

🧪 검증 / 중복

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-09 Manual cleanup — feature comparison + use case + Three.js code