@babylonjs/lite-compat 1.30.0-preview → 1.31.0-preview
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.
- package/README.md +32 -31
- package/index.d.ts +450 -8
- package/index.js +807 -74
- package/index.js.map +1 -1
- package/{meshes-DJ46g22_.js → meshes-Fu955h5M.js} +155 -24
- package/meshes-Fu955h5M.js.map +1 -0
- package/navigation.d.ts +130 -2
- package/navigation.js +3 -10
- package/navigation.js.map +1 -1
- package/package.json +4 -4
- package/meshes-DJ46g22_.js.map +0 -1
|
@@ -550,6 +550,48 @@ var Color3 = class Color3 {
|
|
|
550
550
|
return new Color3(start.r + (end.r - start.r) * amount, start.g + (end.g - start.g) * amount, start.b + (end.b - start.b) * amount);
|
|
551
551
|
}
|
|
552
552
|
};
|
|
553
|
+
/**
|
|
554
|
+
* @internal A `Color3` whose `r`/`g`/`b` read and write **through** to a live Babylon Lite colour tuple, so
|
|
555
|
+
* inherited in-place methods (`copyFrom`, `set`, `scaleInPlace`, …) reach the Lite object — the colour
|
|
556
|
+
* counterpart of `LiteBackedVector3`. A tuple write cannot notify anyone by itself, so `onWrite` lets the
|
|
557
|
+
* owner publish the change.
|
|
558
|
+
*/
|
|
559
|
+
var LiteBackedColor3 = class extends Color3 {
|
|
560
|
+
constructor(tuple, onWrite) {
|
|
561
|
+
super(0, 0, 0);
|
|
562
|
+
[
|
|
563
|
+
"r",
|
|
564
|
+
"g",
|
|
565
|
+
"b"
|
|
566
|
+
].forEach((key, i) => {
|
|
567
|
+
Object.defineProperty(this, key, {
|
|
568
|
+
enumerable: true,
|
|
569
|
+
configurable: true,
|
|
570
|
+
get: () => tuple[i],
|
|
571
|
+
set: (value) => {
|
|
572
|
+
tuple[i] = value;
|
|
573
|
+
onWrite();
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
/** One stable proxy per Lite tuple, so `light.diffuse === light.diffuse` (Babylon.js identity parity).
|
|
580
|
+
* Created on first use: a module-level `new WeakMap()` would be an import-time side effect. */
|
|
581
|
+
var _liteColor3Proxies = null;
|
|
582
|
+
/**
|
|
583
|
+
* @internal Return the cached write-through `Color3` proxy over a Lite colour tuple (creating it on first
|
|
584
|
+
* use). `onWrite` runs after every component write.
|
|
585
|
+
*/
|
|
586
|
+
function liteBackedColor3(tuple, onWrite) {
|
|
587
|
+
const proxies = _liteColor3Proxies ??= /* @__PURE__ */ new WeakMap();
|
|
588
|
+
let proxy = proxies.get(tuple);
|
|
589
|
+
if (!proxy) {
|
|
590
|
+
proxy = new LiteBackedColor3(tuple, onWrite);
|
|
591
|
+
proxies.set(tuple, proxy);
|
|
592
|
+
}
|
|
593
|
+
return proxy;
|
|
594
|
+
}
|
|
553
595
|
var Color4 = class Color4 {
|
|
554
596
|
r;
|
|
555
597
|
g;
|
|
@@ -1459,6 +1501,30 @@ var Node = class {
|
|
|
1459
1501
|
getChildMeshes(directDescendantsOnly = false, predicate) {
|
|
1460
1502
|
return this.getDescendants(directDescendantsOnly, (node) => node._isMeshNode() && (!predicate || predicate(node)));
|
|
1461
1503
|
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Babylon.js `node.getHierarchyBoundingVectors(includeDescendants?, predicate?)`
|
|
1506
|
+
* — world-space bounds spanning this mesh and eligible descendant meshes.
|
|
1507
|
+
*/
|
|
1508
|
+
getHierarchyBoundingVectors(includeDescendants = true, predicate = null) {
|
|
1509
|
+
const min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1510
|
+
const max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1511
|
+
if (this._isMeshNode()) {
|
|
1512
|
+
const boundingBox = this.getBoundingInfo().boundingBox;
|
|
1513
|
+
min.copyFrom(boundingBox.minimumWorld);
|
|
1514
|
+
max.copyFrom(boundingBox.maximumWorld);
|
|
1515
|
+
}
|
|
1516
|
+
if (includeDescendants) for (const descendant of this.getDescendants()) {
|
|
1517
|
+
const descendantMesh = descendant;
|
|
1518
|
+
if (predicate && !predicate(descendantMesh) || !descendant._isMeshNode() || descendantMesh.getTotalVertices() === 0) continue;
|
|
1519
|
+
const boundingBox = descendantMesh.getBoundingInfo().boundingBox;
|
|
1520
|
+
min.minimizeInPlace(boundingBox.minimumWorld);
|
|
1521
|
+
max.maximizeInPlace(boundingBox.maximumWorld);
|
|
1522
|
+
}
|
|
1523
|
+
return {
|
|
1524
|
+
min,
|
|
1525
|
+
max
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1462
1528
|
isEnabled(checkAncestors = true) {
|
|
1463
1529
|
return this._enabled && (!checkAncestors || this._parentEnabled);
|
|
1464
1530
|
}
|
|
@@ -1513,6 +1579,10 @@ var Node = class {
|
|
|
1513
1579
|
/** Babylon.js `Material` — base class for all materials. */
|
|
1514
1580
|
var Material = class {
|
|
1515
1581
|
name;
|
|
1582
|
+
/** @internal Whether a compat `MaterialPluginBase` is attached. */
|
|
1583
|
+
_usesMaterialPlugins = false;
|
|
1584
|
+
/** Babylon.js plugin manager, created lazily by the first `MaterialPluginBase`. */
|
|
1585
|
+
pluginManager;
|
|
1516
1586
|
/** Common transparency mode flag (Babylon.js `Material.transparencyMode`). */
|
|
1517
1587
|
transparencyMode = null;
|
|
1518
1588
|
/** Back-face culling toggle (Babylon.js `Material.backFaceCulling`). */
|
|
@@ -1583,8 +1653,14 @@ var Material = class {
|
|
|
1583
1653
|
if (!this._scene) {
|
|
1584
1654
|
this._scene = scene;
|
|
1585
1655
|
scene._registerMaterial(this);
|
|
1656
|
+
if (this._usesMaterialPlugins) scene._requestMaterialPlugins(this._lite);
|
|
1586
1657
|
}
|
|
1587
1658
|
}
|
|
1659
|
+
/** @internal Rebuild plugin shader state after a Babylon.js plugin dirties its defines. */
|
|
1660
|
+
_markPluginDefinesDirty() {
|
|
1661
|
+
this._markDirty();
|
|
1662
|
+
this._scene?._requestMaterialPlugins(this._lite);
|
|
1663
|
+
}
|
|
1588
1664
|
/**
|
|
1589
1665
|
* @internal Reconcile this material into its scene when the scene is already
|
|
1590
1666
|
* live: finalize GPU-facing resources ({@link _ensureRenderable}) and rebuild
|
|
@@ -1639,25 +1715,66 @@ function copyLiteMaterialData(src, dst) {
|
|
|
1639
1715
|
d[key] = Array.isArray(value) ? value.slice() : value;
|
|
1640
1716
|
}
|
|
1641
1717
|
}
|
|
1718
|
+
/**
|
|
1719
|
+
* @internal Scene OWNERSHIP of a material, independent of GPU finalization. Babylon.js allows
|
|
1720
|
+
* `new StandardMaterial(name)` with no scene, so the material a mesh renders with adopts that mesh's scene
|
|
1721
|
+
* as soon as the two meet — whether or not the scene has started. A material rendered by a scene it never
|
|
1722
|
+
* adopted has no scene to rebuild in, and its later `_refreshInScene()` requests (a `disableLighting`
|
|
1723
|
+
* toggle, a texture that finished loading) silently do nothing.
|
|
1724
|
+
*/
|
|
1725
|
+
function adoptMaterialScene(material, scene) {
|
|
1726
|
+
material._adoptScene?.(scene);
|
|
1727
|
+
}
|
|
1728
|
+
/**
|
|
1729
|
+
* @internal Ownership plus GPU finalization (`_ensureRenderable`). Finalization needs the engine, so it stays
|
|
1730
|
+
* gated to the moments a mesh actually enters the running scene: the live branch of the `material` setter
|
|
1731
|
+
* and the deferred registration at engine start.
|
|
1732
|
+
*/
|
|
1733
|
+
function attachMaterialToScene(material, scene) {
|
|
1734
|
+
adoptMaterialScene(material, scene);
|
|
1735
|
+
material._ensureRenderable(scene.getEngine()._lite);
|
|
1736
|
+
}
|
|
1642
1737
|
var StandardMaterial = class StandardMaterial extends PushMaterial {
|
|
1643
1738
|
/** @internal Underlying Babylon Lite standard-material props. */
|
|
1644
1739
|
_lite;
|
|
1740
|
+
/** Diffuse colour as the app set it. Kept apart from `_lite.diffuseColor`, which is forced to white
|
|
1741
|
+
* while the material is unlit (see `_syncDiffuse`). */
|
|
1742
|
+
_diffuse = null;
|
|
1645
1743
|
constructor(name, scene) {
|
|
1646
1744
|
super(name, scene);
|
|
1647
1745
|
this._lite = createStandardMaterial();
|
|
1648
1746
|
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Babylon.js shades an unlit StandardMaterial as `emissive + ambient`: the diffuse colour only scales
|
|
1749
|
+
* the accumulated light, and there is none. Lite's unlit path is `emissive × diffuse`, so the usual
|
|
1750
|
+
* "unlit colour" setup (black diffuse, colour in emissive) rendered black. Hand Lite a neutral white
|
|
1751
|
+
* diffuse while lighting is disabled and the app's own colour otherwise.
|
|
1752
|
+
*/
|
|
1753
|
+
_syncDiffuse() {
|
|
1754
|
+
const diffuse = this._diffuse ??= [...this._lite.diffuseColor];
|
|
1755
|
+
this._lite.diffuseColor = this._lite.disableLighting ? [
|
|
1756
|
+
1,
|
|
1757
|
+
1,
|
|
1758
|
+
1
|
|
1759
|
+
] : [
|
|
1760
|
+
diffuse[0],
|
|
1761
|
+
diffuse[1],
|
|
1762
|
+
diffuse[2]
|
|
1763
|
+
];
|
|
1764
|
+
}
|
|
1649
1765
|
getClassName() {
|
|
1650
1766
|
return "StandardMaterial";
|
|
1651
1767
|
}
|
|
1652
1768
|
get diffuseColor() {
|
|
1653
|
-
return readColor3(this._lite.diffuseColor);
|
|
1769
|
+
return readColor3(this._diffuse ?? this._lite.diffuseColor);
|
|
1654
1770
|
}
|
|
1655
1771
|
set diffuseColor(value) {
|
|
1656
|
-
this.
|
|
1772
|
+
this._diffuse = [
|
|
1657
1773
|
value.r,
|
|
1658
1774
|
value.g,
|
|
1659
1775
|
value.b
|
|
1660
1776
|
];
|
|
1777
|
+
this._syncDiffuse();
|
|
1661
1778
|
this._markDirty();
|
|
1662
1779
|
}
|
|
1663
1780
|
get specularColor() {
|
|
@@ -1697,8 +1814,11 @@ var StandardMaterial = class StandardMaterial extends PushMaterial {
|
|
|
1697
1814
|
return this._lite.disableLighting;
|
|
1698
1815
|
}
|
|
1699
1816
|
set disableLighting(value) {
|
|
1817
|
+
const changed = this._lite.disableLighting !== value;
|
|
1700
1818
|
this._lite.disableLighting = value;
|
|
1819
|
+
this._syncDiffuse();
|
|
1701
1820
|
this._markDirty();
|
|
1821
|
+
if (changed) this._refreshInScene();
|
|
1702
1822
|
}
|
|
1703
1823
|
_applyBackFaceCulling(value) {
|
|
1704
1824
|
this._lite.backFaceCulling = value;
|
|
@@ -1793,6 +1913,11 @@ var StandardMaterial = class StandardMaterial extends PushMaterial {
|
|
|
1793
1913
|
clone(name) {
|
|
1794
1914
|
const cloned = new StandardMaterial(name, this._scene);
|
|
1795
1915
|
this._cloneBaseInto(cloned);
|
|
1916
|
+
cloned._diffuse = this._diffuse && [
|
|
1917
|
+
this._diffuse[0],
|
|
1918
|
+
this._diffuse[1],
|
|
1919
|
+
this._diffuse[2]
|
|
1920
|
+
];
|
|
1796
1921
|
cloned.useAlphaFromDiffuseTexture = this.useAlphaFromDiffuseTexture;
|
|
1797
1922
|
cloned._diffuseTexture = this._diffuseTexture;
|
|
1798
1923
|
cloned._bumpTexture = this._bumpTexture;
|
|
@@ -2163,22 +2288,10 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2163
2288
|
else lite._gammaAlbedo = false;
|
|
2164
2289
|
}
|
|
2165
2290
|
if (!lite.baseColorTexture) {
|
|
2166
|
-
|
|
2167
|
-
lite.
|
|
2168
|
-
lite.baseColorFactor = [
|
|
2169
|
-
1,
|
|
2170
|
-
1,
|
|
2171
|
-
1,
|
|
2172
|
-
1
|
|
2173
|
-
];
|
|
2174
|
-
}
|
|
2175
|
-
if (!lite.ormTexture) {
|
|
2176
|
-
const rough = lite.roughnessFactor ?? 1;
|
|
2177
|
-
const metal = lite.metallicFactor ?? 1;
|
|
2178
|
-
lite.ormTexture = createSolidTexture2D(engine, 1, rough, metal);
|
|
2179
|
-
lite.roughnessFactor = 1;
|
|
2180
|
-
lite.metallicFactor = 1;
|
|
2291
|
+
lite.baseColorTexture = createSolidTexture2D(engine, 1, 1, 1, 1);
|
|
2292
|
+
lite.baseColorFactor = [...this._albedoFactor];
|
|
2181
2293
|
}
|
|
2294
|
+
if (!lite.ormTexture) lite.ormTexture = createSolidTexture2D(engine, 1, 1, 1);
|
|
2182
2295
|
}
|
|
2183
2296
|
/**
|
|
2184
2297
|
* Babylon.js `PBRMaterial.clone(name)`. Copies the albedo/metallic/roughness/
|
|
@@ -2601,6 +2714,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2601
2714
|
/** @internal Underlying Babylon Lite mesh. */
|
|
2602
2715
|
_lite;
|
|
2603
2716
|
_material = null;
|
|
2717
|
+
_meshBlendingTag = 0;
|
|
2604
2718
|
_visible = true;
|
|
2605
2719
|
constructor(name, lite, scene) {
|
|
2606
2720
|
super(name, scene, lite);
|
|
@@ -2625,9 +2739,9 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2625
2739
|
this._material = value;
|
|
2626
2740
|
const scene = this._scene;
|
|
2627
2741
|
const renderMaterial = value ?? scene?.defaultMaterial;
|
|
2628
|
-
if (renderMaterial && scene
|
|
2629
|
-
|
|
2630
|
-
renderMaterial
|
|
2742
|
+
if (renderMaterial && scene) {
|
|
2743
|
+
if (scene._hasStarted) attachMaterialToScene(renderMaterial, scene);
|
|
2744
|
+
else adoptMaterialScene(renderMaterial, scene);
|
|
2631
2745
|
}
|
|
2632
2746
|
if (renderMaterial?._lite) this._lite.material = renderMaterial._lite;
|
|
2633
2747
|
if (value && "_bindMesh" in value) value._bindMesh(this._lite, () => this._material === value);
|
|
@@ -2651,6 +2765,14 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2651
2765
|
set receiveShadows(value) {
|
|
2652
2766
|
this._lite.receiveShadows = value;
|
|
2653
2767
|
}
|
|
2768
|
+
get meshBlendingTag() {
|
|
2769
|
+
return this._meshBlendingTag ?? 0;
|
|
2770
|
+
}
|
|
2771
|
+
set meshBlendingTag(value) {
|
|
2772
|
+
if (!Number.isInteger(value) || value < 0 || value > 255 || value !== 0 && (value & 63) === 0) throw new RangeError("Mesh-blending tag must be 0 or contain a group ID between 1 and 63.");
|
|
2773
|
+
this._meshBlendingTag = value;
|
|
2774
|
+
this._lite.meshBlendingTag = value;
|
|
2775
|
+
}
|
|
2654
2776
|
_onEffectiveEnabledStateChanged(enabled) {
|
|
2655
2777
|
this._syncVisibility(enabled);
|
|
2656
2778
|
}
|
|
@@ -3036,6 +3158,7 @@ var Mesh = class Mesh extends AbstractMesh {
|
|
|
3036
3158
|
if (wrapper instanceof Mesh && source instanceof Mesh) {
|
|
3037
3159
|
wrapper.material = source.material;
|
|
3038
3160
|
wrapper.isVisible = source.isVisible;
|
|
3161
|
+
wrapper.meshBlendingTag = source.meshBlendingTag;
|
|
3039
3162
|
}
|
|
3040
3163
|
}
|
|
3041
3164
|
if (!skipChildren) {
|
|
@@ -3308,10 +3431,18 @@ function engineOf(scene) {
|
|
|
3308
3431
|
* (via `scene._deferAdd`) to let those assignments settle.
|
|
3309
3432
|
*/
|
|
3310
3433
|
function addPrimitive(mesh, scene, afterAdd) {
|
|
3434
|
+
return registerMeshAtStart(mesh, scene, afterAdd);
|
|
3435
|
+
}
|
|
3436
|
+
/**
|
|
3437
|
+
* @internal The deferred registration shared by every compat path that builds a mesh before engine start
|
|
3438
|
+
* (primitives, legacy CSG results, the navigation debug mesh): at startup, finalize the mesh's EFFECTIVE
|
|
3439
|
+
* material — its own, or `scene.defaultMaterial` as it is by then — rebind its Lite handle and add the mesh.
|
|
3440
|
+
*/
|
|
3441
|
+
function registerMeshAtStart(mesh, scene, afterAdd) {
|
|
3311
3442
|
scene._deferAdd(() => {
|
|
3312
3443
|
if (mesh.isDisposed()) return;
|
|
3313
|
-
const mat = mesh.material;
|
|
3314
|
-
mat
|
|
3444
|
+
const mat = mesh.material ?? scene.defaultMaterial;
|
|
3445
|
+
if (mat) attachMaterialToScene(mat, scene);
|
|
3315
3446
|
if (mat?._lite) mesh._lite.material = mat._lite;
|
|
3316
3447
|
addToScene(scene._lite, mesh._lite);
|
|
3317
3448
|
afterAdd?.();
|
|
@@ -3506,6 +3637,6 @@ function CreateTiledPlane(name, options, scene) {
|
|
|
3506
3637
|
return MeshBuilder.CreateTiledPlane(name, options, scene);
|
|
3507
3638
|
}
|
|
3508
3639
|
//#endregion
|
|
3509
|
-
export {
|
|
3640
|
+
export { PBRSpecularGlossinessMaterial as A, transformCoordinates as B, Material as C, PBRMaterial as D, PBRIridescenceConfiguration as E, Observable as F, liteBackedColor3 as G, Quaternion as H, BoundingBox as I, Vector4 as J, Vector2 as K, BoundingInfo as L, StandardMaterial as M, attachMaterialToScene as N, PBRMetallicRoughnessMaterial as O, Node as P, BoundingSphere as R, registerMeshAtStart as S, PBRClearCoatConfiguration as T, Color3 as U, transformNormal as V, Color4 as W, LiteCompatError as X, liteBackedVector3 as Y, unsupported as Z, Mesh as _, CreateDisc as a, VertexBuffer as b, CreateLines as c, CreateTiledBox as d, CreateTiledPlane as f, LinesMesh as g, InstancedMesh as h, CreateDashedLines as i, PushMaterial as j, PBRSheenConfiguration as k, CreatePlane as l, GroundMesh as m, CreateBox as n, CreateGround as o, CreateTorus as p, Vector3 as q, CreateCylinder as r, CreateLineSystem as s, AbstractMesh as t, CreateSphere as u, MeshBuilder as v, PBRAnisotropicConfiguration as w, VertexData as x, TransformNode as y, Matrix as z };
|
|
3510
3641
|
|
|
3511
|
-
//# sourceMappingURL=meshes-
|
|
3642
|
+
//# sourceMappingURL=meshes-Fu955h5M.js.map
|