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

load-wavefront-obj

v0.8.0

Published

Load the graphics buffer data from an obj model and return a draw command that accepts options

Downloads

12

Readme

load-wavefront-obj npm version Build Status

STILL VERY MUCH A WORK IN PROGRESS

Loads the graphics buffer data from a .obj file that's been parsed using a .obj parser and return a draw command that accepts options

View demo

To Install

$ npm install --save load-wavefront-obj

Tutorials

Running the demo locally

// TODO

Usage

var loadWFObj = require('load-wavefront-obj')

// You would usually parse your .obj files before runtime and then `xhr` GET request the pre-parsed JSON
var parseWFObj = require('wavefront-obj-parser')
var modelJSON = parseWFObj(GetWavefrontFileSomehow())

var gl = GetCanvasWebGLContextSomehow()

// This can be a DOM image element or a Uint8Array of pixel data
var image = document.getElementById('some-already-loaded-image')

var model = loadWFObj(gl, modelJSON, {texureImage: image})

// Later inside of your render function
model.draw({
  attributes: model.attributes,
  uniforms: {
    // Specify your uniforms
    uAmbientColor: [1.0, 1.0, 1.0],
    // ...
  }
})

See something broken, confusing or ripe for improvement? Feel free to open an issue or PR!

API

var model = loadWFObj(parsedWFJSON, options) -> object

parsedWFJSON

Required

Type: string

A wavefront .obj file that has been parsed into JSON.

Usually you'd use wavefront-obj-parser to parser the .obj file pre-runtime. But any parser that outputs the same format will do.

Options

textureImage

type HTMLImageElement or Uint8Array

You pass in an HTMLImageElement or Uint8Array for your model's texture

If using an image element, make sure that the onload event has already fired

// example of loading the image
var image = document.getElementById('my-image') || new window.Image()
image.src = 'https://cool-image-texture.com/cool-image.jpg'
image.onload = function () {
  loadWFObj(gl, modelJSON, {textureImage: image})
}

model

// lorem ipsum

TODO:

  • [x] Finish the first iteration of the draw function
  • [ ] Demo in raw WebGL
  • [ ] Demo using regl
  • [ ] Write Documentation
  • [ ] Add tests using require('gl') and test against expected .png file fixtures. example

To Test:

The test suite requires imagemagick to be installed locally

$ npm run test

See Also

License

MIT