小编Pet*_*sen的帖子

使用 React 时 Threejs 使用 fontloader 加载字体会抛出错误

我将ThreeJS库与React一起使用。

我已经使用 npm安装了 ThreeJS 。

添加图像工作正常 - 我正在像这样在反应中导入图像:

import stockImage from './../../images/download.jpg';
Run Code Online (Sandbox Code Playgroud)

像这样使用它效果很好:

this.addCube(stockImage, { x:2, y:2, z:2 } );

(...)

addCube(imageUrl, aPosition) {
        //Load image as material:
        var anImageMaterial = new THREE.MeshBasicMaterial({
            map : this.textureLoader.load(imageUrl)
        });
        //Make box geometry:
        var box = new THREE.BoxGeometry( 1, 1, 1 );
        //Create mesh:
        var cube = new THREE.Mesh( box, anImageMaterial );
        //Add to scene:
        this.scene.add( cube );
        return cube;
    }
Run Code Online (Sandbox Code Playgroud)

尝试使用本教程将文本添加到画布时。

我正在尝试以如下方式导入字体:

import helveticaRegular …
Run Code Online (Sandbox Code Playgroud)

three.js reactjs

1
推荐指数
1
解决办法
1231
查看次数

标签 统计

reactjs ×1

three.js ×1