hello i’m trying to raycast a mouseevent to fabric canvas. It’s working on my vanilla but rn the 3d model is different.
Last time i was using only 1 mesh (mesh-out), but rn i have 3 meshes (mesh-in, mesh-out,zipper)
//on my vanilla i use this code
let intersects: any = getIntersects(onClickPosition, object.children)
//object is the object data
and on my code rn i need to use this, so that the getIntersects
return value, it only raycasting the mesh-in, but it should be giving me mesh-out
let intersects: any = getIntersects(onClickPosition, scene.children)
if i do this
let intersects: any = getIntersects(onClickPosition, nodes.M740158_mesh_out)
getIntersects
returns me nothing in fact it raycasting mesh behind/inside what i was clicking to. what should i use then?
I would create an meshes-array and push all your meshes and their children (looping through mesh children). Then make sure the array inherits all your meshes to intersect with and in the end pass just that array.
If this won’t work, then try your meshes on other examples of raycaster, like this, to make sure its not your implementation:
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - interactive cubes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="main.css">
<style>
body {
background-color: #f0f0f0;
color: #444;
}
a {
color: #08f;
}
</style>
</head>
<body>
<div id="info">
This file has been truncated. show original
https://codepen.io/ricardcreagia/embed/EdEGod
In worst case, you might need to customize your own raycaster, that can handle meshes inside each other.