Skip to content

feat: primive-outline#1720

Open
WallanceLee wants to merge 10 commits into
donmccurdy:mainfrom
WallanceLee:feature/primitive-outline
Open

feat: primive-outline#1720
WallanceLee wants to merge 10 commits into
donmccurdy:mainfrom
WallanceLee:feature/primitive-outline

Conversation

@WallanceLee

Copy link
Copy Markdown

No description provided.

@WallanceLee WallanceLee changed the title feat: primive-outline feat: primive-outline[WIP] Sep 22, 2025
@WallanceLee WallanceLee changed the title feat: primive-outline[WIP] feat: primive-outline Oct 4, 2025
Comment thread packages/functions/src/primitive-outline.ts Outdated
Comment thread packages/functions/src/primitive-outline.ts Outdated
Comment thread packages/functions/src/create-edge-primitive.ts Outdated
// if we found a sibling edge add it into the vertex array if
// it meets the angle threshold and delete the edge from the map.
if (glvec3.dot(normal, edgeData[reverseHash].normal) <= thresholdAngle) {
vertices.push(v0[0], v0[1], v0[2]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you are converting vertices to Float32Array later, make a block-based allocator with typed array could make gc happy.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think this is OK as-is for now — it's a new feature and can be optimized later.

@donmccurdy donmccurdy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you @WallanceLee, and sorry for the slow review! I'd be excited to get this feature merged, and have left some feedback on the PR in comments below. If any of the suggestions are confusing or feel like more than you can do right now, let me know and we'll figure something out. :)

Comment thread packages/functions/src/primitive-outline.ts Outdated
Comment thread packages/functions/src/primitive-outline.ts Outdated
// if we found a sibling edge add it into the vertex array if
// it meets the angle threshold and delete the edge from the map.
if (glvec3.dot(normal, edgeData[reverseHash].normal) <= thresholdAngle) {
vertices.push(v0[0], v0[1], v0[2]);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think this is OK as-is for now — it's a new feature and can be optimized later.


const edgePrim = document
.createPrimitive()
.setName(prim.getName() + '_edges')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Surprisingly, glTF primitives do not have names, so this line has no effect on export and can be removed. The .setName() method in glTF Transform exists only as inherited from the Property class.

.createPrimitive()
.setName(prim.getName() + '_edges')
.setMode(Primitive.Mode.LINES)
.setAttribute('POSITION', accesor);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Perhaps ideally, all vertex attributes from the source primitive would be preserved in the output, but I recognize that's a fairly tricky change. For example, so that edges of a skinned mesh can be animated along with the rest of the mesh. Feel free to skip it and we can include it as a later improvement!

Comment thread packages/functions/src/create-edge-primitive.ts Outdated
Comment thread packages/functions/src/create-edge-primitive.ts
Comment thread packages/functions/src/primitive-outline.ts Outdated
Comment thread packages/functions/src/create-edge-primitive.ts
@donmccurdy donmccurdy added feature New enhancement or request package:functions labels Oct 15, 2025
@donmccurdy donmccurdy modified the milestones: v4.2, 🗄️ Backlog Oct 15, 2025
@WallanceLee

Copy link
Copy Markdown
Author

OK, I will try my best to optimize the code.

@WallanceLee

Copy link
Copy Markdown
Author

Is there anything to be done?

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

Labels

feature New enhancement or request package:functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants