Browse Source

font loading fixed for text content, and manged disposal of teleArc geom

master
Cailean Finn 2 weeks ago
parent
commit
6c1d7177dd
  1. 13
      js/Content.js
  2. 2
      js/Player.js
  3. 6
      public/texts/example.md
  4. 4
      public/texts/example2.md

13
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(() => {
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();
});
return this.displayMesh;
}

2
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;

6
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!
hello-world!
testing 123
hello-world! hello-world! hello-world! hello-world!hello-world! hello-world! hello-world! hello-world! hello-world! hello-world!

4
public/texts/example2.md

@ -1 +1,5 @@
hello-world!
testing 123
hello-world! hello-world! hello-world! hello-world!hello-world! hello-world! hello-world! hello-world! hello-world! hello-world!

Loading…
Cancel
Save