Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

handle localhost development and add to index page.

Scott Petrovic246c2aa2fa74
diff --git a/src/Mesh2MotionEngine.ts b/src/Mesh2MotionEngine.ts
index 3a01d05..406b662 100644
--- a/src/Mesh2MotionEngine.ts
+++ b/src/Mesh2MotionEngine.ts
@@ -99,13 +99,14 @@ export class Mesh2MotionEngine {
tippy('[data-tippy-content]', { theme: 'mesh2motion' })
}
- // for the release, let's just show the first 7 characters of the commit SHA
+ // for the release, let's just show the first N characters of the commit SHA
// then the branch we used to build. This comes from Cloudflare build process
private inject_build_version (): void {
if (this.ui.dom_build_version !== null) {
- this.ui.dom_build_version.innerHTML = `${window.CLOUDFLARE_COMMIT_SHA.slice(0, 6)}-(${window.CLOUDFLARE_BRANCH})`
- } else {
- console.warn('Build version DOM element is null. Cannot set number')
+ const commit_sha: string = window.CLOUDFLARE_COMMIT_SHA.slice(0, 9)
+ const branch: string = window.CLOUDFLARE_BRANCH
+
+ this.ui.dom_build_version.innerHTML = `${commit_sha}-${branch}`
}
}
diff --git a/src/create.html b/src/create.html
index e943110..cc71dc1 100644
--- a/src/create.html
+++ b/src/create.html
@@ -391,7 +391,8 @@
<!-- 3d view control hit box. It is just a container to help with 3d view controls. -->
<div id="view-control-hitbox"></div>
-
+ <!-- build version information-->
+ <script src="./environment.js"></script>
<span id="build-version"></span>
</body>
diff --git a/src/environment.js b/src/environment.js
index 38a98ff..cbcb594 100644
--- a/src/environment.js
+++ b/src/environment.js
@@ -1,4 +1,12 @@
-// grab a couple environment variables from Clourflare build process
-// Vite actually does the injection, so look at vite.config.js with the "define" block
-window.CLOUDFLARE_COMMIT_SHA = PROCESS_ENV.WORKERS_CI_COMMIT_SHA
-window.CLOUDFLARE_BRANCH = PROCESS_ENV.WORKERS_CI_BRANCH || 'unknown'
+// typeof check is safer to check if undefined
+// during local development this variable won't exist
+if (typeof PROCESS_ENV === 'undefined') {
+ window.CLOUDFLARE_COMMIT_SHA = window.location.hostname
+ window.CLOUDFLARE_BRANCH = 'dev'
+}
+else {
+ // grab a couple environment variables from Clourflare build process
+ // Vite actually does the injection, so look at vite.config.js with the "define" block
+ window.CLOUDFLARE_COMMIT_SHA = PROCESS_ENV.WORKERS_CI_COMMIT_SHA
+ window.CLOUDFLARE_BRANCH = PROCESS_ENV.WORKERS_CI_BRANCH || 'unknown'
+}
diff --git a/src/index.html b/src/index.html
index 1b5dfd2..cf484fb 100644
--- a/src/index.html
+++ b/src/index.html
@@ -186,5 +186,9 @@
<!-- 3d view control hit box. It is just a container to help with 3d view controls. -->
<div id="view-control-hitbox"></div>
+ <!-- build version information-->
+ <script src="./environment.js"></script>
+ <span id="build-version"></span>
+
</body>
</html>
\ No newline at end of file