Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't reproduce it with the data you've provided. But it seems you're tweening on startV3DV while using a currentV3D Vector, which is not mentioned in your example code. It could contain invalid data such as 0 axis or 0 scale.</p> <p>Furthermore, this is not how quaternions are supposed to be used for tweening. What you seem to be trying to do here is tween between two axis/angles representations and then generating a quaternion from that each time it's updated. You might as well reconstruct directly using the built-in "axisAngle" rotation mode. This probably won't do what you expect tho, because 1) it's not guaranteed to take the shortest angle, and 2) when the axis differs - all bets are off as to what the interpolation will look like ;)</p> <p>What you should do is convert the start and end rotations to quaternions in the same way you're currently doing inside quat(), and interpolate between those instead. You'll still need to correct for the shortest path: if the 4-component dot product between the two quaternions &lt; 0, you'll need to negate all components of one of them. Finally, you'll have to renormalize the quat (again 4-component-wise, rotation quaternions have to be unit-length).</p> <p>If you want to stick to TweenMax, you could still do something like this (might contain some careless errors, but you should get the gist):</p> <pre><code> t = 0; TweenMax.to(this, 2, {t:1, onUpdate:lerp}); function lerp() : void { var x:Number, y:Number, z:Number, w:Number; var w1:Number = start.w, x1:Number = start.x, y1:Number = start.y, z1:Number = start.z; var w2:Number = end.w, end:Number = end.x, y2:Number = end.y, z2:Number = end.z; var len:Number; // shortest direction if (x1*x2 + y1*y2 + z1*z2 + w1*w2 &lt; 0) { x2 = -x2; y2 = -y2; z2 = -z2; w2 = -w2; } x = x1 + t*(x2 - x1); y = y1 + t*(y2 - y1); z = z1 + t*(z2 - z1); w = w1 + t*(w2 - w1); len = 1.0/Math.sqrt(x*x + y*y + z*z + w*w); quatV3D.x = x*len; quatV3D.y = y*len; quatV3D.z = z*len; quatV3D.w = w*len; recomposeV3DV[1] = quatV3D; myMatrix3D.recompose(recomposeV3DV,"quaternion"); } </code></pre> <p>You might also want to look into spherical linear interpolations ("slerp"), they have a constant angular velocity unlike linear interpolations. I'll be lazy and just direct you to the Away3D Quaternion class I wrote a few years ago: <a href="https://github.com/away3d/away3d-core-fp11/blob/008b1d83d3330281034b90ca7072722a9f486958/src/away3d/core/math/Quaternion.as" rel="nofollow">https://github.com/away3d/away3d-core-fp11/blob/008b1d83d3330281034b90ca7072722a9f486958/src/away3d/core/math/Quaternion.as</a></p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload