mirror of
https://github.com/SamEyeBam/animate.git
synced 2025-12-15 02:01:05 +00:00
larry babby and threejs for glsl
This commit is contained in:
21
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/LICENSE.md
generated
vendored
Normal file
21
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2015 Hugh Kennedy
|
||||
|
||||
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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
||||
OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
33
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/README.md
generated
vendored
Normal file
33
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/README.md
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# glsl-token-whitespace-trim
|
||||
|
||||
[](http://github.com/badges/stability-badges)
|
||||
|
||||
Trim the whitespace within an array of GLSL tokens provided by [glsl-tokenizer](https://github.com/stackgl/glsl-tokenizer). Useful for minimising shader source size, especially after heavy processing steps such as seen in [glslify](http://github.com/stackgl/glslify) or as part of a GLSL minifier.
|
||||
|
||||
## Usage
|
||||
|
||||
[](https://www.npmjs.com/package/glsl-token-whitespace-trim)
|
||||
|
||||
### `trim(tokens, [all])`
|
||||
|
||||
Trims the whitespace in an array of GLSL `tokens`. By default, this will trim repeated to newlines such that no more than two newlines will appear in a row.
|
||||
|
||||
If you're more concerned about size than aesthetics, you can pass `true` as the second argument to remove *all* extraneous whitespace (more or less).
|
||||
|
||||
``` javascript
|
||||
const tokenize = require('glsl-tokenizer')
|
||||
const string = require('glsl-token-string')
|
||||
const trim = require('glsl-token-whitespace-trim')
|
||||
const fs = require('fs')
|
||||
|
||||
const src = fs.readFileSync('shader.glsl', 'utf8')
|
||||
const tokens = tokenize(src)
|
||||
|
||||
trim(tokens, true)
|
||||
|
||||
const trimmed = string(tokens)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT, see [LICENSE.md](http://github.com/hughsk/glsl-token-whitespace-trim/blob/master/LICENSE.md) for details.
|
||||
3
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base-all.glsl
generated
vendored
Normal file
3
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base-all.glsl
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
precision mediump float;
|
||||
#define GLSLIFY 1
|
||||
struct Thing{float b;float c;};vec4 someFunction(vec2 b,vec2 c,vec3 d){return vec4(d,c.y);}void main(){gl_FragColor=someFunction(vec2(0),vec2(1),vec3(2));}
|
||||
27
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base-newlines.glsl
generated
vendored
Normal file
27
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base-newlines.glsl
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
precision mediump float;
|
||||
|
||||
#define GLSLIFY 1
|
||||
|
||||
struct Thing {
|
||||
|
||||
float b;
|
||||
|
||||
float c;
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
vec4 someFunction (
|
||||
|
||||
vec2 b,
|
||||
vec2 c, vec3 d
|
||||
) {
|
||||
return vec4( d , c.y );
|
||||
}
|
||||
|
||||
void main(
|
||||
|
||||
) {
|
||||
gl_FragColor = someFunction ( vec2(0), vec2(1), vec3(2) );
|
||||
}
|
||||
551
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base-padded.glsl
generated
vendored
Normal file
551
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base-padded.glsl
generated
vendored
Normal file
@@ -0,0 +1,551 @@
|
||||
precision
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mediump
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define GLSLIFY 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Thing
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
b;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
c;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
someFunction
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
b,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
c,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
d
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec4(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
d
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
c.y
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
main(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gl_FragColor
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
someFunction
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec2(0),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec2(1),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec3(2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
35
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base.glsl
generated
vendored
Normal file
35
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base.glsl
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
precision mediump float;
|
||||
|
||||
#define GLSLIFY 1
|
||||
|
||||
struct Thing {
|
||||
|
||||
float b;
|
||||
|
||||
|
||||
float c;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
vec4 someFunction (
|
||||
|
||||
vec2 b,
|
||||
vec2 c, vec3 d
|
||||
) {
|
||||
return vec4( d , c.y );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void main(
|
||||
|
||||
) {
|
||||
gl_FragColor = someFunction ( vec2(0), vec2(1), vec3(2) );
|
||||
}
|
||||
7
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base.vert
generated
vendored
Normal file
7
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/fixtures/base.vert
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
precision mediump float;
|
||||
|
||||
attribute vec2 position;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 1, 1);
|
||||
}
|
||||
63
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/index.js
generated
vendored
Normal file
63
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
module.exports = trim
|
||||
|
||||
function trim (tokens, everything) {
|
||||
return trim[everything ? 'all' : 'newlines'](collapse(tokens))
|
||||
}
|
||||
|
||||
function collapse (tokens) {
|
||||
for (var i = 1; i < tokens.length; i++) {
|
||||
var curr = tokens[i]
|
||||
if (curr.type !== 'whitespace') continue
|
||||
var prev = tokens[i - 1]
|
||||
if (prev.type !== 'whitespace') continue
|
||||
tokens.splice(--i, 1)
|
||||
curr.data = prev.data + curr.data
|
||||
}
|
||||
|
||||
return tokens
|
||||
}
|
||||
|
||||
var newlines = /(?:\n|\r\n|\r){2,}/g
|
||||
|
||||
trim.newlines = function (tokens) {
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var token = tokens[i]
|
||||
if (token.type !== 'whitespace') continue
|
||||
token.data = token.data.replace(newlines, '\n\n')
|
||||
}
|
||||
|
||||
return tokens
|
||||
}
|
||||
|
||||
var all = /\s+/g
|
||||
|
||||
trim.all = function (tokens) {
|
||||
var l = tokens.length
|
||||
|
||||
for (var i = 0; i < l; i++) {
|
||||
var token = tokens[i]
|
||||
if (token.type !== 'whitespace') continue
|
||||
var next = tokens[i + 1]
|
||||
var prev = tokens[i - 1]
|
||||
|
||||
if (next && next.type === 'preprocessor' || prev && prev.type === 'preprocessor') {
|
||||
token.data = token.data.replace(all, '\n')
|
||||
} else {
|
||||
token.data = token.data.replace(all, ' ')
|
||||
|
||||
switch (next && next.data) {
|
||||
case '(': case ';': case ')':
|
||||
case '{': case '=': case '}': case ',':
|
||||
token.data = token.data.replace(all, '')
|
||||
}
|
||||
|
||||
switch (prev && prev.data) {
|
||||
case '(': case ';': case ')':
|
||||
case '{': case '=': case '}': case ',':
|
||||
token.data = token.data.replace(all, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tokens
|
||||
}
|
||||
42
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/package.json
generated
vendored
Normal file
42
webGl/my-threejs-test/node_modules/glsl-token-whitespace-trim/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "glsl-token-whitespace-trim",
|
||||
"version": "1.0.0",
|
||||
"description": "Trim the whitespace within an array of GLSL tokens",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Hugh Kennedy",
|
||||
"email": "hughskennedy@gmail.com",
|
||||
"url": "https://github.com/hughsk"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"gl": "^2.1.5",
|
||||
"gl-shader": "^4.0.6",
|
||||
"glsl-token-string": "^1.0.1",
|
||||
"glsl-tokenizer": "^2.0.2",
|
||||
"standard": "^5.4.1",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && node test.js | tspec"
|
||||
},
|
||||
"keywords": [
|
||||
"glsl",
|
||||
"token",
|
||||
"tokenizer",
|
||||
"glslify",
|
||||
"ecosystem:stackgl",
|
||||
"whitespace",
|
||||
"trim"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hughsk/glsl-token-whitespace-trim.git"
|
||||
},
|
||||
"homepage": "https://github.com/hughsk/glsl-token-whitespace-trim",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hughsk/glsl-token-whitespace-trim/issues"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user