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

gl-spikes3d

v1.0.11

Published

gl-spikes3d =========== Draws axis spikes compatible with gl-axes3d. This can be useful to illustrate selections or specific points in a point cloud

Downloads

116,517

Readme

gl-spikes3d

Draws axis spikes compatible with gl-axes3d. This can be useful to illustrate selections or specific points in a point cloud

Example

Try it out here

var shell = require("gl-now")({ clearColor: [0,0,0,0], tickRate: 5 })
var camera = require("game-shell-orbit-camera")(shell)
var mat4 = require("gl-matrix").mat4
var createAxes = require("gl-axes")
var createSpikes = require("gl-spikes")

//Bounds on function to plot
var bounds = [[-1,-1,-1], [1,1,1]]

//camera.lookAt([-15,20,-15], [0,0,0], [0, 1, 0])
camera.lookAt([2, 2, 2], [0,0,0], [0,1,0])

//State variables
var axes, spikes

shell.on("gl-init", function() {
  var gl = shell.gl
  
  axes = createAxes(gl, {
    bounds: bounds,
    tickSpacing: [0.1,0.1,0.1],
    textSize: 0.05
  })

  spikes = createSpikes(gl, {
    bounds: bounds,
    colors: [[1,0,0,1], [0,1,0,1], [0,0,1,1]],
    position: [0,0,0]
  })
})

shell.on("gl-render", function() {
  var gl = shell.gl
  gl.enable(gl.DEPTH_TEST)

  //Compute camera parameters
  var cameraParameters = {
    view: camera.view(),
    projection: mat4.perspective(
        mat4.create(),
        Math.PI/4.0,
        shell.width/shell.height,
        0.1,
        1000.0)
  }


  //Update spike position
  var t = 0.001*Date.now()
  spikes.position = [Math.cos(t), Math.sin(t), Math.cos(2*t+0.1)]

  //Draw objects
  axes.draw(cameraParameters)
  spikes.draw(cameraParameters)
})

Install

npm install gl-spikes

API

var spikes = require('gl-spikes')(gl, options)

Creates a new spike object.

  • gl is a WebGL context
  • options is a list of optional parameters which are passed along

Methods

spikes.draw(camera)

Draws the axis spikes using the given camera coordinates.

  • camera.model is the model matrix for the camera
  • camera.view is the view matrix
  • camera.projection is the projection matrix

spikes.update(options)

Updates the parameters of the axes spikes. options is an object with the following properties:

  • position the position of the spike ball in data coordinates
  • bounds the bounds of the axes object
  • colors an array of 3 length 4 arrays encoding the RGBA colors for the spikes along the x/y/z directions
  • enabled an array of 3 flags which if set turns on or off the spikes
  • drawSides an array of 3 flag which if set turns on or off the projected spikes in each data plane
  • lineWidth an array of 3 numbers giving the thickness of the spikes for each axis

spikes.dispose()

Destroys the spike object and releases all associated resources.

Credits

(c) 2014 Mikola Lysenko. MIT License