Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
window.addEventListener("mouseup", onMouseClick);
window.addEventListener("keyup", onKeyUp);
camera = new THREE.OrthographicCamera(
-window.innerWidth / 2.0,
window.innerWidth / 2.0,
window.innerHeight / 2.0,
-window.innerHeight / 2.0
);
camera.position.z = 1.0;
camera.near = 0.0;
camera.updateProjectionMatrix();
// Init textCanvas
textLayoutStyle = new TextLayoutStyle({
horizontalAlignment: HorizontalAlignment.Left,
verticalAlignment: VerticalAlignment.Center
});
textRenderStyle = new TextRenderStyle();
FontCatalog.load("resources/fonts/Default_FontCatalog.json", 1024).then(
(loadedFontCatalog: FontCatalog) => {
textCanvas = new TextCanvas({
renderer: webglRenderer,
fontCatalog: loadedFontCatalog,
maxGlyphCount: characterCount
});
loadedFontCatalog.loadCharset(applicationCharset, textRenderStyle).then(() => {
assetsLoaded = true;
});
}
);
const lineObject = new THREE.Line(this.geometry, debugMaterial);
lineObject.renderOrder = PRIORITY_ALWAYS;
this.objects.push(lineObject);
this.m_labelPositions.setXYZ(0, 0, 0, 0);
const textPosition = new THREE.Vector3();
if (this.projection.type === ProjectionType.Planar) {
// place the text position at north/west for planar projections.
textPosition.copy(this.geometry.vertices[3]);
textPosition.multiplyScalar(0.95);
this.m_textLayoutStyle = new TextLayoutStyle({
verticalAlignment: VerticalAlignment.Below,
horizontalAlignment: HorizontalAlignment.Left
});
} else {
textPosition.copy(middlePoint);
this.m_textLayoutStyle = new TextLayoutStyle({
verticalAlignment: VerticalAlignment.Center,
horizontalAlignment: HorizontalAlignment.Center
});
}
const text = `${tileKey.mortonCode()} (${tileKey.row}, ${tileKey.column}, ${
tileKey.level
})`;
textPosition.add(this.center);
const textElement = new TextElement(
.onChange((value: string) => {
textRenderStyle.fontVariant = Number(value);
assetsLoaded = false;
textCanvas.fontCatalog.loadCharset(applicationCharset, textRenderStyle).then(() => {
assetsLoaded = true;
});
});
const textLayoutGui = gui.addFolder("TextLayout");
textLayoutGui.add(textLayoutStyle, "lineWidth", 1.0, window.innerWidth, 1.0);
textLayoutGui.add(textLayoutStyle, "maxLines", 0.0, 128, 1.0);
textLayoutGui.add(textLayoutStyle, "tracking", -3.0, 3.0, 0.1);
textLayoutGui.add(textLayoutStyle, "leading", -3.0, 3.0, 0.1);
textLayoutGui
.add(textLayoutStyle, "horizontalAlignment", {
Left: HorizontalAlignment.Left,
Center: HorizontalAlignment.Center,
Right: HorizontalAlignment.Right
})
.onChange((value: string) => {
textLayoutStyle.horizontalAlignment = Number(value);
});
textLayoutGui
.add(textLayoutStyle, "verticalAlignment", {
Above: VerticalAlignment.Above,
Center: VerticalAlignment.Center,
Below: VerticalAlignment.Below
})
.onChange((value: string) => {
textLayoutStyle.verticalAlignment = Number(value);
});
textLayoutGui
.onChange((value: string) => {
textRenderStyle.fontVariant = Number(value);
assetsLoaded = false;
textCanvas.fontCatalog.loadCharset(textSample, textRenderStyle).then(() => {
assetsLoaded = true;
});
});
const textLayoutGui = gui.addFolder("TextLayout");
textLayoutGui.add(textLayoutStyle, "lineWidth", 1.0, window.innerWidth, 1.0);
textLayoutGui.add(textLayoutStyle, "maxLines", 0.0, 128, 1.0);
textLayoutGui.add(textLayoutStyle, "tracking", -3.0, 3.0, 0.1);
textLayoutGui.add(textLayoutStyle, "leading", -3.0, 3.0, 0.1);
textLayoutGui
.add(textLayoutStyle, "horizontalAlignment", {
Left: HorizontalAlignment.Left,
Center: HorizontalAlignment.Center,
Right: HorizontalAlignment.Right
})
.onChange((value: string) => {
textLayoutStyle.horizontalAlignment = Number(value);
});
textLayoutGui
.add(textLayoutStyle, "verticalAlignment", {
Above: VerticalAlignment.Above,
Center: VerticalAlignment.Center,
Below: VerticalAlignment.Below
})
.onChange((value: string) => {
textLayoutStyle.verticalAlignment = Number(value);
});
textLayoutGui
.onChange((value: string) => {
textRenderStyle.fontVariant = Number(value);
assetsLoaded = false;
textCanvas.fontCatalog.loadCharset(textSample, textRenderStyle).then(() => {
assetsLoaded = true;
});
});
const textLayoutGui = gui.addFolder("TextLayout");
textLayoutGui.add(textLayoutStyle, "lineWidth", 1.0, window.innerWidth, 1.0);
textLayoutGui.add(textLayoutStyle, "maxLines", 0.0, 128, 1.0);
textLayoutGui.add(textLayoutStyle, "tracking", -3.0, 3.0, 0.1);
textLayoutGui.add(textLayoutStyle, "leading", -3.0, 3.0, 0.1);
textLayoutGui
.add(textLayoutStyle, "horizontalAlignment", {
Left: HorizontalAlignment.Left,
Center: HorizontalAlignment.Center,
Right: HorizontalAlignment.Right
})
.onChange((value: string) => {
textLayoutStyle.horizontalAlignment = Number(value);
});
textLayoutGui
.add(textLayoutStyle, "verticalAlignment", {
Above: VerticalAlignment.Above,
Center: VerticalAlignment.Center,
Below: VerticalAlignment.Below
})
.onChange((value: string) => {
textLayoutStyle.verticalAlignment = Number(value);
});
textLayoutGui