Expressions / store the variables & attributes in the context
This commit is contained in:
@@ -114,7 +114,10 @@ describe('ol.style.expressions', function() {
|
||||
let context;
|
||||
|
||||
beforeEach(function() {
|
||||
context = {};
|
||||
context = {
|
||||
variables: [],
|
||||
attributes: []
|
||||
};
|
||||
});
|
||||
|
||||
it('correctly converts expressions to GLSL', function() {
|
||||
@@ -137,6 +140,21 @@ describe('ol.style.expressions', function() {
|
||||
'mix(vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), a_attr4)');
|
||||
});
|
||||
|
||||
it('correctly adapts output for fragment shaders', function() {
|
||||
context.inFragmentShader = true;
|
||||
expect(expressionToGlsl(context, ['get', 'myAttr'])).to.eql('v_myAttr');
|
||||
});
|
||||
|
||||
it('correctly adapts output for fragment shaders', function() {
|
||||
expressionToGlsl(context, ['get', 'myAttr']);
|
||||
expressionToGlsl(context, ['var', 'myVar']);
|
||||
expressionToGlsl(context, ['clamp', ['get', 'attr2'], ['get', 'attr2'], ['get', 'myAttr']]);
|
||||
expressionToGlsl(context, ['*', ['get', 'attr2'], ['var', 'myVar']]);
|
||||
expressionToGlsl(context, ['*', ['get', 'attr3'], ['var', 'myVar2']]);
|
||||
expect(context.attributes).to.eql(['myAttr', 'attr2', 'attr3']);
|
||||
expect(context.variables).to.eql(['myVar', 'myVar2']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user