Encountering errors when attempting to load text using three.js

I've been struggling for hours to display text using three.js. My attempt was to use three-bmfont-text following the steps in this guide, but I keep encountering these errors:

THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers

and after a few seconds, the app crashes with this error message:

this.scene.add is not a function

Although when I log this.scene, it does return the correct scene.

What should I do differently here? Do I need to change my approach to loading text?

import * as THREE from 'three';

import fontFile from '../assets/fonts/RLUnno.fnt';
import fontAtlas from '../assets/fonts/RLUnno.png';

const MSDFShader = require('three-bmfont-text/shaders/msdf');
const createGeometry = require('three-bmfont-text');
const loadFont = require('load-bmfont');

export default class Title {
    constructor($el, $scene) {
        this.scene = $scene;
        this.title = $el;

        loadFont(fontFile, (err, font) => {

            const geometry = createGeometry({
                font: font,
                text: this.title.innerText
            });

            const loader = new THREE.TextureLoader();
            loader.load(fontAtlas, (texture) => {
                this.init(geometry, texture);
            })
        });
    }

   init = (geometry, texture) => {
        const material = new THREE.RawShaderMaterial(MSDFShader({
            map: texture,
            color: 0x000000,
            side: THREE.DoubleSide,
            transparent: true,
            negate: false
        }));

        const mesh = new THREE.Mesh(geometry, material);
        this.scene.add(mesh);
    };
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Jeditable feature on the Castle Monorail platform

Exploring the use of Jeditables (http://www.appelsiini.net/projects/jeditable) within my debut castle monorail mvc application Successfully displayed the textbox and executed the ajax call. However, encountering an issue post ajax call where the edited te ...

What is the process for adjusting the input value dynamically in reactjs?

I am working on a dynamic time input row and I need to ensure that the values are updated correctly. This is the code snippet I am using: https://codesandbox.io/s/624vq8y7y3 When I run the code, the values in the TimeInput field do not change as expected ...

Modifying the onclick function for a bootstrap glyphicon

How can I swap the .glyphicon-menu-down to glyphicon-menu-up when a user clicks on a link? Currently, it's not working as expected. Could there be an issue with my jQuery implementation? Markup <a data-toggle="collapse" data-parent="#accordion" h ...

Obtain the chosen item from a Bootstrap4 dropdown menu by utilizing a button

I am struggling to get a button with dropdown working in Bootstrap4. Below is the HTML code: <div class="row" id="dropdown-box"> <div class="col-lg-6"> <div class="input-group"> <div class="input-group-btn" id="button-grou ...

Using node.js to import modules with relative paths

For my project structured following the MVC pattern, I have node.js modules in various directories. I need to use require to access modules located outside of the current directory. How can I achieve this? /app/controller/c1.js ... /app/model/m1.js ... ...

Data in the array is only updated upon refreshing the webpage

Why is the array empty when I navigate to a new route (/category/name-of-category) that renders my Category component, but it gets data when I refresh the page? What am I missing here? To better explain, I have created a video. Video showcasing the issue: ...

Utilize a date state variable in JSX Text based on a specific condition

My goal is to create a feature that allows users to pick a date using DateTimePickerModal. I want to display a clickable message that says "Select date" before any date is chosen, and then replace it with the selected date. While I am not certain if there ...

Error message: Modal.dispose function not available in Bootstrap 5 Symfony 5.3 issue detected

I have been working on creating a modal using Symfony 5 and Bootstrap 5. I want the form fields to be cleared when the modal is closed. Below are the relevant files. I am encountering an error when trying to close the modal: Uncaught TypeError: myModal.dis ...

The unique text: "User-defined input element disregards changes initiated through

I created a custom input component that functions correctly, but I have encountered an issue. When I attempt to update the value through a method, the model gets updated but the input value remains unchanged. Here is my component: https://codepen.io/ken-r ...

Using jQuery to crop an image while maintaining its aspect ratio

My website has two panels: a left panel for menus (370px width) and a right panel for content, mostly images, with padding-left set to 370px. I am currently using jQuery to resize images on document load, but they are stretching out of proportion. How can ...

My extension seems to be missing the content script I uploaded

I am currently developing an extension for Google Chrome. My goal is to create a content script that can retrieve meta tags from the tab when the popup is clicked. In my manifest, I have included the following permissions: "content_scripts": [{ "js" ...

Locate elements in a 2D Array with Google Apps Script

I am working with an array containing the values: [8:00 AM, 9:00 AM] //result of another function My goal is to locate these values within a 2-Dimensional Array: [ [8:00 AM], [9:00 AM], [10:00 AM], [11:00 AM], [12:00 NN], [1:00 PM], [2:00 P ...

Implementing double parentheses in the source code of an AngularJS input directive using JavaScript

I came across some unfamiliar syntax in the angularJs source code. Can someone provide an explanation for the expression within the parentheses of logical operators and dependency injection in "(inputType[lowercase(attr.type)] || inputType.text)(scope, ele ...

What methods are available for integrating ArcGIS JS into Vue.js?

I have been exploring the examples provided in the documentation for ArcGIS, but I am facing difficulties in using it correctly. For instance, when I try to import Map from ArcGIS as demonstrated in this example: import Map from '@arcgis/Map' I ...

Scrolling Effect with Fixed Background Image in FullPage JS

I am trying to use FullPage JS to create a fixed video background with scrolling content. The issue I am facing is that when I set the video to section 1, it shifts to a white background when scrolling. Any assistance would be highly appreciated! #fullp ...

What is the process for modifying JSON attributes with JavaScript?

One JSON data set is provided below: [{ ID: '0001591', name: 'EDUARDO DE BARROS THOMÉ', class: 'EM1A', 'phone Pai': '(11) 999822922', 'email Pai': '<a href="/cdn-cgi/l/em ...

pass extra parameters to breeze-saving-server functions

Currently, I am working on a project using Durandal. In order to retrieve and save data, I am using Breeze. However, I am facing an issue where I need to send additional parameters to the server when saving, such as the user who is saving the entity. The s ...

"Freezing issue with Angular big table causing web page to lock up during

Looking for a way to improve the performance of an HTML table search function that is currently running very slowly and freezing the web page upon loading and searching. The table needs to be within the HTML file itself, not pulling data from a server. Any ...

"Unexpectedly, JavaScript on Android ceases to function without any

Experiencing a frustrating issue with my application that involves a WebView and a html-page with JavaScript functions. Occasionally, the JavaScript functions fail to execute randomly. Despite spending the entire day trying to debug this issue, I can only ...

What is the best way to ensure that two Node processes do not insert duplicate database records when running concurrently?

My Lambda function receives a high volume of events simultaneously, causing AWS to spin up multiple instances to handle the load. The function written in Node.js uses Knex to interact with a Postgres database, checking if a record with a specific ID exists ...