question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebGLBindingState: Add geometry.index cache for VAO

See original GitHub issue

Now, 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:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shawn0326commented, Aug 11, 2020

Ok, I’d like to make PR.

1reaction
takahiroxcommented, Aug 10, 2020

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

If I reuse the same material, everything works fine

it probably works since in my modified example only a single VAO exists (because there is only a single program).

Correct, if you reuse the same material in the example only a single VAO exists so you don’t see the problem.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found