hemisphereBuilder.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Mesh } from "../mesh.js";
  2. import { CreateSphere } from "../Builders/sphereBuilder.js";
  3. import { CreateDisc } from "./discBuilder.js";
  4. /**
  5. * Creates a hemisphere mesh
  6. * @param name defines the name of the mesh
  7. * @param options defines the options used to create the mesh
  8. * @param scene defines the hosting scene
  9. * @returns the hemisphere mesh
  10. */
  11. export function CreateHemisphere(name, options = {}, scene) {
  12. if (!options.diameter) {
  13. options.diameter = 1;
  14. }
  15. if (!options.segments) {
  16. options.segments = 16;
  17. }
  18. const halfSphere = CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  19. const disc = CreateDisc("", { radius: options.diameter / 2, tessellation: options.segments * 3 + (4 - options.segments) }, scene);
  20. disc.rotation.x = -Math.PI / 2;
  21. disc.parent = halfSphere;
  22. const merged = Mesh.MergeMeshes([disc, halfSphere], true);
  23. merged.name = name;
  24. return merged;
  25. }
  26. /**
  27. * Class containing static functions to help procedurally build meshes
  28. * @deprecated use the function directly from the module
  29. */
  30. export const HemisphereBuilder = {
  31. // eslint-disable-next-line @typescript-eslint/naming-convention
  32. CreateHemisphere,
  33. };
  34. /**
  35. * Creates a hemispheric light
  36. * @param name
  37. * @param segments
  38. * @param diameter
  39. * @param scene
  40. * @returns the mesh
  41. */
  42. Mesh.CreateHemisphere = (name, segments, diameter, scene) => {
  43. const options = {
  44. segments: segments,
  45. diameter: diameter,
  46. };
  47. return CreateHemisphere(name, options, scene);
  48. };
  49. //# sourceMappingURL=hemisphereBuilder.js.map