Hey again!!
https://www.babylonjs-playground.com/#HTWJPL#5
This is my PG…asked this before but figured out how to clone. Now the issue is making more than one clone. How to create 2 more houses if possible?
Thank ya
Hey again!!
https://www.babylonjs-playground.com/#HTWJPL#5
This is my PG…asked this before but figured out how to clone. Now the issue is making more than one clone. How to create 2 more houses if possible?
Thank ya
Make a house building function that creates (or clones) the relevant meshes and parents each house mesh part to a common transform node, then simply call that house building function multiple times in a loop with different arguments e.g. house position etc.
Something like this (based on your PG) https://www.babylonjs-playground.com/#HTWJPL#7
Thank ya so very much @inteja this helps alot
I thought that all I had to do was just clone each mesh and number it(box1, box2, etc) never thought about doing a loop. Dont think I saw that within the Clone reading documentation. Also didn’t know there was a house template.
There wouldn’t be anything in the docs about using loops for this purpose as it’s a general programming language feature, not specific to Babylon.js.
Also, there is no “house template” - that’s just what I called it in the example PG. In your use-case it helped to have some hidden meshes (walls and roof) that I called a “template”, that could be cloned in the buildHouse()
function. It keeps the code inside the function cleaner, as we’re just cloning known, existing meshes then enabling the clones.
Sorry to wreck your brain but have to ask
I want to make sure that each house has a different texture so would that be possible with the PG edits you did? Even though mines is extremely simple I thought it would probably be easier to add various materials/textures so each one would be unique. Yours made me think of using an instance moreso than clone.
You would need to use clones (copies) rather than instances if you want separate materials/textures.
In the buildHouse() function you could just add another argument “textureUrl” then inside the function, create a new material and texture with this URL.