sparcoon 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,13 @@
3
3
  [![npm](https://img.shields.io/npm/v/sparcoon.svg)](https://www.npmjs.com/package/sparcoon)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- Instanced-mesh particle system for Three.js. WebGL 1 compatible. **[EDITOR](https://jango-git.github.io/sparcoon/)**
6
+ Instanced-mesh particle system for Three.js.
7
+
8
+ ## Editor
9
+
10
+ Interactive visual **[EDITOR](https://jango-git.github.io/sparcoon/)**
11
+
12
+ ![Editor](assets/editor.jpg)
7
13
 
8
14
  ## API
9
15
 
@@ -0,0 +1,13 @@
1
+ import type { Vector3Like } from "../../miscellaneous/math";
2
+ import type { FXVector3Config } from "../../miscellaneous/miscellaneous";
3
+ import { FXSpawn } from "./FXSpawn";
4
+ export declare class FXSpawnOffset extends FXSpawn<{
5
+ builtin: "Matrix4";
6
+ }> {
7
+ private offsetInternal;
8
+ constructor(offset?: FXVector3Config);
9
+ /** Particle position offset */
10
+ get offset(): Vector3Like;
11
+ /** Particle position offset */
12
+ set offset(value: FXVector3Config);
13
+ }
@@ -0,0 +1,41 @@
1
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
2
+ import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../../miscellaneous/miscellaneous.js';
3
+ import { FXSpawn } from './FXSpawn.js';
4
+
5
+ class FXSpawnOffset extends FXSpawn {
6
+ constructor(offset = { x: 0, y: 0, z: 0 }) {
7
+ super();
8
+ /** @internal */
9
+ this.requiredProperties = { builtin: "Matrix4" };
10
+ this._private_offsetInternal = resolveFXVector3Config(offset);
11
+ assertValidNumber(this._private_offsetInternal.x, "FXSpawnOffset.constructor.offset.x");
12
+ assertValidNumber(this._private_offsetInternal.y, "FXSpawnOffset.constructor.offset.y");
13
+ assertValidNumber(this._private_offsetInternal.z, "FXSpawnOffset.constructor.offset.z");
14
+ }
15
+ /** Particle position offset */
16
+ get offset() {
17
+ return this._private_offsetInternal;
18
+ }
19
+ /** Particle position offset */
20
+ set offset(value) {
21
+ this._private_offsetInternal = resolveFXVector3Config(value);
22
+ assertValidNumber(this._private_offsetInternal.x, "FXSpawnOffset.offset.x");
23
+ assertValidNumber(this._private_offsetInternal.y, "FXSpawnOffset.offset.y");
24
+ assertValidNumber(this._private_offsetInternal.z, "FXSpawnOffset.offset.z");
25
+ }
26
+ /** @internal */
27
+ spawn(properties, instanceBegin, instanceEnd) {
28
+ const { builtin } = properties;
29
+ const { array, itemSize } = builtin;
30
+ const { x: offsetX, y: offsetY, z: offsetZ } = this._private_offsetInternal;
31
+ for (let i = instanceBegin; i < instanceEnd; i++) {
32
+ const itemOffset = i * itemSize;
33
+ array[itemOffset + BUILTIN_OFFSET_POSITION_X] += offsetX;
34
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Y] += offsetY;
35
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Z] += offsetZ;
36
+ }
37
+ builtin.needsUpdate = true;
38
+ }
39
+ }
40
+
41
+ export { FXSpawnOffset };
@@ -1,21 +1,11 @@
1
1
  import type { Vector3Like } from "../../miscellaneous/math";
2
2
  import type { FXVector3Config } from "../../miscellaneous/miscellaneous";
3
3
  import { FXSpawn } from "./FXSpawn";
4
- /**
5
- * Sets particle spawn position offset.
6
- *
7
- * All particles spawned with this module start at the specified position.
8
- */
9
4
  export declare class FXSpawnPoint extends FXSpawn<{
10
5
  builtin: "Matrix4";
11
6
  }> {
12
- private offsetInternal;
13
- /**
14
- * @param offset - Initial particle position offset
15
- */
16
- constructor(offset?: FXVector3Config);
17
- /** Particle position offset */
18
- get offset(): Vector3Like;
19
- /** Particle position offset */
20
- set offset(value: FXVector3Config);
7
+ private positionInternal;
8
+ constructor(position?: FXVector3Config);
9
+ get position(): Vector3Like;
10
+ set position(value: FXVector3Config);
21
11
  }
@@ -2,45 +2,35 @@ import { assertValidNumber } from '../../miscellaneous/asserts.js';
2
2
  import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../../miscellaneous/miscellaneous.js';
3
3
  import { FXSpawn } from './FXSpawn.js';
4
4
 
5
- /**
6
- * Sets particle spawn position offset.
7
- *
8
- * All particles spawned with this module start at the specified position.
9
- */
10
5
  class FXSpawnPoint extends FXSpawn {
11
- /**
12
- * @param offset - Initial particle position offset
13
- */
14
- constructor(offset = { x: 0, y: 0, z: 0 }) {
6
+ constructor(position = { x: 0, y: 0, z: 0 }) {
15
7
  super();
16
8
  /** @internal */
17
9
  this.requiredProperties = { builtin: "Matrix4" };
18
- this._private_offsetInternal = resolveFXVector3Config(offset);
19
- assertValidNumber(this._private_offsetInternal.x, "FXSpawnOffset.constructor.offset.x");
20
- assertValidNumber(this._private_offsetInternal.y, "FXSpawnOffset.constructor.offset.y");
21
- assertValidNumber(this._private_offsetInternal.z, "FXSpawnOffset.constructor.offset.z");
10
+ this._private_positionInternal = resolveFXVector3Config(position);
11
+ assertValidNumber(this._private_positionInternal.x, "FXSpawnPoint.constructor.position.x");
12
+ assertValidNumber(this._private_positionInternal.y, "FXSpawnPoint.constructor.position.y");
13
+ assertValidNumber(this._private_positionInternal.z, "FXSpawnPoint.constructor.position.z");
22
14
  }
23
- /** Particle position offset */
24
- get offset() {
25
- return this._private_offsetInternal;
15
+ get position() {
16
+ return this._private_positionInternal;
26
17
  }
27
- /** Particle position offset */
28
- set offset(value) {
29
- this._private_offsetInternal = resolveFXVector3Config(value);
30
- assertValidNumber(this._private_offsetInternal.x, "FXSpawnOffset.offset.x");
31
- assertValidNumber(this._private_offsetInternal.y, "FXSpawnOffset.offset.y");
32
- assertValidNumber(this._private_offsetInternal.z, "FXSpawnOffset.offset.z");
18
+ set position(value) {
19
+ this._private_positionInternal = resolveFXVector3Config(value);
20
+ assertValidNumber(this._private_positionInternal.x, "FXSpawnPoint.position.x");
21
+ assertValidNumber(this._private_positionInternal.y, "FXSpawnPoint.position.y");
22
+ assertValidNumber(this._private_positionInternal.z, "FXSpawnPoint.position.z");
33
23
  }
34
24
  /** @internal */
35
25
  spawn(properties, instanceBegin, instanceEnd) {
36
26
  const { builtin } = properties;
37
27
  const { array, itemSize } = builtin;
38
- const { x: offsetX, y: offsetY, z: offsetZ } = this._private_offsetInternal;
28
+ const { x: positionX, y: positionY, z: positionZ } = this._private_positionInternal;
39
29
  for (let i = instanceBegin; i < instanceEnd; i++) {
40
30
  const itemOffset = i * itemSize;
41
- array[itemOffset + BUILTIN_OFFSET_POSITION_X] = offsetX;
42
- array[itemOffset + BUILTIN_OFFSET_POSITION_Y] = offsetY;
43
- array[itemOffset + BUILTIN_OFFSET_POSITION_Z] = offsetZ;
31
+ array[itemOffset + BUILTIN_OFFSET_POSITION_X] = positionX;
32
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Y] = positionY;
33
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Z] = positionZ;
44
34
  }
45
35
  builtin.needsUpdate = true;
46
36
  }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@ export { FXBehaviorVelocityDamping } from "./emitter/behavior/FXBehaviorVelocity
7
7
  export { FXBehaviorVelocityNoise } from "./emitter/behavior/FXBehaviorVelocityNoise";
8
8
  export { FXEmitter } from "./emitter/FXEmitter";
9
9
  export { FXSpawnBox } from "./emitter/spawn/FXSpawnBox";
10
- export { FXSpawnPoint as FXSpawnOffset } from "./emitter/spawn/FXSpawnPoint";
10
+ export { FXSpawnOffset } from "./emitter/spawn/FXSpawnOffset";
11
+ export { FXSpawnPoint } from "./emitter/spawn/FXSpawnPoint";
11
12
  export { FXSpawnRandomLifetime } from "./emitter/spawn/FXSpawnRandomLifetime";
12
13
  export { FXSpawnRandomRotation } from "./emitter/spawn/FXSpawnRandomRotation";
13
14
  export { FXSpawnRandomScale } from "./emitter/spawn/FXSpawnRandomScale";
package/dist/index.js CHANGED
@@ -7,7 +7,8 @@ export { FXBehaviorVelocityDamping } from './emitter/behavior/FXBehaviorVelocity
7
7
  export { FXBehaviorVelocityNoise } from './emitter/behavior/FXBehaviorVelocityNoise.js';
8
8
  export { FXEmitter } from './emitter/FXEmitter.js';
9
9
  export { FXSpawnBox } from './emitter/spawn/FXSpawnBox.js';
10
- export { FXSpawnPoint as FXSpawnOffset } from './emitter/spawn/FXSpawnPoint.js';
10
+ export { FXSpawnOffset } from './emitter/spawn/FXSpawnOffset.js';
11
+ export { FXSpawnPoint } from './emitter/spawn/FXSpawnPoint.js';
11
12
  export { FXSpawnRandomLifetime } from './emitter/spawn/FXSpawnRandomLifetime.js';
12
13
  export { FXSpawnRandomRotation } from './emitter/spawn/FXSpawnRandomRotation.js';
13
14
  export { FXSpawnRandomScale } from './emitter/spawn/FXSpawnRandomScale.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sparcoon",
3
- "version": "0.4.5",
4
- "description": "",
3
+ "version": "0.5.0",
4
+ "description": "Instanced-mesh particle system for Three.js.",
5
5
  "keywords": [
6
6
  "particles",
7
7
  "particle-system",