I’m encountering a TypeScript error while following the official documentation on how to use GLTF assets.
I follow the GLTF loading example directly from your docs, and the code looks like this:
import * as ecs from '@8thwall/ecs'
ecs.registerComponent({
name: 'random_luckyitem',
schema: {
// @asset
model1: ecs.string,
// @asset
model2: ecs.string,
// @asset
model3: ecs.string,
},
add: (world, eid, component) => {
const modelOptions = [component.model1, component.model2, component.model3]
const validModels = modelOptions.filter(Boolean)
const selected = validModels[Math.floor(Math.random() * validModels.length)]
ecs.GltfModel.set(world, eid, {
url: selected,
})
},
})
However, when I compile the project, I get the following error:
Unhandled promise rejection: TypeError: undefined is not an object (evaluating ‘component.model1’)
Please help me clarify.