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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-three-nurbs

v0.2.0

Published

A React component library for rendering NURBS (Non-Uniform Rational B-Spline) surfaces in Three.js. Built with React Three Fiber, this library provides an easy way to create and visualize complex curved surfaces in your 3D applications.

Readme

react-three-nurbs

A React component library for rendering NURBS (Non-Uniform Rational B-Spline) surfaces in Three.js. Built with React Three Fiber, this library provides an easy way to create and visualize complex curved surfaces in your 3D applications.

Features

  • 🎯 Simple React component API for NURBS surfaces
  • 📐 Support for arbitrary degree NURBS surfaces
  • 🎨 Customizable surface appearance with R3F materials
  • 🔄 Automatic normal calculation for proper lighting
  • 🎮 Interactive 3D visualization with React Three Fiber
  • 📦 Written in TypeScript with full type support
  • 🎨 Compatible with drei's Line component for curves

Installation

npm install react-three-nurbs

Quick Start

Surface with Default Material

import { NurbsSurface } from 'react-three-nurbs'
import { Canvas } from '@react-three/fiber'

function App() {
  // Define a simple 4x4 control point grid for a surface
  const controlPoints = [
    [[-1, -1, 0], [-1, -0.5, 0], [-1, 0.5, 0], [-1, 1, 0]],
    [[-0.5, -1, 0], [-0.5, -0.5, 1], [-0.5, 0.5, 1], [-0.5, 1, 0]],
    [[0.5, -1, 0], [0.5, -0.5, 1], [0.5, 0.5, 1], [0.5, 1, 0]],
    [[1, -1, 0], [1, -0.5, 0], [1, 0.5, 0], [1, 1, 0]]
  ]

  // Define weights for each control point (1.0 for uniform B-spline)
  const weights = [
    [1, 1, 1, 1],
    [1, 1, 1, 1],
    [1, 1, 1, 1],
    [1, 1, 1, 1]
  ]

  return (
    <Canvas>
      <ambientLight intensity={0.5} />
      <pointLight position={[10, 10, 10]} />
      <NurbsSurface
        controlPoints={controlPoints}
        weights={weights}
        degreeU={3}
        degreeV={3}
        color="#ff0000"
        wireframe={false}
      />
    </Canvas>
  )
}

Surface with Custom Material

import { NurbsSurface } from 'react-three-nurbs'
import { Canvas } from '@react-three/fiber'
import { MeshStandardMaterial } from 'three'

function App() {
  // ... control points and weights as above ...

  return (
    <Canvas>
      <ambientLight intensity={0.5} />
      <pointLight position={[10, 10, 10]} />
      <NurbsSurface
        controlPoints={controlPoints}
        weights={weights}
        degreeU={3}
        degreeV={3}
        position={[0, 0, 0]}
        rotation={[0, Math.PI / 4, 0]}
      >
        <meshStandardMaterial
          color="#00ff00"
          metalness={0.5}
          roughness={0.5}
          wireframe={true}
        />
      </NurbsSurface>
    </Canvas>
  )
}

NURBS Curve

import { NurbsCurve } from 'react-three-nurbs'
import { Canvas } from '@react-three/fiber'

function App() {
  const points = [
    [0, 0, 0],
    [1, 1, 0],
    [2, 0, 0],
    [3, 1, 0],
    [4, 0, 0],
  ]

  const knots = [0, 0, 0, 0.5, 1, 1, 1]

  return (
    <Canvas>
      <NurbsCurve
        points={points}
        knots={knots}
        degree={2}
        color="red"
        dashed={true}
        segments={true}
        vertexColors={[
          [1, 0, 0], // red
          [0, 1, 0], // green
          [0, 0, 1], // blue
          [1, 1, 0], // yellow
          [1, 0, 1], // magenta
        ]}
      />
    </Canvas>
  )
}

Props

NurbsSurface Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | controlPoints | number[][][] | Yes | - | 3D control points grid defining the surface shape | | weights | number[][] | Yes | - | Weights for each control point | | degreeU | number | Yes | - | Degree of the surface in U direction | | degreeV | number | Yes | - | Degree of the surface in V direction | | color | string | No | '#ffffff' | Surface color (only used if no material is provided) | | wireframe | boolean | No | false | Whether to render as wireframe (only used if no material is provided) | | children | ReactElement | No | - | Material component (e.g., meshStandardMaterial, meshPhongMaterial) | | ...meshProps | MeshProps | No | - | All React Three Fiber mesh props are supported |

NurbsCurve Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | points | number[][] | Yes | - | Control points defining the curve shape | | knots | number[] | Yes | - | Knot vector defining the curve parameterization | | degree | number | No | 3 | Degree of the curve | | weights | number[] | No | [1, 1, ...] | Weights for each control point | | curveResolution | number | No | 50 | Number of points to sample along the curve | | color | string | No | 'black' | Line color | | segments | boolean | No | false | Whether to render as line segments | | dashed | boolean | No | false | Whether to render as dashed line | | vertexColors | number[][] | No | - | RGB colors for each vertex | | ...lineProps | LineProps | No | - | All drei Line component props are supported |

Development

This project is built with:

Setup

# Install dependencies
npm install

# Start development server
npm run dev

# Build the library
npm run build

# Run Storybook
npm run storybook

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.