We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Dzynek

Forum Replies Created

Viewing 3 posts - 31 through 33 (of 33 total)
  • Author
    Posts
  • in reply to: Replacing textures rather than materials #4212
    Dzynek
    Participant

    Thank 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

    in reply to: Replacing textures rather than materials #4198
    Dzynek
    Participant

    I forgot to add a file

    in reply to: Replacing textures rather than materials #4196
    Dzynek
    Participant

    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' );
    					}
    			)
Viewing 3 posts - 31 through 33 (of 33 total)