playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
83 lines (82 loc) • 2.86 kB
TypeScript
/**
* @import { Entity } from '../../entity.js'
* @import { ZoneComponentSystem } from './system.js'
*/
/**
* The ZoneComponent enables an {@link Entity} to define a box-shaped area in world space of a
* certain size. Zones are a building block that can be used in various ways, such as affecting
* audio reverb when an {@link AudioListenerComponent} is within the zone, or creating a culling
* system with portals between zones to hide whole indoor sections for performance reasons.
*
* @ignore
*/
export class ZoneComponent extends Component {
/**
* Fired when the zone component is enabled. This event does not take into account the enabled
* state of the entity or any of its ancestors.
*
* @event
* @example
* entity.zone.on('enable', () => {
* console.log(`Zone component of entity '${entity.name}' has been enabled`);
* });
*/
static EVENT_ENABLE: string;
/**
* Fired when the zone component is disabled. This event does not take into account the enabled
* state of the entity or any of its ancestors.
*
* @event
* @example
* entity.zone.on('disable', () => {
* console.log(`Zone component of entity '${entity.name}' has been disabled`);
* });
*/
static EVENT_DISABLE: string;
/**
* Fired when the enabled state of the zone component changes. This event does not take into
* account the enabled state of the entity or any of its ancestors.
*
* @event
* @example
* entity.zone.on('state', (enabled) => {
* console.log(`Zone component of entity '${entity.name}' has been ${enabled ? 'enabled' : 'disabled'}`);
* });
*/
static EVENT_STATE: string;
/**
* Fired when a zone component is removed from an entity.
*
* @event
* @example
* entity.zone.on('remove', () => {
* console.log(`Zone component removed from entity '${entity.name}'`);
* });
*/
static EVENT_REMOVE: string;
/**
* Create a new ZoneComponent instance.
*
* @param {ZoneComponentSystem} system - The ComponentSystem that created this Component.
* @param {Entity} entity - The Entity that this Component is attached to.
*/
constructor(system: ZoneComponentSystem, entity: Entity);
/** @private */
private _oldState;
/** @private */
private _size;
/**
* The size of the axis-aligned box of this ZoneComponent.
*
* @type {Vec3}
*/
set size(data: Vec3);
get size(): Vec3;
_onSetEnabled(prop: any, old: any, value: any): void;
_checkState(): void;
_onBeforeRemove(): void;
}
import { Component } from '../component.js';
import { Vec3 } from '../../../core/math/vec3.js';
import type { ZoneComponentSystem } from './system.js';
import type { Entity } from '../../entity.js';