@babylonjs/core/Materials in build but it wasnt import in my TypeScript app

In my app I use this imports:

import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
import { Engine } from '@babylonjs/core/Engines';
import { SceneLoader } from '@babylonjs/core/Loading/sceneLoader';
import { Color4, Vector3 } from '@babylonjs/core/Maths/math';
import { Scene } from '@babylonjs/core/scene';
import '@babylonjs/loaders/glTF/2.0/glTFLoader';

package.json:

{
  "dependencies": {
    "@babylonjs/core": "^4.0.3",
    "@babylonjs/loaders": "^4.0.3",
    "core-js": "^2.6.10",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@types/node": "~8.10.59",
    "ts-node": "~7.0.1",
    "tslint": "~5.18.0",
    "typescript": "~3.5.3"
  }
}

I look at code coverage tool in Google Chrome DevTools:

As I know this class or function is part of the @babylonjs/core/Materials.
And I think it should not be in build if I dont use it directly. Is it correct?

After simple research I found what function body inclunde when I use: import '@babylonjs/loaders/glTF/2.0/glTFLoader';
If remove this import then function body is empty but still here:
image

Sorry if it is not a bug.

You cannot avoid having materials as the scene builds the default material.

You are not doing any rendering? If you are doing any rendering then you are doing it through materials :wink:

Nope, not a bug - https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/material.ts#L753

The Material class has this function, unimplemented. classes extending the material class implement it themselves

Not quite. Currently I have a task to create scene with black object on transparent background. Something like wires. It fully black and not require any materials.
I think possible found other technical visulization tasks where we not need materals.

But thank you for answer. I understood the general idea.

Thanks! Now it clearly.

1 Like

@RaananW I not fully realize. Why function arguments still here in empty function? Are they needed for function overriding?

In that case, due to “historical” development decisions - we didn’t want to make the material class abstract after already using it as a non-abstract JS class.