Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

gltf ammo-shape loading before object3DMap.mesh information in A-frame #192

Open
icurtis1 opened this issue Jul 2, 2021 · 1 comment
Open

Comments

@icurtis1
Copy link

icurtis1 commented Jul 2, 2021

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
Copy link
Collaborator

Thanks - hit the same problem, and this was very helpful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants