UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

72 lines (71 loc) 1.96 kB
"use strict"; import { NamedFunction1, NamedFunction2, ObjectNamedFunction1 } from "./_Base"; const DISTANCE_NOT_FOUND = -1; const INDEX_NOT_FOUND = -1; export class getIntersectionPropertyDistance extends NamedFunction1 { static type() { return "getIntersectionPropertyDistance"; } func(intersection) { if (!intersection) { return DISTANCE_NOT_FOUND; } return intersection.distance; } } export class getIntersectionPropertyFaceIndex extends NamedFunction1 { static type() { return "getIntersectionPropertyFaceIndex"; } func(intersection) { if (!intersection) { return INDEX_NOT_FOUND; } const faceIndex = intersection.faceIndex; if (faceIndex == null) { return INDEX_NOT_FOUND; } return faceIndex; } } export class getIntersectionPropertyObject extends ObjectNamedFunction1 { static type() { return "getIntersectionPropertyObject"; } func(object3D, intersection) { return (intersection == null ? void 0 : intersection.object) || object3D; } } export class getIntersectionPropertyPoint extends NamedFunction2 { static type() { return "getIntersectionPropertyPoint"; } func(intersection, target) { return intersection ? target.copy(intersection.point) : target.set(0, 0, 0); } } export class getIntersectionPropertyNormal extends NamedFunction2 { static type() { return "getIntersectionPropertyNormal"; } func(intersection, target) { if (!intersection) { return target.set(0, 1, 0); } const face = intersection.face; if (face && face.normal) { target.copy(face.normal); } else { target.set(0, 1, 0); } return target; } } export class getIntersectionPropertyUv extends NamedFunction2 { static type() { return "getIntersectionPropertyUv"; } func(intersection, target) { return (intersection == null ? void 0 : intersection.uv) ? target.copy(intersection.uv) : target.set(0, 0); } }