Skip to content

Error due to "constrain" not being defined in the current scope #23

Description

@nopivnick
🌸 p5.js says: There's an error due to "constrain" not being defined in the current scope (on line 98 in display.js [http://localhost:3000/scripts/display.js:98:3]).

If you have defined it in your code, you should check its scope, spelling, and letter-casing (JavaScript is case-sensitive). For more:
https://p5js.org/examples/data-variable-scope.html
https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Not_Defined#What_went_wrong
p5@1.1.9.js:46374 ▶️ Error at line 98 in "updateAlpha" in display.js (http://localhost:3000/scripts/display.js:98:3)

▶️ Called from line 224 in "updateOutput" in sketch.js (http://localhost:3000/sketch.js:224:3)

▶️ Called from line 35 in "Socket.<anonymous>" in sockets.js (http://localhost:3000/scripts/sockets.js:35:3)

▶️ Called from line 1761 in "Socket../node_modules/component-emitter/index.js.Emitter.emit" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:1761:20)

▶️ Called from line 1160 in "Socket.emitEvent" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:1160:61)

▶️ Called from line 1134 in "Socket.onevent" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:1134:14)

▶️ Called from line 1086 in "Socket.onpacket" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:1086:16)

▶️ Called from line 1761 in "Manager../node_modules/component-emitter/index.js.Emitter.emit" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:1761:20)

▶️ Called from line 526 in "Manager.ondecoded" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:526:62)

▶️ Called from line 1761 in "Decoder../node_modules/component-emitter/index.js.Emitter.emit" in socket.io@3.1.2.js (http://localhost:3000/libraries/socket.io@3.1.2.js:1761:20)


p5@1.1.9.js:46741 Did you just try to use p5.js's constrain() function? If so, you may want to move it into your sketch's setup() function.

For more details, see: https://github.com/processing/p5.js/wiki/p5.js-overview#why-cant-i-assign-variables-using-p5-functions-and-variables-before-setup
display.js:98 Uncaught ReferenceError: constrain is not defined
    at updateAlpha (display.js:98)
    at updateOutput (sketch.js:224)
    at Socket.<anonymous> (sockets.js:35)
    at Socket../node_modules/component-emitter/index.js.Emitter.emit (socket.io@3.1.2.js:1761)
    at Socket.emitEvent (socket.io@3.1.2.js:1160)
    at Socket.onevent (socket.io@3.1.2.js:1134)
    at Socket.onpacket (socket.io@3.1.2.js:1086)
    at Manager../node_modules/component-emitter/index.js.Emitter.emit (socket.io@3.1.2.js:1761)
    at Manager.ondecoded (socket.io@3.1.2.js:526)
    at Decoder../node_modules/component-emitter/index.js.Emitter.emit (socket.io@3.1.2.js:1761)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingp5

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions