Error + solution in compiling the template project specified on the babylonjs website

I am following the instructions specified here Babylon.js ES6 support with Tree Shaking | Babylon.js Documentation

After numerous failed attempts to get a babylon project working from an empty directory, I decided to relent and use their template project, linked from GitHub - RaananW/babylonjs-webpack-es6: Babylon.js basic scene with typescript, webpack, es6 modules, editorconfig, eslint, hot loading and more. Will even make coffee if you ask nicely.

I followed the instructions to the best of my knowledge.
1: clone the repo locally
2: npm install
3: npm start

The error I am getting is:

TS2339: Property 'renderCount' does not exist on type '{ name: string; url: string; waitForNetworkIdle?: undefined; } | { name: string; url: string; waitForNetworkIdle: boolean; }'.
  Property 'renderCount' does not exist on type '{ name: string; url: string; waitForNetworkIdle?: undefined; }'.

This occurs in the file validation.spec.ts. When I look in that file, there’s:

const scenes = [
  {
    name: 'Default',
    url: '/?scene=defaultWithTexture',
  },
  {
    name: 'Fresnel Shader',
    url: '/?scene=fresnelShader',
  },
  {
    name: 'Load model and env',
    url: '/?scene=loadModelAndEnv',
  },
  {
    name: 'Navigation mesh recast',
    url: '/?scene=navigationMeshRecast',
    waitForNetworkIdle: true,
  },
  // {
  //   name: 'Physics (ammo)',
  //   url: '/?scene=physicsWithAmmo',
  //   renderCount: 5,
  // },
]

then, later on, there’s a conditional if (scene.renderCount)...
so the initial array has no typing to it, when it should be something like

const scenes: { name: string, url: string, waitForNetworkIdle?: boolean, renderCount?: number }[] = { ... };

if I put that line in the code, changing nothing else, then the scene loads successfully. Alternatively, you can just not type the array at all and uncomment that last entry.

cc @RaananW.

You can add renderCount: 0 in each object of the scene to make it work (or do (scene as any).renderCount instead of scene.renderCount in the test condition). I guess it’s the current version of Typescript which is less forgiving than when Raanan created the project.

ha! this file should not be a part of the compilation process. I know what happened, will take care of that.

Thanks :slight_smile:

3 Likes

a quick fix was pushed, I will solve it more long-term very soon.

1 Like