viewof coloredFCC = {
const a = 1;
const n = 3;
const radius = 10;
const positions = [];
let index = 0;
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
for (let k = 0; k < n; k++) {
const base = [i * a, j * a, k * a];
positions.push({ x: base[0], y: base[1], z: base[2], i: index++, type: "corner" });
positions.push({ x: base[0] + a/2, y: base[1] + a/2, z: base[2], i: index++, type: "face" });
positions.push({ x: base[0] + a/2, y: base[1], z: base[2] + a/2, i: index++, type: "face" });
positions.push({ x: base[0], y: base[1] + a/2, z: base[2] + a/2, i: index++, type: "face" });
}
}
}
const xs = positions.map(p => p.x);
const ys = positions.map(p => p.y);
const zs = positions.map(p => p.z);
const colors = positions.map(p =>
p.type === "corner"
? concentration_FCC_1[t_index_multi]
: concentration_FCC_2[t_index_multi]
);
const trace = {
type: "scatter3d",
mode: "markers",
x: xs,
y: ys,
z: zs,
marker: {
size: radius,
color: colors,
cmin: -1,
cmax: 1,
colorscale: [
[0, "blue"],
[0.5, "white"],
[1, "red"]
],
opacity: 1,
line: {
color: "black",
width: 0.5
},
colorbar: { title: "Concentration [M]<br>positive: material I<br>negative: material II<br>", thickness: 10 }
}
};
return Plotly.newPlot(
document.createElement("div"),
[trace],
{
scene: {
xaxis: { range: [-1, n * a + 1], visible: false },
yaxis: { range: [-1, n * a + 1], visible: false },
zaxis: { range: [-1, n * a + 1], visible: false },
aspectmode: "data",
camera: {
eye: { x: -1.06, y: -2, z: 1.5 }
}
},
margin: { t: 30 },
dragmode: "turntable",
},
{
scrollZoom: false,
doubleClick: false,
displayModeBar: false
}
);
}