|
11 | 11 | <script type="importmap"> |
12 | 12 | { |
13 | 13 | "imports": { |
14 | | - "three": "https://cdn.jsdelivr.net/npm/three@0.172.0/build/three.module.min.js", |
15 | | - "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.172.0/examples/jsm/", |
16 | | - "meshoptimizer_decoder": "https://cdn.jsdelivr.net/npm/meshoptimizer@0.21.0/meshopt_decoder.module.min.js" |
| 14 | + "three": "https://cdn.jsdelivr.net/npm/three@0.174.0/build/three.module.min.js", |
| 15 | + "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.174.0/examples/jsm/", |
| 16 | + "meshoptimizer_decoder": "https://cdn.jsdelivr.net/npm/meshoptimizer@0.22.0/meshopt_decoder.module.min.js" |
17 | 17 | } |
18 | 18 | } |
19 | 19 | </script> |
|
59 | 59 | gltf_VideoTextureExtension = GLTFVideoTextureExtension; |
60 | 60 |
|
61 | 61 | ktx2_loader = new KTX2Loader(); |
62 | | - ktx2_loader.setTranscoderPath( "https://cdn.jsdelivr.net/npm/three@0.172.0/examples/jsm/libs/basis/" ); |
| 62 | + ktx2_loader.setTranscoderPath( "https://cdn.jsdelivr.net/npm/three@0.174.0/examples/jsm/libs/basis/" ); |
63 | 63 |
|
64 | 64 | manager.addHandler( /\.ktx2$/i, ktx2_loader ); |
65 | 65 |
|
66 | 66 | draco_loader = new DRACOLoader(); |
67 | | - draco_loader.setDecoderPath( "https://cdn.jsdelivr.net/npm/three@0.172.0/examples/jsm/libs/draco/" ); |
| 67 | + draco_loader.setDecoderPath( "https://cdn.jsdelivr.net/npm/three@0.174.0/examples/jsm/libs/draco/" ); |
68 | 68 | draco_loader.setDecoderConfig( { type: 'js' } ); |
69 | 69 | draco_loader.preload(); |
70 | 70 |
|
|
160 | 160 | font-size: x-large; |
161 | 161 | display: none; |
162 | 162 | color: red; |
163 | | - width: 240px; |
164 | | - height: 240px; |
165 | | - top: 50%; |
166 | | - left: 50%; |
167 | | - margin-left: -127px; |
168 | | - padding: 10px; |
| 163 | + width: 50vw; |
| 164 | + height: 50vh; |
| 165 | + top: 50vh; |
| 166 | + left: 25vw; |
| 167 | + padding: 5px; |
169 | 168 | border: none; |
170 | 169 | } |
171 | 170 |
|
|
174 | 173 | color: greenyellow; |
175 | 174 | position: absolute; |
176 | 175 | text-align: center; |
177 | | - font-size: large; |
178 | | - height: 240px; |
179 | | - width: 240px; |
180 | | - top: 50%; |
181 | | - left: 50%; |
182 | | - margin-left: -127px; |
183 | | - padding: 10px; |
| 176 | + font-size: x-large; |
| 177 | + width: 50vw; |
| 178 | + height: 50vh; |
| 179 | + top: 50vh; |
| 180 | + left: 25vw; |
| 181 | + padding: 5px; |
184 | 182 | border: none; |
185 | 183 | } |
186 | 184 |
|
|
213 | 211 |
|
214 | 212 | <!-- mouse_wheel variable is used throughout as a trigger for rendering --> |
215 | 213 |
|
216 | | - <title>ASSIMP Viewer (r172)</title> |
| 214 | + <title>ASSIMP Viewer (r174)</title> |
217 | 215 | </head> |
218 | 216 | <body id="body" onload="reset_all(); document_ready(); disabled_changed();" onresize="resize();"> |
219 | 217 | <div id="fixed_menu" class="fixed-menu"> |
|
671 | 669 | } |
672 | 670 | } |
673 | 671 |
|
674 | | - function load_with_assimp( fetched_files = null, from_url = false ) { |
| 672 | + async function load_with_assimp( fetched_files = null, from_url = false ) { |
675 | 673 | if (fetched_files === null) return; |
676 | 674 |
|
677 | 675 | console.time( 'Assimp Loading Time' ); |
678 | 676 | assimp_load = true; |
679 | 677 |
|
680 | 678 | // Use ASSIMPJS to load files - some models might take time to load |
681 | | - assimpjs().then( async function( ajs ) { |
| 679 | + await assimpjs().then( async function( ajs ) { |
682 | 680 | if (from_url === true) { |
683 | 681 | Promise.all( assimp_files.map( ( file, index ) => fetch( fetched_files[ index ] ) )).then( ( responses ) => { |
684 | 682 | return Promise.all( responses.map( ( res ) => res.arrayBuffer() ) ); |
|
742 | 740 |
|
743 | 741 | console.timeEnd( 'Assimp Loading Time' ); |
744 | 742 |
|
745 | | - load_components( false ); |
| 743 | + load_components( from_url ); |
746 | 744 | } |
747 | 745 | }); |
748 | 746 | } |
|
867 | 865 | // Load DRACO or gltf file |
868 | 866 | if (selected_gltf_file !== null) loadFile(); |
869 | 867 | else if (selected_draco_file !== null) loadDRACO(); |
| 868 | + } else { |
| 869 | + if (assimp_load === true && selected_gltf_file !== null) loadFile(); |
870 | 870 | } |
871 | 871 | } |
872 | 872 |
|
873 | 873 | function loadFile() { |
| 874 | + let lfile = local_files ? local_files[ selected_gltf_file ] : ( assimp_load === true ? selected_gltf_file : null ); |
| 875 | + |
| 876 | + if (lfile === null) { |
| 877 | + handle_error( 'No valid file selected!' ); |
| 878 | + return; |
| 879 | + } |
| 880 | + |
874 | 881 | console.time( 'GLTF Loading Time' ); |
875 | 882 |
|
876 | | - gltf_loader.load( URL.createObjectURL( assimp_load === true ? selected_gltf_file : local_files[ selected_gltf_file ] ), async function( gltf ) { |
| 883 | + gltf_loader.load( URL.createObjectURL( lfile ), async function( gltf ) { |
877 | 884 | URL.revokeObjectURL( assimp_load === true ? selected_gltf_file : local_files[ selected_gltf_file ] ); |
878 | 885 |
|
879 | 886 | parser = gltf.parser; |
|
1106 | 1113 | finish_loading(); |
1107 | 1114 | }, function ( xhr ) { // onProgress |
1108 | 1115 | }, function ( error ) { // onError |
1109 | | - URL.revokeObjectURL( selected_gltf_file ); |
| 1116 | + URL.revokeObjectURL( lfile ); |
1110 | 1117 | handle_error( error ); |
1111 | 1118 | }); |
1112 | 1119 |
|
|
1291 | 1298 | } |
1292 | 1299 |
|
1293 | 1300 | if (selected_gltf_url_file === null) { |
1294 | | - if (file_model_urls.length > 0) load_with_assimp( file_model_urls, true ); |
| 1301 | + if (file_model_urls.length > 0) await load_with_assimp( file_model_urls, true ); |
1295 | 1302 | return; |
1296 | 1303 | } |
1297 | 1304 |
|
|
0 commit comments