MeshWriter integration in Angular+Babylon project

Hi @TheLeftover, thank you for reply.

The problem is that MeshWriter cannot see my Babylon.js. I think the problem is in the scope or namespace.

In my Angular code I have Babylon.js as a npm package. This is from my package.json:

    "dependencies": {
    "@angular/animations": "^9.1.0",
    "@angular/common": "^9.1.0",
    "@angular/compiler": "^9.1.0",
    "@angular/core": "^9.1.0",
    "@angular/forms": "^9.1.0",
    "@angular/platform-browser": "^9.1.0",
    "@angular/platform-browser-dynamic": "^9.1.0",
    "@angular/router": "^9.1.0",

    "@babylonjs/core": "^4.1.0",
    "@babylonjs/gui": "^4.1.0",
    "@babylonjs/inspector": "^4.1.0",
    "@babylonjs/materials": "^4.1.0",
    "babylonjs": "^4.1.0",

    "hammerjs": "^2.0.8",
    "meshwriter": "^1.2.3",
    "node-sass": "^4.13.1",
    "pepjs": "^0.5.2",
    "replace-in-file": "^5.0.2",
    "rxjs": "^6.5.5",
    "tslib": "^1.11.1",
    "zone.js": "^0.10.3"
  },

MeshWriter is added as external script. This is from my angular.json:

"scripts": [ "node_modules/meshwriter/dist/meshwriter.js" ]

I import Babylon.js modules like this:

import { Engine } from '@babylonjs/core/Engines/engine';
import { Scene } from '@babylonjs/core/scene';
import { ArcRotateCamera, DirectionalLight, ShadowGenerator, IShadowLight, Tools, HighlightLayer, KeyboardEventTypes } from '@babylonjs/core';
import { Vector3, Color3, Color4 } from '@babylonjs/core/Maths/math';
import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder';
import { GridMaterial } from '@babylonjs/materials/grid/GridMaterial';

This may I can use them directly. For example:

    this.scene = new Scene(this.engine);
    this.scene.clearColor = new Color4(0, 0, 0, 0);
    this.highlightLayer = new HighlightLayer('', this.scene);

So I use “new Scene”, not “new BABYLON.Scene”, etc.

There is no BABYLON in my code.

I tried different approaches, like

import * as BABYLON from 'babylonjs';
or
declare const BABYLON: any;

but it doesn’t help.

I declare MeshWriter this way:

declare const MeshWriter: any;

then in my function I use it as:

So, MeshWriter is visible, but it cannot find BABYLON when it tries to create material.

Do you know how should I define/declare/import BABYLON to make it visible in MeshWriter?

Thank you,
ogo.