Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught type error when loading TextGeometry font

Tags:

I'm trying to use a loaded typeface.js font, as provided by Three.js examples, yet I keep on getting the following error:

Uncaught TypeError: this.addShapeList is not a function

I've checked Three.js file, I'm using the build version from the three.js master branch, for the reasoning for the error and it seems that THREE.ExtrudeGeometry scoped this is missing all the prototype methods declared previously.

Altering the code to use THREE.ExtrudeGeometry.addShapeList instead of this.addShapeList failed later on when reaching method THREE.ExtrudeGeometry.prototype.addShape by failing to recognize the vertices array of the scope.

I'm of course doing something wrong in creating the TextGeometry yet I'm unable to figure what.

This is the code I use to load the font, creating the TextGeometry object and adding it to the scene.

loader.load('./fonts/gentilis_bold.typeface.js', function(response){
        font = response;
        var text = THREE.TextGeometry('Some Text', {
            font: font,
            size: 70
        });

        scene.add(text);
    });

Here is a fiddle to showcase my issue.

like image 542
Shahar Galukman Avatar asked Apr 25 '16 21:04

Shahar Galukman


1 Answers

You forgot about the new operator:

var text = new THREE.TextGeometry('Some Text', {

[ https://jsfiddle.net/kmny9gbc/ ]

like image 151
stdob-- Avatar answered Sep 28 '22 03:09

stdob--