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 🙏

© 2024 – Pkg Stats / Ryan Hefner

remix-three

v0.0.1

Published

Adapter to render Remix elements with react-three-fiber

Downloads

5

Readme

remix-three

Hi! remix-three is a very tiny shim layer allowing you to render a <Canvas> from @react-three/fiber into a Remix app, as well as render Remix <Outlet>s and calls to useLoaderData() inside your <Canvas>.

This repo consists of three things:

  1. A set of patch-package patches to make all the @react-three/* libraries play nice with the Remix compiler.
  2. A useRemixBridge utility build on @react-three/drei's useContextBridge that will replay all of the necessary Remix context values into the <Canvas> rendering fiber.
  3. A <Link3d> component that allows you to have any object in your 3D scene participate in Remix navigation.

Getting started

  1. npm i remix-three @react-three/[email protected] @react-three/[email protected] @remix-run/[email protected] patch-package

  2. Add the following to your package.json:

{
  "scripts": {
    "postinstall": "patch-package --patch-dir node_modules/remix-three/patches"
  }
}
  1. Use useRemixBridge() when you create your <Canvas>:
// app/routes/canvas.tsx
import { useRemixBridge } from "remix-three";

export default function CanvasRoute() {
  let RemixBridge = useRemixBridge();

  return (
    <Canvas>
      <RemixBridge>
        <MyScene />
      </RemixBridge>
    </Canvas>
  );
}

function MyScene() {
  let matches = useMatches();
  let data = useLoaderData();
  let location = useLocation();

  return (
    <mesh>
      <boxGeometry args={[1, 1, 1]} />
      <meshNormalMaterial />
    </mesh>
  );
}

NB: You must split out your scene content into a separate component that you render inside the RemixBridge in order to access anything from the remix or react-router context.

Link3d

In general, this component takes the exact same props as a regular Remix <Link> but wraps an Object3D inside your scene. It works by invoking navigation directly in the same way a regular <Link> would. It is totally possible this component may mess with your refs or click handlers of the child element, but I've done my best to avoid that.

import { Link3d } from 'remix-three'

function MyScene() {
	return (
		<Link to="./author">
			<mesh>
				<boxGeometry args={[1, 1, 1]} />
				<meshNormalMaterial />
			</mesh>
		</Link>

		<Outlet />
	)
}