Update index.html
Browse files- index.html +32 -34
index.html
CHANGED
@@ -86,41 +86,39 @@
|
|
86 |
animate();
|
87 |
}
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
);
|
119 |
-
scene.add(cube);
|
120 |
-
cubes.push(cube);
|
121 |
-
}
|
122 |
-
}
|
123 |
}
|
|
|
|
|
|
|
124 |
|
125 |
function animate() {
|
126 |
animationFrameId = requestAnimationFrame(animate);
|
|
|
86 |
animate();
|
87 |
}
|
88 |
|
89 |
+
function createCubesFromImage() {
|
90 |
+
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
91 |
+
|
92 |
+
for (let y = 0; y < canvas.height; y++) {
|
93 |
+
for (let x = 0; x < canvas.width; x++) {
|
94 |
+
const index = (y * canvas.width + x) * 4;
|
95 |
+
const r = imageData[index];
|
96 |
+
const g = imageData[index + 1];
|
97 |
+
const b = imageData[index + 2];
|
98 |
+
const a = imageData[index + 3]; // アルファ値を取得
|
99 |
+
|
100 |
+
// アルファ値が0なら透明なキューブを作成
|
101 |
+
const color = new THREE.Color(`rgb(${r},${g},${b})`);
|
102 |
+
const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize);
|
103 |
+
const material = new THREE.MeshBasicMaterial({
|
104 |
+
color: color,
|
105 |
+
transparent: true,
|
106 |
+
opacity: a / 255 // 透明度を設定(0で完全透明、255で不透明)
|
107 |
+
});
|
108 |
+
|
109 |
+
const cube = new THREE.Mesh(geometry, material);
|
110 |
+
|
111 |
+
cube.position.set(
|
112 |
+
(x - canvas.width / 2) * cubeSize * 1.2,
|
113 |
+
(canvas.height / 2 - y) * cubeSize * 1.2,
|
114 |
+
Math.random() * 2200 - 100
|
115 |
+
);
|
116 |
+
scene.add(cube);
|
117 |
+
cubes.push(cube);
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
|
123 |
function animate() {
|
124 |
animationFrameId = requestAnimationFrame(animate);
|