requestanimationframe

running requestAnimationFrame from within a new object

牧云@^-^@ 提交于 2019-12-07 01:40:23
问题 I'm having trouble running an animation. This is inside var ob1 = function() {}; . When called, it runs for a while and then I get the error Uncaught RangeError: Maximum call stack size exceeded . However, this same structure has no problems running outside of the object. /////////////// Render the scene /////////////// this.render = function (){ renderer.render(scene,camera); if(isControls == true) controls.update(clock.getDelta()); this.animate(); //console.log(true); requestAnimationFrame

requestAnimationFrame running slow on weak machines. Work around?

落爺英雄遲暮 提交于 2019-12-06 17:40:39
So, I am doing an animation (Not on a website/webpage!), that uses Javascript . For the animation, I use requestAnimationFrame instead of setInterval , as setInterval did not work well enough for what I need. However, although requestAnimationFrame works well on decently powered devices, slow devices can't keep up with the standard 60 FPS, thereby slowing down the entire animation time. Is there a way I can make the animation work under a time frame, and have the FPS vary depending on how well it keeps up? Other ideas are welcome as well. (Note, I would really prefer not to post code, just

Should I use window.webkitRequestAnimationFrame instead of setInterval?

我与影子孤独终老i 提交于 2019-12-06 16:10:58
I am developing a game in JavaScript and I am confused on which one I should use - window.webkitRequestAnimationFrame or setInterval for moving my game characters. you can use window.webkitRequestAnimationFrame instead of setInterval var counter = 0; var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame; var cancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window

“Uncaught Type” error with requestAnimationFrame

∥☆過路亽.° 提交于 2019-12-06 16:09:06
So I have written a working application (actually half of it) with requestAnimationFrame. Before the project gets too complex I'm rushing to rewrite it in an object-oriented style so we can implement plugins better (and also fix modules without changing the whole app). In fact the first version of the app was really messed up and made up from a lot of test code. So I have the following: Aventura.prototype.update = function() { var av = this; requestAnimationFrame(av.update); /* ... frame code ... */ }; And I get "Uncaught TypeError: Type error " in the console log, right in the

Setting correct this-value in requestAnimationFrame

三世轮回 提交于 2019-12-06 13:41:39
问题 I have an app-object constructer that looks like this: var app = function(loadedsettings) { return { init: function() { this.loop(); }, loop: function() { this.update(); window.requestAnimationFrame(this.loop); }, update: function() { //loop through settings and call update on every object. }, settings: [ //array of settings objects, all with update methods. ] }; } Then when I do: var theApp = app(settings); theApp.init(); I get: Uncaught TypeError: Object [object global] has no method

requestAnimationFrame implementation recursive?

南笙酒味 提交于 2019-12-06 11:06:14
I'm currently experimenting with three.js, which relies on requestAnimationFrame to perform animations. Question: Wouldn't the following code result in infinite recursion before the cube rotations and renderer.render function invocation? function render() { requestAnimationFrame(render); cube.rotation.x += 0.1; cube.rotation.y += 0.1; renderer.render(scene, camera); } render(); The code works, but I'm trying to improve my overall understanding of javascript. The way I see it, is that render is invoked as a callback function. But does that mean that javascript continues running through the code

Does a MutationOberserver callback fire within the same animation frame in which observed elements were modified? [closed]

喜夏-厌秋 提交于 2019-12-06 11:02:00
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last month . Suppose I make changes to an element inside a frame created with window.requestAnimationFrame and that the modified element is being observed by a MutationObserver . Does the MutationOberserver 's change handler fire within the same frame and before the browser does rendering that comes after the frame? (I can imagine that this may not be true with some polyfills. I'm curious to know if there's any guarantee that

requestAnimationFrame scope change to window

狂风中的少年 提交于 2019-12-05 06:58:14
I have a chain of objects that looks like this: Game.world.update() I would like to use requestAnimationFrame to determine the framerate of this function. However when I implement it like this: World.prototype.update = function() { requestAnimationFrame(this.update); } The scope changes from the world object to the window object. How do I maintain the scope I want while calling requestAnimationFrame()? I know it has something to do with anonymous functions and such, but I can't get my head around it. Usual approach, works everywhere: World.prototype.update = function() { var self = this;

running requestAnimationFrame from within a new object

眉间皱痕 提交于 2019-12-05 06:41:37
I'm having trouble running an animation. This is inside var ob1 = function() {}; . When called, it runs for a while and then I get the error Uncaught RangeError: Maximum call stack size exceeded . However, this same structure has no problems running outside of the object. /////////////// Render the scene /////////////// this.render = function (){ renderer.render(scene,camera); if(isControls == true) controls.update(clock.getDelta()); this.animate(); //console.log(true); requestAnimationFrame(this.render()); } /////////////// Update objects /////////////// this.animate = function (){ console

Exact time of display: requestAnimationFrame usage and timeline

让人想犯罪 __ 提交于 2019-12-04 23:49:27
问题 What I want to achieve is to detect the precise time of when a certain change appeared on the screen (primarily with Google Chrome). For example I show an item using $("xelement").show(); or change it using $("#xelement").text("sth new"); and then I would want to see what the performance.now() was exactly when the change appeared on the user's screen with the given screen repaint. So I'm totally open to any solutions - below I just refer primarily to requestAnimationFrame (rAF) because that