瀏覽代碼

webgl_materials_modified: replaced wave with twist

Mr.doob 8 年之前
父節點
當前提交
70780f3b94
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      examples/webgl_materials_modified.html

+ 8 - 1
examples/webgl_materials_modified.html

@@ -100,7 +100,14 @@
 					shader.vertexShader = 'uniform float time;\n' + shader.vertexShader;
 					shader.vertexShader = shader.vertexShader.replace(
 						'#include <begin_vertex>',
-						'vec3 transformed = vec3( position.x + sin( time + position.y ) / 2.0, position.y, position.z );'
+						[
+							'float theta = sin( time + position.y ) / 2.0;',
+							'float c = cos( theta );',
+							'float s = sin( theta );',
+							'mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );',
+							'vec3 transformed = vec3( position ) * m;',
+							'vNormal = vNormal * m;'
+						].join( '\n' )
 					);
 
 					materialShader = shader;