in seriously.js [2405:2503]
EffectNode.prototype.setInput = function (name, value) {
var input, uniform,
sourceKeys,
source,
me = this,
defaultValue;
function disconnectSource() {
var previousSource = me.sources[name],
key;
/*
remove this node from targets of previously connected source node,
but only if the source node is not being used as another input
*/
if (previousSource) {
for (key in me.sources) {
if (key !== name &&
me.sources.hasOwnProperty(key) &&
me.sources[key] === previousSource) {
return;
}
}
previousSource.removeTarget(me);
}
}
if (this.effect.inputs.hasOwnProperty(name)) {
input = this.effect.inputs[name];
if (input.type === 'image') {
//&& !(value instanceof Effect) && !(value instanceof Source)) {
if (value) {
value = findInputNode(value);
if (value !== this.sources[name]) {
disconnectSource();
if (traceSources(value, this)) {
throw new Error('Attempt to make cyclical connection.');
}
this.sources[name] = value;
value.addTarget(this);
}
} else {
delete this.sources[name];
value = false;
}
uniform = this.sources[name];
sourceKeys = Object.keys(this.sources);
if (this.inPlace === true && sourceKeys.length === 1) {
source = this.sources[sourceKeys[0]];
this.uniforms.transform = source && source.cumulativeMatrix || identity;
} else {
this.uniforms.transform = identity;
}
} else {
if (defaultInputs[this.hook] && defaultInputs[this.hook][name] !== undefined) {
defaultValue = defaultInputs[this.hook][name];
} else {
defaultValue = input.defaultValue;
}
value = input.validate.call(this, value, input, defaultValue, this.inputs[name]);
uniform = value;
}
if (this.inputs[name] === value && input.type !== 'color' && input.type !== 'vector') {
return value;
}
this.inputs[name] = value;
if (input.uniform) {
this.uniforms[input.uniform] = uniform;
}
if (input.type === 'image') {
this.resize();
this.updateReady();
} else if (input.updateSources) {
this.updateReady();
}
if (input.shaderDirty) {
this.shaderDirty = true;
}
this.setDirty();
if (input.update) {
input.update.call(this, value);
}
return value;
}
};