Editor Tool for Curve: Point Alignment

Hello everyone,

I’m creating a tool in the editor using this as a reference: Editor API | PlayCanvas Developer Site.

I’m using this example project as a guide: Camera following a path | PlayCanvas Developer Site.

I know pc.CURVE_CARDINAL is deprecated, but it is working so far.

I could implement pretty much everything based on the project mentioned above, parametrized things, and drew debug lines. It’s working great. The Editor API is really interesting to work with.

The image below is my attempt to explain what I’m trying to achieve. What I want is to align the up direction of the curve point to that platform below it. I first thought about using raycast, but the app doesn’t have Ammo on it. To be honest, I don’t really like the idea (but it would solve my problem).

I saw a topic here discussing snapping to vertices, and it seems that it’s not on the roadmap, so I assume this is not something easy to do.

Is there any option that I could use to achieve what I need? I mean, I’m not looking for code, just for a path to follow that wouldn’t take too much time. I’m not sure if it’s possible, so any idea would be great. Thank you.

1 Like

You could create a list of triangles that you need to intersect using Tri class, and intersect it using Ray.

gizmos here work this way:

Thank you it worked,

i need a few more steps for the alignment, but Tri and Ray worked :smiley:

1 Like

Sorry i was nos supposed to hit enter on my reply :sweat_smile:
So… i have this right now


that i achieve with the Tri an Ray thing.

I now for face it up i need to use normals and i can get them from the mesh, so, it is not supposed to be to hard ( i guess :smile:), but for rotation i dont know.

i want something like this ( i placed it manually of course)

Once again thank you :smiley:

Triangle has 3 points, you can compute a normal of a triangle from those using cross product easily. See here for example:

You can then use entity.lookAt to look at a point:

the point to look at would be the intersection point you already have + the normal

it Worked, thank you again :partying_face:

1 Like