TextureLoader issue

I’m having issues with TextureLoader

Books.prototype.initMaterials = function() {
	var self = this;
	self.materials = [];
	
	var $textureImgEls = $("#textures .texture");
	$textureImgEls.each(function() {
		//var texture = THREE.ImageUtils.loadTexture(this.src);
		var texture =new THREE.TextureLoader();
		texture.load(this.src);
		self.materials.push(new THREE.MeshLambertMaterial({map: texture}));
		// this.addEventListener("click", function(){ alert("Hello World!")});

	// console.log(this.src);
	//imgs.push(this.src);
	
	});
	// console.log(imgs);
};
Error:  41 Uncaught TypeError: Cannot read property 'load' of undefined

Try this:

var loader = new THREE.TextureLoader();
var texture = loader.load(this.src);

that doesnt change anything

This example might help: https://threejs.org/examples/#webgl_geometry_cube

1 Like

Thank You Mugen87