Skip to content
This repository was archived by the owner on Jan 24, 2020. It is now read-only.

Commit 81ee113

Browse files
author
Avaer Kazmer
committed
Bugfix block refresh
1 parent 6fbb59a commit 81ee113

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

index.html

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,16 +2036,6 @@
20362036
const {scene: sceneSpec, owner} = token;
20372037
const _isValid = () => !sceneSpec.id || !sceneMeshes.some(sceneMesh => sceneMesh.token.id === sceneSpec.id);
20382038
if (_isValid()) {
2039-
const _setDefaultSubMesh = () => {
2040-
if (_isInMultiverse() && owner === NULL_ADDRESS) {
2041-
const sceneSubMesh = _makeMiningMesh(token.x, token.y);
2042-
object.add(sceneSubMesh);
2043-
} else {
2044-
const sceneSubMesh = _makeMiningPlaceholderMesh(x, z, owner);
2045-
object.add(sceneSubMesh);
2046-
}
2047-
};
2048-
20492039
object.token = sceneSpec;
20502040
if (sceneSpec.id) {
20512041
const {coords, apps} = sceneSpec;
@@ -2097,7 +2087,16 @@
20972087
lastSceneCoords[0] = NaN;
20982088
lastSceneCoords[1] = NaN;
20992089
} else {
2100-
_setDefaultSubMesh();
2090+
if (_isInMultiverse() && owner === NULL_ADDRESS) {
2091+
const sceneSubMesh = _makeMiningMesh(x, z);
2092+
object.add(sceneSubMesh);
2093+
} else {
2094+
const sceneSubMesh = _makeMiningPlaceholderMesh(x, z, owner);
2095+
object.add(sceneSubMesh);
2096+
}
2097+
2098+
lastSceneCoords[0] = NaN;
2099+
lastSceneCoords[1] = NaN;
21012100
}
21022101
} else { // other scene beat us to it
21032102
object.destroy();
@@ -4929,31 +4928,29 @@
49294928
}
49304929
}
49314930

4932-
// if (user) {
4933-
const neededKeys = {};
4934-
for (let dx = coords[0] - 1; dx <= coords[0] + 1; dx++) {
4935-
for (let dz = coords[1] - 1; dz <= coords[1] + 1; dz++) {
4936-
let sceneMesh = sceneMeshes.find(sceneMesh => sceneMesh.token.coords.some(coord => coord[0] === dx && coord[1] === dz))
4937-
if (!sceneMesh) {
4938-
sceneMesh = _loadSceneMeshFromCoords(dx, dz);
4939-
scene.add(sceneMesh);
4940-
sceneMeshes.push(sceneMesh);
4941-
}
4942-
neededKeys[_getKey(dx, dz)] = true;
4931+
const neededKeys = {};
4932+
for (let dx = coords[0] - 1; dx <= coords[0] + 1; dx++) {
4933+
for (let dz = coords[1] - 1; dz <= coords[1] + 1; dz++) {
4934+
let sceneMesh = sceneMeshes.find(sceneMesh => sceneMesh.token.coords.some(coord => coord[0] === dx && coord[1] === dz))
4935+
if (!sceneMesh) {
4936+
sceneMesh = _loadSceneMeshFromCoords(dx, dz);
4937+
scene.add(sceneMesh);
4938+
sceneMeshes.push(sceneMesh);
49434939
}
4940+
neededKeys[_getKey(dx, dz)] = true;
49444941
}
4945-
for (;;) {
4946-
const index = sceneMeshes.findIndex(sceneMesh => !sceneMesh.token.coords.some(coord => neededKeys[_getKey(coord[0], coord[1])]));
4947-
if (index !== -1) {
4948-
const sceneMesh = sceneMeshes[index];
4949-
sceneMesh.destroy();
4950-
scene.remove(sceneMesh);
4951-
sceneMeshes.splice(index, 1);
4952-
} else {
4953-
break;
4954-
}
4942+
}
4943+
for (;;) {
4944+
const index = sceneMeshes.findIndex(sceneMesh => !sceneMesh.token.coords.some(coord => neededKeys[_getKey(coord[0], coord[1])]));
4945+
if (index !== -1) {
4946+
const sceneMesh = sceneMeshes[index];
4947+
sceneMesh.destroy();
4948+
scene.remove(sceneMesh);
4949+
sceneMeshes.splice(index, 1);
4950+
} else {
4951+
break;
49554952
}
4956-
// }
4953+
}
49574954
}
49584955
};
49594956
_updateScene();

0 commit comments

Comments
 (0)