Refactor model loading APIs.
There are three ways to load a model: from a file, from a buffer, or an "empty" model. Instead of overloading a single function to do all three, provide three separate functions. Also disable model loading functions that will not work for emscripten. PiperOrigin-RevId: 859051341 Change-Id: I71557d31d0e7c9c6882895c36116d300f19e255d
This commit is contained in:
committed by
Copybara-Service
parent
e2180ff744
commit
2cc2e579f1
@@ -130,14 +130,7 @@
|
||||
reader.onload = (e) => {
|
||||
const buffer = e.target.result;
|
||||
try {
|
||||
if (file.name.endsWith('.mjb')) {
|
||||
Module.loadMjb(buffer);
|
||||
} else if (file.name.endsWith('.xml')) {
|
||||
Module.loadXml(buffer);
|
||||
} else {
|
||||
console.error('Unsupported file type:', file.name);
|
||||
}
|
||||
console.log('Model loaded from file:', file.name);
|
||||
Module.loadFile(file.name, buffer);
|
||||
} catch (error) {
|
||||
console.error('Failed to load model from file:', error);
|
||||
}
|
||||
@@ -145,7 +138,7 @@
|
||||
reader.onerror = (e) => {
|
||||
console.error('Error reading file:', e);
|
||||
};
|
||||
reader.readAsArrayBuffer(file); // Reads as text, suitable for XML.
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user