Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Add a platform manager to help us tell if we are running a desktop version

Scott Petrovic943ba38ec8d4
diff --git a/src/Mesh2MotionEngine.ts b/src/Mesh2MotionEngine.ts
index d85c6c8..29aa341 100644
--- a/src/Mesh2MotionEngine.ts
+++ b/src/Mesh2MotionEngine.ts
@@ -39,6 +39,7 @@ import { ModelCleanupUtility } from './lib/processes/load-model/ModelCleanupUtil
import { SceneEnvironmentManager } from './lib/SceneEnvironmentManager.ts'
import { CameraShake } from './lib/CameraShake.ts'
import { DOMUtilities } from './lib/DOMUtilities.ts'
+import { PlatformManager } from './lib/PlatformManager.ts'
export class Mesh2MotionEngine {
public readonly camera = Generators.create_camera()
@@ -84,6 +85,9 @@ export class Mesh2MotionEngine {
constructor () {
this.initialize_shared_dom_mounts()
+ // this will add a platform CSS file if we are running our desktop app
+ new PlatformManager().init();
+
this.eventListeners = new EventListeners(this)
// helps resolve requestAnimationFrame calling animate() with wrong context
this.animate = this.animate.bind(this)
diff --git a/src/desktop.css b/src/desktop.css
new file mode 100644
index 0000000..8911924
--- /dev/null
+++ b/src/desktop.css
@@ -0,0 +1,6 @@
+/* desktop code to go here */
+#nav-support-mesh2motion,
+#nav-github
+{
+ display: none;
+}
\ No newline at end of file
diff --git a/src/lib/DOMUtilities.ts b/src/lib/DOMUtilities.ts
index be413a5..f5c4be0 100644
--- a/src/lib/DOMUtilities.ts
+++ b/src/lib/DOMUtilities.ts
@@ -57,8 +57,8 @@ export class DOMUtilities {
mount.innerHTML = `
<a href="#" id="learn-link">Learn</a>
<a href="#" id="attribution-link">Contributors</a>
- <a href="${nav_links.support_href}" target="_blank">πŸ’—</a>
- <a href="${nav_links.github_href}" target="_blank">
+ <a href="${nav_links.support_href}" id="nav-support-mesh2motion" target="_blank">πŸ’—</a>
+ <a href="${nav_links.github_href}" id="nav-github" target="_blank">
<img src="${nav_links.github_icon_src}" width="24" height="24" alt="GitHub" />
</a>
<span id="settings-dropdown-mount"></span>
diff --git a/src/lib/PlatformManager.ts b/src/lib/PlatformManager.ts
new file mode 100644
index 0000000..b4c0540
--- /dev/null
+++ b/src/lib/PlatformManager.ts
@@ -0,0 +1,30 @@
+/**
+ * PlatformManager class
+ * We have a desktop application built with Tauri. This will help us conditionally show/hide things on the desktop app
+ since there is a good chance the desktop app will not have a internet connection
+ **/
+export class PlatformManager {
+
+ private isTauri: boolean;
+ private platform: 'desktop' | 'web';
+
+ constructor() {
+ this.isTauri = '__TAURI_INTERNALS__' in window;
+ this.platform = this.isTauri ? 'desktop' : 'web';
+ console.log(this.platform ? 'Plastform: Desktop' : 'Platform: Web');
+ }
+
+
+ public init() {
+ document.documentElement.dataset.platform = this.platform;
+
+ if (this.platform === 'desktop') {
+ const link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = '/desktop.css';
+ document.head.appendChild(link);
+ }
+
+ return this;
+ }
+}