|
2036 | 2036 | const {scene: sceneSpec, owner} = token; |
2037 | 2037 | const _isValid = () => !sceneSpec.id || !sceneMeshes.some(sceneMesh => sceneMesh.token.id === sceneSpec.id); |
2038 | 2038 | 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 | | - |
2049 | 2039 | object.token = sceneSpec; |
2050 | 2040 | if (sceneSpec.id) { |
2051 | 2041 | const {coords, apps} = sceneSpec; |
|
2097 | 2087 | lastSceneCoords[0] = NaN; |
2098 | 2088 | lastSceneCoords[1] = NaN; |
2099 | 2089 | } 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; |
2101 | 2100 | } |
2102 | 2101 | } else { // other scene beat us to it |
2103 | 2102 | object.destroy(); |
|
4929 | 4928 | } |
4930 | 4929 | } |
4931 | 4930 |
|
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); |
4943 | 4939 | } |
| 4940 | + neededKeys[_getKey(dx, dz)] = true; |
4944 | 4941 | } |
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; |
4955 | 4952 | } |
4956 | | - // } |
| 4953 | + } |
4957 | 4954 | } |
4958 | 4955 | }; |
4959 | 4956 | _updateScene(); |
|
0 commit comments