mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
make coordinate system widget use coordinate system instead of basis
This commit is contained in:
parent
a32ac44a01
commit
02eb8b0662
3 changed files with 29 additions and 7 deletions
|
|
@ -9,6 +9,25 @@ export function setBasisToObject3D(obj, basis, depth) {
|
||||||
obj.applyMatrix(mx);
|
obj.applyMatrix(mx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setCadToViewMatrix(cadMatrix, threeMatrix) {
|
||||||
|
let cm = cadMatrix;
|
||||||
|
threeMatrix.set(
|
||||||
|
cm.mxx, cm.mxy, cm.mxz, cm.tx,
|
||||||
|
cm.myx, cm.myy, cm.myz, cm.ty,
|
||||||
|
cm.mzx, cm.mzy, cm.mzz, cm.tz,
|
||||||
|
0, 0, 0, 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCsysToViewMatrix(csys, threeMatrix) {
|
||||||
|
threeMatrix.set(
|
||||||
|
csys.x.x, csys.y.x, csys.z.x, csys.origin.x,
|
||||||
|
csys.x.y, csys.y.y, csys.z.y, csys.origin.y,
|
||||||
|
csys.x.z, csys.y.z, csys.z.z, csys.origin.z,
|
||||||
|
0, 0, 0, 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function moveObject3D(obj, dir) {
|
export function moveObject3D(obj, dir) {
|
||||||
obj.position.add(dir)
|
obj.position.add(dir)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {OnTopOfAll} from 'scene/materialMixins';
|
||||||
import {moveObject3D, setBasisToObject3D} from 'scene/objects/transform';
|
import {moveObject3D, setBasisToObject3D} from 'scene/objects/transform';
|
||||||
|
|
||||||
import * as SceneGraph from 'scene/sceneGraph';
|
import * as SceneGraph from 'scene/sceneGraph';
|
||||||
|
import {setCsysToViewMatrix} from '../../../../modules/scene/objects/transform';
|
||||||
|
|
||||||
export default class CadScene {
|
export default class CadScene {
|
||||||
|
|
||||||
|
|
@ -44,25 +45,27 @@ export default class CadScene {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.basisGroup = SceneGraph.createGroup();
|
this.basisGroup = SceneGraph.createGroup();
|
||||||
|
this.basisGroup.matrixAutoUpdate = false;
|
||||||
|
|
||||||
let xAxis = createBasisArrow(new Vector(1, 0, 0), 0xFF0000);
|
let xAxis = createBasisArrow(new Vector(1, 0, 0), 0xFF0000);
|
||||||
let yAxis = createBasisArrow(new Vector(0, 1, 0), 0x00FF00);
|
let yAxis = createBasisArrow(new Vector(0, 1, 0), 0x00FF00);
|
||||||
SceneGraph.addToGroup(this.basisGroup, xAxis);
|
SceneGraph.addToGroup(this.basisGroup, xAxis);
|
||||||
SceneGraph.addToGroup(this.basisGroup, yAxis);
|
SceneGraph.addToGroup(this.basisGroup, yAxis);
|
||||||
SceneGraph.addToGroup(this.workGroup, this.basisGroup, yAxis);
|
SceneGraph.addToGroup(this.workGroup, this.basisGroup, yAxis);
|
||||||
this.hideBasis();
|
this.hideGlobalCsys();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBasis(basis, depth) {
|
updateGlobalCsys(csys) {
|
||||||
setBasisToObject3D(this.basisGroup, basis, depth);
|
setCsysToViewMatrix(csys, this.basisGroup.matrix);
|
||||||
|
this.basisGroup.matrixWorldNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
showBasis(basis, depth) {
|
showGlobalCsys(csys) {
|
||||||
this.updateBasis(basis, depth);
|
this.updateGlobalCsys(csys);
|
||||||
this.basisGroup.visible = true;
|
this.basisGroup.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
hideBasis() {
|
hideGlobalCsys() {
|
||||||
this.basisGroup.visible = false;
|
this.basisGroup.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ export function activate(context) {
|
||||||
let modelId = view.model.id;
|
let modelId = view.model.id;
|
||||||
if (kind === PICK_KIND.FACE) {
|
if (kind === PICK_KIND.FACE) {
|
||||||
if (dispatchSelection(streams.selection.face, modelId, event)) {
|
if (dispatchSelection(streams.selection.face, modelId, event)) {
|
||||||
services.cadScene.showBasis(view.model.basis(), view.model.depth());
|
services.cadScene.showGlobalCsys(view.model.csys);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (kind === PICK_KIND.SKETCH) {
|
} else if (kind === PICK_KIND.SKETCH) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue