mirror of
https://github.com/SamEyeBam/animate.git
synced 2026-03-23 06:52:05 +00:00
larry babby and threejs for glsl
This commit is contained in:
8
webGl/my-threejs-test/node_modules/glsl-token-depth/.npmignore
generated
vendored
Normal file
8
webGl/my-threejs-test/node_modules/glsl-token-depth/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
node_modules
|
||||
*.log
|
||||
.DS_Store
|
||||
bundle.js
|
||||
test
|
||||
test.js
|
||||
demo
|
||||
example
|
||||
12
webGl/my-threejs-test/node_modules/glsl-token-depth/LICENSE.md
generated
vendored
Normal file
12
webGl/my-threejs-test/node_modules/glsl-token-depth/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright (c) 2014 [stackgl](http://github.com/stackgl/) contributors
|
||||
|
||||
*stackgl contributors listed at <https://github.com/stackgl/contributing/blob/master/CONTRIBUTING.md#contributors>*
|
||||
|
||||
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.
|
||||
44
webGl/my-threejs-test/node_modules/glsl-token-depth/README.md
generated
vendored
Normal file
44
webGl/my-threejs-test/node_modules/glsl-token-depth/README.md
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# glsl-token-depth
|
||||
|
||||
[](http://github.com/badges/stability-badges)
|
||||
|
||||
Determine the scope depth of an array of GLSL tokens.
|
||||
|
||||
Useful for inferring the scope of variables in a GLSL shader without having
|
||||
to fully parse the source.
|
||||
|
||||
## Usage
|
||||
|
||||
[](https://nodei.co/npm/glsl-token-depth/)
|
||||
|
||||
### `depth(tokens)`
|
||||
|
||||
Where `tokens` is an array of tokens returned from
|
||||
[`glsl-tokenizer`](http://github.com/stackgl/glsl-tokenizer). Each token will
|
||||
be modified in-place, and given a `depth` property.
|
||||
|
||||
``` javascript
|
||||
var tokenize = require('glsl-tokenizer/string')
|
||||
var depth = require('glsl-token-depth')
|
||||
var fs = require('fs')
|
||||
|
||||
var src = fs.readFileSync('shader.frag', 'utf8')
|
||||
var tokens = tokenize(src)
|
||||
|
||||
depth(tokens)
|
||||
|
||||
tokens[0].depth // 0
|
||||
tokens[1].depth // 0
|
||||
tokens[2].depth // 0
|
||||
tokens[3].depth // 0
|
||||
tokens[4].depth // 1
|
||||
// ...
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [stackgl/glsl-tokenizer](http://github.com/stackgl/glsl-tokenizer)
|
||||
|
||||
## License
|
||||
|
||||
MIT. See [LICENSE.md](http://github.com/stackgl/glsl-token-depth/blob/master/LICENSE.md) for details.
|
||||
46
webGl/my-threejs-test/node_modules/glsl-token-depth/index.js
generated
vendored
Normal file
46
webGl/my-threejs-test/node_modules/glsl-token-depth/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
module.exports = getTokenDepth
|
||||
|
||||
function getTokenDepth(tokens) {
|
||||
var loop = false
|
||||
var depth = 0
|
||||
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
loop = loop || (tokens[i].type === 'keyword' && (
|
||||
tokens[i].data === 'for'
|
||||
))
|
||||
|
||||
switch (tokens[i].data) {
|
||||
case '(': tokens[i].depth = loop ? depth++ : depth; break
|
||||
case '{': tokens[i].depth = loop ? depth : depth++; loop = false; break
|
||||
case '}': tokens[i].depth = --depth; break
|
||||
default: tokens[i].depth = depth
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var token = tokens[i]
|
||||
var index = i + 1
|
||||
if (token.type !== 'ident' && token.type !== 'keyword') continue
|
||||
skipArrayArguments()
|
||||
if (tokens[index].type !== 'ident') continue
|
||||
skipArrayArguments()
|
||||
index++
|
||||
if (tokens[index].data !== '(') continue
|
||||
|
||||
while (tokens[index] && tokens[index].data !== ';' && tokens[index].data !== '{') {
|
||||
tokens[index++].depth++
|
||||
}
|
||||
if (tokens[index] && tokens[index].data === '{') tokens[index].depth++
|
||||
}
|
||||
|
||||
return tokens
|
||||
|
||||
function skipArrayArguments() {
|
||||
while (tokens[index] && (
|
||||
tokens[index].type === 'whitespace' ||
|
||||
tokens[index].data === '[' ||
|
||||
tokens[index].data === ']' ||
|
||||
tokens[index].data === 'integer'
|
||||
)) index++
|
||||
}
|
||||
}
|
||||
36
webGl/my-threejs-test/node_modules/glsl-token-depth/package.json
generated
vendored
Normal file
36
webGl/my-threejs-test/node_modules/glsl-token-depth/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "glsl-token-depth",
|
||||
"version": "1.1.2",
|
||||
"description": "Determine the scope depth of an array of GLSL tokens",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "node test | tap-spec"
|
||||
},
|
||||
"author": {
|
||||
"name": "Hugh Kennedy",
|
||||
"email": "hughskennedy@gmail.com",
|
||||
"url": "http://hughsk.io/"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chalk": "^0.5.1",
|
||||
"glsl-tokenizer": "^2.0.0",
|
||||
"tap-spec": "^2.1.1",
|
||||
"tape": "^3.0.3"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stackgl/glsl-token-depth.git"
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:stackgl",
|
||||
"tokens",
|
||||
"glsl",
|
||||
"syntax"
|
||||
],
|
||||
"homepage": "https://github.com/stackgl/glsl-token-depth",
|
||||
"bugs": {
|
||||
"url": "https://github.com/stackgl/glsl-token-depth/issues"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user