Skip to main content

@physion/app / Exports / VisualFiltersMixin

Class: VisualFiltersMixin

Applies PixiJS filters to a Node's container, from a single object-valued property (visualFilters) edited in the inspector and settable from a script.

Each key is a types.VisualFilterKey and each value is an options object switched on by its enabled flag:

{
"glow": { "enabled": true, "options": { "distance": 15, "outerStrength": 2 } },
"blur": { "enabled": true }
}

Key order is the order the filters are applied in, so the example above blurs the glow. Options left out fall back to the defaults in constants.VISUAL_FILTER_DEFINITIONS. Unrecognized keys are kept in the stored value, so a typo survives a save/load round trip, but are ignored.

No filter code is loaded until a node switches a filter on; once loaded, later changes apply synchronously inside the setter, which keeps screenshots deterministic. Filters apply to the container and everything under it, so a filter on a parent affects its children too.

Animation never goes through the property: update writes onto the built instances every simulation step, so the stored value stays as authored, with no rebuild, property-changed event, multiplayer traffic or undo entries. The stored time and seed are starting values, and a rebuild starts over from them.

Like TextMixin, this is a composition helper rather than a TypeScript mixin: the host node owns one, forwards the property accessor to it, and calls its lifecycle methods. The Mixin suffix keeps it out of NodeFactory.getClassNames.

Constructors

constructor

new VisualFiltersMixin(node, visualFilters?): VisualFiltersMixin

Parameters

NameTypeDefault value
nodeNodeundefined
visualFiltersIVisualFiltersdefaultVisualFilters

Returns

VisualFiltersMixin

Properties

DEFAULT_VISUAL_FILTERS

Static Readonly DEFAULT_VISUAL_FILTERS: IVisualFilters = defaultVisualFilters

Accessors

isAnimated

get isAnimated(): boolean

Returns

boolean


isEmpty

get isEmpty(): boolean

Returns

boolean


node

get node(): Node

Returns

Node


visualFilters

get visualFilters(): IVisualFilters

The raw, user-authored value. Mutating it in place does not rebuild the filters.

Returns

IVisualFilters

set visualFilters(v): void

Parameters

NameType
vIVisualFilters

Returns

void

Methods

destroy

destroy(): void

Called before the container is destroyed. Bumping the generation strands any load still in flight.

Returns

void


update

update(delta): void

Advances the animated filters in place. delta is the fixed simulation step in milliseconds, which makes the animation frame-rate independent and identical on every participant of a session without any syncing.

Parameters

NameType
deltanumber

Returns

void


propertyDescriptors

propertyDescriptors(): IPropertyDescriptor[]

Returns

IPropertyDescriptor[]