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

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

Open
martaquintana opened this issue Jan 25, 2022 · 1 comment
Open

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

martaquintana opened this issue Jan 25, 2022 · 1 comment

Comments

@martaquintana
Copy link

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?

@martaquintana martaquintana changed the title Problem with event body-loaded in Chrome AMMO DRIVER Problem with event body-loaded in Chrome Jan 25, 2022
@icurtis1
Copy link

icurtis1 commented Feb 25, 2022

I ran into this with glTF models. I had to make a custom component to add a body to a glTF model correctly. Check out my reply in the below issue

#192

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