PlaneHelper constructor

PlaneHelper(
  1. dynamic plane, [
  2. dynamic size = 1,
  3. dynamic hex = 0xffff00
])

Implementation

factory PlaneHelper(plane, [size = 1, hex = 0xffff00]) {
  var color = hex;

  List<double> positions = [
    1,
    -1,
    1,
    -1,
    1,
    1,
    -1,
    -1,
    1,
    1,
    1,
    1,
    -1,
    1,
    1,
    -1,
    -1,
    1,
    1,
    -1,
    1,
    1,
    1,
    1,
    0,
    0,
    1,
    0,
    0,
    0
  ];

  var geometry = BufferGeometry();
  geometry.setAttribute(
    'position',
    Float32BufferAttribute(Float32Array.from(positions), 3, false),
  );
  geometry.computeBoundingSphere();

  var planeHelper = PlaneHelper.create(
    geometry,
    LineBasicMaterial({"color": color, "toneMapped": false}),
  );

  planeHelper.plane = plane;

  planeHelper.size = size;

  List<double> positions2 = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1];

  var geometry2 = BufferGeometry();
  geometry2.setAttribute(
    'position',
    Float32BufferAttribute(Float32Array.from(positions2), 3, false),
  );
  geometry2.computeBoundingSphere();

  planeHelper.add(
    Mesh(
      geometry2,
      MeshBasicMaterial(
        {
          "color": color,
          "opacity": 0.2,
          "transparent": true,
          "depthWrite": false,
          "toneMapped": false,
        },
      ),
    ),
  );

  return planeHelper;
}