- This topic has 76 replies, 10 voices, and was last updated 5 years, 8 months ago by Yuri Kovelenov.
-
AuthorPosts
-
2018-05-16 at 6:52 pm #4196DzynekParticipant
Hi
I tried to add a preloader function (ATI2.js, line 130) but unfortunately it does not work
var loader = new v3d.ImageLoader(); loader.load( diffuseURL, function(image) { obj.material.map.image = image; obj.material.map.needsUpdate = true; }, function ( xht ) { console.log( (xht.loaded / xht.total * 100) + '% loaded' ); }, function ( xhr ) { console.log( 'An error happened' ); } )
2018-05-16 at 7:12 pm #4198DzynekParticipantI forgot to add a file
2018-05-17 at 8:00 am #4203Yuri KovelenovStaffI did some searching and it appears that progress event handler is currently disabled for ImageLoader.
https://github.com/mrdoob/three.js/issues/10439
There are some suggestion how to work around this in that Github thread. Another approach can be simply showing some animated .gif while it loads.
2018-05-17 at 1:21 pm #4206johngrigniCustomerIt’s me again, and I tried copying the script over to a new version of the same project and I keep getting this error when I try to call the function:
[Error] TypeError: null is not an object (evaluating ‘obj.material.map.image = image’)
(anonymous function) (ATI_Lobby.js:131)
(anonymous function) (v3d.js:1:517256)As far as I know I’m doing the exact same thing as before. Here is the function in ATI_Lobby.js:
app.ExternalInterface.changeDiffuse = function(objName, diffuseURL) {
app.scene.traverse(function(obj){
if (obj.name == objName) {var loader = new v3d.ImageLoader();
loader.load(diffuseURL, function(image) {
obj.material.map.image = image;
obj.material.map.needsUpdate = true;
})
}
});
}2018-05-17 at 2:12 pm #4210johngrigniCustomerScratch that, I figured it out. I had made an error applying textures in the Blend file.
2018-05-17 at 2:19 pm #4212DzynekParticipantThank you for the answer :)
I inserting this function at the beginning document ATI2.js:
// preloader ImageLoader() fix THREE.ImageLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { var scope = this; var image = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'img' ); image.onload = function () { image.onload = null; URL.revokeObjectURL( image.src ); if ( onLoad ) onLoad( image ); scope.manager.itemEnd( url ); }; image.onerror = onError; var loader = new THREE.FileLoader(); loader.setPath( this.path ); loader.setResponseType( 'blob' ); loader.setWithCredentials( this.withCredentials ); loader.load( url, function ( blob ) { image.src = URL.createObjectURL( blob ); }, onProgress, onError ); scope.manager.itemStart( url ); return image; }, setCrossOrigin: function ( value ) { this.crossOrigin = value; return this; }, setWithCredentials: function ( value ) { this.withCredentials = value; return this; }, setPath: function ( value ) { this.path = value; return this; } }
Preloader work but, there was a problem when the image does not have time to load and (fast) hits the button again
I would be grateful for the solution
I attach an example
2018-05-17 at 3:35 pm #4231Yuri KovelenovStaffScratch that, I figured it out. I had made an error applying textures in the Blend file.
2018-05-17 at 3:37 pm #4232Yuri KovelenovStaffPreloader work but, there was a problem when the image does not have time to load and (fast) hits the button again
I downloaded your example. What button should I click in order to manifest this issue?
2018-05-17 at 4:16 pm #4233DzynekParticipantinstruction in picture
2018-05-17 at 4:23 pm #4235DzynekParticipantI suspect that this function
File ATI2.js line 172-175function (xhr ) { var xSize= (xhr.loaded / xhr.total) ; app.ExternalInterface.showMyPreloader(xSize); },
repeats at the same time, i think
I need to stop charging early unfinished Loads
2018-05-17 at 8:27 pm #4237DzynekParticipantI did it differently and it works :)
I submit a working project
Thank and best regards
2018-05-18 at 7:44 am #4240Yuri KovelenovStaff2018-06-03 at 11:38 pm #4584johngrigniCustomerIs there a way to modify this to work with PBR textures? I tried it as is and it doesn’t work. Perhaps normal and diffuse textures are treated differently in PBR? Again, thanks for an excellent program.
2018-06-04 at 2:05 pm #4591Ivan LyubovnikovStaffIs there a way to modify this to work with PBR textures?
Hi, it works for me, I tested it with a pbr material from the sdk’s Pbr demo. I attached the modified example.
Co-founder and lead developer at Soft8Soft.
2018-06-04 at 2:13 pm #4592johngrigniCustomerI’m not seeing an attachment, but I’ll try it again.
-
AuthorPosts
- You must be logged in to reply to this topic.