export type ShapeArgs = { /** * - The axis of the shape (e.g., 'x', 'y', 'z'). */ axis?: string; /** * - The position of the shape. */ position?: Vec3; /** * - The rotation of the shape. */ rotation?: Vec3; /** * - The scale of the shape. */ scale?: Vec3; /** * - Whether the shape is disabled. */ disabled?: boolean; /** * - Whether the shape is visible. */ visible?: boolean; /** * - The layers the shape belongs to. */ layers?: number[]; /** * - The default color of the shape. */ defaultColor?: Color; /** * - The hover color of the shape. */ hoverColor?: Color; /** * - The disabled color of the shape. */ disabledColor?: Color; /** * - The color where the scene hides the shape, drawn first * without depth test. */ occludedColor?: Color; /** * - The culling mode of the shape. */ cull?: number; /** * - The depth of the shape. -1 = interpolated depth. */ depth?: number; }; /** * @typedef {object} ShapeArgs * @property {string} [axis] - The axis of the shape (e.g., 'x', 'y', 'z'). * @property {Vec3} [position] - The position of the shape. * @property {Vec3} [rotation] - The rotation of the shape. * @property {Vec3} [scale] - The scale of the shape. * @property {boolean} [disabled] - Whether the shape is disabled. * @property {boolean} [visible] - Whether the shape is visible. * @property {number[]} [layers] - The layers the shape belongs to. * @property {Color} [defaultColor] - The default color of the shape. * @property {Color} [hoverColor] - The hover color of the shape. * @property {Color} [disabledColor] - The disabled color of the shape. * @property {Color} [occludedColor] - The color where the scene hides the shape, drawn first * without depth test. * @property {number} [cull] - The culling mode of the shape. * @property {number} [depth] - The depth of the shape. -1 = interpolated depth. */ /** * @ignore */ export class Shape { /** * Create a shape. * * @param {GraphicsDevice} device - The graphics device. * @param {string} name - The name of the shape. * @param {ShapeArgs} args - The options for the shape. */ constructor(device: GraphicsDevice, name: string, args: ShapeArgs); /** * The position. * * @protected */ protected _position: Vec3; /** * The rotation. * * @protected */ protected _rotation: Vec3; /** * The scale. * * @protected */ protected _scale: Vec3; /** * The render component layers. * * @type {number[]} * @protected */ protected _layers: number[]; /** * The material state. * * @type {ShaderMaterial} * @protected */ protected _material: ShaderMaterial; /** * The disabled state. * * @protected */ protected _disabled: boolean; /** * The visibility state. * * @protected */ protected _visible: boolean; /** * The default color. * * @type {Color} * @protected */ protected _defaultColor: Color; /** * The hover color. * * @type {Color} * @protected */ protected _hoverColor: Color; /** * The disabled color. * * @type {Color} * @protected */ protected _disabledColor: Color; /** * The occluded color, or null for no occluded pass. * * @type {Color|null} * @protected */ protected _occludedColor: Color | null; /** * The material of the occluded pass. * * @type {ShaderMaterial|null} * @protected */ protected _occludedMaterial: ShaderMaterial | null; /** * The hover state. * * @protected */ protected _hovered: boolean; /** * The fade, a factor of the alpha of its colors. * * @protected */ protected _fade: number; /** * Uniform storage for the color. * * @type {number[]} * @protected */ protected _colorData: number[]; /** * Uniform storage for the occluded color. * * @type {number[]} * @protected */ protected _occludedColorData: number[]; /** * The culling state. * * @type {number} * @protected */ protected _cull: number; /** * The depth state. -1 = interpolated depth. * * @protected */ protected _depth: number; /** * The graphics device. * * @type {GraphicsDevice} */ device: GraphicsDevice; /** * The axis. * * @type {string} */ axis: string; /** * The entity. * * @type {Entity} */ entity: Entity; /** * The triangle data. * * @type {TriData[]} */ triData: TriData[]; /** * The mesh instances. * * @type {MeshInstance[]} */ meshInstances: MeshInstance[]; /** * The mesh instances of the occluded pass, one per entry of {@link Shape#meshInstances}. * * @type {MeshInstance[]} */ occludedMeshInstances: MeshInstance[]; /** * Set the disabled state. * * @type {boolean} */ set disabled(value: boolean); /** * Get the disabled state. * * @type {boolean} */ get disabled(): boolean; /** * Set the visibility state. * * @type {boolean} */ set visible(value: boolean); /** * Get the visibility state. * * @type {boolean} */ get visible(): boolean; /** * Set the fade, a factor of the alpha of its colors. * * @type {number} */ set fade(value: number); /** * Get the fade. * * @type {number} */ get fade(): number; /** * Gets the color for the current state, its alpha scaled by the fade and factor. * * @param {number[]} out - The array to receive the color. * @param {number} [factor] - A further factor of the alpha. * @returns {number[]} The color array. * @protected */ protected _stateColor(out: number[], factor?: number): number[]; /** * Set the depth bias, so the shape does not fight a surface it lies on. Positive values push * it away from the camera. * * @type {number} */ set depthBias(value: number); /** * Get the depth bias. * * @type {number} */ get depthBias(): number; /** * Set whether the shape writes the depth buffer where it is visible. * * @type {boolean} */ set depthWrite(value: boolean); /** * Get whether the shape writes the depth buffer where it is visible. * * @type {boolean} */ get depthWrite(): boolean; /** * Create a render component for an entity. * * @param {Entity} entity - The entity to create the render component for. * @param {Mesh[]} meshes - The meshes to create the render component with. * @protected */ protected _createRenderComponent(entity: Entity, meshes: Mesh[]): void; /** * Updates the transform. * * @protected */ protected _update(): void; /** * Sets the hover state. * * @param {boolean} state - Whether the shape is hovered. * @returns {void} */ hover(state: boolean): void; /** * Destroys the shape and its entity. * * @returns {void} */ destroy(): void; } import { Vec3 } from '../../../core/math/vec3.js'; import { Color } from '../../../core/math/color.js'; import { ShaderMaterial } from '../../../scene/materials/shader-material.js'; import type { GraphicsDevice } from '../../../platform/graphics/graphics-device.js'; import { Entity } from '../../../framework/entity.js'; import type { TriData } from './tri-data.js'; import { MeshInstance } from '../../../scene/mesh-instance.js'; import type { Mesh } from '../../../scene/mesh.js';