DOCS v0.1.13 github

@hatch:gltf v0.1.0

Pure-Wren glTF 2.0 / .glb loader. Parses the binary container into nodes / meshes / materials, resolves accessors into typed vertex + index arrays (Float32Array / Int32Array / ByteArray), decodes embedded images via @hatch:image, and spawns a Transform-rooted hierarchy into a @hatch:ecs World with fully-textured PBR Materials wired to every glTF slot (baseColor / metallicRoughness / normal / occlusion / emissive).

stable data updated May 28, 2026 source ↗
README
$ hatch add @hatch:gltf

MOD gltf

CL Gltf

FN Gltf.static parse(bytes: ByteArray|List<Num>) → GltfScene

FN Gltf.static load(device: Device, bytes: ByteArray|List<Num>) → GltfScene

FN Gltf.static fromAsset(device: Device, asset: Asset) → GltfScene

FN Gltf.static fromAssets(device: Device, db: Assets, relPath: String) → GltfScene

CL Bytes_

FN Bytes_.static u32LE(b, o)

FN Bytes_.static u16LE(b, o)

FN Bytes_.static f32LE(b, o)

FN Bytes_.static asciiString(b, off, len)

CL GltfScene

NEW GltfScene.new_(json: Map, bin: ByteArray)

GET GltfScene.json

GET GltfScene.binBuffer

GET GltfScene.materials

GET GltfScene.meshes

GET GltfScene.nodes

GET GltfScene.rootIndices

FN GltfScene.static parse_(bytes)

FN GltfScene.static stripPad_(s)

FN GltfScene.static textureToImageMap_(json)

FN GltfScene.static imageIndexOf_(json, t2i, slot)

FN GltfScene.static buildMaterials_(json)

FN GltfScene.static buildImageSources_(json, materials)

FN GltfScene.static buildMeshes_(json, bin)

FN GltfScene.static extractPrimitive_(json, bin, p)

FN GltfScene.static buildNodes_(json)

FN GltfScene.static buildNode_(n)

FN GltfScene.static pickRootIndices_(json)

FN GltfScene.static accessorAt_(json, idx)

FN GltfScene.static bufferViewAt_(json, idx)

FN GltfScene.static readVec3Accessor_(json, bin, idx)

FN GltfScene.static readVec2Accessor_(json, bin, idx)

FN GltfScene.static readFloatAccessor_(json, bin, idx, components, expectedType)

FN GltfScene.static readIndexAccessor_(json, bin, idx)

FN GltfScene.upload(device)

FN GltfScene.uploadImages_(device)

FN GltfScene.spawnInto(world)

FN GltfScene.spawnNode_(world, idx, parentEntity, spawned)

FN GltfScene.attachMesh_(world, parentEntity, gltfMesh)

CL GltfNode

NEW GltfNode.new_(name: String, transform: Transform, meshIndex: Num|Null, children: List<Num>)

GET GltfNode.name

GET GltfNode.transform

GET GltfNode.meshIndex

GET GltfNode.children

GET GltfNode.toString

CL GltfMesh

NEW GltfMesh.new_(name: String, primitives: List<GltfPrimitive>)

GET GltfMesh.name

GET GltfMesh.primitives

FN GltfMesh.upload_(device, materials, textures)

CL GltfPrimitive

NEW GltfPrimitive.new_(positions: Float32Array, normals: Float32Array|Null, uvs: Float32Array|Null, indices: Int32Array|Null, materialIndex: Num|Null)

GET GltfPrimitive.positions

GET GltfPrimitive.normals

GET GltfPrimitive.uvs

GET GltfPrimitive.indices

GET GltfPrimitive.materialIndex

GET GltfPrimitive.mesh

GET GltfPrimitive.material

FN GltfPrimitive.upload_(device, materials, textures)

FN GltfPrimitive.pickMaterial_(materials, textures)

FN GltfPrimitive.defaultMaterial_()

CL GltfMaterial

NEW GltfMaterial.new_(name: String, baseColor: Vec4, metallic: Num, roughness: Num, albedoImageIndex: Num|Null, mrImageIndex: Num|Null, normalImageIndex: Num|Null, normalScale: Num, occlusionImageIndex: Num|Null, occlusionStrength: Num, emissiveImageIndex: Num|Null, emissiveColor: Vec4, alphaMode: String, alphaCutoff: Num, doubleSided: Bool)

GET GltfMaterial.name

GET GltfMaterial.baseColor

GET GltfMaterial.metallic

GET GltfMaterial.roughness

GET GltfMaterial.albedoImageIndex

GET GltfMaterial.mrImageIndex

GET GltfMaterial.normalImageIndex

GET GltfMaterial.normalScale

GET GltfMaterial.occlusionImageIndex

GET GltfMaterial.occlusionStrength

GET GltfMaterial.emissiveImageIndex

GET GltfMaterial.emissiveColor

GET GltfMaterial.alphaMode

GET GltfMaterial.alphaCutoff

GET GltfMaterial.doubleSided

FN GltfMaterial.toGpuMaterial(textures: List<Texture|Null>) → Material