THREE JS TextureLoader

前端 未结 3 516
遥遥无期
遥遥无期 2020-12-17 07:09

I am trying to add texture to a model that I converted to json and imported from 3ds Max. I searched but didn\'t find any code online which applies texture to json models us

3条回答
  •  -上瘾入骨i
    2020-12-17 07:25

    This worked for me on September 2019

    load(
        url: string,
        onLoad?: ( texture: Texture ) => void,
        onProgress?: ( event: ProgressEvent ) => void,
        onError?: ( event: ErrorEvent ) => void
    ): Texture;
    
    setCrossOrigin( crossOrigin: string ): TextureLoader;
    

    Usage:

    // instantiate a loader & load a resource
    new THREE.TextureLoader().load(
        // resource URL
        'textures/land_ocean_ice_cloud_2048.jpg',
    
        // onLoad callback
         ( texture )=> {
            // in this example we create the material when the texture is loaded
            var material = new THREE.MeshBasicMaterial( {
                map: texture
             } );
        },
    
        // onProgress callback currently not supported
        undefined,
    
        // onError callback
        ( err )=> {
            console.error( 'An error happened.' );
        }
    );
    

提交回复
热议问题