lyunm1206 commited on
Commit
b168dfd
·
1 Parent(s): c767254
Files changed (2) hide show
  1. index.html +2 -2
  2. script.js +11 -0
index.html CHANGED
@@ -33,7 +33,7 @@
33
  seamless-poster
34
  shadow-intensity="1"
35
  camera-controls
36
- camera-orbit="0deg 180deg 100deg"
37
  >
38
  </model-viewer>
39
  </div>
@@ -48,7 +48,7 @@
48
  seamless-poster
49
  shadow-intensity="1"
50
  camera-controls
51
- camera-orbit="0deg 180deg 100deg"
52
  >
53
  </model-viewer>
54
  </div>
 
33
  seamless-poster
34
  shadow-intensity="1"
35
  camera-controls
36
+ camera-orbit="0deg 180deg 120deg"
37
  >
38
  </model-viewer>
39
  </div>
 
48
  seamless-poster
49
  shadow-intensity="1"
50
  camera-controls
51
+ camera-orbit="0deg 180deg 120deg"
52
  >
53
  </model-viewer>
54
  </div>
script.js CHANGED
@@ -2,11 +2,22 @@ document.addEventListener('DOMContentLoaded', function() {
2
  const toggleOptions = document.querySelectorAll('input[name="toggleOption"]');
3
  const allSubOptionsContainers = document.querySelectorAll('.sub-options');
4
  const allSubOptions = document.querySelectorAll('.sub-options input[type="radio"]');
 
 
 
5
 
6
  function updateModels(selectedSubOption) {
7
  const modelPaths = getModelPaths(selectedSubOption.value);
8
  modelViewer1.setAttribute('src', modelPaths.model1Path);
 
 
 
 
9
  modelViewer2.setAttribute('src', modelPaths.model2Path);
 
 
 
 
10
  }
11
 
12
  function updateSubOptionsDisplay() {
 
2
  const toggleOptions = document.querySelectorAll('input[name="toggleOption"]');
3
  const allSubOptionsContainers = document.querySelectorAll('.sub-options');
4
  const allSubOptions = document.querySelectorAll('.sub-options input[type="radio"]');
5
+ const initialCameraOrbit1 = "0deg 180deg 120deg";
6
+ const initialCameraOrbit2 = "0deg 180deg 120deg";
7
+
8
 
9
  function updateModels(selectedSubOption) {
10
  const modelPaths = getModelPaths(selectedSubOption.value);
11
  modelViewer1.setAttribute('src', modelPaths.model1Path);
12
+ modelViewer1.addEventListener('load', () => {
13
+ modelViewer1.setAttribute('camera-orbit', initialCameraOrbit1);
14
+ modelViewer1.resetCamera();
15
+ });
16
  modelViewer2.setAttribute('src', modelPaths.model2Path);
17
+ modelViewer2.addEventListener('load', () => {
18
+ modelViewer2.setAttribute('camera-orbit', initialCameraOrbit1);
19
+ modelViewer2.resetCamera();
20
+ });
21
  }
22
 
23
  function updateSubOptionsDisplay() {