(sketch, node)
| 48 | static _friendlyFileLoadError = () => {}; |
| 49 | |
| 50 | constructor(sketch, node) { |
| 51 | // Apply addon defined decorations |
| 52 | if(p5.decorations.size > 0){ |
| 53 | decorateClass(p5, p5.decorations, 'p5'); |
| 54 | p5.decorations.clear(); |
| 55 | } |
| 56 | |
| 57 | ////////////////////////////////////////////// |
| 58 | // PRIVATE p5 PROPERTIES AND METHODS |
| 59 | ////////////////////////////////////////////// |
| 60 | |
| 61 | this.hitCriticalError = false; |
| 62 | this._setupDone = false; |
| 63 | this._userNode = node; |
| 64 | this._curElement = null; |
| 65 | this._elements = []; |
| 66 | this._glAttributes = null; |
| 67 | this._webgpuAttributes = null; |
| 68 | this._requestAnimId = 0; |
| 69 | this._isGlobal = false; |
| 70 | this._loop = true; |
| 71 | this._startListener = null; |
| 72 | this._initializeInstanceVariables(); |
| 73 | this._events = { |
| 74 | }; |
| 75 | this._removeAbortController = new AbortController(); |
| 76 | this._removeSignal = this._removeAbortController.signal; |
| 77 | this._millisStart = -1; |
| 78 | this._recording = false; |
| 79 | |
| 80 | // States used in the custom random generators |
| 81 | this._lcg_random_state = null; // NOTE: move to random.js |
| 82 | this._gaussian_previous = false; // NOTE: move to random.js |
| 83 | |
| 84 | // ensure correct reporting of window dimensions |
| 85 | this._updateWindowSize(); |
| 86 | |
| 87 | const bindGlobal = createBindGlobal(this); |
| 88 | // If the user has created a global setup or draw function, |
| 89 | // assume "global" mode and make everything global (i.e. on the window) |
| 90 | if (!sketch) { |
| 91 | this._isGlobal = true; |
| 92 | if (window.hitCriticalError) { |
| 93 | return; |
| 94 | } |
| 95 | p5.instance = this; |
| 96 | |
| 97 | // Loop through methods on the prototype and attach them to the window |
| 98 | // All methods and properties with name starting with '_' will be skipped |
| 99 | for (const p of Object.getOwnPropertyNames(p5.prototype)) { |
| 100 | if(p[0] === '_') continue; |
| 101 | bindGlobal(p); |
| 102 | } |
| 103 | |
| 104 | const protectedProperties = ['constructor', 'length']; |
| 105 | // Attach its properties to the window |
| 106 | for (const p in this) { |
| 107 | if (this.hasOwnProperty(p)) { |
nothing calls this directly
no test coverage detected