Builtin Library
- ..
- .metadata232 B
- README.md2.9 KB
- init.luau5.9 KB
- pose.module
README.md
points.pose (procNode)
Compose the instance attributes of points into one pose: P, orient and scale. The order is pivot, then scale (scale times pscale), then orientation (orient, else the alignment of N, else of v, with +Z along the direction and +Y toward up), then rot after it, then translation (trans plus P). An attribute a point lacks is identity: no pivot, scale 1, unrotated, no extra translation. Reads P, orient, scale, N, v, up, pscale, rot, trans and pivot. Use it before prefab.from_instances, an instancer or anything else that reads only P, orient and scale.
What each attribute reads as, and what a missing one reads as:
| Attribute | Type | Missing reads as | Role |
|---|---|---|---|
P | Vec3 | (required) | where the pivot lands, before trans |
orient | Vec4 quaternion (x, y, z, w) | see below | the base orientation; wins over N and v |
N | Vec3 | see below | turns +Z onto it when the points carry no orient |
v | Vec3 | see below | turns +Z onto it when the points carry neither orient nor N |
up | Vec3 | (0, 1, 0) | where +Y leans while N or v aims +Z |
rot | Vec4 quaternion | (0, 0, 0, 1) | a further turn applied after the base orientation |
scale | Vec3 | (1, 1, 1) | per-axis size |
pscale | Float | 1 | uniform size, multiplied into scale |
trans | Vec3 | (0, 0, 0) | added to P |
pivot | Vec3 | (0, 0, 0) | the point of the source, in its own space, that lands on P + trans |
The base orientation is orient when the points carry it, else the alignment of N when they carry it, else the alignment of v, else identity; which one applies is decided once for the whole set, by which attributes the points carry. A zero-length N or v aligns to identity. The composed result is:
orient=rotapplied after the base orientation;scale=scale * pscale;P=P + trans - orient(scale * pivot).
Built from: g.has, g.where, instances.turn, vector.* over sockets.
Inputs
points(Points). Points carrying any of the instance attributes.orientandrotare quaternions (x, y, z, w);scale,trans,pivot,N,vandupare vectors;pscaleis a number.keep(String, default "none"; "none" or "all"). What happens to the instance attributes once composed. "none" removespscale,rot,trans,pivot,up,Nandvfrom the result; "all" keeps them, writing each one the points lacked at the value it was read as (Nandvat (0, 0, 1)).P,orientandscalealways hold the composed pose.
Outputs
points(Points). The points withP,orientandscaleholding the composed pose, and every other attribute they carried.
local spots = g.points.grid({ countX = 3, countZ = 1 })
spots.point.N = g.math.vec3(1, 0, 0)
spots.point.pscale = 2
local posed = g.points.pose({ points = spots })