mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-25 09:52:19 +01:00
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
import {CURRENT_SELECTION as S} from './wizard'
|
|
import {PreviewWizard, SketchBasedNurbsPreviewer } from './preview-wizard'
|
|
import {TriangulatePolygons} from '../../../tess/triangulation'
|
|
import {revolveToWallNurbs} from '../../../../../../modules/brep/brep-builder'
|
|
import {evalPivot} from '../revolve'
|
|
import Vector from 'math/vector';
|
|
|
|
const METADATA = [
|
|
['angle' , 'number', 5, {min: -360, max: 360, step: 10}],
|
|
['pivot' , 'sketch.segment' , S ],
|
|
['face' , 'face' , S ]
|
|
];
|
|
|
|
export class RevolveWizard extends PreviewWizard {
|
|
constructor(app, initialState) {
|
|
super(app, 'REVOLVE', METADATA, initialState)
|
|
}
|
|
|
|
createPreviewObject(app, params) {
|
|
return REVOLVE_PREVIEWER.createMesh(app, params);
|
|
}
|
|
}
|
|
|
|
export class RevolvePreviewer extends SketchBasedNurbsPreviewer {
|
|
|
|
createNurbses(app, params, sketch, face) {
|
|
const surface = face.surface();
|
|
const pivot = evalPivot(params.pivot, sketch, surface);
|
|
const nurbses = [];
|
|
const contours = sketch.fetchContours();
|
|
for (let contour of contours) {
|
|
const basePath = contour.approximateOnSurface(surface);
|
|
revolveToWallNurbs(basePath, surface, pivot.p0, pivot.v, params.angle).forEach(nurbs => nurbses.push(nurbs));
|
|
}
|
|
return nurbses;
|
|
}
|
|
}
|
|
|
|
|
|
const REVOLVE_PREVIEWER = new RevolvePreviewer();
|