Spaces:
Configuration error
Configuration error
lyunm1206
commited on
Commit
·
5edacc2
1
Parent(s):
d35cca0
checkbox
Browse files- index.html +8 -1
- kodim08_30_ori.gltf +1 -0
- kodim08_30_sh.gltf +0 -0
- script.js +31 -0
index.html
CHANGED
|
@@ -49,12 +49,19 @@
|
|
| 49 |
shadow-intensity="1"
|
| 50 |
camera-controls
|
| 51 |
camera-orbit="0deg 180deg 90deg"
|
| 52 |
-
exposure="1"
|
| 53 |
>
|
| 54 |
</model-viewer>
|
| 55 |
</div>
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
<!-- Import the model-viewer component -->
|
| 58 |
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
|
|
|
|
| 59 |
</body>
|
| 60 |
</html>
|
|
|
|
| 49 |
shadow-intensity="1"
|
| 50 |
camera-controls
|
| 51 |
camera-orbit="0deg 180deg 90deg"
|
|
|
|
| 52 |
>
|
| 53 |
</model-viewer>
|
| 54 |
</div>
|
| 55 |
|
| 56 |
+
<div>
|
| 57 |
+
<input type="checkbox" id="option1" name="modelOption" checked>
|
| 58 |
+
<label for="option1">Option 1</label><br>
|
| 59 |
+
<input type="checkbox" id="option2" name="modelOption">
|
| 60 |
+
<label for="option2">Option 2</label><br>
|
| 61 |
+
</div>
|
| 62 |
+
|
| 63 |
<!-- Import the model-viewer component -->
|
| 64 |
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
|
| 65 |
+
<script src="script.js"></script>
|
| 66 |
</body>
|
| 67 |
</html>
|
kodim08_30_ori.gltf
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"accessors":[{"bufferView":0,"byteOffset":0,"componentType":5126,"count":2601,"max":[1.0,0.75,-1.2919375896453857],"min":[-0.5,-0.75,-2.28713059425354],"type":"VEC3"},{"bufferView":1,"byteOffset":0,"componentType":5126,"count":2601,"normalized":false,"type":"VEC2"},{"bufferView":2,"byteOffset":0,"componentType":5125,"count":15000,"type":"SCALAR"}],"asset":{"generator":"VTK","version":"2.0"},"bufferViews":[{"buffer":0,"byteLength":31212,"byteOffset":0},{"buffer":1,"byteLength":20808,"byteOffset":0},{"buffer":2,"byteLength":60000,"byteOffset":0},{"buffer":3,"byteLength":273,"byteOffset":0}],"buffers":[{"byteLength":31212,"uri":"buffer467986.bin"},{"byteLength":20808,"uri":"buffer896554.bin"},{"byteLength":60000,"uri":"buffer896555.bin"},{"byteLength":273,"uri":"buffer897054.bin"}],"cameras":[{"perspective":{"aspectRatio":1.6759388038942977,"yfov":0.5235987755982988,"zfar":6.776592528152567,"znear":2.7479295556458134},"type":"perspective"}],"images":[{"bufferView":3,"mimeType":"image/png"}],"materials":[{"pbrMetallicRoughness":{"baseColorFactor":[1.0,1.0,1.0,1.0],"baseColorTexture":{"index":0,"texCoord":0},"metallicFactor":0.0,"roughnessFactor":1.0}}],"meshes":[{"name":"mesh0","primitives":[{"attributes":{"POSITION":0,"TEXCOORD_0":1},"indices":2,"material":0,"mode":4}]}],"nodes":[{"mesh":0,"name":"mesh0"},{"camera":0,"matrix":[0.9930182653242161,-0.08163718488812689,0.08514748837180357,-0.0,-0.07411348376221764,0.1297831131124444,0.9887686964479963,0.0,-0.09177099899811561,-0.988175952750513,0.12282658567469673,-0.0,-0.16541443797724062,-4.47311855069713,-1.2335421379143414,1.0],"name":"Camera Node"},{"children":[0,1],"name":"Renderer Node"}],"samplers":[{"magFilter":9728,"minFilter":9728,"wrapS":33071,"wrapT":33071}],"scene":0,"scenes":[{"name":"Layer 0","nodes":[2]}],"textures":[{"sampler":0,"source":0}]}
|
kodim08_30_sh.gltf
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
script.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 2 |
+
const modelViewer1 = document.getElementById('modelViewer1');
|
| 3 |
+
const modelViewer2 = document.getElementById('modelViewer2');
|
| 4 |
+
const option1 = document.getElementById('option1');
|
| 5 |
+
const option2 = document.getElementById('option2');
|
| 6 |
+
|
| 7 |
+
function updateModels() {
|
| 8 |
+
if (option1.checked) {
|
| 9 |
+
modelViewer1.setAttribute('src', 'path/to/option1_model1.glb');
|
| 10 |
+
modelViewer2.setAttribute('src', 'path/to/option1_model2.glb');
|
| 11 |
+
} else if (option2.checked) {
|
| 12 |
+
modelViewer1.setAttribute('src', 'kodim08_30_ori.gltf');
|
| 13 |
+
modelViewer2.setAttribute('src', 'kodim08_30_sh.gltf');
|
| 14 |
+
} else {
|
| 15 |
+
// Set to default models or hide them
|
| 16 |
+
modelViewer1.setAttribute('src', 'kodim08_50_ori.gltf');
|
| 17 |
+
modelViewer2.setAttribute('src', 'kdoim08_50_sh.gltf');
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
[option1, option2].forEach(option => {
|
| 22 |
+
option.addEventListener('change', function() {
|
| 23 |
+
// Uncheck other options
|
| 24 |
+
option1.checked = option2.checked = false;
|
| 25 |
+
this.checked = true;
|
| 26 |
+
updateModels();
|
| 27 |
+
});
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
updateModels();
|
| 31 |
+
});
|