Skip to content

v0.6.2 - Blind Curve

Choose a tag to compare

@krispya krispya released this 27 Dec 18:42
· 79 commits to main since this release

The highlight here is an experimental ordered relation feature. It is highly performant to get flat lists of children to iterate over, but some times explicit order is necessary. The ordered relation API provides away to get an ordered view of the children of an entity like you are used to in graphs like a Three scene.

import { relation, ordered } from 'koota'

const ChildOf = relation()
const OrderedChildren = ordered(ChildOf)

const parent = world.spawn(OrderedChildren)
const children = parent.get(OrderedChildren)

children.push(child1) // adds ChildOf(parent) to child1
children.splice(0, 1) // removes ChildOf(parent) from child1

// Bidirectional sync works both ways
child2.add(ChildOf(parent)) // child2 automatically added to list

A bidirectional sync is maintained between the bound relation and the ordered relation view letting you use an array interface or the usual relation API interchangeably. There is also an example added in the apps folder for a Hearthstone style reordering of cards in a hand. Check it out!

This is an experimental feature so please check it out and give feedback.

What's Changed

Feat

  • core: Add ordered relations for ordered lists of entities by @krispya in #201

Fix

Chore

  • examples: Update Revade for latest best practices by @krispya in #202

Full Changelog: v0.6.1...v0.6.2