getCameraFrustum method

  1. @override
Future<Frustum> getCameraFrustum()
override

Get the camera's culling frustum in world space. Returns a (vector_math) Frustum instance where plane0-plane6 define the left, right, bottom, top, far and near planes respectively. See Camera.h and (filament) Frustum.h for more details.

Implementation

@override
Future<Frustum> getCameraFrustum() async {
  final ptr = _module._malloc(24 * 8) as JSNumber;
  _module.ccall("get_camera_frustum", "void",
      ["void*".toJS, "double*".toJS].toJS, [_viewer!, ptr].toJS, null);
  final planes = List.generate(6, (i) {
    final offset = i * 4;
    return Plane()
      ..setFromComponents(
          (_module.getValue((ptr.toDartInt + (offset * 8)).toJS, "double")
                  as JSNumber)
              .toDartDouble,
          (_module.getValue(
                      (ptr.toDartInt + ((offset + 1) * 8)).toJS, "double")
                  as JSNumber)
              .toDartDouble,
          (_module.getValue(
                      (ptr.toDartInt + ((offset + 2) * 8)).toJS, "double")
                  as JSNumber)
              .toDartDouble,
          (_module.getValue(
                      (ptr.toDartInt + ((offset + 3) * 8)).toJS, "double")
                  as JSNumber)
              .toDartDouble);
  });
  _module._free(ptr);
  throw UnimplementedError();
  // return Frustum()..plane0 = planes[0]..plane1 =planes[1]..plane2 =planes[2]..plane3 =planes[3], planes[4], planes[5]);
}