/** * Draws the shape of each attached light entity: an arrow for a directional light, sized by * {@link Gizmo#size}, the range of an omni light, the cone of a spot light, and the shape of an area * light. Handles drag the range, cone angles or area size, which sets the entity's local scale. * Disabled entities are skipped, but a disabled light component is still drawn. * * ```javascript * const layer = Gizmo.createLayer(app, 'Overlays', undefined, true); * const gizmo = new LightGizmo(cameraComponent, layer); * gizmo.attach([lightEntity]); * ``` * * Relevant Engine API examples: * * - [Light Gizmo](https://playcanvas.github.io/#/gizmos/light) * * @category Gizmo */ export class LightGizmo extends HandleGizmo { /** * Creates a new LightGizmo object. * * @param {CameraComponent} camera - The camera component. * @param {Layer} layer - The render layer. * @example * const gizmo = new LightGizmo(camera, layer); */ constructor(camera: CameraComponent, layer: Layer); /** * Whether to draw a dashed line from each local light down to the plane y = 0. Defaults to * false. * * @type {boolean} */ groundLine: boolean; /** * Whether to draw each light in its own color. Defaults to false. * * @type {boolean} */ useLightColor: boolean; /** * The local scale of the dragged light at the start of the drag. * * @private */ private _startScale; /** * The world scale of the dragged light at the start of the drag. * * @private */ private _startWorldScale; /** * The world scale of the dragged light's parent at the start of the drag. * * @private */ private _startParentScale; /** * Places a dashed line from a light down to the ground. * * @param {Vec3} pos - The light position. * @private */ private _ground; /** * Places rays along the direction a light shines. * * @param {Entity} entity - The light entity. * @param {Vec3[]} starts - The world start points. * @param {number} count - The number of rays. * @param {number} length - The ray length. * @param {number} [weight] - The thickness as a factor of the line thickness. * @param {number} [alpha] - The alpha factor. * @private */ private _rays; /** * Gets a point of a circle in the xz plane of an entity. * * @param {Entity} entity - The entity. * @param {Vec3} center - The circle center. * @param {number} radius - The circle radius. * @param {number} angle - The angle in radians. * @param {Vec3} out - The point. * @returns {Vec3} The point. * @private */ private _circlePoint; /** * Gets whether a light renders with an area shape. * * @param {LightComponent} light - The light. * @returns {boolean} Whether the light has an area shape. * @private */ private _isArea; /** * Places the area shape of a light, sized by the entity scale. * * @param {LightComponent} light - The light to draw. * @returns {boolean} False if the light renders as a punctual light. * @private */ private _drawArea; /** * Places the cone of a spot light, capped by arcs of its range. * * @param {LightComponent} light - The light to draw. * @private */ private _drawSpot; /** * Places an arrow through a disc of parallel rays, a constant size on screen. * * @param {LightComponent} light - The light to draw. * @private */ private _drawDirectional; /** * Places the outline of an omni light's range. * * @param {LightComponent} light - The light to draw. * @private */ private _drawOmni; } import { HandleGizmo } from './handle-gizmo.js'; import type { CameraComponent } from '../../../framework/components/camera/component.js'; import type { Layer } from '../../../scene/layer.js';