Error when trying to load a GLB file

I’m trying to load a react native glb file, with JavaScript.
but i am getting the following problem

Error: Protocol version mismatch: 2 (Native) !== 6 (JS)
NativeEngine@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.apptalk&modulesOnly=false&runModule=true:257550:24
construct@[native code]

my code:

useEffect(() => {

if (engine) {

 

  const scene = new Scene(engine);

  const camera = new ArcRotateCamera(

    'camera',

    -Math.PI / 2,

    Math.PI / 2,

    5,

    Vector3.Zero(),

    scene,

  );

  setCamera(scene.activeCamera);

  scene.createDefaultLight(true);

  // scene.addParticleSystem();

  const rootNode = new TransformNode('Root Container', scene);

  setRootNode(rootNode);

  const transformContainer = new TransformNode(

    'Transform Container',

    scene,

  );

  transformContainer.parent = rootNode;

  transformContainer.scaling.scaleInPlace(0.2);

  transformContainer.position.y -= 0.2;

  scene.beforeRender = () => {

    transformContainer.rotate(

      Vector3.Up(),

      0.005 * scene.getAnimationRatio(),

    );

  };
  SceneLoader.ImportMesh(
    null,
    'https://models.babylonjs.com/',
    'seagulf.glb',
    scene,
    (newMeshes, particleSystems, skeletons, animationGroups) => {
      const hero = newMeshes[0];
      // Scale the model down
      hero.scaling.scaleInPlace(0.1);
      // Lock camera on the character
      camera.target = hero;
      // Get the Samba animation Group
      const sambaAnim = scene.getAnimationGroupByName('Samba');
      // Play the Samba animation
      sambaAnim.start(true, 1.0, sambaAnim.from, sambaAnim.to, false);
    },
  );
}

}, [engine]);

I noticed that in the if inside the useEffect he could not enter

version:
@babylonjs/core”: “^5.0.0-alpha.50”,
@babylonjs/loaders”: “^5.0.0-alpha.50”,
@babylonjs/react-native”: “^0.4.0-alpha.37”
“react”: “17.0.1”,
“react-native”: “0.64.1”,

Hello! First of all, please be sure to post your questions in English :slight_smile: I’ve translated the title for you, but not everyone is capable of understanding Portuguese. I don’t see anything wrong with your code at a glance, and the error seems to point to a configuration issue. @srzerbetto can you take a look at this?

Hello @Lucas_de_Andrade_de , how are you doing?

The issue with the protocol version happens when you have a version of @babylonjs/core that does not match the one expected by @babylonjs/react-native. It seems from your project packages that you are using a really old version @babylonjs/react-native (that has protocol version 2) and a newer version of @babylonjs/core (that has protocol version 6). To fix that I suggest that you update you @babylonjs/react-native to the latest version.

Also, as a side note, from version 1.0.0 and above the @babylonjs/react-native also requires the platform specific package @babylonjs/react-native-iosandroid-0-64 for ios and android and @babylonjs/react-native-windows-0-64 for windows build.

1 Like

Hello just checking in, was your question answered? @Lucas_de_Andrade_de