Skip to content

Commit

Permalink
Clean: Update a_normals to a_normal for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad Ghayour committed Jul 8, 2015
1 parent 7f62062 commit 20e71e4
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions webgl-geometries/DynamicGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ DynamicGeometry.prototype.setVertexPositions = function (value) {
* @return {Object} current geometry.
*/
DynamicGeometry.prototype.setNormals = function (value) {
return this.setVertexBuffer('a_normals', value, 3);
return this.setVertexBuffer('a_normal', value, 3);
};

/**
Expand Down Expand Up @@ -190,7 +190,7 @@ DynamicGeometry.prototype.getVertexPositions = function () {
* @return {Array} Vertex Buffer.
*/
DynamicGeometry.prototype.getNormals = function () {
return this.getVertexBuffer('a_normals');
return this.getVertexBuffer('a_normal');
};

/**
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function BoxGeometry(options) {
buffers: [
{ name: 'a_pos', data: vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Circle (options) {
buffers: [
{ name: 'a_pos', data: buffers.vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: buffers.indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Cylinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function Cylinder (options) {
buffers: [
{ name: 'a_pos', data: buffers.vertices },
{ name: 'a_texCoord', data: GeometryHelper.getSpheroidUV(buffers.vertices), size: 2 },
{ name: 'a_normals', data: GeometryHelper.computeNormals(buffers.vertices, buffers.indices) },
{ name: 'a_normal', data: GeometryHelper.computeNormals(buffers.vertices, buffers.indices) },
{ name: 'indices', data: buffers.indices, size: 1 }
]
});
Expand Down
12 changes: 6 additions & 6 deletions webgl-geometries/primitives/GeodesicSphere.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* The MIT License (MIT)
*
*
* Copyright (c) 2015 Famous Industries Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -36,7 +36,7 @@ var GeometryHelper = require('../GeometryHelper');
*
* @param {Object} options Parameters that alter the
* vertex buffers of the generated geometry.
*
*
* @return {Object} constructed geometry
*/
function GeodesicSphere (options) {
Expand Down Expand Up @@ -69,7 +69,7 @@ function GeodesicSphere (options) {
buffers: [
{ name: 'a_pos', data: vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: indices, size: 1 }
]
});
Expand Down
12 changes: 6 additions & 6 deletions webgl-geometries/primitives/Icosahedron.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* The MIT License (MIT)
*
*
* Copyright (c) 2015 Famous Industries Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -36,7 +36,7 @@ var GeometryHelper = require('../GeometryHelper');
*
* @param {Object} options Parameters that alter the
* vertex buffers of the generated geometry.
*
*
* @return {Object} constructed geometry
*/
function Icosahedron() {
Expand Down Expand Up @@ -65,7 +65,7 @@ function Icosahedron() {
buffers: [
{ name: 'a_pos', data: vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/ParametricCone.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function ParametricCone (options) {
buffers: [
{ name: 'a_pos', data: buffers.vertices },
{ name: 'a_texCoord', data: GeometryHelper.getSpheroidUV(buffers.vertices), size: 2 },
{ name: 'a_normals', data: GeometryHelper.computeNormals(buffers.vertices, buffers.indices) },
{ name: 'a_normal', data: GeometryHelper.computeNormals(buffers.vertices, buffers.indices) },
{ name: 'indices', data: buffers.indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Plane.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function Plane(options) {
buffers: [
{ name: 'a_pos', data: vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Sphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function ParametricSphere (options) {
buffers: [
{ name: 'a_pos', data: buffers.vertices },
{ name: 'a_texCoord', data: GeometryHelper.getSpheroidUV(buffers.vertices), size: 2 },
{ name: 'a_normals', data: GeometryHelper.getSpheroidNormals(buffers.vertices) },
{ name: 'a_normal', data: GeometryHelper.getSpheroidNormals(buffers.vertices) },
{ name: 'indices', data: buffers.indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Tetrahedron.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function Tetrahedron(options) {
buffers: [
{ name: 'a_pos', data: vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Torus.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function Torus(options) {
buffers: [
{ name: 'a_pos', data: buffers.vertices },
{ name: 'a_texCoord', data: GeometryHelper.getSpheroidUV(buffers.vertices), size: 2 },
{ name: 'a_normals', data: GeometryHelper.computeNormals(buffers.vertices, buffers.indices) },
{ name: 'a_normal', data: GeometryHelper.computeNormals(buffers.vertices, buffers.indices) },
{ name: 'indices', data: buffers.indices, size: 1 }
]
});
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/primitives/Triangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Triangle (options) {
buffers: [
{ name: 'a_pos', data: vertices },
{ name: 'a_texCoord', data: textureCoords, size: 2 },
{ name: 'a_normals', data: normals },
{ name: 'a_normal', data: normals },
{ name: 'indices', data: indices, size: 1 }
]
});
Expand Down
4 changes: 2 additions & 2 deletions webgl-geometries/test/DynamicGeometry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ test('DynamicGeometry', function(t) {
geometry.setNormals(vertexNormals);

t.deepEquals(
geometry.spec.bufferValues[geometry.spec.bufferNames.indexOf('a_normals')],
geometry.spec.bufferValues[geometry.spec.bufferNames.indexOf('a_normal')],
vertexNormals,
'Should set vertex data to the "normal" attribute of the geometry'
);

t.equals(
geometry.spec.bufferSpacings[geometry.spec.bufferNames.indexOf('a_normals')],
geometry.spec.bufferSpacings[geometry.spec.bufferNames.indexOf('a_normal')],
3,
'Should set buffer spacing to 3 for normal attribute'
);
Expand Down
2 changes: 1 addition & 1 deletion webgl-geometries/test/Primitives.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test('Primitives', function(t) {
t.ok(primitive instanceof Geometry, 'should be an instance of a static geometry');

t.notEquals(primitive.spec.bufferNames.indexOf('a_texCoord'), -1, 'should contain a texCoord buffer');
t.notEquals(primitive.spec.bufferNames.indexOf('a_normals'), -1, 'should contain a normal buffer');
t.notEquals(primitive.spec.bufferNames.indexOf('a_normal'), -1, 'should contain a normal buffer');
t.notEquals(primitive.spec.bufferNames.indexOf('a_pos'), -1, 'should contain a pos buffer');

if (name !== 'Circle') {
Expand Down
2 changes: 1 addition & 1 deletion webgl-renderers/Program.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var uniforms = keyValueToArrays({
var attributes = keyValueToArrays({
a_pos: [0, 0, 0],
a_texCoord: [0, 0],
a_normals: [0, 0, 0]
a_normal: [0, 0, 0]
});

/**
Expand Down
22 changes: 11 additions & 11 deletions webgl-shaders/VertexShader.glsl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* The MIT License (MIT)
*
*
* Copyright (c) 2015 Famous Industries Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -37,7 +37,7 @@
*/

vec4 applyTransform(vec4 pos) {
//TODO: move this multiplication to application code.
//TODO: move this multiplication to application code.

/**
* Currently multiplied in the vertex shader to avoid consuming the complexity of holding an additional
Expand All @@ -59,7 +59,7 @@ vec4 applyTransform(vec4 pos) {
*
* where convertToDOMSpace represents the transform matrix:
*
* size.x 0 0 size.x
* size.x 0 0 size.x
* 0 -size.y 0 size.y
* 0 0 1 0
* 0 0 0 1
Expand All @@ -71,7 +71,7 @@ vec4 applyTransform(vec4 pos) {
* Later in the transformation chain, the projection transform negates the rigidbody translation.
* Equivalent to (but much faster than) multiplying a translation matrix "origin"
*
* 1 0 0 1
* 1 0 0 1
* 0 1 0 -1
* 0 0 1 0
* 0 0 0 1
Expand All @@ -87,7 +87,7 @@ vec4 applyTransform(vec4 pos) {
* by the inverse of the canvas' resolution.
* Equivalent to (but much faster than) multiplying a scale matrix "sizeScale"
*
* size.x 0 0 0
* size.x 0 0 0
* 0 size.y 0 0
* 0 0 size.z 0
* 0 0 0 1
Expand All @@ -97,11 +97,11 @@ vec4 applyTransform(vec4 pos) {
pos.xyz *= u_size * 0.5;

/**
* Inverts the object space's y axis in order to match DOM space conventions.
* Inverts the object space's y axis in order to match DOM space conventions.
* Later in the transformation chain, the projection transform reinverts the y axis to convert to clip space.
* Equivalent to (but much faster than) multiplying a scale matrix "invertYAxis"
*
* 1 0 0 0
* 1 0 0 0
* 0 -1 0 0
* 0 0 1 0
* 0 0 0 1
Expand Down Expand Up @@ -166,7 +166,7 @@ vec3 calculateOffset(vec3 ID) {
*/
void main() {
v_textureCoordinate = a_texCoord;
vec3 invertedNormals = a_normals + (u_normals.x < 0.0 ? calculateOffset(u_normals) * 2.0 - 1.0 : vec3(0.0));
vec3 invertedNormals = a_normal + (u_normals.x < 0.0 ? calculateOffset(u_normals) * 2.0 - 1.0 : vec3(0.0));
invertedNormals.y *= -1.0;
v_normal = transpose(mat3(inverse(u_transform))) * invertedNormals;
vec3 offsetPos = a_pos + calculateOffset(u_positionOffset);
Expand Down

0 comments on commit 20e71e4

Please sign in to comment.