In many cases applications will need to filter 3D nodes by some custom data source or mechanism. This
is done by extending the NodeCollectionBase
-class. This class generates an IndexSet
and
provides notification when the set has changed. Implementations should
be non-blocking - slow operations should be executed async and the set should
be incrementally updated to avoid blocking the viewer.
Simple, static node collection
See also guide on (de)serializing node collections.
Details about IndexSet
IndexSet
is a specialized implementation of Set<number>
that is optimized for storing ranges of numbers. This is a common case for nodes as typically a
subtree will have the same styling applied.
Although IndexSet
supports adding and removing individual elements using add()
and remove()
, the best
performance is achieved by using addRange()
and removeRange()
whenever possible.
Also note that changes to the underlying IndexSet
held by a NodeCollectionBase
isn't automatically propagated
to be visible in the rendered result. In order to trigger an update after changing the underlying IndexSet
,
use NodeCollectionBase.notifyChanged()
(protected function). Note that this function should not be triggered too often
as it might take some time to apply the changes.