* * @param {IDirectKernelSettings|IJSONSettings} settings
(settings)
| 229 | * @param {IDirectKernelSettings|IJSONSettings} settings |
| 230 | */ |
| 231 | mergeSettings(settings) { |
| 232 | for (let p in settings) { |
| 233 | if (!settings.hasOwnProperty(p) || !this.hasOwnProperty(p)) continue; |
| 234 | switch (p) { |
| 235 | case 'output': |
| 236 | if (!Array.isArray(settings.output)) { |
| 237 | this.setOutput(settings.output); // Flatten output object |
| 238 | continue; |
| 239 | } |
| 240 | break; |
| 241 | case 'functions': |
| 242 | this.functions = []; |
| 243 | for (let i = 0; i < settings.functions.length; i++) { |
| 244 | this.addFunction(settings.functions[i]); |
| 245 | } |
| 246 | continue; |
| 247 | case 'graphical': |
| 248 | if (settings[p] && !settings.hasOwnProperty('precision')) { |
| 249 | this.precision = 'unsigned'; |
| 250 | } |
| 251 | this[p] = settings[p]; |
| 252 | continue; |
| 253 | case 'nativeFunctions': |
| 254 | if (!settings.nativeFunctions) continue; |
| 255 | this.nativeFunctions = []; |
| 256 | for (let i = 0; i < settings.nativeFunctions.length; i++) { |
| 257 | const s = settings.nativeFunctions[i]; |
| 258 | const { name, source } = s; |
| 259 | this.addNativeFunction(name, source, s); |
| 260 | } |
| 261 | continue; |
| 262 | } |
| 263 | this[p] = settings[p]; |
| 264 | } |
| 265 | |
| 266 | if (!this.canvas) this.canvas = this.initCanvas(); |
| 267 | if (!this.context) this.context = this.initContext(); |
| 268 | if (!this.plugins) this.plugins = this.initPlugins(settings); |
| 269 | } |
| 270 | /** |
| 271 | * @desc Builds the Kernel, by compiling Fragment and Vertical Shaders, |
| 272 | * and instantiates the program. |
no test coverage detected