Grass not longer placed on paths
Still need some optimizations
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -393,17 +393,17 @@ export async function addAssetsOnScene(scene){
|
|||||||
// Checking collisions
|
// Checking collisions
|
||||||
const grassHitbox = new THREE.Box3().setFromObject(choosenGrassModel);
|
const grassHitbox = new THREE.Box3().setFromObject(choosenGrassModel);
|
||||||
collision = false;
|
collision = false;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
// Checking with other objects
|
if (distance < 0.8) {
|
||||||
/*scene.children.forEach(object => {
|
collision = true;console.log('ok');
|
||||||
if (object !== ground && object !== choosenGrassModel) {
|
break;
|
||||||
const distance = choosenGrassModel.position.distanceTo(object.position);
|
|
||||||
|
|
||||||
if (distance < 0.5) {
|
|
||||||
collision = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});*/
|
}
|
||||||
} while (collision);
|
} while (collision);
|
||||||
|
|
||||||
// Adding to scene
|
// Adding to scene
|
||||||
|
|||||||
Reference in New Issue
Block a user