Fix XYZBC tool execution TCP path
This commit is contained in:
@@ -16,6 +16,7 @@ const CAMERA_PRESETS = {
|
||||
};
|
||||
const MAX_TOOLPATH_POINTS = Number.POSITIVE_INFINITY;
|
||||
const EMPTY_GEOMETRY = new THREE.BufferGeometry().setFromPoints([]);
|
||||
const LOCAL_TOOL_AXIS = new THREE.Vector3(0, 0, 1);
|
||||
|
||||
export function renderFiveAxisScene(canvas, state) {
|
||||
let preview = scenes.get(canvas);
|
||||
@@ -134,6 +135,7 @@ function createScene(canvas) {
|
||||
toolMarker,
|
||||
toolAxis,
|
||||
currentToolhead: new THREE.Vector3(),
|
||||
currentToolGlyphAxis: new THREE.Vector3(0, 0, 1),
|
||||
currentVismachModelState: null,
|
||||
lastSelectedView: null,
|
||||
lastCameraRevision: null,
|
||||
@@ -254,6 +256,7 @@ function exposePreviewDataset(canvas, state, preview) {
|
||||
canvas.dataset.threeLinearUnits = linearUnitsLabel(resolveSceneLinearUnits(state));
|
||||
canvas.dataset.threeLinearUnitScaleToMeters = String(linearUnitsToMetersFactor(resolveSceneLinearUnits(state)));
|
||||
canvas.dataset.threeToolAxis = JSON.stringify(toRoundedVector(state.toolAxisVector));
|
||||
canvas.dataset.threeToolGlyphAxis = JSON.stringify(toRoundedVector(preview.toolGlyphAxis || preview.currentToolGlyphAxis || state.toolAxisVector));
|
||||
canvas.dataset.threeTcpPose = JSON.stringify(toRoundedPose(state.tcpPose));
|
||||
canvas.dataset.threeRtcpState = state.rtcpState;
|
||||
canvas.dataset.threeSelectedView = state.preview.selectedView;
|
||||
@@ -360,13 +363,13 @@ function createMachineReferenceModel() {
|
||||
new THREE.MeshBasicMaterial({ color: 0xf1f5f9 }),
|
||||
);
|
||||
holderBody.rotation.x = Math.PI / 2;
|
||||
holderBody.position.z = 0.032;
|
||||
holderBody.position.z = 0.046;
|
||||
const cutter = new THREE.Mesh(
|
||||
new THREE.ConeGeometry(0.006, 0.025, 18),
|
||||
new THREE.MeshBasicMaterial({ color: 0xfff176 }),
|
||||
);
|
||||
cutter.rotation.x = Math.PI;
|
||||
cutter.position.z = 0.008;
|
||||
cutter.rotation.x = -Math.PI / 2;
|
||||
cutter.position.z = 0.0125;
|
||||
toolHolder.add(holderBody, cutter);
|
||||
|
||||
toolOffsetAxis.add(toolHolder);
|
||||
@@ -426,14 +429,14 @@ function createAxisReferencePreviewModel() {
|
||||
new THREE.ConeGeometry(0.0017, 0.0048, 4),
|
||||
new THREE.MeshBasicMaterial({ color: 0xe7eef7 }),
|
||||
);
|
||||
cone.rotation.x = Math.PI;
|
||||
cone.position.z = 0.0047;
|
||||
cone.rotation.x = -Math.PI / 2;
|
||||
cone.position.z = 0.0024;
|
||||
const holder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(0.0011, 0.0011, 0.0065, 8),
|
||||
new THREE.MeshBasicMaterial({ color: 0xbfc8d0 }),
|
||||
);
|
||||
holder.rotation.x = Math.PI / 2;
|
||||
holder.position.z = 0.008;
|
||||
holder.position.z = 0.00805;
|
||||
tool.add(cone, holder);
|
||||
|
||||
root.add(xAxis, yAxis, zAxis, dimensions, tool, ...labels);
|
||||
@@ -576,7 +579,10 @@ function updateMachineReferenceModel(preview, state, toolPosition, axisReference
|
||||
preview.axisReference.root.visible = axisReferenceMode;
|
||||
if (axisReferenceMode) {
|
||||
const referenceToolPosition = new THREE.Vector3(0, 0, 0.006);
|
||||
const toolVector = toToolVector(state.toolAxisVector);
|
||||
preview.axisReference.tool.position.copy(referenceToolPosition);
|
||||
alignToolGlyphToAxis(preview.axisReference.tool, toolVector);
|
||||
preview.currentToolGlyphAxis.copy(toolVector);
|
||||
}
|
||||
}
|
||||
if (axisReferenceMode) {
|
||||
@@ -601,7 +607,17 @@ function updateMachineReferenceModel(preview, state, toolPosition, axisReference
|
||||
|
||||
const tcpPosition = toolPosition || toPreviewVector(state.tcpPose || state.axisPose, state);
|
||||
const toolVector = toToolVector(state.toolAxisVector);
|
||||
model.toolHolder.lookAt(tcpPosition.clone().add(toolVector));
|
||||
model.toolHolder.position.copy(tcpPosition);
|
||||
alignToolGlyphToAxis(model.toolHolder, toolVector);
|
||||
preview.currentToolGlyphAxis.copy(toolVector);
|
||||
}
|
||||
|
||||
function alignToolGlyphToAxis(object, toolVector) {
|
||||
const axis = toolVector.clone().normalize();
|
||||
if (!Number.isFinite(axis.x) || !Number.isFinite(axis.y) || !Number.isFinite(axis.z) || axis.lengthSq() === 0) {
|
||||
axis.copy(LOCAL_TOOL_AXIS);
|
||||
}
|
||||
object.quaternion.setFromUnitVectors(LOCAL_TOOL_AXIS, axis);
|
||||
}
|
||||
|
||||
function updateLineGeometry(line, points) {
|
||||
@@ -745,6 +761,14 @@ function buildFixturePreviewPoints(pointCount, tcpPosition) {
|
||||
}
|
||||
|
||||
function executionToolPosition(state, previewPoints) {
|
||||
const uiTcp = state.programUiExecution?.tcp;
|
||||
if (uiTcp && hasLinearAxes(uiTcp)) {
|
||||
return vectorFromAxes(uiTcp, state, state.programRuntimeFeedback?.linearUnits || "mm");
|
||||
}
|
||||
const feedbackTcp = state.programRuntimeFeedback?.tcp;
|
||||
if (feedbackTcp && hasLinearAxes(feedbackTcp)) {
|
||||
return vectorFromAxes(feedbackTcp, state, state.programRuntimeFeedback?.linearUnits || "mm");
|
||||
}
|
||||
const feedbackAxes = state.programRuntimeFeedback?.axisPose || state.programRuntimeFeedback;
|
||||
if (feedbackAxes && hasLinearAxes(feedbackAxes)) {
|
||||
return vectorFromAxes(feedbackAxes, state, state.programRuntimeFeedback?.linearUnits);
|
||||
@@ -811,7 +835,7 @@ function previewSourceMode(state) {
|
||||
}
|
||||
|
||||
function toolpathPreviewSource(state) {
|
||||
if (state.programAxisPreviewPath?.source === "web-axis-preview-expanded-ngcgui-subroutines") {
|
||||
if (isAxisReferencePreview(state)) {
|
||||
return "axis_preview_expanded_ngcgui_subroutines";
|
||||
}
|
||||
if (state.programExecution?.sourceMode === "linuxcnc-interpreter-wasm") {
|
||||
@@ -824,7 +848,9 @@ function toolpathPreviewSource(state) {
|
||||
}
|
||||
|
||||
function isAxisReferencePreview(state) {
|
||||
return state.programAxisPreviewPath?.source === "web-axis-preview-expanded-ngcgui-subroutines";
|
||||
return state.programAxisPreviewPath?.source === "web-axis-preview-expanded-ngcgui-subroutines"
|
||||
|| state.programAxisPreviewPath?.source === "web-axis-source-execution-expanded-ngcgui-subroutines"
|
||||
|| Boolean(state.programAxisPreviewPath?.gcodeExecutionProcess);
|
||||
}
|
||||
|
||||
function toolExecutionTraceSource(state) {
|
||||
|
||||
Reference in New Issue
Block a user