davidvgilmore commited on
Commit
fb6b686
·
verified ·
1 Parent(s): 1e27f46

Upload assets/modelviewer-template.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. assets/modelviewer-template.html +50 -0
assets/modelviewer-template.html ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <!-- Import the component -->
6
+ <!--<script src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.1.1/model-viewer.min.js" type="module"></script> -->
7
+ <script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>
8
+
9
+ <script>
10
+ document.addEventListener('DOMContentLoaded', () => {
11
+ const modelViewers = document.querySelectorAll('model-viewer');
12
+
13
+ modelViewers.forEach(modelViewer => {
14
+ modelViewer.addEventListener('load', (event) => {
15
+ const [material] = modelViewer.model.materials;
16
+ let color = [43, 44, 46, 255];
17
+ color = color.map(x => x / 255);
18
+ material.pbrMetallicRoughness.setMetallicFactor(0.1); // 完全金属
19
+ material.pbrMetallicRoughness.setRoughnessFactor(0.7); // 低粗糙度
20
+ material.pbrMetallicRoughness.setBaseColorFactor(color); // CornflowerBlue in RGB
21
+ });
22
+ });
23
+ });
24
+ </script>
25
+
26
+ <style>
27
+ body {
28
+ margin: 0;
29
+ font-family: Arial, sans-serif;
30
+ }
31
+
32
+ .centered-container {
33
+ display: flex;
34
+ justify-content: center;
35
+ align-items: center;
36
+ border-radius: 8px;
37
+ border-color: #e5e7eb;
38
+ border-style: solid;
39
+ border-width: 1px;
40
+ }
41
+ </style>
42
+ </head>
43
+
44
+ <body>
45
+ <div class="centered-container">
46
+ <model-viewer>
47
+ </div>
48
+ </body>
49
+
50
+ </html>