Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

93
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda