Compare commits

...

21 Commits

Author SHA1 Message Date
Sven Vogel 8862475e72 fix(dockerfile): changed ownership to user with id 1000 and gid 1000
Gitea Vite Build Action / Vite-Build (push) Successful in 46s Details
2024-10-28 14:03:43 +01:00
Sven Vogel 5c8ade73fb feat: added MIT license
Gitea Vite Build Action / Vite-Build (push) Successful in 43s Details
2024-10-25 01:02:13 +02:00
Sven Vogel 407a143729 fix(readme): fixed invalid `img` tag
Gitea Vite Build Action / Vite-Build (push) Successful in 41s Details
2024-10-24 22:59:52 +00:00
Sven Vogel 7c38e77329 feat(readme): added preview image
Gitea Vite Build Action / Vite-Build (push) Successful in 41s Details
2024-10-25 00:56:59 +02:00
Sven Vogel e84f97d9b7 fix(readme): fixed spelling mistake
Gitea Vite Build Action / Vite-Build (push) Successful in 41s Details
2024-10-25 00:52:46 +02:00
Sven Vogel c3b2daab62 fix(readme): centered banner image 2024-10-25 00:51:25 +02:00
Sven Vogel 8acf99bcc1 refactor(readme): updated readme
Gitea Vite Build Action / Vite-Build (push) Successful in 39s Details
Added section to readme:
- getting started
- technology stack
- docker container

Adjusted banner to take up 60% of width
2024-10-25 00:49:57 +02:00
Sven Vogel 6b3da418f7 refactor(readme): changed banner text color to white 2024-10-25 00:37:29 +02:00
Sven Vogel 67902044ca Merge pull request 'feat(docker): added multi stage dockerfile' (#4) from feat/docker-image into main
Gitea Vite Build Action / Vite-Build (push) Successful in 42s Details
Reviewed-on: #4
2024-10-24 22:35:18 +00:00
Sven Vogel 2e3c69b550 feat(docker): added multi stage dockerfile
Gitea Vite Build Action / Vite-Build (push) Successful in 41s Details
2024-10-25 00:34:53 +02:00
Sven Vogel 077d3ef8e9 Merge pull request 'feat/add-three.js' (#3) from feat/add-three.js into main
Gitea Vite Build Action / Vite-Build (push) Successful in 40s Details
Reviewed-on: #3
2024-10-24 22:16:31 +00:00
Sven Vogel ee965a539a fix(three): removed unused import
Gitea Vite Build Action / Vite-Build (push) Successful in 40s Details
2024-10-25 00:15:43 +02:00
Sven Vogel 8578ec4561 feat(three): added ambient light, directional light, base plate
Gitea Vite Build Action / Vite-Build (push) Failing after 34s Details
2024-10-25 00:12:57 +02:00
Sven Vogel 2be2a52925 feat(three): added sample scene
Added two gears and a gradient background
2024-10-24 23:58:58 +02:00
Sven Vogel b96f9626aa feat(three): added reat-three dependency 2024-10-24 23:58:21 +02:00
Sven Vogel 305430796f feat(three): installed three.js 2024-10-24 21:35:45 +02:00
Sven Vogel 0bdd94e870 Merge pull request 'feat/design-index-page' (#2) from feat/design-index-page into main
Gitea Vite Build Action / Vite-Build (push) Successful in 30s Details
Reviewed-on: #2
2024-10-24 19:29:34 +00:00
Sven Vogel 6dd7624458 fix(tailwindcss): removed unused imports and App.css
Gitea Vite Build Action / Vite-Build (push) Successful in 30s Details
2024-10-24 21:28:01 +02:00
Sven Vogel 6317ad2802 refactor(tailwindcss): added header to app.tsx
Gitea Vite Build Action / Vite-Build (push) Failing after 30s Details
2024-10-24 21:24:29 +02:00
Sven Vogel ca910bba0c feat(tailwindcss): added tailwindcss 2024-10-24 21:24:06 +02:00
Sven Vogel e97eb3e1ec Merge pull request 'ci/add-gitea-action' (#1) from ci/add-gitea-action into main
Gitea Vite Build Action / Vite-Build (push) Successful in 29s Details
Reviewed-on: #1
2024-10-24 18:04:43 +00:00
17 changed files with 2084 additions and 162 deletions

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM node:20 AS builder
COPY . /brunsviga
WORKDIR /brunsviga
RUN npm ci
RUN npm run build
FROM nginx:mainline-alpine3.20-slim as runtime
COPY --from=builder /brunsviga/dist /usr/share/nginx/html/
RUN chown -R 1000:1000 /usr/share/nginx/html/

8
LICENSE Normal file
View File

@ -0,0 +1,8 @@
Copyright 2024 Sven Vogel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,2 +1,52 @@
<img alt="banner" src="./assets/brunsviga_banner.svg" width="100%"/>
<div align="center">
<img alt="banner" src="./assets/brunsviga_banner.svg" width="60%"/>
<br>
<h2>Technology demonstration for 3D simulation of Brunsviga RK 13</h2>
</div>
<div align="center" >
<img src="./assets/preview.png" alt="preview" width="60%"/>
</div>
---
This repository is a demonstration of web technologies that might be used for simulating the Brunsviga RK 13 mechanical calculator.
The demo is designed to be small and lightweight in deploment.
We use `vite` as the build system for a `react.js` web application that makes use `three.js` WebGL capabilites in order to render 3D objects and animate them in realtime.
Typescript is the preferred language as it offers relative type-safety during development.
The user interface is styled with `tailwindcss` and will refer to the paper, source code and some refernce documentation for the Brunsviga RK 13.
The built application can be delpoyed via a static web server such as Nginx (see docker container).
## ☁️ Technology Stack
- Vite
- React
- Tailwind CSS
- Three.js
## 🚀 Getting Started
In order to get started, clone the repository:
```
git clone https://git.montehaselino.de/servostar/brunsviga-demo.git
```
Then build compile the application and run in development mode:
```
npm ci && npm run dev
```
## 🐋 Docker Container
The application can be build and launched in a multi stage container:
```
docker build --tag brunsviga-demo:latest .
```
Then run the container on port 80:
```
docker run -p 80:80 brunsviga-demo:latest
```

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 109 KiB

BIN
assets/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

1817
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,18 +10,23 @@
"preview": "vite preview"
},
"dependencies": {
"@react-three/drei": "^9.115.0",
"@react-three/fiber": "^8.17.10",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"three": "^0.169.0"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"@types/three": "^0.169.0",
"@vitejs/plugin-react": "^4.3.3",
"eslint": "^9.13.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.13",
"globals": "^15.11.0",
"tailwindcss": "^3.4.14",
"typescript": "~5.6.2",
"typescript-eslint": "^8.10.0",
"vite": "^5.4.9"

82
public/brunsviga_icon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 27 KiB

BIN
public/gear.glb Normal file

Binary file not shown.

View File

@ -1,42 +0,0 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}

View File

@ -1,33 +1,27 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import Renderer from './Renderer.tsx'
function App() {
const [count, setCount] = useState(0)
return (
<>
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
<header className="bg-gray-100 border-b-2">
<nav className="mx-auto flex max-w-7xl items-center justify-between p-3 lg:px-8" aria-label="Global">
<div className="flex lg:flex-1">
<a href="#" className="-m-1.5 p-1.5">
<span className="sr-only">Your Company</span>
<img className="h-12 w-auto" src="./brunsviga_icon.svg" alt=""/>
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
<div className="hidden lg:flex lg:gap-x-12">
<a href="#" className="text-sm font-semibold leading-6 text-gray-900">Brunsviga RK 13</a>
<a href="#" className="text-sm font-semibold leading-6 text-gray-900">Thesis</a>
<a href="#" className="text-sm font-semibold leading-6 text-gray-900">Source</a>
<a href="#" className="text-sm font-semibold leading-6 text-gray-900">Credits</a>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<div className="hidden lg:flex lg:flex-1 lg:justify-end"/>
</nav>
</header>
<Renderer/>
</>
)
}

50
src/Renderer.tsx Normal file
View File

@ -0,0 +1,50 @@
import { Canvas, useFrame, useLoader } from '@react-three/fiber';
import { Circle, Clone, ContactShadows, OrbitControls } from '@react-three/drei'
import { Suspense, useRef } from 'react';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
function Gear(props: any) {
const gltf = useLoader(GLTFLoader, './gear.glb');
const gear1Ref = useRef<any>()
const gear2Ref = useRef<any>()
const speed = 2.5;
useFrame(({ clock }) => {
gear1Ref.current.rotation.z = clock.getElapsedTime() * speed + Math.sin(clock.getElapsedTime()) * speed
gear2Ref.current.rotation.z = -clock.getElapsedTime() * speed - Math.sin(clock.getElapsedTime()) * speed
})
return <>
<Clone ref={gear1Ref} {...props} object={gltf.scene} />
<Clone ref={gear2Ref} position={[2.5,0,0]} {...props} object={gltf.scene} />
</>
}
function Renderer() {
return (
<div className='flex flex-col h-screen gradient'>
<Canvas camera={{ position: [-8, 5, 8] }}>
<Suspense fallback={null}>
<ambientLight />
<directionalLight />
<Gear />
<ContactShadows
scale={60}
position={[0, -2, 0]}
opacity={2.0}
blur={2}
resolution={512}
/>
<Circle args={[10]} position={[0,-2.001,0]} rotation-x={-Math.PI / 2} receiveShadow>
<meshBasicMaterial color={[0.8,0.8,0.8]}/>
</Circle>
<OrbitControls target={[0, 0, 0]} maxPolarAngle={Math.PI / 2.0} />
</Suspense>
</Canvas>
</div>
);
}
export default Renderer

View File

@ -1,68 +1,8 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
@tailwind base;
@tailwind components;
@tailwind utilities;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
.gradient {
background: rgb(255,255,255);
background: linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(190,190,190,1) 100%);
}

10
tailwind.config.js Normal file
View File

@ -0,0 +1,10 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

1
tsconfig.app.tsbuildinfo Normal file
View File

@ -0,0 +1 @@
{"root":["./src/App.tsx","./src/Renderer.tsx","./src/main.tsx","./src/vite-env.d.ts"],"version":"5.6.3"}

View File

@ -0,0 +1 @@
{"root":["./vite.config.ts"],"version":"5.6.3"}

View File

@ -1,7 +1,16 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from "tailwindcss";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
css: {
postcss: {
plugins: [tailwindcss()],
},
},
assetsInclude: [
"**/*.glb"
]
})