4 ms·
It seems to be pretty heavy on object allocation, eg: BABYLON.Vector3.prototype.add = function (otherVector) { return new BABYLON.Vector3(this.x + ot
by dtf 13y ago
It seems to be pretty heavy on object allocation, eg:
BABYLON.Vector3.prototype.add = function (otherVector) {
return new BABYLON.Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
};
I do a lot of WebGL work and I'm constantly fretting about avoiding allocations. For instance, compare to gl-matrix's operator:
vec3.add = function(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
return out;
};
A little more awkward, but you're only allocating the vector once and then modifying in place wherever possible. THREE.js takes as similar approach with THREE.Vector3.
- dirkk0 13y agoExactly - quote mrdoob: "We try really hard to not create or destroy objects at run time. We use pools and reuse objects as much as possible, or flags. We don't want to rely in the garbage collector." https://github.com/mrdoob/three.js/issues/2435#issuecomment-8705624 https://github.com/mrdoob/three.js/issues/2435#issuecomment-...
- deltakosh 13y agoThe next version (1.2) will remove the pressure on GC by using in place operator and by reusing more entities
- deleted 13y ago[deleted]
- dualogy 13y agoMakes me wonder why this isn't built on top of three.js to begin with? Three has well over 2 years of rock-solid improvements under its belt, from hardcore graphics programmers to boot. Three is not a fully fledged game engine, it's "only" providing a reasonably easy to use, sane 3D graphics engine to run on, which raw WebGL is decidedly not. So any JS "game engine" project would do well to build on three.js (to pick up their many performance and other improvements from the last 2-3 years and those that the community will keep producing over the years to come) and then on top of that provide actual, non-rendering related "game engine" features akin to Unity3D. Objects management, component system, triggers, events, usable input management abstractions, materials management, LOD systems, configurable shadowing/lighting setups (on top of the options provided by three+friends), pluggable post-fx shaders with a few out-of-box ones and easy custom shader integration etc etc etc.