in seriously.js [2098:2191]
EffectNode = function (hook, options) {
var key, name, input,
defaultValue,
defaults,
defaultSources = {};
Node.call(this, options);
this.gl = gl;
this.effectRef = seriousEffects[hook];
this.sources = {};
this.targets = [];
this.inputElements = {};
this.dirty = true;
this.shaderDirty = true;
this.hook = hook;
this.options = options;
this.transform = null;
this.effect = extend({}, this.effectRef);
if (this.effectRef.definition) {
/*
todo: copy over inputs object separately in case some are specified
in advance and some are specified in definition function
*/
extend(this.effect, this.effectRef.definition.call(this, options));
}
validateInputSpecs(this.effect);
this.uniforms.transform = identity;
this.inputs = {};
defaults = defaultInputs[hook];
for (name in this.effect.inputs) {
if (this.effect.inputs.hasOwnProperty(name)) {
input = this.effect.inputs[name];
if (input.defaultValue === undefined || input.defaultValue === null) {
if (input.type === 'number') {
input.defaultValue = Math.min(Math.max(0, input.min), input.max);
} else if (input.type === 'color') {
input.defaultValue = [0, 0, 0, 0];
} else if (input.type === 'boolean') {
input.defaultValue = false;
} else if (input.type === 'string') {
input.defaultValue = '';
} else if (input.type === 'enum') {
input.defaultValue = input.firstValue;
}
}
defaultValue = input.validate.call(this, input.defaultValue, input);
if (defaults && defaults[name] !== undefined) {
defaultValue = input.validate.call(this, defaults[name], input, input.defaultValue, defaultValue);
defaults[name] = defaultValue;
if (input.type === 'image') {
defaultSources[name] = defaultValue;
}
}
this.inputs[name] = defaultValue;
if (input.uniform) {
this.uniforms[input.uniform] = input.defaultValue;
}
}
}
if (gl) {
this.initialize();
if (this.effect.commonShader) {
/*
this effect is unlikely to need to be modified again
by changing parameters, so build it now to avoid jank later
*/
this.buildShader();
}
}
this.updateReady();
this.inPlace = this.effect.inPlace;
this.pub = new Effect(this);
nodes.push(this);
nodesById[this.id] = this;
effects.push(this);
allEffectsByHook[hook].push(this);
for (name in defaultSources) {
if (defaultSources.hasOwnProperty(name)) {
this.setInput(name, defaultSources[name]);
}
}
};