Giter Club home page Giter Club logo

geom-builder's People

Contributors

dmnsgn avatar vorg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mdsumner dmnsgn

geom-builder's Issues

API

all your options have dual type which seems confusing - why not just pass 0?

Use Uint32Array when necessary

It is possible to build mesh with more than 64k vertices that creates clamped indices due to Uint16Array array for cell. Either we should switch to Uint32Array or upgrade to it once positionsIndex is above 60k

Ideas for generalised version 3

Currently we come with assumptions about supported attributes e.g. that positions are always enabled

const builder = createGeomBuilder({ colors: 4, cells: 3 })

builder.addPosition([0, 0, 0])
builder.addColor([0, 0, 0, 1])
builder.count //1
builder.positions //Float32Array [0, 0, 0]

a more generic API could be as follows:

const builder = createGeomBuilder({ positions: 3, colors: 4, cells: { stride: 3, type: Uint32Array }})

builder.add('positions', [0.0, 0.0, 0.0])
builder.add('colors', [0.0, 0.0, 0.0, 1.0])
builder.add('cells', [0, 1, 2])

buidler.positions //Float32Array [0, 0, 0]

The builder.add('positions', []) fees weird, it should be builder.add('position', []) but then how do we guess the name? By adding s automatically?

Also

builder.positions

//vs 

builder.get('position')

Also if we change API so much this should be new module e.g. auto-expanding-buffer. What makes it geometry specific is assumption that all attributes grow at the same rate which is actually not always true (e.g. instancing). Would the api be then builder.count('position') and or builder.count('cells')?

auto-buffer

auto-buffer auto expanding buffer. Is there something similar on npm already?

That also leads to builder.resetAll() and more granular builder.reset('position')... which leads to fact that maybe we need builder per buffer?

const autoBuffer = require('auto-buffer') //free npm name!
const positions = autoBuffer() //no predefined stride/size, probably starts with length 32
positions.add([0, 0, 0])
positions.count //undefined
positions.length //3, actual used length since last reset, not allocated buffer size
let count = positions.length / 3 //diy
positions.reset()

Abysmal performance due to using arguments in each add* function call

Geom builder allows to do addPosition([x, y, z]) and addPosition(x, y, z) to avoid vector allocation. To enable this I use arguments parameter. Turns out it allocates a lot of junk in Firefox causing GC hiccups and has impact on CPU in Safari and Chrome as well.

//1 old
GeomBuilder.prototype.addPosition = function (pos) {
  var values = arguments[0].length ? pos : arguments

//2 new, best
GeomBuilder.prototype.addPosition = function (pos) {
  var values = pos

// 3 better than 1, but still slower than 2
GeomBuilder.prototype.addPosition = function (...pos) {
  var values = pos[0].length ? pos[0] : pos

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.