roles.assign
A copy of a value with host roles added to or removed from chosen points or primitives.
Usage
Roles.assign(geometry: VerbInput, options: RolesAssignOptions): Result<VerbValue>Parameters
geometryGeometry | VerbValueThe value to change; the input is not modified.
options.domain'point' | 'primitive'Which elements change. Default
'primitive'.options.indicesnumber[]The elements changed; without it and whereRole, every element of the domain. Required. In index.
options.whereRolestringWithout indices: the elements holding this role.
options.addstring[]Host roles to add, <namespace>:<name>.
options.removestring[]Host roles to remove.
options.policy{ generated?: 'copy' | 'drop', merged?: 'union' | 'intersect' }The policy of added roles the value does not hold yet; a role keeps the policy it has. Default
{ generated: 'copy', merged: 'union' }.
Returns
Ok with a VerbValue (its ref names the new value; the caller frees it); data has ref, contentHash, the number of elements targeted and of distinct roles.
Errors
Guarantees
- every targeted element holds every added role and none of the removed ones; every other element keeps its roles
- kernel roles are never added or removed
- the same input and options give the same ref and the same content hash
- The same result on every machine.
Example
Roles.assign(Mesh.box().value, { indices: [0], add: ['fx:skin'] }) // → a VerbValue whose face 0 is fx:skin once loadGeometryKernel() has run