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.

AMMO DRIVER Problem with event body-loaded in Chrome #200

Description

@martaquintana

Hello!!

in our application we are trying to change Aframe with cannon to aframe with ammo.

We get load the model well by this way:

First loading the model then the ammo-body.
When the model is loaded, the event loads ammo-shape (the collison mesh) and then when the body is loaded we set the restitution.

    const gltfmodel = document.getElementById(this.data.id)
    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)
    gltfmodel.addEventListener('model-loaded', () => {
          gltfmodel.setAttribute('ammo-shape', {type: this.data.shape,
                                              fit: this.data.fit,
                                              halfExtents: this.data.halfExtents,
                                              offset: this.data.offset})
    });

    gltfmodel.addEventListener('body-loaded', () => {

          try {
            var sceneEl = document.querySelector('a-scene');
            //Set robot restitution
            sceneEl.querySelector("#"+toString(this.data.id)).body.setRestitution(this.data.restitution);
            //Set a-plane restitution
            sceneEl.querySelector("#a-plane").body.setRestitution(0.8);
          } catch (e) {}
          }
     
    })

It works really well in Firefox but the body-loaded event doesn't work quite right for Chrome. This event 'body-loaded' is not picked up properly in chrome, do you have any idea what could be happening?

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