Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[.WebGL-0x1ccc22f46200] GL_INVALID_OPERATION: Vertex shader input type does not match the type of the bound vertex attribute. #93

Closed
SergeiK-27 opened this issue Jan 13, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@SergeiK-27
Copy link

SergeiK-27 commented Jan 13, 2025

If instances are added during or after mounting of gltf model in the scene, I receive this error, and instances aren't added

image

I'm using react-three-fiber with the following code

import React, { useRef } from 'react';
import {extend, useFrame, useLoader} from '@react-three/fiber';
import { InstancedMesh2 } from '@three.ez/instanced-mesh';
import {GLTFLoader} from "three-stdlib";
import {BoxGeometry, MeshStandardMaterial} from "three";

// add InstancedMesh2 to the jsx catalog i.e use it as a jsx component
extend({ InstancedMesh2 });

export const Scene3D = () => {
  const material = new MeshStandardMaterial();
  const geometry = new BoxGeometry(1,1,1);
  
  const ref = useRef();

  useFrame(() => {
    // early return
    if (!ref.current || ref.current.instancesCount >= 100000) return;

    // add 100 instances every frame
    ref.current.addInstances(100, (obj) => {
      obj.position
        .setX(Math.random() * 10000 - 5000)
        .setY(Math.random() * 10000 - 5000)
        .setZ(Math.random() * 10000 - 5000);
      obj.quaternion.random();
    });
  });

  const gltf = useLoader(GLTFLoader, `/models/landscape.glb`);

  return (
    <>
      <instancedMesh2 ref={ref} args={[geometry, material]} />

      <primitive object={gltf.scene}/> // If removed, everything works correctly
      
    </>
  );
};

Any help would be appreciated

@agargaro
Copy link
Owner

Hi, are you using latest package version (0.3.0-alpha.8)?

@SergeiK-27
Copy link
Author

Hi, I was using alpha 7. Just updated, but the issue is still present on alpha 8

@agargaro
Copy link
Owner

Can you please provide a minimal example on stacbklitz or codesandbox so I can debug it?

@agargaro
Copy link
Owner

agargaro commented Jan 13, 2025

I'm not familiar with r3f, but in this example with a different glb, it's working.
https://stackblitz.com/edit/vitejs-vite-ran5phmv?file=src%2FApp.tsx,src%2FInstancedMesh2.tsx

Can you try this example with your glb? Can you share it if it doesnt wokr?

@SergeiK-27
Copy link
Author

I created a fork of this example, do you have a discord profile so I can send you a link to it? I'm not allowed to share this glb publically

@agargaro
Copy link
Owner

Yes, we have a discord sever:

https://discord.gg/MVTwrdX3JM

@agargaro
Copy link
Owner

agargaro commented Jan 13, 2025

Fixed passing renderer as constructor parameter.

const iMesh = new InstancedMesh2(geo, material, { renderer });

The problem occurs when using a MeshPhysicalMaterial, setting transmission.

@agargaro agargaro added the bug Something isn't working label Jan 13, 2025
@agargaro agargaro pinned this issue Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants