Skip to content

Commit 23754bb

Browse files
author
Carlos Scheidegger
committed
Shade.parameter supported by json() and Shade.Debug.from_json()
1 parent 8e72577 commit 23754bb

5 files changed

Lines changed: 29 additions & 9 deletions

File tree

lux.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5988,6 +5988,8 @@ Shade.Debug.from_json = function(json)
59885988
return Shade.constant.apply(undefined, json_node.values);
59895989
case "struct":
59905990
return Shade.struct(_.build(_.zip(json_node.fields, json_node.parents)));
5991+
case "parameter":
5992+
return Shade.parameter(json_node.parameter_type);
59915993
};
59925994

59935995
// swizzle
@@ -8621,7 +8623,15 @@ Shade.parameter = function(type, v)
86218623
this.watchers.splice(this.watchers.indexOf(callback), 1);
86228624
},
86238625
uniform_call: call,
8624-
uniform_name: uniform_name
8626+
uniform_name: uniform_name,
8627+
8628+
//////////////////////////////////////////////////////////////////////
8629+
// debugging
8630+
8631+
_json_helper: Shade.Debug._json_builder("parameter", function(obj) {
8632+
obj.parameter_type = type.repr();
8633+
return obj;
8634+
})
86258635
});
86268636
result._uniforms = [result];
86278637
result.set(v);

lux.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/shade/debug/from_json.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Shade.Debug.from_json = function(json)
1818
return Shade.constant.apply(undefined, json_node.values);
1919
case "struct":
2020
return Shade.struct(_.build(_.zip(json_node.fields, json_node.parents)));
21+
case "parameter":
22+
return Shade.parameter(json_node.parameter_type);
2123
};
2224

2325
// swizzle

src/shade/parameter.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,15 @@ Shade.parameter = function(type, v)
8484
this.watchers.splice(this.watchers.indexOf(callback), 1);
8585
},
8686
uniform_call: call,
87-
uniform_name: uniform_name
87+
uniform_name: uniform_name,
88+
89+
//////////////////////////////////////////////////////////////////////
90+
// debugging
91+
92+
_json_helper: Shade.Debug._json_builder("parameter", function(obj) {
93+
obj.parameter_type = type.repr();
94+
return obj;
95+
})
8896
});
8997
result._uniforms = [result];
9098
result.set(v);

tests/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ test("Shade expressions", function() {
122122
return e.message === "discard_if expects two parameters";
123123
}, "discard_if requires two parameters");
124124

125-
ok(Shade.Debug.from_json(Shade.vec(1,Shade.add(3, 4), Shade.ifelse(Shade.lt(3, 5), Shade.mul(3, 5), 3)).json()),
125+
ok(Shade.Debug.from_json(Shade.vec(Shade.parameter("float", 1),Shade.add(3, 4), Shade.ifelse(Shade.lt(3, 5), Shade.mul(3, 5), 3)).json()),
126126
"calling json() and from_json() on basic expressions");
127127
});
128128

0 commit comments

Comments
 (0)