( where, name, sourceFile, repeat, offset, wrap )
| 8076 | } |
| 8077 | |
| 8078 | function createTexture( where, name, sourceFile, repeat, offset, wrap ) { |
| 8079 | |
| 8080 | where[ name ] = new THREE.Texture(); |
| 8081 | where[ name ].sourceFile = sourceFile; |
| 8082 | |
| 8083 | if ( repeat ) { |
| 8084 | |
| 8085 | where[ name ].repeat.set( repeat[ 0 ], repeat[ 1 ] ); |
| 8086 | |
| 8087 | if ( repeat[ 0 ] !== 1 ) where[ name ].wrapS = THREE.RepeatWrapping; |
| 8088 | if ( repeat[ 1 ] !== 1 ) where[ name ].wrapT = THREE.RepeatWrapping; |
| 8089 | |
| 8090 | } |
| 8091 | |
| 8092 | if ( offset ) { |
| 8093 | |
| 8094 | where[ name ].offset.set( offset[ 0 ], offset[ 1 ] ); |
| 8095 | |
| 8096 | } |
| 8097 | |
| 8098 | if ( wrap ) { |
| 8099 | |
| 8100 | var wrapMap = { |
| 8101 | |
| 8102 | "repeat": THREE.RepeatWrapping, |
| 8103 | "mirror": THREE.MirroredRepeatWrapping |
| 8104 | |
| 8105 | } |
| 8106 | |
| 8107 | if ( wrapMap[ wrap[ 0 ] ] !== undefined ) where[ name ].wrapS = wrapMap[ wrap[ 0 ] ]; |
| 8108 | if ( wrapMap[ wrap[ 1 ] ] !== undefined ) where[ name ].wrapT = wrapMap[ wrap[ 1 ] ]; |
| 8109 | |
| 8110 | } |
| 8111 | |
| 8112 | // load image |
| 8113 | |
| 8114 | var texture = where[ name ]; |
| 8115 | |
| 8116 | var loader = new THREE.ImageLoader(); |
| 8117 | loader.addEventListener( 'load', function ( event ) { |
| 8118 | |
| 8119 | var image = event.content; |
| 8120 | |
| 8121 | if ( !isPow2( image.width ) || !isPow2( image.height ) ) { |
| 8122 | |
| 8123 | var width = nearestPow2( image.width ); |
| 8124 | var height = nearestPow2( image.height ); |
| 8125 | |
| 8126 | texture.image = document.createElement( 'canvas' ); |
| 8127 | texture.image.width = width; |
| 8128 | texture.image.height = height; |
| 8129 | texture.image.getContext( '2d' ).drawImage( image, 0, 0, width, height ); |
| 8130 | |
| 8131 | } else { |
| 8132 | |
| 8133 | texture.image = image; |
| 8134 | |
| 8135 | } |
no test coverage detected