Repository navigation
Expand file tree
/
Copy pathmain.ts
More file actions
222 lines (205 loc) · 6 KB
/
Copy pathmain.ts
File metadata and controls
222 lines (205 loc) · 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
interface PageInfo {
name: string
description: string
url: string
tags?: string[]
featured?: boolean
ai?: boolean
}
const pages: PageInfo[] = [
{
name: 'Model Animation',
description:
'Demonstrates model movement along paths and animation playback.',
url: '/pages/1-model-animation/index.html',
tags: ['Three.js', 'Animation', 'GLTF'],
featured: true
},
{
name: '3D Blob',
description:
'Organic 3D shape creation using Perlin noise and custom shaders.',
url: '/pages/2-3d-blob/index.html',
tags: ['Three.js', 'Shader', 'Noise'],
featured: true
},
{
name: 'Earth',
description:
'Realistic Earth visualization with texture mapping and lighting.',
url: '/pages/3-earth/index.html',
tags: ['Three.js', 'Globe', 'Texture']
},
{
name: 'Globe',
description:
'Interactive globe displaying geographic coordinates and data points.',
url: '/pages/4-globe/index.html',
tags: ['Three.js', 'Globe', 'Data Viz']
},
{
name: 'Shaders',
description: 'Collection of advanced visual effects ported from ShaderToy.',
url: '/pages/5-shaders/index.html',
tags: ['Three.js', 'Shader', 'ShaderToy']
},
{
name: 'Procedural Terrain',
description:
'Dynamic terrain generation using noise algorithms and heightmaps.',
url: '/pages/6-procedural-terrain/index.html',
tags: ['Three.js', 'Terrain', 'Noise']
},
{
name: 'Block Terrain',
description: 'Voxel-style terrain generated with Fractal Brownian Motion.',
url: '/pages/7-block-terrain/index.html',
tags: ['Three.js', 'Terrain', 'Voxel'],
featured: true
},
{
name: '3D Force Layout',
description:
'Dynamic 3D force-directed graph for complex relationship visualization.',
url: '/pages/8-3d-force-layout/index.html',
tags: ['Three.js', 'Graph', 'Force-Directed'],
featured: true
},
{
name: 'Multiple Views',
description:
'Simultaneous rendering of different perspectives in a single scene.',
url: '/pages/9-multiple-views/index.html',
tags: ['Three.js', 'Camera', 'Viewport']
},
{
name: 'Grayscale Shaders',
description:
'Procedural grayscale textures including chessboard, noise, and FBM.',
url: '/pages/10-grayscale/index.html',
tags: ['Three.js', 'Shader', 'Noise']
},
{
name: 'Voronoi Algorithm',
description:
'Interactive visualization of Voronoi diagrams and Delaunay triangulation.',
url: '/pages/11-voronoi-demo/index.html',
tags: ['Canvas', 'Algorithm', 'Geometry']
},
{
name: 'Atmospheric Earth',
description:
'Advanced Earth with day/night cycles and atmospheric scattering.',
url: '/pages/12-shader-earth/index.html',
tags: ['Three.js', 'Shader', 'Atmosphere'],
featured: true
},
{
name: 'GPU Picking',
description:
'High-performance object selection using GPU-based color ID mapping.',
url: '/pages/13-gpu-picking/index.html',
tags: ['Three.js', 'Performance', 'Interaction']
},
{
name: 'Map Generator',
description:
'Procedural island maps with elevation, moisture, and river systems.',
url: '/pages/14-mapgen-webgl-demo/index.html',
tags: ['OGL', 'Terrain', 'Procedural'],
featured: true
},
{
name: 'Building Explode',
description:
'Interactive 3D building with layering, explode effects, and floor selection.',
url: '/pages/15-building-explode-effect/index.html',
tags: ['Three.js', 'Building', 'Interaction'],
featured: true
},
{
name: 'Web Worker Demo',
description:
'A simple performance benchmark counting primes on the UI thread vs. a background Web Worker.',
url: '/pages/16-webworker-demo/index.html',
tags: ['Web Worker', 'Performance', 'Canvas'],
featured: true,
ai: true
}
]
function createPageCard(page: PageInfo): HTMLElement {
const card = document.createElement('a')
card.className = `page-card ${page.featured ? 'featured' : ''}`
card.href = page.url
const tagsHtml = page.tags
? page.tags
.map(
(tag, index) =>
`<span class="tag ${index === 0 ? 'tech-tag' : ''}">${tag}</span>`
)
.join('')
: ''
const featuredBadge = page.featured
? '<span class="featured-badge">Featured</span>'
: ''
const aiBadge = page.ai ? '<span class="ai-badge">AI</span>' : ''
card.innerHTML = `
<div class="card-content">
<div class="card-header">
<h2 class="card-title">${page.name}</h2>
<div class="badge-container">
${aiBadge}
${featuredBadge}
</div>
</div>
<p class="card-description">${page.description}</p>
<div class="card-tags">${tagsHtml}</div>
<div class="card-arrow">
View Demo <span>→</span>
</div>
</div>
`
return card
}
function renderPages(
filterFeatured: boolean = false,
filterAi: boolean = false
) {
const pagesGrid = document.querySelector('.pages-grid')
if (!pagesGrid) return
pagesGrid.innerHTML = ''
let filteredPages = pages
if (filterFeatured) {
filteredPages = filteredPages.filter((page) => page.featured)
}
if (filterAi) {
filteredPages = filteredPages.filter((page) => page.ai)
}
filteredPages.forEach((page) => {
const card = createPageCard(page)
pagesGrid.appendChild(card)
})
}
function initializePages() {
const filterFeaturedToggle = document.getElementById(
'featured-filter'
) as HTMLInputElement
const filterAiToggle = document.getElementById(
'ai-filter'
) as HTMLInputElement
const handleChange = () => {
renderPages(filterFeaturedToggle?.checked, filterAiToggle?.checked)
}
if (filterFeaturedToggle) {
filterFeaturedToggle.addEventListener('change', handleChange)
}
if (filterAiToggle) {
filterAiToggle.addEventListener('change', handleChange)
}
renderPages(
filterFeaturedToggle?.checked || false,
filterAiToggle?.checked || false
)
}
// Initialize pages when DOM is loaded
document.addEventListener('DOMContentLoaded', initializePages)