Class Index | File Index

Classes


Built-In Namespace _global_

Field Summary
Field Attributes Field Name and Description
 
In this file, maybe.
 
Phong model with one point light given in camera space.
 
GL constants with "gl_" prepended.
 
This is the event loop that happens on every frame.
 
A very basic vertex shader: Just interpolate color (g) and position (v) projected by perspective (p) and modelview (mv) transforms.
 
A vertex shader that uses normal matrix.
Method Summary
Method Attributes Method Name and Description
 
audioHandler(event)
The onaudioprocess handler.
 
Box(size)
Prepare a drawable WebGL buffer that represents a box.
 
c(gl)
 
Helper function.
 
cross(a, b)
Cross product for homogeneous directions.
 
findcam_wi(node, ms)
Dry traversal to find camera (TODO: lights?) This traverses the scene graph but doesn't draw anything.
 
Simple rational Bezier evaluator.
 
Simple uniform B-spline evaluator.
 
Simple uniform B-spline with transformed control points.
 
XY-plane curves with no inflection points (B==(0,0,1)).
 
funCircle(radius, swpfidel, arclen)
Create an evaluator that can return a local frame for a part or whole circle on the xy plane.
 
funCircleBasic(radius, n)
Create an evaluator that can return a local frame for circle in the xy plane.
 
GenCyl(prof, profilesz, swp)
Prepare a drawable WebGL buffer of a generalized cylinder (swept profile + caps)
 
Homogenize by x/w,y/w,z/w
 
matmul(a, b)
4x4 Matrix multiplication
 
matmul4(a, b)
4x4 matrix times 4xN matrix multiplication.
 
matmul_wi(a, b)
For 4x4 matrices, multiplies both a*b and b^{-1} * a^{-1}.
 
matvec(a, b)
4x4 Matrix times 4x1 vector multiplication
 
nmld(v)
Normalize x,y,z disregarding and untouching w
 
orthographic(top, ar, near, far)
Orthographic projection with fixed width
 
perspective(fov, ar, near, far)
Perspective projection, imitates gluPerspective()
 
perspectiveF(f, ar, near, far)
Perspective projection as in gluPerspective() but assumes a precomputed f==1/Math.tan(fov/2)
 
Perspective with hardcoded near plane "quite near".
 
pushCol4(array, mat, icol, mul)
Push values of the matrix column icol to array, optionally multiply by mul!=0
 
rotX(theta)
Counter-clockwise rotation around the X-axis
 
rotY(theta)
Counter-clockwise rotation around the Y-axis
 
rotZ(theta)
Counter-clockwise rotation around the Z-axis
 
scale(s)
Returns an isotropic scale matrix.
 
Returns an isotropic scale matrix.
 
scaleXYZ(sx, sy, sz)
Returns a scale matrix.
 
scaleXYZ_wi(sx, sy, sz)
Returns a scale matrix.
 
Square(size)
A square [-1,1]^2 on xy-plane, z==0.
 
translate(tx, ty, tz)
Returns a translation matrix of homogeneous coordinates.
 
Transpose the upper 3x3 part and zero the rest.
 
traverse_wi(node, ms)
Traverse a scene graph, and output to the WebGL pipeline.
 
xyToHomog(ptsxy)
Convert packed 2d-vectors to (x,y,0,1) homogenous 3d coordinates.
 
Returns a 4x4 matrix of zeros
Field Detail
cptsProfile
In this file, maybe... There could be like a "library of nice preset curves" Hmm.. why not also parametric shapes as functions?
Defined in: curve_presets.js.

fragment_shader_pointlight_cameraspace
Phong model with one point light given in camera space.
Defined in: shaders_simple.js.

gl_ACTIVE_ATTRIBUTES
GL constants with "gl_" prepended. The rumors say that these have not changed much between WebGL versions :). The rumors say that the following dirty trick is used often in demoscene intro minification. Me too, me too! Usage, by an example: transform "gl.ALPHA_BITS" to "gl_ALPHA_BITS" in the actual source (I have a sed script for that). Insert this file before the actual GL code before feeding the resulting bulk to the Closure compiler. Result: Closure automatically outputs "3413" instead of gl.ALPHA_BITS, which is 9 bytes shorter even before compression. Supposedly, and seemingly, the numeric constants work accross current WebGL implementations...
Defined in: glconstants.js.

startTimeInMillis
This is the event loop that happens on every frame. Assumes prior initialization of C (canvas), audio. Assumes prior initialization of gl and prg. Debug mode needs initialization of dbg_xxx
Defined in: main.js.

vertex_shader_basic
A very basic vertex shader: Just interpolate color (g) and position (v) projected by perspective (p) and modelview (mv) transforms. We transform normals by the modelview (not its inverse transpose) so free scale / skew cannot be done with correct normals. Orthonormal transformations should be OK.
Defined in: shaders_simple.js.

vertex_shader_minimal_with_normalmatrix
A vertex shader that uses normal matrix. It should be a 4x4 matrix whose upper left 3x3 part contains the inverse transpose of modelview. Otherwise as simple as the previous one. This allows free scale/skew of geometries with the expense of requiring you to compute and transfer the normal matrix. It is some heavy code, so you should really go and scale your sH* to make it look awesome, if you decide to compute inverses.
Defined in: shaders_simple.js.
Method Detail
audioHandler(event)
The onaudioprocess handler. This gets called, technically, for audio output.
Defined in: main.js.
Parameters:
event

Box(size)
Prepare a drawable WebGL buffer that represents a box. It's a bit funny that even though the box is a very simple shape, the data and code required for making one is actually quite bloaty when compared to generalized cylinders. Hmm, technically it could be possible to make a box with a 4-point circle, but then there should be some clever way to make non-smooth normals. Think about this..
Defined in: library.js.
Parameters:
size

c(gl)

Defined in: library.js.
Parameters:
gl

createAndFillArrayBuffer32(data)
Helper function. More bloaty than the few inlined calls:
Defined in: library.js.
Parameters:
data

cross(a, b)
Cross product for homogeneous directions. "[(axb)^t,0]^t"
Defined in: library.js.
Parameters:
a
b

findcam_wi(node, ms)
Dry traversal to find camera (TODO: lights?) This traverses the scene graph but doesn't draw anything. Look for property 'r' (for cameRa or dRy or Rehearsal or whatever mnemonic..) and apply the functions found in the property.
Defined in: library.js.
Parameters:
node
ms

funBezierCurve(pts)
Simple rational Bezier evaluator.
Defined in: library.js.
Parameters:
pts

funBSpline(pts)
Simple uniform B-spline evaluator. Hmm.. position and tangent could be evaluated for any t... But how to maintain correct normal and bi-normal for surface creation? Initial idea: pre-compute at some intervals using the cross product trick from our lecture notes, and then evaluate a normalized interpolant upon call to eval(). NOTE: Only need to store binormal (?), because normal can be computed via cross product. The binormal rotations could be corrected while precomputing. (not yet done). Note that analytic tangent doesn't exist for all possible inputs - we don't handle curves with vanishing derivatives, so keep this in mind when defining control points. TODO: Maybe could be sloppy and not even interpolate, if result is OK visually? Hmm... we do have storage, so why not just precompute like a *lot* of values when creating the spline object, and then return the closest one in compute(t)? Nasty, but without redundance... Back-of-the-envelope: 100 control pts * 100 intermediates * 16 * 8 byte float is 1280000 bytes... well.. that's a megabyte for one spline.. admittedly, it sounds like a lot.. TODO (cheating a bit, though): Use only xy-curves with no change of curvature, and delete all the code about flipping gradients. Would be so much smaller and leaner! Well.. if we don't cheat that much, then at least the production should USE the feature and have some twisty curve(s) to show it off.. Closure will omit unused functions, so we can have many versions here in the library. This is the bloaty, most general version. Depending on what you need, you can "cheat" more by using the restricted versions below.
Defined in: library.js.
Parameters:
pts

funBSplineTransformed(pts, tfm)
Simple uniform B-spline with transformed control points.. This was "new" in Instanssi 2018 - allows scaled and/or skewed geometries but needs to be done during instantiation.
Defined in: library.js.
Parameters:
pts
tfm

funBSplineXYnoInf(ipts)
XY-plane curves with no inflection points (B==(0,0,1)). Some 58 bytes smaller than the more general version.
Defined in: library.js.
Parameters:
ipts

funCircle(radius, swpfidel, arclen)
Create an evaluator that can return a local frame for a part or whole circle on the xy plane. The starting point of the arc is at the highest y point "top", and direction is counterclockwise in right-handed coordinates, z towards viewer. Assumes 0 Defined in: library.js.
Parameters:
radius
swpfidel
arclen

funCircleBasic(radius, n)
Create an evaluator that can return a local frame for circle in the xy plane. As in the MIT course assignment, but transposed.
Defined in: library.js.
Parameters:
radius
n

GenCyl(prof, profilesz, swp)
Prepare a drawable WebGL buffer of a generalized cylinder (swept profile + caps)
Defined in: library.js.
Parameters:
prof
profilesz
swp

homogenized(v)
Homogenize by x/w,y/w,z/w
Defined in: library.js.
Parameters:
v

matmul(a, b)
4x4 Matrix multiplication
Defined in: library.js.
Parameters:
a
b

matmul4(a, b)
4x4 matrix times 4xN matrix multiplication. Does a bit of extra work but allows the same routine to multiply both matrices and vectors. The end result seems to be 15 bytes shorter when using this instead of separate matmul and matvec routines.
Defined in: library.js.
Parameters:
a
b

matmul_wi(a, b)
For 4x4 matrices, multiplies both a*b and b^{-1} * a^{-1}.
Defined in: library.js.
Parameters:
a
b

matvec(a, b)
4x4 Matrix times 4x1 vector multiplication
Defined in: library.js.
Parameters:
a
b

nmld(v)
Normalize x,y,z disregarding and untouching w
Defined in: library.js.
Parameters:
v

orthographic(top, ar, near, far)
Orthographic projection with fixed width
Defined in: library.js.
Parameters:
top
ar
near
far

perspective(fov, ar, near, far)
Perspective projection, imitates gluPerspective()
Defined in: library.js.
Parameters:
fov
ar
near
far

perspectiveF(f, ar, near, far)
Perspective projection as in gluPerspective() but assumes a precomputed f==1/Math.tan(fov/2)
Defined in: library.js.
Parameters:
f
ar
near
far

perspectiveFhc(f, ar)
Perspective with hardcoded near plane "quite near". Far plane is "far away". Might have issues with Z stability. Assumes precomputed f==1/Math.tan(fov/2).
Defined in: library.js.
Parameters:
f
ar

pushCol4(array, mat, icol, mul)
Push values of the matrix column icol to array, optionally multiply by mul!=0
Defined in: library.js.
Parameters:
array
mat
icol
mul

rotX(theta)
Counter-clockwise rotation around the X-axis
Defined in: library.js.
Parameters:
theta

rotY(theta)
Counter-clockwise rotation around the Y-axis
Defined in: library.js.
Parameters:
theta

rotZ(theta)
Counter-clockwise rotation around the Z-axis
Defined in: library.js.
Parameters:
theta

scale(s)
Returns an isotropic scale matrix.
Defined in: library.js.
Parameters:
s

scale_wi(s)
Returns an isotropic scale matrix.
Defined in: library.js.
Parameters:
s

scaleXYZ(sx, sy, sz)
Returns a scale matrix.
Defined in: library.js.
Parameters:
sx
sy
sz

scaleXYZ_wi(sx, sy, sz)
Returns a scale matrix.
Defined in: library.js.
Parameters:
sx
sy
sz

Square(size)
A square [-1,1]^2 on xy-plane, z==0. This may not be very useful..
Defined in: library.js.
Parameters:
size

translate(tx, ty, tz)
Returns a translation matrix of homogeneous coordinates.
Defined in: library.js.
Parameters:
tx
ty
tz

transposed3x3(a)
Transpose the upper 3x3 part and zero the rest. For building the normal matrix from the inverse of model matrix.
Defined in: library.js.
Parameters:
a

traverse_wi(node, ms)
Traverse a scene graph, and output to the WebGL pipeline. Algorithm: This is a very basic recursive tree traversal. Size optimizations: - The 'functional' operations provided by Javascript allow a very compact way of writing this. - Call map() without using its output. It is wasteful, but it is 4 characters shorter to write than forEach(). - Always send two uniform matrices, regardless of whether anything is drawn using them. Wasted effort when not drawing.
Defined in: library.js.
Parameters:
node
ms

xyToHomog(ptsxy)
Convert packed 2d-vectors to (x,y,0,1) homogenous 3d coordinates. (Abandoned idea - didn't gain anything)
Defined in: library.js.
Parameters:
ptsxy

zeros()
Returns a 4x4 matrix of zeros
Defined in: library.js.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 02 2023 03:50:23 GMT+0200 (EET)