@babylonjs/core 8.50.5 → 8.51.0
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/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -2
- package/AudioV2/webAudio/webAudioSoundSource.js +12 -2
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/Cameras/geospatialCamera.js +21 -20
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +8 -1
- package/Cameras/geospatialCameraMovement.js +29 -8
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Instrumentation/engineInstrumentation.js +2 -1
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +52 -12
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +86 -0
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +160 -0
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -0
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.constants.d.ts +2 -1
- package/Maths/math.constants.js +3 -2
- package/Maths/math.constants.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +4 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Misc/dataStorage.d.ts +13 -0
- package/Misc/dataStorage.js +25 -0
- package/Misc/dataStorage.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +8 -2
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +8 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +7 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +8 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Color3 } from "../../Maths/math.color.js";
|
|
2
|
+
import { MaterialPluginBase } from "../materialPluginBase.js";
|
|
3
|
+
import { RegisterClass } from "../../Misc/typeStore.js";
|
|
4
|
+
/**
|
|
5
|
+
* Plugin for GaussianSplattingMaterial that replaces per-splat colors with a
|
|
6
|
+
* solid color per compound-mesh part. Each part index maps to a single Color3
|
|
7
|
+
* value, which is looked up in a uniform array in the fragment shader.
|
|
8
|
+
*/
|
|
9
|
+
export class GaussianSplattingSolidColorMaterialPlugin extends MaterialPluginBase {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new GaussianSplatSolidColorPlugin.
|
|
12
|
+
* @param material The GaussianSplattingMaterial to attach the plugin to.
|
|
13
|
+
* @param partColors A map from part index to the solid Color3 for that part.
|
|
14
|
+
* @param maxPartCount The maximum number of parts supported (default 256). This determines the size of the uniform array.
|
|
15
|
+
*/
|
|
16
|
+
constructor(material, partColors, maxPartCount = 256) {
|
|
17
|
+
super(material, "GaussianSplatSolidColor", 200);
|
|
18
|
+
this._partColors = partColors;
|
|
19
|
+
this._maxPartCount = maxPartCount;
|
|
20
|
+
this._enable(true);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Updates the part colors dynamically.
|
|
24
|
+
* @param partColors A map from part index to the solid Color3 for that part.
|
|
25
|
+
*/
|
|
26
|
+
updatePartColors(partColors) {
|
|
27
|
+
this._partColors = partColors;
|
|
28
|
+
}
|
|
29
|
+
// --- Plugin overrides ---
|
|
30
|
+
/**
|
|
31
|
+
* @returns the class name
|
|
32
|
+
*/
|
|
33
|
+
getClassName() {
|
|
34
|
+
return "GaussianSplattingSolidColorMaterialPlugin";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Indicates this plugin supports both GLSL and WGSL.
|
|
38
|
+
* @param shaderLanguage the shader language to check
|
|
39
|
+
* @returns true for GLSL and WGSL
|
|
40
|
+
*/
|
|
41
|
+
isCompatible(shaderLanguage) {
|
|
42
|
+
switch (shaderLanguage) {
|
|
43
|
+
case 0 /* ShaderLanguage.GLSL */:
|
|
44
|
+
case 1 /* ShaderLanguage.WGSL */:
|
|
45
|
+
return true;
|
|
46
|
+
default:
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Always ready — no textures or async resources to wait on.
|
|
52
|
+
* @param _defines the defines
|
|
53
|
+
* @param _scene the scene
|
|
54
|
+
* @param _engine the engine
|
|
55
|
+
* @param _subMesh the submesh
|
|
56
|
+
* @returns true
|
|
57
|
+
*/
|
|
58
|
+
isReadyForSubMesh(_defines, _scene, _engine, _subMesh) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns custom shader code fragments to inject solid-color rendering.
|
|
63
|
+
*
|
|
64
|
+
* @param shaderType "vertex" or "fragment"
|
|
65
|
+
* @param shaderLanguage the shader language to use (default: GLSL)
|
|
66
|
+
* @returns null or a map of injection point names to code strings
|
|
67
|
+
*/
|
|
68
|
+
getCustomCode(shaderType, shaderLanguage = 0 /* ShaderLanguage.GLSL */) {
|
|
69
|
+
const maxPartCount = this._maxPartCount ?? 256;
|
|
70
|
+
if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
71
|
+
return this._getCustomCodeWGSL(shaderType, maxPartCount);
|
|
72
|
+
}
|
|
73
|
+
return this._getCustomCodeGLSL(shaderType, maxPartCount);
|
|
74
|
+
}
|
|
75
|
+
_getCustomCodeGLSL(shaderType, maxPartCount) {
|
|
76
|
+
if (shaderType === "vertex") {
|
|
77
|
+
return {
|
|
78
|
+
CUSTOM_VERTEX_DEFINITIONS: `varying float vPartIndex;`,
|
|
79
|
+
CUSTOM_VERTEX_UPDATE: `
|
|
80
|
+
#if IS_COMPOUND
|
|
81
|
+
vPartIndex = float(splat.partIndex);
|
|
82
|
+
#else
|
|
83
|
+
vPartIndex = 0.0;
|
|
84
|
+
#endif
|
|
85
|
+
`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
else if (shaderType === "fragment") {
|
|
89
|
+
return {
|
|
90
|
+
CUSTOM_FRAGMENT_DEFINITIONS: `
|
|
91
|
+
varying float vPartIndex;
|
|
92
|
+
uniform vec3 partColors[${maxPartCount}];
|
|
93
|
+
`,
|
|
94
|
+
CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: `
|
|
95
|
+
int partIdx = int(vPartIndex + 0.5);
|
|
96
|
+
finalColor = vec4(partColors[partIdx], finalColor.w);
|
|
97
|
+
`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
_getCustomCodeWGSL(shaderType, maxPartCount) {
|
|
103
|
+
if (shaderType === "vertex") {
|
|
104
|
+
return {
|
|
105
|
+
CUSTOM_VERTEX_DEFINITIONS: `varying vPartIndex: f32;`,
|
|
106
|
+
CUSTOM_VERTEX_UPDATE: `
|
|
107
|
+
#if IS_COMPOUND
|
|
108
|
+
vertexOutputs.vPartIndex = f32(splat.partIndex);
|
|
109
|
+
#else
|
|
110
|
+
vertexOutputs.vPartIndex = 0.0;
|
|
111
|
+
#endif
|
|
112
|
+
`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
else if (shaderType === "fragment") {
|
|
116
|
+
return {
|
|
117
|
+
CUSTOM_FRAGMENT_DEFINITIONS: `
|
|
118
|
+
varying vPartIndex: f32;
|
|
119
|
+
uniform partColors: array<vec3f, ${maxPartCount}>;
|
|
120
|
+
`,
|
|
121
|
+
CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: `
|
|
122
|
+
var partIdx: i32 = i32(fragmentInputs.vPartIndex + 0.5);
|
|
123
|
+
finalColor = vec4f(uniforms.partColors[partIdx], finalColor.w);
|
|
124
|
+
`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Registers the `partColors` uniform with the engine so that
|
|
131
|
+
* the Effect can resolve its location.
|
|
132
|
+
* @returns uniform descriptions
|
|
133
|
+
*/
|
|
134
|
+
getUniforms() {
|
|
135
|
+
return {
|
|
136
|
+
externalUniforms: ["partColors"],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Binds the `partColors` uniform array each frame.
|
|
141
|
+
* @param _uniformBuffer the uniform buffer (unused — we bind directly on the effect)
|
|
142
|
+
* @param _scene the current scene
|
|
143
|
+
* @param _engine the current engine
|
|
144
|
+
* @param subMesh the submesh being rendered
|
|
145
|
+
*/
|
|
146
|
+
bindForSubMesh(_uniformBuffer, _scene, _engine, subMesh) {
|
|
147
|
+
const effect = subMesh.effect;
|
|
148
|
+
if (!effect) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const colorArray = [];
|
|
152
|
+
for (let i = 0; i < this._maxPartCount; i++) {
|
|
153
|
+
const color = this._partColors[i] ?? new Color3(0, 0, 0);
|
|
154
|
+
colorArray.push(color.r, color.g, color.b);
|
|
155
|
+
}
|
|
156
|
+
effect.setArray3("partColors", colorArray);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
RegisterClass("BABYLON.GaussianSplattingSolidColorMaterialPlugin", GaussianSplattingSolidColorMaterialPlugin);
|
|
160
|
+
//# sourceMappingURL=gaussianSplattingSolidColorMaterialPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gaussianSplattingSolidColorMaterialPlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.ts"],"names":[],"m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KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACzD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC;CACJ;AAED,aAAa,CAAC,mDAAmD,EAAE,yCAAyC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { SubMesh } from \"../../Meshes/subMesh\";\r\nimport type { UniformBuffer } from \"../uniformBuffer\";\r\nimport type { MaterialDefines } from \"../materialDefines\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { MaterialPluginBase } from \"../materialPluginBase\";\r\nimport { ShaderLanguage } from \"../shaderLanguage\";\r\nimport { RegisterClass } from \"../../Misc/typeStore\";\r\nimport type { GaussianSplattingMaterial } from \"./gaussianSplattingMaterial\";\r\n\r\n/**\r\n * Plugin for GaussianSplattingMaterial that replaces per-splat colors with a\r\n * solid color per compound-mesh part. Each part index maps to a single Color3\r\n * value, which is looked up in a uniform array in the fragment shader.\r\n */\r\nexport class GaussianSplattingSolidColorMaterialPlugin extends MaterialPluginBase {\r\n private _partColors: Color3[];\r\n private _maxPartCount: number;\r\n\r\n /**\r\n * Creates a new GaussianSplatSolidColorPlugin.\r\n * @param material The GaussianSplattingMaterial to attach the plugin to.\r\n * @param partColors A map from part index to the solid Color3 for that part.\r\n * @param maxPartCount The maximum number of parts supported (default 256). This determines the size of the uniform array.\r\n */\r\n constructor(material: GaussianSplattingMaterial, partColors: Color3[], maxPartCount = 256) {\r\n super(material, \"GaussianSplatSolidColor\", 200);\r\n\r\n this._partColors = partColors;\r\n this._maxPartCount = maxPartCount;\r\n this._enable(true);\r\n }\r\n\r\n /**\r\n * Updates the part colors dynamically.\r\n * @param partColors A map from part index to the solid Color3 for that part.\r\n */\r\n public updatePartColors(partColors: Color3[]): void {\r\n this._partColors = partColors;\r\n }\r\n\r\n // --- Plugin overrides ---\r\n\r\n /**\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"GaussianSplattingSolidColorMaterialPlugin\";\r\n }\r\n\r\n /**\r\n * Indicates this plugin supports both GLSL and WGSL.\r\n * @param shaderLanguage the shader language to check\r\n * @returns true for GLSL and WGSL\r\n */\r\n public override isCompatible(shaderLanguage: ShaderLanguage): boolean {\r\n switch (shaderLanguage) {\r\n case ShaderLanguage.GLSL:\r\n case ShaderLanguage.WGSL:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Always ready — no textures or async resources to wait on.\r\n * @param _defines the defines\r\n * @param _scene the scene\r\n * @param _engine the engine\r\n * @param _subMesh the submesh\r\n * @returns true\r\n */\r\n public override isReadyForSubMesh(_defines: MaterialDefines, _scene: Scene, _engine: AbstractEngine, _subMesh: SubMesh): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns custom shader code fragments to inject solid-color rendering.\r\n *\r\n * @param shaderType \"vertex\" or \"fragment\"\r\n * @param shaderLanguage the shader language to use (default: GLSL)\r\n * @returns null or a map of injection point names to code strings\r\n */\r\n public override getCustomCode(shaderType: string, shaderLanguage = ShaderLanguage.GLSL): Nullable<{ [pointName: string]: string }> {\r\n const maxPartCount = this._maxPartCount ?? 256;\r\n\r\n if (shaderLanguage === ShaderLanguage.WGSL) {\r\n return this._getCustomCodeWGSL(shaderType, maxPartCount);\r\n }\r\n return this._getCustomCodeGLSL(shaderType, maxPartCount);\r\n }\r\n\r\n private _getCustomCodeGLSL(shaderType: string, maxPartCount: number): Nullable<{ [pointName: string]: string }> {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n CUSTOM_VERTEX_DEFINITIONS: `varying float vPartIndex;`,\r\n CUSTOM_VERTEX_UPDATE: `\r\n#if IS_COMPOUND\r\n vPartIndex = float(splat.partIndex);\r\n#else\r\n vPartIndex = 0.0;\r\n#endif\r\n `,\r\n };\r\n } else if (shaderType === \"fragment\") {\r\n return {\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\nvarying float vPartIndex;\r\nuniform vec3 partColors[${maxPartCount}];\r\n `,\r\n CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: `\r\nint partIdx = int(vPartIndex + 0.5);\r\nfinalColor = vec4(partColors[partIdx], finalColor.w);\r\n `,\r\n };\r\n }\r\n return null;\r\n }\r\n\r\n private _getCustomCodeWGSL(shaderType: string, maxPartCount: number): Nullable<{ [pointName: string]: string }> {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n CUSTOM_VERTEX_DEFINITIONS: `varying vPartIndex: f32;`,\r\n CUSTOM_VERTEX_UPDATE: `\r\n#if IS_COMPOUND\r\n vertexOutputs.vPartIndex = f32(splat.partIndex);\r\n#else\r\n vertexOutputs.vPartIndex = 0.0;\r\n#endif\r\n `,\r\n };\r\n } else if (shaderType === \"fragment\") {\r\n return {\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\nvarying vPartIndex: f32;\r\nuniform partColors: array<vec3f, ${maxPartCount}>;\r\n `,\r\n CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: `\r\nvar partIdx: i32 = i32(fragmentInputs.vPartIndex + 0.5);\r\nfinalColor = vec4f(uniforms.partColors[partIdx], finalColor.w);\r\n `,\r\n };\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Registers the `partColors` uniform with the engine so that\r\n * the Effect can resolve its location.\r\n * @returns uniform descriptions\r\n */\r\n public override getUniforms(): {\r\n ubo?: Array<{ name: string; size?: number; type?: string; arraySize?: number }>;\r\n vertex?: string;\r\n fragment?: string;\r\n externalUniforms?: string[];\r\n } {\r\n return {\r\n externalUniforms: [\"partColors\"],\r\n };\r\n }\r\n\r\n /**\r\n * Binds the `partColors` uniform array each frame.\r\n * @param _uniformBuffer the uniform buffer (unused — we bind directly on the effect)\r\n * @param _scene the current scene\r\n * @param _engine the current engine\r\n * @param subMesh the submesh being rendered\r\n */\r\n public override bindForSubMesh(_uniformBuffer: UniformBuffer, _scene: Scene, _engine: AbstractEngine, subMesh: SubMesh): void {\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n\r\n const colorArray: number[] = [];\r\n for (let i = 0; i < this._maxPartCount; i++) {\r\n const color = this._partColors[i] ?? new Color3(0, 0, 0);\r\n colorArray.push(color.r, color.g, color.b);\r\n }\r\n\r\n effect.setArray3(\"partColors\", colorArray);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GaussianSplattingSolidColorMaterialPlugin\", GaussianSplattingSolidColorMaterialPlugin);\r\n"]}
|
package/Materials/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export * from "./GreasedLine/greasedLineMaterialInterfaces.js";
|
|
|
37
37
|
export * from "./GreasedLine/greasedLineMaterialDefaults.js";
|
|
38
38
|
export * from "./meshDebugPluginMaterial.js";
|
|
39
39
|
export * from "./GaussianSplatting/gaussianSplattingMaterial.js";
|
|
40
|
+
export * from "./GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js";
|
|
40
41
|
export * from "./materialHelper.functions.js";
|
|
41
42
|
export * from "./materialHelper.geometryrendering.js";
|
|
42
43
|
export * from "./materialStencilState.js";
|
package/Materials/index.js
CHANGED
|
@@ -38,6 +38,7 @@ export * from "./GreasedLine/greasedLineMaterialInterfaces.js";
|
|
|
38
38
|
export * from "./GreasedLine/greasedLineMaterialDefaults.js";
|
|
39
39
|
export * from "./meshDebugPluginMaterial.js";
|
|
40
40
|
export * from "./GaussianSplatting/gaussianSplattingMaterial.js";
|
|
41
|
+
export * from "./GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js";
|
|
41
42
|
export * from "./materialHelper.functions.js";
|
|
42
43
|
export * from "./materialHelper.geometryrendering.js";
|
|
43
44
|
export * from "./materialStencilState.js";
|
package/Materials/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,OAAO,qBAAqB,CAAC;AAE7B,uBAAuB;AAEvB,mBAAmB;AACnB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAE9C,2BAA2B;AAC3B,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./Background/index\";\r\nexport * from \"./colorCurves\";\r\nexport * from \"./iEffectFallbacks\";\r\nexport * from \"./effectFallbacks\";\r\nexport * from \"./effect\";\r\nexport * from \"./fresnelParameters\";\r\nexport * from \"./imageProcessing\";\r\nexport * from \"./imageProcessingConfiguration\";\r\nexport * from \"./material\";\r\nexport * from \"./materialDefines\";\r\nexport * from \"./clipPlaneMaterialHelper\";\r\nexport * from \"./materialHelper\";\r\nexport * from \"./multiMaterial\";\r\nexport * from \"./Occlusion/index\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./pushMaterial\";\r\nexport * from \"./shaderLanguage\";\r\nexport * from \"./shaderMaterial\";\r\nexport * from \"./standardMaterial\";\r\nexport * from \"./Textures/index\";\r\nexport * from \"./uniformBuffer\";\r\nexport * from \"./materialFlags\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./effectRenderer\";\r\nexport * from \"./shadowDepthWrapper\";\r\nexport * from \"./drawWrapper.functions\";\r\nexport * from \"./drawWrapper\";\r\nexport * from \"./materialPluginBase\";\r\nexport * from \"./materialPluginManager\";\r\nexport * from \"./materialPluginEvent\";\r\nexport * from \"./material.detailMapConfiguration\";\r\nexport * from \"./material.decalMapConfiguration\";\r\nexport * from \"./materialPluginFactoryExport\";\r\nexport * from \"./GreasedLine/greasedLinePluginMaterial\";\r\nexport * from \"./GreasedLine/greasedLineSimpleMaterial\";\r\nexport * from \"./GreasedLine/greasedLineMaterialInterfaces\";\r\nexport * from \"./GreasedLine/greasedLineMaterialDefaults\";\r\nexport * from \"./meshDebugPluginMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMaterial\";\r\nexport * from \"./materialHelper.functions\";\r\nexport * from \"./materialHelper.geometryrendering\";\r\nexport * from \"./materialStencilState\";\r\nexport * from \"./uv.defines\";\r\nexport * from \"./floatingOriginMatrixOverrides\";\r\nexport * from \"./vertexPullingHelper.functions\";\r\nimport \"./material.decalMap\";\r\n\r\n// async-loaded shaders\r\n\r\n// StandardMaterial\r\nexport * from \"../Shaders/default.fragment\";\r\nexport * from \"../Shaders/default.vertex\";\r\nexport * from \"../ShadersWGSL/default.fragment\";\r\nexport * from \"../ShadersWGSL/default.vertex\";\r\n\r\n// GreasedLineSimplMaterial\r\nexport * from \"../Shaders/greasedLine.fragment\";\r\nexport * from \"../Shaders/greasedLine.vertex\";\r\nexport * from \"../ShadersWGSL/greasedLine.fragment\";\r\nexport * from \"../ShadersWGSL/greasedLine.vertex\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,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from \"./colorCurves\";\r\nexport * from \"./iEffectFallbacks\";\r\nexport * from \"./effectFallbacks\";\r\nexport * from \"./effect\";\r\nexport * from \"./fresnelParameters\";\r\nexport * from \"./imageProcessing\";\r\nexport * from \"./imageProcessingConfiguration\";\r\nexport * from \"./material\";\r\nexport * from \"./materialDefines\";\r\nexport * from \"./clipPlaneMaterialHelper\";\r\nexport * from \"./materialHelper\";\r\nexport * from \"./multiMaterial\";\r\nexport * from \"./Occlusion/index\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./pushMaterial\";\r\nexport * from \"./shaderLanguage\";\r\nexport * from \"./shaderMaterial\";\r\nexport * from \"./standardMaterial\";\r\nexport * from \"./Textures/index\";\r\nexport * from \"./uniformBuffer\";\r\nexport * from \"./materialFlags\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./effectRenderer\";\r\nexport * from \"./shadowDepthWrapper\";\r\nexport * from \"./drawWrapper.functions\";\r\nexport * from \"./drawWrapper\";\r\nexport * from \"./materialPluginBase\";\r\nexport * from \"./materialPluginManager\";\r\nexport * from \"./materialPluginEvent\";\r\nexport * from \"./material.detailMapConfiguration\";\r\nexport * from \"./material.decalMapConfiguration\";\r\nexport * from \"./materialPluginFactoryExport\";\r\nexport * from \"./GreasedLine/greasedLinePluginMaterial\";\r\nexport * from \"./GreasedLine/greasedLineSimpleMaterial\";\r\nexport * from \"./GreasedLine/greasedLineMaterialInterfaces\";\r\nexport * from \"./GreasedLine/greasedLineMaterialDefaults\";\r\nexport * from \"./meshDebugPluginMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin\";\r\nexport * from \"./materialHelper.functions\";\r\nexport * from \"./materialHelper.geometryrendering\";\r\nexport * from \"./materialStencilState\";\r\nexport * from \"./uv.defines\";\r\nexport * from \"./floatingOriginMatrixOverrides\";\r\nexport * from \"./vertexPullingHelper.functions\";\r\nimport \"./material.decalMap\";\r\n\r\n// async-loaded shaders\r\n\r\n// StandardMaterial\r\nexport * from \"../Shaders/default.fragment\";\r\nexport * from \"../Shaders/default.vertex\";\r\nexport * from \"../ShadersWGSL/default.fragment\";\r\nexport * from \"../ShadersWGSL/default.vertex\";\r\n\r\n// GreasedLineSimplMaterial\r\nexport * from \"../Shaders/greasedLine.fragment\";\r\nexport * from \"../Shaders/greasedLine.vertex\";\r\nexport * from \"../ShadersWGSL/greasedLine.fragment\";\r\nexport * from \"../ShadersWGSL/greasedLine.vertex\";\r\n"]}
|
|
@@ -12,6 +12,7 @@ export declare const ToLinearSpace = 2.2;
|
|
|
12
12
|
export declare const PHI: number;
|
|
13
13
|
/**
|
|
14
14
|
* Constant used to define the minimal number value in Babylon.js
|
|
15
|
+
* Exported as "let" so advanced users can override the epsilon value in supported build targets (for example via the global BABYLON.Epsilon)
|
|
15
16
|
* @ignorenaming
|
|
16
17
|
*/
|
|
17
|
-
export declare
|
|
18
|
+
export declare let Epsilon: number;
|
package/Maths/math.constants.js
CHANGED
|
@@ -15,8 +15,9 @@ export const ToLinearSpace = 2.2;
|
|
|
15
15
|
export const PHI = (1 + Math.sqrt(5)) / 2;
|
|
16
16
|
/**
|
|
17
17
|
* Constant used to define the minimal number value in Babylon.js
|
|
18
|
+
* Exported as "let" so advanced users can override the epsilon value in supported build targets (for example via the global BABYLON.Epsilon)
|
|
18
19
|
* @ignorenaming
|
|
19
20
|
*/
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
|
-
export
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, prefer-const
|
|
22
|
+
export let Epsilon = 0.001;
|
|
22
23
|
//# sourceMappingURL=math.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.constants.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,GAAG,CAAC;AAEpC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"math.constants.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,GAAG,CAAC;AAEpC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAE1C;;;;GAIG;AACH,8EAA8E;AAC9E,MAAM,CAAC,IAAI,OAAO,GAAG,KAAK,CAAC","sourcesContent":["/**\r\n * Constant used to convert a value to gamma space\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToGammaSpace = 1 / 2.2;\r\n\r\n/**\r\n * Constant used to convert a value to linear space\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToLinearSpace = 2.2;\r\n\r\n/**\r\n * Constant Golden Ratio value in Babylon.js\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const PHI = (1 + Math.sqrt(5)) / 2;\r\n\r\n/**\r\n * Constant used to define the minimal number value in Babylon.js\r\n * Exported as \"let\" so advanced users can override the epsilon value in supported build targets (for example via the global BABYLON.Epsilon)\r\n * @ignorenaming\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention, prefer-const\r\nexport let Epsilon = 0.001;\r\n"]}
|
|
@@ -4,7 +4,7 @@ import { VertexData } from "../mesh.vertexData.js";
|
|
|
4
4
|
import { Matrix, TmpVectors, Vector2, Vector3 } from "../../Maths/math.vector.js";
|
|
5
5
|
import { Quaternion } from "../../Maths/math.vector.js";
|
|
6
6
|
import { Logger } from "../../Misc/logger.js";
|
|
7
|
-
import { GaussianSplattingMaterial } from "../../Materials/GaussianSplatting/gaussianSplattingMaterial.js";
|
|
7
|
+
import { GaussianSplattingMaterial, GaussianSplattingMaxPartCount } from "../../Materials/GaussianSplatting/gaussianSplattingMaterial.js";
|
|
8
8
|
import { RawTexture } from "../../Materials/Textures/rawTexture.js";
|
|
9
9
|
|
|
10
10
|
import "../thinInstanceMesh.js";
|
|
@@ -1785,6 +1785,9 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
1785
1785
|
* @returns a placeholder mesh that can be used to manipulate the part transform
|
|
1786
1786
|
*/
|
|
1787
1787
|
addPart(other, disposeOther = true) {
|
|
1788
|
+
if (this.partCount >= GaussianSplattingMaxPartCount) {
|
|
1789
|
+
throw new Error(`Cannot add part, as the maximum part count (${GaussianSplattingMaxPartCount}) has been reached`);
|
|
1790
|
+
}
|
|
1788
1791
|
const splatCountA = this._vertexCount;
|
|
1789
1792
|
const splatsDataA = splatCountA == 0 ? new ArrayBuffer(0) : this.splatsData;
|
|
1790
1793
|
const shDataA = this.shData;
|