Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

319
Visualizações
Trouble using nav-mesh in a-frame js for my VR project

I added appropriate CDN's for aframe ,aframe extras, recast plugin

<script src="https://aframe.io/releases/1.1.0/aframe.min.js"></script>
<script src="https://recast-api.donmccurdy.com/aframe-inspector-plugin-recast.js"></script>
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.0.1/dist/aframe-extras.min.js">/script>

,added my nav mesh entity inside <a-scene>

 <a-entity id="wallmesh" position="0 0.769 0" gltf-model="navmesh/nav3.glb" visible="false"></a-entity>

and for player or camera I tried this,

 <a-entity id="player-rig" >
        <a-entity
          id="player"
          networked="template:#avatar-template;attachTemplateToLocal:false;"
          movement-controls="constrainToNavMesh: true"
          camera="active:true;"
          position="-27 2.5 24"
          
          look-controls
          spawn-in-circle="radius:2"
          rotate-with-camera
        >
        <a-entity id="player-body"  networked="template:#body; attachTemplateToLoacal:false;"         position="-.17 -.88 0"></a-entity>
      </a-entity>
      </a-entity>

But my camera didnt move itself and spawned in different position than expected. Please help me out if you find wrong anything in this approach...

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try knocking down the version of A-Frame to 1.0.4 and see if it works.

The Extras component has not been update recently and the first thing I noticed is that the navmesh component was broken when moving up from the above version. Has to do with the deprecation of Geometry in Three.js I believe.

Try Ada Rose Cannon's XR boiler plate and grab the simple-navmesh-constraint.

about 4 years ago · Juan Pablo Isaza Relatório

0

The fact that your camera is in the wrong place and not moving suggests you might be hittting this issue, whereby A-Frame fails to notice that you have a user-defined camera, and adds a default camera, which takes over. https://github.com/aframevr/aframe/issues/3921

In the console, enter

document.querySelector('[camera]')

If it returns 2 elements you almost certainly have the issue.

Simplest fix is to ensure you declare your user-defined camera before any <template> tags in your a-scene (you are using Networked A-Frame, so I guess you have some of these?)

Alternatively, something like this code in one of your components would probably also fix the issue.

    const sceneEl = document.querySelector('a-scene')
    
    if (sceneEl.camera.el.id !== 'player') {    
        console.log("Deleting unwanted A-Frame default camera")
        const wrongCameraEntity = this.el.sceneEl.camera.el;
        const cameraEntity = document.getElementById('player');
        cameraEntity.setAttribute('camera', 'active', true);
        wrongCameraEntity.parentEl.removeChild(wrongCameraEntity);
    }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda