fix plane off of datum

This commit is contained in:
Val Erastov 2022-03-25 21:24:58 -07:00
parent 9e548409b0
commit 3159b19ca3
5 changed files with 25 additions and 16 deletions

View file

@ -12,7 +12,7 @@ export default function PlaneWizard() {
<RadioButton value='XZ' />
<RadioButton value='ZY' />
</RadioButtonsField>
<Entity name='parallelTo' />
<Entity name='datum' />
<NumberField name='depth' />
</Group>;
}

View file

@ -4,10 +4,14 @@ export default {
enum: ['XY', 'XZ', 'ZY'],
defaultValue: 'XY'
},
parallelTo: {
datum: {
type: 'entity',
allowedKinds: ['face'],
allowedKinds: ['face', 'datum'],
optional: true,
defaultValue: {
usePreselection: true,
preselectionIndex: 0,
}
},
depth: {
type: 'number',

View file

@ -6,21 +6,25 @@ import {MOpenFaceShell} from '../../../model/mopenFace';
import schema from './simplePlaneOpSchema';
import {PlaneSurfacePrototype} from '../../../model/surfacePrototype';
import {STANDARD_BASES} from 'math/basis';
import {MFace} from "cad/model/mface";
import CSys from "math/csys";
import {MDatum} from "cad/model/mdatum";
function paramsToPlane({orientation, parallelTo, depth}, cadRegistry) {
let face = null;
if (parallelTo) {
face = cadRegistry.findFace(parallelTo);
}
let plane = null;
if (face === null) {
const normal = STANDARD_BASES[orientation][2];
plane = new Plane(normal, depth);
function paramsToPlane({orientation, datum, depth}, cadRegistry) {
const csys = datum ? datum.csys : CSys.ORIGIN;
let axis;
if (orientation === 'XY') {
axis = csys.z;
} else if (orientation === 'XZ') {
axis = csys.y;
} else {
let base = face.surface.tangentPlaneInMiddle();
plane = new Plane(base.normal, base.w + depth);
axis = csys.x;
}
return plane;
const w = axis.multiply(depth)._plus(csys.origin).dot(axis);
return new Plane(axis, w);
}
function createPlane(params, {cadRegistry}) {

View file

@ -23,6 +23,7 @@ export default function initializeBySchema(schema: OperationSchema, context: Cor
}
} else if (md.type === Types.entity && md.defaultValue !== undefined) {
const defaultValue = md.defaultValue;
console.log(defaultValue)
if (defaultValue.usePreselection === true && defaultValue.preselectionIndex !== undefined) {
const allowedKinds = md.allowedKinds;
const currentSelection =

View file

@ -53,7 +53,7 @@ export default [
label: 'datum',
cssIcons: ['magic'],
info: 'operations on datum',
actions: ['DATUM_ROTATE', 'DATUM_MOVE', '-', 'PLANE_FROM_DATUM', '-', 'BOX', 'SPHERE', 'CYLINDER', 'TORUS', 'CONE']
actions: ['PLANE', '-', 'BOX', 'SPHERE', 'CYLINDER', 'TORUS', 'CONE']
// actions: ['DATUM_MOVE', 'DATUM_ROTATE', 'DATUM_REBASE', '-', 'PLANE_FROM_DATUM', 'BOX', 'SPHERE', 'TORUS',
// 'CONE', 'CYLINDER']
},