How to use the DefaultLoadingManager function from three

Find comprehensive JavaScript three.DefaultLoadingManager code examples handpicked from public code repositorys.

three.DefaultLoadingManager is a class that manages the loading state of assets in a Three.js scene.

25
26
27
28
29
30
31
32
33
34
var connections;
var sceneGraph;

function FBXLoader( manager ) {

        this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;

}

FBXLoader.prototype = {
fork icon18
star icon229
watch icon9

+ 21 other calls in file

14
15
16
17
18
19
20
21
22
23

var ActiveXObject, xml;

THREE.VTKLoader = function (manager) {

        this.manager = (manager !== undefined) ? manager : THREE.DefaultLoadingManager;

};

Object.assign(THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
fork icon11
star icon28
watch icon2

How does three.DefaultLoadingManager work?

three.DefaultLoadingManager is a class in the Three.js library that manages the loading and progress of external resources such as textures, models, and audio files by tracking the state of loading and dispatching events. When a resource is loaded, the manager increments its internal counter and when all resources are loaded, it dispatches a "load" event. On the other hand, if any errors occur while loading a resource, the manager dispatches an "error" event. The progress of the loading process can be monitored by adding event listeners to the three.DefaultLoadingManager instance for the relevant events.

21
22
23
24
25
26
27
28
29
30
31
32


const DRACOLoader = ( function () { 


    function DRACOLoader (manager) {
        this.timeLoaded = 0;
        this.manager = manager || THREE.DefaultLoadingManager;
        this.materials = null;
        this.verbosity = 0;
        this.attributeOptions = {};
        this.drawMode = THREE.TrianglesDrawMode;
fork icon4
star icon26
watch icon0

+ 5 other calls in file

7
8
9
10
11
12
13
14
15
16
17
var Color = THREE.Color;
var Vector2 = THREE.Vector2;
var Face3 = require('../three/Geometry').Face3;
var Geometry = require('../three/Geometry').Geometry;
var FileLoader = THREE.FileLoader;
var DefaultLoadingManager = THREE.DefaultLoadingManager;
var VideoHandler = require('../videoHandler').VideoHandler;


/**
 * @author mrdoob / http://mrdoob.com/
fork icon10
star icon3
watch icon3

+ 23 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Create a new loading manager
const loadingManager = new THREE.LoadingManager();

// Listen for the "start" event
loadingManager.onStart = (url, itemsLoaded, itemsTotal) => {
  console.log(`Started loading file: ${url}.`);
};

// Listen for the "progress" event
loadingManager.onProgress = (url, itemsLoaded, itemsTotal) => {
  console.log(`Loaded ${itemsLoaded} of ${itemsTotal} files.`);
};

// Listen for the "error" event
loadingManager.onError = (url) => {
  console.error(`Error loading file: ${url}.`);
};

// Use the loading manager to load a texture
const textureLoader = new THREE.TextureLoader(loadingManager);
textureLoader.load("path/to/texture.jpg", (texture) => {
  // Do something with the loaded texture
});

In this example, a new three.DefaultLoadingManager object is created and used to listen for various loading events. A THREE.TextureLoader object is also created and passed the loading manager to track the loading of a texture.

560
561
562
563
564
565
566
567
568
569

loadTexture: function ( url, mapping, onLoad, onProgress, onError ) {

	var texture;
	var loader = THREE.Loader.Handlers.get( url );
	var manager = ( this.manager !== undefined ) ? this.manager : THREE.DefaultLoadingManager;

	if ( loader === null ) {

		loader = new THREE.TextureLoader( manager );
fork icon3
star icon6
watch icon1

+ 56 other calls in file

6
7
8
9
10
11
12
13
14
15
16
17
18
var THREE = window.THREE || require('three');
var MTLLoader = void 0;


MTLLoader = function MTLLoader(manager) {


	this.manager = manager !== undefined ? manager : THREE.DefaultLoadingManager;
};


Object.assign(MTLLoader.prototype, THREE.EventDispatcher.prototype, {

fork icon0
star icon2
watch icon1

+ 3 other calls in file

518
519
520
521
522
523
524
525
526
527

loadTexture: function ( url, mapping, onLoad, onProgress, onError ) {

	let texture;
	let loader = THREE.Loader.Handlers.get( url );
	let manager = ( this.manager !== undefined ) ? this.manager : THREE.DefaultLoadingManager;

	if ( loader === null ) {

		loader = new THREE.TextureLoader( manager );
fork icon0
star icon0
watch icon2

+ 43 other calls in file

237
238
239
240
241
242
243
244
245
246
  return state;
}
//
function OBJLoader(manager) {
  this.manager =
    manager !== undefined ? manager : THREE.DefaultLoadingManager;
  this.materials = null;
}
OBJLoader.prototype = {
  constructor: OBJLoader,
fork icon0
star icon0
watch icon1

+ 15 other calls in file

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)