Skip to content

Commit b1867b3

Browse files
committed
remove contents prop from client
1 parent ae43b8a commit b1867b3

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

components/lib/parseMaterial.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,26 @@ export function processColorInMaterial(material) {
2626
}
2727

2828
export function processMaterialPropertyContents(material) {
29-
const propsWithMaps = intersection(
29+
const propsToUpdate = intersection(
3030
Object.keys(material),
3131
materialPropertiesWithMaps,
3232
);
33-
34-
return propsWithMaps.reduce((prev, curr) => {
35-
const { contents } = curr;
36-
37-
if (!contents || (!contents.path && !contents.color)) {
38-
return prev;
39-
}
40-
41-
return {
33+
// legacy support for old diffuse.color
34+
const color =
35+
typeof material.diffuse === 'string' || material.color
36+
? material.diffuse || material.color
37+
: undefined;
38+
39+
return propsToUpdate.reduce(
40+
(prev, curr) => ({
4241
...prev,
4342
[curr]: {
4443
...prev[curr],
45-
contents: {
46-
[contents.path ? 'path' : 'color']:
47-
contents.path || processColor(contents.color),
48-
},
44+
color: color ? processColor(color) : processColor(prev[curr].color),
4945
},
50-
};
51-
}, material);
46+
}),
47+
material,
48+
);
5249
}
5350

5451
export { processColor };

components/lib/propTypes.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ export const colorBufferWriteMask = PropTypes.oneOf(
6262
export const opacity = PropTypes.number;
6363

6464
export const materialProperty = PropTypes.shape({
65-
contents: PropTypes.shape({
66-
path: PropTypes.string,
67-
color: PropTypes.string,
68-
}),
65+
path: PropTypes.string,
66+
color: PropTypes.string,
6967
intensity: PropTypes.number,
7068
});
7169

0 commit comments

Comments
 (0)