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

Add support for attribute.dirty #334

Closed
vorg opened this issue Jan 12, 2023 · 2 comments
Closed

Add support for attribute.dirty #334

vorg opened this issue Jan 12, 2023 · 2 comments
Labels
Projects
Milestone

Comments

@vorg
Copy link
Member

vorg commented Jan 12, 2023

We need a way to update only one attribute e.g. offsets without re-uploading all others. One solution would be to add .dirty = true/false property. This could be also used for invalidating bouds and and manually asking for recalculating bounding box.

@vorg vorg added type/fix A bug fix type/feat A new feature and removed type/fix A bug fix labels Jan 12, 2023
@dmnsgn dmnsgn added this to To do in 4.0.0 via automation Apr 17, 2023
@dmnsgn dmnsgn added this to the 4.0.0 milestone Apr 17, 2023
@dmnsgn
Copy link
Member

dmnsgn commented Apr 17, 2023

Revived instancing example and use it to demo attribute.dirty: 13ed415#diff-b9928ed31347ca26a5db354cc663e6275c0a7266edafd38ca237539ca95d2cd0R184-R188

The main change in the system are:

  • checking cached object difference upfront and updating properties:

const geometryDirty = cachedGeom.geometry !== geometry;
// Cache properties
if (geometryDirty) {
if (geometrySystem.debug) {
console.debug("geometry-system", "update geometry", id, geometry);
}
cachedGeom.geometry = geometry;
cachedGeom.instances = geometry.instances;
cachedGeom.count = geometry.count;
cachedGeom.primitive = geometry.primitive;
}

  • checking for both upfront whole geometryDirty and attribute.dirty to skip update:

if (!(geometryDirty || attributeValue.dirty)) continue;

@dmnsgn
Copy link
Member

dmnsgn commented Apr 17, 2023

Performance in example (updating offsets/rotations/colors only instead of positions/normals/uvs/cells/offsets/scales/rotations/colors): 10ms -> 3.5ms

@dmnsgn dmnsgn closed this as completed May 5, 2023
4.0.0 automation moved this from To do to Done May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
4.0.0
  
Done
Development

No branches or pull requests

2 participants