Use some names from the Mozilla Monument in the 3D demo
This commit is contained in:
parent
7de664e4a9
commit
6cbc7dc082
|
@ -23,12 +23,9 @@ import {PathfinderDemoView, Timings} from "./view";
|
||||||
import SSAAStrategy from "./ssaa-strategy";
|
import SSAAStrategy from "./ssaa-strategy";
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
|
|
||||||
const WIDTH: number = 40000;
|
const WIDTH: number = 150000;
|
||||||
|
|
||||||
const TEXT: string[][] = [
|
const TEXT_DATA_URI: string = "/data/mozmonument.json";
|
||||||
[ "Lorem ipsum", "dolor sit amet" ],
|
|
||||||
[ "consectetur adipiscing elit." ],
|
|
||||||
];
|
|
||||||
|
|
||||||
const FONT: string = 'open-sans';
|
const FONT: string = 'open-sans';
|
||||||
|
|
||||||
|
@ -38,7 +35,7 @@ const FOV: number = 45.0;
|
||||||
const NEAR_CLIP_PLANE: number = 0.01;
|
const NEAR_CLIP_PLANE: number = 0.01;
|
||||||
const FAR_CLIP_PLANE: number = 10000.0;
|
const FAR_CLIP_PLANE: number = 10000.0;
|
||||||
|
|
||||||
const SCALE: glmatrix.vec3 = glmatrix.vec3.fromValues(1.0 / 50.0, 1.0 / 50.0, 1.0);
|
const SCALE: glmatrix.vec3 = glmatrix.vec3.fromValues(1.0 / 200.0, 1.0 / 200.0, 1.0);
|
||||||
|
|
||||||
const ANTIALIASING_STRATEGIES: AntialiasingStrategyTable = {
|
const ANTIALIASING_STRATEGIES: AntialiasingStrategyTable = {
|
||||||
none: NoAAStrategy,
|
none: NoAAStrategy,
|
||||||
|
@ -50,21 +47,55 @@ interface AntialiasingStrategyTable {
|
||||||
ssaa: typeof SSAAStrategy;
|
ssaa: typeof SSAAStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Panels {
|
||||||
|
upper: string[][];
|
||||||
|
lower: string[][];
|
||||||
|
}
|
||||||
|
|
||||||
class ThreeDController extends DemoAppController<ThreeDView> {
|
class ThreeDController extends DemoAppController<ThreeDView> {
|
||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
this.textPromise = window.fetch(TEXT_DATA_URI)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(textData => this.parseTextData(textData));
|
||||||
|
|
||||||
this.loadInitialFile();
|
this.loadInitialFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private parseTextData(textData: any): string[][] {
|
||||||
|
const panels = {
|
||||||
|
upper: [],
|
||||||
|
lower: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const nameData of textData.monument) {
|
||||||
|
if (nameData.side !== '1')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const row = parseInt(nameData.row) - 1, number = parseInt(nameData.number) - 1;
|
||||||
|
const panel: string[][] = panels[nameData.panel as ('upper' | 'lower')];
|
||||||
|
|
||||||
|
if (panel[row] == null)
|
||||||
|
panel[row] = [];
|
||||||
|
panel[row][number] = nameData.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return panels.upper.concat(panels.lower);
|
||||||
|
}
|
||||||
|
|
||||||
protected fileLoaded(): void {
|
protected fileLoaded(): void {
|
||||||
const font = opentype.parse(this.fileData);
|
const font = opentype.parse(this.fileData);
|
||||||
assert(font.isSupported(), "The font type is unsupported!");
|
assert(font.isSupported(), "The font type is unsupported!");
|
||||||
|
|
||||||
|
this.textPromise.then(text => this.layoutText(font, text));
|
||||||
|
}
|
||||||
|
|
||||||
|
private layoutText(font: opentype.Font, text: string[][]) {
|
||||||
const createGlyph = (glyph: opentype.Glyph) => new ThreeDGlyph(glyph);
|
const createGlyph = (glyph: opentype.Glyph) => new ThreeDGlyph(glyph);
|
||||||
let textRuns = [];
|
let textRuns = [];
|
||||||
for (let lineNumber = 0; lineNumber < TEXT.length; lineNumber++) {
|
for (let lineNumber = 0; lineNumber < text.length; lineNumber++) {
|
||||||
const line = TEXT[lineNumber];
|
const line = text[lineNumber];
|
||||||
|
|
||||||
const lineY = -lineNumber * font.lineHeight();
|
const lineY = -lineNumber * font.lineHeight();
|
||||||
const lineGlyphs = line.map(string => {
|
const lineGlyphs = line.map(string => {
|
||||||
|
@ -114,6 +145,8 @@ class ThreeDController extends DemoAppController<ThreeDView> {
|
||||||
|
|
||||||
private baseMeshes: PathfinderMeshData;
|
private baseMeshes: PathfinderMeshData;
|
||||||
private expandedMeshes: PathfinderMeshData;
|
private expandedMeshes: PathfinderMeshData;
|
||||||
|
|
||||||
|
private textPromise: Promise<string[][]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThreeDView extends PathfinderDemoView {
|
class ThreeDView extends PathfinderDemoView {
|
||||||
|
|
|
@ -54,6 +54,7 @@ static STATIC_JS_POPPER_JS_PATH: &'static str = "../client/node_modules/popper.j
|
||||||
static STATIC_JS_PATHFINDER_PATH: &'static str = "../client";
|
static STATIC_JS_PATHFINDER_PATH: &'static str = "../client";
|
||||||
static STATIC_SVG_OCTICONS_PATH: &'static str = "../client/node_modules/octicons/build/svg";
|
static STATIC_SVG_OCTICONS_PATH: &'static str = "../client/node_modules/octicons/build/svg";
|
||||||
static STATIC_GLSL_PATH: &'static str = "../../shaders";
|
static STATIC_GLSL_PATH: &'static str = "../../shaders";
|
||||||
|
static STATIC_DATA_PATH: &'static str = "../../resources/data";
|
||||||
|
|
||||||
static STATIC_DOC_API_INDEX_URI: &'static str = "/doc/api/pathfinder_font_renderer/index.html";
|
static STATIC_DOC_API_INDEX_URI: &'static str = "/doc/api/pathfinder_font_renderer/index.html";
|
||||||
|
|
||||||
|
@ -610,6 +611,10 @@ fn static_svg_demo(svg_name: String) -> Option<NamedFile> {
|
||||||
.next()
|
.next()
|
||||||
.and_then(|&(_, path)| NamedFile::open(Path::new(path)).ok())
|
.and_then(|&(_, path)| NamedFile::open(Path::new(path)).ok())
|
||||||
}
|
}
|
||||||
|
#[get("/data/<file..>")]
|
||||||
|
fn static_data(file: PathBuf) -> Option<NamedFile> {
|
||||||
|
NamedFile::open(Path::new(STATIC_DATA_PATH).join(file)).ok()
|
||||||
|
}
|
||||||
|
|
||||||
struct Shader {
|
struct Shader {
|
||||||
file: File,
|
file: File,
|
||||||
|
@ -653,5 +658,6 @@ fn main() {
|
||||||
static_glsl,
|
static_glsl,
|
||||||
static_otf_demo,
|
static_otf_demo,
|
||||||
static_svg_demo,
|
static_svg_demo,
|
||||||
|
static_data,
|
||||||
]).launch();
|
]).launch();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue