Decals ES6 tree shaking

Using ES6 tree-shaking and decalMap looks null.

How do I enable decalmaps in certain materials? Usage looks wrong

 1 of 3 unhandled errors

Unhandled Runtime Error
TypeError: Cannot set property decalMap of [object Object] which has only a getter

decals.ts (49:23) @ eval

  48 | RegisterMaterialPlugin("DecalMap", (material) => {
> 49 |   material.decalMap = new DecalMapConfiguration(material);
  50 |   material.decalMap.isEnabled = true;
  51 |   return material.decalMap;
  52 | });

What do your imports look like?

looks normal:

I do this on model load to make it work, but that replaces the existing material, and if i dont, i get a decalMap null

import type { Engine, Scene, Texture } from "@babylonjs/core";
import { AssetsManager, MeshBuilder, PointerEventTypes,  PositionGizmo, RenderTargetTexture, StandardMaterial, UtilityLayerRenderer , Vector3 } from '@babylonjs/core';

mesh.material = new PBRMaterial(, this.scene);
mesh.material.roughness = 0.5;
if (mesh.getTotalVertices() > 0 && mesh.material && mesh.material.decalMap) {
   mesh.decalMap = new MeshUVSpaceRenderer(mesh, this.scene, {height: 4096, width: 4096});
    mesh.material.decalMap.smoothAlpha = true;
   mesh.material.decalMap.isEnabled = true;

it works if i add a PBRMaterial, otherwise does not work with the mesh’s original material.

Also related question, is it possible to rotate decal maps? one that has been placed which could be moved around and transformed. I was thinking of moving the projector around and then clearing the previous mesh UV Texture or something?

Following this example:

You can rotate a decal only at the time you render it. It’s the last parameter of mesh.decalMap.renderTexture(...). Once in the texture, you can’t do anything, except clearing the texture and rendering new decals.

Regarding your error, is it a runtime error or an error in your editor? You say decalMap is null, but the error is about having no setter?

I think you saw the section about ES6 in the decal map doc?