GSAP Tweenlite tweens will not ease - animation

I am building a animated banner with GSAP, the basic animations work fine but the tweens will not ease and will stop functioning altogether when adding further ease statements like bounce.
I am using this piece of code to animate all the stuff.
<script type="text/javascript" src="js/TweenLite.min.js"></script>
<script type="text/javascript" src="js/CSSPlugin.min.js"></script>
<script>
window.onload = function(){
var logo = document.getElementById("logo");
TweenLite.to("#logo", 1, {left:"90px"});
TweenLite.from("#container", 0.50, {left:"-400px",opacity:0,delay:1});
TweenLite.from("#control", 1, {scale:0,opacity:0,delay:2});
TweenLite.from("#cta", 0.15, {scale:0,opacity:0,delay:3.5,ease: Bounce.easeOut,});
}
</script>
Am I missing something? Its frustrating me to bits.

I see two problems:
1) There's an extra comma after your ease:
//BAD:
TweenLite.from("#cta", 0.15, {scale:0,opacity:0,delay:3.5,ease: Bounce.easeOut,});
//GOOD:
TweenLite.from("#cta", 0.15, {scale:0,opacity:0,delay:3.5,ease: Bounce.easeOut});
2) The Bounce ease isn't in the core TweenLite file - you need to either load EasePack or just TweenMax (which includes TweenLite, CSSPlugin, EasePack and a bunch of other stuff). If you're worried about file size, it should be a non-issue because TweenMax is whitelisted on every major ad network (meaning its file size is free), and it's probably the most widely cached file in ads across the web.
Little tip: if you haven't tried the TimelineLite or TimelineMax tools (also part of GSAP), you'll love them especially for ads. They'll make it so much easier to manage your timing and experiment and skip to different portions of the animations while you're working. Your code could be more concise with them too:
window.onload = function(){
var tl = new TimelineLite();
tl.to("#logo", 1, {left:90})
.from("#container", 0.5, {left:-400, opacity:0})
.from("#control", 1, {scale:0, opacity:0}, "+=0.5")
.from("#cta", 0.15, {scale:0, opacity:0, ease: Bounce.easeOut}, "+=1.5");
}
Now you can tweak the timing of any of the individual animations and the changes will cascade down to the rest. Like if you need to make the first tween 0.5 seconds longer, you don't have to then edit all of the "delay" values of subsequent tweens. Plus now you've got one TimelineLite object that you can pause(), seek(), reverse(), timeScale() or whatever you want. It'll open entirely new possibilities workflow-wise for you.
Might interest you:
https://greensock.com/position-parameter
https://greensock.com/sequence-video
Also keep in mind there's a great community in the forums at https://greensock.com/forums that's dedicated to helping with GSAP-specific questions.
Happy tweening!

Related

D3. Js force oriented graph, where path is not compatible with ie10, ie11 [duplicate]

I have some SVG lines with line markers on them, and I have a script that moves those lines around. This works fine on all browsers, including IE9.
However, I just tried it on IE10, and the line markers get left behind when the line moves.
An example of this can be seen here: http://jsfiddle.net/swYRK/8/
I have tried this on both Windows 7 and 8.
Anyone know what's going on? Is this an IE10 bug, or is there another way to move the line and markers?
(Note the actual application is very performance sensitive, so I very much want to avoid doing something like re-creating the lines every frame while I move them, or something.)
-
Edit: this seems like a real IE 10 bug. I've found one open issue in the IE bug tracker (which requires a Microsoft account to even see, which makes it not visible to Google. Hello?), which I have added information to. IE has yet to accept the issue.
If there are any other work-arounds that people can think of, that would be great to hear. Completely removing the end markers, rendering that, and then re-adding them works-ish (shows visible flashing), but would not be acceptable in my application, unfortunately.
This is a quick way of doing it, that works well.
I have not noticed any flickering or performance related issues.
Simply re-add the svg node in it's original place:
if (navigator.appVersion.indexOf("MSIE 10") != -1) {
svgNode.parentNode.insertBefore(svgNode, svgNode);
}
Of course, you could use any browser sniffing of choice..
I want to elaborate a little on the amazing answer given by #ChristianLund and how I used it successfully in my code
In my force animation, I have a tick function that looks like this:
force.on("tick", function() {
...
});
I also hold all of my graph links inside the link variable, defined like so:
var link = svg.selectAll(".link").data(links).enter() ...
Now, to implement the magic suggested by Christian, I've added this line in the beginning of my tick function:
force.on("tick", function() {
link.each(function() {this.parentNode.insertBefore(this, this); });
...
});
This seems to fix the IE 10 problems... of course it's recommended to add this patch only on IE 10
In ie10/11, I found that the line does not move when it with marker-start/marker-end atrribute, I tried to remove those atrributes in your example, and it works. So the idea is remove the atrributes before set the x/y, then reset the atrributes after all jobs done.
You may try this hack:
$("#button4").click(function () {
$("#line1")[0].setAttributeNS(null, "x1", 50);
$("#line1")[0].setAttributeNS(null, "y1", 50);
$("#line1")[0].setAttributeNS(null, "x2", 150);
$("#line1")[0].setAttributeNS(null, "y2", 50);
var oldAttValueDisplay = $("#line1")[0].getAttributeNS(null, "display");
$("#line1")[0].setAttributeNS(null, "display", "none");
setTimeout(function() {$("#line1")[0].setAttributeNS(null, "display", oldAttValueDisplay);}, 0);
// static: setTimeout(function() {$("#line1")[0].setAttributeNS(null, "display", "block");}, 0);
});

argon-aframe move with the users geolocation

I have this project:
my codepen
I want to be able to move forward when the user walks, so it feels like they are walking thru the floor plan in VR as they are in real life.
my goal is get the geolocation of the user and show them the room matching theirs location and have them walk around the room while viewing the AR on the phone they would see paintings on the walls.
my challenges are:
walk in real life and move in VR (right now I have it auto walking forward in the meantime)
var speed = 0.0;
var iMoving = false;
var velocityDelta;
AFRAME.registerComponent("automove-controls", {
init: function() {
this.speed = 0.1;
this.isMoving = true;
this.velocityDelta = new THREE.Vector3();
},
isVelocityActive: function() {
return this.isMoving;
},
getVelocityDelta: function() {
this.velocityDelta.z = this.isMoving ? -this.speed : 0;
return this.velocityDelta.clone();
}
});
capture the user geo location so the moment they open the site they are placed relative to their location on the floor plan
this is my first attempt so any feed back would be appreciated.
As far as i know argon.js is more about geoposition than spatial/marker based augmented reality.
moreover It's quite worrying, that their repo for aframe was not touched for a while.
Argon seems like a library for creating scenes in certain points around the user, even their examples base on positioning stuff around, reason being the GPS/phone accelerometers are way too bad to provide useful data for providing spatial positioning. Thats why VIVE needs two towers, and other devices at least a camera/IR device, to get information about the HMD device.
Positioning the person inside a point depending where are they in a room is quite a difficult task, You would need to get a point of reference and position the user accordingly. It seems impossible, since the user can be anywhere in the world.
I would try to do this using jerome-etienne's marker based AR.js. The markers would be the points of reference You need, and although image processing seems like a difficult task, AR.js is surprisingly stable with multiple markers, which help in creating complex scenes.
The markers seems like a good idea, for they can help You with the positioning, moreover simple scenes have no problem with achieving 60+fps, making the experience quite comfortable.
I would start there, since AR.js seems to be updated frequently.

Skrollr Excessively Jerky

I've been working on a Skrollr site but it appears to be getting excessively jerky. I've had dev tools open and have found a few really really slow frames, but I don't have the knowledge to track down exactly what is going wrong.
My observations are:
it is slower scrolling down than up
intermittently it is absolutely fine
So far I have tried a few things
Given the first segment a translateZ value to try and separate out the paint (I have no idea if this is correct – I'm really at the limit of my knowledge!)
Had a go getting rid of the relative animations (data-top-bottom etc) which could well be slowing things down, but after changing everything back to static numbers (data-1000 etc) its still almost identical
Can anyone shed any light on this? The URL is http://fieldviewfestival.co.uk/500 ... power up!
I think I've fixed it!
The webfonts weren't fully loaded when skrollr kicked in. After initializing it I added a
$(window).load(function(){
Where I refreshed skrollr I then added the following:
s.refresh();
I think the main problem was that the height of the page wasn't calculated by the time skrollr kicked in.
Also I had a strange scrollbar left over (so a scrollbar on the body AND html), which skrollr hadn't removed so I also added above that function
$(window).trigger('resize');
The final initialize looks like this:
var s = skrollr.init();
$(window).load(function(){
// console.log("Loaded");
$(window).trigger('resize');
s.refresh();
});
NB Silly miskate I made as well, don't use the function $(document).load(

Webgl and three.js running great on chrome but HORRIBLE on firefox

Basically I am downloading a zip file and extracting a collada file to load in the browser. This works freaking awesome in chrome but is REALLY slow with model movement from the mouse in Firefox. I cant seem to figure this out or if there's a setting I'm missing to speed up Firefox or what. The file is loaded up here
http://moneybagsnetwork.com/3d/test.htm
Its using jsunzip and three.js to load everything. I've bypassed the jsunzip and that's not the issue. I've also dumbed down the model to not use any event listeners and no lights and that didn't help one bit. Completely stumped here and the model really isn't that big :/
Here is a link to a zip of the files I'm using
http://moneybagsnetwork.com/3d/good.zip
Sorry about the multiple commented lines. I might turn things back on if this gets fixed.
I have noticed that Chrome is usually way faster and more responsive with Three.js applications than Firefox. The difference is not so much on the WebGL side, but at the plain Javascript supporting code.
Looking at your code, it seems you do some very heavy javascript stuff on your onmousemove function. This could very well cause much of the performance gap between the browsers. Mousemove is executed many many times during each and every mousemovement, so it quickly adds up to slow performance. It could also be that Firefox actually creates more mousemove events for similat cursor movements (not sure).
You could either move most of the raycasting and other stuff from mousemove to mouseclick. Alternatively, you could implement a delayed mousemove so that the function is called only maximum of X times per second, or only when the mouse has stopped. Something like this (untested but should work):
var mousemovetimer = null;
function onmousemove(event){
if (mousemovetimer) {
window.clearTimeout(mousemovetimer);
}
mousemovetimer = window.setTimeout(delayedmousemove, 100);
}
function delayedmousemove(event) {
// your original mousemove code here
}
Maybe your graphics card is in our blacklist. There is usually a note about this towards the bottom of about:support.
Cards can be blacklisted for various reasons, missing drivers / features, occasional crashes ... see:
http://www.sitepoint.com/firefox-enable-webgl-blacklisted-graphics-card/
To enable WebGL, set webgl.force-enabled to true.
To enable Layers Acceleration, set layers.acceleration.force-enabled to true
To enable Direct2D in Windows Vista/7, set gfx.direct2d.force-enabled to true

Three.js performance?

I run quite a simple loop creating 30 new Cube meshes:
for(i=0; i<30; i++){
var zPos = 0 + i * (cubeHeight+ySpace) + cubeHeight/2;
cube = new THREE.Mesh(new THREE.CubeGeometry(cubeWidth, cubeWidth, cubeHeight), material);
cube.position.z = zPos;
cube.castShadow = true;
cube.recieveShadow = true;
parent.add(cube);
}
This runs terribly slow. What could the causes be?
(I assume I should be able to re-render 30 boxes continuously without performance issues?)
We need a few more details to completely answer your question:
What version of three.js are you using?
What else is going on in the scene?
What render timer method are you using? (setInterval, setTimeout, or requestAnimationFrame)
My guesses as to why it could be slow:
Some other section of code is actually using up more of the time before this code executes.
Your render isn't being called often enough and it looks choppy.
Your computer doesn't support some function of three.js and it is using a work around to make up for it.
Your computer javascript timer may be slow. (Depends on platform and browser.)
You are creating and destroying these blocks without caching techniques. (You should overwrite old values without using the new operator as much as possible. Requesting memory can be expensive in timing.)
new THREE.CubeGeometry(...); should be initalized once for all outside the for-loop, you need just 1 geometry for all cubes -> because they are all the same, you have to share the instace of this geometry. I hope it helps.
You could also check how many instances of three.js you have running on your computer. Maybe you run some demos from their website in the background (also in other browsers).
Close them will give you more performance.

Resources