Skip to content

Commit 37b9c13

Browse files
committedMar 21, 2025
Code review tweaks
1 parent 5acefd4 commit 37b9c13

12 files changed

+19985
-1131
lines changed
 

‎build/three.cjs

+9,691-369
Large diffs are not rendered by default.

‎build/three.core.js

+8,936-283
Large diffs are not rendered by default.

‎build/three.core.min.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/three.module.js

+757-87
Large diffs are not rendered by default.

‎build/three.module.min.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/three.tsl.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/three.tsl.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/three.webgpu.js

+296-191
Large diffs are not rendered by default.

‎build/three.webgpu.min.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/three.webgpu.nodes.js

+280-191
Large diffs are not rendered by default.

‎build/three.webgpu.nodes.min.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/geometries/ExtrudeGeometry.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,12 @@ class ExtrudeGeometry extends BufferGeometry {
162162

163163
}
164164

165-
function cleanPoints( points ) {
165+
/**Merges index-adjacent points that are within a threshold distance of each other. Array is modified in-place. Threshold distance is empirical, and scaled based on the magnitude of point coordinates.
166+
* @param {Array<Vector2>} points
167+
*/
168+
function mergeOverlappingPoints( points ) {
166169

167-
const THRESHOLD = 0.0002;
170+
const THRESHOLD = 1e-10;
168171
const THRESHOLD_SQ = THRESHOLD * THRESHOLD;
169172
let prevPos = points[ 0 ];
170173
for ( let i = 1; i <= points.length; i ++ ) {
@@ -175,10 +178,16 @@ class ExtrudeGeometry extends BufferGeometry {
175178
const dy = currentPos.y - prevPos.y;
176179
const distSq = dx * dx + dy * dy;
177180

178-
if ( distSq <= THRESHOLD_SQ ) {
181+
const scalingFactorSqrt = Math.max(
182+
Math.abs( currentPos.x ),
183+
Math.abs( currentPos.y ),
184+
Math.abs( prevPos.x ),
185+
Math.abs( prevPos.y )
186+
);
187+
const thesholdSqScaled = THRESHOLD_SQ * scalingFactorSqrt * scalingFactorSqrt;
188+
if ( distSq <= thesholdSqScaled ) {
179189

180190
points.splice( currentIndex, 1 );
181-
if ( currentIndex == 0 ) break;
182191
i --;
183192
continue;
184193

@@ -190,8 +199,8 @@ class ExtrudeGeometry extends BufferGeometry {
190199

191200
}
192201

193-
cleanPoints( vertices );
194-
holes.forEach( cleanPoints );
202+
mergeOverlappingPoints( vertices );
203+
holes.forEach( mergeOverlappingPoints );
195204

196205
const numHoles = holes.length;
197206

0 commit comments

Comments
 (0)
Failed to load comments.