SceneFilter

View source

Filters live scene component and resource type IDs during Scene#toWorld.

SceneFilterMode.Allow admits only listed IDs, while SceneFilterMode.Deny admits every ID except those listed. An empty allow-list therefore rejects every type, and an empty deny-list allows every type. The filter decides eligibility only; it does not alter the scene snapshot or the supplied type IDs.

Examples

import { SceneFilter, SceneFilterMode } from '@wimaengine/scene'
import { Position2D, Scale2D } from '@wimaengine/transform'
import { typeid } from '@wimaengine/type'

const filter = new SceneFilter(
  [typeid(Position2D)],
  SceneFilterMode.Allow
)

filter.allows(typeid(Position2D)) // true
filter.allows(typeid(Scale2D)) // false

Constructor


constructor(typeIds?: TypeId[], mode?: number)

View source

Creates a scene type filter.

With the default SceneFilterMode.Allow mode, only the supplied type IDs are allowed. Pass SceneFilterMode.Deny to allow every type ID not in the array. The array is retained rather than copied.

Parameters

NameDescriptionDefault
typeIds?—[]
mode?—SceneFilterMode.Allow

Properties


Methods


allows(typeId: TypeId): boolean

View source

Tests whether a scene component or resource type may be restored.

Allow returns true when typeId is listed; Deny returns true when it is not listed. This method does not mutate the filter.

Parameters

NameDescriptionDefault
typeId——

Returns

Whether the type ID passes the configured filter mode.