Skip to content

Commit a276bf3

Browse files
committed
docs: update demos
1 parent bf4f681 commit a276bf3

6 files changed

Lines changed: 23 additions & 21 deletions

File tree

playground/App.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { A, Route, Router } from "@solidjs/router"
22
import type { ParentProps } from "solid-js"
33
import * as THREE from "three"
4-
import { Canvas, createT } from "../src/index.ts"
4+
import { Canvas, createT, Entity } from "../src/index.ts"
55
import { EnvironmentExample } from "./examples/EnvironmentExample.tsx"
66
import { PortalExample } from "./examples/PortalExample.tsx"
77
import { SolarExample } from "./examples/SolarExample.tsx"
@@ -83,13 +83,16 @@ export function App() {
8383
path="/"
8484
component={() => (
8585
<Canvas
86+
defaultCamera={{ position: new THREE.Vector3(0, 0, 15) }}
87+
scene={{ background: [1, 0, 0] }}
8688
style={{ width: "100vw", height: "100vh" }}
87-
camera={{ position: new THREE.Vector3(0, 0, 15) }}
8889
>
89-
<T.Mesh>
90-
<T.BoxGeometry />
91-
<T.MeshBasicMaterial color="gray" />
92-
</T.Mesh>
90+
<Entity from={THREE.Group}>
91+
<T.Mesh>
92+
<T.BoxGeometry />
93+
<T.MeshBasicMaterial color="gray" />
94+
</T.Mesh>
95+
</Entity>
9396
</Canvas>
9497
)}
9598
/>

playground/controls/OrbitControls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { processProps } from "./process-props.ts"
88

99
export interface OrbitControlsProps extends S3.Props<typeof ThreeOrbitControls> {
1010
ref?: Ref<ThreeOrbitControls>
11-
camera?: S3.CameraType
11+
camera?: S3.CameraKind
1212
domElement?: HTMLElement
1313
enableDamping?: boolean
1414
onChange?: (e?: Event<"change", ThreeOrbitControls>) => void
@@ -41,7 +41,7 @@ export function OrbitControls(props: OrbitControlsProps) {
4141
const three = useThree()
4242
const controls = createMemo<ThreeOrbitControls>(previous => {
4343
previous?.dispose()
44-
return new ThreeOrbitControls(config.camera ?? three.camera)
44+
return new ThreeOrbitControls(config.camera ?? three.currentCamera)
4545
})
4646

4747
useFrame(() => controls().update())

playground/examples/EnvironmentExample.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import * as THREE from "three"
2+
import { Resource } from "../../src/components.tsx"
23
import { Canvas, createT } from "../../src/index.ts"
34
import { OrbitControls } from "../controls/OrbitControls.tsx"
45

56
const T = createT(THREE)
67

78
export function EnvironmentExample() {
8-
const texture = new THREE.CubeTextureLoader()
9-
.setPath(
10-
"https://rawcdn.githack.com/mrdoob/three.js/54ac263593c81b669ca9a089491ddd9e240427d2/examples/textures/cube/Bridge2/",
11-
)
12-
.load(["posx.jpg", "negx.jpg", "posy.jpg", "negy.jpg", "posz.jpg", "negz.jpg"])
13-
149
return (
1510
<Canvas
1611
style={{ width: "100vw", height: "100vh" }}
17-
camera={{ position: new THREE.Vector3(0, 0, 30) }}
12+
defaultCamera={{ position: new THREE.Vector3(0, 0, 30) }}
1813
onClick={event => console.debug("canvas clicked", event)}
1914
onClickMissed={event => console.debug("canvas click missed", event)}
2015
onPointerLeave={event => console.debug("canvas pointer leave", event)}
2116
onPointerEnter={event => console.debug("canvas pointer enter", event)}
22-
scene={{
23-
environment: texture,
24-
}}
2517
>
2618
<OrbitControls />
2719
<T.Mesh>
2820
<T.TorusKnotGeometry args={[1, 0.5, 128, 32]} />
29-
<T.MeshStandardMaterial metalness={1} roughness={0} color="white" />
21+
<T.MeshStandardMaterial metalness={1} roughness={0} color="white">
22+
<Resource
23+
loader={THREE.CubeTextureLoader}
24+
attach="envMap"
25+
path="https://rawcdn.githack.com/mrdoob/three.js/54ac263593c81b669ca9a089491ddd9e240427d2/examples/textures/cube/Bridge2/"
26+
url={["posx.jpg", "negx.jpg", "posy.jpg", "negy.jpg", "posz.jpg", "negz.jpg"]}
27+
/>
28+
</T.MeshStandardMaterial>
3029
</T.Mesh>
3130
</Canvas>
3231
)

playground/examples/Gltf.tsx

Whitespace-only changes.

playground/examples/PortalExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function PortalExample() {
88
return (
99
<Canvas
1010
style={{ width: "100vw", height: "100vh" }}
11-
camera={{ position: new THREE.Vector3(0, 0, 30) }}
11+
defaultCamera={{ position: new THREE.Vector3(0, 0, 30) }}
1212
onClick={event => console.debug("canvas clicked", event)}
1313
onClickMissed={event => console.debug("canvas click missed", event)}
1414
onPointerLeave={event => console.debug("canvas pointer leave", event)}

playground/examples/SolarExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function CelestialBody(
119119
export function SolarExample() {
120120
return (
121121
<Canvas
122-
camera={{ position: new THREE.Vector3(0, 0, 30) }}
122+
defaultCamera={{ position: new THREE.Vector3(0, 0, 30) }}
123123
onClick={event => console.debug("canvas clicked", event)}
124124
onClickMissed={event => console.debug("canvas click missed", event)}
125125
onPointerLeave={event => console.debug("canvas pointer leave", event)}

0 commit comments

Comments
 (0)