verb NURBS Library

repository·master·Indexed 21 days ago

https://github.com/pboyer/verb

A high-performance, cross-platform mathematical library for creating and manipulating NURBS (Non-Uniform Rational B-Splines) surfaces and curves. Built with Haxe, it supports compilation to JavaScript, C#, C++, Python, and PHP. Key features include derivative evaluation, adaptive tessellation, intersection calculations, and concurrent execution via WebWorkers or thread pools. The library is organized into four modules: verb.geom, verb.core, verb.eval, and verb.exe.

Tokens
2.4K
Snippets
13
Records
16
Agent score
74%

What's inside verb

  1. Overview of verb NURBS library

    master

    verb is an open-source, cross-platform library designed for creating and manipulating NURBS (Non-Uniform Rational B-Splines) surfaces and curves.

    Key features include:

    • Derivative evaluation
    • Adaptive tessellation
    • Intersection calculations
    • Concurrent execution via WebWorkers (in browsers) or thread pools (on other platforms), making it suitable for both browser-based and datacenter environments.

    Because it is built with Haxe, it can be compiled for multiple platforms including JavaScript, C#, C++, Python, and PHP.

  2. What is verb and how is it organized?

    master

    verb is a library for creating and manipulating NURBS (Non-Uniform Rational B-Splines) surfaces and curves. It provides advanced tools such as derivative evaluation, adaptive tessellation, and intersection. It supports concurrent execution via WebWorkers in browsers or thread pools on other platforms.

    Note: verb is a mathematical library, not a graphics library. It is designed to complement web graphics libraries like three.js rather than replace them.

    The library is organized into four functional modules:

    • verb.geom: Geometric types for working with NURBS (includes common curve and surface types). This is the recommended entry point for most users.
    • verb.core: Shared mathematical and geometric utilities.
    • verb.eval: Fundamental NURBS algorithms (evaluation, intersection, analysis, etc.).
    • verb.exe: Tools for managing multi-core evaluation across different platforms.
  3. Build the documentation site

    master

    The documentation is generated in two steps. First, run the generation script to transform .hx files into .md files within the docs directory. Second, use mkdocs to compile the markdown files into a static HTML website.

    node gen.js
    mkdocs build
  4. Install and use verb with JavaScript

    master

    To use verb in a JavaScript environment, install the pre-compiled package via npm:

    npm install verb-nurbs

    Once installed, you can use the pre-compiled packages found in build/js. The library is compatible with:

    • AMD (via require.js)
    • CommonJS (via browserify or in Node.js)

    For integration with three.js, you can convert verb geometric types into three.js Meshes and Lines.

  5. Use verb-nurbs directly in a webpage via UNPKG

    master

    You can import verb directly into a web page by including the pre-compiled script from UNPKG.

    <script language="javascript" src="https://unpkg.com/verb-nurbs"></script>
  6. Compile verb for C++

    master

    To compile for C++, ensure you have hxcpp installed (and XCode 7 if on OS X).

    1. Install the hxcpp dependency:
      haxelib install hxcpp
    2. Build the project:
      haxe buildcpp.hxml

    Output is located in build/cpp.

    haxelib install hxcpp
    haxe buildcpp.hxml
  7. Compile verb for JavaScript

    master

    If you are developing or building the library from source, use the following commands:

    • Build to JavaScript: npm run build
    • Create ES and UMD versions: npm run package
    • Run unit tests: npm run test
    npm run build
    npm run package
    npm run test
  8. ThreadPool platform compatibility and behavior

    master

    The behavior of ThreadPool depends on the target platform:

    • Neko or C++: Enables true concurrent execution. blockRunAllTasks() manages a pool of PoolThread instances, assigning tasks to available threads and executing the onFinish callback with the task's result once a thread completes its work.
    • Other Platforms (e.g., Browser/JS): Threading is not supported. In these environments, blockRunAllTasks() falls back to sequential execution, running each task one after another on the main thread and calling onFinish immediately after each task completes.