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

Why __dirty* is needed? #2079

Closed
impelluso opened this issue Jun 19, 2012 · 4 comments
Closed

Why __dirty* is needed? #2079

impelluso opened this issue Jun 19, 2012 · 4 comments
Labels

Comments

@impelluso
Copy link

Hi all,

I recently asked about modifying a line. Someone helped (thank you). In the process I learned that I must also declare:

line.geometry.__dirtyVertices = true;
line.geometry.__dirtyNormals = true;

May I ask why this happens? I do it, it is fine, I can close the book and move on.
But I am left with an uneasy feeling that there is something not truly fixed.
It is a feeling that this works only because it is a kludge.
Maybe I get this feeling because I am not from the world of computer graphics (my area is mechanical engineering).

But when I see "tricks" like this, I get concerned that I am not learning this correctly, or that three.js is not comprehensive.

I am not asking for someone to explain the specifics of why the above two lines work (I can intuit that that mean "my work got mess and dirty so please revisit this Mr. GPU" or something like that)

But why do you all seem so comfortable with things like this?

@impelluso
Copy link
Author

Or, more specifically:
What ELSE can "dirtyVertices = true" possibly mean?

Why not just say
renderer(revisit.geometry)

Or something like that?

@alteredq
Copy link
Contributor

Real-time computer graphics is all about performance. Whenever you see something weird, chances are it's there to squeeze out more performance somewhere.

In this case, changes to geometry are expensive (while rendering static geometry is cheap, even if it's huge), so we try to limit changes to absolute necessary minimum.

And here changes are not atomic on geometry (geometries have multiple components). For example you may want to update just some attributes (position, normal, color, uvs, etc), not all of them at once - this is often the bottleneck, so if you can update just one attribute instead of two, voila, you just doubled the performance.

And "dirty" flags are a common technique (and name) for signaling that something has changed. BTW since some time we don't call them anymore "dirty", partly as initiative to make it more newbie friendly (see #697).

@impelluso
Copy link
Author

Thank you... BUT

I understand what you said. I read the additional note.

I converted:
line.geometry.__dirtyVertices = true;
To
line.geometry.verticesNeedUpdate = true;

And it does not work. It only works with dirty

And why is there not a similar change for normals?
Must those remain dirty?

@alteredq
Copy link
Contributor

Maybe you are using some old version of the lib?

It should work, examples using it work.

Read here about exact syntax for all attributes:

https://github.com/mrdoob/three.js/wiki/Updates

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

No branches or pull requests

3 participants