copy/paste error?
I thought, but now this is the code:
try{
for(let i1 in trunk_mesh){
if(trunk_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete trunk_mesh[i1]
}
}
for(let i1 in leaves_mesh){
if(leaves_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete leaves_mesh[i1]
}
}
for(let i1 in trueBlockBox_mesh){
if(trueBlockBox_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete trueBlockBox_mesh[i1]
}
}
for(let i1 in cooper_mesh){
if(cooper_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete cooper_mesh[i1]
}
}
for(let i1 in iron_mesh){
if(iron_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete iron_mesh[i1]
}
}
for(let i1 in gold_mesh){
if(gold_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete gold_mesh[i1]
}
}
for(let i1 in lead_mesh){
if(lead_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete lead_mesh[i1]
}
}
for(let i1 in coal_mesh){
if(coal_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete coal_mesh[i1]
}
}
for(let i1 in sulphur_mesh){
if(sulphur_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete sulphur_mesh[i1]
}
}
for(let i1 in potassium_mesh){
if(potassium_mesh[i1].c.position.distanceTo(camera.position)>chunkSize*renderDistance*2){
delete potassium_mesh[i1]
}
}
}catch(e){}
And the scene is the same, with no diference compared to the code previous of this function.
You can’t use top-level delete
(!). I invite you to remove the mesh from the scene/group. Also dispose of the texture, except three can reuse textures. InstancedMesh patterns would be more appropos (¹). Loop your scene each frame is CPU-side, and GPU blocks block blocks.
Update: I meant in my COVID simulator I pushed dirty data to a bin and destroyed it with an anonymous interval.
¹ prooper
How? I used scene.remove and scene.geometry.dispose and scene.material.dispose and the meshes farther than render distance didnt deleted.
EDIT:
for(i1 in trueBlockBox_mesh){
scene.remove(trueBlockBox_mesh[i1].c);
trueBlockBox_mesh[i1].c.geometry.dispose();
trueBlockBox_mesh[i1].c.material.dispose();
trueBlockBox_mesh[i1].c = undefined;
}
doesnt work too. Its says geometry isnt defined…
Each frame, try/catch iterates 1000’s of meshes. Any (reference) error condition will terminate early. You may or may not check for objects that may or may not be.
I tried to use my personal code for the instancedmesh, so there are it:
The trees are hidding the block horizon, and the fps ran at 40-50 fps this time.
I see why shadow texture may help. I feel like I’m syncing with a mobx store 1000 times a second.
Shadow Texture is laggy…
And sorry if i may be rude or somewhat but i actually dont know how to apply shadows to minecraft clone.
EDIT:
If u want, may I close this post and the others…
How is this related to threejs?
nothing, im deleting now this post, if i can…