export const circleSpectrumFactory = () => {
  const spectrum = new THREE.Object3D();
  const split = 48;
  const theta = Math.PI / split;
  const ofs = 5;
  const width = 1;

  for (let i = 0; i < split * 2; i++) {
    const rectShape = new THREE.Shape();
    rectShape.moveTo(
      ofs * Math.cos(theta * i) +
        width * 0.5 * Math.cos(theta * i - Math.PI / 2),
      ofs * Math.sin(theta * i) +
        width * 0.5 * Math.sin(theta * i - Math.PI / 2)
    );
    rectShape.lineTo(
      ofs * Math.cos(theta * i) +
        width * 0.5 * Math.cos(theta * i + Math.PI / 2),
      ofs * Math.sin(theta * i) +
        width * 0.5 * Math.sin(theta * i + Math.PI / 2)
    );
    rectShape.lineTo(
      10 * Math.cos(theta * i) +
        width * 0.5 * Math.cos(theta * i + Math.PI / 2),
      10 * Math.sin(theta * i) + width * 0.5 * Math.sin(theta * i + Math.PI / 2)
    );
    rectShape.lineTo(
      10 * Math.cos(theta * i) +
        width * 0.5 * Math.cos(theta * i - Math.PI / 2),
      10 * Math.sin(theta * i) + width * 0.5 * Math.sin(theta * i - Math.PI / 2)
    );

    const geometry = new THREE.ShapeGeometry(rectShape);
    const material = new THREE.MeshBasicMaterial({
      color: colors[2],
      fog: false,
    });
    const line = new THREE.Mesh(geometry, material);
    spectrum.add(line);
  }

  spectrum.position.set(0, 0, 30);
  spectrum.visible = false;

  return spectrum;
};
Beispiel #2
0
export const squareFactory = ({
  color,
  width,
  offsetX,
  offsetY,
}: squareFactoryParams) => {
  const rectShape = new THREE.Shape();
  rectShape.moveTo(-width * 0.5, width * 0.5);
  rectShape.lineTo(width * 0.5, width * 0.5);
  rectShape.lineTo(width * 0.5, -width * 0.5);
  rectShape.lineTo(-width * 0.5, -width * 0.5);
  rectShape.lineTo(-width * 0.5, width * 0.5);

  const geometry = new THREE.ShapeGeometry(rectShape);
  const material = new THREE.MeshBasicMaterial({
    color: color,
    fog: false,
    wireframe: true,
    wireframeLinewidth: 2,
    transparent: true,
    opacity: 0.5,
  });
  const square = new THREE.Mesh(geometry, material);

  square.position.set(0 + offsetX, 0 + offsetY, -400);

  return square;
};
    private generateFaultPlane(orientation, size, color, opacity) {
        let circleRadius = size
        let circleShape = new three.Shape()
        circleShape.moveTo(0, circleRadius)
        circleShape.quadraticCurveTo(circleRadius, circleRadius, circleRadius, 0)
        circleShape.quadraticCurveTo(circleRadius, -circleRadius, 0, -circleRadius)
        circleShape.quadraticCurveTo(-circleRadius, -circleRadius, -circleRadius, 0)
        circleShape.quadraticCurveTo(-circleRadius, circleRadius, 0, circleRadius)

        let geometry = new three.ShapeGeometry(circleShape)
        let material = new three.MeshLambertMaterial({
            color: color,
            vertexColors: three.VertexColors,
            side: three.DoubleSide,
            transparent: true,
            opacity: opacity
        })

        let plane = new three.Mesh(geometry, material)
        plane.lookAt(new three.Vector3(orientation[0], orientation[1], orientation[2]))
        return plane
    }