larry babby and threejs for glsl

This commit is contained in:
Sam
2024-06-24 21:24:00 +12:00
parent 87d5dc634d
commit 907ebae4c0
6474 changed files with 1279596 additions and 8 deletions

View File

@@ -0,0 +1,8 @@
node_modules
*.log
.DS_Store
bundle.js
test
test.js
demo
example

View 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.

View File

@@ -0,0 +1,60 @@
# glsl-token-scope
[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
Infer the scope of each token in an array of GLSL tokens.
## Usage
[![NPM](https://nodei.co/npm/glsl-token-scope.png)](https://nodei.co/npm/glsl-token-scope/)
### `scope(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 `scope` and `stack` properties.
`token.scope` is a unique number for the token's current scope.
`token.stack` is an array containing the scopes available to the current token.
Note that you must first determine the scope depth of each token using
[`glsl-token-depth`](http://github.com/stackgl/glsl-token-depth)
``` javascript
var tokenize = require('glsl-tokenizer/string')
var depth = require('glsl-token-depth')
var scope = require('glsl-token-scope')
var fs = require('fs')
var src = fs.readFileSync('shader.frag', 'utf8')
var tokens = tokenize(src)
depth(tokens)
scope(tokens)
tokens[0].scope // 0
tokens[1].scope // 0
tokens[2].scope // 1
tokens[3].scope // 1
tokens[4].scope // 0
tokens[5].scope // 2
// ...
tokens[0].stack // [0]
tokens[1].stack // [0]
tokens[2].stack // [0, 1]
tokens[3].stack // [0, 1]
tokens[4].stack // [0]
tokens[5].stack // [0, 2]
// ...
```
## See Also
* [stackgl/glsl-tokenizer](http://github.com/stackgl/glsl-tokenizer)
* [stackgl/glsl-token-depth](http://github.com/stackgl/glsl-token-depth)
## License
MIT. See [LICENSE.md](http://github.com/stackgl/glsl-token-scope/blob/master/LICENSE.md) for details.

View File

@@ -0,0 +1,30 @@
module.exports = tokenScope
function tokenScope(tokens) {
var stack = [0]
var inc = stack[0]
var ldepth = 0
if (!tokens || !tokens.length) return tokens
if (!('depth' in tokens[0])) {
throw new Error('glsl-token-scope: No scope depth defined on tokens! Use glsl-token-depth on these tokens first')
}
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i]
var depth = token.depth
if (depth > ldepth) {
stack.push(++inc)
} else
if (depth < ldepth) {
stack.splice(-1, 1)
}
token.scope = stack[stack.length - 1]
token.stack = stack.slice()
ldepth = token.depth
}
return tokens
}

View File

@@ -0,0 +1,38 @@
{
"name": "glsl-token-scope",
"version": "1.1.2",
"description": "Infer the scope of each token in an array of GLSL tokens",
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "node test | tap-spec",
"start": "node test/eyeball"
},
"author": {
"name": "Hugh Kennedy",
"email": "hughskennedy@gmail.com",
"url": "http://hughsk.io/"
},
"dependencies": {},
"devDependencies": {
"chalk": "^0.5.1",
"glsl-token-depth": "^1.1.0",
"glsl-tokenizer": "^2.0.0",
"tap-spec": "^2.1.1",
"tape": "^3.0.3"
},
"repository": {
"type": "git",
"url": "git://github.com/stackgl/glsl-token-scope.git"
},
"keywords": [
"ecosystem:stackgl",
"glsl",
"tokens",
"syntax"
],
"homepage": "https://github.com/stackgl/glsl-token-scope",
"bugs": {
"url": "https://github.com/stackgl/glsl-token-scope/issues"
}
}