add client lib @kittycad/lib (#214)

* add client lib

* tsc after build

* update after spec update

* remove uneeded check

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix camera drag

* fix throttle typing

* comment with link to issue

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Kurt Hutten
2023-08-02 15:41:59 +10:00
committed by GitHub
parent aabb88ee45
commit 5419039fae
12 changed files with 140 additions and 126 deletions

View File

@ -3,6 +3,7 @@ import { PanelHeader } from '../components/PanelHeader'
import { v4 as uuidv4 } from 'uuid'
import { useStore } from '../useStore'
import { throttle } from '../lib/utils'
import { EngineCommand } from '../lang/std/engineConnection'
export const Stream = () => {
const videoRef = useRef<HTMLVideoElement>(null)
@ -25,7 +26,7 @@ export const Stream = () => {
const file_id = uuidv4()
const debounceSocketSend = throttle((message) => {
const debounceSocketSend = throttle<EngineCommand>((message) => {
engineCommandManager?.sendSceneCommand(message)
}, 16)
const handleMouseMove: MouseEventHandler<HTMLVideoElement> = ({
@ -41,14 +42,13 @@ export const Stream = () => {
const interaction = ctrlKey ? 'pan' : 'rotate'
debounceSocketSend({
type: 'ModelingCmdReq',
type: 'modeling_cmd_req',
cmd: {
CameraDragMove: {
interaction,
window: {
x: x,
y: y,
},
type: 'camera_drag_move',
interaction,
window: {
x: x,
y: y,
},
},
cmd_id: uuidv4(),
@ -73,14 +73,13 @@ export const Stream = () => {
const interaction = ctrlKey ? 'pan' : 'rotate'
engineCommandManager?.sendSceneCommand({
type: 'ModelingCmdReq',
type: 'modeling_cmd_req',
cmd: {
CameraDragStart: {
interaction,
window: {
x: x,
y: y,
},
type: 'camera_drag_start',
interaction,
window: {
x: x,
y: y,
},
},
cmd_id: newId,
@ -104,14 +103,13 @@ export const Stream = () => {
const interaction = ctrlKey ? 'pan' : 'rotate'
engineCommandManager?.sendSceneCommand({
type: 'ModelingCmdReq',
type: 'modeling_cmd_req',
cmd: {
CameraDragEnd: {
interaction,
window: {
x: x,
y: y,
},
type: 'camera_drag_end',
interaction,
window: {
x: x,
y: y,
},
},
cmd_id: uuidv4(),