@viamrobotics/motion-tools 1.31.0 → 1.33.0
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/components/App.svelte +64 -53
- package/dist/components/App.svelte.d.ts +14 -7
- package/dist/components/Entities/Arrows/Arrows.svelte +4 -7
- package/dist/components/Entities/hooks/useEntityEvents.svelte.d.ts +0 -1
- package/dist/components/Entities/hooks/useEntityEvents.svelte.js +30 -16
- package/dist/components/InputBindings.svelte +0 -43
- package/dist/components/KeyboardBindings.svelte +38 -0
- package/dist/components/KeyboardBindings.svelte.d.ts +18 -0
- package/dist/components/PointerMissBox.svelte +6 -3
- package/dist/components/Scene.svelte +43 -61
- package/dist/components/SceneProviders.svelte +2 -7
- package/dist/components/SceneProviders.svelte.d.ts +1 -3
- package/dist/components/Selected.svelte +20 -27
- package/dist/components/SelectedTransformControls.svelte +8 -7
- package/dist/components/StaticGeometries.svelte +3 -5
- package/dist/components/hover/HoveredEntities.svelte +15 -14
- package/dist/components/hover/HoveredEntities.svelte.d.ts +17 -2
- package/dist/components/hover/HoveredEntity.svelte +8 -5
- package/dist/components/hover/HoveredEntity.svelte.d.ts +5 -1
- package/dist/components/hover/LinkedHoveredEntity.svelte +7 -11
- package/dist/components/hover/LinkedHoveredEntity.svelte.d.ts +1 -0
- package/dist/components/overlay/Details.svelte +22 -37
- package/dist/components/overlay/Details.svelte.d.ts +3 -1
- package/dist/components/overlay/controls/Controls.svelte +0 -2
- package/dist/components/overlay/dashboard/Button.svelte +5 -3
- package/dist/components/overlay/dashboard/Button.svelte.d.ts +1 -1
- package/dist/components/overlay/left-pane/Tree.svelte +13 -10
- package/dist/components/overlay/left-pane/TreeContainer.svelte +9 -4
- package/dist/components/overlay/left-pane/TreeNode.svelte +6 -4
- package/dist/components/overlay/settings/ConnectionSettings.svelte +42 -0
- package/dist/components/overlay/settings/ConnectionSettings.svelte.d.ts +18 -0
- package/dist/components/overlay/settings/DebugSettings.svelte +13 -0
- package/dist/components/{xr/frame-configure/Controllers.svelte.d.ts → overlay/settings/DebugSettings.svelte.d.ts} +3 -3
- package/dist/components/overlay/settings/PointcloudSettings.svelte +61 -0
- package/dist/components/overlay/settings/PointcloudSettings.svelte.d.ts +3 -0
- package/dist/components/overlay/settings/SceneSettings.svelte +110 -0
- package/dist/components/overlay/settings/SceneSettings.svelte.d.ts +18 -0
- package/dist/components/overlay/settings/Settings.svelte +27 -312
- package/dist/components/overlay/settings/Settings.svelte.d.ts +8 -1
- package/dist/components/overlay/settings/Tabs.svelte +5 -3
- package/dist/components/overlay/settings/Tabs.svelte.d.ts +3 -3
- package/dist/components/overlay/settings/VisionSettings.svelte +31 -0
- package/dist/components/overlay/settings/VisionSettings.svelte.d.ts +3 -0
- package/dist/components/overlay/settings/WeblabSettings.svelte +27 -0
- package/dist/components/overlay/settings/WeblabSettings.svelte.d.ts +18 -0
- package/dist/components/overlay/settings/WidgetSettings.svelte +49 -0
- package/dist/components/overlay/settings/WidgetSettings.svelte.d.ts +3 -0
- package/dist/components/overlay/widgets/FramePov.svelte +1 -12
- package/dist/draw.d.ts +1 -0
- package/dist/draw.js +1 -1
- package/dist/ecs/index.d.ts +1 -0
- package/dist/ecs/index.js +1 -0
- package/dist/ecs/traits.d.ts +22 -5
- package/dist/ecs/traits.js +33 -4
- package/dist/ecs/useTag.svelte.d.ts +5 -0
- package/dist/ecs/useTag.svelte.js +43 -0
- package/dist/hooks/useEnvironment.svelte.d.ts +1 -1
- package/dist/hooks/useLinked.svelte.js +7 -8
- package/dist/hooks/useMouseRaycaster.svelte.d.ts +4 -3
- package/dist/hooks/useMouseRaycaster.svelte.js +1 -0
- package/dist/hooks/useSettings.svelte.d.ts +1 -1
- package/dist/plugins/Focus/Focus.svelte +45 -0
- package/dist/plugins/Focus/Focus.svelte.d.ts +3 -0
- package/dist/plugins/Focus/FocusBox.svelte +75 -0
- package/dist/plugins/Focus/FocusBox.svelte.d.ts +3 -0
- package/dist/plugins/Focus/provideFocus.svelte.d.ts +1 -0
- package/dist/plugins/Focus/provideFocus.svelte.js +61 -0
- package/dist/{components → plugins}/MeasureTool/MeasureTool.svelte +6 -8
- package/dist/plugins/Selection/SelectionTool.svelte +10 -3
- package/dist/{components/xr → plugins/XR}/ArmTeleop.svelte +3 -5
- package/dist/plugins/XR/DebugPanel.svelte +29 -0
- package/dist/plugins/XR/DebugPanel.svelte.d.ts +3 -0
- package/dist/plugins/XR/OriginMarker.svelte +341 -0
- package/dist/plugins/XR/PendingEditsPanel.svelte +60 -0
- package/dist/plugins/XR/PendingEditsPanel.svelte.d.ts +18 -0
- package/dist/plugins/XR/WristDisplay.svelte +60 -0
- package/dist/plugins/XR/WristDisplay.svelte.d.ts +19 -0
- package/dist/{components/xr → plugins/XR}/XR.svelte +69 -23
- package/dist/plugins/XR/XRPlugins.svelte +9 -0
- package/dist/plugins/XR/XRPlugins.svelte.d.ts +26 -0
- package/dist/plugins/XR/XRSettings.svelte +240 -0
- package/dist/plugins/XR/XRSettings.svelte.d.ts +3 -0
- package/dist/{components/xr → plugins/XR}/XRToast.svelte +6 -9
- package/dist/plugins/XR/debug.svelte.d.ts +7 -0
- package/dist/plugins/XR/debug.svelte.js +13 -0
- package/dist/plugins/XR/frame-configure/Controllers.svelte +413 -0
- package/dist/plugins/XR/teleop/Controllers.svelte.d.ts +3 -0
- package/dist/{components/xr → plugins/XR}/useAnchors.svelte.d.ts +4 -0
- package/dist/{components/xr → plugins/XR}/useAnchors.svelte.js +22 -0
- package/dist/plugins/XR/useOrigin.svelte.d.ts +24 -0
- package/dist/plugins/XR/useOrigin.svelte.js +50 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +4 -0
- package/dist/three/OBBHelper.js +1 -0
- package/dist/three/arrow.d.ts +2 -0
- package/dist/three/arrow.js +3 -1
- package/package.json +16 -4
- package/dist/components/Focus.svelte +0 -46
- package/dist/components/Focus.svelte.d.ts +0 -7
- package/dist/components/xr/OriginMarker.svelte +0 -151
- package/dist/components/xr/XRControllerSettings.svelte +0 -242
- package/dist/components/xr/XRControllerSettings.svelte.d.ts +0 -3
- package/dist/components/xr/frame-configure/Controllers.svelte +0 -6
- package/dist/components/xr/useOrigin.svelte.d.ts +0 -9
- package/dist/components/xr/useOrigin.svelte.js +0 -27
- package/dist/hooks/useSelection.svelte.d.ts +0 -33
- package/dist/hooks/useSelection.svelte.js +0 -94
- /package/dist/{components → plugins}/MeasureTool/MeasurePoint.svelte +0 -0
- /package/dist/{components → plugins}/MeasureTool/MeasurePoint.svelte.d.ts +0 -0
- /package/dist/{components → plugins}/MeasureTool/MeasureTool.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/ArmTeleop.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/BentPlaneGeometry.svelte +0 -0
- /package/dist/{components/xr → plugins/XR}/BentPlaneGeometry.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/CameraFeed.svelte +0 -0
- /package/dist/{components/xr → plugins/XR}/CameraFeed.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/JointLimitsWidget.svelte +0 -0
- /package/dist/{components/xr → plugins/XR}/JointLimitsWidget.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/OriginMarker.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/PointDistance.svelte +0 -0
- /package/dist/{components/xr → plugins/XR}/PointDistance.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/XR.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/XRConfigPanel.svelte +0 -0
- /package/dist/{components/xr → plugins/XR}/XRConfigPanel.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/XRToast.svelte.d.ts +0 -0
- /package/dist/{components/xr/teleop → plugins/XR/frame-configure}/Controllers.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/math.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/math.js +0 -0
- /package/dist/{components/xr → plugins/XR}/teleop/Controllers.svelte +0 -0
- /package/dist/{components/xr → plugins/XR}/toasts.svelte.d.ts +0 -0
- /package/dist/{components/xr → plugins/XR}/toasts.svelte.js +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Struct } from '@viamrobotics/sdk'
|
|
3
3
|
import type { Entity } from 'koota'
|
|
4
|
-
import type { Snippet } from 'svelte'
|
|
5
4
|
|
|
6
5
|
import { Canvas } from '@threlte/core'
|
|
7
6
|
import { PortalTarget } from '@threlte/extras'
|
|
8
7
|
import { useXR } from '@threlte/xr'
|
|
9
8
|
import { provideToast, ToastContainer } from '@viamrobotics/prime-core'
|
|
10
9
|
import { primeTheme } from '@viamrobotics/tweakpane-config'
|
|
10
|
+
import { type Component, onMount, type Snippet } from 'svelte'
|
|
11
11
|
import { ThemeUtils } from 'svelte-tweakpane-ui'
|
|
12
12
|
|
|
13
13
|
import type { FragmentInfo } from '../hooks/usePartConfig.svelte'
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
import Details from './overlay/Details.svelte'
|
|
18
18
|
import TreeContainer from './overlay/left-pane/TreeContainer.svelte'
|
|
19
19
|
import Settings from './overlay/settings/Settings.svelte'
|
|
20
|
-
import
|
|
21
|
-
import { provideWorld } from '../ecs'
|
|
20
|
+
import { provideWorld, traits, useQuery } from '../ecs'
|
|
22
21
|
import { type CameraPose, provideCameraControls } from '../hooks/useControls.svelte'
|
|
23
22
|
import { provideEnvironment } from '../hooks/useEnvironment.svelte'
|
|
24
23
|
import { providePartConfig } from '../hooks/usePartConfig.svelte'
|
|
@@ -51,7 +50,20 @@
|
|
|
51
50
|
localConfigProps?: LocalConfigProps
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
53
|
+
* Allows adding additional tabs to the settings panel
|
|
54
|
+
*/
|
|
55
|
+
settingsTabs?: {
|
|
56
|
+
label: string
|
|
57
|
+
component: Component
|
|
58
|
+
}[]
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Allows setting the initial camera pose
|
|
62
|
+
*/
|
|
63
|
+
cameraPose?: CameraPose
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Snippet for Three.js objects
|
|
55
67
|
*/
|
|
56
68
|
children?: Snippet
|
|
57
69
|
|
|
@@ -64,11 +76,6 @@
|
|
|
64
76
|
* Snippet to inject items into the details panel
|
|
65
77
|
*/
|
|
66
78
|
details?: Snippet<[{ entity: Entity }]>
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Allows setting the initial camera pose
|
|
70
|
-
*/
|
|
71
|
-
cameraPose?: CameraPose
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
let {
|
|
@@ -76,6 +83,7 @@
|
|
|
76
83
|
inputBindingsEnabled = true,
|
|
77
84
|
localConfigProps,
|
|
78
85
|
cameraPose,
|
|
86
|
+
settingsTabs,
|
|
79
87
|
children: appChildren,
|
|
80
88
|
dashboard,
|
|
81
89
|
details,
|
|
@@ -107,9 +115,11 @@
|
|
|
107
115
|
environment.current.isStandalone = !localConfigProps
|
|
108
116
|
})
|
|
109
117
|
|
|
110
|
-
|
|
118
|
+
onMount(() => {
|
|
111
119
|
ThemeUtils.setGlobalDefaultTheme(primeTheme)
|
|
112
120
|
})
|
|
121
|
+
|
|
122
|
+
const selected = useQuery(traits.Selected)
|
|
113
123
|
</script>
|
|
114
124
|
|
|
115
125
|
<div
|
|
@@ -118,53 +128,54 @@
|
|
|
118
128
|
>
|
|
119
129
|
<Canvas renderMode="on-demand">
|
|
120
130
|
<SceneProviders>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
<Scene>
|
|
132
|
+
{@render appChildren?.()}
|
|
133
|
+
</Scene>
|
|
134
|
+
|
|
135
|
+
{#if settings.current.renderSubEntityHoverDetail}
|
|
136
|
+
<HoveredEntities />
|
|
137
|
+
{/if}
|
|
138
|
+
|
|
139
|
+
<!-- Overlays that need Threlte context -->
|
|
140
|
+
<div {@attach domPortal(root)}>
|
|
141
|
+
<FileDrop />
|
|
142
|
+
<Dashboard {dashboard} />
|
|
143
|
+
<Controls />
|
|
144
|
+
|
|
145
|
+
{#each selected.current as entity, index (entity)}
|
|
146
|
+
<Details
|
|
147
|
+
{entity}
|
|
148
|
+
{details}
|
|
149
|
+
style="transform: translate(0, {index * 40}px)"
|
|
150
|
+
/>
|
|
151
|
+
{/each}
|
|
152
|
+
|
|
153
|
+
{#if environment.current.isStandalone}
|
|
154
|
+
<LiveUpdatesBanner />
|
|
155
|
+
{/if}
|
|
125
156
|
|
|
126
|
-
<
|
|
157
|
+
<TreeContainer />
|
|
127
158
|
|
|
128
|
-
{#if settings.current.
|
|
129
|
-
<
|
|
159
|
+
{#if settings.current.enableArmPositionsWidget}
|
|
160
|
+
<ArmPositions />
|
|
130
161
|
{/if}
|
|
131
162
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<ArmPositions />
|
|
149
|
-
{/if}
|
|
150
|
-
|
|
151
|
-
{#if !focus && !$isPresenting}
|
|
152
|
-
{#each currentRobotCameraWidgets as cameraName (cameraName)}
|
|
153
|
-
<Camera name={cameraName} />
|
|
154
|
-
{/each}
|
|
155
|
-
|
|
156
|
-
{#each currentFramePovWidgets as povFrameName (povFrameName)}
|
|
157
|
-
<FramePov frameName={povFrameName} />
|
|
158
|
-
{/each}
|
|
159
|
-
{/if}
|
|
160
|
-
|
|
161
|
-
<PortalTarget id="dom" />
|
|
162
|
-
|
|
163
|
-
<Settings />
|
|
164
|
-
<Logs />
|
|
165
|
-
<AddFrames />
|
|
166
|
-
</div>
|
|
167
|
-
{/snippet}
|
|
163
|
+
{#if !$isPresenting}
|
|
164
|
+
{#each currentRobotCameraWidgets as cameraName (cameraName)}
|
|
165
|
+
<Camera name={cameraName} />
|
|
166
|
+
{/each}
|
|
167
|
+
|
|
168
|
+
{#each currentFramePovWidgets as povFrameName (povFrameName)}
|
|
169
|
+
<FramePov frameName={povFrameName} />
|
|
170
|
+
{/each}
|
|
171
|
+
{/if}
|
|
172
|
+
|
|
173
|
+
<PortalTarget id="dom" />
|
|
174
|
+
|
|
175
|
+
<Settings {settingsTabs} />
|
|
176
|
+
<Logs />
|
|
177
|
+
<AddFrames />
|
|
178
|
+
</div>
|
|
168
179
|
</SceneProviders>
|
|
169
180
|
</Canvas>
|
|
170
181
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Struct } from '@viamrobotics/sdk';
|
|
2
2
|
import type { Entity } from 'koota';
|
|
3
|
-
import type
|
|
3
|
+
import { type Component, type Snippet } from 'svelte';
|
|
4
4
|
import type { FragmentInfo } from '../hooks/usePartConfig.svelte';
|
|
5
5
|
import { type CameraPose } from '../hooks/useControls.svelte';
|
|
6
6
|
interface LocalConfigProps {
|
|
@@ -14,7 +14,18 @@ interface Props {
|
|
|
14
14
|
inputBindingsEnabled?: boolean;
|
|
15
15
|
localConfigProps?: LocalConfigProps;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Allows adding additional tabs to the settings panel
|
|
18
|
+
*/
|
|
19
|
+
settingsTabs?: {
|
|
20
|
+
label: string;
|
|
21
|
+
component: Component;
|
|
22
|
+
}[];
|
|
23
|
+
/**
|
|
24
|
+
* Allows setting the initial camera pose
|
|
25
|
+
*/
|
|
26
|
+
cameraPose?: CameraPose;
|
|
27
|
+
/**
|
|
28
|
+
* Snippet for Three.js objects
|
|
18
29
|
*/
|
|
19
30
|
children?: Snippet;
|
|
20
31
|
/**
|
|
@@ -27,11 +38,7 @@ interface Props {
|
|
|
27
38
|
details?: Snippet<[{
|
|
28
39
|
entity: Entity;
|
|
29
40
|
}]>;
|
|
30
|
-
/**
|
|
31
|
-
* Allows setting the initial camera pose
|
|
32
|
-
*/
|
|
33
|
-
cameraPose?: CameraPose;
|
|
34
41
|
}
|
|
35
|
-
declare const App:
|
|
42
|
+
declare const App: Component<Props, {}, "">;
|
|
36
43
|
type App = ReturnType<typeof App>;
|
|
37
44
|
export default App;
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import AxesHelper from '../../AxesHelper.svelte'
|
|
9
9
|
import { useEntityEvents } from '../hooks/useEntityEvents.svelte'
|
|
10
|
-
import { traits, useTrait } from '../../../ecs'
|
|
11
|
-
import { useFocusedEntity, useSelectedEntity } from '../../../hooks/useSelection.svelte'
|
|
10
|
+
import { traits, useTag, useTrait } from '../../../ecs'
|
|
12
11
|
import { meshBoundsRaycast, raycast } from '../../../three/InstancedArrows/raycast'
|
|
13
12
|
|
|
14
13
|
interface Props {
|
|
@@ -20,19 +19,17 @@
|
|
|
20
19
|
|
|
21
20
|
const { invalidate } = useThrelte()
|
|
22
21
|
const worldMatrix = useTrait(() => entity, traits.WorldMatrix)
|
|
22
|
+
const selected = useTag(() => entity, traits.Selected)
|
|
23
23
|
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
24
24
|
const showAxesHelper = useTrait(() => entity, traits.ShowAxesHelper)
|
|
25
25
|
|
|
26
26
|
const events = useEntityEvents(() => entity)
|
|
27
|
-
const selectedEntity = useSelectedEntity()
|
|
28
|
-
const focusedEntity = useFocusedEntity()
|
|
29
|
-
|
|
30
|
-
const displayEntity = $derived(selectedEntity.current ?? focusedEntity.current)
|
|
31
27
|
|
|
32
28
|
const raycastFunction = $derived.by(() => {
|
|
33
|
-
if (
|
|
29
|
+
if (selected.current) {
|
|
34
30
|
return raycast
|
|
35
31
|
}
|
|
32
|
+
|
|
36
33
|
return meshBoundsRaycast
|
|
37
34
|
})
|
|
38
35
|
|
|
@@ -4,7 +4,6 @@ export declare const useEntityEvents: (entity: () => Entity | undefined) => {
|
|
|
4
4
|
onpointerenter: (event: IntersectionEvent<MouseEvent>) => void;
|
|
5
5
|
onpointermove: (event: IntersectionEvent<MouseEvent>) => void;
|
|
6
6
|
onpointerleave: (event: IntersectionEvent<MouseEvent>) => void;
|
|
7
|
-
ondblclick: (event: IntersectionEvent<MouseEvent>) => void;
|
|
8
7
|
onpointerdown: (event: IntersectionEvent<MouseEvent>) => void;
|
|
9
8
|
onclick: (event: IntersectionEvent<MouseEvent>) => void;
|
|
10
9
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCursor } from '@threlte/extras';
|
|
2
2
|
import { MathUtils, Matrix4, Quaternion, Vector2 } from 'three';
|
|
3
|
-
import { traits, useTrait } from '../../../ecs';
|
|
4
|
-
import { useFocusedEntity, useSelectedEntity } from '../../../hooks/useSelection.svelte';
|
|
3
|
+
import { traits, useTrait, useWorld } from '../../../ecs';
|
|
5
4
|
import { updateHoverInfo } from '../../../HoverUpdater.svelte';
|
|
6
5
|
import { OrientationVector } from '../../../three/OrientationVector';
|
|
7
6
|
const tempHoverMatrix = new Matrix4();
|
|
@@ -15,8 +14,7 @@ const infoToLocalMatrix = (info, out) => {
|
|
|
15
14
|
};
|
|
16
15
|
export const useEntityEvents = (entity) => {
|
|
17
16
|
const down = new Vector2();
|
|
18
|
-
const
|
|
19
|
-
const focusedEntity = useFocusedEntity();
|
|
17
|
+
const world = useWorld();
|
|
20
18
|
const cursor = useCursor();
|
|
21
19
|
const invisible = useTrait(entity, traits.InheritedInvisible);
|
|
22
20
|
const onpointerenter = (event) => {
|
|
@@ -80,25 +78,42 @@ export const useEntityEvents = (entity) => {
|
|
|
80
78
|
currentEntity.remove(traits.InstancedMatrix);
|
|
81
79
|
}
|
|
82
80
|
};
|
|
83
|
-
const ondblclick = (event) => {
|
|
84
|
-
if (invisible.current)
|
|
85
|
-
return;
|
|
86
|
-
event.stopPropagation();
|
|
87
|
-
const currentEntity = entity();
|
|
88
|
-
focusedEntity.set(currentEntity, event.instanceId ?? event.batchId);
|
|
89
|
-
};
|
|
90
81
|
const onpointerdown = (event) => {
|
|
91
82
|
if (invisible.current)
|
|
92
83
|
return;
|
|
93
84
|
down.copy(event.pointer);
|
|
94
85
|
};
|
|
95
86
|
const onclick = (event) => {
|
|
96
|
-
if (invisible.current)
|
|
87
|
+
if (invisible.current) {
|
|
97
88
|
return;
|
|
89
|
+
}
|
|
98
90
|
event.stopPropagation();
|
|
99
|
-
if (down.distanceToSquared(event.pointer)
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
if (down.distanceToSquared(event.pointer) >= 0.1) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const currentEntity = entity();
|
|
95
|
+
if (!currentEntity)
|
|
96
|
+
return;
|
|
97
|
+
if (event.nativeEvent.shiftKey) {
|
|
98
|
+
if (currentEntity.has(traits.Selected)) {
|
|
99
|
+
currentEntity.remove(traits.Selected);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
currentEntity.add(traits.Selected);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
for (const entity of world.query(traits.Selected)) {
|
|
107
|
+
if (entity !== currentEntity) {
|
|
108
|
+
entity.remove(traits.Selected);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!currentEntity.has(traits.Selected)) {
|
|
112
|
+
currentEntity.add(traits.Selected);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (event.instanceId || event.batchId) {
|
|
116
|
+
currentEntity.add(traits.InstanceId(event.instanceId ?? event.batchId));
|
|
102
117
|
}
|
|
103
118
|
};
|
|
104
119
|
$effect(() => {
|
|
@@ -117,7 +132,6 @@ export const useEntityEvents = (entity) => {
|
|
|
117
132
|
onpointerenter,
|
|
118
133
|
onpointermove,
|
|
119
134
|
onpointerleave,
|
|
120
|
-
ondblclick,
|
|
121
135
|
onpointerdown,
|
|
122
136
|
onclick,
|
|
123
137
|
};
|
|
@@ -3,26 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import { isInstanceOf, useTask } from '@threlte/core'
|
|
5
5
|
import { useGamepad, useInputMap, useKeyboard } from '@threlte/extras'
|
|
6
|
-
import { PressedKeys } from 'runed'
|
|
7
6
|
import { MathUtils, Vector3 } from 'three'
|
|
8
7
|
|
|
9
|
-
import { traits } from '../ecs'
|
|
10
|
-
import { useFocusedEntity, useSelectedEntity } from '../hooks/useSelection.svelte'
|
|
11
|
-
import { useSettings } from '../hooks/useSettings.svelte'
|
|
12
|
-
|
|
13
8
|
interface Props {
|
|
14
9
|
cameraControls: CameraControlsRef
|
|
15
10
|
}
|
|
16
11
|
|
|
17
12
|
let { cameraControls }: Props = $props()
|
|
18
13
|
|
|
19
|
-
const focusedEntity = useFocusedEntity()
|
|
20
|
-
const selectedEntity = useSelectedEntity()
|
|
21
|
-
|
|
22
|
-
const entity = $derived(focusedEntity.current ?? selectedEntity.current)
|
|
23
|
-
|
|
24
|
-
const settings = useSettings()
|
|
25
|
-
|
|
26
14
|
const keyboard = useKeyboard()
|
|
27
15
|
const gamepad = useGamepad()
|
|
28
16
|
const input = useInputMap(
|
|
@@ -125,35 +113,4 @@
|
|
|
125
113
|
autoInvalidate: false,
|
|
126
114
|
}
|
|
127
115
|
)
|
|
128
|
-
|
|
129
|
-
const keys = new PressedKeys()
|
|
130
|
-
|
|
131
|
-
keys.onKeys('escape', () => {
|
|
132
|
-
focusedEntity.set()
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
keys.onKeys('c', () => {
|
|
136
|
-
settings.current.cameraMode =
|
|
137
|
-
settings.current.cameraMode === 'perspective' ? 'orthographic' : 'perspective'
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
keys.onKeys('1', () => {
|
|
141
|
-
settings.current.transformMode = 'translate'
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
keys.onKeys('2', () => {
|
|
145
|
-
settings.current.transformMode = 'rotate'
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
keys.onKeys('3', () => {
|
|
149
|
-
settings.current.transformMode = 'scale'
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
keys.onKeys('h', () => {
|
|
153
|
-
if (entity?.has(traits.Invisible)) {
|
|
154
|
-
entity.remove(traits.Invisible)
|
|
155
|
-
} else {
|
|
156
|
-
entity?.add(traits.Invisible)
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
116
|
</script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { PressedKeys } from 'runed'
|
|
3
|
+
|
|
4
|
+
import { traits, useQuery } from '../ecs'
|
|
5
|
+
import { useSettings } from '../hooks/useSettings.svelte'
|
|
6
|
+
|
|
7
|
+
const selected = useQuery(traits.Selected)
|
|
8
|
+
|
|
9
|
+
const settings = useSettings()
|
|
10
|
+
const keys = new PressedKeys()
|
|
11
|
+
|
|
12
|
+
keys.onKeys('c', () => {
|
|
13
|
+
settings.current.cameraMode =
|
|
14
|
+
settings.current.cameraMode === 'perspective' ? 'orthographic' : 'perspective'
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
keys.onKeys('1', () => {
|
|
18
|
+
settings.current.transformMode = 'translate'
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
keys.onKeys('2', () => {
|
|
22
|
+
settings.current.transformMode = 'rotate'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
keys.onKeys('3', () => {
|
|
26
|
+
settings.current.transformMode = 'scale'
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
keys.onKeys('h', () => {
|
|
30
|
+
for (const entity of selected.current) {
|
|
31
|
+
if (entity?.has(traits.Invisible)) {
|
|
32
|
+
entity.remove(traits.Invisible)
|
|
33
|
+
} else {
|
|
34
|
+
entity?.add(traits.Invisible)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const KeyboardBindings: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type KeyboardBindings = InstanceType<typeof KeyboardBindings>;
|
|
18
|
+
export default KeyboardBindings;
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
import { MeshDiscardMaterial } from '@threlte/extras'
|
|
4
4
|
import { BackSide, Mesh, Vector3 } from 'three'
|
|
5
5
|
|
|
6
|
+
import { traits, useQuery } from '../ecs'
|
|
6
7
|
import { useTransformControls } from '../hooks/useControls.svelte'
|
|
7
|
-
import { useSelectedEntity } from '../hooks/useSelection.svelte'
|
|
8
8
|
import { useSettings } from '../hooks/useSettings.svelte'
|
|
9
9
|
|
|
10
10
|
const { camera } = useThrelte()
|
|
11
11
|
const settings = useSettings()
|
|
12
|
-
const selectedEntity = useSelectedEntity()
|
|
13
12
|
const transformControls = useTransformControls()
|
|
13
|
+
const selected = useQuery(traits.Selected)
|
|
14
|
+
|
|
14
15
|
const cameraDown = new Vector3()
|
|
15
16
|
|
|
16
17
|
const enabled = $derived(settings.current.interactionMode === 'navigate')
|
|
@@ -32,7 +33,9 @@
|
|
|
32
33
|
return
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
for (const entity of selected.current) {
|
|
37
|
+
entity.remove(traits.Selected)
|
|
38
|
+
}
|
|
36
39
|
}}
|
|
37
40
|
>
|
|
38
41
|
<T.BoxGeometry args={[size, size, size]} />
|
|
@@ -4,24 +4,21 @@
|
|
|
4
4
|
import { T, useThrelte } from '@threlte/core'
|
|
5
5
|
import { Environment, Grid, interactivity, PerfMonitor, PortalTarget } from '@threlte/extras'
|
|
6
6
|
import { useXR } from '@threlte/xr'
|
|
7
|
-
import { ShaderMaterial
|
|
7
|
+
import { ShaderMaterial } from 'three'
|
|
8
8
|
|
|
9
9
|
import Camera from './Camera.svelte'
|
|
10
10
|
import Entities from './Entities/Entities.svelte'
|
|
11
|
-
import Focus from './Focus.svelte'
|
|
12
11
|
import Selected from './Selected.svelte'
|
|
13
12
|
import SelectedTransformControls from './SelectedTransformControls.svelte'
|
|
14
13
|
import StaticGeometries from './StaticGeometries.svelte'
|
|
15
14
|
import { bvh } from '../hooks/plugins/bvh.svelte'
|
|
16
|
-
import { useFocusedObject3d } from '../hooks/useSelection.svelte'
|
|
17
15
|
import { useSettings } from '../hooks/useSettings.svelte'
|
|
18
16
|
|
|
19
17
|
import hdrImage from '../assets/ferndale_studio_11_1k.hdr'
|
|
20
18
|
import BatchedArrows from './BatchedArrows.svelte'
|
|
21
19
|
import CameraControls from './CameraControls.svelte'
|
|
22
|
-
import
|
|
20
|
+
import KeyboardBindings from './KeyboardBindings.svelte'
|
|
23
21
|
import PointerMissBox from './PointerMissBox.svelte'
|
|
24
|
-
import { useOrigin } from './xr/useOrigin.svelte'
|
|
25
22
|
|
|
26
23
|
interface Props {
|
|
27
24
|
children?: Snippet
|
|
@@ -31,8 +28,6 @@
|
|
|
31
28
|
|
|
32
29
|
const threlte = useThrelte()
|
|
33
30
|
const settings = useSettings()
|
|
34
|
-
const focusedObject3d = useFocusedObject3d()
|
|
35
|
-
const origin = useOrigin()
|
|
36
31
|
|
|
37
32
|
// @ts-expect-error This is for debugging
|
|
38
33
|
globalThis.__threlte__ = threlte
|
|
@@ -59,8 +54,6 @@
|
|
|
59
54
|
|
|
60
55
|
bvh(raycaster, () => ({ helper: false, enabled: bvhEnabled }))
|
|
61
56
|
|
|
62
|
-
const focusedObject = $derived(focusedObject3d.current)
|
|
63
|
-
|
|
64
57
|
const { isPresenting } = useXR()
|
|
65
58
|
</script>
|
|
66
59
|
|
|
@@ -68,57 +61,46 @@
|
|
|
68
61
|
<PerfMonitor anchorX="right" />
|
|
69
62
|
{/if}
|
|
70
63
|
|
|
64
|
+
<KeyboardBindings />
|
|
71
65
|
<Environment url={hdrImage} />
|
|
72
66
|
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<T.Group attach={focusedObject ? false : undefined}>
|
|
114
|
-
<PortalTarget />
|
|
115
|
-
|
|
116
|
-
<Entities />
|
|
117
|
-
<BatchedArrows />
|
|
118
|
-
</T.Group>
|
|
119
|
-
|
|
120
|
-
{@render children?.()}
|
|
121
|
-
|
|
122
|
-
<T.DirectionalLight position={[3, 3, 3]} />
|
|
123
|
-
<T.AmbientLight />
|
|
124
|
-
</T.Group>
|
|
67
|
+
<PointerMissBox />
|
|
68
|
+
<SelectedTransformControls />
|
|
69
|
+
|
|
70
|
+
{#if !$isPresenting && settings.current.grid}
|
|
71
|
+
<Grid
|
|
72
|
+
oncreate={(ref) => {
|
|
73
|
+
const material = ref.material as ShaderMaterial
|
|
74
|
+
material.depthWrite = false
|
|
75
|
+
}}
|
|
76
|
+
raycast={() => null}
|
|
77
|
+
bvh={{ enabled: false }}
|
|
78
|
+
plane="xy"
|
|
79
|
+
sectionColor="#333"
|
|
80
|
+
infiniteGrid
|
|
81
|
+
renderOrder={999}
|
|
82
|
+
cellSize={settings.current.gridCellSize}
|
|
83
|
+
sectionSize={settings.current.gridSectionSize}
|
|
84
|
+
fadeOrigin={[0, 0, 0]}
|
|
85
|
+
fadeDistance={settings.current.gridFadeDistance}
|
|
86
|
+
/>
|
|
87
|
+
{/if}
|
|
88
|
+
|
|
89
|
+
{#if !$isPresenting}
|
|
90
|
+
<Camera position={[3, 3, 3]}>
|
|
91
|
+
<CameraControls />
|
|
92
|
+
</Camera>
|
|
93
|
+
{/if}
|
|
94
|
+
|
|
95
|
+
<StaticGeometries />
|
|
96
|
+
<Selected />
|
|
97
|
+
|
|
98
|
+
<PortalTarget />
|
|
99
|
+
|
|
100
|
+
<Entities />
|
|
101
|
+
<BatchedArrows />
|
|
102
|
+
|
|
103
|
+
{@render children?.()}
|
|
104
|
+
|
|
105
|
+
<T.DirectionalLight position={[3, 3, 3]} />
|
|
106
|
+
<T.AmbientLight />
|
|
@@ -19,13 +19,10 @@
|
|
|
19
19
|
import { providePointclouds } from '../hooks/usePointclouds.svelte'
|
|
20
20
|
import { provideRelationships } from '../hooks/useRelationships.svelte'
|
|
21
21
|
import { provideResourceByName } from '../hooks/useResourceByName.svelte'
|
|
22
|
-
import { provideSelection } from '../hooks/useSelection.svelte'
|
|
23
22
|
import { provideWorldStates } from '../hooks/useWorldState.svelte'
|
|
24
23
|
|
|
25
|
-
import { provideOrigin } from './xr/useOrigin.svelte'
|
|
26
|
-
|
|
27
24
|
interface Props {
|
|
28
|
-
children: Snippet
|
|
25
|
+
children: Snippet
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
let { children }: Props = $props()
|
|
@@ -38,7 +35,6 @@
|
|
|
38
35
|
provideHierarchy()
|
|
39
36
|
provideWorldMatrix()
|
|
40
37
|
provideInheritedInvisible()
|
|
41
|
-
provideOrigin()
|
|
42
38
|
|
|
43
39
|
provideRelationships()
|
|
44
40
|
|
|
@@ -55,8 +51,7 @@
|
|
|
55
51
|
provideWorldStates()
|
|
56
52
|
provideFramelessComponents()
|
|
57
53
|
|
|
58
|
-
const { focus } = provideSelection()
|
|
59
54
|
provideLinkedEntities()
|
|
60
55
|
</script>
|
|
61
56
|
|
|
62
|
-
{@render children(
|
|
57
|
+
{@render children()}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
|
-
children: Snippet
|
|
4
|
-
focus: boolean;
|
|
5
|
-
}]>;
|
|
3
|
+
children: Snippet;
|
|
6
4
|
}
|
|
7
5
|
declare const SceneProviders: import("svelte").Component<Props, {}, "">;
|
|
8
6
|
type SceneProviders = ReturnType<typeof SceneProviders>;
|