Is there a way to retrieve the text from THREE.TextGeometry?

I recently generated a new Mesh using TextGeometry and added it to an array of meshes:

var text3d = new THREE.TextGeometry( "Hello!", {
    font: "Helvetica"
});
text3d.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial({ color: 0xb0bca7, overdraw: true });
meshArray.push(new THREE.Mesh( text3d, textMaterial ));

This leads me to the following inquiries:

  1. How can I retrieve the original text from the text3d object?
  2. How can I extract the same text from the Mesh object stored in meshArray?

Unfortunately, the documentation did not provide me with any useful information.

Answer №1

When using THREE.TextGeometry, the text is immediately converted to shapes and not stored in its original form. Retrieving the original text later on is not possible.

However, you can assign a variable to the created text3d object in JavaScript if needed.

var myText = "Greetings!";
var text3d = new THREE.TextGeometry(myText, {
    font: "helvetiker"
});
text3d.text = myText; // saving for future reference...
text3d.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial({ color: 0xffcc00, overdraw: true });
meshArray.push(new THREE.Mesh(text3d, textMaterial));

If you decide to save the text for later use, you can access it with text3d.text, or retrieve it from the Mesh using mesh.geometry.text or meshArray[xxx].geometry.text.

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

The Kendo UI Grid will consistently begin at Page 0

I have a Kendo UI Grid and it always starts at 0. When I change the sort on a column, it goes to 1 and displays the other page numbers. What could be the issue? Below is the code snippet: $('#userGrid').kendoGrid({ dataSource: ...

Unable to find 'react/lib/merge' module

I'm currently working on a React project and utilizing Babel and Webpack. Within one of my files, I have this require statement: var merge = require('react/lib/merge'); Unfortunately, I'm encountering the following error: ERROR in . ...

Is there a specific event in fancytree that is triggered once the tree data has finished loading entirely?

Is there a way to determine when fancytree has finished loading data and the component is fully loaded in order to change its options? I am currently attempting to change the selectMode (for example, from 3 to 2), but the data is not being fully loaded a ...

Import a JavaScript dependency from a browserify bundle

I am faced with a challenge in my single page app that consists of a JS bundle created using Browserify and Coffeescript. There is a specific scenario where I need to create a standalone page detached from the SPA. This adhoc page requires access to a lib ...

Managing consecutive synchronous side effects that are dependent on each other using React hooks

I am currently in the process of transitioning my application from using Redux to the new context and hooks, but I am facing challenges when it comes to handling a series of synchronous side-effects that rely on the response of the previous one. In my exi ...

Retrieve Chosen Option in AngularJS

One issue I am facing is related to an ng-repeat that displays users in rows. When a user is clicked, it opens a modal popup for editing the user and displays all user details. However, when I select another role for the user and try to retrieve the newly ...

Tips for using MatTableDataSource in a custom Thingsboard widget

After creating multiple custom Thingsboard widgets, I've discovered that I can access a significant portion of @angular/material within my widget code. While I have successfully implemented mat-table, I now want to incorporate pagination, filtering, a ...

The Vuetify Jest button trigger fails to function properly despite utilizing a spy

Recently delved into the world of Vue.js and Jest to see how they interact. I watched some tutorials and then decided to give it a go myself, but ran into trouble with getting the trigger click to work. Within my component, I have a login button, which is ...

Tips for testing Sequelize with Jasmine

In my database/index.ts file, I set up a Sequelize database using the code below: import { Sequelize } from 'sequelize'; const { DATABASE_DIALECT, DATABASE_HOST, DATABASE_PORT, DATABASE_USER_NAME, DATABASE_USER_PASSWORD, DATABASE_NAM ...

Using NodeJS to assign key-value pairs to a JSON object

I am currently working with a NodeJS script that receives data in the form of "key, value" pairs and I need to transform this data into a JSON object. The data is obtained using SNMP where the key corresponds to the OID. My goal is to efficiently map thes ...

Handling Camera Positioning and Direction in Three.js: Utilizing Orbit Controls and camera

Having trouble getting Orbit Controls to function correctly after setting the camera to : camera.up.set(0,0,1) This results in improper orbiting behavior, and there are some unresolved questions online addressing this issue: Three.js: way to change the u ...

Tips for detecting when the MDC Snackbar has been closed using JavaScript

I'm currently working with Material Design's Snackbar in combination with VueJS. My goal is to detect when the snackbar has finished closing. The Snackbar object does have a property called isOpen, which allows me to check if the snackbar is ope ...

Tips for effectively dividing a component's code into smaller sub-components

Within my component MyComp, there exists an extensive code that I wish to divide into 3 separate components. In envisioning the structure of MyComp, I am seeking general advice and a brief example in response: import React, { Component, Fragment } from & ...

Deactivate the Autofill feature on Google Toolbar

Dealing with the Google Toolbar's autofill feature has been a constant frustration in my web development journey over the years. I have resorted to creating a timer control to monitor changes, as the developers overlooked firing change events on contr ...

Instantaneous data refresh using Firebase Cloud Functions

Currently, I am working on developing a chat feature in React using Firebase cloud functions. However, I am facing an issue where I do not receive updates when a user sends a message. Below is the code snippet that I have been working with: const app = a ...

What factors outside of the program could potentially lead to the splice function not functioning as expected?

Within my code, I encountered a peculiar issue involving a splice line along with debug lines on both sides. Take a look: const obj = { x:[1,2], y:{t:"!!!"} } const lenBefore = S.groupings.length const ret = S.groupings.splice(gix, 0, obj) console.log(`${ ...

Having trouble sending data through a jQuery AJAX request?

When I make a post request using jQuery AJAX to an ActionResult method, I encounter the following issue: $("#itemTextbox, #itemTextboxNew, #quantity1Textbox").on("keydown", function (e) { if ((e.keyCode == 120){ var GetReportLast5SellAndBuyURL="/Trd/Se ...

Sharing the state of a button group across different tabs using Bootstrap 5 and JQuery (or pure JavaScript): A complete guide!

Creating a tabbed web page using Bootstrap 5 nav-tabs for the front end and JQuery for the back end. I aim to have a single radio button group displayed on all tabs, with the state of the group persisting across tab changes. Currently, both tabs display t ...

What is the best way to paginate aggregated results in Mongoose?

In my project, I have a User model that is linked to two other associated models - Profile and WorkProfile. The Profile model contains basic information about the user like name, email, and home address, while the WorkProfile model stores details such as o ...

Material design for Angular applications - Angular Material is

Recently, I decided to explore the world of Angular and its accompanying libraries - angular-material, angular-aria, and angular-animate. I'm eager to experiment with this new styling technique, but it seems like I've hit a roadblock right at the ...