UNPKG

@tsparticles/updater-tilt

Version:

tsParticles particles tilt updater

2 lines (1 loc) 5.54 kB
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.updaters.tilt=t.__tsParticlesInternals.updaters.tilt||{}),t.__tsParticlesInternals.engine)}(this,function(t,s){"use strict";var e;!function(t){t.clockwise="clockwise",t.counterClockwise="counter-clockwise",t.random="random"}(e||(e={}));class n{decay;enable;speed;sync;constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){s.isNull(t)||(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=s.setRangeValue(t.speed)),void 0!==t.decay&&(this.decay=s.setRangeValue(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class a extends s.ValueWithRandom{animation;direction;enable;constructor(){super(),this.animation=new n,this.direction=e.clockwise,this.enable=!1,this.value=0}load(t){super.load(t),s.isNull(t)||(this.animation.load(t.animation),void 0!==t.direction&&(this.direction=t.direction),void 0!==t.enable&&(this.enable=t.enable))}}class l{#t;constructor(t){this.#t=t}getTransformValues(t){const s=t.tilt?.enable&&t.tilt;return{b:s?Math.cos(s.value)*s.cosDirection:void 0,c:s?Math.sin(s.value)*s.sinDirection:void 0}}init(t){const n=t.options.tilt;if(!n)return;t.tilt={enable:n.enable,value:s.degToRad(s.getRangeValue(n.value)),sinDirection:s.getRandom()>=s.half?s.identity:-s.identity,cosDirection:s.getRandom()>=s.half?s.identity:-s.identity,min:0,max:s.doublePI};let a=n.direction;if(a===e.random){a=Math.floor(s.getRandom()*s.double)>0?e.counterClockwise:e.clockwise}switch(a){case e.counterClockwise:case"counterClockwise":t.tilt.status=s.AnimationStatus.decreasing;break;case e.clockwise:t.tilt.status=s.AnimationStatus.increasing}const l=t.options.tilt?.animation;l?.enable&&(t.tilt.decay=s.identity-s.getRangeValue(l.decay),t.tilt.velocity=s.getRangeValue(l.speed)/360*this.#t.retina.reduceFactor,l.sync||(t.tilt.velocity*=s.getRandom()))}isEnabled(t){const s=t.options.tilt?.animation;return!t.destroyed&&!t.spawning&&!!s?.enable}loadOptions(t,...s){t.tilt??=new a;for(const e of s)t.tilt.load(e?.tilt)}update(t,e){this.isEnabled(t)&&t.tilt&&s.updateAnimation(t,t.tilt,!1,s.DestroyType.none,e)}}async function i(t){t.checkVersion("4.1.3"),await t.pluginManager.register(t=>{t.pluginManager.addParticleUpdater("tilt",t=>Promise.resolve(new l(t)))})}const r=globalThis;r.__tsParticlesInternals=r.__tsParticlesInternals??{},r.loadTiltUpdater=i,t.loadTiltUpdater=i}),Object.assign(globalThis.window||globalThis,{loadTiltUpdater:(globalThis.__tsParticlesInternals.updaters.tilt||{}).loadTiltUpdater}),delete(globalThis.window||globalThis).tsparticlesInternalExports;