Error handling in three js

Hello Three js Team,

I check on react we have one concept call the error boundaries that help to show an user friendly error message but i need some functionality in three js any help.
Means i see that when my three js code fails to my screen turn out to be blank i dont need that please if some one suggest me something to achieve my task

Any form of error handling has to be handled on app level. three.js does not provide any form of UI elements to communicate an error situation. So you what you have to do is ordinary JavaScript error handling e.g. via try/catch.

1 Like

@Mugen87 i know that three js is simply javascript i only post the ticket to see if some thing is available
There is one more query for you if you can help so please
For my dxf terrain the raycasting is not working i am not able to get the intersects
let intersects = raycaster.intersectObjects([object], true);
dxf-terrain

even i set the layers too any specific reason

and i got one ticket for advance tutorial is it from the three js team ?

let raycaster = new THREE.Raycaster(point, projectionVector)

raycaster.layers = window.mainContainer && window.mainContainer.getCamera().layers

raycaster.firstHitOnly = true

let intersects = raycaster.intersectObjects([object], true);

here point = Vector3 {x: -0.10748505814204007, y: -0.027587346732616425, z: 0.11825445265238115}
projectionVector = Vector3 {x: 0, y: -1, z: 0}
mesh position = Vector3 {x: 0, y: 0.028, z: 0}
camera position is Vector3 {x: 0.25813433968370547, y: 0.3659489708080761, z: 0.2572327399580828}

is that any issue with my raycasting setup ?

if you are using react, and if you drive threejs in jsx via react-three-fiber, react error boundaries work as usual. as well as suspense. i would definitively recommend it. threejs doesn’t have any means to handle errors, you’ll be trycatching. not that it should.

example: https://codesandbox.io/s/r3f-basic-demo-3s98o?file=/src/index.js

(codesandbox has these weird error overlays in dev mode, you can click the X and it goes away, then you see the error representation.)