soiz commited on
Commit
d8cbec2
·
verified ·
1 Parent(s): e3bf736

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +7 -6
index.html CHANGED
@@ -90,10 +90,11 @@
90
  const material = new THREE.MeshBasicMaterial({ color: color });
91
  const cube = new THREE.Mesh(geometry, material);
92
 
 
93
  cube.position.set(
94
- (x - canvas.width / 2) * cubeSize * 1.2,
95
- (y - canvas.height / 2) * cubeSize * 1.2,
96
- Math.random() * 200 - 100 // 初期位置のばらつきを与える
97
  );
98
  scene.add(cube);
99
  cubes.push(cube);
@@ -106,8 +107,8 @@
106
 
107
  // 各立方体をターゲット位置へ移動させる
108
  cubes.forEach((cube, index) => {
109
- const targetX = ((index % canvas.width) - canvas.width / 2) * cubeSize * 1.2;
110
- const targetY = (Math.floor(index / canvas.width) - canvas.height / 2) * cubeSize * 1.2;
111
  const targetZ = 0;
112
 
113
  cube.position.x += (targetX - cube.position.x) * 0.05;
@@ -119,4 +120,4 @@
119
  }
120
  </script>
121
  </body>
122
- </html>
 
90
  const material = new THREE.MeshBasicMaterial({ color: color });
91
  const cube = new THREE.Mesh(geometry, material);
92
 
93
+ // xとyの座標を反転させる
94
  cube.position.set(
95
+ (canvas.width / 2 - x) * cubeSize * 1.2, // x座標を反転
96
+ (canvas.height / 2 - y) * cubeSize * 1.2, // y座標を反転
97
+ Math.random() * 200 - 100 // 初期位置のばらつきを与える
98
  );
99
  scene.add(cube);
100
  cubes.push(cube);
 
107
 
108
  // 各立方体をターゲット位置へ移動させる
109
  cubes.forEach((cube, index) => {
110
+ const targetX = ((canvas.width / 2) - (index % canvas.width)) * cubeSize * 1.2;
111
+ const targetY = ((canvas.height / 2) - Math.floor(index / canvas.width)) * cubeSize * 1.2;
112
  const targetZ = 0;
113
 
114
  cube.position.x += (targetX - cube.position.x) * 0.05;
 
120
  }
121
  </script>
122
  </body>
123
+ </html>