fenomas / noa

Experimental voxel game engine.
MIT License
615 stars 88 forks source link

Does NOA support child meshes? #192

Closed eran-sefirot closed 1 year ago

eran-sefirot commented 1 year ago

Hello! Thanks for this great package, I am experiencing an issue where child meshes are not positioned correctly after "checkWorldOffset" completes.

I simply add a text mesh above a simple mash - which works fine, but after player entity gets close enough the child mesh (text above ball) is re-positioned incorrectly.

Thanks! :)

fenomas commented 1 year ago

Hmm, that should work correctly - the engine repositions meshes when the player moves a certain distance (25 blocks by default) but it should handle parented meshes correctly.

It seems to work okay for me with code like this:

var box = CreateBox('', {}, noa.rendering.getScene())
box.position.set(1, 1, 1)
box.parent = playerMesh
noa.rendering.addMeshToScene(box)

Can you post code that shows the issue?

eran-sefirot commented 1 year ago

Thanks, that worked! I was trying to add the mesh as an entity using noa.entities.add instead of using addMeshToScene.

another question - is there a way to add a skybox? /change the sky color?

Appreciate the quick response! Thanks again for this great package !

On Tue, May 2, 2023 at 6:22 PM Andy Hall @.***> wrote:

Hmm, that should work correctly - the engine repositions meshes when the player moves a certain distance (25 blocks by default) but it should handle parented meshes correctly.

It seems to work okay for me with code like this:

var box = CreateBox('', {}, noa.rendering.getScene())box.position.set(1, 1, 1)box.parent = playerMeshnoa.rendering.addMeshToScene(box)

Can you post code that shows the issue?

— Reply to this email directly, view it on GitHub https://github.com/fenomas/noa/issues/192#issuecomment-1531669324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWXQ6QEH3LHGLIJDDDEIF3TXEERDZANCNFSM6AAAAAAXS7XAIA . You are receiving this because you authored the thread.Message ID: @.***>

fenomas commented 1 year ago

Ah good! entities.add is for when you want to add an "entity" - a thing that can have its own position, mesh, physics and so on.

For the sky color, you can pass the option clearColor: [1,1,1] when creating the engine - this is the color that is drawn to the canvas before meshes are rendered, so it's effectively the sky color.

For a skybox, basically that should work like in any Babylon project; the only noa-specific thing is that you need to call noa.rendering.addMeshToScene so that the mesh will get selected for rendering.