|
1869 | 1869 | mouse_wheel = true;
|
1870 | 1870 |
|
1871 | 1871 | let image_name = (document.getElementById('file_image_input').value).toUpperCase();
|
| 1872 | + let svg = (image_name.endsWith('.SVG') === true && navigator.userAgent.indexOf('Safari') > -1); |
1872 | 1873 | let exr = (image_name.endsWith( '.EXR' ) === true);
|
1873 | 1874 | let hdr = (image_name.endsWith( '.HDR' ) === true);
|
1874 | 1875 | let hd = (exr === true || hdr === true);
|
1875 | 1876 |
|
1876 | 1877 | let clone;
|
1877 | 1878 |
|
1878 |
| - if (bg_flip === true) { |
| 1879 | + if ((bg_flip === true && svg === false) || (bg_flip === false && svg === true)) { |
1879 | 1880 | const options = { imageOrientation: 'flipY' };
|
1880 | 1881 | const imageBitmap = await createImageBitmap( scene_bgnd.image, options );
|
1881 | 1882 | clone = new THREE.CanvasTexture( imageBitmap );
|
|
2168 | 2169 | const res = (isMobile === true ? M2K : (isNewiPad === true ? I8K : D16K));
|
2169 | 2170 |
|
2170 | 2171 | if (fii.type.startsWith('image/') && ! (exclude_extensions.some( ext => fn_uc.endsWith( ext ) ))) {
|
2171 |
| - let svg = (fn_uc.endsWith('.SVG') === true && navigator.userAgent.indexOf('Safari') > -1); |
2172 |
| - |
2173 | 2172 | texture_loader.load( URL.createObjectURL( fii ) , async function( texture ) {
|
2174 | 2173 | URL.revokeObjectURL( fii );
|
2175 | 2174 |
|
|
2187 | 2186 |
|
2188 | 2187 | // Get canvas texture with bitmap image
|
2189 | 2188 | texture = await resize_texture( texture, res, false, fii.type );
|
2190 |
| - if (svg === true) texture.flipY = false; |
2191 | 2189 |
|
2192 | 2190 | hdrjpg_texture = false;
|
2193 | 2191 |
|
|
2269 | 2267 | URL.revokeObjectURL( fii );
|
2270 | 2268 | });
|
2271 | 2269 | } else if (fn_uc.endsWith('.KTX2')) {
|
2272 |
| - try { |
2273 |
| - ktx2_loader.load( URL.createObjectURL( fii ), async function( texture ) { |
2274 |
| - URL.revokeObjectURL( fii ); |
2275 |
| - |
2276 |
| - // Unsupported KTX2 formats might log a warning |
| 2270 | + ktx2_loader.load( URL.createObjectURL( fii ), async function( texture ) { |
| 2271 | + URL.revokeObjectURL( fii ); |
2277 | 2272 |
|
2278 |
| - if (texture.colorSpace === 'display-p3') texture.colorSpace === 'srgb'; |
| 2273 | + // Unsupported KTX2 formats might log a warning |
2279 | 2274 |
|
2280 |
| - // Get canvas texture with bitmap image |
| 2275 | + if (texture.colorSpace === 'display-p3') texture.colorSpace === 'srgb'; |
2281 | 2276 |
|
2282 |
| - if (texture.isCompressedTexture) { |
2283 |
| - texture = await decompress( texture ); |
2284 |
| - texture = await resize_texture( texture, res, true, 'image/ktx2' ); |
2285 |
| - } else { |
2286 |
| - texture = await resize_texture( texture, res, false, 'image/ktx2' ); |
2287 |
| - } |
| 2277 | + // Get canvas texture with bitmap image |
2288 | 2278 |
|
2289 |
| - hdrjpg_texture = false; |
| 2279 | + if (texture.isCompressedTexture) { |
| 2280 | + texture = await decompress( texture ); |
| 2281 | + texture = await resize_texture( texture, res, true, 'image/ktx2' ); |
| 2282 | + } else { |
| 2283 | + texture = await resize_texture( texture, res, false, 'image/ktx2' ); |
| 2284 | + } |
2290 | 2285 |
|
2291 |
| - if (scene_bgnd !== null) scene_bgnd.dispose(); |
2292 |
| - scene_bgnd = texture.clone(); |
2293 |
| - await set_bgnd(); |
| 2286 | + hdrjpg_texture = false; |
2294 | 2287 |
|
2295 |
| - texture.dispose(); |
| 2288 | + if (scene_bgnd !== null) scene_bgnd.dispose(); |
| 2289 | + scene_bgnd = texture.clone(); |
| 2290 | + await set_bgnd(); |
2296 | 2291 |
|
2297 |
| - set_bgenv_message( true ); |
2298 |
| - }, function ( xhr ) { // onProgress |
2299 |
| - }, function ( error ) { // onError |
2300 |
| - document.getElementById('div_message').innerText = 'Error loading image: ' + error.message; |
2301 |
| - console.log( 'Error loading Background Image File!' ); |
2302 |
| - console.log( error ); |
| 2292 | + texture.dispose(); |
2303 | 2293 |
|
2304 |
| - URL.revokeObjectURL( fii ); |
2305 |
| - }); |
2306 |
| - } catch ( error ) { |
| 2294 | + set_bgenv_message( true ); |
| 2295 | + }, function ( xhr ) { // onProgress |
| 2296 | + }, function ( error ) { // onError |
2307 | 2297 | document.getElementById('div_message').innerText = 'Error loading image: ' + error.message;
|
2308 | 2298 | console.log( 'Error loading Background Image File!' );
|
2309 | 2299 | console.log( error );
|
2310 | 2300 |
|
2311 | 2301 | URL.revokeObjectURL( fii );
|
2312 |
| - } |
| 2302 | + }); |
2313 | 2303 | } else if (fn_uc.endsWith('.EXR') || fn_uc.endsWith('.HDR')) {
|
2314 | 2304 | const hd_loader = fn_uc.endsWith('.EXR') ? exr_loader : rgbe_loader;
|
2315 | 2305 |
|
|
0 commit comments