Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

field.distance

How far each element's position is from a target, as a Float field. The target is the wired b field, else the fixed point.

Inputs

  • a (Field<Vec3> | Vec3). The positions being measured, one per element.
  • b (Field<Vec3> | Vec3, optional). What each element is measured to, per element: a second position field, so the target can move with the element. Wired, it stands in for point.
  • point (Vec3). Default { x = 0, y = 0, z = 0 }. One fixed position every element is measured to, used when b is left unwired: how a radial falloff around a place is built.

Outputs

  • field: a Float field, the distance at each element.

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.distance({ a = g.field.position(), point = vector.create(3, 0, 0) }) })

The points at x = -1.5, -0.5, 0.5, 1.5 are 4.5, 3.5, 2.5 and 1.5 from (3, 0, 0).