add_sims = {
const a = d3
.select(chart)
.select("#lines")
.html("");
const lines = a
.selectAll("a-entity")
.data(bus.features)
.enter()
.append("a-entity")
.attr("meshline", "")
.nodes();
if (true)
for (var i = 0; i < lines.length; i++) {
d3.select(lines[i]).attr(
"meshline",
l =>
`lineWidth: 0.4; path: ${l.geometry.coordinates
.map(d => `${xyz(d)}`)
.join(", ")}; color: rgb(${l.properties.couleur.replace(
/ /g,
","
)});`
);
yield `${1 + i}/${lines.length}`;
}
a.select("a-text").remove();
const b = d3.select(chart).select("#dots");
const boxes = b
.html("")
.selectAll("a-box")
.data(bus.features)
.enter()
.append("a-box")
.attr("width", 0.01)
.attr("height", 0.01)
.attr("depth", 0.01)
.attr(
"material",
l => `color: rgb(${l.properties.couleur.replace(/ /g, ",")});`
);
const camera = d3.select(chart).select("#camera");
do {
const t = Date.now() / 30000,
s = sims(Date.now());
boxes.attr("position", (d, i) => `${xyz(s[i].coordinates, i)}`);
if (false)
boxes.each((d, i, e) => {
const A = xyz(s[i].coordinates, i)
.split(" ")
.map(d => +d),
pos = { x: A[0], y: A[1], z: A[2] };
e[i].setAttribute("position", pos);
});
camera.each((d, i, e) => {
e[i].setAttribute("position", {
x: 3 * Math.sin(t),
y: 1,
z: 3 + 3 * Math.cos(t)
});
});
yield html`<tt>sims updated at ${Date.now()}`;
} while (true);
}