@viamrobotics/motion-tools 1.28.0 → 1.28.1
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.
|
@@ -1,54 +1,73 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { T } from '@threlte/core'
|
|
3
3
|
import { EquirectangularReflectionMapping, type Texture, TextureLoader } from 'three'
|
|
4
|
+
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js'
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
url: string
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
9
|
+
* World-space position `[x, y, z]`. Defaults to `[0, 0, height]` so the
|
|
10
|
+
* dome's ground sits flush with the world XY plane in this Z-up scene.
|
|
11
|
+
*/
|
|
12
|
+
position?: [x: number, y: number, z: number]
|
|
13
|
+
/**
|
|
14
|
+
* Euler rotation `[x, y, z]` in radians. Default aligns the
|
|
15
|
+
* equirectangular image's vertical axis (+Y) with this scene's vertical
|
|
16
|
+
* axis (+Z); the Z component then acts as yaw around world +Z.
|
|
11
17
|
*/
|
|
12
18
|
rotation?: [x: number, y: number, z: number]
|
|
19
|
+
/**
|
|
20
|
+
* Camera height above ground when the source photo was taken. Larger
|
|
21
|
+
* values magnify the lower portion of the image.
|
|
22
|
+
*/
|
|
23
|
+
height?: number
|
|
24
|
+
/**
|
|
25
|
+
* Skybox dome radius. Must exceed the scene camera's reach.
|
|
26
|
+
*/
|
|
27
|
+
radius?: number
|
|
13
28
|
}
|
|
14
29
|
|
|
15
|
-
const {
|
|
16
|
-
|
|
30
|
+
const {
|
|
31
|
+
url,
|
|
32
|
+
position,
|
|
33
|
+
rotation = [Math.PI / 2, 0, 0],
|
|
34
|
+
height = 15,
|
|
35
|
+
radius = 100,
|
|
36
|
+
}: Props = $props()
|
|
37
|
+
|
|
38
|
+
let texture = $state.raw<Texture | undefined>()
|
|
17
39
|
|
|
18
40
|
$effect.pre(() => {
|
|
19
|
-
const previous = scene.background
|
|
20
|
-
let texture: Texture | undefined
|
|
21
41
|
let cancelled = false
|
|
42
|
+
let loaded: Texture | undefined
|
|
22
43
|
|
|
23
|
-
new TextureLoader().load(url, (
|
|
44
|
+
new TextureLoader().load(url, (t) => {
|
|
24
45
|
if (cancelled) {
|
|
25
|
-
|
|
46
|
+
t.dispose()
|
|
26
47
|
return
|
|
27
48
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
invalidate()
|
|
49
|
+
t.mapping = EquirectangularReflectionMapping
|
|
50
|
+
loaded = t
|
|
51
|
+
texture = t
|
|
32
52
|
})
|
|
33
53
|
|
|
34
54
|
return () => {
|
|
35
55
|
cancelled = true
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
invalidate()
|
|
39
|
-
}
|
|
40
|
-
texture?.dispose()
|
|
56
|
+
loaded?.dispose()
|
|
57
|
+
texture = undefined
|
|
41
58
|
}
|
|
42
59
|
})
|
|
43
60
|
|
|
44
|
-
$
|
|
45
|
-
const previous = scene.backgroundRotation.clone()
|
|
46
|
-
scene.backgroundRotation.set(...rotation)
|
|
47
|
-
invalidate()
|
|
48
|
-
|
|
49
|
-
return () => {
|
|
50
|
-
scene.backgroundRotation.copy(previous)
|
|
51
|
-
invalidate()
|
|
52
|
-
}
|
|
53
|
-
})
|
|
61
|
+
const resolvedPosition = $derived(position ?? ([0, 0, height] as [number, number, number]))
|
|
54
62
|
</script>
|
|
63
|
+
|
|
64
|
+
{#if texture}
|
|
65
|
+
<T
|
|
66
|
+
is={GroundedSkybox}
|
|
67
|
+
args={[texture, height, radius]}
|
|
68
|
+
position={resolvedPosition}
|
|
69
|
+
{rotation}
|
|
70
|
+
raycast={() => null}
|
|
71
|
+
bvh={{ enabled: false }}
|
|
72
|
+
/>
|
|
73
|
+
{/if}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
url: string;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
4
|
+
* World-space position `[x, y, z]`. Defaults to `[0, 0, height]` so the
|
|
5
|
+
* dome's ground sits flush with the world XY plane in this Z-up scene.
|
|
6
|
+
*/
|
|
7
|
+
position?: [x: number, y: number, z: number];
|
|
8
|
+
/**
|
|
9
|
+
* Euler rotation `[x, y, z]` in radians. Default aligns the
|
|
10
|
+
* equirectangular image's vertical axis (+Y) with this scene's vertical
|
|
11
|
+
* axis (+Z); the Z component then acts as yaw around world +Z.
|
|
7
12
|
*/
|
|
8
13
|
rotation?: [x: number, y: number, z: number];
|
|
14
|
+
/**
|
|
15
|
+
* Camera height above ground when the source photo was taken. Larger
|
|
16
|
+
* values magnify the lower portion of the image.
|
|
17
|
+
*/
|
|
18
|
+
height?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Skybox dome radius. Must exceed the scene camera's reach.
|
|
21
|
+
*/
|
|
22
|
+
radius?: number;
|
|
9
23
|
}
|
|
10
24
|
declare const Skybox: import("svelte").Component<Props, {}, "">;
|
|
11
25
|
type Skybox = ReturnType<typeof Skybox>;
|