Update index.html
Browse files- index.html +22 -16
index.html
CHANGED
@@ -95,23 +95,29 @@
|
|
95 |
const r = imageData[index];
|
96 |
const g = imageData[index + 1];
|
97 |
const b = imageData[index + 2];
|
98 |
-
const
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize);
|
104 |
-
const material = new THREE.MeshBasicMaterial({ color: color });
|
105 |
-
const cube = new THREE.Mesh(geometry, material);
|
106 |
-
|
107 |
-
cube.position.set(
|
108 |
-
(x - canvas.width / 2) * cubeSize * 1.2,
|
109 |
-
(canvas.height / 2 - y) * cubeSize * 1.2,
|
110 |
-
Math.random() * 2200 - 100
|
111 |
-
);
|
112 |
-
scene.add(cube);
|
113 |
-
cubes.push(cube);
|
114 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
}
|
117 |
}
|
|
|
95 |
const r = imageData[index];
|
96 |
const g = imageData[index + 1];
|
97 |
const b = imageData[index + 2];
|
98 |
+
const alpha = imageData[index + 3] / 255; // Alpha channel (0-1)
|
99 |
+
|
100 |
+
if (alpha < 0.1) {
|
101 |
+
// Skip creating a cube if the alpha is near 0 (transparent)
|
102 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
+
|
105 |
+
const color = new THREE.Color(`rgb(${r},${g},${b})`);
|
106 |
+
const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize);
|
107 |
+
const material = new THREE.MeshBasicMaterial({
|
108 |
+
color: color,
|
109 |
+
transparent: true,
|
110 |
+
opacity: alpha // Set opacity based on alpha value
|
111 |
+
});
|
112 |
+
const cube = new THREE.Mesh(geometry, material);
|
113 |
+
|
114 |
+
cube.position.set(
|
115 |
+
(x - canvas.width / 2) * cubeSize * 1.2,
|
116 |
+
(canvas.height / 2 - y) * cubeSize * 1.2,
|
117 |
+
Math.random() * 2200 - 100
|
118 |
+
);
|
119 |
+
scene.add(cube);
|
120 |
+
cubes.push(cube);
|
121 |
}
|
122 |
}
|
123 |
}
|