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
}
console.log("Ready to render scene, placed objects : "+scene.children.length);
animate();

View File

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