|
4821 | 4821 | currentSceneToken = newSceneMesh && newSceneMesh.token; |
4822 | 4822 |
|
4823 | 4823 | if (trayMesh.visible) { |
| 4824 | + const _getCurrentTokenColor = token => { |
| 4825 | + if (token.owner !== NULL_ADDRESS) { |
| 4826 | + if (token.owner === _getUserAddress()) { |
| 4827 | + if (token.id) { |
| 4828 | + return 0x9ccc65; |
| 4829 | + } else { |
| 4830 | + return 0x42a5f5; |
| 4831 | + } |
| 4832 | + } else { |
| 4833 | + return 0x78909c; |
| 4834 | + } |
| 4835 | + } else { |
| 4836 | + return 0xef5350; |
| 4837 | + } |
| 4838 | + }; |
| 4839 | + const _getNonCurrentTokenColor = token => { |
| 4840 | + if (token.owner === _getUserAddress()) { |
| 4841 | + if (token.id) { |
| 4842 | + return 0x5c6bc0; |
| 4843 | + } else { |
| 4844 | + return 0x42a5f5; |
| 4845 | + } |
| 4846 | + } else { |
| 4847 | + return 0x78909c; |
| 4848 | + } |
| 4849 | + }; |
| 4850 | + |
4824 | 4851 | for (let i = 0; i < guardianMeshes.length; i++) { |
4825 | 4852 | const guardianMesh = guardianMeshes[i]; |
4826 | 4853 | guardianMesh.destroy(); |
|
4834 | 4861 |
|
4835 | 4862 | for (let i = 0; i < sceneMeshes.length; i++) { |
4836 | 4863 | const sceneMesh = sceneMeshes[i]; |
4837 | | - if (sceneMesh.token.id !== 0 && sceneMesh.token !== currentSceneToken && sceneMesh.token !== selectedSceneToken) { |
4838 | | - const baseMesh = _makeBaseMesh(sceneMesh.token, 0x5c6bc0); |
| 4864 | + if (sceneMesh.token.owner !== NULL_ADDRESS && sceneMesh.token !== currentSceneToken && sceneMesh.token !== selectedSceneToken) { |
| 4865 | + const baseMesh = _makeBaseMesh(sceneMesh.token, _getNonCurrentTokenColor(sceneMesh.token)); |
4839 | 4866 | _insertBefore(baseMesh, floorMesh); |
4840 | 4867 | baseMeshes.push(baseMesh); |
4841 | 4868 | } |
|
4846 | 4873 | id: 0, |
4847 | 4874 | coords: [coords], |
4848 | 4875 | apps: [], |
| 4876 | + owner: NULL_ADDRESS, |
4849 | 4877 | }; |
4850 | | - const sceneColor = sceneToken.id !== 0 ? 0x9ccc65 : 0xef5350; |
| 4878 | + const sceneColor = _getCurrentTokenColor(sceneToken); |
4851 | 4879 |
|
4852 | 4880 | const guardianMesh = _makeGuardianMesh(sceneToken, sceneColor); |
4853 | 4881 | scene.add(guardianMesh); |
|
4879 | 4907 | for (;;) { |
4880 | 4908 | const index = sceneMeshes.findIndex(sceneMesh => !sceneMesh.token.coords.some(coord => neededKeys[_getKey(coord[0], coord[1])])); |
4881 | 4909 | if (index !== -1) { |
4882 | | - sceneMeshes[index].destroy(); |
| 4910 | + const sceneMesh = sceneMeshes[index]; |
| 4911 | + sceneMesh.destroy(); |
| 4912 | + scene.remove(sceneMesh); |
4883 | 4913 | sceneMeshes.splice(index, 1); |
4884 | 4914 | } else { |
4885 | 4915 | break; |
|
0 commit comments