Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Show license separately and have tooltip for info

Scott Petrovicf543abfc6af6
diff --git a/src/dialog.css b/src/dialog.css
index 5527035..4f68314 100644
--- a/src/dialog.css
+++ b/src/dialog.css
@@ -148,6 +148,14 @@
margin-bottom: 0.25rem;
}
+.variation-license-chip {
+ padding: 0.5rem 1.0rem;
+ background: color-mix(in srgb, var(--text-alternate) 22%, var(--bg-primary));
+}
+.variation-license-chip:hover {
+ background: color-mix(in srgb, var(--text-alternate) 32%, var(--bg-primary));
+}
+
.variation-attribution {
opacity: 0.7;
}
diff --git a/src/lib/RigConfig.ts b/src/lib/RigConfig.ts
index 231c1b6..c8ea7f1 100644
--- a/src/lib/RigConfig.ts
+++ b/src/lib/RigConfig.ts
@@ -70,7 +70,7 @@ export class RigConfig {
model_file: 'models-variation/human-jay.glb',
display_name: 'Jay',
attribution: 'Blender Studio',
- license: 'CC0',
+ license: 'CC-BY',
preview_image: 'models-variation/profiles/jay.png'
} satisfies ModelVariation
]
@@ -90,14 +90,14 @@ export class RigConfig {
{
model_file: 'models-variation/fox-base.glb',
display_name: 'Fox',
- attribution: 'None',
+ attribution: '',
license: 'CC0',
preview_image: 'models-variation/profiles/fox.png'
} satisfies ModelVariation,
{
model_file: 'models-variation/fox-horse.glb',
display_name: 'Horse',
- attribution: 'None',
+ attribution: '',
license: 'CC0',
preview_image: 'models-variation/profiles/horse.png'
} satisfies ModelVariation,
diff --git a/src/lib/VariationLicenseInfo.ts b/src/lib/VariationLicenseInfo.ts
new file mode 100644
index 0000000..40ea85b
--- /dev/null
+++ b/src/lib/VariationLicenseInfo.ts
@@ -0,0 +1,36 @@
+export interface VariationLicenseInfo {
+ description: string
+}
+
+// eslint-disable-next-line @typescript-eslint/no-extraneous-class
+export class VariationLicenseCatalog {
+ private static readonly license_info_by_key: Record<string, VariationLicenseInfo> = {
+ cc0: {
+ description: 'Public domain dedication. You can use, modify, and redistribute this asset without attribution.'
+ },
+ 'cc-by': {
+ description: 'Use is allowed, including commercial use, but attribution to the creator is required.'
+ },
+ 'cc-sa': {
+ description: 'Use and modification are allowed, but derivative works must be shared under the same license.'
+ }
+ }
+
+ // try to catch small variations on license with typos. Probably over-engineered code.
+ private static normalize_license_key (license_name: string): string {
+ const normalized = license_name.toLowerCase().trim()
+ if (normalized.includes('cc0')) return 'cc0'
+ if (normalized.includes('cc-by-sa') || normalized.includes('cc-sa')) return 'cc-sa'
+ if (normalized.includes('cc-by')) return 'cc-by'
+
+ return normalized
+ }
+
+ static get_license_info (license_name: string): VariationLicenseInfo {
+ const normalized_key = this.normalize_license_key(license_name)
+
+ return this.license_info_by_key[normalized_key] ?? {
+ description: 'License details are not available yet. Please verify usage terms before redistribution.'
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/lib/processes/animations-listing/ModelVariationSwitcher.ts b/src/lib/processes/animations-listing/ModelVariationSwitcher.ts
index d1b124a..eae9676 100644
--- a/src/lib/processes/animations-listing/ModelVariationSwitcher.ts
+++ b/src/lib/processes/animations-listing/ModelVariationSwitcher.ts
@@ -1,7 +1,9 @@
import { Skeleton, SkinnedMesh } from 'three'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
+import tippy from 'tippy.js'
import { RigConfig, type ModelVariation, type RigConfigEntry } from '../../RigConfig'
import { type SkeletonType } from '../../enums/SkeletonType'
+import { VariationLicenseCatalog } from '../../VariationLicenseInfo'
/**
* Manages the model variation selection on the Explore page.
@@ -88,6 +90,18 @@ export class ModelVariationSwitcher extends EventTarget {
name_el.textContent = variation.display_name
card.appendChild(name_el)
+ const license_info = VariationLicenseCatalog.get_license_info(variation.license)
+ const license_chip = document.createElement('span')
+ license_chip.className = 'variation-license-chip'
+ license_chip.textContent = variation.license
+ card.appendChild(license_chip)
+
+ tippy(license_chip, {
+ content: `${variation.license}: ${license_info.description}`,
+ theme: 'mesh2motion',
+ placement: 'top'
+ })
+
if (variation.attribution !== 'None') {
const attribution_el = document.createElement('div')
attribution_el.className = 'variation-attribution'