attempting to implement orthographic camera
Hello there!
Attempting to implement orthographic camera (for the purpose of 2D Usage of 3d-force graph for performance benefits) using this SO post: https://stackoverflow.com/questions/48758959/what-is-required-to-convert-threejs-perspective-camera-to-orthographic
I actually was unable to get a test environment working for this (with the different packages working together for some reason NPM link didn't work), I figure you likely have one readily available to take a quick look.
To test it locally, i did the following:
- Clone
3d-force-graphand your fork in the same folder. - Modify the
package.jsonof3d-force-graph. Change thethree-render-objectsdependency tofile:<relative-route>(probablyfile:../three-render-objects). - Run
npm iin your fork. - Modify your fork as much as you want.
- Run
npm run buildin your fork folder whenever you want to test changes. - Run
npm iin3d-force-graph, then open one file of theexamplefolder (i usually pickbasic) and change the import to the one that is local (<script src="../../dist/3d-force-graph.js"></script>). - Open that file in the browser.
And that's it.
Now, when you want to test some changes you need to run npm run build on the fork and npm i on the 3d-force-graph.
PS: In order for your fork to work, you also need to add cameraType to the stateInit in 3d-force-graph/src/3d-force-graph.js.
got it, thank you, I figured there had to be something upstream I was missing...
btw you can use npm link in order to avoid needing to modify package.jsons, it overrides a dependency with a local symlink
- in the local forked and modified dependency run
npm link, this builds and exposes this local code to be symlinked elsewhere. - in your consuming repo
npm link <dependency name>, in this casenpm link three-render-objects
Here I think why I failed is because as you pointed out I also need to modify the intermediate dependency of 3d-force-graph.
Interesting, thanks for the PR @sirrodgepodge! 👍
I left a few minor comments. We should be able to merge this after cleaning up the code a bit.
Would you mind adding something to the docs also?
Responded to all the comments.
Have to be honest and say that I still couldn't get a test environment working :( :( :(. Maybe you have and can confirm it works.
I need to link three-forcegraph and 3d-force-graph to get react-force-graph-3d to be using this right?
@sirrodgepodge for testing this functionality you can run yarn build or yarn dev which will save the built files in the local /dist directory.
Then you can simply import those into your development example. If you want to try with the built-in example, you just have to modify the script tag target here: https://github.com/vasturiano/three-render-objects/blob/master/example/basic/index.html#L7
whoops, that was super sloppy, apologies, attempted to clean up here: https://github.com/vasturiano/three-render-objects/pull/6/commits/38305ff5fc8aff0dba3600a635a032a8049e09ee
The only thing I'm unclear on is whether state.camera.position.z maps exactly to depth described here:
https://stackoverflow.com/questions/48758959/what-is-required-to-convert-threejs-perspective-camera-to-orthographic
Will give up on fancy npm link and just try getting local orchestration happening through direct imports this weekend.