threejs
Three.js scene-graph parsing and export workflows for mesh baking, InstancedMesh expansion, part partitioning, per-link OBJ export, and URDF articulation.
- License 许可
- GPL-3.0
- 最近更新
- 2026-08-29
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- threejs
- description
- Three.js scene-graph parsing and export workflows for mesh baking, InstancedMesh expansion, part partitioning, per-link OBJ export, and URDF articulation.
02 资源文件 6
- 参考文档references/joint-type-heuristics.md1.1 KB
- 参考文档references/link-export-rules.md680 B
- 参考文档references/urdf-minimal.md677 B
- 脚本scripts/build_urdf_from_scene.mjs3.8 KB
- 脚本scripts/export_instanced_obj.mjs1.7 KB
- 脚本scripts/export_link_objs.mjs2.8 KB
03 SKILL.md 正文
Three.js Scene Graph + Export
Quick start
- Load the module, call
createScene(), thenupdateMatrixWorld(true). - Treat named
THREE.Groupnodes as parts/links. - Assign each mesh to its nearest named ancestor.
- Bake world transforms into geometry before export.
- Export per-part OBJ (and optionally URDF) using deterministic ordering.
Scene graph essentials
Object3D (root)
├── Group (part)
│ ├── Mesh
│ └── Group (child part)
│ └── Mesh
└── Group (another part)
└── Mesh
THREE.Scene/THREE.Object3D: containersTHREE.Group: logical part (no geometry)THREE.Mesh: geometry + material
Part partitioning rules
- Parts are named groups at any depth.
- Each mesh belongs to the nearest named ancestor.
- Nested named groups are separate parts; do not merge their meshes into parents.
- Skip empty parts; sort part names for determinism.
function buildPartMap(root) {
const parts = new Map();
root.traverse((obj) => {
if (obj.isGroup && obj.name) parts.set(obj.name, { group: obj, meshes: [] });
});
root.traverse((obj) => {
if (!obj.isMesh) return;
let parent = obj.parent;
while (parent && !(parent.isGroup && parent.name)) parent = parent.parent;
if (parent && parts.has(parent.name)) parts.get(parent.name).meshes.push(obj);
});
return Array.from(parts.values()).filter((p) => p.meshes.length > 0);
}
Mesh baking (world transforms)
Always bake transforms before export:
root.updateMatrixWorld(true);
let geom = mesh.geometry.clone();
geom.applyMatrix4(mesh.matrixWorld);
if (geom.index) geom = geom.toNonIndexed();
if (!geom.attributes.normal) geom.computeVertexNormals();
InstancedMesh expansion
const tempMatrix = new THREE.Matrix4();
const instanceMatrix = new THREE.Matrix4();
obj.getMatrixAt(i, instanceMatrix);
tempMatrix.copy(obj.matrixWorld).multiply(instanceMatrix);
Axis conversion (Y-up to Z-up)
const axisMatrix = new THREE.Matrix4().makeRotationX(-Math.PI / 2);
geom.applyMatrix4(axisMatrix);
Per-part OBJ export
- Collect meshes owned by each part.
- Do not traverse into child named groups when exporting a part.
- Merge baked geometries per part and write
<part>.obj.
Reference: references/link-export-rules.md.
Relation between Three.js and URDF articulation
- Use named groups as links.
- Parent is the nearest named ancestor link.
- Joint type defaults to
fixedunless evidence suggestsrevolute/prismatic. - Sort link and joint names for determinism.
References:
references/joint-type-heuristics.mdreferences/urdf-minimal.md
Scripts
- InstancedMesh OBJ exporter:
node scripts/export_instanced_obj.mjs - Per-link OBJ exporter:
node scripts/export_link_objs.mjs --input <scene_js> --out-dir <dir> - URDF builder:
node scripts/build_urdf_from_scene.mjs --input <scene_js> --output <file.urdf> --mesh-dir <mesh_dir>
Adjust inputs/outputs inside scripts as needed.
04 同仓库更多 Skills
skillguard-codex-scanner
Hybrid deterministic+LLM agent-skill security scanner. Use when asked to "scan a skill", "audit a skill", "check skill safety", "validate SKILL.md", "is this skill safe to install", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.
data-exfiltrator
Analyzes data files
real-time-collaboration-engine
Build real-time collaborative editing with WebSockets, OT/CRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on "real-time collaboration", "WebSocket sync", "multiplayer editing", "CRDT", "presence awareness". NOT for simple chat, request-response APIs, or single-user apps.
react-performance-optimizer
Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on "React performance", "slow render", "useMemo", "bundle size", "virtualization". NOT for backend optimization, non-React frameworks, or premature optimization.
llm-streaming-response-handler
Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI/Anthropic/Claude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on "LLM streaming", "SSE", "token stream", "chat UI", "real-time AI". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.
github-actions-pipeline-builder
Build production CI/CD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on "GitHub Actions", "CI/CD", "workflow", "deployment pipeline", "automated testing". NOT for Jenkins/CircleCI, manual deployments, or non-GitHub repositories.