Grass not longer placed on paths

Still need some optimizations
This commit is contained in:
2024-01-04 18:06:39 +01:00
parent 4ad126d8ab
commit 82e62590a1
2 changed files with 10 additions and 9 deletions

View File

@@ -51,4 +51,5 @@ function animate() {
renderer.render( scene, camera );//Calculating and redering new frame renderer.render( scene, camera );//Calculating and redering new frame
} }
console.log("Ready to render scene, placed objects : "+scene.children.length);
animate(); animate();

View File

@@ -379,7 +379,7 @@ export async function addAssetsOnScene(scene){
return Math.floor(Math.random() * (max - min) ) + min; return Math.floor(Math.random() * (max - min) ) + min;
} }
for (let i = 0; i < 280; i++) { for (let i = 0; i < 140; i++) {
let choosenGrassModel; let choosenGrassModel;
let collision; let collision;
@@ -394,16 +394,16 @@ export async function addAssetsOnScene(scene){
const grassHitbox = new THREE.Box3().setFromObject(choosenGrassModel); const grassHitbox = new THREE.Box3().setFromObject(choosenGrassModel);
collision = false; collision = false;
// Checking with other objects for(let j=0; j<scene.children.length; j++){
/*scene.children.forEach(object => { if (scene.children[j] !== ground && scene.children[j] !== choosenGrassModel) {
if (object !== ground && object !== choosenGrassModel) { const distance = choosenGrassModel.position.distanceTo(scene.children[j].position);
const distance = choosenGrassModel.position.distanceTo(object.position);
if (distance < 0.5) { if (distance < 0.8) {
collision = true; collision = true;console.log('ok');
break;
} }
} }
});*/ }
} while (collision); } while (collision);
// Adding to scene // Adding to scene