diff --git a/client/src/app.css b/client/src/app.css index f7782b4..2898b55 100644 --- a/client/src/app.css +++ b/client/src/app.css @@ -21,6 +21,8 @@ overflow: auto; /* or 'scroll' if you always want scrollability */ scrollbar-width: none; /* Hide scrollbar for Firefox */ -ms-overflow-style: none; /* Hide scrollbar for IE 10+ and Edge */ + + overscroll-behavior: none; } body::-webkit-scrollbar { display: none; diff --git a/client/src/lib/Apps/DevTools/DevTools.svelte b/client/src/lib/Apps/DevTools/DevTools.svelte index f75c868..916b6df 100644 --- a/client/src/lib/Apps/DevTools/DevTools.svelte +++ b/client/src/lib/Apps/DevTools/DevTools.svelte @@ -1,4 +1,8 @@ Simulate random motion + diff --git a/client/src/lib/Dashboard/Visualization/CameraControls/CameraControls.svelte b/client/src/lib/Dashboard/Visualization/CameraControls/CameraControls.svelte index f6d3935..29b96c8 100644 --- a/client/src/lib/Dashboard/Visualization/CameraControls/CameraControls.svelte +++ b/client/src/lib/Dashboard/Visualization/CameraControls/CameraControls.svelte @@ -34,6 +34,7 @@ type PerspectiveCamera, } from 'three' import { DEG2RAD } from 'three/src/math/MathUtils' + import { cameraState } from './utils/cameraStore' const subsetOfTHREE = { Vector2, @@ -70,11 +71,9 @@ const getControls = () => ref - let disableAutoRotate = false - useTask( delta => { - if (autoRotate && !disableAutoRotate) { + if (autoRotate && !$cameraState.userControlled) { getControls().azimuthAngle += 4 * delta * DEG2RAD * autoRotateSpeed } const updated = getControls().update(delta) @@ -91,13 +90,13 @@ { - disableAutoRotate = true + cameraState.set('userControlled', true) }} on:zoom={e => { console.log('zoomstart', e) }} on:controlend={() => { - disableAutoRotate = false + cameraState.set('userControlled', false) }} {...$$restProps} bind:this={$forwardingComponent} diff --git a/client/src/lib/Dashboard/Visualization/CameraControls/Scene.svelte b/client/src/lib/Dashboard/Visualization/CameraControls/Scene.svelte index c39e00d..8e06fe2 100644 --- a/client/src/lib/Dashboard/Visualization/CameraControls/Scene.svelte +++ b/client/src/lib/Dashboard/Visualization/CameraControls/Scene.svelte @@ -1,122 +1,96 @@ { - ref.lookAt(0, 1, 0); + ref.lookAt(0, 1, 0) }} > { - $cameraControls = ref; + $cameraControls = ref }} + autoRotate={$cameraState.mode === 'orbit'} + autoRotateSpeed={3} /> + { // @ts-expect-error - $mesh = ref; + $mesh = ref }} /> diff --git a/client/src/lib/Dashboard/Visualization/CameraControls/utils/cameraStore.ts b/client/src/lib/Dashboard/Visualization/CameraControls/utils/cameraStore.ts index 37a02c6..9a68df5 100644 --- a/client/src/lib/Dashboard/Visualization/CameraControls/utils/cameraStore.ts +++ b/client/src/lib/Dashboard/Visualization/CameraControls/utils/cameraStore.ts @@ -1,7 +1,35 @@ -import type CameraControls from "camera-controls"; -import { writable } from "svelte/store"; -import type { Mesh, Object3DEventMap } from "three"; -import type { Group } from "three/examples/jsm/libs/tween.module.js"; +import type CameraControls from 'camera-controls' +import { writable } from 'svelte/store' +import type { Mesh } from 'three' -export const cameraControls = writable(); -export const mesh = writable(); +export const cameraControls = writable() +export const mesh = writable() + +type CameraMode = + | 'orbit' + | 'follow-facing' + | 'follow-direction' + | 'follow-position' + | 'showcase' + +interface CameraState { + mode: CameraMode + userControlled: boolean +} + +const { set, update, subscribe } = writable({ + mode: 'orbit', + userControlled: false, +}) + +const createCameraState = () => { + return { + update, + subscribe, + set: (prop: keyof CameraState, val: any) => + update(state => ({ ...state, [prop]: val })), + reset: () => set({ mode: 'orbit', userControlled: false }), + } +} + +export const cameraState = createCameraState() diff --git a/client/src/lib/stores/telemetryStore.ts b/client/src/lib/stores/telemetryStore.ts index 4663c97..7521597 100644 --- a/client/src/lib/stores/telemetryStore.ts +++ b/client/src/lib/stores/telemetryStore.ts @@ -1,4 +1,4 @@ -import { writable, readonly } from 'svelte/store' +import { writable, readonly, get } from 'svelte/store' let defaults: TelemetryData = { 'orientation': 0, @@ -28,6 +28,16 @@ const createTelemetryStore = () => { return store }) }, + set: (key: keyof TelemetryData, value: any) => { + let newObj = { + ...get(telemetryStore), + } + newObj = { + ...newObj, + [key]: value, + } + set(newObj) + }, reset: () => set(defaults), } } diff --git a/client/src/lib/utils/initializeTelemetry.ts b/client/src/lib/utils/initializeTelemetry.ts index 3f2d847..68d4fb3 100644 --- a/client/src/lib/utils/initializeTelemetry.ts +++ b/client/src/lib/utils/initializeTelemetry.ts @@ -34,7 +34,11 @@ export const initializeTelemetry = async ( }) const unlistenTelemetry = await listen('telemetry_data', event => { - console.log(event.payload) + const data = JSON.parse(event.payload as string) + // console.log(JSON.parse) + telemetryStore.set('connected', true) + + telemetryStore.set(data['topic_name'], data['data']) }) const unlistenAll = () => {