roles.assign

A copy of a value with host roles added to or removed from chosen points or primitives.

GeometricSince 0.15.0

Usage

TypeScript
Roles.assign(geometry: VerbInput, options: RolesAssignOptions): Result<VerbValue>

Parameters

  • geometryGeometry | VerbValue

    The value to change; the input is not modified.

    Required

  • 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.whereRolestring

    Without indices: the elements holding this role.

    Required

  • options.addstring[]

    Host roles to add, <namespace>:<name>.

    Required

  • options.removestring[]

    Host roles to remove.

    Required

  • 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

TypeScript
Roles.assign(Mesh.box().value, { indices: [0], add: ['fx:skin'] }) // → a VerbValue whose face 0 is fx:skin once loadGeometryKernel() has run

See also