-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uniform function templates #99
Comments
Agreed. I suggested this here: #75 (comment) For an example in Cesium, see https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/Source/Scene/Cesium3DTileContent.js |
I can start going through some of our unlabeled functions. @lilleyse, thoughts on @lasalvavida's template before I move forward? |
@JoshuaStorm We probably want to go the whole way with @pjcozzi's suggestion. That is, make a Stage.js that looks something like this: function Stage() {
this.name = undefined;
this.before = [];
this.after = [];
};
Stage.prototype.run = function(gltf, options) {}; Then change the stages that currently just export functions to follow the Stage template. module.exports = RemoveUnusedMeshesStage;
function RemoveUnusedMeshesStage() {
this.name = 'removeUnusedMeshes';
this.before = ['addPipelineExtras'];
this.after = [];
}
RemoveUnusedMeshes.prototype.run = function(gltf, options) {
return new Promise(resolve, reject) {
// This is a synchronous stage, so it's pretty easy
// async will need a little more work, but shouldn't be too difficult
removeUnusedMeshes(gltf);
resolve();
}
} The function bodies won't need to change until we have something set up for using the before and after to resolve dependencies, but it would be good to go ahead and set them up while we're making this change. |
We may also want to start keeping stages in a subdirectory of lib and utility functions in another. |
Yup, all the suggestions here should be part of a larger cleanup/restructuring process, which I'm going to open an issue for pretty soon and @lasalvavida will handle. @JoshuaStorm in the meantime there are a few other stages you can work on like pre-cache vertex optimization and transparent textures. |
@lasalvavida What exactly is the purpose of having a synchronous function return as a promise? |
@JoshuaStorm It is so that all stages can be executed in the same way. Eventually, when we have stage dependencies and custom pipelines we need to be able to run a stage by name without knowing anything about it and ideally without needing to do any special handling for async stages. However, I think it actually makes more sense to have synchronous stages return undefined and asynchronous ones return promises which would be equally easy to handle, but would result in fewer changes to the code-base. |
As we continue adding pipeline stages, it is going to be important to keep a uniform template for pipeline stage functions so that they can be used in the same way.
I would propose the following:
For #130:
I would classify the following as "stages" and should be converted to use this template. Anyone can feel free to do them in any order; it doesn't need to be one big pull request.
The text was updated successfully, but these errors were encountered: