import _extends from "@babel/runtime/helpers/esm/extends";
import React from 'react';
import { Vec3, Vec2 } from '../components';
import { toProps } from '../core';
import EventListener from '../event/EventListener';

function toTriangleProps(_ref) {
  var ambientOcclusionMap = _ref.ambientOcclusionMap,
      ambientOcclusionMapIntensity = _ref.ambientOcclusionMapIntensity,
      ambientOcclusionTextureOffset = _ref.ambientOcclusionTextureOffset,
      ambientOcclusionTextureRepeat = _ref.ambientOcclusionTextureRepeat,
      color = _ref.color,
      displacementBias = _ref.displacementBias,
      displacementMap = _ref.displacementMap,
      displacementScale = _ref.displacementScale,
      displacementTextureOffset = _ref.displacementTextureOffset,
      displacementTextureRepeat = _ref.displacementTextureRepeat,
      envMap = _ref.envMap,
      fog = _ref.fog,
      height = _ref.height,
      metalness = _ref.metalness,
      normalMap = _ref.normalMap,
      normalScale = _ref.normalScale,
      normalTextureOffset = _ref.normalTextureOffset,
      normalTextureRepeat = _ref.normalTextureRepeat,
      repeat = _ref.repeat,
      roughness = _ref.roughness,
      sphericalEnvMap = _ref.sphericalEnvMap,
      src = _ref.src,
      vertexA = _ref.vertexA,
      vertexB = _ref.vertexB,
      vertexC = _ref.vertexC,
      width = _ref.width,
      wireframe = _ref.wireframe,
      wireframeLinewidth = _ref.wireframeLinewidth;
  return {
    'ambient-occlusion-map': ambientOcclusionMap,
    'ambient-occlusion-map-intensity': ambientOcclusionMapIntensity,
    'ambient-occlusion-texture-offset': ambientOcclusionTextureOffset && new Vec2(ambientOcclusionTextureOffset).toString(),
    'ambient-occlusion-texture-repeat': ambientOcclusionTextureRepeat && new Vec2(ambientOcclusionTextureRepeat).toString(),
    color: color,
    'displacement-bias': displacementBias,
    'displacement-map': displacementMap,
    'displacement-scale': displacementScale,
    'displacement-texture-offset': displacementTextureOffset && new Vec2(displacementTextureOffset).toString(),
    'displacement-texture-repeat': displacementTextureRepeat && new Vec2(displacementTextureRepeat).toString(),
    'env-map': envMap,
    fog: fog,
    height: height,
    metalness: metalness,
    'normal-map': normalMap,
    'normal-scale': normalScale && new Vec2(normalScale).toString(),
    'normal-texture-offset': normalTextureOffset && new Vec2(normalTextureOffset).toString(),
    'normal-texture-repeat': normalTextureRepeat && new Vec2(normalTextureRepeat).toString(),
    repeat: repeat && new Vec2(repeat).toString(),
    roughness: roughness,
    'spherical-env-map': sphericalEnvMap,
    src: src,
    'vertex-a': vertexA && new Vec3(vertexA).toString(),
    'vertex-b': vertexB && new Vec3(vertexB).toString(),
    'vertex-c': vertexC && new Vec3(vertexC).toString(),
    width: width,
    wireframe: wireframe,
    'wireframe-linewidth': wireframeLinewidth
  };
}
/**
 * The triangle primitive creates triangle surfaces using the [geometry](https://aframe.io/docs/1.3.0/components/geometry.html) component with the type set to `triangle`.
 *
 * @see https://aframe.io/docs/1.3.0/primitives/a-triangle.html
 *
 * @example
 * ```tsx
 * <Scene>
 *   <Assets>
 *     <img id="platform" src="https://i.imgur.com/mYmmbrp.jpg" />
 *   </Assets>
 *
 *   // Basic triangle.
 *   <Triangle
 *     color="#CCC"
 *     vertex-c={{ x: 1, y: -1, z: 0 }}
 *   />
 *
 *   // Textured triangle parallel to ground.
 *   <Triangle
 *     src="#platform"
 *     rotation="{{ x: -90, y: 0, z: 0 }}
 *   />
 * </Scene>
 * ```
 */


export var Triangle = function Triangle(props) {
  var triangleKeys = ['ambientOcclusionMap', 'ambientOcclusionMapIntensity', 'ambientOcclusionTextureOffset', 'ambientOcclusionTextureRepeat', 'color', 'displacementBias', 'displacementMap', 'displacementScale', 'displacementTextureOffset', 'displacementTextureRepeat', 'envMap', 'fog', 'height', 'metalness', 'normalMap', 'normalScale', 'normalTextureOffset', 'normalTextureRepeat', 'repeat', 'roughness', 'sphericalEnvMap', 'src', 'vertexA', 'vertexB', 'vertexC', 'width', 'wireframe', 'wireframeLinewidth'];
  var children = props.children;
  return /*#__PURE__*/React.createElement(EventListener, _extends({
    primitive: "a-triangle"
  }, toProps(props, triangleKeys), toTriangleProps(props)), children);
};