@babylonjs/lite-compat 1.39.2 → 1.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -647,6 +647,14 @@ var Color4 = class Color4 {
647
647
  this.a
648
648
  ];
649
649
  }
650
+ toHexString(returnAsColor3 = false) {
651
+ const intR = Math.round(Math.min(Math.max(this.r, 0), 1) * 255);
652
+ const intG = Math.round(Math.min(Math.max(this.g, 0), 1) * 255);
653
+ const intB = Math.round(Math.min(Math.max(this.b, 0), 1) * 255);
654
+ const rgb = "#" + toHex(intR) + toHex(intG) + toHex(intB);
655
+ if (returnAsColor3) return rgb;
656
+ return rgb + toHex(Math.round(Math.min(Math.max(this.a, 0), 1) * 255));
657
+ }
650
658
  static FromArray(array, offset = 0) {
651
659
  return new Color4(array[offset] ?? 0, array[offset + 1] ?? 0, array[offset + 2] ?? 0, array[offset + 3] ?? 1);
652
660
  }
@@ -2147,6 +2155,9 @@ var StandardMaterial = class StandardMaterial extends PushMaterial {
2147
2155
  cloned._diffuseTexture = this._diffuseTexture;
2148
2156
  cloned._bumpTexture = this._bumpTexture;
2149
2157
  cloned._emissiveTexture = this._emissiveTexture;
2158
+ cloned._watchTexture(cloned._diffuseTexture);
2159
+ cloned._watchTexture(cloned._bumpTexture);
2160
+ cloned._watchTexture(cloned._emissiveTexture);
2150
2161
  return cloned;
2151
2162
  }
2152
2163
  };
@@ -2194,9 +2205,11 @@ var PBRClearCoatConfiguration = class {
2194
2205
  var PBRSheenConfiguration = class {
2195
2206
  _props;
2196
2207
  _markDirty;
2197
- constructor(_props, _markDirty) {
2208
+ _watchTexture;
2209
+ constructor(_props, _markDirty, _watchTexture) {
2198
2210
  this._props = _props;
2199
2211
  this._markDirty = _markDirty;
2212
+ this._watchTexture = _watchTexture;
2200
2213
  }
2201
2214
  get isEnabled() {
2202
2215
  return this._props.isEnabled;
@@ -2240,16 +2253,29 @@ var PBRSheenConfiguration = class {
2240
2253
  return this._texture;
2241
2254
  }
2242
2255
  set texture(value) {
2256
+ this._textureAssigned = true;
2243
2257
  this._texture = value;
2244
2258
  if (value?._lite) this._props.texture = value._lite;
2245
2259
  else delete this._props.texture;
2260
+ this._watchTexture(value);
2246
2261
  this._markDirty();
2247
2262
  }
2248
2263
  _texture = null;
2264
+ _textureAssigned = false;
2249
2265
  /** Enumerate the sheen texture slot for `Material.getActiveTextures`. */
2250
2266
  getActiveTextures() {
2251
2267
  return this._texture ? [this._texture] : [];
2252
2268
  }
2269
+ /** @internal Rebind a replaced or newly-ready texture handle. */
2270
+ _ensureRenderable() {
2271
+ if (!this._textureAssigned) return;
2272
+ if (this._texture?._lite) this._props.texture = this._texture._lite;
2273
+ else delete this._props.texture;
2274
+ }
2275
+ /** @internal Copy an explicit facade texture assignment without disturbing loader-owned state. */
2276
+ _copyTextureTo(target) {
2277
+ if (this._textureAssigned) target.texture = this._texture;
2278
+ }
2253
2279
  };
2254
2280
  /** Babylon.js `PBRAnisotropicConfiguration` — the `pbr.anisotropy` sub-object over Lite `AnisotropyProps`. */
2255
2281
  var PBRAnisotropicConfiguration = class {
@@ -2507,7 +2533,7 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
2507
2533
  get sheen() {
2508
2534
  if (!this._sheen) {
2509
2535
  setPbrSheen(this._lite, this._lite._sheen ?? { isEnabled: false });
2510
- this._sheen = new PBRSheenConfiguration(this._lite._sheen, () => this._markDirty());
2536
+ this._sheen = new PBRSheenConfiguration(this._lite._sheen, () => this._markDirty(), (texture) => this._watchTexture(texture));
2511
2537
  }
2512
2538
  return this._sheen;
2513
2539
  }
@@ -2566,6 +2592,7 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
2566
2592
  lite.bentNormalTexture = bent._lite;
2567
2593
  lite.bentNormalStrength = bent.level ?? 1;
2568
2594
  }
2595
+ this._sheen?._ensureRenderable();
2569
2596
  if (!lite.baseColorTexture) {
2570
2597
  lite.baseColorTexture = createSolidTexture2D(engine, 1, 1, 1, 1);
2571
2598
  lite.baseColorFactor = [...this._albedoFactor];
@@ -2601,7 +2628,10 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
2601
2628
  const dst = target._lite;
2602
2629
  if (src._emissiveColor) setPbrEmissive(dst, [...src._emissiveColor]);
2603
2630
  if (src._clearCoat) setPbrClearCoat(dst, { ...src._clearCoat });
2604
- if (src._sheen) setPbrSheen(dst, { ...src._sheen });
2631
+ if (src._sheen) {
2632
+ setPbrSheen(dst, { ...src._sheen });
2633
+ if (this._sheen) this._sheen._copyTextureTo(target.sheen);
2634
+ }
2605
2635
  if (src._anisotropy) setPbrAnisotropy(dst, { ...src._anisotropy });
2606
2636
  if (src._iridescence) setPbrIridescence(dst, { ...src._iridescence });
2607
2637
  if (src.bentNormalTexture) {
@@ -4477,4 +4507,4 @@ var PolygonBuilder = {
4477
4507
  function RegisterPolygonBuilder() {}
4478
4508
  export { Vector2 as $, Material as A, attachMaterialToScene as B, RegisterPolygonBuilder as C, registerMeshAtStart as D, VertexData as E, PBRMetallicRoughnessMaterial as F, BoundingSphere as G, Observable as H, PBRSheenConfiguration as I, transformNormal as J, Matrix as K, PBRSpecularGlossinessMaterial as L, PBRClearCoatConfiguration as M, PBRIridescenceConfiguration as N, MorphTarget as O, PBRMaterial as P, liteBackedColor3 as Q, PushMaterial as R, PolygonBuilder as S, VertexBuffer as T, BoundingBox as U, Node as V, BoundingInfo as W, Color3 as X, Quaternion as Y, Color4 as Z, GroundMesh as _, CreateDisc as a, Mesh as b, CreateLines as c, CreatePolygonVertexData as d, Vector3 as et, CreateSphere as f, ExtrudePolygon as g, CreateTorus as h, CreateDashedLines as i, unsupported as it, PBRAnisotropicConfiguration as j, MorphTargetManager as k, CreatePlane as l, CreateTiledPlane as m, CreateBox as n, liteBackedVector3 as nt, CreateGround as o, CreateTiledBox as p, transformCoordinates as q, CreateCylinder as r, LiteCompatError as rt, CreateLineSystem as s, AbstractMesh as t, Vector4 as tt, CreatePolygon as u, InstancedMesh as v, TransformNode as w, MeshBuilder as x, LinesMesh as y, StandardMaterial as z };
4479
4509
 
4480
- //# sourceMappingURL=meshes-DWnDIh1l.js.map
4510
+ //# sourceMappingURL=meshes-CdVN59oi.js.map