Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

function like createEntity should return the entity defined by options.entityClass, not the default Entity. #213

Open
iam-yan opened this issue Jul 18, 2020 · 2 comments
Labels

Comments

@iam-yan
Copy link

iam-yan commented Jul 18, 2020

Issue:
In the library when an entity or entity[] is returned, e.g. createEntity function, the return types now are defined as Entity / Entity[]. But in the constructor of World class, one can pass in {entityClass: CustomEntity} to override the default entityClass, in which case all the relevant returned entity should be CustomEntity.

PS:
I like how A-Frame is designed and wished to apply it in a wider use cases and found ecsy. Thanks a lot for bringing this fantastic project! !

@iam-yan iam-yan changed the title entity type should be options.entityClass instead of Entity function like createEntity should return the entity defined by options.entityClass, not the default Entity. Jul 18, 2020
@fernandojsg fernandojsg added this to the v0.4.0 milestone Jul 29, 2020
@fernandojsg
Copy link
Member

@robertlong do you have any thoughts on this?

@robertlong
Copy link
Member

Maybe we could make the type of World accept an optional generic?

export class World<E = Entity> {
  createEntity(name?: string): E
}

Then you could do something like: World<ECSYThreeEntity>

I also need this in systems for query results:
https://github.com/MozillaReality/ecsy-three/blob/dev/src/core/System.d.ts

It's a slightly larger change, but I think we could do it.

@fernandojsg fernandojsg removed this from the v0.4.0 milestone Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants