UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

160 lines (149 loc) 4.52 kB
import { removeEntityWithEffect } from "./AnimationUtils.js"; import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter/ParticleEmitter.js"; const lib = { 'cloud-puff': { "receiveLight": true, "parameters": [ { "name": "scale", "itemSize": 1, "defaultTrackValue": { "itemSize": 1, "data": [ 1 ], "positions": [ 0 ] } }, { "name": "color", "itemSize": 4, "defaultTrackValue": { "itemSize": 4, "data": [ 1, 1, 1, 1 ], "positions": [ 0 ] } } ], "blendingMode": 0, "layers": [ { "imageURL": "data/textures/particle/smokeparticle.png", "particleLife": { "min": 1.2, "max": 1.5 }, "particleSize": { "min": 1, "max": 1.2 }, "particleRotation": { "min": 0, "max": 0 }, "particleRotationSpeed": { "min": 0, "max": 0 }, "emissionShape": 1, "emissionFrom": 1, "emissionRate": 0, "emissionImmediate": 25, "parameterTracks": [ { "name": "color", "track": { "itemSize": 4, "data": [ 0.6, 0.6, 0.6, 0, 0.6, 0.6, 0.6, 1, 0.6, 0.6, 0.6, 0.5, 0.6, 0.6, 0.6, 0 ], "positions": [ 0, 0.07, 0.8097826086956522, 1 ] } } ], "position": { "x": 0, "y": 0.6, "z": 0 }, "scale": { "x": 0.9, "y": 0.5, "z": 0.65 }, "particleVelocityDirection": { "direction": { "x": 0, "y": 1, "z": 0 }, "angle": 1.5 }, "particleSpeed": { "min": 0.2, "max": 0.5 } } ] } }; /** * * @param {Engine} engine * @param {EntityComponentDataset} ecd * @param {number} entity * @param {string} [particles] * @param {string} [sound] * @returns {Promise<any>} */ export function removeEntityGenericEffect( { engine, ecd, entity, particles = 'cloud-puff', sound = "data/sounds/effects/Magic_Game_Essentials/Magic_Vanish_3.wav" } ) { const particle_json = lib[particles]; if (particle_json === undefined) { throw new Error(`Unsupported particle ID '${particles}'`); } const emitter = ParticleEmitter.fromJSON(particle_json); const result = removeEntityWithEffect({ entity, ecd, emitter, soundEffect: sound }); return result; }