Search the Community
Showing results for tags 'merging'.
-
Hello guys! First of all I would like to thank you for all your valuable comments on this forum. I’ve found basically all answers to my questions digging up this forum. I’m trying to make a simulation/rpg like game with Babylon and I'm experimenting with procedural generation and content streaming. I need help on two (probably related) questions: https://playground.babylonjs.com/#SCV25U#6 1 Z-Fighting / Flickering on Mobile. I’ve noticed that some meshes are flickering on mobile (especially the ones who are generated on click). I thought could be some Z-Fighting problem and I moved the ground generation before the trees generation, doing this has solved the issue only on the meshes who are generated on load, not on the meshes generated on con click. I’ve also tried various ways of click picking / invisible mesh combination but nothing changed apparently. I need to try with no overlapping visible meshes, but I still need an overlapping invisible plane to detect the click. 2 Merging / Instancing doubts. Merging a big group of boxes has really amazing FPS performance (even on mobile with a large world), but freezes the browser. So I’ve splitted and delayed the merging execution, still freezing but it looks better. I’ve tried with ribbons, amazing performance and results if you need something like Transport Tycoon, but isn’t what I was looking for. Instancing a big group of boxes has no freezing at all but really low FPS rate, I need to try to use a box without 2 useless faces, but I suppose the FPS rate will be much the same. Clues on solving this or ideas about different approaches will be really appreciated. Thanks, Marco.
- 3 replies
-
- z-fighting
- merging
-
(and 2 more)
Tagged with:
-
Hello! I am working on a voxel project and creating a very basic voxel player. It has a box as head, a bigger box for body, etc. I created the whole thing like this: this.player_head = BABYLON.MeshBuilder.CreateBox(PLAYER_HEAD, {size: 1, updatable: true}, scene); this.player_body = BABYLON.MeshBuilder.CreateBox(PLAYER_BODY, {width: 1, depth: 0.5, height: 1.5, updatable: true}, scene); this.player_right_arm = BABYLON.MeshBuilder.CreateBox(PLAYER_RIGHT_ARM, {width: 0.5, depth: 0.5, height: 1.5, updatable: true}, scene); this.player_left_arm = BABYLON.MeshBuilder.CreateBox(PLAYER_LEFT_ARM, {width: 0.5, depth: 0.5, height: 1.5, updatable: true}, scene); this.player_right_leg = BABYLON.MeshBuilder.CreateBox(PLAYER_RIGHT_LEG, {width: 0.5, depth: 0.5, height: 1.5, updatable: true}, scene); this.player_left_leg = BABYLON.MeshBuilder.CreateBox(PLAYER_LEFT_LEG, {width: 0.5, depth: 0.5, height: 1.5, updatable: true}, scene); // Head this.player_head.parent = this.player_body; this.player_head.position.y += 1.25; // Right arm this.player_right_arm.parent = this.player_body; this.player_right_arm.position.x += 0.75; // Left arm this.player_left_arm.parent = this.player_body; this.player_left_arm.position.x -= 0.75; // Right leg this.player_right_leg.parent = this.player_body; this.player_right_leg.position.x -= 0.25; this.player_right_leg.position.y -= 1.5; // Left leg this.player_left_leg.parent = this.player_body; this.player_left_leg.position.x += 0.25; this.player_left_leg.position.y -= 1.5; Since I need all the meshes to be treated as a single mesh, I merged them with: BABYLON.Mesh.MergeMeshes([this.player_head, this.player_body, this.player_right_arm, this.player_left_arm, this.player_left_leg, this.player_right_leg]); Until here, all beautiful and nice. But a problem arises: I want to be able to move the arms, legs and head to make some sort of animation for walking but it doesn't seem to work. My player object has the references to all the meshes before the merging, so I thought I would still be able to transform them even after the merging. What's wrong then? Also, is there perchance a better way to create a bunch of simple meshes, apply a specific material to each of them and then 'merging' them into 1 bigger BABYLON.Mesh without losing their individual texture/material? MergeMeshes destroys the materials of the children objects, which is quite bad :/.