Skip to content
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

Text to model docs #7595

Open
wants to merge 11 commits into
base: dev-2.0
Choose a base branch
from

Conversation

perminder-17
Copy link
Contributor

@perminder-17 perminder-17 commented Mar 3, 2025

No description provided.

@perminder-17 perminder-17 marked this pull request as draft March 6, 2025 16:14
@perminder-17 perminder-17 requested a review from holomorfo March 18, 2025 00:02
@perminder-17 perminder-17 marked this pull request as ready for review March 18, 2025 21:00
Copy link

@holomorfo holomorfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @perminder-17 thanks, it looks good, I just added a small comment about notation and a need for a small clarification, let me know your thoughts.
CC: @davepagurek @limzykenneth

* 'vec4 getFinalColor': `(vec4 _c) {
* float x = vPos.x * 0.005;
* float a = floor(fract(x) * numColors);
* float b = a == numColors - 1. ? 0. : a + 1.;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this was adressed before, but having the notation -1. might not be clear for all users, thinking that why not use just -1 or -1.0 I understand that we might need to explicitly cast it like this to indicate its a float to WEBGL but it might I think it would be useful to add a note as to why we choose to notate it like this. A brief comment would be good enough I believe

*
* let prevWords = '';
* let prevFont = '';
* let prevExtrude = -1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example, why in the other cases we need an explicit float and not here? It might be confusing for some users.

* let prevExtrude = -1;
*
* function draw() {
* if (words !== prevWords || prevFont !== font || prevExtrude !== extrude) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a leftover from when the input and font were editable? We can probably remove this if statement and the prev* variables, and just create the geometry in setup.

* createCanvas(200, 200, WEBGL);
* fonts = {
* Anton: await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'),
* Montserrat: await loadFont('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Ew-Y3tcoqK5.ttf'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can change this from being an object to just a single font variable since the example doesn't let people switch fonts interactively as the sketch runs. Maybe we can list the other URLs just in comments if users want to try different ones and rerun?

* async function setup() {
* createCanvas(200, 200, WEBGL);
* fonts = {
* Anton: await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment here about the fonts object

* }
*
* function draw() {
* if (geom) freeGeometry(geom);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this will free and remake the geometry every frame. We can take this out for the example and reuse the initial geometry

* function draw() {
* if (geom) freeGeometry(geom);
*
* geom = fonts[font].textToModel(words, 0, 50, { sampleFactor: 2, extrude });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block can be moved to setup() since we won't need to remake the geometry while the example is running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants