@babylonjs/lite-compat 1.38.0-preview → 1.38.2-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 +64 -32
- package/{brdf-lut-data-BRUnY8c5.js → brdf-lut-data-CIJtJXN2.js} +2 -3
- package/{brdf-lut-data-BRUnY8c5.js.map → brdf-lut-data-CIJtJXN2.js.map} +1 -1
- package/{bundler-resolve-CVkl7m-0.js → bundler-resolve-DLIJhtfD.js} +2 -3
- package/{bundler-resolve-CVkl7m-0.js.map → bundler-resolve-DLIJhtfD.js.map} +1 -1
- package/esbuild.js +2 -3
- package/index.d.ts +89 -16
- package/index.js +377 -158
- package/index.js.map +1 -1
- package/{meshes-sOWGK4P8.js → meshes-Bt_UAqXU.js} +168 -56
- package/meshes-Bt_UAqXU.js.map +1 -0
- package/navigation.d.ts +85 -15
- package/navigation.js +2 -3
- package/navigation.js.map +1 -1
- package/package.json +4 -4
- package/recast-shim.js +1 -2
- package/rollup.js +2 -3
- package/vite.js +2 -3
- package/webpack.js +2 -3
- package/meshes-sOWGK4P8.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addToScene, cloneTransformNode, computeAabb, createBox, createCylinder, createDashedLines, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createLineMaterial, createLineSystem, createMeshFromData, createPbrMaterial, createPlane, createPolyhedron, createQuatFromRotationMat4, createRibbon, createSolidTexture2D, createSphere, createStandardMaterial, createTorus, createTorusKnot, createTransformNode, createTube, markMaterialUboDirty, maximizeMat4InPlace, normalizeVec2ToRef, projectPointToViewportToRef, rebuildMaterial, removeFromScene, resizeMeshGeometry, scaleBoundsFromCenterToRef, setAccessibilityTag, setLineMaterialColor, setMat4Translation, setMeshVisible, setParent, setPbrAnisotropy, setPbrClearCoat, setPbrEmissive, setPbrGammaAlbedo, setPbrIridescence, setPbrSheen, setStandardBumpTexture, setStandardEmissiveTexture, setThinInstanceColors, setThinInstances, updateDashedLines, updateLineSystem, updateMeshUvs, writeMat4FromLookDirectionLHIntoBuffer, writeMat4FromLookDirectionRHIntoBuffer, writeMat4FromQuatIntoBuffer, writeQuatFromRotationMat4IntoRef } from "@babylonjs/lite";
|
|
2
|
-
|
|
1
|
+
import { addToScene, cloneTransformNode, computeAabb, createBox, createCylinder, createDashedLines, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createLineMaterial, createLineSystem, createMeshFromData, createPbrMaterial, createPlane, createPolyhedron, createQuatFromRotationMat4, createRibbon, createSolidTexture2D, createSphere, createStandardMaterial, createTorus, createTorusKnot, createTransformNode, createTube, getMaterialFamily, getMeshOpacity, markMaterialUboDirty, maximizeMat4InPlace, normalizeVec2ToRef, projectPointToViewportToRef, rebuildMaterial, removeFromScene, resizeMeshGeometry, scaleBoundsFromCenterToRef, setAccessibilityTag, setLineMaterialColor, setMat4Translation, setMeshOpacity, setMeshVisible, setParent, setPbrAnisotropy, setPbrClearCoat, setPbrEmissive, setPbrGammaAlbedo, setPbrIridescence, setPbrSheen, setStandardBumpTexture, setStandardEmissiveTexture, setThinInstanceColors, setThinInstances, updateDashedLines, updateLineSystem, updateMeshGeometry, updateMeshUvs, writeMat4FromLookDirectionLHIntoBuffer, writeMat4FromLookDirectionRHIntoBuffer, writeMat4FromQuatIntoBuffer, writeQuatFromRotationMat4IntoRef } from "@babylonjs/lite";
|
|
2
|
+
// src/error.ts
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown when Babylon.js code reaches an API surface that the Babylon Lite
|
|
5
5
|
* compatibility layer cannot (or does not yet) support.
|
|
@@ -19,8 +19,7 @@ var LiteCompatError = class extends Error {
|
|
|
19
19
|
function unsupported(api, detail) {
|
|
20
20
|
throw new LiteCompatError(api, detail);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
//#region src/math/vector.ts
|
|
22
|
+
// src/math/vector.ts
|
|
24
23
|
/**
|
|
25
24
|
* Babylon.js-compatible vector classes (`Vector2`, `Vector3`, `Vector4`).
|
|
26
25
|
*
|
|
@@ -85,6 +84,10 @@ var Vector2 = class Vector2 {
|
|
|
85
84
|
clone() {
|
|
86
85
|
return new Vector2(this.x, this.y);
|
|
87
86
|
}
|
|
87
|
+
/** Babylon.js `dot(otherVector)`. */
|
|
88
|
+
dot(otherVector) {
|
|
89
|
+
return this.x * otherVector.x + this.y * otherVector.y;
|
|
90
|
+
}
|
|
88
91
|
equals(other) {
|
|
89
92
|
return this.x === other.x && this.y === other.y;
|
|
90
93
|
}
|
|
@@ -207,6 +210,10 @@ var Vector3 = class Vector3 {
|
|
|
207
210
|
clone() {
|
|
208
211
|
return new Vector3(this.x, this.y, this.z);
|
|
209
212
|
}
|
|
213
|
+
/** Babylon.js `dot(otherVector)`. */
|
|
214
|
+
dot(otherVector) {
|
|
215
|
+
return this.x * otherVector.x + this.y * otherVector.y + this.z * otherVector.z;
|
|
216
|
+
}
|
|
210
217
|
equals(other) {
|
|
211
218
|
return this.x === other.x && this.y === other.y && this.z === other.z;
|
|
212
219
|
}
|
|
@@ -436,6 +443,10 @@ var Vector4 = class Vector4 {
|
|
|
436
443
|
clone() {
|
|
437
444
|
return new Vector4(this.x, this.y, this.z, this.w);
|
|
438
445
|
}
|
|
446
|
+
/** Babylon.js `dot(otherVector)`. */
|
|
447
|
+
dot(otherVector) {
|
|
448
|
+
return this.x * otherVector.x + this.y * otherVector.y + this.z * otherVector.z + this.w * otherVector.w;
|
|
449
|
+
}
|
|
439
450
|
equals(other) {
|
|
440
451
|
return this.x === other.x && this.y === other.y && this.z === other.z && this.w === other.w;
|
|
441
452
|
}
|
|
@@ -451,8 +462,7 @@ var Vector4 = class Vector4 {
|
|
|
451
462
|
return new Vector4(0, 0, 0, 0);
|
|
452
463
|
}
|
|
453
464
|
};
|
|
454
|
-
|
|
455
|
-
//#region src/math/color.ts
|
|
465
|
+
// src/math/color.ts
|
|
456
466
|
/**
|
|
457
467
|
* Babylon.js-compatible colour classes (`Color3`, `Color4`).
|
|
458
468
|
*
|
|
@@ -648,8 +658,7 @@ function toHex(value) {
|
|
|
648
658
|
const hex = value.toString(16).toUpperCase();
|
|
649
659
|
return hex.length === 1 ? "0" + hex : hex;
|
|
650
660
|
}
|
|
651
|
-
|
|
652
|
-
//#region src/math/quaternion.ts
|
|
661
|
+
// src/math/quaternion.ts
|
|
653
662
|
/**
|
|
654
663
|
* Babylon.js-compatible `Quaternion`.
|
|
655
664
|
*
|
|
@@ -657,6 +666,7 @@ function toHex(value) {
|
|
|
657
666
|
* Babylon Lite `{ x, y, z, w }` quaternion shape used on transform nodes.
|
|
658
667
|
*/
|
|
659
668
|
var lookDirectionRotationScratch;
|
|
669
|
+
var axesRotationScratch;
|
|
660
670
|
var Quaternion = class Quaternion {
|
|
661
671
|
x;
|
|
662
672
|
y;
|
|
@@ -814,7 +824,32 @@ var Quaternion = class Quaternion {
|
|
|
814
824
|
static FromEulerAngles(x, y, z) {
|
|
815
825
|
return Quaternion.RotationYawPitchRoll(y, x, z);
|
|
816
826
|
}
|
|
827
|
+
/** Babylon.js `Quaternion.FromEulerVector(vec)`: `vec` holds pitch (x), yaw (y) and roll (z). */
|
|
828
|
+
static FromEulerVector(vec) {
|
|
829
|
+
return Quaternion.RotationYawPitchRoll(vec.y, vec.x, vec.z);
|
|
830
|
+
}
|
|
831
|
+
/** Babylon.js `Quaternion.FromEulerVectorToRef(vec, result)`. */
|
|
832
|
+
static FromEulerVectorToRef(vec, result) {
|
|
833
|
+
return Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
|
|
834
|
+
}
|
|
835
|
+
/** Babylon.js `Quaternion.RotationQuaternionFromAxis(axis1, axis2, axis3)`: the rotation of the XYZ system onto these axes. */
|
|
836
|
+
static RotationQuaternionFromAxis(axis1, axis2, axis3) {
|
|
837
|
+
return Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, new Quaternion());
|
|
838
|
+
}
|
|
839
|
+
/** Babylon.js `Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, ref)`. Like Babylon.js, it normalizes
|
|
840
|
+
* copies of the axes and uses them as the rows of a rotation matrix (`Matrix.FromXYZAxesToRef`); the axes are left as they are. */
|
|
841
|
+
static RotationQuaternionFromAxisToRef(axis1, axis2, axis3, ref) {
|
|
842
|
+
const matrix = axesRotationScratch ??= /* @__PURE__ */ new Float32Array(16);
|
|
843
|
+
writeNormalizedRow(matrix, 0, axis1);
|
|
844
|
+
writeNormalizedRow(matrix, 1, axis2);
|
|
845
|
+
writeNormalizedRow(matrix, 2, axis3);
|
|
846
|
+
return Quaternion._FromRotationStorageToRef(matrix, ref);
|
|
847
|
+
}
|
|
817
848
|
static RotationYawPitchRoll(yaw, pitch, roll) {
|
|
849
|
+
return Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, new Quaternion());
|
|
850
|
+
}
|
|
851
|
+
/** Babylon.js `Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, result)`. */
|
|
852
|
+
static RotationYawPitchRollToRef(yaw, pitch, roll, result) {
|
|
818
853
|
const halfRoll = roll * .5;
|
|
819
854
|
const halfPitch = pitch * .5;
|
|
820
855
|
const halfYaw = yaw * .5;
|
|
@@ -824,7 +859,7 @@ var Quaternion = class Quaternion {
|
|
|
824
859
|
const cosPitch = Math.cos(halfPitch);
|
|
825
860
|
const sinYaw = Math.sin(halfYaw);
|
|
826
861
|
const cosYaw = Math.cos(halfYaw);
|
|
827
|
-
return
|
|
862
|
+
return result.set(cosYaw * sinPitch * cosRoll + sinYaw * cosPitch * sinRoll, sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll, cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll, cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll);
|
|
828
863
|
}
|
|
829
864
|
static RotationAxis(axis, angle) {
|
|
830
865
|
const sin = Math.sin(angle / 2);
|
|
@@ -853,8 +888,14 @@ var Quaternion = class Quaternion {
|
|
|
853
888
|
return new Quaternion(num3 * left.x + num2 * right.x, num3 * left.y + num2 * right.y, num3 * left.z + num2 * right.z, num3 * left.w + num2 * right.w);
|
|
854
889
|
}
|
|
855
890
|
};
|
|
856
|
-
|
|
857
|
-
|
|
891
|
+
/** Write `axis`, normalized as `Vector3.normalize()` does (a zero axis stays zero), as row `row` of a 4×4 storage. */
|
|
892
|
+
function writeNormalizedRow(matrix, row, axis) {
|
|
893
|
+
const len = axis.length() || 1;
|
|
894
|
+
matrix[row * 4] = axis.x / len;
|
|
895
|
+
matrix[row * 4 + 1] = axis.y / len;
|
|
896
|
+
matrix[row * 4 + 2] = axis.z / len;
|
|
897
|
+
}
|
|
898
|
+
// src/math/matrix.ts
|
|
858
899
|
/**
|
|
859
900
|
* Babylon.js-compatible `Matrix` (4x4).
|
|
860
901
|
*
|
|
@@ -1025,6 +1066,31 @@ var Matrix = class Matrix {
|
|
|
1025
1066
|
for (let i = 0; i < 16; i++) result.m[i] = array[offset + i] ?? 0;
|
|
1026
1067
|
return result;
|
|
1027
1068
|
}
|
|
1069
|
+
/** Babylon.js `Matrix.Invert(source)`: a new matrix holding the inverse of `source`, which is left as it is. */
|
|
1070
|
+
static Invert(source) {
|
|
1071
|
+
return source.invertToRef(new Matrix());
|
|
1072
|
+
}
|
|
1073
|
+
/** Babylon.js `Matrix.FromXYZAxesToRef(xaxis, yaxis, zaxis, result)`: the axes as the first three rows. */
|
|
1074
|
+
static FromXYZAxesToRef(xaxis, yaxis, zaxis, result) {
|
|
1075
|
+
const m = result.m;
|
|
1076
|
+
m[0] = xaxis.x;
|
|
1077
|
+
m[1] = xaxis.y;
|
|
1078
|
+
m[2] = xaxis.z;
|
|
1079
|
+
m[3] = 0;
|
|
1080
|
+
m[4] = yaxis.x;
|
|
1081
|
+
m[5] = yaxis.y;
|
|
1082
|
+
m[6] = yaxis.z;
|
|
1083
|
+
m[7] = 0;
|
|
1084
|
+
m[8] = zaxis.x;
|
|
1085
|
+
m[9] = zaxis.y;
|
|
1086
|
+
m[10] = zaxis.z;
|
|
1087
|
+
m[11] = 0;
|
|
1088
|
+
m[12] = 0;
|
|
1089
|
+
m[13] = 0;
|
|
1090
|
+
m[14] = 0;
|
|
1091
|
+
m[15] = 1;
|
|
1092
|
+
return result.markAsUpdated();
|
|
1093
|
+
}
|
|
1028
1094
|
static Identity() {
|
|
1029
1095
|
return Matrix.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
1030
1096
|
}
|
|
@@ -1157,24 +1223,7 @@ function invertValues(m) {
|
|
|
1157
1223
|
const b10 = m21 * m33 - m23 * m31;
|
|
1158
1224
|
const b11 = m22 * m33 - m23 * m32;
|
|
1159
1225
|
const det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
1160
|
-
if (det === 0) return
|
|
1161
|
-
1,
|
|
1162
|
-
0,
|
|
1163
|
-
0,
|
|
1164
|
-
0,
|
|
1165
|
-
0,
|
|
1166
|
-
1,
|
|
1167
|
-
0,
|
|
1168
|
-
0,
|
|
1169
|
-
0,
|
|
1170
|
-
0,
|
|
1171
|
-
1,
|
|
1172
|
-
0,
|
|
1173
|
-
0,
|
|
1174
|
-
0,
|
|
1175
|
-
0,
|
|
1176
|
-
1
|
|
1177
|
-
];
|
|
1226
|
+
if (det === 0) return Array.from(m);
|
|
1178
1227
|
const invDet = 1 / det;
|
|
1179
1228
|
return [
|
|
1180
1229
|
(m11 * b11 - m12 * b10 + m13 * b09) * invDet,
|
|
@@ -1218,8 +1267,7 @@ function transformNormal(vector, transformation) {
|
|
|
1218
1267
|
const z = vector.z;
|
|
1219
1268
|
return new Vector3(x * m[0] + y * m[4] + z * m[8], x * m[1] + y * m[5] + z * m[9], x * m[2] + y * m[6] + z * m[10]);
|
|
1220
1269
|
}
|
|
1221
|
-
|
|
1222
|
-
//#region src/culling/bounding.ts
|
|
1270
|
+
// src/culling/bounding.ts
|
|
1223
1271
|
/**
|
|
1224
1272
|
* Babylon.js-compatible bounding volumes (`BoundingBox`, `BoundingSphere`,
|
|
1225
1273
|
* `BoundingInfo`) — pure JS over the compat math types.
|
|
@@ -1384,8 +1432,7 @@ var BoundingInfo = class {
|
|
|
1384
1432
|
this.boundingSphere.reConstruct(min, max, worldMatrix);
|
|
1385
1433
|
}
|
|
1386
1434
|
};
|
|
1387
|
-
|
|
1388
|
-
//#region src/misc/observable.ts
|
|
1435
|
+
// src/misc/observable.ts
|
|
1389
1436
|
var Observable = class {
|
|
1390
1437
|
_onObserverAdded;
|
|
1391
1438
|
notifyIfTriggered;
|
|
@@ -1474,8 +1521,7 @@ var Observable = class {
|
|
|
1474
1521
|
this._lastNotifiedMask = -1;
|
|
1475
1522
|
}
|
|
1476
1523
|
};
|
|
1477
|
-
|
|
1478
|
-
//#region src/node/node.ts
|
|
1524
|
+
// src/node/node.ts
|
|
1479
1525
|
/**
|
|
1480
1526
|
* Babylon.js-compatible `Node` — the base of the scene-graph class hierarchy.
|
|
1481
1527
|
*
|
|
@@ -1671,6 +1717,8 @@ var Node = class {
|
|
|
1671
1717
|
}
|
|
1672
1718
|
/** @internal Dispose this node's subclass-owned resources. */
|
|
1673
1719
|
_disposeSelf(_doNotRecurse) {}
|
|
1720
|
+
/** @internal Drop scene-side references that hold this node by identity. */
|
|
1721
|
+
_retireFromScene() {}
|
|
1674
1722
|
/** @internal Dispose this compat wrapper tree in post-order. */
|
|
1675
1723
|
_disposeWrapperTree(doNotRecurse = false) {
|
|
1676
1724
|
this._disposeWrapperTreeInternal(doNotRecurse, true);
|
|
@@ -1687,6 +1735,7 @@ var Node = class {
|
|
|
1687
1735
|
if (this._disposed) return;
|
|
1688
1736
|
if (doNotRecurse) for (const child of [...this._children]) child.parent = null;
|
|
1689
1737
|
else for (const child of [...this._children]) child._disposeWrapperTreeInternal(false, disposeSelf);
|
|
1738
|
+
this._retireFromScene();
|
|
1690
1739
|
if (disposeSelf) this._disposeSelf(doNotRecurse);
|
|
1691
1740
|
this._disposed = true;
|
|
1692
1741
|
let hasError = false;
|
|
@@ -1720,8 +1769,7 @@ var Node = class {
|
|
|
1720
1769
|
/** @internal Hook for subclasses to wire the parent link into the Lite scene graph. */
|
|
1721
1770
|
_applyParent(_parent) {}
|
|
1722
1771
|
};
|
|
1723
|
-
|
|
1724
|
-
//#region src/materials/materials.ts
|
|
1772
|
+
// src/materials/materials.ts
|
|
1725
1773
|
/**
|
|
1726
1774
|
* Babylon.js-compatible material classes over the Babylon Lite material
|
|
1727
1775
|
* factories.
|
|
@@ -2539,8 +2587,7 @@ var PBRSpecularGlossinessMaterial = class PBRSpecularGlossinessMaterial extends
|
|
|
2539
2587
|
return cloned;
|
|
2540
2588
|
}
|
|
2541
2589
|
};
|
|
2542
|
-
|
|
2543
|
-
//#region src/meshes/merge-mesh-geometry.ts
|
|
2590
|
+
// src/meshes/merge-mesh-geometry.ts
|
|
2544
2591
|
function fillFlatNormals(positions, indices, indexOffset, indexCount, vertexBase, out) {
|
|
2545
2592
|
for (let i = 0; i < indexCount; i += 3) {
|
|
2546
2593
|
const a = (indices[indexOffset + i] + vertexBase) * 3;
|
|
@@ -2633,8 +2680,7 @@ function mergeMeshGeometry(engine, name, meshes) {
|
|
|
2633
2680
|
}
|
|
2634
2681
|
return createMeshFromData(engine, name, positions, normals, indices, uvs);
|
|
2635
2682
|
}
|
|
2636
|
-
|
|
2637
|
-
//#region src/meshes/meshes.ts
|
|
2683
|
+
// src/meshes/meshes.ts
|
|
2638
2684
|
/**
|
|
2639
2685
|
* Babylon.js-compatible mesh hierarchy and `MeshBuilder`.
|
|
2640
2686
|
*
|
|
@@ -2687,6 +2733,12 @@ function liteNodeOf(node) {
|
|
|
2687
2733
|
const n = node;
|
|
2688
2734
|
return n._node ?? n._lite ?? null;
|
|
2689
2735
|
}
|
|
2736
|
+
function validateOpacityMaterial(api, name, material) {
|
|
2737
|
+
if (material) {
|
|
2738
|
+
const family = getMaterialFamily(material);
|
|
2739
|
+
if (family !== "standard" && family !== "pbr") unsupported(api, `Mesh "${name}" uses a "${family}" material; visibility below 1 supports only Standard and PBR materials.`);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2690
2742
|
var PLACEHOLDER_POSITIONS = new Float32Array([
|
|
2691
2743
|
0,
|
|
2692
2744
|
0,
|
|
@@ -2766,12 +2818,28 @@ function computeFlatNormals(positions, indices) {
|
|
|
2766
2818
|
function matchingVertexAttribute(data, vertexCount, components) {
|
|
2767
2819
|
return data?.length === vertexCount * components ? data : void 0;
|
|
2768
2820
|
}
|
|
2821
|
+
/** @internal Whether an optional attribute keeps the presence and length its GPU buffer was created with. */
|
|
2822
|
+
function keepsAttributeLayout(values, present, length) {
|
|
2823
|
+
return !!values?.length === !!present && (!present || values.length === length);
|
|
2824
|
+
}
|
|
2825
|
+
/**
|
|
2826
|
+
* @internal Write new geometry into a Lite mesh. When the vertex and index counts and the attribute layout are
|
|
2827
|
+
* unchanged, `updateMeshGeometry` rewrites the existing GPU buffers, so the buffers, the mesh's renderable and every
|
|
2828
|
+
* recorded bundle stay valid. Anything else goes through `resizeMeshGeometry`, which allocates new buffers and makes
|
|
2829
|
+
* every scene re-record its bundles. The in-place conditions are `updateMeshGeometry`'s own, plus geometry that only
|
|
2830
|
+
* this mesh writes (no clone sharing it, no borrowed vertex slab or shared index buffer) and no active draw range.
|
|
2831
|
+
*/
|
|
2832
|
+
function writeMeshGeometry(engine, mesh, positions, normals, indices, uvs, uvs2, tangents, colors) {
|
|
2833
|
+
const gpu = mesh._gpu;
|
|
2834
|
+
const vertexCount = positions.length / 3;
|
|
2835
|
+
(!gpu._vbLayout && gpu._ownsVertexBuffers !== false && gpu._ownsIndexBuffer !== false && (gpu._refCount ?? 1) <= 1 && !gpu._drawRangeSource && gpu.indexFormat === "uint32" && mesh._cpuPositions?.length === positions.length && normals.length === positions.length && mesh._cpuIndices?.length === indices.length && indices.length <= (gpu._indexCapacity ?? gpu.indexCount) && keepsAttributeLayout(uvs, gpu.hasUv, vertexCount * 2) && keepsAttributeLayout(uvs2, gpu.hasUv2, vertexCount * 2) && keepsAttributeLayout(tangents, gpu.hasTangent, vertexCount * 4) && keepsAttributeLayout(colors, gpu.hasColor, vertexCount * 4) ? updateMeshGeometry : resizeMeshGeometry)(engine, mesh, positions, normals, indices, uvs, uvs2, tangents, colors);
|
|
2836
|
+
}
|
|
2769
2837
|
/**
|
|
2770
2838
|
* Babylon.js `TransformNode` — a positioned, rotated, scaled scene-graph node.
|
|
2771
2839
|
* Wraps a Lite scene node (`_node`): either a standalone Lite transform node, or
|
|
2772
2840
|
* (for meshes) the Lite mesh itself, which also carries the transform.
|
|
2773
2841
|
*/
|
|
2774
|
-
var TransformNode = class extends Node {
|
|
2842
|
+
var TransformNode = class TransformNode extends Node {
|
|
2775
2843
|
/** @internal The Lite scene node that carries this transform. */
|
|
2776
2844
|
_node;
|
|
2777
2845
|
physicsBody = null;
|
|
@@ -2845,6 +2913,13 @@ var TransformNode = class extends Node {
|
|
|
2845
2913
|
} else this._useQuat = false;
|
|
2846
2914
|
}
|
|
2847
2915
|
/**
|
|
2916
|
+
* Babylon.js `getChildTransformNodes(directDescendantsOnly?, predicate?)` — the descendants that are transform nodes
|
|
2917
|
+
* (meshes included). As in Babylon.js, `predicate` is called on every evaluated descendant.
|
|
2918
|
+
*/
|
|
2919
|
+
getChildTransformNodes(directDescendantsOnly, predicate) {
|
|
2920
|
+
return this.getDescendants(directDescendantsOnly, (node) => (!predicate || predicate(node)) && node instanceof TransformNode);
|
|
2921
|
+
}
|
|
2922
|
+
/**
|
|
2848
2923
|
* Babylon.js `setParent(node)` — reparent while **preserving world position**
|
|
2849
2924
|
* (the child's local transform is recomputed). Distinct from the `parent`
|
|
2850
2925
|
* setter, which keeps the local transform and lets the world move.
|
|
@@ -2892,11 +2967,13 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2892
2967
|
*/
|
|
2893
2968
|
_liteOnlyMaterial = false;
|
|
2894
2969
|
_meshBlendingTag = 0;
|
|
2970
|
+
_visibilityValue = 1;
|
|
2895
2971
|
_visible = true;
|
|
2896
2972
|
constructor(name, lite, scene) {
|
|
2897
2973
|
super(name, scene, lite);
|
|
2898
2974
|
this._lite = lite;
|
|
2899
2975
|
this._lite.name = name;
|
|
2976
|
+
this._visibilityValue = "_gpu" in lite ? getMeshOpacity(lite) : 1;
|
|
2900
2977
|
if (scene) {
|
|
2901
2978
|
this.material = scene.defaultMaterial;
|
|
2902
2979
|
scene._registerMesh(this, this._lite);
|
|
@@ -2909,14 +2986,22 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2909
2986
|
_isMeshNode() {
|
|
2910
2987
|
return true;
|
|
2911
2988
|
}
|
|
2989
|
+
/**
|
|
2990
|
+
* @internal Take this mesh out of every light's filter lists before it goes, as Babylon.js
|
|
2991
|
+
* `AbstractMesh.dispose` does in its own `Lights` loop. Container-retired wrappers prune too.
|
|
2992
|
+
*/
|
|
2993
|
+
_retireFromScene() {
|
|
2994
|
+
for (const light of this._scene?.lights ?? []) light._pruneDisposedMesh(this);
|
|
2995
|
+
}
|
|
2912
2996
|
get material() {
|
|
2913
2997
|
return this._material;
|
|
2914
2998
|
}
|
|
2915
2999
|
set material(value) {
|
|
2916
|
-
this._material = value;
|
|
2917
|
-
this._liteOnlyMaterial = false;
|
|
2918
3000
|
const scene = this._scene;
|
|
2919
3001
|
const renderMaterial = value ?? scene?.defaultMaterial;
|
|
3002
|
+
if (renderMaterial && (this._visibilityValue < 1 || this._opacityTargets().some((target) => getMeshOpacity(target) < 1))) this._validateCompatOpacityMaterial("Mesh.material", renderMaterial);
|
|
3003
|
+
this._material = value;
|
|
3004
|
+
this._liteOnlyMaterial = false;
|
|
2920
3005
|
if (renderMaterial && scene) {
|
|
2921
3006
|
if (scene._hasStarted) attachMaterialToScene(renderMaterial, scene);
|
|
2922
3007
|
else adoptMaterialScene(renderMaterial, scene);
|
|
@@ -2931,6 +3016,30 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2931
3016
|
this._visible = value;
|
|
2932
3017
|
this._syncVisibility(this.isEnabled());
|
|
2933
3018
|
}
|
|
3019
|
+
/** Raw finite Babylon visibility; rendering clamps it to [0, 1]. Independent of isVisible. */
|
|
3020
|
+
get visibility() {
|
|
3021
|
+
return this._visibilityValue;
|
|
3022
|
+
}
|
|
3023
|
+
set visibility(value) {
|
|
3024
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError("Mesh.visibility must be a finite number.");
|
|
3025
|
+
const targets = this._opacityTargets();
|
|
3026
|
+
if (value < 1 && this._material) this._validateCompatOpacityMaterial("Mesh.visibility", this._material);
|
|
3027
|
+
for (const target of targets) {
|
|
3028
|
+
if (target._disposed) throw new Error(`Mesh "${target.name}" cannot set opacity: it was disposed when it left its last scene. Create a new mesh instead.`);
|
|
3029
|
+
if (value < 1) validateOpacityMaterial("Mesh.visibility", target.name ?? this.name, target.material);
|
|
3030
|
+
}
|
|
3031
|
+
for (const target of targets) setMeshOpacity(target, value);
|
|
3032
|
+
this._visibilityValue = value;
|
|
3033
|
+
}
|
|
3034
|
+
_validateCompatOpacityMaterial(api, material) {
|
|
3035
|
+
if (!material._lite) unsupported(api, `Mesh "${this.name}" cannot fade a deferred ${material.getClassName()} material; visibility below 1 supports only Standard and PBR materials.`);
|
|
3036
|
+
validateOpacityMaterial(api, this.name, material._lite);
|
|
3037
|
+
}
|
|
3038
|
+
/** A glTF node owns its immediate primitive meshes, never a child glTF node's primitives. */
|
|
3039
|
+
_opacityTargets() {
|
|
3040
|
+
const node = this._lite;
|
|
3041
|
+
return "_gpu" in node ? [node] : node.children.filter((child) => "_gpu" in child);
|
|
3042
|
+
}
|
|
2934
3043
|
get isPickable() {
|
|
2935
3044
|
return this._lite.pickable !== false;
|
|
2936
3045
|
}
|
|
@@ -3009,8 +3118,8 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3009
3118
|
}
|
|
3010
3119
|
/**
|
|
3011
3120
|
* Babylon.js `mesh.setVerticesData(kind, data)` — replace a vertex attribute.
|
|
3012
|
-
* `position` / `normal` / `uv` / `color` / `tangent` re-upload the geometry
|
|
3013
|
-
*
|
|
3121
|
+
* `position` / `normal` / `uv` / `color` / `tangent` re-upload the geometry, into the
|
|
3122
|
+
* existing GPU buffers when its layout is unchanged (`writeMeshGeometry`); the last-set `color`/`tangent` buffers are retained so successive calls
|
|
3014
3123
|
* (e.g. set tangent then set color) keep both. Skinning/morph attributes
|
|
3015
3124
|
* (`matricesIndices`, etc.) are accepted but not applied (Babylon Lite drives
|
|
3016
3125
|
* skinning through its own loaded-skeleton path).
|
|
@@ -3035,7 +3144,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3035
3144
|
const uvs2 = kind === "uv2" ? f32 : matchingVertexAttribute(this._lastUv2 ?? lite._cpuUv2s, vertexCount, 2);
|
|
3036
3145
|
const tangents = matchingVertexAttribute(this._lastTangents ?? lite._cpuTangents, vertexCount, 4);
|
|
3037
3146
|
const colors = matchingVertexAttribute(this._lastColors ?? lite._cpuColors, vertexCount, 4);
|
|
3038
|
-
|
|
3147
|
+
writeMeshGeometry(engine, this._lite, positions, normals, lite._cpuIndices, uvs, uvs2, tangents, colors);
|
|
3039
3148
|
}
|
|
3040
3149
|
/**
|
|
3041
3150
|
* Babylon.js `mesh.getIndices()` — read back the mesh's index (topology) buffer.
|
|
@@ -3049,8 +3158,8 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3049
3158
|
}
|
|
3050
3159
|
/**
|
|
3051
3160
|
* Babylon.js `mesh.setIndices(indices)` — replace the mesh's index (topology)
|
|
3052
|
-
* buffer.
|
|
3053
|
-
* keeping the existing position/normal/uv/tangent/color attributes and swapping
|
|
3161
|
+
* buffer. The geometry is re-uploaded through `writeMeshGeometry` (into the existing
|
|
3162
|
+
* buffers when the index count is unchanged), keeping the existing position/normal/uv/tangent/color attributes and swapping
|
|
3054
3163
|
* only the indices. Returns the mesh for chaining.
|
|
3055
3164
|
*/
|
|
3056
3165
|
setIndices(indices, _totalVertices, _updatable) {
|
|
@@ -3061,7 +3170,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3061
3170
|
const positions = lite._cpuPositions;
|
|
3062
3171
|
const vertexCount = positions.length / 3;
|
|
3063
3172
|
const normals = this._normalsFollowIndices ? computeFlatNormals(positions, u32) : matchingVertexAttribute(lite._cpuNormals, vertexCount, 3) ?? computeFlatNormals(positions, u32);
|
|
3064
|
-
|
|
3173
|
+
writeMeshGeometry(engine, this._lite, positions, normals, u32, matchingVertexAttribute(lite._cpuUvs, vertexCount, 2), matchingVertexAttribute(this._lastUv2 ?? lite._cpuUv2s, vertexCount, 2), matchingVertexAttribute(this._lastTangents ?? lite._cpuTangents, vertexCount, 4), matchingVertexAttribute(this._lastColors ?? lite._cpuColors, vertexCount, 4));
|
|
3065
3174
|
return this;
|
|
3066
3175
|
}
|
|
3067
3176
|
/** @internal Retained uv2/tangent/color buffers so successive `setVerticesData` (and a bake) keep them all. */
|
|
@@ -3154,7 +3263,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3154
3263
|
newTangents[i + 3] = tangents[i + 3];
|
|
3155
3264
|
}
|
|
3156
3265
|
}
|
|
3157
|
-
|
|
3266
|
+
writeMeshGeometry(engine, this._lite, newPositions, newNormals, bakedIndices, lite._cpuUvs, this._lastUv2 ?? lite._cpuUv2s ?? void 0, newTangents, this._lastColors ?? lite._cpuColors ?? void 0);
|
|
3158
3267
|
return true;
|
|
3159
3268
|
}
|
|
3160
3269
|
/**
|
|
@@ -3331,7 +3440,9 @@ var Mesh = class Mesh extends AbstractMesh {
|
|
|
3331
3440
|
}
|
|
3332
3441
|
static _wrapCloneHierarchy(source, lite, scene, parent, skipChildren, cloneName) {
|
|
3333
3442
|
if (cloneName !== void 0) lite.name = cloneName;
|
|
3334
|
-
const
|
|
3443
|
+
const isMesh = source instanceof Mesh || "_gpu" in lite && "material" in lite;
|
|
3444
|
+
if (isMesh) lite.id = void 0;
|
|
3445
|
+
const wrapper = isMesh ? new Mesh(lite.name ?? "", lite) : new TransformNode(lite.name ?? "", scene, lite);
|
|
3335
3446
|
wrapper._container = source?._container;
|
|
3336
3447
|
if (wrapper instanceof Mesh) {
|
|
3337
3448
|
wrapper._scene = scene;
|
|
@@ -3343,6 +3454,7 @@ var Mesh = class Mesh extends AbstractMesh {
|
|
|
3343
3454
|
wrapper.metadata = source.metadata;
|
|
3344
3455
|
wrapper.setEnabled(source.isEnabled(false));
|
|
3345
3456
|
if (wrapper instanceof Mesh && source instanceof Mesh) {
|
|
3457
|
+
wrapper._visibilityValue = source._visibilityValue;
|
|
3346
3458
|
if (source._liteOnlyMaterial) wrapper._liteOnlyMaterial = true;
|
|
3347
3459
|
else wrapper.material = source.material;
|
|
3348
3460
|
wrapper.isVisible = source.isVisible;
|
|
@@ -3579,7 +3691,8 @@ var VertexData = class {
|
|
|
3579
3691
|
/**
|
|
3580
3692
|
* Babylon.js `VertexData.applyToMesh(mesh)` — upload this CPU geometry onto a
|
|
3581
3693
|
* mesh (typically one created via `new Mesh(name, scene)`). Replaces the Lite
|
|
3582
|
-
* mesh's geometry
|
|
3694
|
+
* mesh's geometry through `writeMeshGeometry` (into the existing buffers when the
|
|
3695
|
+
* layout is unchanged, new ones otherwise). Normals are computed flat
|
|
3583
3696
|
* if omitted (Babylon Lite requires a normals buffer).
|
|
3584
3697
|
*/
|
|
3585
3698
|
applyToMesh(mesh) {
|
|
@@ -3592,7 +3705,7 @@ var VertexData = class {
|
|
|
3592
3705
|
const normals = this.normals ? toF32(this.normals) : computeFlatNormals(positions, indices);
|
|
3593
3706
|
const uvs = this.uvs ? toF32(this.uvs) : void 0;
|
|
3594
3707
|
const colors = this.colors ? toF32(this.colors) : void 0;
|
|
3595
|
-
|
|
3708
|
+
writeMeshGeometry(engine, mesh._lite, positions, normals, indices, uvs, void 0, void 0, colors);
|
|
3596
3709
|
}
|
|
3597
3710
|
/** Merge another `VertexData` into this one (concatenating attributes + reindexing). */
|
|
3598
3711
|
merge(other) {
|
|
@@ -3856,7 +3969,6 @@ var PolygonBuilder = {
|
|
|
3856
3969
|
* methods directly, so importing or calling this function requires no mutation.
|
|
3857
3970
|
*/
|
|
3858
3971
|
function RegisterPolygonBuilder() {}
|
|
3859
|
-
//#endregion
|
|
3860
3972
|
export { Vector4 as $, PBRClearCoatConfiguration as A, Observable as B, RegisterPolygonBuilder as C, registerMeshAtStart as D, VertexData as E, PBRSpecularGlossinessMaterial as F, transformCoordinates as G, BoundingInfo as H, PushMaterial as I, Color3 as J, transformNormal as K, StandardMaterial as L, PBRMaterial as M, PBRMetallicRoughnessMaterial as N, Material as O, PBRSheenConfiguration as P, Vector3 as Q, attachMaterialToScene as R, PolygonBuilder as S, VertexBuffer as T, BoundingSphere as U, BoundingBox as V, Matrix as W, liteBackedColor3 as X, Color4 as Y, Vector2 as Z, GroundMesh as _, CreateDisc as a, Mesh as b, CreateLines as c, CreatePolygonVertexData as d, liteBackedVector3 as et, CreateSphere as f, ExtrudePolygon as g, CreateTorus as h, CreateDashedLines as i, PBRIridescenceConfiguration as j, PBRAnisotropicConfiguration as k, CreatePlane as l, CreateTiledPlane as m, CreateBox as n, unsupported as nt, CreateGround as o, CreateTiledBox as p, Quaternion as q, CreateCylinder as r, CreateLineSystem as s, AbstractMesh as t, LiteCompatError as tt, CreatePolygon as u, InstancedMesh as v, TransformNode as w, MeshBuilder as x, LinesMesh as y, Node as z };
|
|
3861
3973
|
|
|
3862
|
-
//# sourceMappingURL=meshes-
|
|
3974
|
+
//# sourceMappingURL=meshes-Bt_UAqXU.js.map
|