Code Monkey home page Code Monkey logo

frame.js's People

Contributors

bishopz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frame.js's Issues

Clear Libs

Frame.clearLibs = function(){
_libs = [];
};

to force a reload

Frame.flutter()

Something like

Frame.flutter = function( times, offset, [ease,] fn){

if(isNumber(offset)){

    $.for(times, function(i){

        setTimeout(fn, offset * i);

    });

} else if(isFunction(offset)){

    $.for(times, function(i){

        setTimeout(fn, offset(i) );

    });

} else if(optional(ease) === 'expo'){

    $.for(times, function(i){

        setTimeout(fn, expo(i, 0, offset, times) );

    });

}




};

add Frame.delay()

Frame(100);

would be the same as:

Frame(100, function(next){ next(); });

Change ordering of debug levels

Frame.debug = 0; // silent
Frame.debug = 1; >> errors only
Frame.debug = 2; >> titles & errors
Frame.debug = 3; >> logs & errors
Frame.debug = 4; >> titles, logs & errors
Frame.debug = 5; >> titles, logs & errors, and start and stop messages

Sequential calls within a for loop

I hope this is the appropriate way to address a question. I searched for another contact method for you, but did not find one. So...

I have successfully implemented Frame.js to sequence a series of calls. But when one of the functions is a for loop, the frames within the for loop (of which there are several ajax calls) are not performed in sequence. I have tried re-initiated the Frame within the loop function, but it did not resolve the problem. Do you have any other suggestions?

update description

Frame.js is the combination of two basic types of libraries, together these two open the opportunity to solve both problems in a more systematic, elegant and concise way than either separately.

Frame is a combination of a library loader, like require, yep/nope or LAB, and a flow control library, like async ...

The Frame sequence stops when a script fails to load

Should add support for a timeout value per Frame (in addition to useTimeout), and have a failover method that allows Frame to continue on.

This may require changing the script loader away from $LAB, as $LAB does not offer a "fail" state.

Consider Transitions

I've been thinking on how to manage transitions like for example crossfade or so on in frame.js, I think it's an enough cool feature to be easy to use instead of ending using a lot of flash everywhere to change between scenes :)

As frame.js is timeline based instead of node based, the "graphical view" of the solution could be something like:

var effects = [
{"name": "FX1", "start": 0, "end": 1000, "layer": 0, "id": 0 },
{"name": "FX2", "start": 750, "end": 2000, "layer": 1, "id": 1 },
{"name": "FXTransition", "start": 750, "end": 1000, "layer": 2, "id": 2 },
];
So the transition effect will affect during 250ms.
The transition effect should have two parameters: List of effects from the beginning of the transition, and list of effect at the end of the transition.
Right now for this example one will be the FX1, and the other one the FX2.

In summary what it will do is to create one FBO for each effect, and when it appears in action (.start()) it will disable the render to screen on both attached effects, and it will start using their FBO to do the transition using some shadermaterial or whatever you want to implement.

I've a proof of concept but before going further I wanted to check what you think about it.
I've made basically:

Include id parameter for each module instance, as we could link between effects, not just for this kind of effects but for many other kind.
Include a getModuleInstanceById or so function in frame.js
Create a TransitionModule with basic mix shader between the two fbo.
Include a input parameter on each effect in the transition similar to: parameters.input.renderToTexture=false. This parameter will be changed by the transition effect. And a parameter.output.fbo
Modify the doFrame in both effects to render to screen or to fbo according to the .renderToTexture parameter
So this is what I was doing yesterday and I got it working. Of course the part of including the extra input/output parameters and the doFrame switching between fbo or screen should be done in a cool fancy way so you could include each effect in a transition without need to modify it code.

Let me know what you think

update readme examples from Stack questions

Frame.yield() & Trampoline tail-calls

Add a yield function, like Unity has:

It is often more convenient to use the yield statement. The yield statement is a special kind of return, that ensures that the function will continue from the line after the yield statement next time it is called.

while(true) {
// do step 0
yield; // wait for one frame
// do step 1
yield; // wait for one frame
// ...
}

Frame.perf

(function(exports){
exports = exports || {};
var Frame = exports.Frame || {};
var tests = {};

Frame.perf = function(){
    Frame.perf('Frame.perf', 'start');
    var args = Array.prototype.slice.apply(arguments);

    var perf = {
        name : args[0],
        start:[],
        stop:[],
        duration:[]
    };
    if(tests.hasOwnProperty(perf.name)){ 
        perf = tests[perf.name];
    } else {
        tests[perf.name] = perf;
    };

    switch(args[1]){
    case 'start':
        var timer = new Date();
        perf.start.push(timer.getTime());
        break;
    case 'stop':
        var timer = new Date();
        perf.stop.push(timer.getTime());
        perf.duration.push( _.last(perf.stop) - _.last(perf.start) );
        //console.log(_.last(perf.stop) , _.last(perf.start),  _.last(perf.stop) - _.last(perf.start))
        break;
    };

    if(Frame.debug >= 3){
        Frame.log('Frame Perf Test ::', args);
    };

    Frame.perf('Frame.perf', 'stop');
    return perf;
};

Frame.perf.report = function(){
    var report = _.reduce(tests, function(m, perf){ 
        m[perf.name] = Math.floor(_.reduce(perf.duration, function(m, num){ return m + num; }, 0) / perf.duration.length);
        return m; 
    }, {});
    return report;
};

Frame.perf.count = function(){
    var report = _.reduce(tests, function(m, perf){ 
        m[perf.name] = perf.duration.length;
        return m; 
    }, {});
    return report;
};

Frame.perf.impact = function(){
    var report = _.reduce(tests, function(m, perf){ 
        m[perf.name] = Math.floor(_.reduce(perf.duration, function(m, d){ m += d; return m; }, 0) / 100);
        return m; 
    }, {});
    return report;
};

Frame.perf.range = function(){
    var report = _.reduce(tests, function(m, perf){ 
        m[perf.name] = Math.floor(_.range(perf.duration) / 100);
        return m; 
    }, {});
    return report;
};


Frame.perf.tests = tests;

})(window);

Frame.stack creates a memory leak if Frame() is used with setIntrval

Frame.stack grows in size with each Frame. Using it in with setInterval, to create a FPS timeline for instance, creates a memory leak in the development version.

This is not true in the production version, so I'm not sure how important it is. Seems better Chrome than Firefox, which is struggling with it's memory footprint right now.

At very least Frame.stack() should be disable-able via some config option, maybe even be disabled by default.

improve Frame's error reports

by calling

get message: function () { [native code] }
get stack: function () { [native code] }

and appending result to the error message

Frame.double() should be renamed

Even though double is not a reserved word in javascript. Some javascript minifiers do not like it's use (I assume because it is a reserved word in other languages).

splice.(1) causing problems in IE

IE does not support syntax array.splice(index[, howMany[, element1[, ...[, elementN]]]]) well. Using slice(1) instead fixing the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.