123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- import { Color4 } from "../Maths/math";
- import { Mesh } from "../Meshes/mesh";
- import type { Scene, IDisposable } from "../scene";
- import { CloudPoint } from "./cloudPoint";
- import type { Material } from "../Materials/material";
- /** Defines the 4 color options */
- export declare enum PointColor {
- /** color value */
- Color = 2,
- /** uv value */
- UV = 1,
- /** random value */
- Random = 0,
- /** stated value */
- Stated = 3
- }
- /**
- * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
- * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
- * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
- * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
- *
- * Full documentation here : TO BE ENTERED
- */
- export declare class PointsCloudSystem implements IDisposable {
- /**
- * The PCS array of cloud point objects. Just access each particle as with any classic array.
- * Example : var p = SPS.particles[i];
- */
- particles: CloudPoint[];
- /**
- * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
- */
- nbParticles: number;
- /**
- * This a counter for your own usage. It's not set by any SPS functions.
- */
- counter: number;
- /**
- * The PCS name. This name is also given to the underlying mesh.
- */
- name: string;
- /**
- * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
- */
- mesh?: Mesh;
- /**
- * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
- * Please read :
- */
- vars: any;
- /**
- * @internal
- */
- _size: number;
- private _scene;
- private _promises;
- private _positions;
- private _indices;
- private _normals;
- private _colors;
- private _uvs;
- private _indices32;
- private _positions32;
- private _colors32;
- private _uvs32;
- private _updatable;
- private _isVisibilityBoxLocked;
- private _alwaysVisible;
- private _groups;
- private _groupCounter;
- private _computeParticleColor;
- private _computeParticleTexture;
- private _computeParticleRotation;
- private _computeBoundingBox;
- private _isReady;
- /**
- * Gets the particle positions computed by the Point Cloud System
- */
- get positions(): Float32Array;
- /**
- * Gets the particle colors computed by the Point Cloud System
- */
- get colors(): Float32Array;
- /**
- * Gets the particle uvs computed by the Point Cloud System
- */
- get uvs(): Float32Array;
- /**
- * Creates a PCS (Points Cloud System) object
- * @param name (String) is the PCS name, this will be the underlying mesh name
- * @param pointSize (number) is the size for each point. Has no effect on a WebGPU engine.
- * @param scene (Scene) is the scene in which the PCS is added
- * @param options defines the options of the PCS e.g.
- * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
- * @param options.updatable
- */
- constructor(name: string, pointSize: number, scene: Scene, options?: {
- updatable?: boolean;
- });
- /**
- * Builds the PCS underlying mesh. Returns a standard Mesh.
- * If no points were added to the PCS, the returned mesh is just a single point.
- * @param material The material to use to render the mesh. If not provided, will create a default one
- * @returns a promise for the created mesh
- */
- buildMeshAsync(material?: Material): Promise<Mesh>;
- /**
- * @internal
- */
- private _buildMesh;
- private _addParticle;
- private _randomUnitVector;
- private _getColorIndicesForCoord;
- private _setPointsColorOrUV;
- private _colorFromTexture;
- private _calculateDensity;
- /**
- * Adds points to the PCS in random positions within a unit sphere
- * @param nb (positive integer) the number of particles to be created from this model
- * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
- * @returns the number of groups in the system
- */
- addPoints(nb: number, pointFunction?: any): number;
- /**
- * Adds points to the PCS from the surface of the model shape
- * @param mesh is any Mesh object that will be used as a surface model for the points
- * @param nb (positive integer) the number of particles to be created from this model
- * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
- * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
- * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
- * @returns the number of groups in the system
- */
- addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
- /**
- * Adds points to the PCS inside the model shape
- * @param mesh is any Mesh object that will be used as a surface model for the points
- * @param nb (positive integer) the number of particles to be created from this model
- * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
- * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
- * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
- * @returns the number of groups in the system
- */
- addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
- /**
- * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
- * This method calls `updateParticle()` for each particle of the SPS.
- * For an animated SPS, it is usually called within the render loop.
- * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
- * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
- * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
- * @returns the PCS.
- */
- setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
- /**
- * Disposes the PCS.
- */
- dispose(): void;
- /**
- * Visibility helper : Recomputes the visible size according to the mesh bounding box
- * doc :
- * @returns the PCS.
- */
- refreshVisibleSize(): PointsCloudSystem;
- /**
- * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
- * @param size the size (float) of the visibility box
- * note : this doesn't lock the PCS mesh bounding box.
- * doc :
- */
- setVisibilityBox(size: number): void;
- /**
- * Gets whether the PCS is always visible or not
- * doc :
- */
- get isAlwaysVisible(): boolean;
- /**
- * Sets the PCS as always visible or not
- * doc :
- */
- set isAlwaysVisible(val: boolean);
- /**
- * Tells to `setParticles()` to compute the particle rotations or not
- * Default value : false. The PCS is faster when it's set to false
- * Note : particle rotations are only applied to parent particles
- * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
- */
- set computeParticleRotation(val: boolean);
- /**
- * Tells to `setParticles()` to compute the particle colors or not.
- * Default value : true. The PCS is faster when it's set to false.
- * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
- */
- set computeParticleColor(val: boolean);
- set computeParticleTexture(val: boolean);
- /**
- * Gets if `setParticles()` computes the particle colors or not.
- * Default value : false. The PCS is faster when it's set to false.
- * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
- */
- get computeParticleColor(): boolean;
- /**
- * Gets if `setParticles()` computes the particle textures or not.
- * Default value : false. The PCS is faster when it's set to false.
- * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
- */
- get computeParticleTexture(): boolean;
- /**
- * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
- */
- set computeBoundingBox(val: boolean);
- /**
- * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
- */
- get computeBoundingBox(): boolean;
- /**
- * This function does nothing. It may be overwritten to set all the particle first values.
- * The PCS doesn't call this function, you may have to call it by your own.
- * doc :
- */
- initParticles(): void;
- /**
- * This function does nothing. It may be overwritten to recycle a particle
- * The PCS doesn't call this function, you can to call it
- * doc :
- * @param particle The particle to recycle
- * @returns the recycled particle
- */
- recycleParticle(particle: CloudPoint): CloudPoint;
- /**
- * Updates a particle : this function should be overwritten by the user.
- * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
- * doc :
- * @example : just set a particle position or velocity and recycle conditions
- * @param particle The particle to update
- * @returns the updated particle
- */
- updateParticle(particle: CloudPoint): CloudPoint;
- /**
- * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
- * This does nothing and may be overwritten by the user.
- * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
- * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
- * @param update the boolean update value actually passed to setParticles()
- */
- beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
- /**
- * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
- * This will be passed three parameters.
- * This does nothing and may be overwritten by the user.
- * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
- * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
- * @param update the boolean update value actually passed to setParticles()
- */
- afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
- }
|