@viamrobotics/motion-tools 1.15.6 → 1.15.8
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/dist/buf/common/v1/common_pb.d.ts +38 -0
- package/dist/buf/common/v1/common_pb.js +64 -0
- package/dist/buf/draw/v1/scene_pb.d.ts +6 -2
- package/dist/buf/draw/v1/scene_pb.js +9 -3
- package/dist/components/Entities/Geometry.svelte +1 -1
- package/dist/components/PCD.svelte +4 -1
- package/dist/components/PCD.svelte.d.ts +1 -0
- package/dist/components/Scene.svelte +0 -1
- package/dist/components/SceneProviders.svelte +0 -2
- package/dist/components/Snapshot.svelte +8 -0
- package/dist/components/hover/LinkedHoveredEntity.svelte +6 -12
- package/dist/components/hover/LinkedHoveredEntity.svelte.d.ts +0 -2
- package/dist/components/overlay/RefreshRate.svelte +7 -6
- package/dist/components/overlay/RefreshRate.svelte.d.ts +1 -1
- package/dist/components/overlay/settings/Settings.svelte +16 -8
- package/dist/components/xr/OriginMarker.svelte +44 -83
- package/dist/components/xr/PointDistance.svelte +8 -14
- package/dist/components/xr/XR.svelte +32 -11
- package/dist/components/xr/frame-configure/Controllers.svelte +6 -0
- package/dist/components/xr/{HandCollider.svelte.d.ts → frame-configure/Controllers.svelte.d.ts} +3 -3
- package/dist/components/xr/{Controllers.svelte → teleop/Controllers.svelte} +4 -19
- package/dist/hooks/use3DModels.svelte.js +1 -1
- package/dist/hooks/useControls.svelte.d.ts +1 -0
- package/dist/hooks/useControls.svelte.js +4 -0
- package/dist/hooks/useGeometries.svelte.js +7 -9
- package/dist/hooks/usePointcloudObjects.svelte.js +7 -6
- package/dist/hooks/usePointclouds.svelte.js +7 -6
- package/dist/hooks/usePose.svelte.js +3 -3
- package/dist/hooks/useSettings.svelte.d.ts +17 -3
- package/dist/hooks/useSettings.svelte.js +27 -7
- package/package.json +2 -2
- package/dist/components/xr/Draggable.svelte +0 -102
- package/dist/components/xr/Draggable.svelte.d.ts +0 -11
- package/dist/components/xr/HandCollider.svelte +0 -20
- package/dist/hooks/useMachineSettings.svelte.d.ts +0 -13
- package/dist/hooks/useMachineSettings.svelte.js +0 -58
- /package/dist/components/xr/{Controllers.svelte.d.ts → teleop/Controllers.svelte.d.ts} +0 -0
|
@@ -668,6 +668,44 @@ export declare class DoCommandResponse extends Message<DoCommandResponse> {
|
|
|
668
668
|
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DoCommandResponse;
|
|
669
669
|
static equals(a: DoCommandResponse | PlainMessage<DoCommandResponse> | undefined, b: DoCommandResponse | PlainMessage<DoCommandResponse> | undefined): boolean;
|
|
670
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* GetStatusRequest represents a generic GetStatus input
|
|
673
|
+
*
|
|
674
|
+
* @generated from message viam.common.v1.GetStatusRequest
|
|
675
|
+
*/
|
|
676
|
+
export declare class GetStatusRequest extends Message<GetStatusRequest> {
|
|
677
|
+
/**
|
|
678
|
+
* @generated from field: string name = 1;
|
|
679
|
+
*/
|
|
680
|
+
name: string;
|
|
681
|
+
constructor(data?: PartialMessage<GetStatusRequest>);
|
|
682
|
+
static readonly runtime: typeof proto3;
|
|
683
|
+
static readonly typeName = "viam.common.v1.GetStatusRequest";
|
|
684
|
+
static readonly fields: FieldList;
|
|
685
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetStatusRequest;
|
|
686
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetStatusRequest;
|
|
687
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetStatusRequest;
|
|
688
|
+
static equals(a: GetStatusRequest | PlainMessage<GetStatusRequest> | undefined, b: GetStatusRequest | PlainMessage<GetStatusRequest> | undefined): boolean;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* GetStatusResponse represents a generic GetStatus output
|
|
692
|
+
*
|
|
693
|
+
* @generated from message viam.common.v1.GetStatusResponse
|
|
694
|
+
*/
|
|
695
|
+
export declare class GetStatusResponse extends Message<GetStatusResponse> {
|
|
696
|
+
/**
|
|
697
|
+
* @generated from field: google.protobuf.Struct result = 1;
|
|
698
|
+
*/
|
|
699
|
+
result?: Struct;
|
|
700
|
+
constructor(data?: PartialMessage<GetStatusResponse>);
|
|
701
|
+
static readonly runtime: typeof proto3;
|
|
702
|
+
static readonly typeName = "viam.common.v1.GetStatusResponse";
|
|
703
|
+
static readonly fields: FieldList;
|
|
704
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetStatusResponse;
|
|
705
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetStatusResponse;
|
|
706
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetStatusResponse;
|
|
707
|
+
static equals(a: GetStatusResponse | PlainMessage<GetStatusResponse> | undefined, b: GetStatusResponse | PlainMessage<GetStatusResponse> | undefined): boolean;
|
|
708
|
+
}
|
|
671
709
|
/**
|
|
672
710
|
* @generated from message viam.common.v1.GetKinematicsRequest
|
|
673
711
|
*/
|
|
@@ -968,6 +968,70 @@ export class DoCommandResponse extends Message {
|
|
|
968
968
|
return proto3.util.equals(DoCommandResponse, a, b);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
+
/**
|
|
972
|
+
* GetStatusRequest represents a generic GetStatus input
|
|
973
|
+
*
|
|
974
|
+
* @generated from message viam.common.v1.GetStatusRequest
|
|
975
|
+
*/
|
|
976
|
+
export class GetStatusRequest extends Message {
|
|
977
|
+
/**
|
|
978
|
+
* @generated from field: string name = 1;
|
|
979
|
+
*/
|
|
980
|
+
name = "";
|
|
981
|
+
constructor(data) {
|
|
982
|
+
super();
|
|
983
|
+
proto3.util.initPartial(data, this);
|
|
984
|
+
}
|
|
985
|
+
static runtime = proto3;
|
|
986
|
+
static typeName = "viam.common.v1.GetStatusRequest";
|
|
987
|
+
static fields = proto3.util.newFieldList(() => [
|
|
988
|
+
{ no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
989
|
+
]);
|
|
990
|
+
static fromBinary(bytes, options) {
|
|
991
|
+
return new GetStatusRequest().fromBinary(bytes, options);
|
|
992
|
+
}
|
|
993
|
+
static fromJson(jsonValue, options) {
|
|
994
|
+
return new GetStatusRequest().fromJson(jsonValue, options);
|
|
995
|
+
}
|
|
996
|
+
static fromJsonString(jsonString, options) {
|
|
997
|
+
return new GetStatusRequest().fromJsonString(jsonString, options);
|
|
998
|
+
}
|
|
999
|
+
static equals(a, b) {
|
|
1000
|
+
return proto3.util.equals(GetStatusRequest, a, b);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* GetStatusResponse represents a generic GetStatus output
|
|
1005
|
+
*
|
|
1006
|
+
* @generated from message viam.common.v1.GetStatusResponse
|
|
1007
|
+
*/
|
|
1008
|
+
export class GetStatusResponse extends Message {
|
|
1009
|
+
/**
|
|
1010
|
+
* @generated from field: google.protobuf.Struct result = 1;
|
|
1011
|
+
*/
|
|
1012
|
+
result;
|
|
1013
|
+
constructor(data) {
|
|
1014
|
+
super();
|
|
1015
|
+
proto3.util.initPartial(data, this);
|
|
1016
|
+
}
|
|
1017
|
+
static runtime = proto3;
|
|
1018
|
+
static typeName = "viam.common.v1.GetStatusResponse";
|
|
1019
|
+
static fields = proto3.util.newFieldList(() => [
|
|
1020
|
+
{ no: 1, name: "result", kind: "message", T: Struct },
|
|
1021
|
+
]);
|
|
1022
|
+
static fromBinary(bytes, options) {
|
|
1023
|
+
return new GetStatusResponse().fromBinary(bytes, options);
|
|
1024
|
+
}
|
|
1025
|
+
static fromJson(jsonValue, options) {
|
|
1026
|
+
return new GetStatusResponse().fromJson(jsonValue, options);
|
|
1027
|
+
}
|
|
1028
|
+
static fromJsonString(jsonString, options) {
|
|
1029
|
+
return new GetStatusResponse().fromJsonString(jsonString, options);
|
|
1030
|
+
}
|
|
1031
|
+
static equals(a, b) {
|
|
1032
|
+
return proto3.util.equals(GetStatusResponse, a, b);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
971
1035
|
/**
|
|
972
1036
|
* @generated from message viam.common.v1.GetKinematicsRequest
|
|
973
1037
|
*/
|
|
@@ -52,11 +52,15 @@ export declare enum RenderShapes {
|
|
|
52
52
|
NURBS = 5
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* for orthographic camera props
|
|
56
|
-
*
|
|
57
55
|
* @generated from message draw.v1.OrthographicCamera
|
|
58
56
|
*/
|
|
59
57
|
export declare class OrthographicCamera extends Message<OrthographicCamera> {
|
|
58
|
+
/**
|
|
59
|
+
* for orthographic camera props
|
|
60
|
+
*
|
|
61
|
+
* @generated from field: optional float zoom = 1;
|
|
62
|
+
*/
|
|
63
|
+
zoom?: number;
|
|
60
64
|
constructor(data?: PartialMessage<OrthographicCamera>);
|
|
61
65
|
static readonly runtime: typeof proto3;
|
|
62
66
|
static readonly typeName = "draw.v1.OrthographicCamera";
|
|
@@ -73,18 +73,24 @@ proto3.util.setEnumType(RenderShapes, "draw.v1.RenderShapes", [
|
|
|
73
73
|
{ no: 5, name: "RENDER_SHAPES_NURBS" },
|
|
74
74
|
]);
|
|
75
75
|
/**
|
|
76
|
-
* for orthographic camera props
|
|
77
|
-
*
|
|
78
76
|
* @generated from message draw.v1.OrthographicCamera
|
|
79
77
|
*/
|
|
80
78
|
export class OrthographicCamera extends Message {
|
|
79
|
+
/**
|
|
80
|
+
* for orthographic camera props
|
|
81
|
+
*
|
|
82
|
+
* @generated from field: optional float zoom = 1;
|
|
83
|
+
*/
|
|
84
|
+
zoom;
|
|
81
85
|
constructor(data) {
|
|
82
86
|
super();
|
|
83
87
|
proto3.util.initPartial(data, this);
|
|
84
88
|
}
|
|
85
89
|
static runtime = proto3;
|
|
86
90
|
static typeName = "draw.v1.OrthographicCamera";
|
|
87
|
-
static fields = proto3.util.newFieldList(() => [
|
|
91
|
+
static fields = proto3.util.newFieldList(() => [
|
|
92
|
+
{ no: 1, name: "zoom", kind: "scalar", T: 2 /* ScalarType.FLOAT */, opt: true },
|
|
93
|
+
]);
|
|
88
94
|
static fromBinary(bytes, options) {
|
|
89
95
|
return new OrthographicCamera().fromBinary(bytes, options);
|
|
90
96
|
}
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
data: Uint8Array
|
|
10
10
|
name?: string
|
|
11
11
|
renderOrder?: number
|
|
12
|
+
oncreate?: (positions: Float32Array, colors: Uint8Array | null) => void
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
let { data, name, renderOrder }: Props = $props()
|
|
15
|
+
let { data, name, renderOrder, oncreate }: Props = $props()
|
|
15
16
|
|
|
16
17
|
const world = useWorld()
|
|
17
18
|
|
|
@@ -32,6 +33,8 @@
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
entity = world.spawn(...entityTraits)
|
|
36
|
+
|
|
37
|
+
oncreate?.(positions, colors)
|
|
35
38
|
})
|
|
36
39
|
|
|
37
40
|
return () => {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
import { provideGeometries } from '../hooks/useGeometries.svelte'
|
|
17
17
|
import { provideLinkedEntities } from '../hooks/useLinked.svelte'
|
|
18
18
|
import { provideLogs } from '../hooks/useLogs.svelte'
|
|
19
|
-
import { provideMachineSettings } from '../hooks/useMachineSettings.svelte'
|
|
20
19
|
import { usePartID } from '../hooks/usePartID.svelte'
|
|
21
20
|
import { providePointcloudObjects } from '../hooks/usePointcloudObjects.svelte'
|
|
22
21
|
import { providePointclouds } from '../hooks/usePointclouds.svelte'
|
|
@@ -37,7 +36,6 @@
|
|
|
37
36
|
|
|
38
37
|
provideCameraControls(() => cameraPose)
|
|
39
38
|
provideTransformControls()
|
|
40
|
-
provideMachineSettings()
|
|
41
39
|
provideLogs()
|
|
42
40
|
|
|
43
41
|
provideOrigin()
|
|
@@ -66,6 +66,14 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
|
|
|
66
66
|
position: [x * 0.001, y * 0.001, z * 0.001],
|
|
67
67
|
lookAt: [lx * 0.001, ly * 0.001, lz * 0.001],
|
|
68
68
|
})
|
|
69
|
+
|
|
70
|
+
if (sceneCamera.cameraType.case === 'orthographicCamera') {
|
|
71
|
+
const orthographicCamera = sceneCamera.cameraType.value as { zoom?: number }
|
|
72
|
+
const zoom = orthographicCamera.zoom
|
|
73
|
+
if (zoom !== undefined) {
|
|
74
|
+
cameraControls.setZoom(zoom)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
})
|
|
71
79
|
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
<script
|
|
2
|
-
lang="ts"
|
|
3
|
-
module
|
|
4
|
-
>
|
|
5
|
-
import { Parser } from 'expr-eval'
|
|
6
|
-
|
|
7
|
-
export const parser = new Parser()
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
1
|
<script lang="ts">
|
|
11
2
|
import type { Entity } from 'koota'
|
|
12
3
|
|
|
4
|
+
import { compileExpression } from 'filtrex'
|
|
5
|
+
|
|
13
6
|
import { relations, traits } from '../../ecs'
|
|
14
7
|
import { useTrait } from '../../ecs'
|
|
15
8
|
import { SubEntityLinkType } from '../../ecs/relations'
|
|
@@ -39,11 +32,12 @@
|
|
|
39
32
|
if (linkType !== SubEntityLinkType.HoverLink) {
|
|
40
33
|
return
|
|
41
34
|
}
|
|
42
|
-
// Index
|
|
35
|
+
// Index mapping is a formula with the variable 'index' in it.
|
|
36
|
+
// Supported operations: https://github.com/cshaa/filtrex#expressions
|
|
43
37
|
const indexMapping =
|
|
44
38
|
displayEntity?.get(relations.SubEntityLink(linkedEntity))?.indexMapping ?? 'index'
|
|
45
|
-
const
|
|
46
|
-
const resolvedIndex =
|
|
39
|
+
const evaluate = compileExpression(indexMapping)
|
|
40
|
+
const resolvedIndex = evaluate({ index: displayedHoverInfo.current.index })
|
|
47
41
|
const linkedHoverInfo = getLinkedHoverInfo(resolvedIndex, linkedEntity)
|
|
48
42
|
hoverInfo = linkedHoverInfo
|
|
49
43
|
} else {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
import { IconButton, Select } from '@viamrobotics/prime-core'
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { useSettings } from '../../hooks/useSettings.svelte'
|
|
24
24
|
|
|
25
25
|
interface Props {
|
|
26
|
-
id:
|
|
26
|
+
id: 'poses' | 'pointclouds' | 'vision'
|
|
27
27
|
label: string
|
|
28
28
|
allowLive?: boolean
|
|
29
29
|
onManualRefetch: () => void
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
let { id, label, allowLive = false, onManualRefetch, children }: Props = $props()
|
|
34
34
|
|
|
35
|
-
const
|
|
36
|
-
const
|
|
35
|
+
const settings = useSettings()
|
|
36
|
+
const { refreshRates } = $derived(settings.current)
|
|
37
|
+
const rate = $derived(refreshRates[id] ?? RefetchRates.MANUAL)
|
|
37
38
|
</script>
|
|
38
39
|
|
|
39
40
|
<label class="flex flex-col gap-1">
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
onchange={(event: InputEvent) => {
|
|
49
50
|
if (event.target instanceof HTMLSelectElement) {
|
|
50
51
|
const { value } = event.target
|
|
51
|
-
refreshRates
|
|
52
|
+
refreshRates[id] = Number.parseInt(value, 10)
|
|
52
53
|
}
|
|
53
54
|
}}
|
|
54
55
|
value={String(rate)}
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
variant="secondary"
|
|
88
89
|
cx="border-light border"
|
|
89
90
|
onclick={() => {
|
|
90
|
-
refreshRates
|
|
91
|
+
refreshRates[id] = RefetchRates.MANUAL
|
|
91
92
|
}}
|
|
92
93
|
/>
|
|
93
94
|
{/if}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
import DashboardButton from '../dashboard/Button.svelte'
|
|
10
10
|
import XRControllerSettings from '../../xr/XRControllerSettings.svelte'
|
|
11
11
|
import { useGeometries } from '../../../hooks/useGeometries.svelte'
|
|
12
|
-
import { RefreshRates, useMachineSettings } from '../../../hooks/useMachineSettings.svelte'
|
|
13
12
|
import { usePartID } from '../../../hooks/usePartID.svelte'
|
|
13
|
+
import { usePointcloudObjects } from '../../../hooks/usePointcloudObjects.svelte'
|
|
14
14
|
import { usePointClouds } from '../../../hooks/usePointclouds.svelte'
|
|
15
15
|
import { useRefetchPoses } from '../../../hooks/useRefetchPoses'
|
|
16
|
-
import { useSettings } from '../../../hooks/useSettings.svelte'
|
|
16
|
+
import { RefreshRates, useSettings } from '../../../hooks/useSettings.svelte'
|
|
17
17
|
import { useWeblabs, WEBLABS_EXPERIMENTS } from '../../../hooks/useWeblabs.svelte'
|
|
18
18
|
|
|
19
19
|
import FloatingPanel from '../FloatingPanel.svelte'
|
|
@@ -26,9 +26,10 @@
|
|
|
26
26
|
const cameras = useResourceNames(() => partID.current, 'camera')
|
|
27
27
|
const visionServices = useResourceNames(() => partID.current, 'vision')
|
|
28
28
|
const settings = useSettings()
|
|
29
|
-
const { disabledCameras, disabledVisionServices } =
|
|
29
|
+
const { disabledCameras, disabledVisionServices } = $derived(settings.current)
|
|
30
30
|
const geometries = useGeometries()
|
|
31
31
|
const pointclouds = usePointClouds()
|
|
32
|
+
const pointcloudObjects = usePointcloudObjects()
|
|
32
33
|
const { refetchPoses } = useRefetchPoses()
|
|
33
34
|
const weblabs = useWeblabs()
|
|
34
35
|
const knownWeblabs = Object.keys(WEBLABS_EXPERIMENTS)
|
|
@@ -87,11 +88,18 @@
|
|
|
87
88
|
/>
|
|
88
89
|
<RefreshRate
|
|
89
90
|
id={RefreshRates.pointclouds}
|
|
90
|
-
label="Pointclouds"
|
|
91
|
+
label="Pointclouds from cameras"
|
|
91
92
|
onManualRefetch={() => {
|
|
92
93
|
pointclouds.refetch()
|
|
93
94
|
}}
|
|
94
95
|
/>
|
|
96
|
+
<RefreshRate
|
|
97
|
+
id={RefreshRates.vision}
|
|
98
|
+
label="Vision service pointcloud segments and objects"
|
|
99
|
+
onManualRefetch={() => {
|
|
100
|
+
pointcloudObjects.refetch()
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
95
103
|
</div>
|
|
96
104
|
{/snippet}
|
|
97
105
|
|
|
@@ -126,9 +134,9 @@
|
|
|
126
134
|
<div class="flex items-center justify-between py-0.5 text-xs">
|
|
127
135
|
{camera.name}
|
|
128
136
|
<Switch
|
|
129
|
-
on={disabledCameras
|
|
137
|
+
on={disabledCameras[camera.name] !== true}
|
|
130
138
|
on:change={(event) => {
|
|
131
|
-
disabledCameras
|
|
139
|
+
disabledCameras[camera.name] = !event.detail
|
|
132
140
|
}}
|
|
133
141
|
/>
|
|
134
142
|
</div>
|
|
@@ -146,9 +154,9 @@
|
|
|
146
154
|
<div class="flex items-center justify-between py-0.5">
|
|
147
155
|
{visionService.name}
|
|
148
156
|
<Switch
|
|
149
|
-
on={disabledVisionServices
|
|
157
|
+
on={disabledVisionServices[visionService.name] !== true}
|
|
150
158
|
on:change={(event) => {
|
|
151
|
-
disabledVisionServices
|
|
159
|
+
disabledVisionServices[visionService.name] = !event.detail
|
|
152
160
|
}}
|
|
153
161
|
/>
|
|
154
162
|
</div>
|
|
@@ -1,113 +1,74 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { T, useTask } from '@threlte/core'
|
|
2
|
+
import { T } from '@threlte/core'
|
|
4
3
|
import { Grid, useGamepad } from '@threlte/extras'
|
|
5
|
-
import {
|
|
6
|
-
import { useController } from '@threlte/xr'
|
|
7
|
-
import { Euler, Group, Quaternion, Vector3 } from 'three'
|
|
4
|
+
import { Group, Quaternion, Vector2, Vector3 } from 'three'
|
|
8
5
|
|
|
6
|
+
import { useAnchors } from './useAnchors.svelte'
|
|
9
7
|
import { useOrigin } from './useOrigin.svelte'
|
|
10
8
|
|
|
11
9
|
const origin = useOrigin()
|
|
12
|
-
|
|
13
|
-
const height = 0.1
|
|
14
|
-
const radius = 0.05
|
|
10
|
+
const anchors = useAnchors()
|
|
15
11
|
|
|
16
12
|
const group = new Group()
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const vec3 = new Vector3()
|
|
20
|
-
|
|
21
|
-
const quaternion = new Quaternion()
|
|
22
|
-
const euler = new Euler()
|
|
23
|
-
|
|
24
|
-
const offset = new Vector3()
|
|
25
|
-
|
|
26
|
-
const position = new Vector3()
|
|
27
|
-
|
|
28
|
-
let dragging = $state(false)
|
|
29
|
-
let rotating = $state(false)
|
|
30
|
-
|
|
31
|
-
let currentDistance = 0
|
|
32
|
-
const rotateDown = new Vector3()
|
|
33
|
-
|
|
34
|
-
let rigidBody = $state<RigidBodyType>()
|
|
35
|
-
|
|
36
|
-
const left = useController('left')
|
|
37
|
-
const right = useController('right')
|
|
13
|
+
const anchorObject = new Group()
|
|
38
14
|
|
|
39
15
|
const leftPad = useGamepad({ xr: true, hand: 'left' })
|
|
16
|
+
const rightPad = useGamepad({ xr: true, hand: 'right' })
|
|
40
17
|
|
|
41
|
-
|
|
42
|
-
const grip = $left?.grip
|
|
18
|
+
const speed = 0.05
|
|
43
19
|
|
|
44
|
-
|
|
20
|
+
const vec2 = new Vector2()
|
|
21
|
+
const target = new Vector2()
|
|
22
|
+
|
|
23
|
+
leftPad.thumbstick.on('change', ({ value }) => {
|
|
24
|
+
if (typeof value === 'number') {
|
|
45
25
|
return
|
|
46
26
|
}
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})
|
|
52
|
-
leftPad.trigger.on('up', () => (dragging = false))
|
|
28
|
+
const { x: vx, y: vy } = value
|
|
29
|
+
const [x, y, z] = origin.position
|
|
30
|
+
const r = origin.rotation
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!$left || !rigidBody) return
|
|
32
|
+
origin.set([x, y, z + vy * speed], r + vx * speed)
|
|
33
|
+
})
|
|
57
34
|
|
|
58
|
-
|
|
35
|
+
rightPad.thumbstick.on('change', ({ value }) => {
|
|
36
|
+
if (typeof value === 'number') {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
59
39
|
|
|
60
|
-
|
|
40
|
+
const { x: vx, y: vy } = value
|
|
41
|
+
const [x, y, z] = origin.position
|
|
42
|
+
const r = origin.rotation
|
|
61
43
|
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
running: () => dragging,
|
|
66
|
-
}
|
|
67
|
-
)
|
|
44
|
+
vec2.set(x, y).lerp(target.set(x + vx * speed, y + vy * speed), 0.5)
|
|
68
45
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!$right || !rigidBody) return
|
|
46
|
+
origin.set([vec2.x, vec2.y, z], r)
|
|
47
|
+
})
|
|
72
48
|
|
|
73
|
-
|
|
49
|
+
const vec3 = new Vector3()
|
|
50
|
+
const quaternion = new Quaternion()
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
euler.setFromQuaternion(quaternion)
|
|
78
|
-
euler.z = distance + currentDistance
|
|
79
|
-
origin.set(undefined, euler.z)
|
|
52
|
+
$effect(() => {
|
|
53
|
+
vec3.fromArray(origin.position)
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)
|
|
55
|
+
anchors.createAnchor(vec3, quaternion)?.then((anchor) => {
|
|
56
|
+
anchors.bindAnchorObject(anchor, anchorObject)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
85
59
|
</script>
|
|
86
60
|
|
|
87
61
|
<T
|
|
88
62
|
is={group}
|
|
89
63
|
position={[0, 0.05, 0]}
|
|
90
64
|
>
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<T is={innerGroup}>
|
|
101
|
-
<Grid
|
|
102
|
-
plane="xy"
|
|
103
|
-
position.y={0.05}
|
|
104
|
-
fadeDistance={5}
|
|
105
|
-
fadeOrigin={new Vector3()}
|
|
106
|
-
cellSize={0.1}
|
|
107
|
-
cellColor="#fff"
|
|
108
|
-
sectionColor="#fff"
|
|
109
|
-
/>
|
|
110
|
-
</T>
|
|
111
|
-
</Collider>
|
|
112
|
-
</RigidBody>
|
|
65
|
+
<Grid
|
|
66
|
+
plane="xy"
|
|
67
|
+
position.y={0.05}
|
|
68
|
+
fadeDistance={5}
|
|
69
|
+
fadeOrigin={new Vector3()}
|
|
70
|
+
cellSize={0.1}
|
|
71
|
+
cellColor="#fff"
|
|
72
|
+
sectionColor="#fff"
|
|
73
|
+
/>
|
|
113
74
|
</T>
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import { Billboard, Text } from '@threlte/extras'
|
|
4
4
|
import { Mesh, Vector3 } from 'three'
|
|
5
5
|
|
|
6
|
-
import Draggable from './Draggable.svelte'
|
|
7
|
-
|
|
8
6
|
const mesh1 = new Mesh()
|
|
9
7
|
const mesh2 = new Mesh()
|
|
10
8
|
const distance = new Vector3()
|
|
@@ -29,12 +27,10 @@
|
|
|
29
27
|
</script>
|
|
30
28
|
|
|
31
29
|
<T.Group position={[-1, 1, 0]}>
|
|
32
|
-
<
|
|
33
|
-
<T
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</T>
|
|
37
|
-
</Draggable>
|
|
30
|
+
<T is={mesh1}>
|
|
31
|
+
<T.SphereGeometry args={[0.05]} />
|
|
32
|
+
<T.MeshStandardMaterial />
|
|
33
|
+
</T>
|
|
38
34
|
</T.Group>
|
|
39
35
|
|
|
40
36
|
<T.Group position={textPosition}>
|
|
@@ -44,10 +40,8 @@
|
|
|
44
40
|
</T.Group>
|
|
45
41
|
|
|
46
42
|
<T.Group position={[-1.5, 1, 0]}>
|
|
47
|
-
<
|
|
48
|
-
<T
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</T>
|
|
52
|
-
</Draggable>
|
|
43
|
+
<T is={mesh2}>
|
|
44
|
+
<T.SphereGeometry args={[0.05]} />
|
|
45
|
+
<T.MeshStandardMaterial />
|
|
46
|
+
</T>
|
|
53
47
|
</T.Group>
|