@crapthings/run3d 0.2.4 → 0.2.5
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 +4 -1
- package/package.json +1 -1
- package/template/AGENTS.md +5 -1
- package/template/package.json +1 -0
- package/template/pnpm-lock.yaml +14 -0
- package/template/src/App.jsx +1 -1
- package/template/src/Scenes/index.jsx +42 -0
- package/template/src/Scene.jsx +0 -80
package/README.md
CHANGED
|
@@ -14,7 +14,9 @@ cd my-project
|
|
|
14
14
|
pnpm dev
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Edit `src/
|
|
17
|
+
Edit the components in `src/Scenes` to make the starter scene your own. To install dependencies later, add `--skip-install` to the first command.
|
|
18
|
+
|
|
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.
|
|
18
20
|
|
|
19
21
|
## Included tools
|
|
20
22
|
|
|
@@ -52,5 +54,6 @@ Edit `src/Scene.jsx` to make it your own. To install dependencies later, add `--
|
|
|
52
54
|
|
|
53
55
|
- [React Router](https://github.com/remix-run/react-router) — connects URLs to pages and handles navigation.
|
|
54
56
|
- [Tailwind CSS](https://github.com/tailwindlabs/tailwindcss) — styles the app.
|
|
57
|
+
- [React Hotkeys Hook](https://github.com/JohannesKlauss/react-hotkeys-hook) — adds declarative keyboard shortcuts with a React hook.
|
|
55
58
|
- [Headless UI](https://github.com/tailwindlabs/headlessui) — provides accessible, unstyled React UI components.
|
|
56
59
|
- [Floating UI](https://github.com/floating-ui/floating-ui) — positions menus, tooltips, and popovers.
|
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.5",
|
|
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Commands
|
|
4
4
|
|
|
5
|
-
- Only run `pnpm build`, `pnpm lint`, or `pnpm test` when explicitly requested by the user
|
|
5
|
+
- Only run `pnpm build`, `pnpm lint`, or `pnpm test` when explicitly requested by the user, and never run `pnpm dev`.
|
|
6
6
|
|
|
7
7
|
## Code Style
|
|
8
8
|
|
|
@@ -11,3 +11,7 @@
|
|
|
11
11
|
## Scene Lighting
|
|
12
12
|
|
|
13
13
|
- Avoid ambient lighting by default. Only add ambient lighting (such as `AmbientLight` or `HemisphereLight`) when explicitly requested by the user.
|
|
14
|
+
|
|
15
|
+
## Texture Maps
|
|
16
|
+
|
|
17
|
+
- When using texture maps, process them with the installed `three-hex-tiling` package to reduce visible texture repetition instead of relying on basic repeating UV tiling alone.
|
package/template/package.json
CHANGED
package/template/pnpm-lock.yaml
CHANGED
|
@@ -220,6 +220,9 @@ importers:
|
|
|
220
220
|
react-dom:
|
|
221
221
|
specifier: 19.2.8
|
|
222
222
|
version: 19.2.8(react@19.2.8)
|
|
223
|
+
react-hotkeys-hook:
|
|
224
|
+
specifier: ^5.3.3
|
|
225
|
+
version: 5.3.3(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
|
223
226
|
react-router:
|
|
224
227
|
specifier: ^7.18.3
|
|
225
228
|
version: 7.18.3(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
|
@@ -1327,6 +1330,12 @@ packages:
|
|
|
1327
1330
|
peerDependencies:
|
|
1328
1331
|
react: ^19.2.8
|
|
1329
1332
|
|
|
1333
|
+
react-hotkeys-hook@5.3.3:
|
|
1334
|
+
resolution: {integrity: sha512-aswgyWUnE25hmhzHTfKDmKzsaSE5DJ4LKaU/o6rQSXkDd/1Bh9TfAFQbHkf6fLy11HvlYkp+cDDarGdhmCDhoQ==}
|
|
1335
|
+
peerDependencies:
|
|
1336
|
+
react: '>=16.8.0'
|
|
1337
|
+
react-dom: '>=16.8.0'
|
|
1338
|
+
|
|
1330
1339
|
react-is@16.13.1:
|
|
1331
1340
|
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
|
|
1332
1341
|
|
|
@@ -2557,6 +2566,11 @@ snapshots:
|
|
|
2557
2566
|
react: 19.2.8
|
|
2558
2567
|
scheduler: 0.27.0
|
|
2559
2568
|
|
|
2569
|
+
react-hotkeys-hook@5.3.3(react-dom@19.2.8(react@19.2.8))(react@19.2.8):
|
|
2570
|
+
dependencies:
|
|
2571
|
+
react: 19.2.8
|
|
2572
|
+
react-dom: 19.2.8(react@19.2.8)
|
|
2573
|
+
|
|
2560
2574
|
react-is@16.13.1: {}
|
|
2561
2575
|
|
|
2562
2576
|
react-router@7.18.3(react-dom@19.2.8(react@19.2.8))(react@19.2.8):
|
package/template/src/App.jsx
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Canvas, extend } from '@react-three/fiber'
|
|
2
|
+
import { Grid, OrbitControls, Sky } from '@react-three/drei'
|
|
3
|
+
import { Perf } from 'r3f-perf'
|
|
4
|
+
import { SunLight } from 'three/addons/lights/SunLight.js'
|
|
5
|
+
|
|
6
|
+
extend({ SunLight })
|
|
7
|
+
|
|
8
|
+
// One world unit represents one meter.
|
|
9
|
+
export function Scene () {
|
|
10
|
+
return (
|
|
11
|
+
<Canvas camera={{ position: [4, 3.4, 6], fov: 50, far: 100 }} dpr={1} shadows>
|
|
12
|
+
{import.meta.env.DEV && <Perf position='top-right' />}
|
|
13
|
+
<sunLight
|
|
14
|
+
args={['#fff2e3', 2]}
|
|
15
|
+
position={[30, 45, 20]}
|
|
16
|
+
castShadow
|
|
17
|
+
shadow-camera-far={60}
|
|
18
|
+
/>
|
|
19
|
+
<Sky distance={1000} rayleigh={1} sunPosition={[30, 45, 20]} turbidity={4} />
|
|
20
|
+
<mesh castShadow position-y={0.7}>
|
|
21
|
+
<boxGeometry args={[1.4, 1.4, 1.4]} />
|
|
22
|
+
<meshStandardMaterial color='#38bdf8' metalness={0.15} roughness={0.35} />
|
|
23
|
+
</mesh>
|
|
24
|
+
<mesh receiveShadow rotation-x={-Math.PI / 2} position-y={-0.01}>
|
|
25
|
+
<planeGeometry args={[64, 64]} />
|
|
26
|
+
<shadowMaterial transparent opacity={0.25} depthWrite={false} />
|
|
27
|
+
</mesh>
|
|
28
|
+
<Grid
|
|
29
|
+
args={[64, 64]}
|
|
30
|
+
cellColor='#cbd5e1'
|
|
31
|
+
cellSize={1}
|
|
32
|
+
cellThickness={0.5}
|
|
33
|
+
fadeDistance={32}
|
|
34
|
+
infiniteGrid
|
|
35
|
+
sectionColor='#94a3b8'
|
|
36
|
+
sectionSize={2}
|
|
37
|
+
sectionThickness={0.8}
|
|
38
|
+
/>
|
|
39
|
+
<OrbitControls makeDefault target={[0, 0.7, 0]} />
|
|
40
|
+
</Canvas>
|
|
41
|
+
)
|
|
42
|
+
}
|
package/template/src/Scene.jsx
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Canvas, extend } from '@react-three/fiber'
|
|
2
|
-
import { Grid, OrbitControls, Sky, SpotLight } from '@react-three/drei'
|
|
3
|
-
import { Perf } from 'r3f-perf'
|
|
4
|
-
import { SunLight } from 'three/addons/lights/SunLight.js'
|
|
5
|
-
|
|
6
|
-
extend({ SunLight })
|
|
7
|
-
|
|
8
|
-
const SUN_POSITION = [30, 45, 20]
|
|
9
|
-
|
|
10
|
-
function Box () {
|
|
11
|
-
return (
|
|
12
|
-
<mesh castShadow position-y={0.7}>
|
|
13
|
-
<boxGeometry args={[1.4, 1.4, 1.4]} />
|
|
14
|
-
<meshStandardMaterial color='#38bdf8' metalness={0.15} roughness={0.35} />
|
|
15
|
-
</mesh>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function Atmosphere () {
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
<Sky
|
|
23
|
-
distance={80}
|
|
24
|
-
mieCoefficient={0.005}
|
|
25
|
-
mieDirectionalG={0.8}
|
|
26
|
-
rayleigh={1}
|
|
27
|
-
sunPosition={SUN_POSITION}
|
|
28
|
-
turbidity={6}
|
|
29
|
-
/>
|
|
30
|
-
<SpotLight
|
|
31
|
-
angle={0.35}
|
|
32
|
-
anglePower={4}
|
|
33
|
-
attenuation={80}
|
|
34
|
-
castShadow={false}
|
|
35
|
-
color='#fff2e3'
|
|
36
|
-
distance={70}
|
|
37
|
-
intensity={0}
|
|
38
|
-
opacity={0.035}
|
|
39
|
-
position={SUN_POSITION}
|
|
40
|
-
radiusBottom={14}
|
|
41
|
-
radiusTop={1}
|
|
42
|
-
/>
|
|
43
|
-
</>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function Scene () {
|
|
48
|
-
return (
|
|
49
|
-
<Canvas camera={{ position: [6, 4.8, 9.2], fov: 45, far: 100 }} dpr={[1, 1.5]} shadows>
|
|
50
|
-
{import.meta.env.DEV && <Perf position='top-right' />}
|
|
51
|
-
<color attach='background' args={['#b9d2e5']} />
|
|
52
|
-
<fogExp2 attach='fog' args={['#b9d2e5', 0.01]} />
|
|
53
|
-
<sunLight
|
|
54
|
-
args={[0xfff2e3, 3]}
|
|
55
|
-
castShadow
|
|
56
|
-
position={SUN_POSITION}
|
|
57
|
-
shadow-camera-far={60}
|
|
58
|
-
/>
|
|
59
|
-
<Atmosphere />
|
|
60
|
-
<Box />
|
|
61
|
-
<mesh receiveShadow rotation-x={-Math.PI / 2} position-y={-0.01}>
|
|
62
|
-
<planeGeometry args={[60, 60]} />
|
|
63
|
-
<shadowMaterial transparent opacity={0.25} depthWrite={false} />
|
|
64
|
-
</mesh>
|
|
65
|
-
<Grid
|
|
66
|
-
args={[12, 12]}
|
|
67
|
-
cellColor='#cbd5e1'
|
|
68
|
-
cellSize={0.5}
|
|
69
|
-
cellThickness={0.6}
|
|
70
|
-
fadeDistance={18}
|
|
71
|
-
fadeStrength={1}
|
|
72
|
-
infiniteGrid
|
|
73
|
-
sectionColor='#94a3b8'
|
|
74
|
-
sectionSize={2}
|
|
75
|
-
sectionThickness={1}
|
|
76
|
-
/>
|
|
77
|
-
<OrbitControls makeDefault target={[0, 0.7, 0]} />
|
|
78
|
-
</Canvas>
|
|
79
|
-
)
|
|
80
|
-
}
|