WebGLBindingState: Add geometry.index cache for VAO
See original GitHub issueNow, the needsUpdate method only compares geometry.attributes, if i change geometry.index when using VAO, it may cause bugs.
Add geometry.index cache for VAO will help:
function needsUpdate( geometry ) {
const cachedAttributes = currentState.attributes;
const geometryAttributes = geometry.attributes;
if ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;
for ( const key in geometryAttributes ) {
const cachedAttribute = cachedAttributes[ key ];
const geometryAttribute = geometryAttributes[ key ];
if ( cachedAttribute.attribute !== geometryAttribute ) return true;
if ( cachedAttribute.data !== geometryAttribute.data ) return true;
}
if ( currentState.index !== geometry.index ) { // Fix!!
return true;
}
return false;
}
function saveCache( geometry ) {
const cache = {};
const attributes = geometry.attributes;
for ( const key in attributes ) {
const attribute = attributes[ key ];
const data = {};
data.attribute = attribute;
if ( attribute.data ) {
data.data = attribute.data;
}
cache[ key ] = data;
}
currentState.attributes = cache;
currentState.index = geometry.index; // Fix!!
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Add Spatial Index (Data Management)—ArcGIS Pro
Use this tool to either add a spatial index to a shapefile or feature class that does not already have one or to...
Read more >15. Spatial Indexing — Introduction to PostGIS
Spatial indexes are a little different – they are unable to index the geometric features themselves and instead index the bounding boxes of...
Read more >11.4.10 Creating Spatial Indexes - MySQL :: Developer Zone
For InnoDB and MyISAM tables, MySQL can create spatial indexes using syntax similar ... CREATE TABLE geom (g GEOMETRY NOT NULL SRID 4326,...
Read more >5.1 Creating a Spatial Index
Within each geometry column to be indexed, all the geometries must have the same SDO_SRID value. Spatial indexes can be built on two,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I’d like to make PR.
Yes, this is actually a bug. Good catch and sorry for the bug!
Probably, as you suggested, we need to cache index and check it.
@shawn0326
Would you like to make PR to fix? Or do you want me to make?
@Mugen87
Correct, if you reuse the same material in the example only a single VAO exists so you don’t see the problem.