mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 00:45:08 +01:00
33 lines
No EOL
938 B
JavaScript
33 lines
No EOL
938 B
JavaScript
import * as vec from '../../app/math/math'
|
|
import {assertFaceOrigination, assertFaceRole} from './asserts';
|
|
|
|
export class SurfaceGauge {
|
|
|
|
constructor(surface, rayCast) {
|
|
this.surface = surface;
|
|
this.rayCast = rayCast;
|
|
}
|
|
|
|
sample(u, v, delta = 10) {
|
|
let normal = this.surface.normal(u, v);
|
|
let pt = this.surface.point(u, v);
|
|
let deltaV = vec.mul(normal, delta);
|
|
let [face] = ui.rayCastFaces(vec.add(pt, deltaV), vec.sub(pt, deltaV));
|
|
let sampleAssertations = {
|
|
assertFaceOrigination: (sketchId, primitiveId) => {
|
|
assertFaceOrigination(face, sketchId, primitiveId);
|
|
return sampleAssertations;
|
|
},
|
|
assertFaceRole: role => {
|
|
assertFaceRole(face, role);
|
|
return sampleAssertations
|
|
}
|
|
}
|
|
}
|
|
|
|
static prism(surfaceImpl, a, b, c, d) {
|
|
return new SurfaceGauge(surfaceImpl(1, 1, [0,0,1,1], [0,0,1,1],
|
|
[ [ a, b] ,
|
|
[ c, d ] ] ));
|
|
}
|
|
} |