I am currently dealing with a Boat modal that is being imported as a JSON format. My current challenge involves importing its texture map to apply it to the mesh.
Although the model loads correctly, I encounter an error when attempting to load the texture's .tga
file using TGALoader:
Uncaught TypeError: THREE.TGALoader is not a constructor
Despite my efforts to search for similar instances of this issue, I have not been able to find any solutions. As someone who is relatively new to threejs, I apologize if this is considered a beginner question.
Below is the code for the Boat
class:
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;
}
}
}