Commit 8d01892b authored by Florent Becker's avatar Florent Becker

show time

parent 14a76a22
......@@ -36,9 +36,14 @@
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<button id="set-simulation-mode-menu" class="w3-bar-item w3-button">Set Simulation Mode</button>
<button id="set-temperature-button" class="w3-bar-item w3-button">Set Temperature</button>
<span class="w3-bar-item">
<input id="report-nondeterminism-checkbox" name="report-nondeterminism-checkbox" type="checkbox" value="report-nondeterminism" checked />
<label for="report-nondeterminism-checkbox"> Report Nondeterminism</label>
</span>
<span class="w3-bar-item">
<input id="show-attach-time-checkbox" name="show-attach-time-checkbox" type="checkbox" value="show-attach-time" checked />
<label for="show-attach-time-checkbox"> Show Attachment Times</label>
</span>
<button id="set-background-color-button" class="w3-bar-item w3-button">Set Background Color</button>
<input id="bg-color-input" type="color" value="#ffffee" style="display: none;" />
......
......@@ -364,7 +364,7 @@ export class Simulator {
this.selectedTile.resize();
}
render() {
render(include_times=false) {
if (this.renderUpdate) {
this.renderUpdate = false;
......@@ -378,6 +378,8 @@ export class Simulator {
const screenMax = new Vector2D( this.camera.position.x + this.camera.right / this.camera.zoom,
this.camera.position.y + this.camera.top / this.camera.zoom ).round();
this.tileBlockAtlas.forTilesInRegion(screenMin, screenMax, TextManager.addTileGlyphs);
if (include_times)
this.tileBlockAtlas.forTilesInRegion(screenMin, screenMax, TextManager.addTimeGlyphs);
TextManager.update(this.scene, this.canvas);
}
......@@ -464,6 +466,7 @@ export class Simulator {
}
loadSystem(data) {
console.log("before load, history: ", this.tileBlockAtlas.history);
if (data['tdp'] !== undefined && data['tds'] !== undefined) {
this.clear();
this.tileset = new TileSet();
......@@ -533,7 +536,6 @@ export class Simulator {
}
this.tileBlockAtlas.add_many(this.seedTiles);
console.log(this.seedTiles.length);
if (this.seedTiles.length == 0) {
let ttypes = this.tileset.tileTypes;
......@@ -542,8 +544,8 @@ export class Simulator {
this.tileBlockAtlas.add(tile, origin);
this.seedTiles.push({type: tile, coords: origin});
}
this.tileWorker.postMessage({ msg: 'set-seed', seed: this.seedTiles});
this.tileWorker.postMessage({ msg: 'set-seed', seed: this.seedTiles});
Logger.log(Logger.INFO, `loaded ${this.simulation_mode} system file "${data.tdp.name}" with a seed of size ${this.seedTiles.length}`);
......@@ -556,6 +558,7 @@ export class Simulator {
}
Logger.log(Logger.INFO, `simulation mode set to ${this.simulation_mode}${version_str}`);
this.setTemperature(temp);
this.setState(STATE_DEFAULT);
this.renderUpdate = true;
}
......
......@@ -37,6 +37,12 @@ export function clearText() {
}
}
export function addTimeGlyphs(tile) {
console.log("adding time");
const glyphData = ;
}
export function addTileGlyphs(tile) {
const glyphData = tileGlyphData.get(tile.type.id);
......
......@@ -39,7 +39,7 @@ class TileBlock {
offset.y >= 0 && offset.y < BLOCK_HEIGHT;
}
add(type, coords) {
add(type, coords, time) {
if (!this.contains(coords)) {
console.log("ERROR: attempting to add tile to invalid tile block");
return false;
......@@ -53,7 +53,7 @@ class TileBlock {
}
this.indexMap[key] = this.tileData.length;
this.tileData.push({type: type, coords: coords});
this.tileData.push({type: type, coords: coords, time: time});
// there's a cleaner way to do this, but I'm lazy
const dummy = new THREE.Object3D();
......@@ -238,6 +238,7 @@ export class TileBlockAtlas {
clear() {
this.tileBlocks = new Map();
this.numTiles = 0;
this.history = [];
// TODO: not entirely sure if geometry will be properly be deallocated
// if memory leaks appear after clearing, start looking into this
......@@ -254,7 +255,7 @@ export class TileBlockAtlas {
return true;
}
add_inner(type, coords) {
add_inner(type, coords, time) {
const blockIndex = this.getBlockIndex(coords);
if (!this.tileBlocks.has(blockIndex.y))
......@@ -272,20 +273,16 @@ export class TileBlockAtlas {
const tileBlock = subMap.get(blockIndex.x);
tileBlock.add(type, coords);
tileBlock.add(type, coords, time);
this.numTiles++;
}
add_one(type, coords) {
this.add_inner(type, coords);
this.history.push([coords]);
}
add_many(attachments) {
const current_time = this.history.length;
var all_coords = [];
for (let a of attachments) {
this.add_inner(a.type, a.coords);
this.add_inner(a.type, a.coords, current_time);
all_coords.push(a.coords);
}
this.history.push(all_coords);
......
......@@ -173,8 +173,8 @@ document.addEventListener('DOMContentLoaded', () => {
function render() {
requestAnimationFrame(render);
simulator.render();
const b_show = document.getElementById('show-attach-time-checkbox').checked;
simulator.render(b_show);
}
// called when all assets have been loaded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment