@tsparticles/interaction-particles-collisions 3.0.0-alpha.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/LICENSE +21 -0
- package/README.md +70 -0
- package/browser/Absorb.js +27 -0
- package/browser/Bounce.js +4 -0
- package/browser/Collider.js +37 -0
- package/browser/Destroy.js +16 -0
- package/browser/ResolveCollision.js +19 -0
- package/browser/index.js +4 -0
- package/cjs/Absorb.js +31 -0
- package/cjs/Bounce.js +8 -0
- package/cjs/Collider.js +52 -0
- package/cjs/Destroy.js +20 -0
- package/cjs/ResolveCollision.js +23 -0
- package/cjs/index.js +19 -0
- package/esm/Absorb.js +27 -0
- package/esm/Bounce.js +4 -0
- package/esm/Collider.js +37 -0
- package/esm/Destroy.js +16 -0
- package/esm/ResolveCollision.js +19 -0
- package/esm/index.js +4 -0
- package/package.json +82 -0
- package/report.html +39 -0
- package/tsparticles.interaction.particles.collisions.js +214 -0
- package/tsparticles.interaction.particles.collisions.min.js +2 -0
- package/tsparticles.interaction.particles.collisions.min.js.LICENSE.txt +8 -0
- package/types/Absorb.d.ts +2 -0
- package/types/Bounce.d.ts +2 -0
- package/types/Collider.d.ts +10 -0
- package/types/Destroy.d.ts +2 -0
- package/types/ResolveCollision.d.ts +2 -0
- package/types/index.d.ts +2 -0
- package/umd/Absorb.js +41 -0
- package/umd/Bounce.js +18 -0
- package/umd/Collider.js +51 -0
- package/umd/Destroy.js +30 -0
- package/umd/ResolveCollision.js +33 -0
- package/umd/index.js +18 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define(["@tsparticles/engine"], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ var __webpack_modules__ = ({
|
|
22
|
+
|
|
23
|
+
/***/ 533:
|
|
24
|
+
/***/ ((module) => {
|
|
25
|
+
|
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
/******/ });
|
|
31
|
+
/************************************************************************/
|
|
32
|
+
/******/ // The module cache
|
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // The require function
|
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
|
37
|
+
/******/ // Check if module is in cache
|
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
|
40
|
+
/******/ return cachedModule.exports;
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
44
|
+
/******/ // no module.id needed
|
|
45
|
+
/******/ // no module.loaded needed
|
|
46
|
+
/******/ exports: {}
|
|
47
|
+
/******/ };
|
|
48
|
+
/******/
|
|
49
|
+
/******/ // Execute the module function
|
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // Return the exports of the module
|
|
53
|
+
/******/ return module.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ // define __esModule on exports
|
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
/******/ };
|
|
83
|
+
/******/ })();
|
|
84
|
+
/******/
|
|
85
|
+
/************************************************************************/
|
|
86
|
+
var __webpack_exports__ = {};
|
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
88
|
+
(() => {
|
|
89
|
+
// ESM COMPAT FLAG
|
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
|
91
|
+
|
|
92
|
+
// EXPORTS
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
+
"loadParticlesCollisionsInteraction": () => (/* binding */ loadParticlesCollisionsInteraction)
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
+
;// CONCATENATED MODULE: ./dist/browser/Absorb.js
|
|
100
|
+
|
|
101
|
+
function updateAbsorb(p1, r1, p2, r2, delta, pixelRatio) {
|
|
102
|
+
const factor = (0,engine_root_window_.clamp)(p1.options.collisions.absorb.speed * delta.factor / 10, 0, r2);
|
|
103
|
+
p1.size.value += factor / 2;
|
|
104
|
+
p2.size.value -= factor;
|
|
105
|
+
if (r2 <= pixelRatio) {
|
|
106
|
+
p2.size.value = 0;
|
|
107
|
+
p2.destroy();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function absorb(p1, p2, delta, pixelRatio) {
|
|
111
|
+
const r1 = p1.getRadius(),
|
|
112
|
+
r2 = p2.getRadius();
|
|
113
|
+
if (r1 === undefined && r2 !== undefined) {
|
|
114
|
+
p1.destroy();
|
|
115
|
+
} else if (r1 !== undefined && r2 === undefined) {
|
|
116
|
+
p2.destroy();
|
|
117
|
+
} else if (r1 !== undefined && r2 !== undefined) {
|
|
118
|
+
if (r1 >= r2) {
|
|
119
|
+
updateAbsorb(p1, r1, p2, r2, delta, pixelRatio);
|
|
120
|
+
} else {
|
|
121
|
+
updateAbsorb(p2, r2, p1, r1, delta, pixelRatio);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
;// CONCATENATED MODULE: ./dist/browser/Bounce.js
|
|
126
|
+
|
|
127
|
+
function bounce(p1, p2) {
|
|
128
|
+
(0,engine_root_window_.circleBounce)((0,engine_root_window_.circleBounceDataFromParticle)(p1), (0,engine_root_window_.circleBounceDataFromParticle)(p2));
|
|
129
|
+
}
|
|
130
|
+
;// CONCATENATED MODULE: ./dist/browser/Destroy.js
|
|
131
|
+
|
|
132
|
+
function destroy(p1, p2) {
|
|
133
|
+
if (!p1.unbreakable && !p2.unbreakable) {
|
|
134
|
+
bounce(p1, p2);
|
|
135
|
+
}
|
|
136
|
+
if (p1.getRadius() === undefined && p2.getRadius() !== undefined) {
|
|
137
|
+
p1.destroy();
|
|
138
|
+
} else if (p1.getRadius() !== undefined && p2.getRadius() === undefined) {
|
|
139
|
+
p2.destroy();
|
|
140
|
+
} else if (p1.getRadius() !== undefined && p2.getRadius() !== undefined) {
|
|
141
|
+
const deleteP = p1.getRadius() >= p2.getRadius() ? p1 : p2;
|
|
142
|
+
deleteP.destroy();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
;// CONCATENATED MODULE: ./dist/browser/ResolveCollision.js
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
function resolveCollision(p1, p2, delta, pixelRatio) {
|
|
150
|
+
switch (p1.options.collisions.mode) {
|
|
151
|
+
case "absorb":
|
|
152
|
+
{
|
|
153
|
+
absorb(p1, p2, delta, pixelRatio);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case "bounce":
|
|
157
|
+
{
|
|
158
|
+
bounce(p1, p2);
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case "destroy":
|
|
162
|
+
{
|
|
163
|
+
destroy(p1, p2);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
;// CONCATENATED MODULE: ./dist/browser/Collider.js
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class Collider extends engine_root_window_.ParticlesInteractorBase {
|
|
172
|
+
constructor(container) {
|
|
173
|
+
super(container);
|
|
174
|
+
}
|
|
175
|
+
clear() {}
|
|
176
|
+
init() {}
|
|
177
|
+
async interact(p1, delta) {
|
|
178
|
+
const container = this.container,
|
|
179
|
+
pos1 = p1.getPosition(),
|
|
180
|
+
radius1 = p1.getRadius(),
|
|
181
|
+
query = container.particles.quadTree.queryCircle(pos1, radius1 * 2);
|
|
182
|
+
for (const p2 of query) {
|
|
183
|
+
if (p1 === p2 || !p2.options.collisions.enable || p1.options.collisions.mode !== p2.options.collisions.mode || p2.destroyed || p2.spawning) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const pos2 = p2.getPosition(),
|
|
187
|
+
radius2 = p2.getRadius();
|
|
188
|
+
if (Math.abs(Math.round(pos1.z) - Math.round(pos2.z)) > radius1 + radius2) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const dist = (0,engine_root_window_.getDistance)(pos1, pos2),
|
|
192
|
+
distP = radius1 + radius2;
|
|
193
|
+
if (dist > distP) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
resolveCollision(p1, p2, delta, container.retina.pixelRatio);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
isEnabled(particle) {
|
|
200
|
+
return particle.options.collisions.enable;
|
|
201
|
+
}
|
|
202
|
+
reset() {}
|
|
203
|
+
}
|
|
204
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
205
|
+
|
|
206
|
+
async function loadParticlesCollisionsInteraction(engine) {
|
|
207
|
+
await engine.addInteractor("particlesCollisions", container => new Collider(container));
|
|
208
|
+
}
|
|
209
|
+
})();
|
|
210
|
+
|
|
211
|
+
/******/ return __webpack_exports__;
|
|
212
|
+
/******/ })()
|
|
213
|
+
;
|
|
214
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.interaction.particles.collisions.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function i(e){var s=t[e];if(void 0!==s)return s.exports;var n=t[e]={exports:{}};return o[e](n,n.exports,i),n.exports}i.d=(e,o)=>{for(var t in o)i.o(o,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},i.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{i.r(s),i.d(s,{loadParticlesCollisionsInteraction:()=>a});var e=i(533);function o(o,t,i,s,n,r){const a=(0,e.clamp)(o.options.collisions.absorb.speed*n.factor/10,0,s);o.size.value+=a/2,i.size.value-=a,s<=r&&(i.size.value=0,i.destroy())}function t(o,t){(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(o),(0,e.circleBounceDataFromParticle)(t))}function n(e,i,s,n){switch(e.options.collisions.mode){case"absorb":!function(e,t,i,s){const n=e.getRadius(),r=t.getRadius();void 0===n&&void 0!==r?e.destroy():void 0!==n&&void 0===r?t.destroy():void 0!==n&&void 0!==r&&(n>=r?o(e,0,t,r,i,s):o(t,0,e,n,i,s))}(e,i,s,n);break;case"bounce":t(e,i);break;case"destroy":!function(e,o){e.unbreakable||o.unbreakable||t(e,o),void 0===e.getRadius()&&void 0!==o.getRadius()?e.destroy():void 0!==e.getRadius()&&void 0===o.getRadius()?o.destroy():void 0!==e.getRadius()&&void 0!==o.getRadius()&&(e.getRadius()>=o.getRadius()?e:o).destroy()}(e,i)}}class r extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(o,t){const i=this.container,s=o.getPosition(),r=o.getRadius(),a=i.particles.quadTree.queryCircle(s,2*r);for(const c of a){if(o===c||!c.options.collisions.enable||o.options.collisions.mode!==c.options.collisions.mode||c.destroyed||c.spawning)continue;const a=c.getPosition(),d=c.getRadius();if(Math.abs(Math.round(s.z)-Math.round(a.z))>r+d)continue;(0,e.getDistance)(s,a)>r+d||n(o,c,t,i.retina.pixelRatio)}}isEnabled(e){return e.options.collisions.enable}reset(){}}async function a(e){await e.addInteractor("particlesCollisions",(e=>new r(e)))}})(),s})()));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Container, IDelta, Particle } from "@tsparticles/engine";
|
|
2
|
+
import { ParticlesInteractorBase } from "@tsparticles/engine";
|
|
3
|
+
export declare class Collider extends ParticlesInteractorBase {
|
|
4
|
+
constructor(container: Container);
|
|
5
|
+
clear(): void;
|
|
6
|
+
init(): void;
|
|
7
|
+
interact(p1: Particle, delta: IDelta): Promise<void>;
|
|
8
|
+
isEnabled(particle: Particle): boolean;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
package/types/index.d.ts
ADDED
package/umd/Absorb.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.absorb = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
function updateAbsorb(p1, r1, p2, r2, delta, pixelRatio) {
|
|
15
|
+
const factor = (0, engine_1.clamp)((p1.options.collisions.absorb.speed * delta.factor) / 10, 0, r2);
|
|
16
|
+
p1.size.value += factor / 2;
|
|
17
|
+
p2.size.value -= factor;
|
|
18
|
+
if (r2 <= pixelRatio) {
|
|
19
|
+
p2.size.value = 0;
|
|
20
|
+
p2.destroy();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function absorb(p1, p2, delta, pixelRatio) {
|
|
24
|
+
const r1 = p1.getRadius(), r2 = p2.getRadius();
|
|
25
|
+
if (r1 === undefined && r2 !== undefined) {
|
|
26
|
+
p1.destroy();
|
|
27
|
+
}
|
|
28
|
+
else if (r1 !== undefined && r2 === undefined) {
|
|
29
|
+
p2.destroy();
|
|
30
|
+
}
|
|
31
|
+
else if (r1 !== undefined && r2 !== undefined) {
|
|
32
|
+
if (r1 >= r2) {
|
|
33
|
+
updateAbsorb(p1, r1, p2, r2, delta, pixelRatio);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
updateAbsorb(p2, r2, p1, r1, delta, pixelRatio);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.absorb = absorb;
|
|
41
|
+
});
|
package/umd/Bounce.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.bounce = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
function bounce(p1, p2) {
|
|
15
|
+
(0, engine_1.circleBounce)((0, engine_1.circleBounceDataFromParticle)(p1), (0, engine_1.circleBounceDataFromParticle)(p2));
|
|
16
|
+
}
|
|
17
|
+
exports.bounce = bounce;
|
|
18
|
+
});
|
package/umd/Collider.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./ResolveCollision"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Collider = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const ResolveCollision_1 = require("./ResolveCollision");
|
|
15
|
+
class Collider extends engine_1.ParticlesInteractorBase {
|
|
16
|
+
constructor(container) {
|
|
17
|
+
super(container);
|
|
18
|
+
}
|
|
19
|
+
clear() {
|
|
20
|
+
}
|
|
21
|
+
init() {
|
|
22
|
+
}
|
|
23
|
+
async interact(p1, delta) {
|
|
24
|
+
const container = this.container, pos1 = p1.getPosition(), radius1 = p1.getRadius(), query = container.particles.quadTree.queryCircle(pos1, radius1 * 2);
|
|
25
|
+
for (const p2 of query) {
|
|
26
|
+
if (p1 === p2 ||
|
|
27
|
+
!p2.options.collisions.enable ||
|
|
28
|
+
p1.options.collisions.mode !== p2.options.collisions.mode ||
|
|
29
|
+
p2.destroyed ||
|
|
30
|
+
p2.spawning) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const pos2 = p2.getPosition(), radius2 = p2.getRadius();
|
|
34
|
+
if (Math.abs(Math.round(pos1.z) - Math.round(pos2.z)) > radius1 + radius2) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const dist = (0, engine_1.getDistance)(pos1, pos2), distP = radius1 + radius2;
|
|
38
|
+
if (dist > distP) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
(0, ResolveCollision_1.resolveCollision)(p1, p2, delta, container.retina.pixelRatio);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
isEnabled(particle) {
|
|
45
|
+
return particle.options.collisions.enable;
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Collider = Collider;
|
|
51
|
+
});
|
package/umd/Destroy.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./Bounce"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.destroy = void 0;
|
|
13
|
+
const Bounce_1 = require("./Bounce");
|
|
14
|
+
function destroy(p1, p2) {
|
|
15
|
+
if (!p1.unbreakable && !p2.unbreakable) {
|
|
16
|
+
(0, Bounce_1.bounce)(p1, p2);
|
|
17
|
+
}
|
|
18
|
+
if (p1.getRadius() === undefined && p2.getRadius() !== undefined) {
|
|
19
|
+
p1.destroy();
|
|
20
|
+
}
|
|
21
|
+
else if (p1.getRadius() !== undefined && p2.getRadius() === undefined) {
|
|
22
|
+
p2.destroy();
|
|
23
|
+
}
|
|
24
|
+
else if (p1.getRadius() !== undefined && p2.getRadius() !== undefined) {
|
|
25
|
+
const deleteP = p1.getRadius() >= p2.getRadius() ? p1 : p2;
|
|
26
|
+
deleteP.destroy();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.destroy = destroy;
|
|
30
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./Absorb", "./Bounce", "./Destroy"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.resolveCollision = void 0;
|
|
13
|
+
const Absorb_1 = require("./Absorb");
|
|
14
|
+
const Bounce_1 = require("./Bounce");
|
|
15
|
+
const Destroy_1 = require("./Destroy");
|
|
16
|
+
function resolveCollision(p1, p2, delta, pixelRatio) {
|
|
17
|
+
switch (p1.options.collisions.mode) {
|
|
18
|
+
case "absorb": {
|
|
19
|
+
(0, Absorb_1.absorb)(p1, p2, delta, pixelRatio);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case "bounce": {
|
|
23
|
+
(0, Bounce_1.bounce)(p1, p2);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case "destroy": {
|
|
27
|
+
(0, Destroy_1.destroy)(p1, p2);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.resolveCollision = resolveCollision;
|
|
33
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./Collider"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadParticlesCollisionsInteraction = void 0;
|
|
13
|
+
const Collider_1 = require("./Collider");
|
|
14
|
+
async function loadParticlesCollisionsInteraction(engine) {
|
|
15
|
+
await engine.addInteractor("particlesCollisions", (container) => new Collider_1.Collider(container));
|
|
16
|
+
}
|
|
17
|
+
exports.loadParticlesCollisionsInteraction = loadParticlesCollisionsInteraction;
|
|
18
|
+
});
|