Possible bug?

Hi everyone, I am trying to render dynamic points.

So I create a Primitive Collection

. this.pointPrimitives = viewer.scene.primitives.add(new Cesium.PrimitiveCollection());

Render some points using GroundPrimitive (when I use PointPrimitives, this error does not happen!!)

. pointPrimitives.add(new Cesium.GroundPrimitive({…

And in each iteration, remove the points and go again.

. pointPrimitives.removeAll();

(I would give you a SandCastle link, but I am not being able to reproduce this error there.)

After removing for the first time, when I try to add a new point, I get the following message:

This only happens with GroundPrimitives and Entities, but not with other primitives.

Any ideas to what may be causing this? Thanks in advance!

Hi Juan,

  1. Do you have a full snippet you can copy/paste here? It’s ok if it’s not possible to replicate in Sandcastle.

  2. What version of Cesium are you using? It may be that you can’t duplicate in Sandcastle because you’re using an older version.

Thanks,

Gabby

My error would be similar to this: https://github.com/AnalyticalGraphicsInc/cesium/issues/5577, when I use some logic to remove and add primitives.

The code would be something like this, in a loop or other logic:

polylinePrimitives.removeAll();

var rectangleInstance = new Cesium.GeometryInstance({

geometry: new Cesium.CircleGeometry({

center: Cesium.Cartesian3.fromDegrees(-110, 35),

radius: 100000

}),

attributes: {

color: new Cesium.ColorGeometryInstanceAttribute(Math.random(), Math.random(), Math.random(), 0.99)

}

});

pointPrimitives.add(new Cesium.GroundPrimitive({

geometryInstances: rectangleInstance

}));

It seems it is trying to render something that was removed, but I do not know what or why.

UniformSampler.prototype.set = function() {

var gl = this._gl;

gl.activeTexture(gl.TEXTURE0 + this.textureUnitIndex);

var v = this.value;

gl.bindTexture(v._target, v._texture); // error is thrown here, because v is undefined!

};

When I checked for v first, (adding if (v) to that line), it throws another error, “object was destroyed”

This is the error I get when I add “if (v)”

Are you adding the GroundPrimitve to scene.groundPrimitves instead of scene.primitives?

I am adding them to this variable
. this.pointPrimitives = viewer.scene.primitives.add(new Cesium.PrimitiveCollection());

I could ‘fix’ this bug by setting destroyPrimitives to false, though I don’t know why it works.

Disabling distroyPrimitives will not destroy the underlying geometry rendering references, so when they are updated, they aren’t undefined, and don’t throw an error. However, youapplication will use more memory.