npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nachi-vfx/react

v0.2.3

Published

Thin React Three Fiber lifecycle bindings for nachi VFX systems

Readme

@nachi-vfx/react

Thin React Three Fiber bindings for @nachi-vfx/core. React, R3F, and Three.js are peer dependencies; the package does not create a second renderer or VFX runtime.

pnpm add @nachi-vfx/core @nachi-vfx/three @nachi-vfx/react react@^19 @react-three/fiber@^9 [email protected]
pnpm add -D @types/[email protected]
import {
  billboard,
  burst,
  defineEffect,
  defineEmitter,
  lifetime,
  positionSphere,
} from '@nachi-vfx/core';
import { VFXSystemProvider, useEffectInstance } from '@nachi-vfx/react';
import {
  createThreeKernelAdapter,
  createThreeRuntimeRenderer,
  materializeThreeSpriteDraw,
} from '@nachi-vfx/three';
import { Canvas, useThree } from '@react-three/fiber';
import { useEffect } from 'react';
import * as THREE from 'three/webgpu';

const effect = defineEffect({
  elements: {
    sparks: defineEmitter({
      capacity: 256,
      init: [positionSphere({ radius: 0.2 }), lifetime(0.8)],
      render: billboard({ blending: 'additive' }),
      spawn: burst({ count: 80 }),
    }),
  },
});

const threeRenderer = new THREE.WebGPURenderer({ antialias: true });
await threeRenderer.init();
const kernelAdapter = createThreeKernelAdapter({ backend: 'webgpu' });
const runtimeRenderer = createThreeRuntimeRenderer(threeRenderer, kernelAdapter);

function Sparks() {
  const scene = useThree((state) => state.scene);
  const instance = useEffectInstance(effect, { position: [0, 1, 0], seed: 42 });

  useEffect(() => {
    const emitter = instance?.getEmitter('sparks');
    if (!emitter) return;
    const draw = materializeThreeSpriteDraw(emitter.program, emitter.kernels);
    scene.add(draw);
    return () => {
      scene.remove(draw);
      draw.geometry.dispose();
      draw.material.dispose();
    };
  }, [instance, scene]);

  return null;
}

export function App() {
  return (
    <Canvas gl={threeRenderer} camera={{ position: [0, 1, 5] }}>
      <VFXSystemProvider renderer={runtimeRenderer}>
        <Sparks />
      </VFXSystemProvider>
    </Canvas>
  );
}

[email protected] is an exact peer. TypeScript projects also need @types/[email protected] because Three publishes its declarations separately.

VFXSystemProvider copies the active R3F camera matrices and pixel viewport to core, then calls system.update(delta) from useFrame. Camera synchronization is enabled by default so distance and frustum culling, significance, scene-depth effects, and transparent sorting use the rendered view; set syncCamera={false} only when camera state is supplied manually. useEffectInstance() spawns on mount, forwards live parameter/transform/time-scale changes, supports attachTo with a Three Object3D, and always releases on unmount. Seed and priority are spawn-only and restart the instance when changed. Parameter values are retained by the binding only after core validation and forwarding succeeds. Keep definition at module scope (or otherwise referentially stable), because a new reference respawns the instance. attachTo owns the complete live transform and overwrites position and rotation supplied at spawn or through props on each scheduled step.

Core contains per-instance runtime failures, so the provider's frame update may resolve even when an instance transitions to state === 'error'. The mounted instance object is mutable: retain it from useEffectInstance() (or an onInstance integration callback) and inspect state and diagnostics after the update. The binding keeps the component mounted, but stops forwarding later parameter, transform, time-scale, and attachment writes once the instance is no longer active. Configure onRuntimeDiagnostic on the system when the error must also reach logging or telemetry; the React provider does not turn contained instance errors into render or frame-loop exceptions.