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

@imaginary-maths/surfer-core-gpu

v0.2.1

Published

A WebGL-based implicit surface render

Downloads

14

Readme

surfer-core-gpu

This package provides a WebGL (actually, CindyJS and CindyGL) based renderer for algebraic surfaces. It can also be used for other types of implicit surfaces. However, the quality of the results may vary a lot.

Check out the demo.

Usage

Add the package to your project:

npm install @imaginary-maths/surfer-core-gpu

Import the main class, instantiate and modify:

import '@imaginary-maths/surfer-core-gpu';

// ...

const container = document.getElementById('my-container');
const s = await SurferCoreGpu.create(container, 512, 512);

s.setExpression('x^2+y^2+z^2+x*y*z-4*a');
s.setAlpha(0.75);
s.setZoom(0.1);
s.setParameter('a', 1);

// For translucent surfaces, having the same material for both sides often looks better.
s.setTwoSided(false);

Some getters are also available:

s.getExpression();
// "x^2+y^2+z^2+x*y*z-4*a"
s.getAlpha();
// 0.75
s.getZoom();
// 0.1
s.getParameterNames();
// ["a"]
s.getParameters();
// { a: 1.0 }
s.getTwoSided();
// false

Some elements of the intersection algorithm can be tweaked as well:

const PolynomialInterpolation =
  SurferCoreGpu.Algorithms.PolynomialInterpolation;

// For some non-algebraic functions, Chebyshev nodes yield better results.
// Explictly set the maximum degree of the interpolating function for experimentation.
const algorithm0 = new PolynomialInterpolation(
  PolynomialInterpolation.nodeGeneratorChebyshev(),
  11,
);
s.setAlgorithm(algorithm);

// Equidistant nodes are the default and yield good results if the zoom parameter is rather small.
const algorithm1 = new PolynomialInterpolation(
  PolynomialInterpolation.nodeGeneratorEquidistant(),
);
s.setAlgorithm(algorithm1);

The SurferGpuCore object exposes two internal elements:

  • canvas: A HTMLCanvasElement that is used for drawing the surface. This element should not be modified, but its properties can be read safely.
  • element: A HTMLDivElement used as a container for the canvas. Additional CSS properties such as background color, width and height can be applied to this element.

Bundled CindyJS

This package uses the CindyJS package internally. Since CindyJS is not published through NPM, you can either add the libraries from the vendor folder to your project manually (via <script> tags), or you change your imports to

import '@imaginary-maths/surfer-core-gpu/dist/surfer-core-gpu-bundled-cindyjs';

Build

npm install
npm run build

Credits

Created by Christian Stussak for IMAGINARY gGmbH, based on a prototype by Aaron Montag.

License

Copyright 2022 IMAGINARY gGmbH

Licensed under the Apache v2.0 license (see the LICENSE file).