pex-renderer icon indicating copy to clipboard operation
pex-renderer copied to clipboard

Deleting unused attributes from Geometry

Open vorg opened this issue 7 years ago • 0 comments

Currently there is no way of deleting attributes from Geometry.

The following code will fail for 2 reasons:

  • second mesh doesn't have uvs so we will get out of bounds error if the obj has more vertices than the cube
  • count will be ignored as initilalization with cube.cells creates index buffer that is still there and has priority over count

Solution

  • check unused attributes in set() and delete them. This is problematic as setting only one parameter to update it is a common case
  • we can dispose whole geometry and create new one. Same as above: how do we know if we are setting new one or doing partial update?
  • currently all obj/stl/gltf loaders try to add missing uvs/normal attributes. This is still not bullet proof if we have mesh with instancing and switch to mesh without
var cube = {
  positions: [],
  normals: [],
  uvs: [],
  cells: []
}

var geometryCmp = renderer.geometry(cube)

var loadedObj = {
  positions: [],
  normals: [],
  count: 100
}

geometryCmp.set(loadedObj)

vorg avatar Sep 14 '18 13:09 vorg