Skip to content

Commit e133ab3

Browse files
committed
feat: added cannon external interaction
1 parent f023170 commit e133ab3

31 files changed

Lines changed: 941 additions & 3 deletions

bundles/all/package.dist.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"@tsparticles/effect-shadow": "4.0.0-beta.0",
105105
"@tsparticles/effect-trail": "4.0.0-beta.0",
106106
"@tsparticles/engine": "4.0.0-beta.0",
107+
"@tsparticles/interaction-external-cannon": "4.0.0-beta.0",
107108
"@tsparticles/interaction-external-particle": "4.0.0-beta.0",
108109
"@tsparticles/interaction-external-pop": "4.0.0-beta.0",
109110
"@tsparticles/interaction-light": "4.0.0-beta.0",

bundles/all/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
"@tsparticles/effect-shadow": "workspace:4.0.0-beta.0",
113113
"@tsparticles/effect-trail": "workspace:4.0.0-beta.0",
114114
"@tsparticles/engine": "workspace:4.0.0-beta.0",
115+
"@tsparticles/interaction-external-cannon": "workspace:4.0.0-beta.0",
115116
"@tsparticles/interaction-external-particle": "workspace:4.0.0-beta.0",
116117
"@tsparticles/interaction-external-pop": "workspace:4.0.0-beta.0",
117118
"@tsparticles/interaction-light": "workspace:4.0.0-beta.0",

bundles/all/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export async function loadAll(engine: Engine): Promise<void> {
5757
{ loadExportJSONPlugin },
5858
{ loadExportVideoPlugin },
5959

60+
{ loadExternalCannonInteraction },
6061
{ loadExternalParticleInteraction },
6162
{ loadExternalPopInteraction },
6263
{ loadLightInteraction },
@@ -143,6 +144,7 @@ export async function loadAll(engine: Engine): Promise<void> {
143144
import("@tsparticles/plugin-export-json"),
144145
import("@tsparticles/plugin-export-video"),
145146

147+
import("@tsparticles/interaction-external-cannon"),
146148
import("@tsparticles/interaction-external-particle"),
147149
import("@tsparticles/interaction-external-pop"),
148150
import("@tsparticles/interaction-light"),
@@ -193,6 +195,7 @@ export async function loadAll(engine: Engine): Promise<void> {
193195
await loadFull(e);
194196

195197
await Promise.all([
198+
loadExternalCannonInteraction(e),
196199
loadExternalParticleInteraction(e),
197200
loadExternalPopInteraction(e),
198201
loadLightInteraction(e),

demo/vanilla/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ app.use("/plugin-emitters", express.static("./node_modules/@tsparticles/plugin-e
117117
app.use("/plugin-interactivity", express.static("./node_modules/@tsparticles/plugin-interactivity"));
118118
app.use("/plugin-polygon-mask", express.static("./node_modules/@tsparticles/plugin-polygon-mask"));
119119
app.use("/plugin-poisson-disc", express.static("./node_modules/@tsparticles/plugin-poisson-disc"));
120+
app.use("/interaction-external-cannon", express.static("./node_modules/@tsparticles/interaction-external-cannon"));
120121
app.use("/interaction-external-parallax", express.static("./node_modules/@tsparticles/interaction-external-parallax"));
121122
app.use("/interaction-external-particle", express.static("./node_modules/@tsparticles/interaction-external-particle"));
122123
app.use("/interaction-external-pop", express.static("./node_modules/@tsparticles/interaction-external-pop"));

demo/vanilla/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"@tsparticles/interaction-external-attract": "workspace:4.0.0-beta.0",
6666
"@tsparticles/interaction-external-bounce": "workspace:4.0.0-beta.0",
6767
"@tsparticles/interaction-external-bubble": "workspace:4.0.0-beta.0",
68+
"@tsparticles/interaction-external-cannon": "workspace:4.0.0-beta.0",
6869
"@tsparticles/interaction-external-connect": "workspace:4.0.0-beta.0",
6970
"@tsparticles/interaction-external-drag": "workspace:4.0.0-beta.0",
7071
"@tsparticles/interaction-external-grab": "workspace:4.0.0-beta.0",

demo/vanilla/views/index.pug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ html(lang="en")
128128
script(src="/interaction-external-attract/tsparticles.interaction.external.attract.min.js")
129129
script(src="/interaction-external-bounce/tsparticles.interaction.external.bounce.min.js")
130130
script(src="/interaction-external-bubble/tsparticles.interaction.external.bubble.min.js")
131+
script(src="/interaction-external-cannon/tsparticles.interaction.external.cannon.min.js")
131132
script(src="/interaction-external-connect/tsparticles.interaction.external.connect.min.js")
132133
script(src="/interaction-external-drag/tsparticles.interaction.external.drag.min.js")
133134
script(src="/interaction-external-grab/tsparticles.interaction.external.grab.min.js")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
since 2021
2+
not dead
3+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
report.html
2+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Matteo Bruni
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
[![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
2+
3+
# tsParticles External Cannon Interaction
4+
5+
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/interaction-external-cannon/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/interaction-external-cannon)
6+
[![npmjs](https://badge.fury.io/js/@tsparticles/interaction-external-cannon.svg)](https://www.npmjs.com/package/@tsparticles/interaction-external-cannon)
7+
[![npmjs](https://img.shields.io/npm/dt/@tsparticles/interaction-external-cannon)](https://www.npmjs.com/package/@tsparticles/interaction-external-cannon) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8+
9+
[tsParticles](https://github.com/tsparticles/tsparticles) interaction plugin for a particles cannon
10+
with the mouse/pointer.
11+
12+
## How to use it
13+
14+
### CDN / Vanilla JS / jQuery
15+
16+
The CDN/Vanilla version JS has one required file in vanilla configuration:
17+
18+
Including the `tsparticles.interaction.external.cannon.min.js` file will export the function to load the interaction
19+
plugin:
20+
21+
```javascript
22+
loadExternalCannonInteraction;
23+
```
24+
25+
### Usage
26+
27+
Once the scripts are loaded you can set up `tsParticles` and the interaction plugin like this:
28+
29+
```javascript
30+
(async () => {
31+
await loadInteractivityPlugin(tsParticles);
32+
await loadExternalCannonInteraction(tsParticles);
33+
34+
await tsParticles.load({
35+
id: "tsparticles",
36+
options: {
37+
interactivity: {
38+
events: {
39+
onClick: {
40+
enable: true,
41+
mode: "cannon",
42+
},
43+
},
44+
},
45+
},
46+
});
47+
})();
48+
```
49+
50+
### ESM / CommonJS
51+
52+
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
53+
54+
```shell
55+
$ npm install @tsparticles/interaction-external-cannon
56+
```
57+
58+
or
59+
60+
```shell
61+
$ yarn add @tsparticles/interaction-external-cannon
62+
```
63+
64+
Then you need to import it in the app, like this:
65+
66+
```javascript
67+
const { tsParticles } = require("@tsparticles/engine");
68+
const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity");
69+
const { loadExternalCannonInteraction } = require("@tsparticles/interaction-external-cannon");
70+
71+
(async () => {
72+
await loadInteractivityPlugin(tsParticles);
73+
await loadExternalCannonInteraction(tsParticles);
74+
})();
75+
```
76+
77+
or
78+
79+
```javascript
80+
import { tsParticles } from "@tsparticles/engine";
81+
import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
82+
import { loadExternalCannonInteraction } from "@tsparticles/interaction-external-cannon";
83+
84+
(async () => {
85+
await loadInteractivityPlugin(tsParticles);
86+
await loadExternalCannonInteraction(tsParticles);
87+
})();
88+
```

0 commit comments

Comments
 (0)