Live data from Hacker News

Two.js

jonobr1.github.io

41–50 of 92 posts

Re: Two.js

#44
post #26

What I am struggling with, is the use case of a library like this. Is this oriented towards gaming or substitude something like d3.js or is it has a simplier api, for the developer than other libraries. Or is it a library to showcase the cool stuff that can be done with new technologies. I think the main difference and the selling point is that it is "renderer agnostic" but I don't understand the benefits of that.

it's for motion graphics. https://www.youtube.com/watch?v=2jTwX8jz-44

It's for motion graphics, with no facilitation for motion graphics! Brilliant!

Re: Two.js

#45
post #14
post #12

what is meant by "modern web browsers"?

I guess it would be something along the lines of this quote from http://farukat.es/journal/2011/02/528-modern-browser : "A modern browser is any browser that: successfully renders a site that you just built using web standards, testing only in your browser of choice along the way, with all the essentials functioning well; without you having written any browser-specific hacks, forks or workarounds; and shows great per…

In other words, "modern browsers" might as well be mythical creatures :)

Re: Two.js

#46
post #20
post #12

what is meant by "modern web browsers"?

Roughly, self updating html5 compliant browser.

Why self-updating? Is my version of Firefox non-"modern" simply because I install and update it through my operating system's package management system?

Re: Two.js

#47
post #42

I'm looking for a library that can create a calligraphic shape (path) from a stroke path.

You can do this pretty easily with SVG, assuming your browser supports SVG, and your “caligraphic stroke” means you want the envelope of an ellipse translated along the path.

Or do you need the precise bezier-curves for the stroke outline? For that you need to do some computation.

Re: Two.js

#48
post #26

What I am struggling with, is the use case of a library like this. Is this oriented towards gaming or substitude something like d3.js or is it has a simplier api, for the developer than other libraries. Or is it a library to showcase the cool stuff that can be done with new technologies. I think the main difference and the selling point is that it is "renderer agnostic" but I don't understand the benefits of that.

Renderer-agnostic is nice, actually, when you need to support lots of different browsers. Some mobile browsers can't do WebGL as fast as they do Canvas, for instance. Other browsers will have a huge speed advantage with WebGL. I'm not sure if any are faster with SVG, or the relative performance between SVG and canvas. But being able to do some test renders quickly in all three modes should allow you to select the fas…

I love SVG support because it means you can render something in vector art in the browser which is also downloadable as a file by the user. Drawing stuff in the browser which is then stuck there is cute but lacks an important layer of interoperability with the rest of the computing ecosystem. So here we appear to get the best of all worlds: render to whatever is fastest in the browser but get automatic "export as SVG" for free.

Re: Two.js

#49
post #48

Earlier quoted context omitted.

Renderer-agnostic is nice, actually, when you need to support lots of different browsers. Some mobile browsers can't do WebGL as fast as they do Canvas, for instance. Other browsers will have a huge speed advantage with WebGL. I'm not sure if any are faster with SVG, or the relative performance between SVG and canvas. But being able to do some test renders quickly in all three modes should allow you to select the fas…

I love SVG support because it means you can render something in vector art in the browser which is also downloadable as a file by the user. Drawing stuff in the browser which is then stuck there is cute but lacks an important layer of interoperability with the rest of the computing ecosystem. So here we appear to get the best of all worlds: render to whatever is fastest in the browser but get automatic "export as SVG…

You can save out a to png quite easily: canvas.toDataURL();

Re: Two.js

#50

Why Vector.isZero() is checking whether a vector length is smaller than 0.0001? Why this arbitrary number and not e.g. 0.00000001?

Dunno about this case, but probably because floating point arithmetic is a bitch. Try the following in Chrome's developer console:

    (0.3 - 0.1 - 0.1 - 0.1) === 0.0
    > false
    0.3 - 0.1 - 0.1 - 0.1
    > -2.7755575615628914e-17
In order to get helpful results, we're gonna have to pick some semi-arbitrary epsilon. Still, my problem domain might require a different epsilon than they expect; even if they have a default, the API should allow me to specify my own choice of epsilon.

They might also want to consider being more nuanced for the equals method than just taking the difference and comparing to zero. See http://floating-point-gui.de/errors/comparison/

Post reply on HN