-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
103c8a9
commit d0f4ced
Showing
11 changed files
with
801 additions
and
26 deletions.
There are no files selected for viewing
560 changes: 560 additions & 0 deletions
560
alexanderristinmaa/app/(experiments)/[experiment]/info/markdown.css
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
alexanderristinmaa/app/(experiments)/[experiment]/info/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// styles | ||
import './markdown.css'; | ||
|
||
// other | ||
import * as fs from 'fs'; | ||
import {marked} from 'marked'; | ||
import parseMD from 'parse-md'; | ||
|
||
marked.use({ | ||
gfm: true | ||
}) | ||
|
||
export function generateStaticParams() { | ||
const experiments = | ||
fs.readdirSync('./app/(experiments)', {withFileTypes: true}) | ||
.filter(pathname => pathname.isDirectory() && fs.existsSync(`./app/(experiments)/${pathname.name}/page.md`)) | ||
.map(foldername => ({experiment: foldername.name})); | ||
|
||
// Should return a list of objects with the parameter experiment (because the dynamic path is [experiment]) | ||
// with the value of the path [experiment]/info where experiment is the different paths | ||
// ex return [{experiment: 'donut/info'}] | ||
return experiments; | ||
} | ||
|
||
// Multiple versions of this page will be statically generated | ||
// using the `params` returned by `generateStaticParams` | ||
export default async function Page({ params } : { params: { experiment: string } }) { | ||
const { experiment } = params; | ||
const markdownString = fs.readFileSync(`./app/(experiments)/${experiment}/page.md`, 'utf8'); | ||
const htmlFromMarkdown = await marked.parse(parseMD(markdownString).content); | ||
|
||
return ( | ||
<div style={{minHeight: '100vh'}} dangerouslySetInnerHTML={{__html: htmlFromMarkdown}}> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
name: The (3D) Donut | ||
description: A little spinning 3d donut made with three.js | ||
tags: | ||
- three.js | ||
- 3d | ||
--- | ||
# THE (3D) DONUT | ||
|
||
This amazing viewer-experience shows a (SPINNING) model of a 3D donut using three.js with some encouraging music. | ||
|
||
## How does it work? | ||
Using three.js and a 3d object stored in a .gltf file it is no problem loading and displaying it. | ||
|
||
The setup is **identical** to the [three.js startup docs](https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene). | ||
```typescript | ||
const scene = new THREE.Scene(); | ||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | ||
const renderer = new THREE.WebGLRenderer(); | ||
``` | ||
|
||
*then* adding the **donut** to the scene using the builtin GLTFLoader. | ||
```typescript | ||
const loader = new GLTFLoader(); | ||
const donut = ... => loader.load('/donuts.gltf', ...); | ||
scene.add(donut.scene); | ||
``` | ||
|
||
Animating the donut is as simple as creating a function which calls `renderer.render(scene, camera)` and then requests an animation frame for itself. In between these, update the donut's rotation. | ||
```typescript | ||
const renderScene = () => { | ||
requestAnimationFrame(renderScene); | ||
|
||
donut.scene.rotation.x += 0.01; | ||
donut.scene.rotation.y += 0.01; | ||
|
||
renderer.render(scene, camera); | ||
}; | ||
|
||
renderScene(); | ||
``` | ||
|
||
|
||
# Credit | ||
This work is based on "DONUTS" (https://sketchfab.com/3d-models/donuts-1710b0f3f44d429ea7b41114f3ce0a09) by jun_sketchsoft (https://sketchfab.com/jun_sketchsoft) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/) | ||
|
||
Music by Bensound.com | ||
License code: RZYLPS60JH8KEXM5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
name: Mandelbrot in WASM! | ||
description: The beautiful mandelbrot fractal computed and rendered with compiled WebAssembly! | ||
tags: | ||
- WebAssembly | ||
- Fractals | ||
--- | ||
# Mandelbrot with Webassembly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,41 @@ | ||
#imgDiv { | ||
width: 50%; | ||
float: right; | ||
#contentDiv { | ||
display: flex; | ||
gap: 20px; | ||
} | ||
|
||
#contentDiv > div { | ||
flex: 1; | ||
} | ||
|
||
#imgDiv > p{ | ||
#imgDiv > p { | ||
margin-top: 8px; | ||
float: right; | ||
} | ||
|
||
#img { | ||
width: 100%; | ||
border: 2px solid var(--black); | ||
} | ||
|
||
#experimentsTitle { | ||
font-size: 1.05em; | ||
margin-bottom: 10px; | ||
} | ||
|
||
#experimentsList { | ||
list-style: none; | ||
} | ||
|
||
#experimentsList > * > li { | ||
margin-bottom: 10px; | ||
} | ||
|
||
.experimentTitle { | ||
margin-bottom: 4px; | ||
} | ||
|
||
@media screen and (max-width: 900px) { | ||
#contentDiv { | ||
flex-direction: column; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.