pex-gl / pex-renderer

Physically based renderer (PBR) and scene graph for PEX.
https://pex-gl.github.io/pex-renderer/examples/index.html
MIT License
237 stars 16 forks source link

Update animation.js to add interpolation types #181

Closed simonharrisco closed 5 years ago

simonharrisco commented 5 years ago

I should also note that i know it shouldnt be merged in this starting form up its more a proposed structure (that needs work) and some functioning maths as a foundation

Fix #168

dmnsgn commented 5 years ago

We haven't merged prettier in pex-renderer yet so you can revert your latest commit.

vorg commented 5 years ago

Are those actually Vec4 or Quaternions?

if (path === 'rotation') {
  prevInTangent = vec4.create(); 
  prevOutTangent = vec4.create(); 
  prevPosition = vec4.create(); 
  nextInTangent = vec4.create();
  nextOutTangent = vec4.create(); 
  nextPos = vec4.create();        
simonharrisco commented 5 years ago

Thats the thing right, I thought they would be quaternions but the equation has you scale them, which doesn't make sense for a quaternion (right?!)

So I just used vec4 thinking I could use vec4.scale (I mean I now realise I cant, but as I wrote it that was the logic)

vorg commented 5 years ago

It would be also good to have a look at garbage collection if target.transform.set({ position: currentOutput }) doesn't retain the vec3 then we could have preallocated temp array instead of new one every frame.

Stuff like

currentOutput = [1,1,1,1]
currentOutput = quat.copy(prevOutput)
vorg commented 5 years ago

@simonharrisco can link the interpolation docs?

simonharrisco commented 5 years ago

https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation

simonharrisco commented 5 years ago

the resulting p(t) quaternion So it should be quat

simonharrisco commented 5 years ago

There is a mistake slomo shouldnt move backwards.

dmnsgn commented 5 years ago

Pending pex-math vec4.scale to be released.