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

Commit e30a22b

Browse files
author
Avaer Kazmer
committed
Update scene colors rendering
1 parent 5be6282 commit e30a22b

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

index.html

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,6 +4821,33 @@
48214821
currentSceneToken = newSceneMesh && newSceneMesh.token;
48224822

48234823
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+
48244851
for (let i = 0; i < guardianMeshes.length; i++) {
48254852
const guardianMesh = guardianMeshes[i];
48264853
guardianMesh.destroy();
@@ -4834,8 +4861,8 @@
48344861

48354862
for (let i = 0; i < sceneMeshes.length; i++) {
48364863
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));
48394866
_insertBefore(baseMesh, floorMesh);
48404867
baseMeshes.push(baseMesh);
48414868
}
@@ -4846,8 +4873,9 @@
48464873
id: 0,
48474874
coords: [coords],
48484875
apps: [],
4876+
owner: NULL_ADDRESS,
48494877
};
4850-
const sceneColor = sceneToken.id !== 0 ? 0x9ccc65 : 0xef5350;
4878+
const sceneColor = _getCurrentTokenColor(sceneToken);
48514879

48524880
const guardianMesh = _makeGuardianMesh(sceneToken, sceneColor);
48534881
scene.add(guardianMesh);
@@ -4879,7 +4907,9 @@
48794907
for (;;) {
48804908
const index = sceneMeshes.findIndex(sceneMesh => !sceneMesh.token.coords.some(coord => neededKeys[_getKey(coord[0], coord[1])]));
48814909
if (index !== -1) {
4882-
sceneMeshes[index].destroy();
4910+
const sceneMesh = sceneMeshes[index];
4911+
sceneMesh.destroy();
4912+
scene.remove(sceneMesh);
48834913
sceneMeshes.splice(index, 1);
48844914
} else {
48854915
break;

0 commit comments

Comments
 (0)