Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.
This repository was 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

Description

@icurtis1

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions