Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

1.1 KB
Raw Blame
import { useMemo, useEffect } from 'react'
import * as THREE from 'three'

export const SHADED_COLOR = new THREE.Color(0xb8b8b8)

export interface AssetMaterials {
  wireframeMaterial: THREE.MeshBasicMaterial
  shadedMaterial: THREE.MeshStandardMaterial
  wireframeOverlayMaterial: THREE.MeshBasicMaterial
}

export function useAssetMaterials(): AssetMaterials {
  const materials = useMemo<AssetMaterials>(
    () => ({
      wireframeMaterial: new THREE.MeshBasicMaterial({
        color: 0x000000,
        wireframe: true,
        toneMapped: false,
        fog: false,
      }),
      shadedMaterial: new THREE.MeshStandardMaterial({
        color: SHADED_COLOR,
        roughness: 0.75,
        metalness: 0,
      }),
      wireframeOverlayMaterial: new THREE.MeshBasicMaterial({
        color: 0x000000,
        wireframe: true,
        toneMapped: false,
        fog: false,
      }),
    }),
    [],
  )

  useEffect(() => {
    return () => {
      materials.wireframeMaterial.dispose()
      materials.shadedMaterial.dispose()
      materials.wireframeOverlayMaterial.dispose()
    }
  }, [materials])

  return materials
}