pmndrs/cannon-es

CANNON.Ray(...).intersectBody doesn't update direction itself

Aberta

#15 aberto em 6 de abr. de 2020

 (5 comentários) (0 reação) (1 responsável)TypeScript (152 forks)github user discovery
enhancementhelp wanted

Métricas do repositório

Stars
 (2.030 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

new CANNON.Ray(vFrom, vTo).intersectBody(body) method doesn't work without using ray.updateDirection method (which was private in cannon.js).

body.addEventListener("collide", ({ contact }) => {
  if (!grounded) {
    const vFrom = body.position;
    const vTo = new CANNON.Vec3(0, -1, 0);
    const ray = new CANNON.Ray(vFrom, vTo);
    ray.updateDirection(); // <------ I shouldnt need to update the direction 
                            //         manually before using intersectBody
    ray.intersectBody(contact.bi);
    grounded = ray.result.hasHit;
  }
});

A bug also encountered here but you should dig into the code.

Also, thanks for your port and fork !

Guia do colaborador