-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
modelX/Y/Z() and screenX/Y/Z() for p5.js (WebGL) #4743
Comments
modelX/Y/Z()
and screenX/Y/Z()
for p5.js (WebGL)
I think I've figured out a partial workaround (for my purposes) for the missing modelX/Y/Z() functions, using the canvas "Model View" matrix uMVMatrix and p5.Matrix functions: https://editor.p5js.org/mkmori.05/sketches/uoPdThLGU
I was hoping a variable could reference I'm assuming people with matrix math skills could also get transformed coordinates using these matrix objects, so we could almost do away with the modelX/Y/Z() part of this request...? (I'll edit the initial request....) |
hi @mkmori When replacing line 43 @davepagurek |
Thanks, @opheliagame! I tweaked my sketch to replace .copy() (and .set()) with object references.... I'm still a bit confused about how the object references seem to function like value assignments in practice: I found it also works to do As for screen space coordinates, here is another sketch, based on work done by @bohnacker & @tcoppex: Thanks again--I am following with interest! |
How would this new feature help increase access to p5.js?
This feature set would increase access by improving feature parity between Java P5 and p5.js. Js seems more accessible than Java these days, (esp. on the Web), and both are learning tools, so I feel, where possible, equivalent functionality would be desirable.
I also believe 3D is a core Processing.org feature, offering a uniquely low bar to entry.
The alternative to these "matrix access" functions seems to be direct matrix manipulation and/or access to WebGL. In my experience so far, these both add steep learning curves to what may be accomplished in Java P5 quite intuitively using push()/pop(), transformation, and these "matrix access" functions.
From the history of related requests, besides limiting common access to a well-implemented feature set, I feel the lack of easier "matrix access" functions also poses a risk to learners (like me!) getting frustrated trying to integrate unmaintained, external dependencies, or cooking up their own creative & idiosyncratic, but also potentially limiting theories & workarounds , (as valuable as such frustrations may be).
Most appropriate sub-area of p5.js?
New feature details:
This is a request to implement, specifically for
WEBGL
mode,modelX()
,modelY()
, &modelZ()
, andscreenX()
,screenY()
, &screenZ()
.I've collected all the related requests I could find below, but most of them are P2D-specific and seem to be precluded by canvas-specific issues. (Maybe a future WebGL-implementation of 2D mode would remove that obstacle, and offer users a common 2D/3D code and visualization space...?)
As a compromise/alternative to implementation of(Something like this seems to exist in the p5.Matrix functions.)modelX/Y/Z()
(departing a little from Java P5 convenience), if "let gl = getGlMatrix();
" were a thing in p5.js, could that be used à laapplyMatrix( gl.a, gl.b, gl.c, gl.d., gl.e., gl.f., gl.g, gl.h, gl.i, gl.j, gl.k, gl.l, gl.m, gl.n, gl.o, gl.p )
to reproduce WebGL transformations outside ofpush()
/pop()
?applyMatrix()
seems to require matrix elements as individual arguments...so maybe a separate array? mat4? version "applyGlMatrix( gl )
" would be nicer?Is there already an easy way to grab the current 3D transformation matrix, ((Did it, I think! Please see next post....)p5.Matrix.mat4
or something)? I feel this would be less accessible and intuitive thanmodelX/Y/Z()
, but still sufficiently abstracted for a learner like me to get things done....With the transformation matrix, (a bit more study, and a few more steps), I gather we should be able to get transformed coordinates just as we would with
modelX/Y/Z()
, right?Lastly, there's the "projection matrix", of possible relevance to the
screenX/Y/Z()
part of this request, I think. I understand from playing with Java P5, thatscreenZ()
returns z-buffer values, for 3d picking, "screen space" effects etc.--a little unpredictable, but still fun....Out of my depth, but some of this even seems semi-doable for me! If I could figure out how to get the current GL context and transformation matrix...and get help writing code on par for contribution here....
Thanks for considering!
#243 (push()/pop() discussion)
#377 (modelX(), modelY() feature request)
#1553 (screenX() screenY(), screenZ() feature request)
#1873 (modelX(), modelY() feature request)
#4337 (matrix functions...completed!)
The text was updated successfully, but these errors were encountered: