Builtin Library
README.md
core.points (procNode)
Points made from columns: a count of points, each attribute given as a column, a field or a constant.
Built from the make kernel (SHAPE = "points") for the elements and a point-class write for every entry of columns. The call is g.core.points({ columns = { P = positions, mass = 1.0 }, count = 64 }); count is how many points there are. The elements are made on the device.
Inputs
columns(Record, optional). The attributes, by name: each a column of the point count, a field evaluated over the points, or a constant.Pplaces the points; the other names are carried as point attributes.count(Float). Default0. At least 0. How many points.
What a column takes
Each entry of columns is a field, a Column, a constant, or a list with one entry per point (the table below states every form):
- A field evaluated over the points, such as
vector.create(g.element.id * 2, 0, 0)org.field.noise({ position = g.element.P }): every point takes the field's value at its own element number. - A Column with one element per point: a column another node answers (
g.attribute.read, a column ofcore.entity.read),g.core.column({ values = { ... }, type = "Float" })for numbers given in the graph, org.op.transfer.upload({ values = { P = { type = "Vec3", values = { x0, y0, z0, x1, y1, z1, ... } } } }).Pfor vectors given in the graph, their components laid flat. - A constant every point takes: a number (a Float column) or a vector made by
vector.create(a Vec2, Vec3 or Vec4 column).
Without a P entry the points lie in a row along x from 0 to 1, where core.make places them.
What a column entry can be
| Entry | Becomes |
|---|---|
a field (g.math.vec3(g.element.id * 5, 0, 0), g.element.id % 2) | evaluated over the points: one value each |
| a Column of the point count | the column as it is |
a list of vectors, one per point ({ vector.create(0, 0, 0), vector.create(5, 0, 0) }, or { x, y, z } records) | a numeric Vec2, Vec3 or Vec4 column, one vector per point, every vector of the list one width |
a list of texts or records, one per point ({ "oak", "pine" }) | a column of those values, one per point |
| a number, a vector, a text or a record | that value at every point |
a list of numbers ({ 0, 1, 0 }) | one vector, at every point |
A list of vectors, texts or records holds exactly one entry per point; any other length is refused. A number
that differs per point is a field or a Column: a list of numbers is read as one vector, so { 1, 2, 3 }
over three points gives every point the vector (1, 2, 3).
Outputs
points: the points,countof them, carryingPand every column ofcolumns.
Example
local points = g.core.points({ count = 3, columns = { P = vector.create(g.element.id * 2, 0, 0), mass = 1.5 } })
The three points stand at x = 0, 2 and 4, each with mass 1.5. Positions given as numbers in the graph go through an upload:
local where = g.op.transfer.upload({ values = { P = { type = "Vec3", values = { 0, 0, 0, 1, 0, 0, 3, 0, 0 } } } }).P
local points = g.core.points({ count = 3, columns = { P = where } })