Skip to content

Commit

Permalink
💩 Add band-aids for @pixi/particle-emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Dec 26, 2023
1 parent 57c3155 commit 326a816
Show file tree
Hide file tree
Showing 5 changed files with 1,111 additions and 1,010 deletions.
51 changes: 51 additions & 0 deletions src/ct.release/emitters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,57 @@ declare var PIXI: typeof pixiMod & {
particles: typeof particlesMod;
};

// TODO: remove this band-aid when https://github.com/pixijs/pixijs/issues/9495 closes
/// ⚠️⚠️⚠️ BAND-AID FOR https://github.com/pixijs/particle-emitter/issues/209
PIXI.particles.Particle.prototype.isInteractive = () => false;

// TODO: remove when resolved
/// ⚠️⚠️⚠️ BAND-AID FOR https://github.com/pixijs/particle-emitter/issues/209
{
const hexToRGB = (color, output?) => {
if (!output) {
output = {};
}
if (color.charAt(0) === '#') {
color = color.substr(1);
} else if (color.indexOf('0x') === 0) {
color = color.substr(2);
}
let alpha;
if (color.length === 8) {
alpha = color.substr(0, 2);
color = color.substr(2);
}
output.r = parseInt(color.substr(0, 2), 16); // Red
output.g = parseInt(color.substr(2, 2), 16); // Green
output.b = parseInt(color.substr(4, 2), 16); // Blue
if (alpha) {
output.a = parseInt(alpha, 16);
}
return output;
};
/* eslint-disable id-blacklist */
PIXI.particles.PropertyNode.createList = (data) => {
const array = (data as any).list;
let node;
// eslint-disable-next-line prefer-destructuring
const {value, time} = array[0];
// eslint-disable-next-line max-len
const first = node = new PIXI.particles.PropertyNode(typeof value === 'string' ? hexToRGB(value) : value, time, (data as any).ease);
// only set up subsequent nodes if there are a bunch of them
if (array.length > 1) {
for (let i = 1; i < array.length; ++i) {
const {value, time} = array[i];
node.next = new PIXI.particles.PropertyNode(typeof value === 'string' ? hexToRGB(value) : value, time);
node = node.next;
}
}
first.isStepped = Boolean((data as any).isStepped);
return first;
};
/* eslint-enable id-blacklist */
}

import type {ExportedTandem, ExportedTandems} from '../node_requires/exporter/_exporterContracts';

type EmitterPatched = Emitter & {
Expand Down
2 changes: 0 additions & 2 deletions src/ct.release/index.pixi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {sound as pixiSound, filters as pixiSoundFilters} from 'node_modules/@pix
/* eslint-disable @typescript-eslint/no-explicit-any */
export const PIXI = pixi;
(PIXI as any).particles = particles;
// TODO: remove this band-aid when https://github.com/pixijs/pixijs/issues/9495 closes
PIXI.particles.Particle.prototype.isInteractive = () => false;
(PIXI as any).sound = pixiSound;
(PIXI as any).sound.filters = pixiSoundFilters;
// (PIXI as any).sounds = sounds
Expand Down
Loading

0 comments on commit 326a816

Please sign in to comment.