/** * The clipping of a mesh instance, a camera or a render component: its planes, whether they clip * by intersection, and the uniforms the clipPlanesPS chunk reads. * * It keeps the planes as last assigned, which the owner uses, apart from the copies the getter of * the owner returns, which can be changed and assigned again. It owns the planes of both, and * their normals, so the entries of the returned array are independent copies after each * assignment, whatever had been put into the array or its planes. * * @ignore */ export class ClipPlanes { /** * The planes as last assigned. They are not exposed, so only assignments change them. * * @type {Plane[]} */ assigned: Plane[]; /** * Copies of the assigned planes, which the getter of the owner returns. * * @type {Plane[]} */ returned: Plane[]; /** * Whether only the parts behind all of the planes are clipped, instead of the parts behind any * of them. * * @type {boolean} */ intersection: boolean; /** * The assigned planes as the uniform the shader reads, (normal, distance) per plane. Allocated * by the first {@link ClipPlanes#updateUniforms}. * * @type {Float32Array|null} */ planesData: Float32Array | null; /** * The number of assigned planes, and 1 for intersection clipping, as the uniform the shader * reads. Allocated by the first {@link ClipPlanes#updateUniforms}. * * @type {Float32Array|null} */ paramsData: Float32Array | null; /** * The planes owned for {@link ClipPlanes#assigned}, kept when there are fewer planes. * * @type {Plane[]} * @private */ private _assignedPlanes; /** * The planes owned for {@link ClipPlanes#returned}, kept when there are fewer planes. * * @type {Plane[]} * @private */ private _returnedPlanes; /** * The normals of {@link ClipPlanes#_returnedPlanes}. The normal of a returned plane can be * replaced through the returned array, so each assignment gives the plane its own back. * * @type {Vec3[]} * @private */ private _returnedNormals; /** * Assigns planes, which can include planes of the returned array, in any order. * * @param {Plane[]|null|undefined} planes - The planes. * @param {number} [maxCount] - The largest number of planes to keep. */ set(planes: Plane[] | null | undefined, maxCount?: number): void; /** * Copies the assigned planes and the mode of other clipping, or removes the planes and resets * the mode when there is none. * * @param {ClipPlanes|null} other - The clipping to copy, or null for none. * @returns {ClipPlanes} Self for chaining. */ copy(other: ClipPlanes | null): ClipPlanes; /** * Writes the assigned planes and the mode into the uniform data, allocating it on first use. */ updateUniforms(): void; } /** * @import { Vec3 } from '../core/math/vec3.js' */ export const MAX_CLIP_PLANES: 8; import { Plane } from '../core/shape/plane.js';