i have some threejs code that’s to be the basis for a web based 3D file & data explorer app.
however, upon initializing the data i’ve hit a snag.
at nicerapp_v2/na3D.source.js at 493fe2e1eed5316681d17177e99b99920978093d · nicerapp/nicerapp_v2 · GitHub , i initialize a bunch of filesystem data recursively (data is viewable at nicerapp_v2/backgrounds_recursive.json at 493fe2e1eed5316681d17177e99b99920978093d · nicerapp/nicerapp_v2 · GitHub ), with the intent of creating one folder GLTF (webGL) icon per folder in the dataset.
at both debugger statements, the data in my browser debugger shows correctly.
BUT… inside the t.loader.load() call’s callback for a successful load, i get only the last ‘it’ variable, and the same for each of the GLTF load calls on any given level.
i’ve tried passing the ‘it’ (that’s short for ‘item’, btw) variable as an extra parameter to t.loader.load(), but that just results in ‘it’ being ‘undefined’ when it hits the debugger statement inside the GLTF-load-complete handler.
i’m wondering how to fix this. i’m wondering if i even can at all
i dug into the source of threejs and it was fairly easy to adapt, so i did that…
return new GLTFMeshoptCompression( parser ); } ); } GLTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: GLTFLoader, load: function ( url, onLoad, onProgress, onError, it ) { var scope = this; var resourcePath; if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; } else if ( this.path !== '' ) {
and
loader.setResponseType( 'arraybuffer' ); loader.setRequestHeader( this.requestHeader ); loader.setWithCredentials( this.withCredentials ); loader.load( url, function ( data ) { try { scope.parse( data, resourcePath, function ( gltf ) { onLoad( gltf, it ); scope.manager.itemEnd( url ); }, _onError ); } catch ( e ) { _onError( e ); }
and of course
levelIdx : t.ld[level].levelIdx, parent : t.ld[level].parent, children : [], path : t.ld[level].path } items[items.length] = it; t.ld[level+1].initItemsDoingIdx++; t.ld[level+1].levelIdx++; debugger; t.loader.load( '/nicerapp/3rd-party/3D/models/folder icon/scene.gltf', function ( gltf, it ) { gltf.scene.scale.setScalar (20); t.scene.add (gltf.scene); it.model = gltf.scene; it.model.it = it; t.updateTextureEncoding(t, gltf.scene); debugger; t.initializeItems (t, items, itd, t.ld[level].initItemsDoingIdx, level + 1); }, function ( xhr ) { console.log( 'model "folder icon" : ' + ( xhr.loaded / xhr.total * 100 ) + '% loaded' ); }, function ( error ) {
and
t.scene.add (gltf.scene); it.model = gltf.scene; it.model.it = it; t.updateTextureEncoding(t, gltf.scene); debugger; t.initializeItems (t, items, itd, t.ld[level].initItemsDoingIdx, level + 1); }, function ( xhr ) { console.log( 'model "folder icon" : ' + ( xhr.loaded / xhr.total * 100 ) + '% loaded' ); }, function ( error ) { console.error( error ); }, it ); } t.ld[level].initItemsDoingIdx++; t.ld[level].levelIdx++; clearTimeout (t.onresizeTimeout); t.onresizeTimeout = setTimeout(function() { t.onresize (t); }, 500); }