Skip to content

Intermact API Reference / @intermact/core / findTrait

Function: findTrait()

findTrait<K>(traits, kind): TraitByKind[K] | undefined

Defined in: packages/core/src/object/traits.ts:228

Capability query: find a trait by kind, typed to its concrete interface. Returns undefined when the object lacks the capability.

Type Parameters

K

K extends "fill" | "stroke" | "morphable" | "parametric" | "text-layout" | "interactive" | "instanced" | "axes-layout" | "geometry-3d" | "rendered-scene"

Parameters

traits

readonly ObjectTrait[]

kind

K

Returns

TraitByKind[K] | undefined

Intermact v1.0 — 文档覆盖 Phase-1 / Phase-2 / Phase-3(全阶段)