text: import * as THREE from 'three';
  
  const localVector = new THREE.Vector3();
  const localVector2 = new THREE.Vector3();
  const localQuaternion = new THREE.Quaternion();
  const localMatrix = new THREE.Matrix4();
  
  class CameraGeometry extends THREE.BufferGeometry {
    constructor() {
      super();
  
      const boxGeometry = new THREE.BoxBufferGeometry(1, 1, 1);
      const positions = new Float32Array(boxGeometry.attributes.position.array.length * 8);
      const indices = new Uint16Array(boxGeometry.index.array.length * 8);
  
      const _pushBoxGeometry = m => {
        const g = boxGeometry.clone();
        g.applyMatrix4(m);
        positions.set(g.attributes.position.array, positionIndex);
        for (let i = 0; i < g.index.array.length; i++) {
          indices[indexIndex + i] = g.index.array[i] + positionIndex/3;
        }
        positionIndex += g.attributes.position.array.length;
        indexIndex += g.index.array.length;
      };
  
      const topLeft = new THREE.Vector3(-1, 0.5, -2);
      const topRight = new THREE.Vector3(1, 0.5, -2);
      const bottomLeft = new THREE.Vector3(-1, -0.5, -2);
      const bottomRight = new THREE.Vector3(1, -0.5, -2);
      const back = new THREE.Vector3(0, 0, 0);
  
      const _setMatrixBetweenPoints = (m, p1, p2) => {
        const quaternion = localQuaternion.setFromRotationMatrix(
          localMatrix.lookAt(
            p1,
            p2,
            localVector.set(0, 1, 0)
          )
        );
        const position = localVector.copy(p1)
          .add(p2)
          .divideScalar(2)
          // .add(new THREE.Vector3(0, 2, 0));
        const sc = 0.01;
        const scale = localVector2.set(sc, sc, p1.distanceTo(p2));
        m.compose(position, quaternion, scale);
        return m;
      };
  
      let positionIndex = 0;
      let indexIndex = 0;
      [
        [topLeft, back],
        [topRight, back],
        [bottomLeft, back],
        [bottomRight, back],
        [topLeft, topRight],
        [topRight, bottomRight],
        [bottomRight, bottomLeft],
        [bottomLeft, topLeft],
      ].forEach(e => {
        const [p1, p2] = e;
        _pushBoxGeometry(
          _setMatrixBetweenPoints(localMatrix, p1, p2)
        );
      });
  
      this.setAttribute('position', new THREE.BufferAttribute(positions, 3));
      this.setIndex(new THREE.BufferAttribute(indices, 1));
    }
  }
  
  export {
    CameraGeometry,
  };