Smilebags / p5.dimensions.js

An addon for p5.js which adds support for higher dimensional calculations.
72 stars 24 forks source link

Trouble with directories in windows? #29

Open bwanaaa opened 3 years ago

bwanaaa commented 3 years ago

I am using sublime text and browser sync to test p5.js projects. Typically, I open the index.html file and 'launch' it from the Browser sync menu in sublime text. I have tried this with lerp.html, veector.html, and 4d-projection.html but my browser remains blank.

I copied the p5.dimensions.js file as well as the p5 library into the examples directory and changed the html thusly:

   <script src="p5/p5.js"></script>
    <script src="p5/addons/p5.dom.js"></script>
    <script language="javascript" type="text/javascript" src="/p5.dimensions.js"></script>

Now it works. mostly. Lerp lets me draw swooshy blue calligraphic shapes Vector puts out four little boxes where numbers can be entered but the output is NaN 4d-projection works fine.

So I guess directory traversal in windows is confounding browser sync. The vector thingy that might be failing is the function perspectiveProjectionMatrix The line iin that function that gives NaN is multipliedVector = multipliedVector.nDiv(multipliedVector[dimensionalSymbols[vector.dimension()]]); It seems to refer to an array, dimensionalSymbols, which is not defined inside that function. But even if I copy that line that starts with 'var dimensionalSymbols=...' inside the function (just before 'var matrixString =...') I still get NaN.

If I put console.log(multipliedVector); just after it's calculated in p5.dimensions.js I see a lot of

vector2.html:76 {x: 3, y: 1, z: 4, a: 1, nDist: ƒ, …}
p5.dimensions.ts:126 {x: NaN, y: NaN, z: NaN, a: NaN, b: NaN, …}

```and

​ {x: 3, y: 1, z: 4, a: 1, nDist: ƒ, …} ​ {x: NaN, y: NaN, z: NaN, a: NaN, b: NaN, …}


in the console of chrome.

So I'm stumped.