-
Notifications
You must be signed in to change notification settings - Fork 200
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
Fix rendering issues for line, stamp, and geometry brushes #265
Conversation
msub2
commented
Mar 4, 2022
•
edited
Loading
edited
- Line and stamp brushes now use indexed BufferGeometries to replace the TriangleStrip drawMode that was being used before.
- Cube/Sphere/Rainbow brushes are now properly added to the a-drawing entity and behave properly by disappearing when the user undoes a stroke made with one.
- Made small adjustments to address three.js API updates over the years
- Adjusts BufferAttribute updateRanges to only update as much as has been drawn (as in Performance: sharedbuffergeometry update ranges #249). This results in visibly better performance while drawing.
This removes the remaining references to TriangleStripDrawMode. In its place is a vertex index buffer that seems to be working. Still currently an issue with strokes made after an undo action.
Undoing a stroke and then drawing again would cause it to read old data. Now vertex/index buffers are cleared back to the prevIdx on undo/clear.
For whatever reason they still aren't rendering though.
This modifies the way indices are sent to the index buffer. If the brush is strip-based, we know verts are being sent 2 at a time. If it's stamp based, we know verts are being sent 3 at a time. SharedBufferGeometry now has a strip flag and sets indices accordingly.
These brushes were not being added to the a-drawing entity. They were also missing an undo function, which is now implemented. Rainbow brush was adjusted to use indexed BufferGeometry. Increased index buffer size for sharedbuffergeometry.
src/brushes/cubes.js
Outdated
}); | ||
this.geometry = new THREE.BoxGeometry(1, 1, 1); | ||
this.drawing = document.querySelector('.a-drawing'); |
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.
this.drawingEl
for style consistency
src/brushes/single-sphere.js
Outdated
}); | ||
this.geometry = new THREE.IcosahedronGeometry(1, 2); | ||
this.mesh = new THREE.Mesh(this.geometry, this.material); | ||
this.object3D.add(this.mesh); | ||
this.mesh.visible = false | ||
this.mesh.visible = false; | ||
this.drawing = document.querySelector('.a-drawing'); |
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.
this.drawingEl
src/brushes/spheres.js
Outdated
}); | ||
this.geometry = new THREE.IcosahedronGeometry(1, 0); | ||
this.drawing = document.querySelector('.a-drawing'); |
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.
this.drawingEl
Super appreciated! |