Comments (8)
so there's a couple of immediate solutions I guess.
- make all the functions/values on
Math
globally available - create a
math
variable that is justMath
so casing doesn't make any difference.
Both are fine, though the bigger issue really is that the undefined variable crashes everything. I think a better fix would be to catch the error and handle it gracefully with a warning so users can fix the casing.
I've not had a look at the hydra code for a while now, but I've not got anything else happening with my Friday night so I'll start digging ๐
from hydra.
Hi @rfpuyana
I think the error might be because math isn't capitalized in your code. The name of the math object in javascript is capitalized: Math
. (Source: MDN web docs)
Try the following code:
osc(10,0.1)
.thresh(0.1).scale(()=>Math.sin(time))
.out()
from hydra.
Zach you are correct. My Bad.
It's now working.
However, Hydra shouldn't freeze.
An error message should notify about this particular case.
from hydra.
Maybe a solution is allowing sin
to be a globally accessible function to prevent calling Math
object directly.
Example (hydra-editor)
sin = (x) => Math.sin(x);
shape(3)
.scale(
()=>sin(time)
).out();
Ideally, it wouldn't require an anonymous function to pass the value but I am not sure how that could be accomplished. Maybe @ojack @rumblesan @echophon @brucelane have ideas on that?
Example:
shape(3)
.scale(
sin(time)
).out();
from hydra.
setting sin( )
matches how p5.js (source code, line 188) has approached this too
from hydra.
right, think I've figured out what's going on and opened that PR, but not had a chance to fully check. will get back to it a bit later when I have a moment
from hydra.
@rumblesan's commit fixed the function crashing issue, yay! And also fixes https://github.com/ojack/hydra/issues/35
As far as globally defining certain functions as @zachkrall mentions, that is part of a much larger conversation at https://github.com/ojack/hydra/issues/8 so let's continue it there.
Opened a new issue about providing user log info about what happens in hydra synth at: https://github.com/ojack/hydra/issues/53
from hydra.
hah, glad to be of use :D
from hydra.
Related Issues (20)
- Link to interactive docs broken HOT 1
- p5 fails to init after reload
- dev branch double space triggers period
- set initStream quality
- a.onBeat() not working? HOT 1
- Add yourself to the contribution list ๐ HOT 28
- exclude dist folder from dev branch HOT 7
- landing modal suggestions
- Dynamic canvas to pass into hydra-synth HOT 1
- WebRTC Deprecated? HOT 1
- WebRTC issue on local server
- Hydra three.js integration needs updating (+workaround)
- Hide code via urlParameter doesn't work anymore HOT 5
- needed to --ignore-engines to build
- Show documentation from within editor
- Make it easier to use local videos from within hydra editor
- Icons not visible if .brightness is set to 1
- simplify readme HOT 5
- add .github repo for the "landing" page on GH
- Use extensiรณn libraries "inside a web page" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hydra.