我有一个作为JSON导入的Boat模式。现在我正试图导入它的纹理贴图以应用它的网格。
模型加载正常,但是当我使用TGALoader尝试加载纹理.tga
文件时,我收到此错误:
Uncaught TypeError: THREE.TGALoader is not a constructor
我已经四处搜寻其他任何此类情况但无法找到。我对三个人非常陌生,所以我很抱歉 - 这可能是一个非常棒的问题。
以下是Boat
类的代码:
var scale = 10;
class Boat {
constructor(scene) {
var loader = new THREE.JSONLoader();
var textureLoader = new THREE.TGALoader();
// Texture
var texture = textureLoader.load('models/BW Bandit all in one.tga');
// Model
loader.load('models/boat.json', handle_load);
function handle_load(geom, mats) {
var material = new THREE.MeshPhongMaterial({
color: 0xffffff,
map: texture
});
var mesh = new THREE.Mesh(geom, material);
scene.add(mesh);
mesh.position.z = -5;
mesh.scale.set(scale, scale, scale);
mesh.rotation.y = -90;
}
}
}
答案 0 :(得分:3)
您需要在文件顶部找到TGALoader.js加载程序。
例如说:
<script src="path_to_parent_folder_of_threeJS/threeJS/examples/js/loaders/TGALoader.js"></script>