@mlightcad/mtext-renderer 0.4.2 → 0.4.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,57 @@
1
+ /**
2
+ * Utility class for temporarily disabling `BufferGeometry.computeVertexNormals`.
3
+ *
4
+ * By default, Three.js computes vertex normals for many geometries,
5
+ * which can be unnecessary (e.g., when using `MeshBasicMaterial` that does not require lighting).
6
+ * This class lets you temporarily replace `computeVertexNormals` with a no-op
7
+ * to save CPU time during geometry creation.
8
+ *
9
+ * Example:
10
+ * ```ts
11
+ * import { TextGeometry } from "three/examples/jsm/geometries/TextGeometry.js";
12
+ * import { NormalComputationToggle } from "./NormalComputationToggle";
13
+ *
14
+ * // Create geometry without computing normals
15
+ * const textGeom = NormalComputationToggle.runWithoutNormals(() =>
16
+ * new TextGeometry("Fast!", { font, size: 1, height: 0.2 })
17
+ * );
18
+ * ```
19
+ */
20
+ export declare class NormalComputationToggle {
21
+ /**
22
+ * Stores the original `computeVertexNormals` method from BufferGeometry.
23
+ */
24
+ private static originalComputeVertexNormals;
25
+ /**
26
+ * Dummy replacement for `computeVertexNormals` that does nothing.
27
+ */
28
+ private static dummyComputeVertexNormals;
29
+ /**
30
+ * Disable vertex normal computation globally.
31
+ *
32
+ * After calling this, all calls to `computeVertexNormals`
33
+ * will do nothing until {@link restore} is called.
34
+ */
35
+ static disable(): void;
36
+ /**
37
+ * Restore the original `computeVertexNormals` implementation.
38
+ */
39
+ static restore(): void;
40
+ /**
41
+ * Execute a function with normal computation disabled,
42
+ * then automatically restore afterwards.
43
+ *
44
+ * This is the safest way to create geometries without normals.
45
+ *
46
+ * Example:
47
+ * ```ts
48
+ * const geom = NormalComputationToggle.runWithoutNormals(() =>
49
+ * new TextGeometry("World", { font, size: 1, height: 0.2 })
50
+ * );
51
+ * ```
52
+ *
53
+ * @param fn - A callback that creates the geometry.
54
+ * @returns The result of the callback, e.g., a geometry.
55
+ */
56
+ static runWithoutNormals<T>(fn: () => T): T;
57
+ }