gltf ammo-shape loading before object3DMap.mesh information in A-frame
icurtis1 opened this issue · 1 comments
icurtis1 commented
When adding ammo-body and ammo-shape components to a loaded gltf-model I get error "Cannot use FIT.ALL without object3DMap.mesh" it seems that the ammo is trying to create a ammo-shape before model loaded.
This is what currently causes the error:
I've created a workaround for now in my A-frame project for now with an A-frame component like so:
const gltfPhysicsObjectComponent = {
schema: {
model: {default: ''},
body: {type: 'string', default: 'dynamic'}, //dynamic: A freely-moving object.
shape: {type: 'string', default: 'hull'}, // hull: Wraps a model in a convex hull, like a shrink-wrap
},
init() {
const gltfmodel = document.createElement('a-entity')
this.el.appendChild(gltfmodel)
gltfmodel.setAttribute('gltf-model', this.data.model)
gltfmodel.setAttribute('shadow', {receive: false})
// Specify what type of ammo-body (dynamic, static, kinematic)
gltfmodel.setAttribute('ammo-body', {type: this.data.body})
// Waiting for model to load before adding ammo-shape (box, cylinder, sphere, capsule, cone, hull)
this.el.addEventListener('model-loaded', () => {
gltfmodel.setAttribute('ammo-shape', {type: this.data.shape})
})
},
}
export {gltfPhysicsObjectComponent}
The ammo component as of now works great with primitives but not with gltf models. This is my current workaround for now...
diarmidmackenzie commented
Thanks - hit the same problem, and this was very helpful.