UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

112 lines (111 loc) 4.95 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); import { Vec3 } from "../../../core/math/vec3.js"; import { BLEND_NORMAL, EMITTERSHAPE_BOX, LAYERID_WORLD, PARTICLEMODE_GPU, PARTICLEORIENTATION_SCREEN } from "../../../scene/constants.js"; class ParticleSystemComponentData { constructor() { __publicField(this, "numParticles", 1); // Amount of particles allocated (max particles = max GL texture width at this moment) __publicField(this, "rate", 1); // Emission rate /** @type {number|null} */ __publicField(this, "rate2", null); __publicField(this, "startAngle", 0); /** @type {number|null} */ __publicField(this, "startAngle2", null); __publicField(this, "lifetime", 50); // Particle lifetime __publicField(this, "emitterExtents", new Vec3()); // Spawn point divergence __publicField(this, "emitterExtentsInner", new Vec3()); __publicField(this, "emitterRadius", 0); __publicField(this, "emitterRadiusInner", 0); __publicField(this, "emitterShape", EMITTERSHAPE_BOX); __publicField(this, "initialVelocity", 0); __publicField(this, "wrap", false); __publicField(this, "wrapBounds", new Vec3()); __publicField(this, "localSpace", false); __publicField(this, "screenSpace", false); /** @type {Texture|null} */ __publicField(this, "colorMap", null); /** @type {Asset|null} */ __publicField(this, "colorMapAsset", null); /** @type {Texture|null} */ __publicField(this, "normalMap", null); /** @type {Asset|null} */ __publicField(this, "normalMapAsset", null); __publicField(this, "loop", true); __publicField(this, "preWarm", false); __publicField(this, "sort", 0); // Sorting mode: 0 = none, 1 = by distance, 2 = by life, 3 = by -life; Forces CPU mode if not 0 __publicField(this, "mode", PARTICLEMODE_GPU); __publicField(this, "scene", null); __publicField(this, "lighting", false); __publicField(this, "halfLambert", false); // Uses half-lambert lighting instead of Lambert __publicField(this, "intensity", 1); __publicField(this, "stretch", 0); __publicField(this, "alignToMotion", false); __publicField(this, "depthSoftening", 0); /** @type {Asset|null} */ __publicField(this, "renderAsset", null); /** @type {Asset|null} */ __publicField(this, "meshAsset", null); /** @type {Mesh|null} */ __publicField(this, "mesh", null); // Mesh to be used as particle. Vertex buffer is supposed to hold vertex position in first 3 floats of each vertex // Leave undefined to use simple quads __publicField(this, "depthWrite", false); __publicField(this, "noFog", false); __publicField(this, "orientation", PARTICLEORIENTATION_SCREEN); __publicField(this, "particleNormal", new Vec3(0, 1, 0)); __publicField(this, "animTilesX", 1); __publicField(this, "animTilesY", 1); __publicField(this, "animStartFrame", 0); __publicField(this, "animNumFrames", 1); __publicField(this, "animNumAnimations", 1); __publicField(this, "animIndex", 0); __publicField(this, "randomizeAnimIndex", false); __publicField(this, "animSpeed", 1); __publicField(this, "animLoop", true); // Time-dependent parameters /** @type {Curve|null} */ __publicField(this, "scaleGraph", null); /** @type {Curve|null} */ __publicField(this, "scaleGraph2", null); /** @type {CurveSet|null} */ __publicField(this, "colorGraph", null); /** @type {CurveSet|null} */ __publicField(this, "colorGraph2", null); /** @type {Curve|null} */ __publicField(this, "alphaGraph", null); /** @type {Curve|null} */ __publicField(this, "alphaGraph2", null); /** @type {CurveSet|null} */ __publicField(this, "localVelocityGraph", null); /** @type {CurveSet|null} */ __publicField(this, "localVelocityGraph2", null); /** @type {CurveSet|null} */ __publicField(this, "velocityGraph", null); /** @type {CurveSet|null} */ __publicField(this, "velocityGraph2", null); /** @type {Curve|null} */ __publicField(this, "rotationSpeedGraph", null); /** @type {Curve|null} */ __publicField(this, "rotationSpeedGraph2", null); /** @type {Curve|null} */ __publicField(this, "radialSpeedGraph", null); /** @type {Curve|null} */ __publicField(this, "radialSpeedGraph2", null); __publicField(this, "blendType", BLEND_NORMAL); __publicField(this, "enabled", true); __publicField(this, "paused", false); __publicField(this, "autoPlay", true); __publicField(this, "layers", [LAYERID_WORLD]); } // assign to the default world layer } export { ParticleSystemComponentData };