mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-16 05:23:19 +01:00
remove ported code
This commit is contained in:
parent
16318b29be
commit
65a822ba5a
3 changed files with 0 additions and 162 deletions
|
|
@ -1,21 +0,0 @@
|
|||
import {PreviewWizard, IMAGINARY_SURFACE_MATERIAL} from './preview-wizard'
|
||||
|
||||
const METADATA = [
|
||||
['width' , 'number', 500, {min: 0}],
|
||||
['height' , 'number', 500, {min: 0}],
|
||||
['depth' , 'number', 500, {min: 0}]
|
||||
];
|
||||
|
||||
|
||||
export class BoxWizard extends PreviewWizard {
|
||||
|
||||
constructor(app, initialState) {
|
||||
super(app, 'BOX', METADATA, initialState);
|
||||
}
|
||||
|
||||
createPreviewObject(app, params) {
|
||||
const geometry = new THREE.BoxGeometry(params.width, params.height, params.depth);
|
||||
return new THREE.Mesh(geometry, IMAGINARY_SURFACE_MATERIAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
import {CURRENT_SELECTION as S} from './wizard'
|
||||
import {PreviewWizard, SketchBasedPreviewer} from './preview-wizard'
|
||||
import {getEncloseDetails} from '../cut-extrude'
|
||||
import {TriangulatePolygons} from '../../../tess/triangulation'
|
||||
import Vector from 'math/vector';
|
||||
import {curveTessParams} from "../../../../brep/geom/impl/curve/curve-tess";
|
||||
|
||||
|
||||
const METADATA = [
|
||||
['value' , 'number', 50],
|
||||
['prism' , 'number', 1 , {min: 0, step: 0.1, round: 1}],
|
||||
['angle' , 'number', 0 , {}],
|
||||
['rotation', 'number', 0 , {step: 5}],
|
||||
['face' , 'face' , S ]
|
||||
];
|
||||
|
||||
export class CutWizard extends PreviewWizard {
|
||||
constructor(app, initialState) {
|
||||
super(app, 'CUT', METADATA, initialState)
|
||||
}
|
||||
|
||||
createPreviewObject(app, params) {
|
||||
return CUT_PREVIEWER.create(app, params);
|
||||
}
|
||||
|
||||
uiLabel(name) {
|
||||
if ('value' === name) return 'depth';
|
||||
return super.uiLabel(name);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtrudeWizard extends PreviewWizard {
|
||||
constructor(app, initialState) {
|
||||
super(app, 'EXTRUDE', METADATA, initialState)
|
||||
}
|
||||
|
||||
createPreviewObject(app, params) {
|
||||
return EXTRUDE_PREVIEWER.create(app, params);
|
||||
}
|
||||
|
||||
uiLabel(name) {
|
||||
if ('value' === name) return 'height';
|
||||
return super.uiLabel(name);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtrudePreviewer extends SketchBasedPreviewer {
|
||||
|
||||
constructor(inversed) {
|
||||
super();
|
||||
this.inversed = inversed;
|
||||
}
|
||||
|
||||
createImpl(app, params, sketch, face) {
|
||||
const encloseDetails = getEncloseDetails(params, sketch, face.surface().tangentPlane(0, 0), !this.inversed);
|
||||
const triangles = [];
|
||||
|
||||
for (let {basePath, lidPath, baseSurface, lidSurface} of encloseDetails) {
|
||||
const basePoints = [];
|
||||
const lidPoints = [];
|
||||
for (let i = 0; i < basePath.length; ++i) {
|
||||
let baseNurbs = basePath[i];
|
||||
let lidNurbs = lidPath[i];
|
||||
|
||||
let tessCurve = params.prism > 1 ? lidNurbs : baseNurbs;
|
||||
|
||||
const us = curveTessParams(tessCurve.impl, tessCurve.uMin, tessCurve.uMax);
|
||||
const base = us.map(u => baseNurbs.point(u));
|
||||
const lid = us.map(u => lidNurbs.point(u));
|
||||
const n = base.length;
|
||||
for (let p = n - 1, q = 0; q < n; p = q ++) {
|
||||
triangles.push([ base[p], base[q], lid[q] ]);
|
||||
triangles.push([ lid[q], lid[p], base[p] ]);
|
||||
}
|
||||
base.forEach(p => basePoints.push(p));
|
||||
lid.forEach(p => lidPoints.push(p));
|
||||
}
|
||||
|
||||
function collectOnSurface(points, normal) {
|
||||
TriangulatePolygons([points], normal, (v) => v.toArray(), (arr) => new Vector().set3(arr))
|
||||
.forEach(tr => triangles.push(tr));
|
||||
}
|
||||
collectOnSurface(basePoints, baseSurface.normal);
|
||||
collectOnSurface(lidPoints, lidSurface.normal);
|
||||
}
|
||||
return triangles;
|
||||
}
|
||||
}
|
||||
|
||||
const EXTRUDE_PREVIEWER = new ExtrudePreviewer(false);
|
||||
const CUT_PREVIEWER = new ExtrudePreviewer(true);
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
import {PreviewWizard, IMAGINARY_SURFACE_MATERIAL} from './preview-wizard'
|
||||
import {CURRENT_SELECTION as S} from './wizard'
|
||||
import {AXIS, IDENTITY_BASIS, STANDARD_BASES} from '../../../../math/l3space'
|
||||
import Vector from 'math/vector';
|
||||
|
||||
const METADATA = [
|
||||
['orientation', 'choice', 'XY', {options: ['XY', 'XZ', 'ZY']}],
|
||||
['parallelTo', 'face', S],
|
||||
['depth', 'number', 0, {}]
|
||||
];
|
||||
|
||||
export class PlaneWizard extends PreviewWizard {
|
||||
|
||||
constructor(app, initialState) {
|
||||
super(app, 'PLANE', METADATA, initialState);
|
||||
}
|
||||
|
||||
createPreviewObject(app, params) {
|
||||
let face = null;
|
||||
if (params.parallelTo) {
|
||||
face = this.app.findFace(params.parallelTo);
|
||||
}
|
||||
let basis;
|
||||
let depth = params.depth;
|
||||
if (face == null) {
|
||||
basis = STANDARD_BASES[params.orientation];
|
||||
} else {
|
||||
basis = face.basis();
|
||||
depth += face.depth();
|
||||
}
|
||||
|
||||
const w = 375, h = 375;
|
||||
const a = new Vector(-w, -h, 0);
|
||||
const b = new Vector( w, -h, 0);
|
||||
const c = new Vector( w, h, 0);
|
||||
const d = new Vector(-w, h, 0);
|
||||
|
||||
const plane = PreviewWizard.createMesh([[a, b, c], [a, c, d]])
|
||||
|
||||
const m = new THREE.Matrix4();
|
||||
m.makeBasis.apply(m, basis);
|
||||
const wVec = new THREE.Vector3(0, 0, depth);
|
||||
wVec.applyMatrix4(m);
|
||||
m.setPosition(wVec);
|
||||
plane.geometry.applyMatrix(m);
|
||||
plane.geometry.computeFaceNormals();
|
||||
return plane;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue