-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to load external scripts / other libraries #88
Comments
heyhey @TiborUdvari ! FYI it's already a built in feature! yeah yeah.. looooong readme... let libs = [
'' // path(s) to CDN or local if running OFFLINE mode
] There's a small libs loading bug in the Here's the code you'd use in the future P5LIVE version (soooon) to disable built in p5, then manually load an older version. // p5.xr works with p5.js 1.5.0 - bug with latest 1.9+
// no p5 // disable latest version
let libs = [
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js',
'https://cdn.jsdelivr.net/npm/p5.xr/dist/p5xr.min.js'
]
new p5(); // manually init p5
function preload() {
createVRCanvas();
}
function setup() {
setVRBackgroundColor(200, 0, 150);
fill(0, 255, 0);
}
function calculate() {
// Things you want to happen once per frame
}
function draw() {
translate(0, 0, 10);
rotateX(10);
rotateY(20);
box(5);
} |
output.mp4Thank you! I got it working directly in the headset. It does crash out of immersive mode sometimes, but I think this is the closest I got to have live coding in Mixed Reality. p5.xr hasn't released the new version with the encoded fixes just yet. I have a fork that works, so for anyone with a XR headset this should work: let libs = [
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.1/p5.js',
'https://cdn.jsdelivr.net/npm/@tiborudvari/p5.xr@0.4.67/dist/p5xr.js'
]
new p5(); // manually init p5
function preload() {
createMRCanvas();
}
let r = 0;
function calculate() {
r = frameCount / 100 * 1;
}
function draw() {
push();
scale(0.01); // use cm
push();
translate(10, -11, -50)
rotateX(r);
box(10, 10, 10)
pop();
pop();
} |
badaaaamn – that looks awesome in the XR recording! Super cool it all works. 1st P5LIVE in VR that i know of..? there's a BIG ol update coming veeery soon (last touches right now) – would be great to add a demo for this – what else is needed? does the /*
_hardware_xr // cc _prefered_name/handle_ 2024
_short description of setup/hardware/workflow_
*/
|
The draw function is being called twice, one time for each eye. So any calculations there get updated twice. I'm actively doing tests / different versions to the API, before I update to upstream. It's not always clear what the p5 like api should be like. For now I feel it's a little hardware specific, so it's kind of hard to have it be as plug and play as I would like it. Anyways, I'm doing a small workshop with this soon, so I'll do a proper writeup of what is needed / how to use it with p5.live, I'll post it here once I'm done. It's an ideal use case, because when people have the headset on there is no way of knowing what they are actually seeing ... PS Doing small demos here in the meantime: https://www.tiborudvari.com/sketchbook |
I would like to make a test with
p5.xr
among other libraries. Is there anofficial
way to do this?I'm thinking of doing something like this if not
The text was updated successfully, but these errors were encountered: