Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions examples/webgl_buffergeometry_instancing_dynamic.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@

varying vec2 vUv;

// http://www.geeks3d.com/20141201/how-to-rotate-a-vertex-by-a-quaternion-in-glsl/

vec3 applyQuaternionToVector( vec4 q, vec3 v ){

return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );

}

void main() {

vec3 vPosition = position;
vec3 vcV = cross( orientation.xyz, vPosition );
vPosition = vcV * ( 2.0 * orientation.w ) + ( cross( orientation.xyz, vcV ) * 2.0 + vPosition );
vec3 vPosition = applyQuaternionToVector( orientation, position );

vUv = uv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@

varying vec2 vUv;

// http://www.geeks3d.com/20141201/how-to-rotate-a-vertex-by-a-quaternion-in-glsl/

vec3 applyQuaternionToVector( vec4 q, vec3 v ){

return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );

}

void main() {

vec3 vPosition = position;
vec3 vcV = cross(orientation.xyz, vPosition);
vPosition = vcV * (2.0 * orientation.w) + (cross(orientation.xyz, vcV) * 2.0 + vPosition);
vec3 vPosition = applyQuaternionToVector( orientation, position );

vUv = uv;

Expand Down