I’m using canvastexture for text on boxgeometry and I’m using it to all the sides of boxgeometry. I’m using raycaster to highlight the canvastexture when the cursor is on the boxgeometry and disable canvastexture when the cursor is not on the boxgeometry .It is working fine!. but, I’m facing issue with different angels. when I rotate the boxgeometry and now when I perform raycaster is not functioning accordingly. If anyone has any advice, any help would be greatly appreciated!
Not really possible to help without seeing the code (at least the part responsible for rotating and raycasting) in this case
if (intersects.length > 0) {
console.log("faceIndex intersects inside " + intersects.length)
for (var i = 0; i < intersects.length; i++) {
var faceIndex = intersects[i].faceIndex;
console.log("faceIndex " + faceIndex)
if (faceIndex > 0) {
console.log("faceIndex this.state.showText " + this.state.showText)
intersected = intersects[0];
// this.attachLabel(this.globalx, this.globaly, this.globalWidth, this.globalHeight, this.globalType, this.globalName);
console.log("faceIndex onTrue " + faceIndex)
} else {
console.log("faceIndex onFalse " + faceIndex)
console.log("faceIndex this.state.showText elsepart " + this.state.showText);
}
}
}
if(this.prevIntersected !== this.currIntersected){
this.prevIntersected = this.currIntersected;
this.attachLabel(this.globalx, this.globaly, this.globalWidth, this.globalHeight, this.globalType, this.globalName);
}
This code isn’t in any way connected to any mesh or the scene - so it’s unlikely it would affect it.
Try opening the devtools console and see if any errors appear at any point - when you rotate the box, when you raycast, especially after when things stop working - errors can prevent stuff from executing further and make it look as if it’s the raycaster that stopped working.
(Also - consider switching all var
s to let
s / const
s - they’ll make your debugging life easier in a long run )
1 Like