guidocalvano / OgreJS

Ogre in javascript
2 stars 1 forks source link

Heavy math and performance, marshaling data #10

Open realazthat opened 13 years ago

realazthat commented 13 years ago

Preface: The JS api ideally should not be used to do heavy lifting, for example, per-frame procedural mesh generation etc., but instead be used for creating a scenegraph and less intensive per-frame operations on pre-built models, for example.

However, there should be mesh generation facilities (Ogre's ManualObject), for example, for one-time mesh generation, where performance matters less. In order to optimize this the most, I propose that we have an entirely JS implementation, so that the data does not have to be marshaled in and out of JS for each function call. The entire mesh would be done in JS, which v8 might be able to optimize more, then "cooked" into a native version of the implementation. We should benchmark one example of this, vs. directly calling native functions for each vertex/index created, and see if this strategy works. If so, we can do this for many possibly intensive APIs.

guidocalvano commented 13 years ago

the most important argument you make is not so much about creating mesh generators, but about doing complex vector math in js itself, because ping ponging control between C++ and JS wreaks havoc on performance potentially. Though on irc you said it might not be the case. We'd have to benchmark. Fact is we don't know, and building it in js is easier, so lets do that instead. (: