Skip to main content
Skip table of contents

Typescript

As part of the Web SDK npm package, we also ship appropriate typescript types. Sometimes we use some of their types in the Pictofit SDK (e.g. setting a color for a size visualisation overlay takes a BABYLON.Color3). To ensure the types are found even tho you are not importing them directly in your code, you will need to install the babylonjs package (which also contains the types) and add it to the types array in your tsconfig.json:

JSON
{
  "compilerOptions": {
    ...
    "types": [
      ...
      "babylonjs",
    ]
  },
}

Using Typescript >=4.3.2

Since version v18.0.0 the SDK uses BabylonJS v5. This workaround is only needed for earlier versions!

CODE
Error: node_modules/babylonjs/babylon.module.d.ts:159173:29 - error TS2304: Cannot find name 'WebGLObject'.

Since Typescript v4.3.2 certain types / interfaces that were previously part of the DOM types lib (lib.dom.d.ts), were removed but are still used in BabylonJS types.

To circumvent this issue, we need to mock these types ourselves. We suggest adding a file like babylonjs-ts4.3.2-typefix.d.ts to your included typescript files and add the following in there:

TYPESCRIPT
interface WebGLObject {}
interface NavigatorUserMediaSuccessCallback {}
interface NavigatorUserMediaErrorCallback {}
interface OffscreenCanvasRenderingContext2D {}
interface OffscreenCanvas {}
interface MouseWheelEvent {}
interface MSGesture {}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.