ParticleBase

ParticleBase

new ParticleBase()

Description:
  • Default Particle System Class

    Outputs a basic system expecting uniforms, vertex shader, and fragment shader to be passed into build()

Source:

Classes

ParticleBase

Members

knownKeys :Array.<string>

Description:
  • Known keys for shader settings.

Source:

Known keys for shader settings.

Type:
  • Array.<string>

shaderSettings :Object

Description:
  • Shader settings for the floating dust particles.

Source:
Properties:
Name Type Description
vertCount number

Number of vertices.

pScale number

Scale of the particles.

atlasRes number

Atlas resolution.

atlasPicks Array

Atlas picks.

randomAtlas boolean

Random atlas flag.

additiveBlend boolean

Additive blending flag.

hasLights boolean

Lights flag.

Shader settings for the floating dust particles.

Type:
  • Object

Methods

addToScene(vertexCount, pScale, atlasRes, atlasPicks) → {Object}

Description:
  • Add the particle system to the scene.

Source:
Parameters:
Name Type Description
vertexCount number

The number of vertices.

pScale number

The scale of the particles.

atlasRes number

The atlas resolution.

atlasPicks Array

The atlas picks.

Returns:

The particle system added to the scene.

Type
Object

atlasArrayPicker(arr) → {Array}

Description:
  • Pick a random atlas value from an array.

Source:
Example
// Pick a random atlas value from an array
import { pxlNav } from 'pxlNav.esm.js';
const pxlParticleBase = pxlNav.pxlEffects.pxlParticles.pxlParticle

build(){
  pxlParticleBase.atlasArrayPicker( [ [0.0,0.75], [0.0,0.5], [0.25,0.75], [0.25,0.5] ] );
  // Output 1: [0.0,0.75]
  // Output 2: [0.0,0.5]
  // Output 3: [0.25,0.75]
  // Output 4: [0.0,0.5]
}
Parameters:
Name Type Description
arr Array

The array of atlas values.

Returns:

A random atlas value from the array.

Type
Array

atlasRandomGen(atlasResopt, dSizeopt) → {Array}

Description:
  • Generate random atlas values.

Source:
Example
// Generate random atlas values
import { pxlNav } from 'pxlNav.esm.js';
const pxlParticleBase = pxlNav.pxlEffects.pxlParticles.pxlParticle

build(){
 pxlParticleBase.atlasRandomGen( 4, 2 );
// Output: [0.0,0.75]
}
Parameters:
Name Type Attributes Default Description
atlasRes number <optional>
4

The atlas resolution.

dSize number <optional>
2

The size of the atlas.

Returns:

Random atlas values.

Type
Array

atlasRandomList(countopt, resopt, sizeopt) → {Array}

Description:
  • Generate a list of random atlas values.

Source:
Example
// Generate a list of random atlas values
import { pxlNav } from 'pxlNav.esm.js';
const pxlParticleBase = pxlNav.pxlEffects.pxlParticles.pxlParticle

build(){
  pxlParticleBase.atlasRandomList( 4, 4, 2 );
  // Output: [ [0.0,0.75], [0.0,0.5], [0.25,0.75], [0.25,0.5] ]
}
Parameters:
Name Type Attributes Default Description
count number <optional>
4

The number of random atlas values to generate.

res number <optional>
4

The atlas resolution.

size number <optional>
2

The size of the atlas.

Returns:

A list of random atlas values.

Type
Array

build(curShaderSettingsopt, vertShaderopt, fragShaderopt)

Description:
  • Build the particle system with the given shader settings.

Source:
Parameters:
Name Type Attributes Default Description
curShaderSettings Object <optional>
{}

Current shader settings to override the default settings.

vertShader string <optional>
null

The vertex shader for the particle system.

fragShader string <optional>
null

The fragment shader for the particle system.

dupeArray(val, count) → {Array}

Description:
  • Duplicate an array.

Source:
Example
// Duplicate an array
import { pxlNav } from 'pxlNav.esm.js';
const pxlParticleBase = pxlNav.pxlEffects.pxlParticles.pxlParticle

build(){
 pxlParticleBase.dupeArray( [0.0,0.75], 4 );
 // Output: [0.0,0.75], [0.0,0.75], [0.0,0.75], [0.0,0.75]
}
Parameters:
Name Type Description
val Array

The array to duplicate.

count number

The number of times to duplicate the array.

Returns:

The duplicated array.

Type
Array

elementDuplicator(arr, countopt) → {Array}

Description:
  • Duplicate an element in an array.

Source:
Example
// Duplicate an element in an array
import { pxlNav } from 'pxlNav.esm.js';
const pxlParticleBase = pxlNav.pxlEffects.pxlParticles.pxlParticle

build(){
  pxlParticleBase.elementDuplicator([ [0.0,0.75], [0.0,0.5], [0.25,0.75], [0.25,0.5] ],4);
  // Output: [
  //    [0.0,0.75], [0.0,0.75], [0.0,0.75], [0.0,0.75],
  //    [0.0,0.5], [0.0,0.5], [0.0,0.5], [0.0,0.5],   
  //    [0.25,0.75], [0.25,0.75], [0.25,0.75], [0.25,0.75], 
  //    [0.25,0.5], [0.25,0.5], [0.25,0.5], [0.25,0.5]
  // ]
}
Parameters:
Name Type Attributes Default Description
arr Array

The array to duplicate.

count number <optional>
4

The number of times to duplicate the array.

Returns:

The duplicated array.

Type
Array

getSettings() → {Object}

Description:
  • Set the shader settings for the particle system.

Source:
Returns:

The shader settings for the particle system.

Type
Object

hasPointLights() → {boolean}

Description:
  • Check if the room has point lights.

Source:
Returns:

Flag for whether the room has point lights.

Type
boolean

newMaterial(mtl) → {void}

Description:
  • Set the material for the particle system.

Source:
Example
// Run from your pxlRoom javascript file
// Create an Atlas Material
import { SphereGeometry, Mesh } from 'three';

build(){
 let sphere = new SphereGeometry( 1, 32, 32 );
 let mtl = pxlNav.pxlEffects.pxlParticles.pxlParticleBase.newMaterial();
 let mesh = new Mesh( sphere, mtl );
 this.scene.add( mesh );
}
Parameters:
Name Type Description
mtl Material

The material for the particle system.

Returns:
Type
void

setAtlasPath(path, alphaPathopt) → {void}

Description:
  • Set the path for the atlas texture file.

Source:
Example
// Run from your pxlRoom javascript file
// Set the path for the atlas texture file
build(){
let dust = pxlNav.pxlEffects.pxlParticles.pxlParticleBase.newParticle();
dust.setAtlasPath( "sprite_dustAtlas_rgb.jpg", "sprite_dustAtlas_alpha.jpg" );
}
Parameters:
Name Type Attributes Default Description
path string

The path to the atlas texture file.

alphaPath string <optional>
null

The path to the atlas alpha texture

Returns:
Type
void

setPosition(position)

Description:
  • Set the position of the particle system.

Source:
Parameters:
Name Type Description
position Vector3

The position of the particle system.