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

82
Visualizações
Threejs Raycast Intersects empty with scene.children. What am I doing wrong?

Post 1) I am trying to detect all objects viewable by the camera so I can reposition them to the starting position once they are out of view. I am aiming for an infinite waterfall effect that reuses the existing objects. I really don't why intersects is empty and it works if I raycast for individual objects while looping through scene.children but this will lead to very bad performance because it is in the animation loop.

Thanks for any help

Post 2) I have changed over to frustrum culling but frustum.containsPoint(scene.children[index]) always returns true even when objects are clearly out of camera view.

Again any help is appreciated

camera.updateMatrix();
  camera.updateMatrixWorld();

  var frustum = new THREE.Frustum();
  var projScreenMatrix = new THREE.Matrix4();
  projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);

  // frustum.setFromProjectionMatrix(camera.projectionMatrix);
  frustum.setFromProjectionMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse));

  for (let index = 0; index < scene.children.length; index++) {
    scene.children[index].updateMatrix(); // make sure plane's local matrix is updated
    scene.children[index].updateMatrixWorld();

    if (frustum.containsPoint(scene.children[index])) {
      //stuff happens...
      if (scene.children[index].name === "coin") {
        scene.children[index].rotation.x += 0.01;
        scene.children[index].position.y -= 0.1;
      }
      // console.log("mesh in view Frustrum");
    } else {
      console.log("mesh not in view Frustrum");
    }
  }

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

0

I am trying to detect all objects viewable by the camera

You don't need raycasting for this. Instead, setup an instance of Frustum based on the projection and view matrix of your camera via setFromProjectionMatrix(). In the next step, use intersectsObject() to detect whether a 3D object is inside the camera's view frustum (the viewable area of the 3D scene) or not.

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