Any way to programmatically draw a polygon?

I have an AR experience I’m designing in studio where I need to plot a surface that is dynamically created using a mathematical function. I can compute arbitraty points on the surface, and I’d like to be able to draw polygons that connect these arbitrary points so that I can tile together lots of triangles or other polygons to make a surface. Is this possible?

Right now what I am doing is placing planes at grid points on my surface, each positioned and rotated to be tangent to the surface and scaled to just cover the space to the neighboring plane, but this gives less than satisfying results as the planes either overlap at points or leave a gap between them (imagine trying to make sphere out of lots of small squares).

I could generate the 3D object outside of zapworks, but then I wouldn’t be able to dynamically change it (other than position, rotation and scale).

Yes, it is. You can generate planes on runtime, and then define their scale, rotation and position according to your algorithm.

Use const newPolygon = Z.Object().type(symbol.mediaFiles.Plane);

Thanks for the reply. That’s is what I am doing now, but this method is limited to producing rectangles. The for the curved surfaces I want to generate I need to be able to produce arbitrary triangular faces. I can calculate the vertex positions easily enough and was hoping there was a way to define faces based off of those vertex positions.

Why would it be limited to producing rectangles? Given 3 arbitraty points, you can use 3 planes to make a triangle. You’d need to stretch, rotate and position the planes correctly.

As far as I can tell the plane object produces a face that is bounded by a rectangle of size set by the scale property and oriented based on the rotation property. I can see how to use this to generate a rectangle of any size and orientation, but not how to produce a triangular face. I can see how to make the outline of a triangle using planes deformed to be like lines along the edges of the triangle, but not how to fill in the triangle as a face.

Oh I see. What you want is much more complex, but it’s possible to make approximate triangles. You can use many very thin planes with fixed rotations adjacent to one another to create a triangle face. It would be an approximation, not an exact triangle. But the math to do this is beyond me. It probably involves integrals and such to come out with a formula to generate these triangle faces approximations out of square planes.