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

An attempt to subdivide each edge in 3 #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Main {

console.time("Generate Tiling");
const tiling = new RegularHyperbolicTesselation(this.spec).generateTiling(
false
true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

enable designMode

);
console.timeEnd("Generate Tiling");

Expand Down
32 changes: 8 additions & 24 deletions src/utilities/createGeometries.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ function subdivideHyperbolicArc( arc, numDivisions ) {
// calculate the number of subdivisions required to break the arc into an
// even number of pieces (or 1 in case of tiny polygons)

numDivisions = numDivisions || ( arc.arcLength > 0.001 )
? 2 * Math.ceil( arc.arcLength ) // currently always = 2
: 1;
// numDivisions = numDivisions || ( arc.arcLength > 0.001 )
// ? 2 * Math.ceil( arc.arcLength ) // currently always = 2
// : 1;
numDivisions = 3;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Force all edges to be subdivided in 3


// calculate spacing based on number of points
const spacing = arc.arcLength / numDivisions;
Expand Down Expand Up @@ -129,7 +130,7 @@ function subdivideHyperbolicPolygon( polygon ) {
const startPoint = subdividedEdges[2][( numDivisions - i )];
const endPoint = subdividedEdges[1][i];
// this.subdivideInteriorArc( startPoint, endPoint, i );
const newPoints = subdivideLine( startPoint, endPoint, i );
const newPoints = subdivideLine( startPoint, endPoint, numDivisions, i );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo here? Was not matching the prototype of subdivideLine()


// for ( let j = 0; j < newPoints.length; j++) {
// flatPoints.push(
Expand Down Expand Up @@ -256,30 +257,13 @@ export default function createGeometries( tiling ) {
edgeStartingVertex += m;
}

return [ positionIndex, uvIndex ];
}

if ( polygon.materialIndex === 0 ) {
addPositionsAndUvs( positionsA, positionAIndex, uvsA, uvAIndex );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleanup, so that "Too many divisions!!" error is not thrown

if ( divisions === 1 ) {
positionAIndex += 9;
uvAIndex += 6;
} else if ( divisions === 2 ) {
positionAIndex += 36;
uvAIndex += 24;
} else {
console.error( 'Too many divisions!!' );
}
[ positionAIndex, uvAIndex ] = addPositionsAndUvs( positionsA, positionAIndex, uvsA, uvAIndex );
} else {
addPositionsAndUvs( positionsB, positionBIndex, uvsB, uvBIndex );
if ( divisions === 1 ) {
positionBIndex += 9;
uvBIndex += 6;
} else if ( divisions === 2 ) {
positionBIndex += 36;
uvBIndex += 24;
} else {
console.error( 'Too many divisions!!' );
}
[ positionBIndex, uvBIndex ] = addPositionsAndUvs( positionsB, positionBIndex, uvsB, uvBIndex );
}

}
Expand Down