Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit fc7bf4a

Browse files
Update mobile ASSIMP Viewer
1 parent 825bb7a commit fc7bf4a

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

viewers/templates/Mobile/MASSIMP Viewer.html

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<script type="importmap">
1212
{
1313
"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"
1717
}
1818
}
1919
</script>
@@ -59,12 +59,12 @@
5959
gltf_VideoTextureExtension = GLTFVideoTextureExtension;
6060

6161
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/" );
6363

6464
manager.addHandler( /\.ktx2$/i, ktx2_loader );
6565

6666
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/" );
6868
draco_loader.setDecoderConfig( { type: 'js' } );
6969
draco_loader.preload();
7070

@@ -160,12 +160,11 @@
160160
font-size: x-large;
161161
display: none;
162162
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;
169168
border: none;
170169
}
171170

@@ -174,13 +173,12 @@
174173
color: greenyellow;
175174
position: absolute;
176175
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;
184182
border: none;
185183
}
186184

@@ -213,7 +211,7 @@
213211

214212
<!-- mouse_wheel variable is used throughout as a trigger for rendering -->
215213

216-
<title>ASSIMP Viewer (r172)</title>
214+
<title>ASSIMP Viewer (r174)</title>
217215
</head>
218216
<body id="body" onload="reset_all(); document_ready(); disabled_changed();" onresize="resize();">
219217
<div id="fixed_menu" class="fixed-menu">
@@ -671,14 +669,14 @@
671669
}
672670
}
673671

674-
function load_with_assimp( fetched_files = null, from_url = false ) {
672+
async function load_with_assimp( fetched_files = null, from_url = false ) {
675673
if (fetched_files === null) return;
676674

677675
console.time( 'Assimp Loading Time' );
678676
assimp_load = true;
679677

680678
// 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 ) {
682680
if (from_url === true) {
683681
Promise.all( assimp_files.map( ( file, index ) => fetch( fetched_files[ index ] ) )).then( ( responses ) => {
684682
return Promise.all( responses.map( ( res ) => res.arrayBuffer() ) );
@@ -742,7 +740,7 @@
742740

743741
console.timeEnd( 'Assimp Loading Time' );
744742

745-
load_components( false );
743+
load_components( from_url );
746744
}
747745
});
748746
}
@@ -867,13 +865,22 @@
867865
// Load DRACO or gltf file
868866
if (selected_gltf_file !== null) loadFile();
869867
else if (selected_draco_file !== null) loadDRACO();
868+
} else {
869+
if (assimp_load === true && selected_gltf_file !== null) loadFile();
870870
}
871871
}
872872

873873
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+
874881
console.time( 'GLTF Loading Time' );
875882

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 ) {
877884
URL.revokeObjectURL( assimp_load === true ? selected_gltf_file : local_files[ selected_gltf_file ] );
878885

879886
parser = gltf.parser;
@@ -1106,7 +1113,7 @@
11061113
finish_loading();
11071114
}, function ( xhr ) { // onProgress
11081115
}, function ( error ) { // onError
1109-
URL.revokeObjectURL( selected_gltf_file );
1116+
URL.revokeObjectURL( lfile );
11101117
handle_error( error );
11111118
});
11121119

@@ -1291,7 +1298,7 @@
12911298
}
12921299

12931300
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 );
12951302
return;
12961303
}
12971304

0 commit comments

Comments
 (0)