@onerjs/core 8.40.1 → 8.40.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/Engines/WebGPU/webgpuHardwareTexture.js +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +5 -3
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +2 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.js +12 -1
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +2 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +31 -11
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Maths/math.path.d.ts +11 -6
- package/Maths/math.path.js +86 -25
- package/Maths/math.path.js.map +1 -1
- package/Maths/math.vector.d.ts +24 -0
- package/Maths/math.vector.js +39 -5
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +7 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +80 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Rendering/depthRenderer.d.ts +9 -0
- package/Rendering/depthRenderer.js +42 -6
- package/Rendering/depthRenderer.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.fragment.js +11 -4
- package/Shaders/gaussianSplattingDepth.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.fragment.js +9 -3
- package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +2 -1
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Scene } from "../../scene.js";
|
|
2
|
-
import type { Nullable } from "../../types.js";
|
|
2
|
+
import type { DeepImmutable, Nullable } from "../../types.js";
|
|
3
3
|
import type { BaseTexture } from "../../Materials/Textures/baseTexture.js";
|
|
4
4
|
import { SubMesh } from "../subMesh.js";
|
|
5
5
|
import type { AbstractMesh } from "../abstractMesh.js";
|
|
@@ -518,5 +518,11 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
518
518
|
* @param index - The index of the part to remove
|
|
519
519
|
*/
|
|
520
520
|
removePart(index: number): void;
|
|
521
|
+
/**
|
|
522
|
+
* Modifies the splats according to the passed transformation matrix.
|
|
523
|
+
* @param transform defines the transform matrix to use
|
|
524
|
+
* @returns the current mesh
|
|
525
|
+
*/
|
|
526
|
+
bakeTransformIntoVertices(transform: DeepImmutable<Matrix>): Mesh;
|
|
521
527
|
}
|
|
522
528
|
export {};
|
|
@@ -547,9 +547,16 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
547
547
|
if (!cameraViewInfos || !cameraViewInfos.splatIndexBufferSet) {
|
|
548
548
|
return this;
|
|
549
549
|
}
|
|
550
|
+
if (this.onBeforeRenderObservable) {
|
|
551
|
+
this.onBeforeRenderObservable.notifyObservers(this);
|
|
552
|
+
}
|
|
550
553
|
const mesh = cameraViewInfos.mesh;
|
|
551
554
|
mesh.getWorldMatrix().copyFrom(this.getWorldMatrix());
|
|
552
|
-
|
|
555
|
+
const ret = mesh.render(subMesh, enableAlphaMode, effectiveMeshReplacement);
|
|
556
|
+
if (this.onAfterRenderObservable) {
|
|
557
|
+
this.onAfterRenderObservable.notifyObservers(this);
|
|
558
|
+
}
|
|
559
|
+
return ret;
|
|
553
560
|
}
|
|
554
561
|
static _TypeNameToEnum(name) {
|
|
555
562
|
switch (name) {
|
|
@@ -1370,7 +1377,7 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1370
1377
|
return new RawTexture(data, width, height, format, this._scene, false, false, 2, 2);
|
|
1371
1378
|
};
|
|
1372
1379
|
const firstTime = this._covariancesATexture === null;
|
|
1373
|
-
const textureSizeChanged = this._textureSize.y
|
|
1380
|
+
const textureSizeChanged = this._textureSize.y != textureSize.y;
|
|
1374
1381
|
if (!firstTime && !textureSizeChanged) {
|
|
1375
1382
|
this._delayedTextureUpdate = { covA, covB, colors: colorArray, centers: this._splatPositions, sh, partIndices };
|
|
1376
1383
|
const positions = Float32Array.from(this._splatPositions);
|
|
@@ -1557,7 +1564,7 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1557
1564
|
// in case size is different
|
|
1558
1565
|
_updateSplatIndexBuffer(vertexCount) {
|
|
1559
1566
|
const paddedVertexCount = (vertexCount + 15) & ~0xf;
|
|
1560
|
-
if (!this._splatIndex || vertexCount
|
|
1567
|
+
if (!this._splatIndex || vertexCount != this._splatIndex.length) {
|
|
1561
1568
|
this._splatIndex = new Float32Array(paddedVertexCount);
|
|
1562
1569
|
for (let i = 0; i < paddedVertexCount; i++) {
|
|
1563
1570
|
this._splatIndex[i] = i;
|
|
@@ -1568,10 +1575,10 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1568
1575
|
});
|
|
1569
1576
|
}
|
|
1570
1577
|
// Update depthMix
|
|
1571
|
-
if ((!this._depthMix || vertexCount
|
|
1578
|
+
if ((!this._depthMix || vertexCount != this._depthMix.length) && !IsNative) {
|
|
1572
1579
|
this._depthMix = new BigInt64Array(paddedVertexCount);
|
|
1573
1580
|
}
|
|
1574
|
-
this.forcedInstanceCount = paddedVertexCount >> 4;
|
|
1581
|
+
this.forcedInstanceCount = Math.max(paddedVertexCount >> 4, 1);
|
|
1575
1582
|
}
|
|
1576
1583
|
_updateSubTextures(centers, covA, covB, colors, lineStart, lineCount, sh, partIndices) {
|
|
1577
1584
|
const updateTextureFromData = (texture, data, width, lineStart, lineCount) => {
|
|
@@ -1917,8 +1924,6 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1917
1924
|
}
|
|
1918
1925
|
writeIndex++;
|
|
1919
1926
|
}
|
|
1920
|
-
// Update the mesh with the new data
|
|
1921
|
-
this.updateData(newSplatsData.buffer, newShData, { flipY: false }, newPartIndices);
|
|
1922
1927
|
// Remove the part matrix and visibility
|
|
1923
1928
|
this._partMatrices.splice(index, 1);
|
|
1924
1929
|
this._partVisibility.splice(index, 1);
|
|
@@ -1926,6 +1931,8 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1926
1931
|
if (this._worker) {
|
|
1927
1932
|
this._worker.postMessage({ partMatrices: this._partMatrices.map((matrix) => new Float32Array(matrix.m)) });
|
|
1928
1933
|
}
|
|
1934
|
+
// Update the mesh with the new data
|
|
1935
|
+
this.updateData(newSplatsData.buffer, newShData, { flipY: false }, newPartIndices);
|
|
1929
1936
|
// Dispose and remove the proxy for the removed part
|
|
1930
1937
|
const proxyToRemove = this._partProxies.get(index);
|
|
1931
1938
|
if (proxyToRemove) {
|
|
@@ -1946,7 +1953,72 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1946
1953
|
proxy.updatePartIndex(oldIndex - 1);
|
|
1947
1954
|
this._partProxies.set(oldIndex - 1, proxy);
|
|
1948
1955
|
}
|
|
1949
|
-
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Modifies the splats according to the passed transformation matrix.
|
|
1959
|
+
* @param transform defines the transform matrix to use
|
|
1960
|
+
* @returns the current mesh
|
|
1961
|
+
*/
|
|
1962
|
+
bakeTransformIntoVertices(transform) {
|
|
1963
|
+
const arrayBuffer = this.splatsData;
|
|
1964
|
+
if (!arrayBuffer) {
|
|
1965
|
+
Logger.Error("Cannot bake transform into vertices if splatsData is not kept in RAM");
|
|
1966
|
+
return this;
|
|
1967
|
+
}
|
|
1968
|
+
// Check for uniform scaling
|
|
1969
|
+
const m = transform.m;
|
|
1970
|
+
const scaleX = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
|
|
1971
|
+
const scaleY = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
|
|
1972
|
+
const scaleZ = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
|
|
1973
|
+
const epsilon = 0.001;
|
|
1974
|
+
if (Math.abs(scaleX - scaleY) > epsilon || Math.abs(scaleX - scaleZ) > epsilon) {
|
|
1975
|
+
Logger.Error("Gaussian Splatting bakeTransformIntoVertices does not support non-uniform scaling");
|
|
1976
|
+
return this;
|
|
1977
|
+
}
|
|
1978
|
+
const uBuffer = new Uint8Array(arrayBuffer);
|
|
1979
|
+
const fBuffer = new Float32Array(arrayBuffer);
|
|
1980
|
+
const temp = TmpVectors.Vector3[0];
|
|
1981
|
+
let index;
|
|
1982
|
+
const quaternion = TmpVectors.Quaternion[0];
|
|
1983
|
+
const transformedQuaternion = TmpVectors.Quaternion[1];
|
|
1984
|
+
transform.decompose(temp, transformedQuaternion, temp);
|
|
1985
|
+
for (index = 0; index < this._vertexCount; index++) {
|
|
1986
|
+
const floatIndex = index * 8; // 8 floats per splat (center.x, center.y, center.z, scale.x, scale.y, scale.z, ...)
|
|
1987
|
+
Vector3.TransformCoordinatesFromFloatsToRef(fBuffer[floatIndex], fBuffer[floatIndex + 1], fBuffer[floatIndex + 2], transform, temp);
|
|
1988
|
+
fBuffer[floatIndex] = temp.x;
|
|
1989
|
+
fBuffer[floatIndex + 1] = temp.y;
|
|
1990
|
+
fBuffer[floatIndex + 2] = temp.z;
|
|
1991
|
+
// Apply uniform scaling to splat scales
|
|
1992
|
+
fBuffer[floatIndex + 3] *= scaleX;
|
|
1993
|
+
fBuffer[floatIndex + 4] *= scaleX;
|
|
1994
|
+
fBuffer[floatIndex + 5] *= scaleX;
|
|
1995
|
+
// Unpack quaternion from uint8array (matching _GetSplat packing convention)
|
|
1996
|
+
quaternion.set((uBuffer[32 * index + 28 + 1] - 127.5) / 127.5, (uBuffer[32 * index + 28 + 2] - 127.5) / 127.5, (uBuffer[32 * index + 28 + 3] - 127.5) / 127.5, (uBuffer[32 * index + 28 + 0] - 127.5) / 127.5);
|
|
1997
|
+
quaternion.normalize();
|
|
1998
|
+
// If there is a negative scaling, we need to flip the quaternion to keep the correct handedness
|
|
1999
|
+
if (this.scaling.x < 0) {
|
|
2000
|
+
quaternion.x = -quaternion.x;
|
|
2001
|
+
quaternion.w = -quaternion.w;
|
|
2002
|
+
}
|
|
2003
|
+
if (this.scaling.y < 0) {
|
|
2004
|
+
quaternion.y = -quaternion.y;
|
|
2005
|
+
quaternion.w = -quaternion.w;
|
|
2006
|
+
}
|
|
2007
|
+
if (this.scaling.z < 0) {
|
|
2008
|
+
quaternion.z = -quaternion.z;
|
|
2009
|
+
quaternion.w = -quaternion.w;
|
|
2010
|
+
}
|
|
2011
|
+
// Transform the quaternion
|
|
2012
|
+
transformedQuaternion.multiplyToRef(quaternion, quaternion);
|
|
2013
|
+
quaternion.normalize();
|
|
2014
|
+
// Pack quaternion back to uint8array (matching _GetSplat packing convention)
|
|
2015
|
+
uBuffer[32 * index + 28 + 0] = Math.round(quaternion.w * 127.5 + 127.5);
|
|
2016
|
+
uBuffer[32 * index + 28 + 1] = Math.round(quaternion.x * 127.5 + 127.5);
|
|
2017
|
+
uBuffer[32 * index + 28 + 2] = Math.round(quaternion.y * 127.5 + 127.5);
|
|
2018
|
+
uBuffer[32 * index + 28 + 3] = Math.round(quaternion.z * 127.5 + 127.5);
|
|
2019
|
+
}
|
|
2020
|
+
this.updateData(arrayBuffer, this.shData ?? undefined, { flipY: false });
|
|
2021
|
+
return this;
|
|
1950
2022
|
}
|
|
1951
2023
|
}
|
|
1952
2024
|
GaussianSplattingMesh._RowOutputLength = 3 * 4 + 3 * 4 + 4 + 4; // Vector3 position, Vector3 scale, 1 u8 quaternion, 1 color with alpha
|