import * as d3 from "d3";
// use jsx templating
import { h, Fragment } from 'start-dom-jsx';
import anime from 'animejs/lib/anime.es.js';
console.log(anime)
// const projection = d3.geoAitoff();
function degreesToRadians(degrees) {
return (degrees * Math.PI) / 180;
}
function latLonToOffsets(latitude, longitude, mapWidth, mapHeight) {
const FE = 180; // false easting
const radius = mapWidth / (2 * Math.PI);
const latRad = degreesToRadians(latitude);
const lonRad = degreesToRadians(longitude + FE);
const x = lonRad * radius;
const yFromEquator = radius * Math.log(Math.tan(Math.PI / 4 + latRad / 2));
const y = mapHeight / 2 - yFromEquator;
return { x, y };
}
export function viz(vizEl) {
console.log(d3)
// vizEl.appendChild(
Hello
);
fetch("data/parsed_requests.json")
.then((response) => response.json())
.then(start)
.catch((error) => {
console.error(error);
// alert("Data could not be loaded.")
});
// d3.queue()
// .defer(d3.json, "data/parsed_requests.json") // World shape
// .await(start)
}
function lerp(X, Y, t) {
return X * t + Y * (1 - t)
}
function inverse_lerp(a, b, x) {
return (x - a) / (b - a);
}
interface IndexObject {
[index: string]: Array;
}
/**
* A scene
*/
class Scene {
// setup: CallableFunction;
animation: CallableFunction; // the function that returns an anime.js object
constructor(animation: CallableFunction) {
// this.setup = setup;
this.animation = animation;
}
async run () {
const anim = this.animation();
console.log('anim', anim);
await anim.finished
}
}
class Sequence {
scenes: Array;
constructor() {
this.scenes = [];
}
async run() {
while(true) {
for(const scene of this.scenes){
console.log('scene', scene);
await scene.run();
console.log('ran')
}
}
}
}
function buildIndex(objectList: Array