Skip to content

Commit

Permalink
web: Fixes #86. debounce pointermove events when sketching
Browse files Browse the repository at this point in the history
  • Loading branch information
av8ta committed Jun 3, 2024
1 parent 30f6edd commit 3549501
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
5 changes: 3 additions & 2 deletions applications/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"tailwindcss": "^3.4.3",
"ts-auto-guard": "^4.2.0",
"vite": "^5.2.11",
"vitest": "^1.6.0",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0"
"vite-plugin-wasm": "^3.3.0",
"vitest": "^1.6.0"
},
"type": "module",
"dependencies": {
Expand All @@ -47,6 +47,7 @@
"camera-controls": "^2.8.3",
"gsap": "^3.12.5",
"js-file-download": "^0.4.12",
"just-debounce-it": "^3.2.0",
"nurbs": "^1.1.1",
"shared": "workspace:*",
"three": "^0.164.1",
Expand Down
5 changes: 3 additions & 2 deletions applications/web/src/components/PassiveSketch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import NewRectangleTool from "./tools/NewRectangle.svelte"
import SelectTool from "./tools/Select.svelte"
import type {ArcTuple, CircleTuple, FaceTuple, IDictionary, LineTuple, PlaneData, PreviewGeometry, SketchPoint, PointById, SketchRealized} from "shared/types"
import debounce from "just-debounce-it"
const log = (function () { const context = "[PassiveSketch.svelte]"; const color="gray"; return Function.prototype.bind.call(console.log, console, `%c${context}`, `font-weight:bold;color:${color};`)})() // prettier-ignore
Expand Down Expand Up @@ -178,7 +179,7 @@
}
}
}}
on:pointermove={e => {
on:pointermove={debounce(e => {
if (editing) {
if ($sketchTool === "line") {
newLineTool.mouseMove(e, projectToPlane(e.point))
Expand All @@ -188,7 +189,7 @@
newRectangleTool.mouseMove(e, projectToPlane(e.point))
}
}
}}
}, 10)}
>
<T.PlaneGeometry args={[width * 100, height * 100]} />
</T.Mesh>
Expand Down
50 changes: 29 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3549501

Please sign in to comment.