TextGeometry results in "THREE.TextGeometry is not a constructor"

I am using the following code:

I am using it at the top of my project here: Scale Test Cubes - CodeSandbox

import { FontLoader } from "three/examples/jsm/loaders/FontLoader.js";

const loader = new FontLoader();

var xLengthText;

const font = loader.load(
  // resource URL
  "https://threejs.org/examples/fonts/helvetiker_regular.typeface.json",

  // onLoad callback
  function (font) {
    // do something with the font
    xLengthText = new THREE.TextGeometry("Hello three.js!", {
      font: font,
      size: 5,
      height: 5,
      curveSegments: 12,
      bevelEnabled: true,
      bevelThickness: 10,
      bevelSize: 8,
      bevelOffset: 0,
      bevelSegments: 5
    });
  },

  // onProgress callback
  function (xhr) {
    console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
  },

  // onError callback
  function (err) {
    console.log("An error happened");
  }
);

And I get the error:

TextGeometry is not part of the core three namespace you’ll have to import it eg.

import {TextGeometry} from 'three/addons/geometries/TextGeometry.js' 

See the official docs on TextGeometry

2 Likes
Could not find module in path: 'three/addons/geometries/TextGeometry.js' relative to '/src/index.js'

If all your other dependencies are using the path

three/examples/jsm/

Then TextGeometry will be using the same path…

three/examples/jsm/geometries/TextGeometry.js