r3f-points-fx
Version:
React three fiber component for easily creating high performance particles meshes. Makes particles morphing from one arrangement to another a piece of cake.
93 lines (92 loc) • 2.93 kB
TypeScript
import { ThreeElements } from '@react-three/fiber';
import * as React from 'react';
import * as THREE from 'three';
type uniforms = {
[name: string]: THREE.Color | THREE.CubeTexture | THREE.DataTexture | THREE.Matrix3 | THREE.Matrix4 | THREE.Quaternion | THREE.Texture | THREE.Vector2 | THREE.Vector3 | THREE.Vector4 | boolean | number | null;
};
export type attribute = {
attach: string;
array: THREE.TypedArray;
itemSize: number;
};
export type R3FPointsPropsType = ThreeElements['points'] & {
/**
* An array of THREE.Mesh objects to be used as models for the particle system.
*/
models: THREE.Mesh[];
/**
* The number of points (particles) to be rendered.
* @default 1000
*/
pointsCount?: number;
/**
* The index of the model in the `models` array to be used as the starting model (modelA).
* @default null
*/
modelA?: number | null;
/**
* The index of the model in the `models` array to be used as the ending model (modelB).
* @default null
*/
modelB?: number | null;
/**
* An object of uniforms to be passed to the shaders.
* @default {}
*/
uniforms?: uniforms;
/**
* The base color of the particles.
* @default new THREE.Color(0, 0, 0)
*/
baseColor?: THREE.Color;
/**
* The size of the particles.
* @default 0.1
*/
pointSize?: number;
/**
* The alpha (transparency) of the particles.
* @default 1
*/
alpha?: number;
/**
* An array of custom attributes to be passed to the shaders.
*/
attributes?: attribute[];
/**
* The blending mode to be used for the particles.
* @default THREE.AdditiveBlending
*/
blending?: THREE.Blending;
/**
* A string of GLSL code to be injected into the vertex shader.
*/
vertexModifier?: string;
/**
* A string of GLSL code to be injected into the fragment shader.
*/
fragmentModifier?: string;
/**
* A string of GLSL code to be injected into the FBO fragment shader to modify the transition progress.
*/
progressModifier?: string;
/**
* Whether the particle size should be attenuated by the distance from the camera.
* @default true
*/
sizeAttenutation?: boolean;
/**
* An array of indexes of models that should have their particles arranged in an organized manner.
*/
organizedParticleIndexes?: number[];
};
export type R3FPointsFXRefType = {
getSimulationMesh: () => THREE.Mesh | null;
getPointsMesh: () => THREE.Points | null;
updateProgress: (progress: number) => void;
updateTime: (time: number) => void;
setModelA: (index: number) => void;
setModelB: (index: number) => void;
};
export declare const R3FPointsFX: React.ForwardRefExoticComponent<Omit<R3FPointsPropsType, "ref"> & React.RefAttributes<R3FPointsFXRefType>>;
export {};