Skip to content

Commit

Permalink
Merge pull request #76 from fantasticsoul/master
Browse files Browse the repository at this point in the history
chore: add types.d.ts
  • Loading branch information
drawcall authored Oct 5, 2020
2 parents 5a523b1 + ec77e8f commit e3d2cc7
Show file tree
Hide file tree
Showing 3 changed files with 1,477 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"webgl"
],
"main": "./build/proton.min.js",
"module": "src/index.js",
"types": "src/types.d.ts",
"scripts": {
"start": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c -w -m inline\" \"serve --listen 3001\"",
"page": "node ./script/makeexamplepage",
Expand Down
33 changes: 33 additions & 0 deletions src/core/Particle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/** @typedef {import('../behaviour/Behaviour')} Behaviour */
/** @typedef {import('../math/Vector2D')} Vector2D */
/** @typedef {import('../utils/Rgb')} Rgb */
import Rgb from "../utils/Rgb";
import Puid from "../utils/Puid";
import Util from "../utils/Util";
Expand All @@ -6,6 +9,30 @@ import Vector2D from "../math/Vector2D";
import MathUtil from "../math/MathUtil";

export default class Particle {
/** @type string */
id = ''

/** @type {{p:Vector2D,v:Vector2D,a:Vector2D}} */
old = {}

/** @type {object} */
data = {}

/** @type {Behaviour[]} */
behaviours = []

/** @type {Vector2D} */
p = []

/** @type {Vector2D} */
v = []

/** @type {Vector2D} */
a = []

/** @type {Rgb} */
rgb = {}

/**
* the Particle class
*
Expand Down Expand Up @@ -99,13 +126,19 @@ export default class Particle {
}
}

/**
* @param {Behaviour} behaviour
*/
addBehaviour(behaviour) {
this.behaviours.push(behaviour);

if (behaviour.hasOwnProperty("parents")) behaviour.parents.push(this);
behaviour.initialize(this);
}

/**
* @param {Behaviour[]} behaviours
*/
addBehaviours(behaviours) {
const length = behaviours.length;
let i;
Expand Down
Loading

0 comments on commit e3d2cc7

Please sign in to comment.