@crapthings/run3d 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -16
- package/package.json +1 -1
- package/template/AGENTS.md +1 -0
- package/template/package.json +3 -0
- package/template/src/App.jsx +4 -1
- package/template/src/i18n.js +34 -0
- package/template/src/locales/en.json +5 -0
- package/template/src/locales/zh.json +5 -0
- package/template/src/main.jsx +1 -0
package/README.md
CHANGED
|
@@ -18,8 +18,16 @@ Edit the components in `src/Scenes` to make the starter scene your own. To insta
|
|
|
18
18
|
|
|
19
19
|
Drag to orbit the scene, scroll to zoom, and right-drag to pan. Edit `src/Scenes/index.jsx` for the scene and its settings.
|
|
20
20
|
|
|
21
|
+
## Languages
|
|
22
|
+
|
|
23
|
+
The template initializes [react-i18next](https://react.i18next.com/latest) in `src/i18n.js`, with English and Chinese resources in `src/locales`. It detects the browser language, falls back to English, and remembers language changes in local storage. The document's `lang` attribute follows the active language.
|
|
24
|
+
|
|
25
|
+
Use `const { t, i18n } = useTranslation()` from `react-i18next` in components, render text with `t('scene.label')`, and switch languages with `i18n.changeLanguage('zh')` or `i18n.changeLanguage('en')`. Add new translation keys to both JSON files; register additional languages in `src/i18n.js`.
|
|
26
|
+
|
|
21
27
|
## Included tools
|
|
22
28
|
|
|
29
|
+
Ordered by importance to the starter and typical usage, with core tools first and specialized tools later.
|
|
30
|
+
|
|
23
31
|
### App foundation
|
|
24
32
|
|
|
25
33
|
- [React and React DOM](https://github.com/react/react) — build and render the app UI.
|
|
@@ -35,6 +43,22 @@ Drag to orbit the scene, scroll to zoom, and right-drag to pan. Edit `src/Scenes
|
|
|
35
43
|
- [pmndrs/math](https://github.com/pmndrs/math) — provides math utilities for 3D work.
|
|
36
44
|
- [R3F-Perf](https://github.com/utsuboco/r3f-perf) — monitors rendering performance while developing.
|
|
37
45
|
|
|
46
|
+
### Data and state
|
|
47
|
+
|
|
48
|
+
- [Zustand](https://github.com/pmndrs/zustand) — manages React app state.
|
|
49
|
+
- [Koota](https://github.com/pmndrs/koota) — manages game state with entities and components.
|
|
50
|
+
- [D3](https://github.com/d3/d3) — provides data scales, layouts, and visualizations.
|
|
51
|
+
- [p5.js](https://github.com/processing/p5.js) — creates interactive graphics and creative coding sketches.
|
|
52
|
+
|
|
53
|
+
### Interface
|
|
54
|
+
|
|
55
|
+
- [Tailwind CSS](https://github.com/tailwindlabs/tailwindcss) — styles the app.
|
|
56
|
+
- [Headless UI](https://github.com/tailwindlabs/headlessui) — provides accessible, unstyled React UI components.
|
|
57
|
+
- [React Router](https://github.com/remix-run/react-router) — connects URLs to pages and handles navigation.
|
|
58
|
+
- [react-i18next](https://react.i18next.com/) and [i18next](https://www.i18next.com/) — translate UI text, with browser language detection and a saved language preference.
|
|
59
|
+
- [React Hotkeys Hook](https://github.com/JohannesKlauss/react-hotkeys-hook) — adds declarative keyboard shortcuts with a React hook.
|
|
60
|
+
- [Floating UI](https://github.com/floating-ui/floating-ui) — positions menus, tooltips, and popovers.
|
|
61
|
+
|
|
38
62
|
### Worlds and movement
|
|
39
63
|
|
|
40
64
|
- [React Three Rapier](https://github.com/pmndrs/react-three-rapier) — adds physics and collisions.
|
|
@@ -44,23 +68,8 @@ Drag to orbit the scene, scroll to zoom, and right-drag to pan. Edit `src/Scenes
|
|
|
44
68
|
- [Three Hex Tiling](https://github.com/Ameobea/three-hex-tiling) — reduces visible repetition in tiled textures.
|
|
45
69
|
- [TSL Hex Tiling](https://github.com/crapthings/tsl-hex-tiling) — reduces texture repetition with Three.js TSL for WebGPU and WebGL 2.
|
|
46
70
|
|
|
47
|
-
### Data and state
|
|
48
|
-
|
|
49
|
-
- [Zustand](https://github.com/pmndrs/zustand) — manages React app state.
|
|
50
|
-
- [Koota](https://github.com/pmndrs/koota) — manages game state with entities and components.
|
|
51
|
-
- [D3](https://github.com/d3/d3) — provides data scales, layouts, and visualizations.
|
|
52
|
-
- [p5.js](https://github.com/processing/p5.js) — creates interactive graphics and creative coding sketches.
|
|
53
|
-
|
|
54
71
|
### Media
|
|
55
72
|
|
|
56
|
-
- [Elementary](https://github.com/elemaudio/elementary) — creates declarative audio DSP graphs with `@elemaudio/core` and runs them in the browser with `@elemaudio/web-renderer`.
|
|
57
73
|
- [Howler.js](https://github.com/goldfire/howler.js#documentation) — plays audio with volume controls, sound sprites, and 3D spatial sound.
|
|
58
74
|
- [Mediabunny](https://mediabunny.dev/) — reads, writes, and converts audio and video files in the browser.
|
|
59
|
-
|
|
60
|
-
### Interface
|
|
61
|
-
|
|
62
|
-
- [React Router](https://github.com/remix-run/react-router) — connects URLs to pages and handles navigation.
|
|
63
|
-
- [Tailwind CSS](https://github.com/tailwindlabs/tailwindcss) — styles the app.
|
|
64
|
-
- [React Hotkeys Hook](https://github.com/JohannesKlauss/react-hotkeys-hook) — adds declarative keyboard shortcuts with a React hook.
|
|
65
|
-
- [Headless UI](https://github.com/tailwindlabs/headlessui) — provides accessible, unstyled React UI components.
|
|
66
|
-
- [Floating UI](https://github.com/floating-ui/floating-ui) — positions menus, tooltips, and popovers.
|
|
75
|
+
- [Elementary](https://github.com/elemaudio/elementary) — creates declarative audio DSP graphs with `@elemaudio/core` and runs them in the browser with `@elemaudio/web-renderer`.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.12",
|
|
7
7
|
"description": "From idea to interactive 3D prototype in one command. A JavaScript starter with Vite, React Three Fiber, and tools for creative experimentation.",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"bin": {
|
package/template/AGENTS.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
- Avoid overengineering: question whether each solution or abstraction is needed for current requirements before implementing it.
|
|
24
24
|
- Write component styles inline with Tailwind utilities in `className`, using arbitrary values when needed; use CSS files only for global setup or styles Tailwind cannot express.
|
|
25
25
|
- Use Zustand for shared state and actions; avoid prop drilling.
|
|
26
|
+
- Use react-i18next for UI translations; keep language resources in `src/locales` and initialize them in `src/i18n.js`.
|
|
26
27
|
|
|
27
28
|
## UI Components
|
|
28
29
|
|
package/template/package.json
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"fastnoise-lite": "^1.1.1",
|
|
28
28
|
"gsap": "^3.15.0",
|
|
29
29
|
"howler": "^2.2.4",
|
|
30
|
+
"i18next": "^26.5.11",
|
|
31
|
+
"i18next-browser-languagedetector": "^8.2.3",
|
|
30
32
|
"koota": "^0.6.6",
|
|
31
33
|
"math": "0.1.0",
|
|
32
34
|
"mediabunny": "^1.61.6",
|
|
@@ -36,6 +38,7 @@
|
|
|
36
38
|
"react": "19.2.8",
|
|
37
39
|
"react-dom": "19.2.8",
|
|
38
40
|
"react-hotkeys-hook": "^5.3.3",
|
|
41
|
+
"react-i18next": "^17.1.9",
|
|
39
42
|
"react-router": "^8.4.0",
|
|
40
43
|
"recast-navigation": "^0.43.1",
|
|
41
44
|
"three": "^0.186.1",
|
package/template/src/App.jsx
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Scene } from '@/Scenes'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
2
3
|
|
|
3
4
|
// The starter scene fills the viewport against the favicon's dark background.
|
|
4
5
|
export function App () {
|
|
6
|
+
const { t } = useTranslation()
|
|
7
|
+
|
|
5
8
|
return (
|
|
6
|
-
<main className='fixed inset-0 bg-slate-900'>
|
|
9
|
+
<main className='fixed inset-0 bg-slate-900' aria-label={t('scene.label')}>
|
|
7
10
|
<Scene />
|
|
8
11
|
</main>
|
|
9
12
|
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import i18n from 'i18next'
|
|
2
|
+
import LanguageDetector from 'i18next-browser-languagedetector'
|
|
3
|
+
import { initReactI18next } from 'react-i18next'
|
|
4
|
+
import en from '@/locales/en.json'
|
|
5
|
+
import zh from '@/locales/zh.json'
|
|
6
|
+
|
|
7
|
+
// Keep the document language aligned with the active translation language.
|
|
8
|
+
function updateDocumentLanguage (language) {
|
|
9
|
+
document.documentElement.lang = language
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
i18n.on('languageChanged', updateDocumentLanguage)
|
|
13
|
+
|
|
14
|
+
i18n
|
|
15
|
+
.use(LanguageDetector)
|
|
16
|
+
.use(initReactI18next)
|
|
17
|
+
.init({
|
|
18
|
+
resources: {
|
|
19
|
+
en: { translation: en },
|
|
20
|
+
zh: { translation: zh }
|
|
21
|
+
},
|
|
22
|
+
supportedLngs: ['en', 'zh'],
|
|
23
|
+
fallbackLng: 'en',
|
|
24
|
+
load: 'languageOnly',
|
|
25
|
+
detection: {
|
|
26
|
+
order: ['localStorage', 'navigator'],
|
|
27
|
+
caches: ['localStorage']
|
|
28
|
+
},
|
|
29
|
+
interpolation: {
|
|
30
|
+
escapeValue: false
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export default i18n
|