Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] Allow World.add to take a setup function as an optional second argument #263

Open
hmans opened this issue Nov 14, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@hmans
Copy link
Owner

hmans commented Nov 14, 2022

This is just some convenience glue to make initializing newly created entities a little easier without requiring the user to store them in a variable first.

As is:

const entity = world.add({
  transform: new Mesh(
    new DodecahedronGeometry(),
    new MeshStandardMaterial({ color: "orange" })
  )
})

entity.transform.position.set(-3, 0, 0)

To be:

world.add({
  transform: new Mesh(
    new DodecahedronGeometry(),
    new MeshStandardMaterial({ color: "orange" })
  )
}, (entity) => { 
  entity.transform.position.set(-3, 0, 0)
})
@hmans hmans added the enhancement New feature or request label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant