"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const three_module = require("../../../../../../../../node_modules/.pnpm/three@0.145.0/node_modules/three/build/three.module.js");
const lon2xyz = (R, longitude, latitude) => {
  let lon = longitude * Math.PI / 180;
  const lat = latitude * Math.PI / 180;
  lon = -lon;
  const x = R * Math.cos(lat) * Math.cos(lon);
  const y = R * Math.sin(lat);
  const z = R * Math.cos(lat) * Math.sin(lon);
  return new three_module.Vector3(x, y, z);
};
const createWaveMesh = (options) => {
  const geometry = new three_module.PlaneGeometry(1, 1);
  const texture = options.textures.aperture;
  const material = new three_module.MeshBasicMaterial({
    color: 15310696,
    map: texture,
    transparent: true,
    //使用背景透明的png贴图，注意开启透明计算
    opacity: 1,
    depthWrite: false
    //禁止写入深度缓冲区数据
  });
  const mesh = new three_module.Mesh(geometry, material);
  const coord = lon2xyz(options.radius * 1.001, options.lon, options.lat);
  const size = options.radius * 0.12;
  mesh.scale.set(size, size, size);
  mesh.userData["size"] = size;
  mesh.userData["scale"] = Math.random() * 1;
  mesh.position.set(coord.x, coord.y, coord.z);
  const coordVec3 = new three_module.Vector3(coord.x, coord.y, coord.z).normalize();
  const meshNormal = new three_module.Vector3(0, 0, 1);
  mesh.quaternion.setFromUnitVectors(meshNormal, coordVec3);
  return mesh;
};
const createLightPillar = (options) => {
  const height = options.radius * 0.3;
  const geometry = new three_module.PlaneGeometry(options.radius * 0.05, height);
  geometry.rotateX(Math.PI / 2);
  geometry.translate(0, 0, height / 2);
  const material = new three_module.MeshBasicMaterial({
    map: options.textures.light_column,
    color: options.index == 0 ? options.punctuation.lightColumn.startColor : options.punctuation.lightColumn.endColor,
    transparent: true,
    side: three_module.DoubleSide,
    depthWrite: false
    //是否对深度缓冲区有任何的影响
  });
  const mesh = new three_module.Mesh(geometry, material);
  const group = new three_module.Group();
  group.add(mesh, mesh.clone().rotateZ(Math.PI / 2));
  const SphereCoord = lon2xyz(options.radius, options.lon, options.lat);
  group.position.set(SphereCoord.x, SphereCoord.y, SphereCoord.z);
  const coordVec3 = new three_module.Vector3(SphereCoord.x, SphereCoord.y, SphereCoord.z).normalize();
  const meshNormal = new three_module.Vector3(0, 0, 1);
  group.quaternion.setFromUnitVectors(meshNormal, coordVec3);
  return group;
};
const createPointMesh = (options) => {
  const geometry = new three_module.PlaneGeometry(1, 1);
  const mesh = new three_module.Mesh(geometry, options.material);
  const coord = lon2xyz(options.radius * 1.001, options.lon, options.lat);
  const size = options.radius * 0.05;
  mesh.scale.set(size, size, size);
  mesh.position.set(coord.x, coord.y, coord.z);
  const coordVec3 = new three_module.Vector3(coord.x, coord.y, coord.z).normalize();
  const meshNormal = new three_module.Vector3(0, 0, 1);
  mesh.quaternion.setFromUnitVectors(meshNormal, coordVec3);
  return mesh;
};
const getCirclePoints = (option) => {
  const list = [];
  for (let j = 0; j < 2 * Math.PI - 0.1; j += 2 * Math.PI / (option.number || 100)) {
    list.push([
      parseFloat((Math.cos(j) * (option.radius || 10)).toFixed(2)),
      0,
      parseFloat((Math.sin(j) * (option.radius || 10)).toFixed(2))
    ]);
  }
  if (option.closed)
    list.push(list[0]);
  return list;
};
const createAnimateLine = (option) => {
  const l = [];
  option.pointList.forEach((e) => l.push(new three_module.Vector3(e[0], e[1], e[2])));
  const curve = new three_module.CatmullRomCurve3(l);
  const tubeGeometry = new three_module.TubeGeometry(curve, option.number || 50, option.radius || 1, option.radialSegments);
  return new three_module.Mesh(tubeGeometry, option.material);
};
exports.createAnimateLine = createAnimateLine;
exports.createLightPillar = createLightPillar;
exports.createPointMesh = createPointMesh;
exports.createWaveMesh = createWaveMesh;
exports.getCirclePoints = getCirclePoints;
exports.lon2xyz = lon2xyz;
