Loading objects using the basic class - loader

Always, when loading any objects, be it materials, 3D models and the like, a special type of THREE.js library objects called loader has to be used.

circle-info

You can read more about loaders herearrow-up-right.

The loader is used to add, for example, material to the scene from the outside.

An example of using a loader is adding a texture to a plane (line 6):

let loader = new THREE.ImageLoader;

let planeGeometry = new THREE.PlaneGeometry(20, 5, 10, 10);
let planeMaterial = new THREE.MeshBasicMaterial({
	//Использование загрузчика
	map: loader.load("https://mywebar-a.akamaihd.net/1330/20322/Mywebar.png?hash=028902a08ce058c1a17f57b40d423ca9"),
	side:THREE.DoubleSide
});
plane = new THREE.Mesh(planeGeometry, planeMaterial);

So what are the limitations of using the loader?

Files cannot be imported from all servers. The server from which you import your file must allow resource sharing and have Access-Control-Allow-Origin. What it is, is written arrow-up-rightherearrow-up-right.

If the server does not allow resource sharing, you will see the following error in the console:

As it can be seen above, the link to the image from Google.Drive does not pass validation, due to which the scene cannot be launched and errors appear.

Last updated