Comments (3)
This means support for branching (if/else) statements whose conditions depend on variables defined in terms of time/x/y/z/p
from shader-park-core.
Example code tree to study:
// Life, Universe, and Everything
var answer = 6 * 7;
let x = 0.4;
for (let i=0; i<7; i++) {
if (x-i<4){
x += 0.1;
} else if (3<5) {
x = 0.3;
} else {
x = 3;
}
}
produces:
{
"type": "Program",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "answer"
},
"init": {
"type": "BinaryExpression",
"operator": "*",
"left": {
"type": "Literal",
"value": 6,
"raw": "6"
},
"right": {
"type": "Literal",
"value": 7,
"raw": "7"
}
}
}
],
"kind": "var"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "x"
},
"init": {
"type": "Literal",
"value": 0.4,
"raw": "0.4"
}
}
],
"kind": "let"
},
{
"type": "ForStatement",
"init": {
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "i"
},
"init": {
"type": "Literal",
"value": 0,
"raw": "0"
}
}
],
"kind": "let"
},
"test": {
"type": "BinaryExpression",
"operator": "<",
"left": {
"type": "Identifier",
"name": "i"
},
"right": {
"type": "Literal",
"value": 7,
"raw": "7"
}
},
"update": {
"type": "UpdateExpression",
"operator": "++",
"argument": {
"type": "Identifier",
"name": "i"
},
"prefix": false
},
"body": {
"type": "BlockStatement",
"body": [
{
"type": "IfStatement",
"test": {
"type": "BinaryExpression",
"operator": "<",
"left": {
"type": "BinaryExpression",
"operator": "-",
"left": {
"type": "Identifier",
"name": "x"
},
"right": {
"type": "Identifier",
"name": "i"
}
},
"right": {
"type": "Literal",
"value": 4,
"raw": "4"
}
},
"consequent": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "+=",
"left": {
"type": "Identifier",
"name": "x"
},
"right": {
"type": "Literal",
"value": 0.1,
"raw": "0.1"
}
}
}
]
},
"alternate": {
"type": "IfStatement",
"test": {
"type": "BinaryExpression",
"operator": "<",
"left": {
"type": "Literal",
"value": 3,
"raw": "3"
},
"right": {
"type": "Literal",
"value": 5,
"raw": "5"
}
},
"consequent": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "Identifier",
"name": "x"
},
"right": {
"type": "Literal",
"value": 0.3,
"raw": "0.3"
}
}
}
]
},
"alternate": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "Identifier",
"name": "x"
},
"right": {
"type": "Literal",
"value": 3,
"raw": "3"
}
}
}
]
}
}
}
]
}
}
],
"sourceType": "script"
}
from shader-park-core.
first need to convert comparison ops to function calls (>, <, ==)
from shader-park-core.
Related Issues (20)
- initializing vec3 with vec3 as third components works with unexpected behavior, initializing vec3 with firs component as vec3 silently fails
- 1.0 feature wishlist
- Import doesn't work with the current version
- Allow users to build ultra lightweight shaders HOT 1
- Should enable2D return a vec3, or vec2?
- Proposed approach for handling GLSL Builtin Other
- Proposal to make SP work like a regular JS library HOT 1
- Error loading SP in Oculus browser HOT 2
- Error Loading in Fire Fox
- add function 'shapeFromGLSL' HOT 2
- Add WebGL1 support / backward compatibility
- input has argument of a shape HOT 1
- add hashT
- repeat with overlap HOT 1
- re-enable writing to frag depth so regular meshes are respected in clipping
- Integrate with threejs lighting model
- example using sp at build time HOT 2
- [Request] A demo Request HOT 2
- Make sculpt to GLSL functions only accept string instead of string or function
- Add input type validation for "hsv2rgb" and "sphericalDistribution"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shader-park-core.