Import a 3D Model and automatically assign and export animations
TypeScript
Remove special class just for zip load error dialog
Scott Petrovice5b86580b1ca
diff --git a/src/lib/Generators.ts b/src/lib/Generators.tsindex 7813621..e9d9ea9 100644--- a/src/lib/Generators.ts+++ b/src/lib/Generators.ts@@ -18,6 +18,17 @@ export class Generators {return material}+ // put HTML with all the contributors+ static get_contributors_list (): string {+ // Return a list of contributors+ return `+ <div style="text-align: start">+ <p><span style="font-size: 120%">Scott Petrovic</span> - Project Maintainer</p>+ <p><span style="font-size: 120%">Quatnerius</span> - Human model, rig, and animations</p>+ </div>+ `+ }+static create_grid_helper (grid_color: number = 0x111155, floor_color: number = 0x4e4e7a): any[] {// create floor mesh and add to scene to help with shadowsconst grid_size: number = 180diff --git a/src/lib/processes/load-model/StepLoadModel.ts b/src/lib/processes/load-model/StepLoadModel.tsindex 3839e89..655711a 100644--- a/src/lib/processes/load-model/StepLoadModel.ts+++ b/src/lib/processes/load-model/StepLoadModel.ts@@ -1,4 +1,3 @@-import { ZipLoadErrorDialog } from './ZipLoadErrorDialog.ts'import { UI } from '../../UI.ts'import { ZipGLTFLoader } from './ZipGLTFLoader.ts'import { Box3 } from 'three/src/math/Box3.js'@@ -11,6 +10,7 @@ import { MeshNormalMaterial } from 'three/src/materials/MeshNormalMaterial.js'import { MathUtils } from 'three/src/math/MathUtils.js'import { FrontSide } from 'three/src/constants.js'import { type BufferGeometry, type Material, type Object3D, type SkinnedMesh } from 'three'+import { ModalDialog } from '../../ModalDialog.ts'// Note: EventTarget is a built-ininterface and do not need to import itexport class StepLoadModel extends EventTarget {@@ -178,12 +178,12 @@ export class StepLoadModel extends EventTarget {const zip_loader = new ZipGLTFLoader(this.gltf_loader)zip_loader.load_from_zip(buffer, (scene) => {this.process_loaded_scene(scene) // loaded successfully...continue- }, (err) => {+ }, (err: Error) => {console.error('Failed to load GLTF from ZIP:', err)- new ZipLoadErrorDialog('Failed to load GLTF from ZIP: ' + (err?.message || err))- }).catch((err) => {+ new ModalDialog('Failed to load GLTF from ZIP: ', err?.message || err).show()+ }).catch((err: Error) => {console.error('Error loading ZIP:', err)- new ZipLoadErrorDialog('Error loading ZIP: ' + (err?.message || err))+ new ModalDialog('Error loading ZIP: ', err?.message || err).show()})}@@ -192,16 +192,16 @@ export class StepLoadModel extends EventTarget {fetch(model_file_path).then(async res => await res.arrayBuffer()).then(buffer => { handle_zip(buffer) })- .catch(err => {+ .catch((err: Error) => {console.error('Failed to fetch ZIP data:', err)- new ZipLoadErrorDialog('Failed to fetch ZIP data: ' + (err?.message || err))+ new ModalDialog('Failed to fetch ZIP data: ', err?.message || err).show()})} else if (model_file_path instanceof ArrayBuffer) {handle_zip(model_file_path)} else {- const msg = 'ZIP file data is not in a supported format';+ const msg = 'ZIP file data is not in a supported format'console.error(msg)- new ZipLoadErrorDialog(msg)+ new ModalDialog('ZIP file error decompressing: ', msg).show()}}diff --git a/src/lib/processes/load-model/ZipLoadErrorDialog.ts b/src/lib/processes/load-model/ZipLoadErrorDialog.tsdeleted file mode 100644index 0e335c0..0000000--- a/src/lib/processes/load-model/ZipLoadErrorDialog.ts+++ /dev/null@@ -1,13 +0,0 @@--import { ModalDialog } from '../../ModalDialog.ts'---export class ZipLoadErrorDialog {- private modal: ModalDialog | null = null;-- constructor(message: string) {- this.modal = new ModalDialog('ZIP Load Error', `<p>${message}</p>`)- this.modal.show()- }-}-diff --git a/src/script.ts b/src/script.tsindex a20d65e..8a27c32 100644--- a/src/script.ts+++ b/src/script.ts@@ -518,18 +518,11 @@ export class Bootstrap {// Show the contributors dialogconsole.log('Showing contributors dialog')// instantiate modal dialog and show contributors- const modal = new ModalDialog('Contributors', this.get_contributors_list())+ const modal = new ModalDialog('Contributors', Generators.get_contributors_list())modal.show()}- private get_contributors_list (): string {- // Return a list of contributors- return `- <p>Contributor 1</p>- <p>Contributor 2</p>- <p>Contributor 3</p>- `- }+} // end Bootstrap class// Create an instance of the Bootstrap class when the script is loaded