Skip to content

Commit

Permalink
sort of garbage fix for selected sausage bug
Browse files Browse the repository at this point in the history
  • Loading branch information
insanj committed Dec 29, 2020
1 parent 7dc8dce commit bd2d2dd
Show file tree
Hide file tree
Showing 4 changed files with 911 additions and 24 deletions.
21 changes: 11 additions & 10 deletions public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ turnAllMaterials = (thing, hex='ffacac', checkSelected=true) => {
// }

if (!thing.children || thing.children.length < 1) {
if (!thing.material) {
return;
}

if (checkSelected) {
selectedSandwichMaterials[thing.uuid] = thing.material.color.getHexString();
}

const hexNum = parseInt(hex, 16);
thing.material.color.setHex(hexNum);
return;
}

Expand All @@ -371,7 +381,7 @@ turnAllMaterials = (thing, hex='ffacac', checkSelected=true) => {
selectedSandwichMaterials = {};

for (let childUUID of Object.keys(materialsToChange)) {
turnAllMaterials(selectedSandwichScene, materialsToChange[childUUID], false)
turnAllMaterials(selectedSandwichScene, 'ffffff', false);
}
} else {
selectedSandwichMaterials = {};
Expand All @@ -382,15 +392,6 @@ turnAllMaterials = (thing, hex='ffacac', checkSelected=true) => {

for (let child of thing.children) {
turnAllMaterials(child, hex, checkSelected);

if (child.material) {
if (checkSelected) {
selectedSandwichMaterials[child.uuid] = child.material.color.getHexString();
}

const hexNum = parseInt(hex, 16);
child.material.color.setHex(hexNum);
}
}
}

Expand Down
34 changes: 20 additions & 14 deletions public/sausages.gltf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
{
"name": "Scene",
"nodes": [
4,
5,
6
7
]
}
],
Expand All @@ -34,7 +32,7 @@
4.023137796754443,
1
],
"name": "Cube.006_Cube.007",
"name": "Cube006_Cube007_2",
"mesh": 0
},
{
Expand All @@ -56,7 +54,7 @@
3.593443194115111,
1
],
"name": "Cube.005_Cube.006",
"name": "Cube005_Cube006",
"mesh": 1
},
{
Expand All @@ -78,7 +76,7 @@
4.848,
1
],
"name": "Cube.002_Cube.003",
"name": "Cube002_Cube003",
"mesh": 2
},
{
Expand All @@ -100,7 +98,7 @@
5.969,
1
],
"name": "Cube.001_Cube.002",
"name": "Cube001_Cube002",
"mesh": 3
},
{
Expand All @@ -122,7 +120,7 @@
-3.012393204776683,
1
],
"name": "Butcher's meat.obj",
"name": "Butcher's_meatobj",
"children": [
0,
1,
Expand All @@ -132,24 +130,24 @@
},
{
"matrix": [
0.12500000000000003,
0.125,
0,
0.21650635094610965,
0.21650635094610962,
0,
0,
0.25,
0,
0,
-0.21650635094610965,
-0.21650635094610962,
0,
0.12500000000000003,
0.125,
0,
-2.4394169684058244,
-0.22062477262467106,
-1.8949344427538803,
1
],
"name": "Cube.006_Cube.007",
"name": "Cube006_Cube007",
"mesh": 0
},
{
Expand All @@ -171,8 +169,16 @@
-0.13393163398216723,
1
],
"name": "Cube.006_Cube.007",
"name": "Cube006_Cube007_1",
"mesh": 0
},
{
"name": "sausages_old.gltf",
"children": [
4,
5,
6
]
}
],
"bufferViews": [
Expand Down
Loading

0 comments on commit bd2d2dd

Please sign in to comment.