54
56
invModelViewMatrix = new Matrix4 (),
55
matrix = new Matrix4 (),
56
57
billboardToScreen = new Vector3 (0, 0, 0),
57
58
viewerYAxis = new Vector3 (0, 0, 0),
58
59
normal = new Vector3 (0, 0, 0),
60
s1 = new Vector3 (0, 0, 0),
61
s2 = new Vector3 (0, 0, 0),
62
s3 = new Vector3 (0, 0, 0),
63
s4 = new Vector3 (0, 0, 0),
59
64
x = new Vector3 (0, 0, 0),
60
65
y = new Vector3 (0, 0, 0),
61
66
z = new Vector3 (0, 0, 0);
886
for (var i = 0; i < numParticles; ++ i)
914
if (this .geometryType === SPRITE)
889
position = particles [i] .position,
903
vertexArray [i24] = x - sx1_2;
904
vertexArray [i24 + 1] = y - sy1_2;
905
vertexArray [i24 + 2] = z;
908
vertexArray [i24 + 4] = x + sx1_2;
909
vertexArray [i24 + 5] = y - sy1_2;
910
vertexArray [i24 + 6] = z;
913
vertexArray [i24 + 8] = x + sx1_2;
914
vertexArray [i24 + 9] = y + sy1_2;
915
vertexArray [i24 + 10] = z;
918
vertexArray [i24 + 12] = x - sx1_2;
919
vertexArray [i24 + 13] = y - sy1_2;
920
vertexArray [i24 + 14] = z;
923
vertexArray [i24 + 16] = x + sx1_2;
924
vertexArray [i24 + 17] = y + sy1_2;
925
vertexArray [i24 + 18] = z;
928
vertexArray [i24 + 20] = x - sx1_2;
929
vertexArray [i24 + 21] = y + sy1_2;
930
vertexArray [i24 + 22] = z;
919
rotation = this .getScreenAlignedRotation (this .modelViewMatrix),
924
for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
926
normalArray [i] = nx;
927
normalArray [i + 1] = ny;
928
normalArray [i + 2] = nz;
931
gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
932
gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
936
s1 .set (-sx1_2, -sy1_2, 0);
937
s2 .set ( sx1_2, -sy1_2, 0);
938
s3 .set ( sx1_2, sy1_2, 0);
939
s4 .set (-sx1_2, sy1_2, 0);
941
rotation .multVecMatrix (s1);
942
rotation .multVecMatrix (s2);
943
rotation .multVecMatrix (s3);
944
rotation .multVecMatrix (s4);
946
for (var i = 0; i < numParticles; ++ i)
949
position = particles [i] .position,
964
vertexArray [i24] = vertexArray [i24 + 12] = x + s1 .x;
965
vertexArray [i24 + 1] = vertexArray [i24 + 13] = y + s1 .y;
966
vertexArray [i24 + 2] = vertexArray [i24 + 14] = z + s1 .z;
969
vertexArray [i24 + 4] = x + s2 .x;
970
vertexArray [i24 + 5] = y + s2 .y;
971
vertexArray [i24 + 6] = z + s2 .z;
974
vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + s3 .x;
975
vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + s3 .y;
976
vertexArray [i24 + 10] = vertexArray [i24 + 18] = z + s3 .z;
979
vertexArray [i24 + 20] = x + s4 .x;
980
vertexArray [i24 + 21] = y + s4 .y;
981
vertexArray [i24 + 22] = z + s4 .z;
986
for (var i = 0; i < numParticles; ++ i)
989
position = particles [i] .position,
1003
vertexArray [i24] = vertexArray [i24 + 12] = x - sx1_2;
1004
vertexArray [i24 + 1] = vertexArray [i24 + 13] = y - sy1_2;
1005
vertexArray [i24 + 2] = vertexArray [i24 + 14] = z;
1008
vertexArray [i24 + 4] = x + sx1_2;
1009
vertexArray [i24 + 5] = y - sy1_2;
1010
vertexArray [i24 + 6] = z;
1013
vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + sx1_2;
1014
vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + sy1_2;
1015
vertexArray [i24 + 10] = vertexArray [i24 + 18] = z;
1018
vertexArray [i24 + 20] = x - sx1_2;
1019
vertexArray [i24 + 21] = y + sy1_2;
1020
vertexArray [i24 + 22] = z;
933
1024
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
1042
1112
// Wireframes are always solid so only one drawing call is needed.
1115
positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0,
1116
frontFace = gl .CCW;
1118
gl .frontFace (positiveScale ? frontFace : (frontFace === gl .CCW ? gl .CW : gl .CCW));
1044
1119
gl .enable (gl .CULL_FACE);
1045
1120
gl .cullFace (gl .BACK);
1047
gl .drawArrays (this .primitiveType, 0, this .numParticles * this .vertexCount);
1122
gl .drawArrays (this .shader .primitiveMode, 0, this .numParticles * this .vertexCount);
1049
1124
if (shader .color >= 0) gl .disableVertexAttribArray (shader .color);
1050
1125
gl .disableVertexAttribArray (shader .vertex);