#Vertex buffer is not big enough for the draw call

8 messages · Page 1 of 1 (latest)

lean chasm
#

I keep running into an issue on mac that stops my particles from rendering.

This problem only occurs on mac and im not sure why? i've tried searching and searching and all the weird solutions people have hacked together don't seem to work at all.

Is anyone able to help with this? I have no idea where to even start fixing this issue

My code:

export default function Particles({
amount,
size,
color,
spread,
onClick,
shape
}: ParticlesProps) {
const particles = useRef(null) as any;

useFrame(() => {
particles.current.rotation.y += 0.001;
particles.current.rotation.x += 0.001;
});

const verticesAmount = amount;
const positionArray = new Float32Array(verticesAmount * 3);

if (shape === "cube") {
for (let i = 0; i < verticesAmount * 3; i++) {
positionArray[i] = (Math.random() - 0.5) * spread;
}
} else if (shape === "sphere") {
const radius = 1;
for (let i = 0; i < verticesAmount; i++) {
const i3 = i * 3;
const phi = Math.acos(-1 + (2 * i) / verticesAmount);
const theta = Math.sqrt(verticesAmount * Math.PI) * phi;
positionArray[i3] = radius * Math.cos(theta) * Math.sin(phi) * spread;
positionArray[i3 + 1] = radius * Math.sin(theta) * Math.sin(phi) * spread;
positionArray[i3 + 2] = radius * Math.cos(phi) * spread;
}
}

return (
<points ref={particles} onClick={onClick}>
<bufferGeometry>
<bufferAttribute
attach="attributes-position"
count={positionArray.length}
array={positionArray}
itemSize={3}

    />
  </bufferGeometry>
  <pointsMaterial
    args={[
      {
        color: color,
        size: size,
        sizeAttenuation: true,
        alphaTest: 0.1,
      },
    ]}
  />
</points>

);
}

slate perch
#

could try fixing the NaN values in your position array first

lean chasm
#

maybe a simple fix like an if statement that checks if the values are nan and then assign it a random int?🤔

lean chasm
#

okay so I fixed the NaN values. This is literally only a mac issue on my pc I don't even get a NaN issue and they work perfectly fine. very odd but everything is now working as normal

slate perch
#

can you console log the geometry and post it here? just the sizes are important I think
.attributes.position.count
.attrubutes.position.array.length
and any other attributes
.indices

#

also "not supported" warning seems.. suspicious

lean chasm
#

I mean it all works fine now but like I say you only get the NaN error and the Vertex buffer error on mac if you aren't already checking for NaN values. Windows works perfectly fine but macOS is just weird for no reason. probably because they dont use the same graphic encoding.