Declare std::offsetPlane in KCL (#6344)

* Declare std::offsetPlane in KCL

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Use two axes to define planes in KCL

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-04-24 22:01:27 +12:00
committed by GitHub
parent 20c2ce3bac
commit 83a87b046f
187 changed files with 115960 additions and 133737 deletions

View File

@ -31,7 +31,6 @@ import type { CallExpressionKw } from '@rust/kcl-lib/bindings/CallExpressionKw'
import type { Node } from '@rust/kcl-lib/bindings/Node'
import type { Path } from '@rust/kcl-lib/bindings/Path'
import type { PipeExpression } from '@rust/kcl-lib/bindings/PipeExpression'
import type { Point3d } from '@rust/kcl-lib/bindings/Point3d'
import type { Program } from '@rust/kcl-lib/bindings/Program'
import type { Sketch } from '@rust/kcl-lib/bindings/Sketch'
import type { SourceRange } from '@rust/kcl-lib/bindings/SourceRange'
@ -140,7 +139,7 @@ import {
updateStartProfileAtArgs,
} from '@src/lang/std/sketch'
import type { SegmentInputs } from '@src/lang/std/stdTypes'
import { topLevelRange } from '@src/lang/util'
import { crossProduct, topLevelRange } from '@src/lang/util'
import type { PathToNode, VariableMap } from '@src/lang/wasm'
import {
defaultSourceRange,
@ -3532,7 +3531,7 @@ export class SceneEntities {
>
}> {
if (sketch.on.type === 'plane') {
const zAxis = sketch?.on.zAxis
const zAxis = crossProduct(sketch?.on.xAxis, sketch?.on.yAxis)
return {
quat: getQuaternionFromZAxis(massageFormats(zAxis)),
sketchDetails: {
@ -3830,7 +3829,7 @@ export function getSketchQuaternion(
kclManager,
})
if (err(sketch)) return sketch
const zAxis = sketch?.on.zAxis || sketchNormalBackUp
const zAxis = (sketch?.on.xAxis && sketch?.on.yAxis) ? crossProduct(sketch?.on.xAxis, sketch?.on.yAxis) : sketchNormalBackUp
if (!zAxis) return Error('Sketch zAxis not found')
return getQuaternionFromZAxis(massageFormats(zAxis))
@ -3856,7 +3855,7 @@ export function getQuaternionFromZAxis(zAxis: Vector3): Quaternion {
return quaternion
}
function massageFormats(a: Vec3Array | Point3d): Vector3 {
function massageFormats(a: Vec3Array | {x: number, y: number, z: number}): Vector3 {
return isArray(a) ? new Vector3(a[0], a[1], a[2]) : new Vector3(a.x, a.y, a.z)
}