HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/.codex/.tmp/plugins/plugins/game-studio/references/gltf-loading-starter.md
# GLB Loading Starter

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

## Vanilla Three.js

```ts
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

```tsx
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.