@crapthings/run3d 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.2.3",
6
+ "version": "0.2.4",
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": {
@@ -1,4 +1,13 @@
1
1
  # Rules
2
2
 
3
+ ## Commands
4
+
3
5
  - Only run `pnpm build`, `pnpm lint`, or `pnpm test` when explicitly requested by the user.
6
+
7
+ ## Code Style
8
+
4
9
  - Follow JavaScript Standard Style (standard.js) when writing `.js` and `.jsx` files.
10
+
11
+ ## Scene Lighting
12
+
13
+ - Avoid ambient lighting by default. Only add ambient lighting (such as `AmbientLight` or `HemisphereLight`) when explicitly requested by the user.
@@ -1,5 +1,11 @@
1
- import { Canvas } from '@react-three/fiber'
2
- import { Grid, OrbitControls } from '@react-three/drei'
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]
3
9
 
4
10
  function Box () {
5
11
  return (
@@ -10,13 +16,52 @@ function Box () {
10
16
  )
11
17
  }
12
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
+
13
47
  export function Scene () {
14
48
  return (
15
- <Canvas camera={{ position: [3, 2.4, 4.6], fov: 45 }} shadows>
16
- <color attach='background' args={['#f8fafc']} />
17
- <ambientLight intensity={0.8} />
18
- <directionalLight castShadow intensity={2} position={[4, 6, 3]} />
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 />
19
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>
20
65
  <Grid
21
66
  args={[12, 12]}
22
67
  cellColor='#cbd5e1'
@@ -29,7 +74,7 @@ export function Scene () {
29
74
  sectionSize={2}
30
75
  sectionThickness={1}
31
76
  />
32
- <OrbitControls makeDefault />
77
+ <OrbitControls makeDefault target={[0, 0.7, 0]} />
33
78
  </Canvas>
34
79
  )
35
80
  }