UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

61 lines 2.03 kB
/** This file must only contain pure code and pure imports */ import { Mesh } from "../mesh.pure.js"; import { CreateSphere } from "../Builders/sphereBuilder.pure.js"; import { CreateDisc } from "./discBuilder.pure.js"; /** * Creates a hemisphere mesh * @param name defines the name of the mesh * @param options defines the options used to create the mesh * @param scene defines the hosting scene * @returns the hemisphere mesh */ export function CreateHemisphere(name, options = {}, scene) { if (!options.diameter) { options.diameter = 1; } if (!options.segments) { options.segments = 16; } const halfSphere = CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene); const disc = CreateDisc("", { radius: options.diameter / 2, tessellation: options.segments * 3 + (4 - options.segments) }, scene); disc.rotation.x = -Math.PI / 2; disc.parent = halfSphere; const merged = Mesh.MergeMeshes([disc, halfSphere], true); merged.name = name; return merged; } /** * Class containing static functions to help procedurally build meshes * @deprecated use the function directly from the module */ export const HemisphereBuilder = { // eslint-disable-next-line @typescript-eslint/naming-convention CreateHemisphere, }; let _Registered = false; /** * Register side effects for hemisphereBuilder. * Safe to call multiple times; only the first call has an effect. */ export function RegisterHemisphereBuilder() { if (_Registered) { return; } _Registered = true; /** * Creates a hemispheric light * @param name * @param segments * @param diameter * @param scene * @returns the mesh */ Mesh.CreateHemisphere = (name, segments, diameter, scene) => { const options = { segments: segments, diameter: diameter, }; return CreateHemisphere(name, options, scene); }; } //# sourceMappingURL=hemisphereBuilder.pure.js.map