// Generated by scripts/generate.mjs from bindings/api.mjs. Do not edit.

///|
#external
pub type ConvexHull

///|
#module("@mizchi/three-mbt/spatial-detail")
pub extern "js" fn ConvexHull::ConvexHull() -> ConvexHull = "convexHull"

///|
extern "js" fn ConvexHull::ffi_set_from_points(
  self : ConvexHull,
  points : FixedArray[Vector3],
) -> JsResult[ConvexHull] =
  #| (self, points) => { try { return { ok: true, value: (() => { if(points.length<4)throw new RangeError("At least four points required"); return self.setFromPoints(points); })() }; } catch (error) { return { ok: false, error: String(error) }; } }

///|
pub fn ConvexHull::set_from_points(
  self : ConvexHull,
  points : FixedArray[Vector3],
) -> ConvexHull raise ModelingError {
  match self.ffi_set_from_points(points).into_result() {
    Ok(value) => value
    Err(message) => raise ModelingError(message)
  }
}

///|
extern "js" fn ConvexHull::ffi_set_from_object(
  self : ConvexHull,
  object : Object3D,
) -> JsResult[ConvexHull] =
  #| (self, object) => { try { return { ok: true, value: (() => self.setFromObject(object))() }; } catch (error) { return { ok: false, error: String(error) }; } }

///|
pub fn ConvexHull::set_from_object(
  self : ConvexHull,
  object : Object3D,
) -> ConvexHull raise ModelingError {
  match self.ffi_set_from_object(object).into_result() {
    Ok(value) => value
    Err(message) => raise ModelingError(message)
  }
}

///|
pub extern "js" fn ConvexHull::contains_point(
  self : ConvexHull,
  point : Vector3,
) -> Bool =
  #| (self, point) => self.containsPoint(point)

///|
pub extern "js" fn ConvexHull::intersects_ray(
  self : ConvexHull,
  ray : Ray,
) -> Bool =
  #| (self, ray) => self.intersectsRay(ray)

///|
extern "js" fn ConvexHull::ffi_intersect_ray(
  self : ConvexHull,
  ray : Ray,
  target : Vector3,
) -> Nullable[Vector3] =
  #| (self, ray, target) => self.intersectRay(ray,target)

///|
pub fn ConvexHull::intersect_ray(
  self : ConvexHull,
  ray : Ray,
  target : Vector3,
) -> Vector3? {
  self.ffi_intersect_ray(ray, target).to_option()
}

///|
pub extern "js" fn ConvexHull::faces(self : ConvexHull) -> FixedArray[HullFace] =
  #| (self) => self.faces.slice()

///|
pub extern "js" fn ConvexHull::tolerance(self : ConvexHull) -> Double =
  #| (self) => self.tolerance

///|
pub extern "js" fn ConvexHull::make_empty(self : ConvexHull) -> ConvexHull =
  #| (self) => self.makeEmpty()