Bending 3D Text with Three.js

Has anyone confirmed if this feature is still available in the latest version? I'm working on customizing my own solution, but before diving in further, I want to double-check that I haven't missed any important resources or helpful libraries...

Answer №1

Check out this example to see how it works. Pay attention to the messages in the console.

<script src="js/modifiers/BendModifier.js"></script>
var text = "THREE.BendModifier";
var textGeometry = new THREE.TextGeometry(text, {
    size: 128,
    height: 50,
    curveSegments: 4,
    font: "gentilis",
    weight: "bold",
    style: "normal",
    bevelEnabled: true,
    bevelThickness: 2,
    bevelSize: 1,
});


var textMaterial = new THREE.MeshPhongMaterial({
    color: 0x62254a
});
var text3D = new THREE.Mesh(textGeometry, textMaterial);

var direction = new THREE.Vector3(0, 0, -1);
var axis = new THREE.Vector3(0, 1, 0);
var angle = Math.PI / 6;

var modifier = new THREE.BendModifier();
modifier.set(direction, axis, angle).modify( text3D.geometry );

textGeometry.computeBoundingBox();
var textWidth = textGeometry.boundingBox.max.x - textGeometry.boundingBox.min.x;
text3D.position.set(-0.5 * textWidth, 500, 0);
scene.add(text3D);

Answer №2

Noticing a crucial update for BendModifier.js - you'll need to refer to this guide to ensure compatibility with the latest versions of three.js

BendModifier.js previously utilized THREE.Matrix3.getInverse() which is now outdated. To adapt, switch to using THREE.Matrix4.getInverse(..) in BendModifier.js as well as incorporating another modification outlined in the linked answer.

Another notable change is in text generation - leveraging THREE.fontLoader()

For a functional example, check out this reference link

View a screenshot of the website here

Furthermore, detailed instructions on the necessary adjustments:

With the recent THREE.js update, simply tweak the BendModifier.js script by modifying the following lines:

var InverseP =  new THREE.Matrix3().getInverse( P );

and

newVertices[i] = new THREE.Vector3(); newVertices[i].copy( geometry.vertices[i] ).applyMatrix3( InverseP );

Replace Matrix3 with Matrix4 in both instances, resulting in:

var InverseP =  new THREE.Matrix4().getInverse( P );

and

newVertices[i] = new THREE.Vector3(); newVertices[i].copy( geometry.vertices[i] ).applyMatrix4( InverseP );

Tested successfully with three.min.81.js version.

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

What could be causing the browser.get method to fail to redirect to the specified URL?

I have organized my files in a folder structure that looks like this: project structure Currently, I am following the steps outlined in this particular tutorial The contents of my package.json file are as follows: { "name": "node_cucumber_e2e", "ver ...

I am experiencing an issue with the Jstree Leaf Node icons displaying as expandable instead of showing a minus (-) sign for leaf nodes

My theme is currently set to "themes": { "theme": "proton" }, On my JavaScript tree image, the leaf nodes are indicated by a plus sign (+) and they cannot be expanded. See the highlighted section below. ...

Filtering objects in JavaScript using a technique similar to list comprehension

I'm dealing with a basic array structure that resembles: obj = {1:false, 2:true, 3:true} My goal is to extract an array containing all the keys in the object that have a value of true. In Python, you can achieve this easily using: >>> [ke ...

The gradual vanishing of principles

Below you will find text fields that I am populating with values that are later utilized in a JavaScript function. These fields are all contained within a form. The issue I am encountering is that when I submit the form, I initially get the correct value ...

Error: The module 'cropbox' could not be located. 2

I posed the inquiry Module not found: Error: Can't resolve 'cropbox' Unfortunately, I did not receive a response, prompting me to delve into more specific issues and scour StackOverflow for solutions. After investigating, I identified thr ...

Applying a variety of class names in real-time based on JSON data results

Extracting multiple class names from a single key value in a JSON response and dynamically binding these class names. Here is an example of my JSON result: [ { "categoryId": 1, "categoryValue": "Mobiles", "divId": "MobilesId", "uiClass": ...

Unable to render Google map on Vue CLI component

I am currently using the google map api to develop a basic application with vue.js. Interestingly, when I utilize a simple html and javascript setup with the api key, everything runs smoothly. However, once I transition the same process to vue, the map fai ...

Angular webpage failing to display JSON data received from Node backend server

Embarking on my journey in modern web development, I've been diving into the MEAN stack with online tutorials. My current project involves building a basic todo app that facilitates CRUD operations. Utilizing the MEAN stack (Mongo database via Mongola ...

Avoid unnecessary re-renders in ReactJS Material UI tabs when pressing the "Enter

I've created a user interface with tabs using material-ui in reactJS. The issue I'm facing is that every time a tab is selected, the content under that tab reloads, causing performance problems because there's an iFrame displayed in one of t ...

Karma-coverage examines the test coverage of JavaScript files rather than TypeScript files within Angular 2

I am facing an issue with checking test coverage in TypeScript files using Istanbul and setting test thresholds via karma-coverage. The problem arises because karma-coverage checks test coverage in JavaScript files instead of TypeScript, which leads to mis ...

Guide on showing the message "loading" following multiple executions of JavaScript functions?

I recently customized a SharePoint list page for a new form. On this page, I've implemented a JS function that loads various documents from the document library into a Telerik RadComboBox component. However, when there are a lot of documents to load, ...

How can I resolve the Error: Element type is invalid?

https://i.sstatic.net/9PehR.jpgI am encountering the error message displayed above, and I am uncertain about the cause of this issue. In the code snippet below, I am fetching data from a file named Data.js located in my root folder. When I run the app, I r ...

Creating visuals from written content

I am attempting to transform Y[0] into an image rather than text. Currently, it is only displayed as a plain text link and not as an image. <html> <head> <script type="text/javascript"> function modifyContent(){ var rows=document.g ...

Press the button to automatically scroll to a designated div section

One of the challenges I'm facing involves a fixed menu and content box (div) on a webpage. Whenever I click on the menu, the content box should scroll to a specific div. Initially, everything was working fine. Here is a sample of it in action: http ...

Transitioning Pace.JS Across a Webpage

My dilemma involves a 200px wide sidebar and trying to have my pace.js bar load beside it, with a margin of 200px to its left. Here is the CSS I've been using for editing: .pace-progress { background: #2dbaa6 !important; position: fixed; z-i ...

Create a web application in NodeJS that mimics browser functionality by running JavaScript code from an HTML page

I'm a beginner in NodeJS and I am working on developing a web service that can send a response with the output of a JavaScript script from an HTML page sourced online. For instance: Imagine my webpage contains a JavaScript snippet that outputs "hell ...

What is the process for removing a document attribute in Sanity iO?

I have a collection of objects within my Sanity Document named Images which includes Comments An example comment object in the comments array looks like: { "_key": "6510dc79cf8b", "comment": "Hello world" ...

What could possibly be the issue with this mongoose query?

const images = await tbl .find({ creator_id: req.user._id, }) .select({ creator_id: 0, }) .then((images) => images.forEach((image) => { image.file_name = process.env.IMAGE_HOST_URL + ima ...

Interactive Mini Games - AJAX Edition

If you haven't heard of Microgames before, take a look at this video showcasing WarioWare Twisted. I have a vision of creating a platform where users can engage in a series of browser-based Microgames delivered to them through a server. My goal is to ...

Connected Date Selector

I am new to using Bootstrap and attempting to implement a linked datepicker with the following requirements: Display only the date (not the time). The default selected date on page load should be today's date for both the Datepicker and the text ...