Files
Genarrative/.codex/plugins/game-studio/references/gltf-loading-starter.md
T
kdletters 071faa482c 统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口

完成项目 TypeScript/Prettier 与 Rust 全量格式化

修复 Pingora expected executable 门禁的空白敏感误报

同步开发运维文档与 AGC skill pack 格式化忽略规则
2026-09-01 16:28:34 +08:00

980 B

GLB Loading Starter

Use this as the canonical minimal pattern for loading shipped 3D content.

Vanilla Three.js

import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';

const draco = new DRACOLoader();
draco.setDecoderPath('/draco/');

const gltfLoader = new GLTFLoader();
gltfLoader.setDRACOLoader(draco);

gltfLoader.load('/assets/hero.glb', (gltf) => {
  const root = gltf.scene;
  root.traverse((node) => {
    if ('castShadow' in node) {
      node.castShadow = true;
      node.receiveShadow = true;
    }
  });
  scene.add(root);
});

React Three Fiber

import { useGLTF } from '@react-three/drei';

function HeroModel() {
  const gltf = useGLTF('/assets/hero.glb');
  return <primitive object={gltf.scene} />;
}

Notes

  • Default shipping format is GLB or glTF 2.0.
  • Keep optimization upstream in the asset pipeline; loader code should stay boring.