@threlte/xr 1.0.0-next.15 → 1.0.0-next.16
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,31 +1,73 @@
|
|
|
1
|
-
import { injectPlugin, isInstanceOf
|
|
1
|
+
import { injectPlugin, isInstanceOf } from '@threlte/core';
|
|
2
2
|
import { useTeleportControls } from './context';
|
|
3
3
|
/**
|
|
4
4
|
* Registers T components with "teleportSurface" or "teleportBlocker" attributes.
|
|
5
5
|
*/
|
|
6
6
|
export const injectTeleportControlsPlugin = () => {
|
|
7
|
-
injectPlugin('threlte-teleport-controls', (args) => {
|
|
7
|
+
injectPlugin('threlte-teleport-controls-surfaces', (args) => {
|
|
8
8
|
if (!isInstanceOf(args.ref, 'Mesh'))
|
|
9
9
|
return;
|
|
10
|
-
|
|
11
|
-
const isBlocker = $derived('teleportBlocker' in args.props && !!args.props.teleportBlocker);
|
|
12
|
-
const surfaceRef = $derived(isSurface ? args.ref : undefined);
|
|
13
|
-
const blockerRef = $derived(isBlocker ? args.ref : undefined);
|
|
14
|
-
if (!isSurface && !isBlocker)
|
|
10
|
+
if (!('teleportSurface' in args.props))
|
|
15
11
|
return;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
let ref = $state(args.ref);
|
|
13
|
+
let isSurface = $state(args.props.teleportSurface);
|
|
14
|
+
const { addSurface, removeSurface } = useTeleportControls();
|
|
15
|
+
$effect(() => {
|
|
16
|
+
if (!ref)
|
|
17
|
+
return;
|
|
18
|
+
let mesh = ref;
|
|
19
|
+
if (isSurface) {
|
|
20
|
+
addSurface(mesh, args.props);
|
|
21
21
|
}
|
|
22
|
-
else
|
|
23
|
-
|
|
24
|
-
return removeBlocker(blockerRef);
|
|
22
|
+
else {
|
|
23
|
+
removeSurface(mesh);
|
|
25
24
|
}
|
|
25
|
+
return () => removeSurface(mesh);
|
|
26
26
|
});
|
|
27
27
|
return {
|
|
28
|
-
pluginProps: ['teleportSurface',
|
|
28
|
+
pluginProps: ['teleportSurface'],
|
|
29
|
+
onRefChange: (nextRef) => {
|
|
30
|
+
ref = nextRef;
|
|
31
|
+
return () => {
|
|
32
|
+
ref = undefined;
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
onPropsChange: (props) => {
|
|
36
|
+
isSurface = props.teleportSurface;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
injectPlugin('threlte-teleport-controls-blockers', (args) => {
|
|
41
|
+
if (!isInstanceOf(args.ref, 'Mesh'))
|
|
42
|
+
return;
|
|
43
|
+
if (!('teleportBlocker' in args.props))
|
|
44
|
+
return;
|
|
45
|
+
let ref = $state(args.ref);
|
|
46
|
+
let isBlocker = $state(args.props.teleportBlocker);
|
|
47
|
+
const { addBlocker, removeBlocker } = useTeleportControls();
|
|
48
|
+
$effect(() => {
|
|
49
|
+
if (!ref)
|
|
50
|
+
return;
|
|
51
|
+
let mesh = ref;
|
|
52
|
+
if (isBlocker) {
|
|
53
|
+
addBlocker(mesh);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
removeBlocker(mesh);
|
|
57
|
+
}
|
|
58
|
+
return () => removeBlocker(mesh);
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
pluginProps: ['teleportBlocker'],
|
|
62
|
+
onRefChange: (nextRef) => {
|
|
63
|
+
ref = nextRef;
|
|
64
|
+
return () => {
|
|
65
|
+
ref = undefined;
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
onPropsChange: (props) => {
|
|
69
|
+
isBlocker = props.teleportBlocker;
|
|
70
|
+
}
|
|
29
71
|
};
|
|
30
72
|
});
|
|
31
73
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/xr",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.16",
|
|
4
4
|
"author": "Micheal Parks <michealparks1989@gmail.com> (https://parks.lol)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Tools to more easily create VR and AR experiences with Threlte",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"typescript": "^5.6.3",
|
|
25
25
|
"vite": "^5.2.8",
|
|
26
26
|
"vite-plugin-mkcert": "^1.17.5",
|
|
27
|
-
"@threlte/core": "8.0.0-next.
|
|
27
|
+
"@threlte/core": "8.0.0-next.39"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"svelte": ">=5",
|