@babylonjs/core 6.12.2 → 6.12.4

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.
@@ -0,0 +1,267 @@
1
+ import { MaterialPluginBase } from "./materialPluginBase";
2
+ import type { Scene } from "../scene";
3
+ import type { UniformBuffer } from "./uniformBuffer";
4
+ import type { Nullable } from "../types";
5
+ import { MaterialDefines } from "./materialDefines";
6
+ import type { PBRBaseMaterial } from "./PBR/pbrBaseMaterial";
7
+ import type { StandardMaterial } from "./standardMaterial";
8
+ import { Color3 } from "../Maths/math.js";
9
+ import type { Mesh } from "../Meshes/mesh.js";
10
+ import type { AbstractMesh } from "../Meshes/abstractMesh.js";
11
+ /**
12
+ * Supported visualizations of MeshDebugPluginMaterial
13
+ */
14
+ export declare enum MeshDebugMode {
15
+ /**
16
+ * Material without any mesh debug visualization
17
+ */
18
+ NONE = 0,
19
+ /**
20
+ * A wireframe of the mesh
21
+ * NOTE: For this mode to work correctly, convertToUnIndexedMesh() or MeshDebugPluginMaterial.PrepareMeshForTrianglesAndVerticesMode() must first be called on mesh.
22
+ */
23
+ TRIANGLES = 1,
24
+ /**
25
+ * Points drawn over vertices of mesh
26
+ * NOTE: For this mode to work correctly, MeshDebugPluginMaterial.PrepareMeshForTrianglesAndVerticesMode() must first be called on mesh.
27
+ */
28
+ VERTICES = 2,
29
+ /**
30
+ * A wireframe of the mesh, with points drawn over vertices
31
+ * NOTE: For this mode to work correctly, MeshDebugPluginMaterial.PrepareMeshForTrianglesAndVerticesMode() must first be called on mesh.
32
+ */
33
+ TRIANGLES_VERTICES = 3,
34
+ /**
35
+ * A checkerboard grid of the mesh's UV set 0
36
+ */
37
+ UV0 = 4,
38
+ /**
39
+ * A checkerboard grid of the mesh's UV set 1
40
+ */
41
+ UV1 = 5,
42
+ /**
43
+ * The mesh's vertex colors displayed as the primary texture
44
+ */
45
+ VERTEXCOLORS = 6,
46
+ /**
47
+ * An arbitrary, distinguishable color to identify the material
48
+ */
49
+ MATERIALIDS = 7
50
+ }
51
+ /**
52
+ * Options for MeshDebugPluginMaterial that are given at initialization
53
+ */
54
+ export interface MeshDebugOptions {
55
+ /**
56
+ * The mesh debug visualization.
57
+ * Defaults to NONE.
58
+ */
59
+ mode?: MeshDebugMode;
60
+ /**
61
+ * Whether the mesh debug visualization should multiply with color underneath.
62
+ * Defaults to true.
63
+ */
64
+ multiply?: boolean;
65
+ /**
66
+ * Diffuse color used to shade the mesh.
67
+ * Defaults to (1.0, 1.0, 1.0).
68
+ */
69
+ shadedDiffuseColor?: Color3;
70
+ /**
71
+ * Specular color used to shade the mesh.
72
+ * Defaults to (0.8, 0.8, 0.8).
73
+ */
74
+ shadedSpecularColor?: Color3;
75
+ /**
76
+ * Specular power used to shade the mesh.
77
+ * Defaults to 10.
78
+ */
79
+ shadedSpecularPower?: number;
80
+ /**
81
+ * Width of edge lines in TRIANGLES and TRIANGLE_VERTICES modes.
82
+ * Defaults to 0.7.
83
+ */
84
+ wireframeThickness?: number;
85
+ /**
86
+ * Color of edge lines in TRIANGLES mode.
87
+ * Defaults to (0.0, 0.0, 0.0).
88
+ */
89
+ wireframeTrianglesColor?: Color3;
90
+ /**
91
+ * Color of edge lines in TRIANGLES_VERTICES modes.
92
+ * Defaults to (0.8, 0.8, 0.8).
93
+ */
94
+ wireframeVerticesColor?: Color3;
95
+ /**
96
+ * Color of vertices in TRIANGLES_VERTICES and VERTICES mode.
97
+ * Defaults to (0.0, 0.0, 0.0).
98
+ */
99
+ vertexColor?: Color3;
100
+ /**
101
+ * Radius of dots drawn over vertices in TRIANGLE_VERTICES and VERTICES mode.
102
+ * Defaults to 1.2.
103
+ */
104
+ vertexRadius?: number;
105
+ /**
106
+ * Size of tiles in UV1 or UV2 modes.
107
+ * Defaults to 20.
108
+ */
109
+ uvScale?: number;
110
+ /**
111
+ * 1st color of checkerboard grid in UV1 or UV2 modes.
112
+ * Defaults to (1.0, 1.0, 1.0).
113
+ */
114
+ uvPrimaryColor?: Color3;
115
+ /**
116
+ * 2nd color of checkerboard grid in UV1 or UV2 modes.
117
+ * Defaults to (0.5, 0.5, 0.5).
118
+ */
119
+ uvSecondaryColor?: Color3;
120
+ }
121
+ /** @internal */
122
+ declare class MeshDebugDefines extends MaterialDefines {
123
+ /**
124
+ * Current mesh debug visualization.
125
+ * Defaults to NONE.
126
+ */
127
+ DBG_MODE: MeshDebugMode;
128
+ /**
129
+ * Whether the mesh debug visualization multiplies with colors underneath.
130
+ * Defaults to true.
131
+ */
132
+ DBG_MULTIPLY: boolean;
133
+ /**
134
+ * Whether the mesh debug plugin is enabled in the material.
135
+ * Defaults to true.
136
+ */
137
+ DBG_ENABLED: boolean;
138
+ }
139
+ /**
140
+ * Plugin that implements various mesh debug visualizations,
141
+ * List of available visualizations can be found in MeshDebugMode enum.
142
+ */
143
+ export declare class MeshDebugPluginMaterial extends MaterialPluginBase {
144
+ /**
145
+ * Total number of instances of the plugin.
146
+ * Starts at 0.
147
+ */
148
+ private static _PluginCount;
149
+ /**
150
+ * Color palette used for MATERIALIDS mode.
151
+ * Defaults to `defaultMaterialColors`
152
+ */
153
+ static MaterialColors: Color3[];
154
+ /**
155
+ * Options for the plugin.
156
+ * See MeshDebugOptions interface for defaults.
157
+ */
158
+ private _options;
159
+ /**
160
+ * Material ID color of this plugin instance.
161
+ * Taken from index `_PluginCount` of `MaterialColors` at time of instantiation.
162
+ */
163
+ private _materialColor;
164
+ /**
165
+ * Whether the mesh debug plugin is enabled in the material.
166
+ * Defaults to true in constructor.
167
+ */
168
+ private _isEnabled;
169
+ private _mode;
170
+ /**
171
+ * Current mesh debug visualization.
172
+ * Defaults to NONE.
173
+ */
174
+ mode: MeshDebugMode;
175
+ private _multiply;
176
+ /**
177
+ * Whether the mesh debug visualization multiplies with colors underneath.
178
+ * Defaults to true.
179
+ */
180
+ multiply: boolean;
181
+ /** @internal */
182
+ protected _markAllDefinesAsDirty(): void;
183
+ /**
184
+ * Creates a new MeshDebugPluginMaterial
185
+ * @param material Material to attach the mesh debug plugin to
186
+ * @param options Options for the mesh debug plugin
187
+ */
188
+ constructor(material: PBRBaseMaterial | StandardMaterial, options?: MeshDebugOptions);
189
+ /**
190
+ * Get the class name
191
+ * @returns Class name
192
+ */
193
+ getClassName(): string;
194
+ /**
195
+ * Gets whether the mesh debug plugin is enabled in the material.
196
+ */
197
+ get isEnabled(): boolean;
198
+ /**
199
+ * Sets whether the mesh debug plugin is enabled in the material.
200
+ * @param value enabled
201
+ */
202
+ set isEnabled(value: boolean);
203
+ /**
204
+ * Prepare the defines
205
+ * @param defines Mesh debug defines
206
+ * @param scene Scene
207
+ * @param mesh Mesh associated with material
208
+ */
209
+ prepareDefines(defines: MeshDebugDefines, scene: Scene, mesh: AbstractMesh): void;
210
+ /**
211
+ * Get the shader attributes
212
+ * @param attributes Array of attributes
213
+ */
214
+ getAttributes(attributes: string[]): void;
215
+ /**
216
+ * Get the shader uniforms
217
+ * @returns Uniforms
218
+ */
219
+ getUniforms(): {
220
+ ubo: {
221
+ name: string;
222
+ size: number;
223
+ type: string;
224
+ }[];
225
+ fragment: string;
226
+ };
227
+ /**
228
+ * Bind the uniform buffer
229
+ * @param uniformBuffer Uniform buffer
230
+ */
231
+ bindForSubMesh(uniformBuffer: UniformBuffer): void;
232
+ /**
233
+ * Get shader code
234
+ * @param shaderType "vertex" or "fragment"
235
+ * @returns Shader code
236
+ */
237
+ getCustomCode(shaderType: string): Nullable<{
238
+ [pointName: string]: string;
239
+ }>;
240
+ /**
241
+ * Serializes this plugin material
242
+ * @returns serialized object
243
+ */
244
+ serialize(): any;
245
+ /**
246
+ * Parses a serialized object
247
+ * @param serializationObject serialized object
248
+ * @param scene scene
249
+ * @param rootUrl root url for textures
250
+ */
251
+ parse(serializationObject: any, scene: Scene, rootUrl: string): void;
252
+ /**
253
+ * Resets static variables of the plugin to their original state
254
+ */
255
+ static Reset(): void;
256
+ /**
257
+ * Renders triangles in a mesh 3 times by tripling the indices in the index buffer.
258
+ * Used to prepare a mesh to be rendered in `TRIANGLES`, `VERTICES`, or `TRIANGLES_VERTICES` modes.
259
+ * NOTE: This is a destructive operation. The mesh's index buffer and vertex buffers are modified, and a new vertex buffer is allocated.
260
+ * If you'd like the ability to revert these changes, toggle the optional `returnRollback` flag.
261
+ * @param mesh the mesh to target
262
+ * @param returnRollback whether or not to return a function that reverts mesh to its initial state. Default: false.
263
+ * @returns a rollback function if `returnRollback` is true, otherwise an empty function.
264
+ */
265
+ static PrepareMeshForTrianglesAndVerticesMode(mesh: Mesh, returnRollback?: boolean): () => void;
266
+ }
267
+ export {};