Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript declarations #98

Closed
Closed
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
9 changes: 9 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ module.exports = function(grunt) {
outputSourceFiles: false,
},
},
ts: {
src: docsFiles,
options: {
destination: 'dist/4.x',
configure: 'build/jsdoc.conf.json',
template: './node_modules/tsd-jsdoc/dist',
outputSourceFiles: false,
},
}
},
webpack: {
full: {
Expand Down
4,201 changes: 4,201 additions & 0 deletions dist/4.x/types.d.ts

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "4.7.0",
"description": "A Tiny WebGL helper library",
"main": "dist/4.x/twgl-full.js",
"types" : "dist/4.x/types.d.ts",
"scripts": {
"test": "node node_modules/mocha/bin/mocha --recursive 'test/**/*-harness.js'",
"pre-push": "grunt eslint",
Expand Down Expand Up @@ -30,7 +31,8 @@
"homepage": "https://github.com/greggman/twgl.js",
"files": [
"dist/4.x/twgl-full.js",
"dist/4.x/twgl.js"
"dist/4.x/twgl.js",
"dist/4.x/types.d.ts"
],
"devDependencies": {
"@babel/core": "^7.1.2",
Expand Down Expand Up @@ -61,8 +63,9 @@
"requirejs": "^2.3.5",
"semver": "^5.4.1",
"should": "^13.2.0",
"tsd-jsdoc": "^2.1.2",
"webpack": "^3.10.0",
"webpack-load-plugins": "^0.1.2"
},
"dependencies": {}
}
}
4 changes: 1 addition & 3 deletions src/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,7 @@ function getBytesPerValueForGLType(gl, type) {
return 0;
}

/**
* tries to get the number of elements from a set of arrays.
*/
// Tries to get the number of elements from a set of arrays.
const positionKeys = ['position', 'positions', 'a_position'];
function getNumElementsFromNonIndexedArrays(arrays) {
let key;
Expand Down
14 changes: 7 additions & 7 deletions src/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function transformNormal(mi, v, dst) {
/**
* Reorients directions by the given matrix..
* @param {number[]|TypedArray} array The array. Assumes value floats per element.
* @param {Matrix} matrix A matrix to multiply by.
* @param {module:twgl/m4.Mat4} matrix A matrix to multiply by.
* @return {number[]|TypedArray} the same array that was passed in
* @memberOf module:twgl/primitives
*/
Expand All @@ -261,7 +261,7 @@ function reorientDirections(array, matrix) {
* Reorients normals by the inverse-transpose of the given
* matrix..
* @param {number[]|TypedArray} array The array. Assumes value floats per element.
* @param {Matrix} matrix A matrix to multiply by.
* @param {module:twgl/m4.Mat4} matrix A matrix to multiply by.
* @return {number[]|TypedArray} the same array that was passed in
* @memberOf module:twgl/primitives
*/
Expand All @@ -274,7 +274,7 @@ function reorientNormals(array, matrix) {
* Reorients positions by the given matrix. In other words, it
* multiplies each vertex by the given matrix.
* @param {number[]|TypedArray} array The array. Assumes value floats per element.
* @param {Matrix} matrix A matrix to multiply by.
* @param {module:twgl/m4.Mat4} matrix A matrix to multiply by.
* @return {number[]|TypedArray} the same array that was passed in
* @memberOf module:twgl/primitives
*/
Expand All @@ -289,7 +289,7 @@ function reorientPositions(array, matrix) {
* 'binorm' or 'tan' as directions, and 'norm' as normals.
*
* @param {Object.<string, (number[]|TypedArray)>} arrays The vertices to reorient
* @param {Matrix} matrix matrix to reorient by.
* @param {module:twgl/m4.Mat4} matrix matrix to reorient by.
* @return {Object.<string, (number[]|TypedArray)>} same arrays that were passed in.
* @memberOf module:twgl/primitives
*/
Expand Down Expand Up @@ -408,7 +408,7 @@ function createXYQuadVertices(size, xOffset, yOffset) {
* @param {number} [depth] Depth of the plane. Default = 1
* @param {number} [subdivisionsWidth] Number of steps across the plane. Default = 1
* @param {number} [subdivisionsDepth] Number of steps down the plane. Default = 1
* @param {Matrix4} [matrix] A matrix by which to multiply all the vertices.
* @param {module:twgl/m4.Mat4} [matrix] A matrix by which to multiply all the vertices.
* @return {@module:twgl.BufferInfo} The created plane BufferInfo.
* @memberOf module:twgl/primitives
* @function createPlaneBufferInfo
Expand All @@ -424,7 +424,7 @@ function createXYQuadVertices(size, xOffset, yOffset) {
* @param {number} [depth] Depth of the plane. Default = 1
* @param {number} [subdivisionsWidth] Number of steps across the plane. Default = 1
* @param {number} [subdivisionsDepth] Number of steps down the plane. Default = 1
* @param {Matrix4} [matrix] A matrix by which to multiply all the vertices.
* @param {module:twgl/m4.Mat4} [matrix] A matrix by which to multiply all the vertices.
* @return {Object.<string, WebGLBuffer>} The created plane buffers.
* @memberOf module:twgl/primitives
* @function createPlaneBuffers
Expand All @@ -439,7 +439,7 @@ function createXYQuadVertices(size, xOffset, yOffset) {
* @param {number} [depth] Depth of the plane. Default = 1
* @param {number} [subdivisionsWidth] Number of steps across the plane. Default = 1
* @param {number} [subdivisionsDepth] Number of steps down the plane. Default = 1
* @param {Matrix4} [matrix] A matrix by which to multiply all the vertices.
* @param {module:twgl/m4.Mat4} [matrix] A matrix by which to multiply all the vertices.
* @return {Object.<string, TypedArray>} The created plane vertices.
* @memberOf module:twgl/primitives
*/
Expand Down
2 changes: 1 addition & 1 deletion src/programs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ function setAttributes(setters, buffers) {
*
* @param {WebGLRenderingContext} gl A WebGLRenderingContext.
* @param {(module:twgl.ProgramInfo|Object.<string, function>)} setters A `ProgramInfo` as returned from {@link module:twgl.createProgrmaInfo} or Attribute setters as returned from {@link module:twgl.createAttributeSetters}
* @param {(module:twgl.BufferInfo|module:twgl.vertexArrayInfo)} buffers a `BufferInfo` as returned from {@link module:twgl.createBufferInfoFromArrays}.
* @param {(module:twgl.BufferInfo|module:twgl.VertexArrayInfo)} buffers a `BufferInfo` as returned from {@link module:twgl.createBufferInfoFromArrays}.
* or a `VertexArrayInfo` as returned from {@link module:twgl.createVertexArrayInfo}
* @memberOf module:twgl/programs
*/
Expand Down
2 changes: 1 addition & 1 deletion src/textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ function setDefaults(newDefaults) {
* @property {number} [colorspaceConversion] Whether or not to let the browser do colorspace conversion of the texture on upload. Defaults to whatever the current setting is.
* This lets you set it once before calling `twgl.createTexture` or `twgl.createTextures` and only override
* the current setting for specific textures.
* @property {(number[]|ArrayBufferView)} color color used as temporary 1x1 pixel color for textures loaded async when src is a string.
* @property {(number[]|ArrayBufferView)} [color] color used as temporary 1x1 pixel color for textures loaded async when src is a string.
* If it's a JavaScript array assumes color is 0 to 1 like most GL colors as in `[1, 0, 0, 1] = red=1, green=0, blue=0, alpha=0`.
* Defaults to `[0.5, 0.75, 1, 1]`. See {@link module:twgl.setDefaultTextureColor}. If `false` texture is set. Can be used to re-load a texture
* @property {boolean} [auto] If `undefined` or `true`, in WebGL1, texture filtering is set automatically for non-power of 2 images and
Expand Down