Spaces:
Running
on
Zero
Running
on
Zero
Update assets/modelviewer-template.html
Browse files- assets/modelviewer-template.html +12 -12
assets/modelviewer-template.html
CHANGED
|
@@ -11,10 +11,10 @@
|
|
| 11 |
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
| 12 |
|
| 13 |
modelViewers.forEach(modelViewer => {
|
| 14 |
-
modelViewer.setAttribute(
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
);
|
| 18 |
// if (!isSafari) {
|
| 19 |
// modelViewer.setAttribute(
|
| 20 |
// "environment-image",
|
|
@@ -30,14 +30,14 @@
|
|
| 30 |
// material.pbrMetallicRoughness.setBaseColorFactor(color); // CornflowerBlue in RGB
|
| 31 |
// });
|
| 32 |
// }
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
});
|
| 42 |
});
|
| 43 |
</script>
|
|
|
|
| 11 |
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
| 12 |
|
| 13 |
modelViewers.forEach(modelViewer => {
|
| 14 |
+
// modelViewer.setAttribute(
|
| 15 |
+
// "environment-image",
|
| 16 |
+
// "/static/env_maps/gradient.jpg"
|
| 17 |
+
// );
|
| 18 |
// if (!isSafari) {
|
| 19 |
// modelViewer.setAttribute(
|
| 20 |
// "environment-image",
|
|
|
|
| 30 |
// material.pbrMetallicRoughness.setBaseColorFactor(color); // CornflowerBlue in RGB
|
| 31 |
// });
|
| 32 |
// }
|
| 33 |
+
modelViewer.addEventListener('load', (event) => {
|
| 34 |
+
const [material] = modelViewer.model.materials;
|
| 35 |
+
let color = [43, 44, 46, 255];
|
| 36 |
+
color = color.map(x => x / 255);
|
| 37 |
+
material.pbrMetallicRoughness.setMetallicFactor(0.1); // 完全金属
|
| 38 |
+
material.pbrMetallicRoughness.setRoughnessFactor(0.7); // 低粗糙度
|
| 39 |
+
material.pbrMetallicRoughness.setBaseColorFactor(color); // CornflowerBlue in RGB
|
| 40 |
+
});
|
| 41 |
});
|
| 42 |
});
|
| 43 |
</script>
|