mirror of
https://github.com/xibyte/jsketcher
synced 2026-01-15 12:41:23 +01:00
craft tests scenarios
This commit is contained in:
parent
a638f45d6e
commit
a67bd9bfe7
12 changed files with 418 additions and 46 deletions
156
web/test/cases/craftCut.js
Normal file
156
web/test/cases/craftCut.js
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
import {extrudeCube} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function testCutMid(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(-50, -50, 50, 50);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI1Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, 0, 80, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI2Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, 0, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI3Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI4Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
// all the way cuts
|
||||
|
||||
export function testCutMidAllWay(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(-50, -50, 50, 50);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI1FacesAllWay(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, 0, 80, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI2FacesAllWay(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, 0, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI3FacesAllWay(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testCutCOI4FacesAllWay(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('CUT');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
78
web/test/cases/craftExtrude.js
Normal file
78
web/test/cases/craftExtrude.js
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import {extrudeCube} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function testExtrudeMid(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(-50, -50, 50, 50);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testExtrudeCOI1Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, 0, 80, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testExtrudeCOI2Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, 0, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testExtrudeCOI3Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(0, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testExtrudeCOI4Faces(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.selectFaces([0, 0, 210], [0, 0, 190]);
|
||||
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 50);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
import {assertFaceOrigination, assertFaceRole} from '../utils/asserts';
|
||||
import {createPlaneAndOpenSketcher} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function testExtrudeFromSketch(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let seg1 = sketcherUI.addSegment(-100, -100, 100, -100);
|
||||
let seg2 = sketcherUI.addSegment(100, -100, 100, 100);
|
||||
|
|
@ -47,7 +48,7 @@ export function testExtrudeFromSketch(env, ui) {
|
|||
}
|
||||
|
||||
export function testExtrudeArc(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let arc = sketcherUI.addArc(0, 0, 100, 0, -100, 0);
|
||||
let segment = sketcherUI.addSegment(100, 0, -100, 0);
|
||||
|
|
@ -85,7 +86,7 @@ export function testExtrudeArc(env, ui) {
|
|||
}
|
||||
|
||||
export function testExtrudeCircle(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let circle = sketcherUI.addCircle(100, 100, 100);
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ export function testExtrudeCircle(env, ui) {
|
|||
}
|
||||
|
||||
export function testExtrudeEllipse(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let ellipse = sketcherUI.addEllipse(-100, 100, 100, 100, 0, 150);
|
||||
|
||||
|
|
@ -145,7 +146,7 @@ export function testExtrudeEllipse(env, ui) {
|
|||
}
|
||||
|
||||
export function testExtrudeEllipticalArc(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let eArc = sketcherUI.addEllipticalArc(-100, 100, 100, 100, 0, 150);
|
||||
sketcherUI.move(100, 100, -50, 170);
|
||||
|
|
@ -177,7 +178,7 @@ export function testExtrudeEllipticalArc(env, ui) {
|
|||
}
|
||||
|
||||
export function testExtrudeBezier(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let bezier = sketcherUI.addBezier(-100, 100, 100, 100, 0, 150);
|
||||
sketcherUI.move(bezier.cp2.x, bezier.cp2.y, bezier.cp2.x, bezier.cp1.y);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import {assertFaceOrigination, assertFaceRole} from '../utils/asserts';
|
||||
import {createPlaneAndOpenSketcher} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function testExtrudePrism(env, ui) {
|
||||
let sketcherUI = ui.createPlaneAndOpenSketcher();
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
let sketchedFace = ui.context.services.selection.face.single;
|
||||
let [S1, S2, S3, S4] = sketcherUI.addPolygon(-100, -100, 100, 100);
|
||||
|
||||
|
|
|
|||
32
web/test/cases/craftFillet.js
Normal file
32
web/test/cases/craftFillet.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import {createPlaneAndOpenSketcher, extrudeCube} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function test1Fillet(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.openWizard('FILLET');
|
||||
ui.select([0, 110, 210], [0, 90, 190]);
|
||||
ui.wizardOK();
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function test2Fillet(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.openWizard('FILLET');
|
||||
ui.select([0, 110, 210], [0, 90, 190]);
|
||||
ui.select([-110, 110, 100], [-90, 90, 100]);
|
||||
ui.wizardOK();
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function test3Fillet(env, ui) {
|
||||
extrudeCube(ui);
|
||||
ui.openWizard('FILLET');
|
||||
ui.select([0, 110, 210], [0, 90, 190]);
|
||||
ui.select([-110, 110, 100], [-90, 90, 100]);
|
||||
ui.select([-110, 0, 210], [-90, 0, 190]);
|
||||
ui.wizardOK();
|
||||
env.done();
|
||||
}
|
||||
|
||||
|
||||
26
web/test/cases/craftLoft.js
Normal file
26
web/test/cases/craftLoft.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import {createPlaneAndOpenSketcher, extrudeCube} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function testLoftOver2Sections(env, ui) {
|
||||
let sui = createPlaneAndOpenSketcher(ui);
|
||||
sui.addPolygon(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('PLANE');
|
||||
ui.wizardContext.updateParam('depth', 300);
|
||||
ui.wizardOK();
|
||||
ui.selectFaces([0, 0, 290], [0, 0, 310]);
|
||||
sui = ui.openSketcher();
|
||||
sui.addSerpinski([-100, 0], [100, 0], 2);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('LOFT');
|
||||
ui.select([-3, -3, 310], [-3, -3, 290]);
|
||||
ui.select([-3, -3, -10], [-3, -3, 10]);
|
||||
ui.wizardOK();
|
||||
env.done();
|
||||
}
|
||||
|
||||
|
||||
|
||||
36
web/test/cases/craftRevolve.js
Normal file
36
web/test/cases/craftRevolve.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import {createPlaneAndOpenSketcher, extrudeCube} from '../utils/scripts';
|
||||
|
||||
export const TEST_MODE = 'modellerUI';
|
||||
|
||||
export function testRevolveHalfWay(env, ui) {
|
||||
createPlaneAndOpenSketcher(ui);
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(20, -50, 50, 50);
|
||||
sui.changeToConstructionLayer();
|
||||
sui.addSegment(0, -50, 0, 50);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('REVOLVE');
|
||||
ui.wizardContext.updateParam('angle', 180);
|
||||
ui.select([0, 0, 10], [0, 0, -10]);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
export function testRevolveAllWay(env, ui) {
|
||||
createPlaneAndOpenSketcher(ui);
|
||||
let sui = ui.openSketcher();
|
||||
sui.addPolygon(20, -50, 50, 50);
|
||||
sui.changeToConstructionLayer();
|
||||
sui.addSegment(0, -50, 0, 50);
|
||||
ui.commitSketch();
|
||||
|
||||
ui.openWizard('REVOLVE');
|
||||
ui.wizardContext.updateParam('angle', 360);
|
||||
ui.select([0, 0, 10], [0, 0, -10]);
|
||||
ui.wizardOK();
|
||||
|
||||
env.done();
|
||||
}
|
||||
|
||||
|
|
@ -9,10 +9,10 @@ body {
|
|||
box-sizing: border-box;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: 40%;
|
||||
max-height: 500px;
|
||||
width: 40%;
|
||||
max-width: 500px;
|
||||
//max-height: 700px;
|
||||
//max-width: 700px;
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
background-color: #233930;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ export default {
|
|||
TestCase('craftPlane'),
|
||||
TestCase('craftExtrudeBasicShapes'),
|
||||
TestCase('craftExtrudeOptions'),
|
||||
TestCase('craftExtrude'),
|
||||
TestCase('craftCut'),
|
||||
TestCase('craftRevolve'),
|
||||
TestCase('craftFillet'),
|
||||
TestCase('craftLoft'),
|
||||
],
|
||||
|
||||
SketcherObjects: [
|
||||
|
|
|
|||
18
web/test/utils/scripts.js
Normal file
18
web/test/utils/scripts.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
export function createPlaneAndOpenSketcher(ui) {
|
||||
ui.openWizard('PLANE');
|
||||
ui.wizardOK();
|
||||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
return ui.openSketcher();
|
||||
}
|
||||
|
||||
export function extrudeCube(ui) {
|
||||
let sketcherUI = createPlaneAndOpenSketcher(ui);
|
||||
sketcherUI.addPolygon(-100, -100, 100, 100);
|
||||
ui.commitSketch();
|
||||
ui.selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
ui.openWizard('EXTRUDE');
|
||||
ui.wizardContext.updateParam('value', 200);
|
||||
ui.wizardOK();
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
import {getAttribute} from '../../../../../modules/scene/objectData';
|
||||
import {FACE} from '../../../../app/cad/scene/entites';
|
||||
import {createSubjectFromInPlaceSketcher} from './sketcherUISubject';
|
||||
import {
|
||||
ALL_EXCLUDING_SOLID_KINDS,
|
||||
PICK_KIND,
|
||||
traversePickResults
|
||||
} from '../../../../app/cad/scene/controls/pickControlPlugin';
|
||||
|
||||
export default ctx => {
|
||||
|
||||
|
|
@ -24,37 +27,25 @@ export default ctx => {
|
|||
sceneMouseEvent('mouseup', x, y);
|
||||
}
|
||||
|
||||
function rayCast(from3, to3) {
|
||||
const THREE = ctx.services.tpi.THREE;
|
||||
let raycaster = new THREE.Raycaster();
|
||||
let from = new THREE.Vector3().fromArray(from3);
|
||||
let to = new THREE.Vector3().fromArray(to3);
|
||||
let dir = to.sub(from);
|
||||
let dist = dir.length();
|
||||
raycaster.set(from, dir.normalize());
|
||||
return raycaster.intersectObjects( ctx.services.cadScene.workGroup.children, true ).filter(h => h.distance <= dist);
|
||||
}
|
||||
|
||||
function rayCastFaces(from, to) {
|
||||
let models = rayCast(from, to).map(h => {
|
||||
if (h.face) {
|
||||
let faceV = getAttribute(h.face, FACE);
|
||||
if (faceV && faceV.model) {
|
||||
return faceV.model;
|
||||
}
|
||||
}
|
||||
});
|
||||
let rawObjects = ctx.services.viewer.customRaycast(from, to, ctx.services.cadScene.workGroup.children);
|
||||
let faces = [];
|
||||
traversePickResults(null, rawObjects, PICK_KIND.FACE, face => faces.push(face));
|
||||
let out = [];
|
||||
models.forEach(m => {
|
||||
if (!!m && !out.includes(m)) {
|
||||
out.push(m);
|
||||
faces.forEach(face => {
|
||||
if (!out.includes(face)) {
|
||||
out.push(face);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function selectFaces(from, to) {
|
||||
rayCastFaces(from, to).forEach(face => ctx.services.pickControl.pick(face));
|
||||
ctx.services.pickControl.pickFromRay(from, to, PICK_KIND.FACE);
|
||||
}
|
||||
|
||||
function select(from, to) {
|
||||
ctx.services.pickControl.pickFromRay(from, to, ALL_EXCLUDING_SOLID_KINDS);
|
||||
}
|
||||
|
||||
function getWizardContext() {
|
||||
|
|
@ -70,19 +61,11 @@ export default ctx => {
|
|||
ctx.services.action.run('sketchSaveAndExit');
|
||||
}
|
||||
|
||||
function createPlaneAndOpenSketcher() {
|
||||
openWizard('PLANE');
|
||||
wizardOK();
|
||||
selectFaces([0, 0, -10], [0, 0, 10]);
|
||||
return openSketcher();
|
||||
}
|
||||
|
||||
return {
|
||||
context: ctx,
|
||||
openWizard, wizardOK, sceneMouseEvent, clickOnScene,
|
||||
rayCastFaces, selectFaces, openSketcher, commitSketch,
|
||||
rayCastFaces, select, selectFaces, openSketcher, commitSketch,
|
||||
get wizardContext() { return getWizardContext()},
|
||||
createPlaneAndOpenSketcher,
|
||||
__DEBUG__: ctx.services.debug.utils
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import * as sketcher_utils from '../../../utils/sketcher-utils'
|
||||
import {decapitalize} from '../../../../../modules/gems/capitalize';
|
||||
import genSerpinski, {genSerpinskiImpl} from '../../../../app/utils/genSerpinski';
|
||||
import {distance, distanceAB} from '../../../../app/math/math';
|
||||
|
||||
export function createSubjectFromInPlaceSketcher(ctx) {
|
||||
|
||||
|
|
@ -35,8 +37,42 @@ export function createSubjectFromInPlaceSketcher(ctx) {
|
|||
];
|
||||
}
|
||||
|
||||
function addSerpinski([ax, ay], [bx, by], depth) {
|
||||
genSerpinskiImpl(ctx.services.sketcher.inPlaceEditor.viewer, {x: ax, y: ay}, {x: bx, y: by}, depth);
|
||||
let jointWidth = distance(ax, ay, bx, by) / (depth + 1) / 2;
|
||||
|
||||
let dx = bx - ax;
|
||||
let dy = by - ay;
|
||||
|
||||
let D = Math.sqrt(dx*dx + dy*dy);
|
||||
|
||||
dx /= D;
|
||||
dy /= D;
|
||||
|
||||
let ddx = -dy * jointWidth;
|
||||
let ddy = dx * jointWidth;
|
||||
|
||||
|
||||
genSerpinskiImpl(ctx.services.sketcher.inPlaceEditor.viewer, {x: bx-ddx, y: by-ddy}, {x: ax-ddx, y: ay-ddy}, depth);
|
||||
addSegment(ax, ay, ax-ddx, ay-ddy);
|
||||
addSegment(bx, by, bx-ddx, by-ddy);
|
||||
}
|
||||
|
||||
function changeLayer(layerName) {
|
||||
ctx.services.sketcher.inPlaceEditor.viewer.setActiveLayerName(layerName);
|
||||
}
|
||||
|
||||
function changeToConstructionLayer() {
|
||||
changeLayer('_construction_');
|
||||
}
|
||||
|
||||
function changeToDefaultLayer() {
|
||||
changeLayer('sketch');
|
||||
}
|
||||
|
||||
return {
|
||||
addSegment, addPolygon, addArc, addCircle, addEllipse, addEllipticalArc, addBezier, move
|
||||
addSegment, addPolygon, addArc, addCircle, addEllipse, addEllipticalArc, addSerpinski, addBezier,
|
||||
move, changeLayer, changeToConstructionLayer, changeToDefaultLayer,
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue