Skip to content

Commit f94efc7

Browse files
committed
Start adding an attribution area for animation and skeletons. This might be too complicated
1 parent 8903bf7 commit f94efc7

File tree

5 files changed

+140
-2
lines changed

5 files changed

+140
-2
lines changed

src/credits.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#credits-dialog {
2+
display:none;
3+
position: fixed;
4+
top: 0;
5+
left: 0;
6+
width: 100vw;
7+
height: 100vh;
8+
background: rgba(0,0,0,0.5); /* grey out bg, so don't use theme colors */
9+
z-index: 10000;
10+
align-items: center;
11+
justify-content: center;
12+
}
13+
14+
#credits-contents {
15+
background: var(--bg-primary);
16+
color: var(--text-primary);
17+
padding: 2rem;
18+
border-radius: 8px;
19+
max-width: 90vw;
20+
max-height: 80vh;
21+
overflow-y: auto;
22+
position: relative;
23+
box-shadow: 0 4px 32px #000a;
24+
}
25+
26+
button#close-credits-dialog {
27+
28+
}

src/index.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<link href="./styles.css" rel="stylesheet" crossorigin="anonymous" />
1313
<link rel="stylesheet" href="./radio-button-group.css" crossorigin="anonymous" />
1414
<link rel="stylesheet" href="./animation-player.css" crossorigin="anonymous" />
15+
<link rel="stylesheet" href="./credits.css" crossorigin="anonymous" />
1516

1617
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
1718

@@ -258,8 +259,20 @@
258259
<!-- javascript will populate this item with animations
259260
that we get from the animations file(s) -->
260261
<div id="animations-items"> </div>
261-
262-
262+
263+
<!-- Attribution. clicking will open dialog with attribution information -->
264+
<a href="#" id="attribution-link">Attribution</a>
265+
<div id="attribution-message" style="display: none;"></div>
266+
<div id="credits-dialog">
267+
<div id="credits-contents" >
268+
<div style="display: flex; align-items: center; gap: 2rem;">
269+
<h2 style="margin:0;">Attribution for skeleton &amp; animations</h2>
270+
<button id="close-credits-dialog" >&times;</button>
271+
</div>
272+
<div id="credits-content"></div>
273+
</div>
274+
</div>
275+
263276
<!-- slider to control arm extension (hide this feature until the base functionality is more stable) -->
264277
<div id="a-pose-correction-options">
265278
<div style="display: flex; flex-direction: row; align-items: center;">
@@ -342,5 +355,6 @@
342355
<!-- 3d view control hit box. It is just a container to help with 3d view controls. -->
343356
<div id="view-control-hitbox"></div>
344357

358+
345359
</body>
346360
</html>

src/lib/CreditsDialog.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Attribution/Credits Dialog Logic as a TypeScript class
2+
export interface CreditEntry {
3+
name: string
4+
url: string
5+
}
6+
7+
export class CreditsDialog {
8+
private readonly attribution_link: HTMLElement | null
9+
private readonly credits_dialog: HTMLElement | null
10+
private readonly close_button: HTMLElement | null
11+
private readonly credits_content: HTMLElement | null
12+
private readonly skeleton_credits: Record<string, CreditEntry[]>
13+
14+
constructor () {
15+
this.attribution_link = document.getElementById('attribution-link')
16+
this.credits_dialog = document.getElementById('credits-dialog')
17+
this.close_button = document.getElementById('close-credits-dialog')
18+
this.credits_content = document.getElementById('credits-content')
19+
20+
this.skeleton_credits = {
21+
human: [
22+
{ name: 'Quaternius', url: 'https://quaternius.com/' },
23+
{ name: 'Scott Petrovic', url: 'https://scottpetrovic.com' }
24+
],
25+
fox: [
26+
{ name: 'Scott Petrovic', url: 'https://scottpetrovic.com' }
27+
],
28+
bird: [
29+
{ name: 'Scott Petrovic', url: 'https://scottpetrovic.com' }
30+
]
31+
}
32+
33+
this.addEventListeners()
34+
}
35+
36+
private get_current_skeleton_type (): string {
37+
const sel = document.getElementById('skeleton-selection') as HTMLSelectElement | null
38+
if (sel && sel.value) {
39+
return sel.value
40+
}
41+
return 'human'
42+
}
43+
44+
public show (): void {
45+
if ((this.credits_dialog == null) || (this.credits_content == null)) return
46+
47+
const skeleton_type = this.get_current_skeleton_type()
48+
const credits = this.skeleton_credits[skeleton_type] || []
49+
this.credits_dialog.style.display = 'flex'
50+
51+
if (credits.length === 0) {
52+
this.credits_content.innerHTML = '<p>No credits available for this skeleton type.</p>'
53+
return
54+
}
55+
56+
this.credits_content.innerHTML = '<ul style="padding-left: 1.2em;">' +
57+
credits.map(c => `<li><a href="${c.url}" target="_blank" rel="noopener">${c.name}</a></li>`)
58+
.join('') + '</ul>'
59+
}
60+
61+
public hide (): void {
62+
if (this.credits_dialog != null) this.credits_dialog.style.display = 'none'
63+
}
64+
65+
private addEventListeners (): void {
66+
this.attribution_link?.addEventListener('click', (e) => {
67+
e.preventDefault()
68+
this.show()
69+
})
70+
71+
this.close_button?.addEventListener('click', () => {
72+
this.hide()
73+
})
74+
75+
this.credits_dialog?.addEventListener('click', (e) => {
76+
if (e.target === this.credits_dialog) {
77+
this.hide()
78+
}
79+
})
80+
}
81+
}

src/script.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CreditsDialog } from './lib/CreditsDialog.ts';
12
import * as THREE from 'three'
23
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
34
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js'
@@ -87,6 +88,9 @@ export class Bootstrap {
8788
this.process_step = this.process_step_changed(ProcessStep.LoadModel)
8889
this.animate() // start the render loop which will continue rendering the scene
8990
this.inject_build_version()
91+
92+
// Create the credits dialog
93+
const creds_dialog: CreditsDialog = new CreditsDialog()
9094
}
9195

9296
private inject_build_version (): void {

src/styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/* Dark theme (default) */
66
--text-primary: white;
77
--text-alternate: #dae2e6;
8+
--link-color: #d0d0d0;
89

910
--bg-primary: #2b4353;
1011
--bg-alternate: #426074;
@@ -24,6 +25,7 @@
2425
[data-theme="light"] {
2526
--text-primary: #2c3e50;
2627
--text-alternate: #96a5ac;
28+
--link-color: #3b6081;
2729

2830
--bg-primary: #ecf0f1;
2931
--bg-alternate: #bac9d2;
@@ -54,9 +56,18 @@ h1, h2, h3, h4, h5, h6, input, button, select {
5456
color: var(--text-primary);
5557
font-family: 'Jost', sans-serif;
5658
font-size: 14px;
59+
font-weight: 400;
5760
display: inline-block;
5861
}
5962

63+
a {
64+
color: var(--link-color);
65+
font-size: 80%;
66+
}
67+
a:hover {
68+
text-decoration: none;
69+
}
70+
6071
/* Icon toggle for show skeleton */
6172
.icon-toggle label {
6273
cursor: pointer;

0 commit comments

Comments
 (0)