simple formulas to ui · webvr api three.js unity unreal engine a‐frame. go play! references...

58
Algorithms for Animaon Simple formulas to UI acvate #QConNewYork Courtney Hemphill courtney @carbonfive.com @chemphill

Upload: others

Post on 17-Aug-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Algorithms for Anima�onSimple formulas to   UIac�vate

#QConNewYork

Courtney [email protected]

@chemphill

Page 2: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 3: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

"You can take a problem that can't be solveddirectly by anima�on and can't be solved bytechnology and work together to acheive a

much be�er resolu�on."

‐ Joe Longson, Senior So�ware Engineer ‐ Zootopia

Page 4: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

 CLI    GUI    NUI

Page 5: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Affordance & percievedaffordance

Page 6: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Animations are cognitiveaids

Page 7: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 8: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 9: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Subtle Cues

Page 10: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 11: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Progressive Disclosure

Page 12: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 13: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Colin Garven h�ps://dribbble.com/ColinGarven

Page 14: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

AutoLoading

Page 15: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Navigation

Page 16: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Adrian Zumbrunnen h�p://www.smashingmagazine.com/2013/10/23/smart‐transi�ons‐in‐user‐experience‐design/

Page 17: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Adrian Zumbrunnen h�p://www.smashingmagazine.com/2013/10/23/smart‐transi�ons‐in‐user‐experience‐design/

Page 18: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Context

Page 19: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Jason Zigrinoh�ps://dribbble.com/shots/2749851‐Gboard‐Dark‐Material‐Mo�on

Page 20: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Interactive

Page 21: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Sergey Valiukhh�ps://dribbble.com/SergeyValiukh

Page 22: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

How do you communicateanimation ideas?

Page 23: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Math

Page 24: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 25: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Motionvar ball = document.getElementById('ball'); var start = 0; var basicAnimation = function (e) { start += 12; basic.style.left = start + "px"; if (Math.abs(start) <= 800) { requestAnimationFrame(basicAnimation); } }

Page 26: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

The basics of animation:interpolation

valueAtTime = (end - start) * time / duration + start

Page 27: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

The basics of animation:interpolation

valueAtTime = (end - start) * time / duration + start

Page 28: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Timing (end - start) * time/duration + start div.style.left = 900-0 * time/1000 + 0+"px"

Page 29: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 30: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

‐ Stanislaw Ulam

"Using a term like nonlinear science is likereferring to the bulk of zoology as the study of

non‐elephant animals."

Page 31: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Natural movementVelocity, Accelera�on, Fric�on, Torque

Page 32: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Easing functions

Page 33: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Easing

Change in property �mes (some float) plus beginning value.

(end - start) * easingfunction([0-1]) + start

Page 34: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Power Functions - EaseIn

endX * Math.pow(percentChange, 3) + "px";

Page 35: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Power Functions - EaseOut

(endX - startX)*(1 - Math.pow(1 - (t / d), 3)) +startX+"px";

Page 36: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Trig! ... sine :)

(endX - startX)*Math.sin( t/d * Math.PI / 2 ) +startX+"px";

Page 37: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Follow Through> 1

Page 38: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Elasticity

(endX - startX)*k * k * ( ( s + 1 ) * k - s ) +startX+"px";

Page 39: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Bounce

if ( k < ( 1 / 2.75 ) ) { return 7.5625 * k * k;

} else if ( k < ( 2 / 2.75 ) ) { return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;

} else if ( k < ( 2.5 / 2.75 ) ) { return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;

} else { return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; } }

Page 40: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Physics Engines

Page 41: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 42: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Linear Interpolation Function(start, stop, amount)

function lerp(a,b,x) { return a+x*(b-a); }

Page 43: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Radial motionanim.theta += .02*Math.pow(1-anim.r/cw,8) * Math.PI;anim.p.x = anim.r * Math.cos(anim.theta); anim.p.y = anim.r * Math.sin(anim.theta);

Page 44: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Depth (varying velocity)// different shaped circles (depth)

function shape() { return randomCircle(.006, .09) }

// initializes each circle w/ random velocity (px/second) x:lerp(xmin,xmax,Math.random()), y:lerp(ymin,ymax,Math.random())}

// basic equation: incremental x and/or y by velocity to get acceleration

anim.p.x += anim.v.x anim.p.y += anim.v.y

// this just keeps everything w/in the bounds of the canvas

anim.p.x = (anim.p.x + cw/2) % cw - cw/2 anim.p.y = (anim.p.y + ch/2) % ch - ch/2

Page 45: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Constraints (gravity)// simple constraint of gradually increasing gravity

gravity = lerp(0,2,fraction);

// add an amount of gravity to the y velocity anim.v.y += gravity

// same as before, add the velocity to the position

anim.p.x += anim.v.x anim.p.y += anim.v.y

// flip velocity for bounce

anim.v.y = -.9*Math.abs(anim.v.y)

// adds a bit of drag to slow down horizonal movement anim.v.x *= .99;

Page 46: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Separation, Alignment, &Cohesion

// set boids direction towards center

var centroidDirection = vsub(anim1.p, centroid) var centroidDistance = vlength(centroidDirection)

// apply interaction force against boids

var centroidForce = -attraction / (centroidDistance || .001) anim1.force.x += centroidForce * centroidDirection.x anim2.force.x += centroidForce * centroidDirection.x

var rejectForce = rejection / (distance ? distance * distance : 0)

anim1.force.x += rejectForce * direction.x anim2.force.x += rejectForce * direction.y

// match velocity to nearby boids

anim1.force.x += velocitySync * anim2.v.x anim2.force.x += velocitySync * anim1.v.x

Page 47: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Collisions (engines!)

// create a world with a ground and some objects var bodyDef = new Box2D.Dynamics.b2BodyDef();

var fixtureDef = new Box2D.Dynamics.b2FixtureDef();

// set the details for our constraints fixtureDef.density = 1.0; fixtureDef.friction = 0.5;

// step through within constraints of our setup

world.Step( 1 / 60 /* frame-rate */, 10 /* velocity iterations*/, 1 /* position iterations */);

Page 48: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Static & Dynamic// set body parts oriented in the right direction

torso: partTransitions(0, -.04, .02, .04, -Math.PI/2), left_arm: partTransitions(-.018, -.03, .01, .03, -3*Math.PI/4),

// sets how parts are attached to each other

fixtureDef.filter.groupIndex = -1

// set up static & dynamic types addPhysics(anims.head[0], Box2D.Dynamics.b2Body.b2_staticBody, bodyDef, fixtureDef)

groups.slice(1).forEach(function(group) { addPhysics(anims[group][0], Box2D.Dynamics.b2Body.b2_dynamicBody, bodyDef, fixtureDef)

})

Page 49: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Performance

Page 50: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

HTML, CSS, & JS BasedUse Keyframes, Transi�ons & Transforms with CSS

Use requestAnima�onFrame with JS

Web Anima�on API (WAAPI)

Page 51: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

RAILResponse 100ms

Anima�on 6ms

Idle 50ms

Load 1000ms

credit Paul Irish & Paul Lewis and Blink Team ( )bit.ly/blink‐midnight‐train

Page 52: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

100 ms

Page 53: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

RenderingClear & Reuse

Procedural Sprites

Keep States

Composi�ng

Page 54: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday
Page 56: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

Go play!

Page 57: Simple formulas to UI · WebVR API Three.js Unity Unreal Engine A‐Frame. Go play! References & Credits Huge thanks to Alex Cruikshank (@sivoh) Don Norman ‐ The Design of Everyday

References & CreditsHuge thanks to   (@sivoh)Alex Cruikshank

Don Norman ‐ The Design of Everyday Things

Google Web Anima�on Docs

Box2dWeb