etherealengine icon indicating copy to clipboard operation
etherealengine copied to clipboard

Reactivity improvements

Open speigg opened this issue 2 years ago β€’ 0 comments

  • 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
  • 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

speigg avatar Oct 03 '22 22:10 speigg