@babylonjs/lite-compat 1.39.0-preview → 1.39.2
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/CHANGELOG.md +1739 -0
- package/README.md +3 -3
- package/index.d.ts +85 -12
- package/index.js +187 -23
- package/index.js.map +1 -1
- package/{meshes-C-PkzbPM.js → meshes-DWnDIh1l.js} +126 -20
- package/meshes-DWnDIh1l.js.map +1 -0
- package/navigation.d.ts +20 -11
- package/navigation.js +1 -1
- package/package.json +8 -5
- package/meshes-C-PkzbPM.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addToScene, adoptMeshMorphTargets, cloneTransformNode, computeAabb, createBox, createCylinder, createDashedLines, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createLineMaterial, createLineSystem, createMeshFromData, createMorphTargets, createPbrMaterial, createPlane, createPolyhedron, createQuatFromRotationMat4, createRibbon, createSolidTexture2D, createSphere, createStandardMaterial, createTorus, createTorusKnot, createTransformNode, createTube, getMaterialFamily, getMeshOpacity, markMaterialUboDirty, maximizeMat4InPlace, normalizeVec2ToRef, projectPointToViewportToRef, rebuildMaterial, releaseMorphTargets, removeFromScene, resizeMeshGeometry, retainMorphTargets, scaleBoundsFromCenterToRef, setAccessibilityTag, setLineMaterialColor, setMat4Translation, setMeshOpacity, setMeshVisible, setMorphTargetWeight, setMorphTargetWeights, setParent, setPbrAnisotropy, setPbrClearCoat, setPbrEmissive, setPbrGammaAlbedo, setPbrIridescence, setPbrSheen, setStandardBumpTexture, setStandardEmissiveTexture, setThinInstanceColors, setThinInstances, shareMeshMorphTargets, updateDashedLines, updateLineSystem, updateMeshGeometry, updateMeshUvs, writeMat4FromLookDirectionLHIntoBuffer, writeMat4FromLookDirectionRHIntoBuffer, writeMat4FromQuatIntoBuffer, writeQuatFromRotationMat4IntoRef } from "@babylonjs/lite";
|
|
1
|
+
import { addToScene, adoptMeshMorphTargets, cloneTransformNode, computeAabb, createBox, createCylinder, createDashedLines, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createLineMaterial, createLineSystem, createMeshFromData, createMorphTargets, createPbrMaterial, createPlane, createPolyhedron, createQuatFromRotationMat4, createRibbon, createSolidTexture2D, createSphere, createStandardMaterial, createTorus, createTorusKnot, createTransformNode, createTube, enableBentNormals, getMaterialFamily, getMeshOpacity, markMaterialUboDirty, maximizeMat4InPlace, normalizeVec2ToRef, projectPointToViewportToRef, rebuildMaterial, releaseMorphTargets, removeFromScene, resizeMeshGeometry, retainMorphTargets, scaleBoundsFromCenterToRef, setAccessibilityTag, setLineMaterialColor, setMat4Translation, setMeshOpacity, setMeshVisible, setMorphTargetWeight, setMorphTargetWeights, setParent, setPbrAnisotropy, setPbrClearCoat, setPbrEmissive, setPbrGammaAlbedo, setPbrIridescence, setPbrSheen, setStandardBumpTexture, setStandardEmissiveTexture, setThinInstanceColors, setThinInstances, shareMeshMorphTargets, updateDashedLines, updateLineSystem, updateMeshGeometry, updateMeshUvs, writeMat4FromLookDirectionLHIntoBuffer, writeMat4FromLookDirectionRHIntoBuffer, writeMat4FromQuatIntoBuffer, writeQuatFromRotationMat4IntoRef } from "@babylonjs/lite";
|
|
2
2
|
// src/error.ts
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown when Babylon.js code reaches an API surface that the Babylon Lite
|
|
@@ -1825,6 +1825,10 @@ var Material = class {
|
|
|
1825
1825
|
target.wireframe = this.wireframe;
|
|
1826
1826
|
target.backFaceCulling = this._backFaceCulling;
|
|
1827
1827
|
}
|
|
1828
|
+
/** @internal Initialize facade culling state for a loaded material without mutating its Lite source. */
|
|
1829
|
+
_initializeBackFaceCulling(value) {
|
|
1830
|
+
this._backFaceCulling = value;
|
|
1831
|
+
}
|
|
1828
1832
|
/** The scene this material was constructed against (Babylon.js `Material.getScene`). */
|
|
1829
1833
|
getScene() {
|
|
1830
1834
|
return this._scene;
|
|
@@ -1914,7 +1918,7 @@ function copyLiteMaterialData(src, dst) {
|
|
|
1914
1918
|
const s = src;
|
|
1915
1919
|
const d = dst;
|
|
1916
1920
|
for (const key of Object.keys(s)) {
|
|
1917
|
-
if (key
|
|
1921
|
+
if (key === "_buildGroup" || key === "_uboVersion" || key === "_renderFeatures" || key === "_pi" || key === "_preparedPlugins" || key === "_csmGen" || key === "_uvTxExt") continue;
|
|
1918
1922
|
const value = s[key];
|
|
1919
1923
|
d[key] = Array.isArray(value) ? value.slice() : value;
|
|
1920
1924
|
}
|
|
@@ -1948,6 +1952,16 @@ var StandardMaterial = class StandardMaterial extends PushMaterial {
|
|
|
1948
1952
|
super(name, scene);
|
|
1949
1953
|
this._lite = createStandardMaterial();
|
|
1950
1954
|
}
|
|
1955
|
+
/** @internal Wrap a loader-produced Lite Standard material without replacing its GPU state. */
|
|
1956
|
+
static _fromLite(name, lite, scene) {
|
|
1957
|
+
const material = new StandardMaterial(name);
|
|
1958
|
+
material._lite = lite;
|
|
1959
|
+
material._diffuse = [...lite.diffuseColor];
|
|
1960
|
+
material._initializeBackFaceCulling(lite.backFaceCulling);
|
|
1961
|
+
material._scene = scene;
|
|
1962
|
+
scene._registerMaterial(material);
|
|
1963
|
+
return material;
|
|
1964
|
+
}
|
|
1951
1965
|
/**
|
|
1952
1966
|
* Babylon.js shades an unlit StandardMaterial as `emissive + ambient`: the diffuse colour only scales
|
|
1953
1967
|
* the accumulated light, and there is none. Lite's unlit path is `emissive × diffuse`, so the usual
|
|
@@ -2337,6 +2351,27 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2337
2351
|
getClassName() {
|
|
2338
2352
|
return "PBRMaterial";
|
|
2339
2353
|
}
|
|
2354
|
+
/** @internal Wrap a loader-produced Lite PBR material without replacing its GPU state. */
|
|
2355
|
+
static _fromLite(name, lite, scene) {
|
|
2356
|
+
const material = new PBRMaterial(name);
|
|
2357
|
+
material._lite = lite;
|
|
2358
|
+
const factor = lite.baseColorFactor ?? [
|
|
2359
|
+
1,
|
|
2360
|
+
1,
|
|
2361
|
+
1,
|
|
2362
|
+
1
|
|
2363
|
+
];
|
|
2364
|
+
material._albedoFactor = [
|
|
2365
|
+
factor[0],
|
|
2366
|
+
factor[1],
|
|
2367
|
+
factor[2],
|
|
2368
|
+
factor[3]
|
|
2369
|
+
];
|
|
2370
|
+
material._initializeBackFaceCulling(!lite.doubleSided);
|
|
2371
|
+
material._scene = scene;
|
|
2372
|
+
scene._registerMaterial(material);
|
|
2373
|
+
return material;
|
|
2374
|
+
}
|
|
2340
2375
|
get albedoColor() {
|
|
2341
2376
|
return new Color3(this._albedoFactor[0], this._albedoFactor[1], this._albedoFactor[2]);
|
|
2342
2377
|
}
|
|
@@ -2364,6 +2399,32 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2364
2399
|
this._markDirty();
|
|
2365
2400
|
}
|
|
2366
2401
|
_albedoTexture = null;
|
|
2402
|
+
_bentNormalTexture = null;
|
|
2403
|
+
_bentNormalLevelUnsubscribe;
|
|
2404
|
+
/** Babylon.js `PBRMaterial.bentNormalTexture` over Lite's native IBL occlusion extension. */
|
|
2405
|
+
get bentNormalTexture() {
|
|
2406
|
+
return this._bentNormalTexture;
|
|
2407
|
+
}
|
|
2408
|
+
set bentNormalTexture(texture) {
|
|
2409
|
+
const featureWasEnabled = !!this._lite.bentNormalTexture;
|
|
2410
|
+
this._bentNormalLevelUnsubscribe?.();
|
|
2411
|
+
this._bentNormalLevelUnsubscribe = void 0;
|
|
2412
|
+
this._bentNormalTexture = texture;
|
|
2413
|
+
if (texture) {
|
|
2414
|
+
enableBentNormals();
|
|
2415
|
+
this._bentNormalLevelUnsubscribe = texture._onLevelChanged?.((level) => {
|
|
2416
|
+
if (this._bentNormalTexture === texture) {
|
|
2417
|
+
this._lite.bentNormalStrength = level;
|
|
2418
|
+
this._markDirty();
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
this._lite.bentNormalTexture = texture?._lite ?? void 0;
|
|
2423
|
+
this._lite.bentNormalStrength = texture?.level ?? 1;
|
|
2424
|
+
this._watchTexture(texture);
|
|
2425
|
+
this._markDirty();
|
|
2426
|
+
if (featureWasEnabled && !this._lite.bentNormalTexture) this._refreshInScene();
|
|
2427
|
+
}
|
|
2367
2428
|
/**
|
|
2368
2429
|
* Enumerate every bound PBR texture slot, including extension sub-configurations
|
|
2369
2430
|
* (Babylon.js `PBRMaterial.getActiveTextures`).
|
|
@@ -2371,6 +2432,7 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2371
2432
|
getActiveTextures() {
|
|
2372
2433
|
const textures = [];
|
|
2373
2434
|
if (this._albedoTexture) textures.push(this._albedoTexture);
|
|
2435
|
+
if (this._bentNormalTexture) textures.push(this._bentNormalTexture);
|
|
2374
2436
|
const environmentTexture = this.environmentTexture;
|
|
2375
2437
|
if (environmentTexture) textures.push(environmentTexture);
|
|
2376
2438
|
if (this._sheen) textures.push(...this._sheen.getActiveTextures());
|
|
@@ -2498,6 +2560,12 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2498
2560
|
if (albedo.gammaSpace ?? true) setPbrGammaAlbedo(lite);
|
|
2499
2561
|
else lite._gammaAlbedo = false;
|
|
2500
2562
|
}
|
|
2563
|
+
const bent = this._bentNormalTexture;
|
|
2564
|
+
if (bent?._lite) {
|
|
2565
|
+
enableBentNormals();
|
|
2566
|
+
lite.bentNormalTexture = bent._lite;
|
|
2567
|
+
lite.bentNormalStrength = bent.level ?? 1;
|
|
2568
|
+
}
|
|
2501
2569
|
if (!lite.baseColorTexture) {
|
|
2502
2570
|
lite.baseColorTexture = createSolidTexture2D(engine, 1, 1, 1, 1);
|
|
2503
2571
|
lite.baseColorFactor = [...this._albedoFactor];
|
|
@@ -2527,6 +2595,8 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2527
2595
|
target.forceIrradianceInFragment = this.forceIrradianceInFragment;
|
|
2528
2596
|
target._albedoFactor = [...this._albedoFactor];
|
|
2529
2597
|
target._albedoTexture = this._albedoTexture;
|
|
2598
|
+
target._watchTexture(target._albedoTexture);
|
|
2599
|
+
target.bentNormalTexture = this._bentNormalTexture;
|
|
2530
2600
|
const src = this._lite;
|
|
2531
2601
|
const dst = target._lite;
|
|
2532
2602
|
if (src._emissiveColor) setPbrEmissive(dst, [...src._emissiveColor]);
|
|
@@ -2534,6 +2604,16 @@ var PBRMaterial = class PBRMaterial extends PushMaterial {
|
|
|
2534
2604
|
if (src._sheen) setPbrSheen(dst, { ...src._sheen });
|
|
2535
2605
|
if (src._anisotropy) setPbrAnisotropy(dst, { ...src._anisotropy });
|
|
2536
2606
|
if (src._iridescence) setPbrIridescence(dst, { ...src._iridescence });
|
|
2607
|
+
if (src.bentNormalTexture) {
|
|
2608
|
+
enableBentNormals();
|
|
2609
|
+
dst.bentNormalTexture = src.bentNormalTexture;
|
|
2610
|
+
dst.bentNormalStrength = src.bentNormalStrength;
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
dispose() {
|
|
2614
|
+
this._bentNormalLevelUnsubscribe?.();
|
|
2615
|
+
this._bentNormalLevelUnsubscribe = void 0;
|
|
2616
|
+
super.dispose();
|
|
2537
2617
|
}
|
|
2538
2618
|
};
|
|
2539
2619
|
/**
|
|
@@ -3103,6 +3183,7 @@ var TransformNode = class TransformNode extends Node {
|
|
|
3103
3183
|
_nativeRotationValues;
|
|
3104
3184
|
_isSyncingRotationFromNative = false;
|
|
3105
3185
|
_sceneDisposeObserver;
|
|
3186
|
+
_loadedSceneRegistered = false;
|
|
3106
3187
|
/**
|
|
3107
3188
|
* @internal The Lite asset container this node was loaded from, when produced
|
|
3108
3189
|
* by a loader. Used by the `KHR_materials_variants` helpers (which key off the
|
|
@@ -3110,16 +3191,27 @@ var TransformNode = class TransformNode extends Node {
|
|
|
3110
3191
|
*/
|
|
3111
3192
|
_container;
|
|
3112
3193
|
/**
|
|
3113
|
-
* @internal Bind a loader-produced wrapper to
|
|
3114
|
-
*
|
|
3115
|
-
*
|
|
3116
|
-
*
|
|
3194
|
+
* @internal Bind a loader-produced wrapper to its owning scene. Detached
|
|
3195
|
+
* containers retain scene-aware material adaptation without registry membership;
|
|
3196
|
+
* adoption later lists the wrapper in `scene.meshes`. The underlying Lite node is
|
|
3197
|
+
* never re-inserted here.
|
|
3117
3198
|
*/
|
|
3118
|
-
_bindLoadedScene(scene) {
|
|
3119
|
-
if (this._scene
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3199
|
+
_bindLoadedScene(scene, register = true) {
|
|
3200
|
+
if (this._scene !== scene) {
|
|
3201
|
+
if (this._sceneDisposeObserver) {
|
|
3202
|
+
this._scene?.onDisposeObservable?.remove(this._sceneDisposeObserver);
|
|
3203
|
+
this._sceneDisposeObserver = void 0;
|
|
3204
|
+
}
|
|
3205
|
+
this._scene = scene;
|
|
3206
|
+
this._loadedSceneRegistered = false;
|
|
3207
|
+
this._bindRotationSceneDisposal(scene);
|
|
3208
|
+
}
|
|
3209
|
+
if (register && !this._loadedSceneRegistered) {
|
|
3210
|
+
scene._registerMesh(this, this._node);
|
|
3211
|
+
this._loadedSceneRegistered = true;
|
|
3212
|
+
return true;
|
|
3213
|
+
}
|
|
3214
|
+
return false;
|
|
3123
3215
|
}
|
|
3124
3216
|
/** @internal Link an already-parented Lite node without mutating its Lite hierarchy. */
|
|
3125
3217
|
_adoptLoadedParent(parent) {
|
|
@@ -3325,6 +3417,8 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3325
3417
|
/** @internal Underlying Babylon Lite mesh. */
|
|
3326
3418
|
_lite;
|
|
3327
3419
|
_material = null;
|
|
3420
|
+
/** @internal Lite material identity currently represented by `_material`. */
|
|
3421
|
+
_wrappedLiteMaterial;
|
|
3328
3422
|
/**
|
|
3329
3423
|
* @internal The mesh renders a material that exists only on its Lite node: a natively loaded glTF
|
|
3330
3424
|
* material has no compat wrapper, so `material` reads `null`. Clones keep that Lite material, and the
|
|
@@ -3360,6 +3454,16 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3360
3454
|
for (const light of this._scene?.lights ?? []) light._pruneDisposedMesh(this);
|
|
3361
3455
|
}
|
|
3362
3456
|
get material() {
|
|
3457
|
+
const liteMaterial = this._lite.material;
|
|
3458
|
+
if (this._scene && liteMaterial && (this._liteOnlyMaterial || !!this._wrappedLiteMaterial && liteMaterial !== this._wrappedLiteMaterial)) {
|
|
3459
|
+
if (this._material?._lite === liteMaterial) this._liteOnlyMaterial = false;
|
|
3460
|
+
else {
|
|
3461
|
+
const loaded = this._scene._wrapLoadedMaterial(liteMaterial);
|
|
3462
|
+
this._material = loaded;
|
|
3463
|
+
this._liteOnlyMaterial = !loaded;
|
|
3464
|
+
}
|
|
3465
|
+
this._wrappedLiteMaterial = liteMaterial;
|
|
3466
|
+
}
|
|
3363
3467
|
return this._material;
|
|
3364
3468
|
}
|
|
3365
3469
|
set material(value) {
|
|
@@ -3367,6 +3471,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3367
3471
|
const renderMaterial = value ?? scene?.defaultMaterial;
|
|
3368
3472
|
if (renderMaterial && (this._visibilityValue < 1 || this._opacityTargets().some((target) => getMeshOpacity(target) < 1))) this._validateCompatOpacityMaterial("Mesh.material", renderMaterial);
|
|
3369
3473
|
this._material = value;
|
|
3474
|
+
this._wrappedLiteMaterial = renderMaterial?._lite;
|
|
3370
3475
|
this._liteOnlyMaterial = false;
|
|
3371
3476
|
if (renderMaterial && scene) {
|
|
3372
3477
|
if (scene._hasStarted) attachMaterialToScene(renderMaterial, scene);
|
|
@@ -3686,31 +3791,32 @@ var Mesh = class Mesh extends AbstractMesh {
|
|
|
3686
3791
|
* adopts the existing Lite node. Used by the loader to give
|
|
3687
3792
|
* `AssetContainer.meshes` real, stable-identity mesh handles.
|
|
3688
3793
|
*/
|
|
3689
|
-
static _fromLite(lite, container, scene) {
|
|
3794
|
+
static _fromLite(lite, container, scene, register = true) {
|
|
3690
3795
|
const mesh = new Mesh(lite.name ?? "", lite);
|
|
3691
3796
|
mesh._container = container;
|
|
3692
3797
|
mesh._liteOnlyMaterial = !!lite.material;
|
|
3693
3798
|
mesh._visible = lite.visible !== false;
|
|
3694
|
-
if (scene) mesh._bindLoadedScene(scene);
|
|
3799
|
+
if (scene) mesh._bindLoadedScene(scene, register);
|
|
3695
3800
|
return mesh;
|
|
3696
3801
|
}
|
|
3697
3802
|
/** @internal Bind a loaded mesh and its discovered morph manager to the owning scene. */
|
|
3698
|
-
_bindLoadedScene(scene) {
|
|
3699
|
-
super._bindLoadedScene(scene);
|
|
3803
|
+
_bindLoadedScene(scene, register = true) {
|
|
3804
|
+
if (!super._bindLoadedScene(scene, register)) return false;
|
|
3700
3805
|
for (const manager of this._ownedMorphTargetManagers) scene._retainMorphTargetManagerOwnership(manager);
|
|
3701
3806
|
if (this._morphTargetManager?._lite) this._morphTargetManager._adoptEngine(scene._getLiteEngine());
|
|
3702
3807
|
else if (this._morphTargetManager) scene._registerMorphTargetManager(this, this._morphTargetManager);
|
|
3808
|
+
return true;
|
|
3703
3809
|
}
|
|
3704
3810
|
/** @internal Wrap and link a complete Lite hierarchy, registering every wrapper. */
|
|
3705
|
-
static _fromLiteHierarchy(lite, container, scene, registry = /* @__PURE__ */ new Map(), parent = null) {
|
|
3811
|
+
static _fromLiteHierarchy(lite, container, scene, registry = /* @__PURE__ */ new Map(), parent = null, register = true) {
|
|
3706
3812
|
let wrapper = registry.get(lite);
|
|
3707
3813
|
if (!wrapper) {
|
|
3708
|
-
wrapper = Mesh._fromLite(lite, container, scene);
|
|
3814
|
+
wrapper = Mesh._fromLite(lite, container, scene, register);
|
|
3709
3815
|
registry.set(lite, wrapper);
|
|
3710
|
-
} else if (scene) wrapper._bindLoadedScene(scene);
|
|
3816
|
+
} else if (scene) wrapper._bindLoadedScene(scene, register);
|
|
3711
3817
|
wrapper._adoptLoadedParent(parent);
|
|
3712
3818
|
const children = lite.children;
|
|
3713
|
-
if (children) for (const child of children) Mesh._fromLiteHierarchy(child, container, scene, registry, wrapper);
|
|
3819
|
+
if (children) for (const child of children) Mesh._fromLiteHierarchy(child, container, scene, registry, wrapper, register);
|
|
3714
3820
|
return wrapper;
|
|
3715
3821
|
}
|
|
3716
3822
|
_morphTargetManager = null;
|
|
@@ -4371,4 +4477,4 @@ var PolygonBuilder = {
|
|
|
4371
4477
|
function RegisterPolygonBuilder() {}
|
|
4372
4478
|
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 };
|
|
4373
4479
|
|
|
4374
|
-
//# sourceMappingURL=meshes-
|
|
4480
|
+
//# sourceMappingURL=meshes-DWnDIh1l.js.map
|