Future of CCPWGL
See original GitHub issueBelow are some topics regarding the future of ccpwgl that I’d like to discuss. The following pull request has been created to support this discussion: https://github.com/ccpgames/ccpwgl/pull/196
Matrix Library
Do we want to upgrade to a newer matrix library?
The latest glMatrix library from glMatrix.net (a later version of the one used now) has some performance benefits, a much more logical and consistent argument order (the receiving object is almost always first) vs the current ( the receiving object is either the last or the first argument), more functionality and optimizations.
Benefits:
- SIMD Support
- Faster calculations
- More functionality
- Some complicated calculations have been reduced to single functions
vec2
functionsvec4
functions separated from quaternion functions- better naming conventions
Penalties:
- Slightly more verbose in some situations
- Requires refactoring of ccpwgl
- Requires testing
Do we want to create and maintain our own library?
While the latest glMatrix.net library has a lot of functionality it is lacking some basic scalar operations (I have included these in the pull request in the file ext.js
) and it’s focus excludes any functionality for things like bounding boxes, bounding spheres, ray casting and planes (I have versions of these in testing presently).
There is no need for any of this extra functionality for ccpwgl to work with the new library as it is. Refactoring and replacing the current library is all that would be required.
However, my proposal is:
- Create and maintain our own library based off the latest glMatrix.net library
- Extend scalar functionality (without creating a new file with those extensions as seen in my pull request)
- Keep it separate from any ccpwgl files (as we have now)
- Keep the different math categories in separate files
- Provide a grunt process to build this library
- Migrate all glMatrix and math functions that exist solely in ccpwgl_int to this library
- Incrementally add non-core functionality (see list below)
I’d like to start adding (or see others adding) useful generic 3d library methods to enable quality applications to be made with minimal effort. Raycasting, colour picking and physics would be at the top of that list :3
I do not see this library having to be upgraded often once implemented so maintenance should be low.
Proposed Files and Folders
/src/math
// base
/src/math/gl3.js - Generic
// core
/src/math/vec2.js - Vector 2
/src/math/vec3.js - Vector 3
/src/math/vec4.js - Vector 4
/src/math/quat.js - Quaternion
/src/math/mat3.js - Matrix 3x3
/src/math/mat4.js - Matrix 4x4
// extended
/src/math/clr.js - Colors
/src/math/box.js - Bounding Box
/src/math/sph.js - Bounding Sphere
/src/math/pln.js - Plane
/src/math/tri.js - Triangle/ Face
/src/math/ray.js - Ray casting
// build
/dist/ccpwgl_gl3.js - Unminified
/dist/ccpwgl_gl3.min.js - Minified
EMCAScript 6 / Typescript
A couple of months back I converted the ccpwgl_int files to ES6 and while I didn’t initially see any benefits as it was a pain to keep up to date, it did make extending the library easier, removed the need for a build process (apart from converting to ES5), made things a little more readable and simplified some of the code.
Would anyone apart from myself benefit from moving to ES6 (or to Typescript as some others have suggested)? And more importantly, would @filipppavlov want to maintain the library in this format. :3 I’d be willing to put in the hours to covert it again (and the 10k or so linting issues as well) but only if it was to become the standard version.
For the immediate future I propose that we introduce some build tasks to create versions of ccpwgl_int
and the matrix library that support the ES6 import
and export
features.
Included in the aforementioned pull request there is a working example of how this could work: grunt es6
Proposed Files and Folders
/dist/ccpwgl_int.es6
/dist/ccpwgl_gl3.es6
Compiled Files
Move all compiled files to /dist/
.
Users of ccpwgl would only need this folder for ccpwgl to work.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top GitHub Comments
Any chance of getting an NPM package built and published? Would be really slick to see something like Travis CI building the repo and publishing it.
Presently trying to decide on a format for the extended matrix and collidables methods for y’all to consider, of which I have multiple versions. Any input would be appreciated. I’ve included an example for each option which shows how you’d expand a Tw2 meshes’ bounding box by a given point (this isn’t necessarily something you’d want to do, just an example!).
var mesh = ship.wrappedObjects[0].mesh.geometryResource.meshes[0]
Match the style of the glMatrix libraries
Helper functions only, suited to ccpwgl’s coding style
Add new Tw2Parameters
New Collidable constructors (wip)
Create a new
Tw2CollidableAccumulator
constructor andTw2Collidable
constructor which would be used in a similar way toTw2BatchAccumulator
and render batches. Collidables are collected (Planes, SpriteSets, SpotlightSets, Decals, Boosters, Mesh) and then operations are performed on them. All of the extended matrix functions could be added as static methods to these.Extend Tw2Geometry constructors
Extend existing tw2 constructors with relevant methods.