我已经使用 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)