- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 36.1k
Converted TessellateModifier to recursive and made similar to SubdivisionModifier #20430
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
Conversation
| @mrdoob I also added  So constructor look like this now:  Also, linting rules did not allow me to define constructor arguments as optional with default values in d.ts file. I tried this: constructor( maxEdgeLength?: number = 0.1, maxIterations?: number = 6, maxFaces?: number = 100000 );And I got error: Is this TS linting rule intended? | 
| 
 As far as I know you can't set default function parameters in d.ts files :( | 
| 
 Yeah, I'm still learning about TS. It turns out you can set default values in the constructor but cannot make arguments optional and initialized at the same time. That kinda makes sense since it would be redundant. Anyway, the lint error is fixed.  | 
| @arodic any chance you could resolve the conflicts? | 
| I'll update this PR asap. | 
| Conflicts resolved. Ready to merge. | 
| */ | ||
|  | ||
| THREE.TessellateModifier = function ( maxEdgeLength ) { | ||
| THREE.TessellateModifier = function ( maxEdgeLength = 0.1, maxIterations = 6, maxFaces = 1000000 ) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about maxFaces = Infinity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| Thanks! | 
Currently
TessellateModifieris not recursive and requires manual invocation of themodify( geometry )multiple times like in the example here.The problem with this is that you can't know when the
maxEdgeLengthparameter is satisfied and the tessellation is complete. So you have to guess how many iterations you need. In the example6seems to do the job, in some other cases any number of iterations between0 .. nis needed.This change contains the following:
while ( ! finalized )tessellation loop that runs until no edge withlength > maxEdgeLengthexists.modify( geometry )argument, it returns new geometry (same asSubdivideModifier).It also contains a minor change affecting both
TessellateModifierandSubdivideModifier:GeometryvsBufferGeometry)Geometry.mergeVertices( precisionPoints )now accepts optionalprecisionPointsargument.geometry.mergeVertices( 6 );to avoid collapsing small triangles.Questions:
precisionPointsfor vertex merging also be a property ofTessellateModifierand `SubdivideModifier?