()
| 1774 | } |
| 1775 | |
| 1776 | private emit(): void { |
| 1777 | if (!this.emitActive) |
| 1778 | return; |
| 1779 | |
| 1780 | const oldParticleNum = this.particleNum; |
| 1781 | let srcOffs = oldParticleNum * this.dataStride, dstOffs = oldParticleNum * this.dataInitStride; |
| 1782 | |
| 1783 | for (let i = 0; i < this.emitters.length; i++) |
| 1784 | this.emitters[i].emit(this); |
| 1785 | |
| 1786 | for (let p = oldParticleNum; p < this.particleNum; p++) { |
| 1787 | for (let i = 0; i < this.initializers.length; i++) |
| 1788 | this.initializers[i].init(this, p); |
| 1789 | |
| 1790 | let streamConstBits = this.streamConstMask; |
| 1791 | while (streamConstBits !== 0) { |
| 1792 | const stream = streamConstBits & -streamConstBits; |
| 1793 | let offs = p * this.dataStride + this.dataStreamOffs[ctz32(stream)]; |
| 1794 | if (stream === StreamMask.Position || stream === StreamMask.PrevPosition) { |
| 1795 | this.particleDataF32[offs++] = 0.0; |
| 1796 | this.particleDataF32[offs++] = 0.0; |
| 1797 | this.particleDataF32[offs++] = 0.0; |
| 1798 | } else if (stream === StreamMask.Lifetime) { |
| 1799 | this.particleDataF32[offs] = 1.0; |
| 1800 | } else if (stream === StreamMask.Color) { |
| 1801 | this.particleDataF32[offs++] = this.constColor.r; |
| 1802 | this.particleDataF32[offs++] = this.constColor.g; |
| 1803 | this.particleDataF32[offs++] = this.constColor.b; |
| 1804 | } else if (stream === StreamMask.Alpha) { |
| 1805 | this.particleDataF32[offs] = this.constColor.a; |
| 1806 | } else if (stream === StreamMask.Radius) { |
| 1807 | this.particleDataF32[offs] = this.constRadius; |
| 1808 | } else { |
| 1809 | throw new Error("whoops"); |
| 1810 | } |
| 1811 | streamConstBits &= ~stream; |
| 1812 | } |
| 1813 | |
| 1814 | let streamInitBits = this.streamInitMask; |
| 1815 | while (streamInitBits !== 0) { |
| 1816 | const stream = streamInitBits & -streamInitBits; |
| 1817 | const streamStride = getStreamStride(stream); |
| 1818 | const offsIdx = ctz32(stream); |
| 1819 | let srcIdx = srcOffs + this.dataStreamOffs[offsIdx], dstIdx = dstOffs + this.dataInitStreamOffs[offsIdx]; |
| 1820 | for (let i = 0; i < streamStride; i++) |
| 1821 | this.particleDataInitF32[dstIdx++] = this.particleDataF32[srcIdx++]; |
| 1822 | streamInitBits &= ~stream; |
| 1823 | } |
| 1824 | |
| 1825 | srcOffs += this.dataStride; |
| 1826 | dstOffs += this.dataInitStride; |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | public deadParticle(p: number): void { |
| 1831 | // ensure sorted |
no test coverage detected