From 6c1d7177ddf8f06ff3b8ca60719689ffc2b98fa8 Mon Sep 17 00:00:00 2001 From: Cailean Finn Date: Mon, 20 Oct 2025 13:49:50 +0200 Subject: [PATCH] font loading fixed for text content, and manged disposal of teleArc geom --- js/Content.js | 17 +++++++---------- js/Player.js | 2 +- public/texts/example.md | 6 +++++- public/texts/example2.md | 6 +++++- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/js/Content.js b/js/Content.js index 7a67c89..af2f14c 100644 --- a/js/Content.js +++ b/js/Content.js @@ -38,31 +38,28 @@ export class TextContent extends Content { this.canvas = null; this.context = null; this.lines = []; - this.lineHeight = 80; // Font size + padding + this.lineHeight = 110; // Font size + padding this.maxLinesVisible = 0; this.scrollOffset = 0; // Index of the first line to display this.color = 'black'; } - createDisplayMesh() { + async createDisplayMesh() { this.canvas = document.createElement('canvas'); - const canvasSize = 1024; this.canvas.width = 2048; - this.canvas.height = canvasSize; + this.canvas.height = 1024; this.context = this.canvas.getContext('2d'); - document.fonts.load('60px Redacted70').then(() => { - this._wrapText(); - }); + await document.fonts.load('100px Redacted70'); + + this._wrapText(); this.texture = new THREE.CanvasTexture(this.canvas); const material = new THREE.MeshBasicMaterial({ map: this.texture, transparent: true }); const geometry = new THREE.PlaneGeometry(10, 5); this.displayMesh = new THREE.Mesh(geometry, material); - document.fonts.load('100px Redacted70').then(() => { - this._redrawCanvas(); - }); + this._redrawCanvas(); return this.displayMesh; } diff --git a/js/Player.js b/js/Player.js index a0c1d0a..c4b535f 100644 --- a/js/Player.js +++ b/js/Player.js @@ -366,7 +366,7 @@ export class Player { // Convert world-space points to local-space for the rig const localPoints = points.map(p => this.playerRig.worldToLocal(p.clone())); - + this.teleArc.geometry.dispose(); this.teleArc.geometry.setFromPoints(localPoints); this.teleArc.geometry.computeBoundingSphere(); // Important for visibility this.teleArc.visible = true; diff --git a/public/texts/example.md b/public/texts/example.md index fa92bbd..ad421e6 100644 --- a/public/texts/example.md +++ b/public/texts/example.md @@ -1 +1,5 @@ -hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world!hello-world! \ No newline at end of file +hello-world! + +testing 123 + +hello-world! hello-world! hello-world! hello-world!hello-world! hello-world! hello-world! hello-world! hello-world! hello-world! diff --git a/public/texts/example2.md b/public/texts/example2.md index 8fce0cb..ad421e6 100644 --- a/public/texts/example2.md +++ b/public/texts/example2.md @@ -1 +1,5 @@ -hello-world! \ No newline at end of file +hello-world! + +testing 123 + +hello-world! hello-world! hello-world! hello-world!hello-world! hello-world! hello-world! hello-world! hello-world! hello-world!