The ObjectLoader.parseImages()
method is a function defined in the Three.js library that is used to parse images from JSON data. This function is typically used in conjunction with the ObjectLoader.parse()
method to load and parse 3D object data.
ObjectLoader.parseImages( json, onLoad, onProgress, onError );
json
— A JSON object representing the images to be loaded and parsed.onLoad
— A callback function that is called when all images have been loaded and parsed.onProgress
— A callback function that is called periodically to report the progress of the image loading process.onError
— A callback function that is called if any errors occur during the image loading and parsing process.This method does not return anything.
var loader = new THREE.ObjectLoader();
// Define a JSON object containing image data.
var imageJSON = {
"textures": [
{
"uuid": "3C8B31C2-B32C-420D-B835-BDD5C2B75A46",
"url": "textures/texture1.jpg"
},
{
"uuid": "813A3F3C-0D56-480A-9D9C-20E8BF69A0A2",
"url": "textures/texture2.jpg"
}
]
};
// Load and parse the images from the JSON object.
loader.parseImages( imageJSON, function () {
console.log( "Images loaded and parsed successfully!" );
}, function ( progress ) {
console.log( "Loading progress: " + progress + "%" );
}, function ( error ) {
console.log( "Error loading images: " + error );
} );
The ObjectLoader.parseImages()
method is used internally by the ObjectLoader.parse()
method to load and parse images as part of the overall 3D object loading process. This method is not typically called directly by front-end developers, but instead is called indirectly through the ObjectLoader.parse()
method.
Note that the url
property of each image in the JSON object is relative to the root directory of the web server. If the images are stored in a directory other than the root directory, this property must be updated accordingly.