Im trying to find out which faces and points are intersected by the 3D curve.
codes can be found in Three default - JSFiddle - Code Playground
I looked into three.js docs Raycaster but it used for mouse picking.
You can’t use
Raycaster for this since it performs ray intersections tests with 3D objects. And rays are considered to be straight, starting from an origin and extending infinitely.
For curves like a bezier curve you can only implement an approximation. Meaning you divide the curve into a sequence of line segments and then perform for each one an intersection test with all triangles of the mesh. The mathematical representation of a line segment in
three.js is the Line3 class. However, there is no method for a line segment/triangle intersection test. You have to write this code on your own. Possible reference:
BTW: If you want to define a curve in
three.js, use the
Path class. Not
Shape which is intended for closed 2D shapes.
Thanks Mugen! You are a life savior!This should do the job!And thanks for the advice!I’ll change the curve construct method ,use path instead of shapes.It’s really a good one,save me from coding a chunk of 2D to 3D codes!