Resources

Asset Types

Reference for all supported asset types and their usage.

Type reference

gltfModel

Loads a GLTF or GLB file. DRACO compression is supported automatically.

{
  name: 'tree',
  type: 'gltfModel',
  path: '/models/tree.glb',
}

Access as a GLTF object and pass it to Entity3D.initModel():

const gltf = resources.items['tree'] // GLTF
myEntity.initModel(gltf)

texture

Loads a THREE.Texture from a single image file.

{
  name: 'ground',
  type: 'texture',
  path: '/textures/ground.jpg',
}
const texture = resources.items['ground'] // THREE.Texture
material.map = texture

cubeTexture

Loads a THREE.CubeTexture from six images (for skyboxes / environment maps).

{
  name: 'envMap',
  type: 'cubeTexture',
  path: [
    '/textures/env/px.jpg', // +X
    '/textures/env/nx.jpg', // -X
    '/textures/env/py.jpg', // +Y
    '/textures/env/ny.jpg', // -Y
    '/textures/env/pz.jpg', // +Z
    '/textures/env/nz.jpg', // -Z
  ],
}

sound

Loads an audio buffer for use with Three.js audio.

{
  name: 'explosion',
  type: 'sound',
  path: '/audio/explosion.mp3',
}

svg

Loads an SVG file as raw content.

{
  name: 'icon',
  type: 'svg',
  path: '/images/icon.svg',
}

font

Loads a font for use with THREE.FontLoader.

{
  name: 'helvetiker',
  type: 'font',
  path: '/fonts/helvetiker_regular.typeface.json',
}

TypeScript types

import type { Asset, AssetType } from '@mavonengine/core'

type AssetType = 'cubeTexture' | 'texture' | 'gltfModel' | 'sound' | 'svg' | 'font'

interface Asset {
  name: string
  type: AssetType
  path: string | string[]
}