Compare commits
No commits in common. "main" and "ci/add-gitea-action" have entirely different histories.
main
...
ci/add-git
12
Dockerfile
12
Dockerfile
|
@ -1,12 +0,0 @@
|
|||
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
8
LICENSE
|
@ -1,8 +0,0 @@
|
|||
|
||||
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.
|
52
README.md
52
README.md
|
@ -1,52 +1,2 @@
|
|||
|
||||
<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
|
||||
```
|
||||
<img alt="banner" src="./assets/brunsviga_banner.svg" width="100%"/>
|
||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 112 KiB |
Binary file not shown.
Before Width: | Height: | Size: 43 KiB |
File diff suppressed because it is too large
Load Diff
|
@ -10,23 +10,18 @@
|
|||
"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",
|
||||
"three": "^0.169.0"
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"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"
|
||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 27 KiB |
BIN
public/gear.glb
BIN
public/gear.glb
Binary file not shown.
|
@ -0,0 +1,42 @@
|
|||
#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;
|
||||
}
|
38
src/App.tsx
38
src/App.tsx
|
@ -1,27 +1,33 @@
|
|||
import Renderer from './Renderer.tsx'
|
||||
import { useState } from 'react'
|
||||
import reactLogo from './assets/react.svg'
|
||||
import viteLogo from '/vite.svg'
|
||||
import './App.css'
|
||||
|
||||
function App() {
|
||||
const [count, setCount] = useState(0)
|
||||
|
||||
return (
|
||||
<>
|
||||
<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=""/>
|
||||
<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" />
|
||||
</a>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
<div className="hidden lg:flex lg:flex-1 lg:justify-end"/>
|
||||
</nav>
|
||||
</header>
|
||||
<Renderer/>
|
||||
<p className="read-the-docs">
|
||||
Click on the Vite and React logos to learn more
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
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
|
|
@ -1,8 +1,68 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
:root {
|
||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
.gradient {
|
||||
background: rgb(255,255,255);
|
||||
background: linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(190,190,190,1) 100%);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: [
|
||||
"./src/**/*.{js,jsx,ts,tsx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{"root":["./src/App.tsx","./src/Renderer.tsx","./src/main.tsx","./src/vite-env.d.ts"],"version":"5.6.3"}
|
|
@ -1 +0,0 @@
|
|||
{"root":["./vite.config.ts"],"version":"5.6.3"}
|
|
@ -1,16 +1,7 @@
|
|||
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"
|
||||
]
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue