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

show time

parent 14a76a22
......@@ -34,11 +34,16 @@
<div class="w3-dropdown-hover">
<button class="w3-button">Settings</button>
<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-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>
<input id="report-nondeterminism-checkbox" name="report-nondeterminism-checkbox" type="checkbox" value="report-nondeterminism" checked />
<label for="report-nondeterminism-checkbox"> Report Nondeterminism</label>
<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;
......@@ -377,7 +377,9 @@ export class Simulator {
this.camera.position.y + this.camera.bottom / this.camera.zoom ).round();
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);
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,22 +544,23 @@ export class Simulator {
this.tileBlockAtlas.add(tile, origin);
this.seedTiles.push({type: tile, coords: origin});
}
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}`);
Logger.log(Logger.INFO, `loaded ${this.simulation_mode} system file "${data.tdp.name}" with a seed of size ${this.seedTiles.length}`);
// Determine if we're in v1 or v2. V1 should use this.blockerDict and v2 should use this.tileset.tileGlueBlockers
let version_str = '';
if ((this.blockerDict !== undefined) && (Object.keys(this.blockerDict).length > 0)) {
version_str = ' (version 1: blockers specific to glue labels)';
} else if ((this.tileset.tileGlueBlockers !== undefined) && (Object.keys(this.tileset.tileGlueBlockers).length > 0)) {
version_str = ' (version 2: blockers specific to tile type sides)'
}
Logger.log(Logger.INFO, `simulation mode set to ${this.simulation_mode}${version_str}`);
this.setTemperature(temp);
this.setState(STATE_DEFAULT);
this.renderUpdate = true;
// Determine if we're in v1 or v2. V1 should use this.blockerDict and v2 should use this.tileset.tileGlueBlockers
let version_str = '';
if ((this.blockerDict !== undefined) && (Object.keys(this.blockerDict).length > 0)) {
version_str = ' (version 1: blockers specific to glue labels)';
} else if ((this.tileset.tileGlueBlockers !== undefined) && (Object.keys(this.tileset.tileGlueBlockers).length > 0)) {
version_str = ' (version 2: blockers specific to tile type sides)'
}
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);
......@@ -636,4 +642,4 @@ export class TextManager {
return data;
}
}
\ No newline at end of file
}
......@@ -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);
......
......@@ -37,8 +37,8 @@ document.addEventListener('DOMContentLoaded', () => {
document.getElementById('bg-color-input').addEventListener('change', (e) => { simulator.setBackgroundColor(e.target.value); });
document.getElementById('set-background-color-button').addEventListener('click', () => { document.getElementById('bg-color-input').click(); });
document.getElementById('set-temperature-button').addEventListener('click', onSetTemperatureButton);
document.getElementById('set-simulation-mode-menu').addEventListener('click', onSetSimulationModeMenu);
document.getElementById('report-nondeterminism-checkbox').addEventListener('click', onReportNondeterminism);
document.getElementById('set-simulation-mode-menu').addEventListener('click', onSetSimulationModeMenu);
document.getElementById('report-nondeterminism-checkbox').addEventListener('click', onReportNondeterminism);
/* set behavior for rectilinear generator buttons start */
......@@ -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