@babylonjs/lite-compat 1.38.0-preview → 1.38.1-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/{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 +82 -16
- package/index.js +377 -158
- package/index.js.map +1 -1
- package/{meshes-sOWGK4P8.js → meshes-CTqDBeGc.js} +132 -54
- package/meshes-CTqDBeGc.js.map +1 -0
- package/navigation.d.ts +78 -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, 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, 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
|
*
|
|
@@ -2766,12 +2812,28 @@ function computeFlatNormals(positions, indices) {
|
|
|
2766
2812
|
function matchingVertexAttribute(data, vertexCount, components) {
|
|
2767
2813
|
return data?.length === vertexCount * components ? data : void 0;
|
|
2768
2814
|
}
|
|
2815
|
+
/** @internal Whether an optional attribute keeps the presence and length its GPU buffer was created with. */
|
|
2816
|
+
function keepsAttributeLayout(values, present, length) {
|
|
2817
|
+
return !!values?.length === !!present && (!present || values.length === length);
|
|
2818
|
+
}
|
|
2819
|
+
/**
|
|
2820
|
+
* @internal Write new geometry into a Lite mesh. When the vertex and index counts and the attribute layout are
|
|
2821
|
+
* unchanged, `updateMeshGeometry` rewrites the existing GPU buffers, so the buffers, the mesh's renderable and every
|
|
2822
|
+
* recorded bundle stay valid. Anything else goes through `resizeMeshGeometry`, which allocates new buffers and makes
|
|
2823
|
+
* every scene re-record its bundles. The in-place conditions are `updateMeshGeometry`'s own, plus geometry that only
|
|
2824
|
+
* this mesh writes (no clone sharing it, no borrowed vertex slab or shared index buffer) and no active draw range.
|
|
2825
|
+
*/
|
|
2826
|
+
function writeMeshGeometry(engine, mesh, positions, normals, indices, uvs, uvs2, tangents, colors) {
|
|
2827
|
+
const gpu = mesh._gpu;
|
|
2828
|
+
const vertexCount = positions.length / 3;
|
|
2829
|
+
(!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);
|
|
2830
|
+
}
|
|
2769
2831
|
/**
|
|
2770
2832
|
* Babylon.js `TransformNode` — a positioned, rotated, scaled scene-graph node.
|
|
2771
2833
|
* Wraps a Lite scene node (`_node`): either a standalone Lite transform node, or
|
|
2772
2834
|
* (for meshes) the Lite mesh itself, which also carries the transform.
|
|
2773
2835
|
*/
|
|
2774
|
-
var TransformNode = class extends Node {
|
|
2836
|
+
var TransformNode = class TransformNode extends Node {
|
|
2775
2837
|
/** @internal The Lite scene node that carries this transform. */
|
|
2776
2838
|
_node;
|
|
2777
2839
|
physicsBody = null;
|
|
@@ -2845,6 +2907,13 @@ var TransformNode = class extends Node {
|
|
|
2845
2907
|
} else this._useQuat = false;
|
|
2846
2908
|
}
|
|
2847
2909
|
/**
|
|
2910
|
+
* Babylon.js `getChildTransformNodes(directDescendantsOnly?, predicate?)` — the descendants that are transform nodes
|
|
2911
|
+
* (meshes included). As in Babylon.js, `predicate` is called on every evaluated descendant.
|
|
2912
|
+
*/
|
|
2913
|
+
getChildTransformNodes(directDescendantsOnly, predicate) {
|
|
2914
|
+
return this.getDescendants(directDescendantsOnly, (node) => (!predicate || predicate(node)) && node instanceof TransformNode);
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2848
2917
|
* Babylon.js `setParent(node)` — reparent while **preserving world position**
|
|
2849
2918
|
* (the child's local transform is recomputed). Distinct from the `parent`
|
|
2850
2919
|
* setter, which keeps the local transform and lets the world move.
|
|
@@ -2909,6 +2978,13 @@ var AbstractMesh = class extends TransformNode {
|
|
|
2909
2978
|
_isMeshNode() {
|
|
2910
2979
|
return true;
|
|
2911
2980
|
}
|
|
2981
|
+
/**
|
|
2982
|
+
* @internal Take this mesh out of every light's filter lists before it goes, as Babylon.js
|
|
2983
|
+
* `AbstractMesh.dispose` does in its own `Lights` loop. Container-retired wrappers prune too.
|
|
2984
|
+
*/
|
|
2985
|
+
_retireFromScene() {
|
|
2986
|
+
for (const light of this._scene?.lights ?? []) light._pruneDisposedMesh(this);
|
|
2987
|
+
}
|
|
2912
2988
|
get material() {
|
|
2913
2989
|
return this._material;
|
|
2914
2990
|
}
|
|
@@ -3009,8 +3085,8 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3009
3085
|
}
|
|
3010
3086
|
/**
|
|
3011
3087
|
* Babylon.js `mesh.setVerticesData(kind, data)` — replace a vertex attribute.
|
|
3012
|
-
* `position` / `normal` / `uv` / `color` / `tangent` re-upload the geometry
|
|
3013
|
-
*
|
|
3088
|
+
* `position` / `normal` / `uv` / `color` / `tangent` re-upload the geometry, into the
|
|
3089
|
+
* existing GPU buffers when its layout is unchanged (`writeMeshGeometry`); the last-set `color`/`tangent` buffers are retained so successive calls
|
|
3014
3090
|
* (e.g. set tangent then set color) keep both. Skinning/morph attributes
|
|
3015
3091
|
* (`matricesIndices`, etc.) are accepted but not applied (Babylon Lite drives
|
|
3016
3092
|
* skinning through its own loaded-skeleton path).
|
|
@@ -3035,7 +3111,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3035
3111
|
const uvs2 = kind === "uv2" ? f32 : matchingVertexAttribute(this._lastUv2 ?? lite._cpuUv2s, vertexCount, 2);
|
|
3036
3112
|
const tangents = matchingVertexAttribute(this._lastTangents ?? lite._cpuTangents, vertexCount, 4);
|
|
3037
3113
|
const colors = matchingVertexAttribute(this._lastColors ?? lite._cpuColors, vertexCount, 4);
|
|
3038
|
-
|
|
3114
|
+
writeMeshGeometry(engine, this._lite, positions, normals, lite._cpuIndices, uvs, uvs2, tangents, colors);
|
|
3039
3115
|
}
|
|
3040
3116
|
/**
|
|
3041
3117
|
* Babylon.js `mesh.getIndices()` — read back the mesh's index (topology) buffer.
|
|
@@ -3049,8 +3125,8 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3049
3125
|
}
|
|
3050
3126
|
/**
|
|
3051
3127
|
* 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
|
|
3128
|
+
* buffer. The geometry is re-uploaded through `writeMeshGeometry` (into the existing
|
|
3129
|
+
* buffers when the index count is unchanged), keeping the existing position/normal/uv/tangent/color attributes and swapping
|
|
3054
3130
|
* only the indices. Returns the mesh for chaining.
|
|
3055
3131
|
*/
|
|
3056
3132
|
setIndices(indices, _totalVertices, _updatable) {
|
|
@@ -3061,7 +3137,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3061
3137
|
const positions = lite._cpuPositions;
|
|
3062
3138
|
const vertexCount = positions.length / 3;
|
|
3063
3139
|
const normals = this._normalsFollowIndices ? computeFlatNormals(positions, u32) : matchingVertexAttribute(lite._cpuNormals, vertexCount, 3) ?? computeFlatNormals(positions, u32);
|
|
3064
|
-
|
|
3140
|
+
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
3141
|
return this;
|
|
3066
3142
|
}
|
|
3067
3143
|
/** @internal Retained uv2/tangent/color buffers so successive `setVerticesData` (and a bake) keep them all. */
|
|
@@ -3154,7 +3230,7 @@ var AbstractMesh = class extends TransformNode {
|
|
|
3154
3230
|
newTangents[i + 3] = tangents[i + 3];
|
|
3155
3231
|
}
|
|
3156
3232
|
}
|
|
3157
|
-
|
|
3233
|
+
writeMeshGeometry(engine, this._lite, newPositions, newNormals, bakedIndices, lite._cpuUvs, this._lastUv2 ?? lite._cpuUv2s ?? void 0, newTangents, this._lastColors ?? lite._cpuColors ?? void 0);
|
|
3158
3234
|
return true;
|
|
3159
3235
|
}
|
|
3160
3236
|
/**
|
|
@@ -3331,7 +3407,9 @@ var Mesh = class Mesh extends AbstractMesh {
|
|
|
3331
3407
|
}
|
|
3332
3408
|
static _wrapCloneHierarchy(source, lite, scene, parent, skipChildren, cloneName) {
|
|
3333
3409
|
if (cloneName !== void 0) lite.name = cloneName;
|
|
3334
|
-
const
|
|
3410
|
+
const isMesh = source instanceof Mesh || "_gpu" in lite && "material" in lite;
|
|
3411
|
+
if (isMesh) lite.id = void 0;
|
|
3412
|
+
const wrapper = isMesh ? new Mesh(lite.name ?? "", lite) : new TransformNode(lite.name ?? "", scene, lite);
|
|
3335
3413
|
wrapper._container = source?._container;
|
|
3336
3414
|
if (wrapper instanceof Mesh) {
|
|
3337
3415
|
wrapper._scene = scene;
|
|
@@ -3579,7 +3657,8 @@ var VertexData = class {
|
|
|
3579
3657
|
/**
|
|
3580
3658
|
* Babylon.js `VertexData.applyToMesh(mesh)` — upload this CPU geometry onto a
|
|
3581
3659
|
* mesh (typically one created via `new Mesh(name, scene)`). Replaces the Lite
|
|
3582
|
-
* mesh's geometry
|
|
3660
|
+
* mesh's geometry through `writeMeshGeometry` (into the existing buffers when the
|
|
3661
|
+
* layout is unchanged, new ones otherwise). Normals are computed flat
|
|
3583
3662
|
* if omitted (Babylon Lite requires a normals buffer).
|
|
3584
3663
|
*/
|
|
3585
3664
|
applyToMesh(mesh) {
|
|
@@ -3592,7 +3671,7 @@ var VertexData = class {
|
|
|
3592
3671
|
const normals = this.normals ? toF32(this.normals) : computeFlatNormals(positions, indices);
|
|
3593
3672
|
const uvs = this.uvs ? toF32(this.uvs) : void 0;
|
|
3594
3673
|
const colors = this.colors ? toF32(this.colors) : void 0;
|
|
3595
|
-
|
|
3674
|
+
writeMeshGeometry(engine, mesh._lite, positions, normals, indices, uvs, void 0, void 0, colors);
|
|
3596
3675
|
}
|
|
3597
3676
|
/** Merge another `VertexData` into this one (concatenating attributes + reindexing). */
|
|
3598
3677
|
merge(other) {
|
|
@@ -3856,7 +3935,6 @@ var PolygonBuilder = {
|
|
|
3856
3935
|
* methods directly, so importing or calling this function requires no mutation.
|
|
3857
3936
|
*/
|
|
3858
3937
|
function RegisterPolygonBuilder() {}
|
|
3859
|
-
//#endregion
|
|
3860
3938
|
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
3939
|
|
|
3862
|
-
//# sourceMappingURL=meshes-
|
|
3940
|
+
//# sourceMappingURL=meshes-CTqDBeGc.js.map
|