dman
dman

Reputation: 11064

Three.js- RENDER WARNING: Render count or primcount is 0

Using three.js

On my home PC with Nvidia GNU, I get about 105 of these in my browser console:

/#/home:1 [.CommandBufferContext]RENDER WARNING: Render count or primcount is 0

But on my intel GNU laptop, I do not. Is this a disagreement with the GNU driver? Or is this something I can fix?

var animationId;
var CAMERA_POSITION = 5000;
function runClouds() {
  var speed = 0.8;
  cloudsContainer.style.display = 'block';
  animationId = requestAnimationFrame( runClouds );

  camera.position.y = -75;

  if (camera.position.z <= 0) {
    window.cancelAnimationFrame(animationId);
    camera.position.z = CAMERA_POSITION;
    cloudsContainer.style.display = 'none';
    return true;
  } else if (camera.position.z <= 400) {
    speed = 0.1;
  } else if (camera.position.z <= 900) {
    speed = 0.3;
  } else if (camera.position.z <= 2000) {
    speed = 0.7;
  }

  camera.position.z -= 100 * speed;
  renderer.render( scene, camera );
}

Upvotes: 8

Views: 12988

Answers (2)

ty.
ty.

Reputation: 11132

I had this problem because I didn't pass a position attribute to a BufferGeometry object. Although my shader overrides position with its own computation, it seems to be a required attribute.

I solved this with:

const positions = new Float32Array(PARTICLE_COUNT * 3);
myGeometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));

The default values of 0 are fine if you're not using the value in your shader.

Upvotes: 4

Rush2112
Rush2112

Reputation: 426

This warning is thrown when Three.js is trying to render an object that does not exist yet.

Take, for example, a program here you draw a line.

If you add the line to the scene before you add any points, this warning will appear UNTIL the first point is added and a line can be seen.

If you get this, either something is waiting to be added to the scene, or in your case, since you say you get about 105 every time, I assume that an object is added to the scene then due to asychronicity, is actually made in another function after the fact.

Since it is a warning, there isn't much to be afraid about.

Upvotes: 9

Related Questions