it works!

This commit is contained in:
Mike Farrell
2024-10-10 16:58:12 -07:00
parent b11e8af9c7
commit 2b233dc705
3 changed files with 30 additions and 2 deletions

View File

@ -1,3 +1,4 @@
src/wasm-lib/*
src/lib/engine-utils/engine.js
*.typegen.ts
packages/codemirror-lsp-client/dist/*

View File

@ -1,4 +1,4 @@
import EngineUtils from './engine-utils/engine.js'
import EngineUtils from '@engine-utils'
type KCEngineUtilsEvaluatePath = {
(sketch: string, t: number): string
@ -10,7 +10,7 @@ export async function init() {
try {
EngineUtils().then((module) => {
kcEngineUtilsEvaluatePath = module.cwrap(
'kcEngineCalcPathEndpoint',
'kcEngineUtilsEvaluatePath',
'string',
['string', 'number']
)
@ -27,5 +27,31 @@ export async function getTruePathEndPos(sketch: string) {
await init()
}
//testing
const obj = {
path: [
{
command: 'moveTo',
pos: { x: 0, y: 0, z: 0 },
},
{
command: 'lineTo',
pos: { x: 10, y: 10, z: 0 },
},
{
command: 'bezCurveTo',
controlPoint1: { x: 15, y: 5, z: 0 },
controlPoint2: { x: 20, y: 15, z: 0 },
pos: { x: 25, y: 12.5, z: 0 },
},
{
command: 'tangentialArc',
radius: 15,
offset: -45,
},
],
}
sketch = JSON.stringify(obj)
return kcEngineUtilsEvaluatePath(sketch, 1.0)
}

View File

@ -58,6 +58,7 @@ const config = defineConfig({
resolve: {
alias: {
'@kittycad/codemirror-lsp-client': '/packages/codemirror-lsp-client/src',
'@engine-utils': '/src/lib/engine-utils/engine.js',
},
},
plugins: [react(), viteTsconfigPaths(), eslint(), version(), lezer()],