@needle-tools/engine 2.59.1-pre → 2.59.2-pre
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/CHANGELOG.md +6 -0
- package/dist/needle-engine.js +3787 -3770
- package/dist/needle-engine.umd.cjs +210 -210
- package/lib/engine/engine_input.js +4 -6
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +10 -0
- package/lib/engine-components/ParticleSystem.js +19 -0
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemSubEmitter.d.ts +5 -1
- package/lib/engine-components/ParticleSystemSubEmitter.js +25 -5
- package/lib/engine-components/ParticleSystemSubEmitter.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/engine/engine_input.ts +4 -4
- package/src/engine-components/ParticleSystem.ts +19 -1
- package/src/engine-components/ParticleSystemSubEmitter.ts +32 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "2.59.
|
|
3
|
+
"version": "2.59.2-pre",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
|
|
5
5
|
"main": "dist/needle-engine.umd.cjs",
|
|
6
6
|
"module": "dist/needle-engine.js",
|
|
@@ -343,10 +343,10 @@ export class Input extends EventTarget {
|
|
|
343
343
|
|
|
344
344
|
private canReceiveInput(evt : Event) {
|
|
345
345
|
// If the user has HTML objects ontop of the canvas
|
|
346
|
-
if(evt.target
|
|
347
|
-
const css = window.getComputedStyle(evt.target as HTMLElement);
|
|
348
|
-
if(css.pointerEvents === "all") return false;
|
|
349
|
-
return
|
|
346
|
+
// if(evt.target === this.context.renderer.domElement) return true;
|
|
347
|
+
// const css = window.getComputedStyle(evt.target as HTMLElement);
|
|
348
|
+
// if(css.pointerEvents === "all") return false;
|
|
349
|
+
return evt.target === this.context.renderer.domElement;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
private keysPressed: { [key: number]: { pressed: boolean, frame: number, startFrame: number, key: string } } = {};
|
|
@@ -16,15 +16,26 @@ import { createFlatTexture } from "../engine/engine_shaders";
|
|
|
16
16
|
import { Mathf } from "../engine/engine_math";
|
|
17
17
|
import { Context } from "../engine/engine_setup";
|
|
18
18
|
import { ParticleSubEmitter } from "./ParticleSystemSubEmitter";
|
|
19
|
+
import { copyFile } from "fs";
|
|
19
20
|
|
|
20
21
|
const debug = getParam("debugparticles");
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
export enum SubEmitterType {
|
|
24
|
+
Birth = 0,
|
|
25
|
+
Collision = 1,
|
|
26
|
+
Death = 2,
|
|
27
|
+
Trigger = 3,
|
|
28
|
+
Manual = 4,
|
|
29
|
+
}
|
|
23
30
|
|
|
24
31
|
export class SubEmitterSystem {
|
|
25
32
|
|
|
26
33
|
particleSystem?: ParticleSystem;
|
|
27
34
|
|
|
35
|
+
emitProbability: number = 1;
|
|
36
|
+
properties?: number;
|
|
37
|
+
type?: SubEmitterType;
|
|
38
|
+
|
|
28
39
|
_deserialize(context: Context) {
|
|
29
40
|
const ps = this.particleSystem;
|
|
30
41
|
if (ps && !(ps instanceof ParticleSystem) && typeof ps["guid"] === "string") {
|
|
@@ -726,6 +737,9 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
726
737
|
arr[i] = instance;
|
|
727
738
|
}
|
|
728
739
|
}
|
|
740
|
+
if (debug && arr.length > 0) {
|
|
741
|
+
console.log("SubEmitters: ", arr, this)
|
|
742
|
+
}
|
|
729
743
|
this._subEmitterSystems = arr;
|
|
730
744
|
}
|
|
731
745
|
private _subEmitterSystems?: SubEmitterSystem[];
|
|
@@ -839,11 +853,15 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
839
853
|
private addSubParticleSystems() {
|
|
840
854
|
if (this._subEmitterSystems && this._particleSystem) {
|
|
841
855
|
for (const sys of this._subEmitterSystems) {
|
|
856
|
+
// Make sure the particle system is created
|
|
857
|
+
if (sys.particleSystem) sys.particleSystem.__internalAwake();
|
|
842
858
|
const system = sys.particleSystem?._particleSystem;
|
|
843
859
|
if (system) {
|
|
844
860
|
sys.particleSystem!._isUsedAsSubsystem = true;
|
|
845
861
|
// sys.particleSystem!.main.simulationSpace = ParticleSystemSimulationSpace.World;
|
|
846
862
|
const sub = new ParticleSubEmitter(this, this._particleSystem, sys.particleSystem!, system);
|
|
863
|
+
sub.emitterType = sys.type;
|
|
864
|
+
sub.emitterProbability = sys.emitProbability;
|
|
847
865
|
this._particleSystem.addBehavior(sub);
|
|
848
866
|
}
|
|
849
867
|
}
|
|
@@ -2,6 +2,7 @@ import { Behavior, Particle, EmissionState, ParticleSystem, ParticleEmitter } fr
|
|
|
2
2
|
import { Vector3, Quaternion, Matrix4 } from "three";
|
|
3
3
|
import { IParticleSystem } from "./ParticleSystemModules";
|
|
4
4
|
import { CircularBuffer } from "../engine/engine_utils";
|
|
5
|
+
import { SubEmitterType } from "./ParticleSystem";
|
|
5
6
|
|
|
6
7
|
const VECTOR_ONE = new Vector3(1, 1, 1);
|
|
7
8
|
const VECTOR_Z = new Vector3(0, 0, 1);
|
|
@@ -11,6 +12,9 @@ export class ParticleSubEmitter implements Behavior {
|
|
|
11
12
|
|
|
12
13
|
type = "NeedleParticleSubEmitter";
|
|
13
14
|
|
|
15
|
+
emitterType?: SubEmitterType;
|
|
16
|
+
emitterProbability?: number;
|
|
17
|
+
|
|
14
18
|
//private matrix_ = new Matrix4();
|
|
15
19
|
private q_ = new Quaternion();
|
|
16
20
|
private v_ = new Vector3();
|
|
@@ -47,14 +51,41 @@ export class ParticleSubEmitter implements Behavior {
|
|
|
47
51
|
} as EmissionState;
|
|
48
52
|
// particle[$emitterMatrix] = new Matrix4();
|
|
49
53
|
this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld)
|
|
54
|
+
|
|
55
|
+
if (this.emitterType === SubEmitterType.Birth) {
|
|
56
|
+
this.run(particle);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
update(particle: Particle, _delta: number): void {
|
|
61
|
+
this.run(particle);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
frameUpdate(_delta: number): void {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
toJSON(): any {
|
|
50
68
|
}
|
|
51
69
|
|
|
52
|
-
|
|
70
|
+
private run(particle: Particle) {
|
|
53
71
|
if (this.subSystem.currentParticles >= this.subSystem.main.maxParticles)
|
|
54
72
|
return;
|
|
55
73
|
if (!this.subParticleSystem || !particle.emissionState)
|
|
56
74
|
return;
|
|
57
75
|
|
|
76
|
+
if(this.emitterProbability && Math.random() > this.emitterProbability)
|
|
77
|
+
return;
|
|
78
|
+
|
|
79
|
+
const delta = this.system.deltaTime;
|
|
80
|
+
|
|
81
|
+
if (this.emitterType === SubEmitterType.Death) {
|
|
82
|
+
const willDie = particle.age + delta * 1.2 >= particle.life;
|
|
83
|
+
if (!willDie) return;
|
|
84
|
+
// Just emit all for now, we should probably add a way to get the amount from the subsystem emission module
|
|
85
|
+
const maxAmount = this.subSystem.main.maxParticles - this.subSystem.currentParticles;
|
|
86
|
+
particle.emissionState.waitEmiting = maxAmount;
|
|
87
|
+
}
|
|
88
|
+
|
|
58
89
|
// TODO: figure out how to re-use matrices
|
|
59
90
|
const m = new Matrix4();// this._circularBuffer.get();// new Matrix4();// particle[$emitterMatrix];
|
|
60
91
|
|
|
@@ -71,10 +102,4 @@ export class ParticleSubEmitter implements Behavior {
|
|
|
71
102
|
|
|
72
103
|
this.subParticleSystem!.emit(delta, particle.emissionState!, m);
|
|
73
104
|
}
|
|
74
|
-
|
|
75
|
-
frameUpdate(_delta: number): void {
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
toJSON(): any {
|
|
79
|
-
}
|
|
80
105
|
}
|