jsketcher/web/app/cad/scene/controls/rayCastDebug.js
2020-05-20 00:07:33 -07:00

20 lines
615 B
JavaScript

import * as vec from "math/vec";
export let RayCastDebugInfo;
export function initRayCastDebug() {
RayCastDebugInfo = {};
}
export function printRaycastDebugInfo(tag , hit) {
if (RayCastDebugInfo && RayCastDebugInfo.ray) {
const pt = hit.point;
//generating test data
const BUFFER = 100;
const r = vec.fromXYZ(pt).map(Math.round);
const dir = vec._mul(vec.fromXYZ(RayCastDebugInfo.ray.direction), BUFFER);
console.log(tag);
console.log('cy.simulateClickByRayCast(['+ vec.sub(r, dir).map(Math.round).join(', ') + '], [' + vec.add(r, dir).map(Math.round).join(', ') + '])');
}
}