mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
refactored plane feature to use mdf widgets and migrated the feature to the modeling workbench.
This commit is contained in:
parent
7b5807089b
commit
2de9e7f98e
6 changed files with 40 additions and 111 deletions
|
|
@ -1,14 +1,19 @@
|
|||
import {createMeshGeometry} from 'scene/geoms';
|
||||
import {Plane} from 'geom/impl/plane';
|
||||
import Vector from 'math/vector';
|
||||
import PlaneWizard from './SimplePlaneWizard';
|
||||
import {MOpenFaceShell} from '../../../model/mopenFace';
|
||||
import schema from './simplePlaneOpSchema';
|
||||
import {PlaneSurfacePrototype} from '../../../model/surfacePrototype';
|
||||
import {MOpenFaceShell} from '../../../../../web/app/cad/model/mopenFace';
|
||||
import {PlaneSurfacePrototype} from '../../../../../web/app/cad/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";
|
||||
import {EntityKind} from "cad/model/entities";
|
||||
import {entityKindCapture} from "cad/craft/schema/types/entityType";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function paramsToPlane({orientation, datum, depth}, cadRegistry) {
|
||||
const csys = datum ? datum.csys : CSys.ORIGIN;
|
||||
|
|
@ -55,8 +60,35 @@ export default {
|
|||
paramsInfo: ({depth}) => `(${depth})`,
|
||||
previewGeomProvider,
|
||||
run: createPlane,
|
||||
form: PlaneWizard,
|
||||
schema
|
||||
form: [
|
||||
{
|
||||
type: 'choice',
|
||||
style: "dropdown",
|
||||
label: 'orientation',
|
||||
name: 'orientation',
|
||||
style: 'radio',
|
||||
values: ['XY', 'XZ', 'ZY'],
|
||||
defaultValue: "XY",
|
||||
},
|
||||
{
|
||||
type: 'selection',
|
||||
name: 'datum',
|
||||
capture: [EntityKind.MDatum,EntityKind.FACE],
|
||||
label: 'datum',
|
||||
multi: false,
|
||||
optional: true,
|
||||
defaultValue: {
|
||||
usePreselection: true,
|
||||
preselectionIndex: 0
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
label: 'depth',
|
||||
name: 'depth',
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import Entity from '../../wizard/components/form/Entity';
|
||||
|
||||
|
||||
export default function PlaneWizard() {
|
||||
return <Group>
|
||||
<Entity name='datum' placeholder='origin'/>
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
import {createMeshGeometry} from 'scene/geoms';
|
||||
import {Plane} from 'geom/impl/plane';
|
||||
import Vector from 'math/vector';
|
||||
import PlaneWizard from './PlaneWizard';
|
||||
import {MOpenFaceShell} from '../../../model/mopenFace';
|
||||
import schema from './planeOpSchema';
|
||||
import {CSysPlaneSurfacePrototype} from '../../../model/surfacePrototype';
|
||||
|
||||
const WIDTH = 750;
|
||||
const HEIGHT = 750;
|
||||
|
||||
function createPlane(params, services) {
|
||||
const mDatum = services.cadRegistry.findDatum(params.datum);
|
||||
|
||||
return {
|
||||
consumed: [mDatum],
|
||||
created: [new MOpenFaceShell(new CSysPlaneSurfacePrototype(mDatum.csys), mDatum.csys)]
|
||||
}
|
||||
}
|
||||
|
||||
function previewGeomProvider(params, services) {
|
||||
const mDatum = services.cadRegistry.findDatum(params.datum);
|
||||
|
||||
if (!mDatum) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tr = mDatum.csys.outTransformation;
|
||||
|
||||
const a = tr._apply(new Vector(0, 0, 0));
|
||||
const b = tr._apply(new Vector(WIDTH, 0, 0));
|
||||
const c = tr._apply(new Vector(WIDTH, HEIGHT, 0));
|
||||
const d = tr._apply(new Vector(0, HEIGHT, 0));
|
||||
|
||||
const trs = [[a, b, c], [a, c, d]];
|
||||
return createMeshGeometry(trs);
|
||||
}
|
||||
|
||||
export default {
|
||||
id: 'PLANE_FROM_DATUM',
|
||||
label: 'Plane',
|
||||
icon: 'img/cad/plane',
|
||||
info: 'creates new object plane off of datum',
|
||||
paramsInfo: ({datum}) => `(${datum})`,
|
||||
previewGeomProvider,
|
||||
run: createPlane,
|
||||
form: PlaneWizard,
|
||||
schema
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import React from 'react';
|
||||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, RadioButtonsField} from '../../wizard/components/form/Fields';
|
||||
import {RadioButton} from 'ui/components/controls/RadioButtons';
|
||||
import Entity from '../../wizard/components/form/Entity';
|
||||
|
||||
|
||||
export default function PlaneWizard() {
|
||||
return <Group>
|
||||
<RadioButtonsField name='orientation'>
|
||||
<RadioButton value='XY' />
|
||||
<RadioButton value='XZ' />
|
||||
<RadioButton value='ZY' />
|
||||
</RadioButtonsField>
|
||||
<Entity name='datum' />
|
||||
<NumberField name='depth' />
|
||||
</Group>;
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import {entityKindCapture} from "cad/craft/schema/types/entityType";
|
||||
|
||||
export default {
|
||||
orientation: {
|
||||
type: 'string',
|
||||
enum: ['XY', 'XZ', 'ZY'],
|
||||
defaultValue: 'XY'
|
||||
},
|
||||
datum: {
|
||||
type: 'entity',
|
||||
entityCapture: entityKindCapture('face', 'datum'),
|
||||
optional: true,
|
||||
defaultValue: {
|
||||
usePreselection: true,
|
||||
preselectionIndex: 0,
|
||||
}
|
||||
},
|
||||
depth: {
|
||||
type: 'number',
|
||||
defaultValue: 0
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import {WorkbenchRegistry} from "workbenches/registry";
|
||||
import planeOperation from "cad/craft/primitives/simplePlane/simplePlaneOperation";
|
||||
import planeOperation from "workbenches/modeler/features/plane/simplePlaneOperation";
|
||||
import createDatumOperation from "cad/craft/datum/create/createDatumOperation";
|
||||
import moveDatumOperation from "cad/craft/datum/move/moveDatumOperation";
|
||||
import rotateDatumOperation from "cad/craft/datum/rotate/rotateDatumOperation";
|
||||
import datumOperation from "cad/craft/primitives/plane/planeOperation";
|
||||
|
||||
import {Bundle} from "bundler/bundleSystem";
|
||||
import {WorkbenchService} from "cad/workbench/workbenchService";
|
||||
import {OperationService} from "cad/craft/operationBundle";
|
||||
|
|
@ -37,6 +37,5 @@ function registerCoreOperations(ctx: WorkbenchesLoaderActivationContext) {
|
|||
createDatumOperation,
|
||||
moveDatumOperation,
|
||||
rotateDatumOperation,
|
||||
datumOperation,
|
||||
] as any);
|
||||
}
|
||||
Loading…
Reference in a new issue