mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
partially working radial patern
This commit is contained in:
parent
684f80faec
commit
88da95c32e
1 changed files with 20 additions and 16 deletions
|
|
@ -3,11 +3,11 @@ import {MFace} from "cad/model/mface";
|
||||||
import {ApplicationContext} from "context";
|
import {ApplicationContext} from "context";
|
||||||
import {EntityKind} from "cad/model/entities";
|
import {EntityKind} from "cad/model/entities";
|
||||||
import Axis from "math/axis";
|
import Axis from "math/axis";
|
||||||
import {OperationDescriptor} from "cad/craft/operationPlugin";
|
import { UnitVector } from "math/vector";
|
||||||
import {MShell} from 'cad/model/mshell';
|
import { OperationDescriptor } from "cad/craft/operationPlugin";
|
||||||
|
import { MShell } from 'cad/model/mshell';
|
||||||
import {Matrix3x4} from "math/matrix";
|
import {Matrix3x4} from "math/matrix";
|
||||||
import {SetLocation} from "cad/craft/e0/interact";
|
import {SetLocation} from "cad/craft/e0/interact";
|
||||||
import {DEG_RAD} from "math/commons";
|
|
||||||
|
|
||||||
interface patternRadialParams {
|
interface patternRadialParams {
|
||||||
inputBodies: MShell[];
|
inputBodies: MShell[];
|
||||||
|
|
@ -27,6 +27,8 @@ export const PatternRadialOperation: OperationDescriptor<patternRadialParams> =
|
||||||
paramsInfo: p => `( ${p.patternMethod} ${r(p.angle * DEG_RAD)})`,
|
paramsInfo: p => `( ${p.patternMethod} ${r(p.angle * DEG_RAD)})`,
|
||||||
run: (params: patternRadialParams, ctx: ApplicationContext) => {
|
run: (params: patternRadialParams, ctx: ApplicationContext) => {
|
||||||
|
|
||||||
|
|
||||||
|
console.log(params);
|
||||||
let occ = ctx.occService;
|
let occ = ctx.occService;
|
||||||
const oci = occ.commandInterface;
|
const oci = occ.commandInterface;
|
||||||
|
|
||||||
|
|
@ -34,20 +36,15 @@ export const PatternRadialOperation: OperationDescriptor<patternRadialParams> =
|
||||||
|
|
||||||
params.inputBodies.forEach((shellToPatern, index) => {
|
params.inputBodies.forEach((shellToPatern, index) => {
|
||||||
for (let i = 2; i <= params.qty; i++) {
|
for (let i = 2; i <= params.qty; i++) {
|
||||||
let angleForInstance;
|
let angleForInstance = 0;
|
||||||
if (params.patternMethod == 'step') {
|
if(params.patternMethod == 'Step Angle') angleForInstance =params.angle*(i-1);
|
||||||
angleForInstance = params.angle*(i-1);
|
if(params.patternMethod == 'Span Angle') angleForInstance =(params.angle / (params.qty-1))*(i-1);
|
||||||
} else if (params.patternMethod == 'span') {
|
|
||||||
angleForInstance = (params.angle / (params.qty))*(i-1);
|
|
||||||
} else {
|
|
||||||
throw 'unsupported pattern type: ' + params.patternMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
const angle = angleForInstance * DEG_RAD;
|
//const tr = shellToPatern.location.rotate(degrees_to_radians(angleForInstance),params.direction.normalize(),params.direction.normalize());
|
||||||
|
let tr = new Matrix3x4().rotate(degrees_to_radians(angleForInstance),params.direction.normalize(),params.direction.normalize());
|
||||||
let tr = new Matrix3x4().rotate(angle, params.axis.direction, params.axis.origin);
|
//tr = tr.rotateWithSphericalAxis(shellToPatern.location)
|
||||||
|
|
||||||
const newShellName = shellToPatern.id + ":pattern/" + index + "/" +i;
|
const newShellName = shellToPatern.id + ":patern/" + index + "/" +i;
|
||||||
oci.copy(shellToPatern, newShellName);
|
oci.copy(shellToPatern, newShellName);
|
||||||
SetLocation(newShellName, tr.toFlatArray());
|
SetLocation(newShellName, tr.toFlatArray());
|
||||||
|
|
||||||
|
|
@ -101,4 +98,11 @@ export const PatternRadialOperation: OperationDescriptor<patternRadialParams> =
|
||||||
optional: false
|
optional: false
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function degrees_to_radians(degrees)
|
||||||
|
{
|
||||||
|
var pi = Math.PI;
|
||||||
|
return degrees * (pi/180);
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue