etherealengine
etherealengine copied to clipboard
Reactivity improvements
- MediaComponent and VideoComponent improvements
- Using reactive logic to bind VideoComponent entities to a MediaComponent source on a different entity
- This allows multiple video entities to share the same media source
- Using reactive logic to bind VideoComponent entities to a MediaComponent source on a different entity
- defineComponent typings improvement: extra component properties can be added
- NameComponent - updated to newer defineComponent api
- Added reactive NameComponent.entitiesByName map
- UUIDComponent - updated to newer defineComponent api
- Reactive UUIDComponent.entitiesByUUID map
- addEntityReactor(): Why this API?
- Complex queries that require matching data patterns across multiple entities which may enter/exit at different times can now be implemented very easily via React
- React-style reactivity makes it easy to intuitively handle more edge-cases which would otherwise require complex inter-frame logic and bookkeeping
- Previously, it was only safe to place reactive logic (via hook stateβs subscribable plugin) for components within the onAdd function, due to how hookstateβs subscribable plugin works (no unsubscribe functionality meant subscriptions were permanent, making it difficult to add temporary reactive logic to an entity). Attaching multiple reactors to an entity is perfectly fine, since these can aggregatively be added/removed within the lifetime of the entity.
- With React Concurrent Mode, all reactive side-effects are automatically batched, scheduled by priority and spread across frames, and interruptible/cancelable if in mid-transition, all which can help maintain a steady framerate if we leverage it well