@needle-tools/engine 4.13.1 → 4.14.0-beta
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/CHANGELOG.md +9 -0
- package/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-DiCnZlf3.js +21 -0
- package/dist/gltf-progressive-Bm_6aEi4.js +1528 -0
- package/dist/gltf-progressive-BttGBXw6.umd.cjs +10 -0
- package/dist/gltf-progressive-T5WKTux5.min.js +10 -0
- package/dist/loader.worker-BqODMeeW.js +23 -0
- package/dist/{materialx-B9ddsHcF.min.js → materialx-CJyQZtjt.min.js} +1 -1
- package/dist/{materialx-fkoFuRh3.js → materialx-DMs1E08Z.js} +2 -2
- package/dist/{materialx-BF23AVE8.umd.cjs → materialx-DaKKOoVk.umd.cjs} +1 -1
- package/dist/needle-engine.bundle-BW2VusZV.min.js +1646 -0
- package/dist/{needle-engine.bundle-tjI5Fq2c.umd.cjs → needle-engine.bundle-Cb5bKEqa.umd.cjs} +152 -159
- package/dist/{needle-engine.bundle-DauZUYl7.js → needle-engine.bundle-D9VPvp5o.js} +7798 -7497
- package/dist/needle-engine.d.ts +779 -42
- package/dist/needle-engine.js +416 -415
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-BVNrgYZK.min.js → postprocessing-CctM1XIO.min.js} +1 -1
- package/dist/{postprocessing-DdM-tz1j.js → postprocessing-DGm6qJ-I.js} +2 -2
- package/dist/{postprocessing-CI2TjWpu.umd.cjs → postprocessing-Dbl2PJpd.umd.cjs} +1 -1
- package/dist/{three-BW2s1Yl-.umd.cjs → three-BjYim-vL.umd.cjs} +4 -4
- package/dist/{three-VvRoMeIN.js → three-Bvk2VKbF.js} +4210 -4210
- package/dist/{three-I__hSXzr.min.js → three-IG2qPafA.min.js} +33 -33
- package/dist/{three-examples-Bpfu6ke_.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +1 -1
- package/dist/{three-examples-BhfOE7NG.js → three-examples-CMYCd5nH.js} +1 -1
- package/dist/{three-examples-D8zAE_7t.min.js → three-examples-CQl1fFZp.min.js} +1 -1
- package/dist/{three-mesh-ui-C3QbemOV.min.js → three-mesh-ui-5HVE2RV-.min.js} +1 -1
- package/dist/{three-mesh-ui-CcMp-FQm.js → three-mesh-ui-BlakAItG.js} +1 -1
- package/dist/{three-mesh-ui-BU55xDxJ.umd.cjs → three-mesh-ui-D828VbQp.umd.cjs} +1 -1
- package/dist/{vendor-DW7zqjuT.min.js → vendor-BxK0WKmT.min.js} +1 -1
- package/dist/{vendor-COVQl0b8.umd.cjs → vendor-CIDkyBaO.umd.cjs} +1 -1
- package/dist/{vendor-BiyIZ61v.js → vendor-ixwD-vv2.js} +1 -1
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.js +12 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_lightdata.js +8 -6
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +259 -0
- package/lib/engine/engine_materialpropertyblock.js +682 -0
- package/lib/engine/engine_materialpropertyblock.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +1 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +171 -14
- package/lib/engine/engine_utils_screenshot.js +65 -0
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.xr.d.ts +1 -1
- package/lib/engine/engine_utils_screenshot.xr.js +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +5 -0
- package/lib/engine/xr/NeedleXRSession.js +5 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +32 -4
- package/lib/engine-components/ReflectionProbe.js +58 -88
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +2 -0
- package/lib/engine-components/Renderer.js +30 -6
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RendererLightmap.d.ts +13 -9
- package/lib/engine-components/RendererLightmap.js +67 -81
- package/lib/engine-components/RendererLightmap.js.map +1 -1
- package/lib/engine-components/SeeThrough.d.ts +0 -2
- package/lib/engine-components/SeeThrough.js +114 -88
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js +6 -0
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +1 -0
- package/lib/engine-components/utils/OpenURL.js +1 -0
- package/lib/engine-components/utils/OpenURL.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +1 -0
- package/lib/engine-components/web/CursorFollow.js +1 -0
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +1 -0
- package/lib/engine-components/web/ScrollFollow.js +1 -0
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +2 -2
- package/lib/engine-components/web/ViewBox.js +2 -2
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +1 -0
- package/lib/engine-components/webxr/WebXR.js +1 -0
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.js.map +1 -1
- package/lib/engine-components/webxr/controllers/XRControllerFollow.js.map +1 -1
- package/lib/engine-components/webxr/controllers/XRControllerMovement.js.map +1 -1
- package/package.json +5 -5
- package/plugins/vite/build-pipeline.js +16 -2
- package/src/engine/api.ts +1 -0
- package/src/engine/engine_context.ts +17 -3
- package/src/engine/engine_lightdata.ts +8 -6
- package/src/engine/engine_materialpropertyblock.ts +866 -0
- package/src/engine/engine_utils.ts +1 -0
- package/src/engine/engine_utils_screenshot.ts +241 -17
- package/src/engine/engine_utils_screenshot.xr.ts +1 -1
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +3 -0
- package/src/engine/xr/NeedleXRSession.ts +5 -0
- package/src/engine-components/Camera.ts +2 -2
- package/src/engine-components/ContactShadows.ts +1 -1
- package/src/engine-components/DropListener.ts +1 -1
- package/src/engine-components/Duplicatable.ts +1 -1
- package/src/engine-components/GroundProjection.ts +3 -0
- package/src/engine-components/NeedleMenu.ts +3 -0
- package/src/engine-components/NestedGltf.ts +1 -1
- package/src/engine-components/ReflectionProbe.ts +64 -105
- package/src/engine-components/Renderer.ts +34 -6
- package/src/engine-components/RendererLightmap.ts +75 -87
- package/src/engine-components/SeeThrough.ts +124 -109
- package/src/engine-components/SmoothFollow.ts +2 -2
- package/src/engine-components/VideoPlayer.ts +6 -0
- package/src/engine-components/ui/Button.ts +1 -1
- package/src/engine-components/ui/Raycaster.ts +1 -1
- package/src/engine-components/utils/OpenURL.ts +1 -0
- package/src/engine-components/web/CursorFollow.ts +1 -0
- package/src/engine-components/web/ScrollFollow.ts +1 -0
- package/src/engine-components/web/ViewBox.ts +9 -2
- package/src/engine-components/webxr/WebARCameraBackground.ts +12 -3
- package/src/engine-components/webxr/WebXR.ts +1 -0
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +3 -3
- package/src/engine-components/webxr/controllers/XRControllerFollow.ts +1 -1
- package/src/engine-components/webxr/controllers/XRControllerMovement.ts +4 -4
- package/dist/generateMeshBVH.worker-iyfPIK6R.js +0 -21
- package/dist/gltf-progressive-BURrJW0U.umd.cjs +0 -8
- package/dist/gltf-progressive-DHLDFNvQ.min.js +0 -8
- package/dist/gltf-progressive-eiJCrjLb.js +0 -1400
- package/dist/loader.worker-C1GG9A7C.js +0 -23
- package/dist/needle-engine.bundle-BNIUpreS.min.js +0 -1653
- package/src/include/three/DragControls.js +0 -232
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine_lightdata.js","sourceRoot":"","sources":["../../src/engine/engine_lightdata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAW,
|
|
1
|
+
{"version":3,"file":"engine_lightdata.js","sourceRoot":"","sources":["../../src/engine/engine_lightdata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAW,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,MAAM,aAAa,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAWhE,gEAAgE;AAChE,sEAAsE;AACtE,gFAAgF;AAEhF,+DAA+D;AAC/D,wGAAwG;AACxG,mDAAmD;AAEnD,MAAM,OAAO,iBAAiB;IAET,OAAO,CAAU;IACjB,GAAG,GAAwD,IAAI,GAAG,EAAE,CAAC;IAEtF,KAAK;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,YAAY,OAAgB;QACxB,IAAI,CAAC,OAA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MnI,CAAC,CAAC;AAEP,WAAW,CAAC,sBAAsB,GAAG;;;;;;;;;;KAUhC,CAAC;AAEN,sFAAsF;AACtF,kDAAkD;AAClD,0GAA0G;AAC1G,gFAAgF;AAChF,WAAW,CAAC,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC,OAAO,CACzE,uEAAuE,EAAE;;;;;OAKtE,CAAC,CAAC;AAET,yDAAyD;AACzD,6EAA6E;AAC7E,+EAA+E"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Material, Object3D, Color, Texture, Vector2, Vector3, Vector4, Euler } from "three";
|
|
2
|
+
/**
|
|
3
|
+
* Valid types that can be used as material property overrides
|
|
4
|
+
*/
|
|
5
|
+
type MaterialPropertyType = number | number[] | Color | Texture | Vector2 | Vector3 | Vector4 | null | Euler;
|
|
6
|
+
/**
|
|
7
|
+
* Defines offset and repeat transformations for texture coordinates
|
|
8
|
+
*/
|
|
9
|
+
export interface TextureTransform {
|
|
10
|
+
/** UV offset applied to the texture */
|
|
11
|
+
offset?: Vector2;
|
|
12
|
+
/** UV repeat/scale applied to the texture */
|
|
13
|
+
repeat?: Vector2;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a single material property override with optional texture transformation
|
|
17
|
+
* @template T The type of the property value
|
|
18
|
+
*/
|
|
19
|
+
export interface PropertyBlockOverride<T extends MaterialPropertyType = MaterialPropertyType> {
|
|
20
|
+
/** The name of the material property to override (e.g., "color", "map", "roughness") */
|
|
21
|
+
name: string;
|
|
22
|
+
/** The value to set for this property */
|
|
23
|
+
value: T;
|
|
24
|
+
/** Optional texture coordinate transformation (only used when value is a Texture) */
|
|
25
|
+
textureTransform?: TextureTransform;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Utility type that extracts only non-function property names from a type
|
|
29
|
+
* @template T The type to extract property names from
|
|
30
|
+
*/
|
|
31
|
+
type NonFunctionPropertyNames<T> = {
|
|
32
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
33
|
+
}[keyof T];
|
|
34
|
+
/**
|
|
35
|
+
* MaterialPropertyBlock allows per-object material property overrides without creating new material instances.
|
|
36
|
+
* This is useful for rendering multiple objects with the same base material but different properties
|
|
37
|
+
* (e.g., different colors, textures, or shader parameters).
|
|
38
|
+
*
|
|
39
|
+
* The property block system works by:
|
|
40
|
+
* - Temporarily applying overrides in onBeforeRender
|
|
41
|
+
* - Restoring original values in onAfterRender
|
|
42
|
+
* - Managing shader defines and program cache keys for correct shader compilation
|
|
43
|
+
* - Supporting texture coordinate transforms per object
|
|
44
|
+
*
|
|
45
|
+
* Common use cases:
|
|
46
|
+
* - **Lightmaps**: Apply unique lightmap textures to individual objects sharing the same material
|
|
47
|
+
* - **Reflection Probes**: Apply different environment maps per object for localized reflections
|
|
48
|
+
* - **See-through effects**: Temporarily override transparency/transmission properties for X-ray effects
|
|
49
|
+
*
|
|
50
|
+
* ## Getting a MaterialPropertyBlock
|
|
51
|
+
*
|
|
52
|
+
* **Important**: Do not use the constructor directly. Instead, use the static {@link MaterialPropertyBlock.get} method:
|
|
53
|
+
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const block = MaterialPropertyBlock.get(myMesh);
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* This method will either return an existing property block or create a new one if it doesn't exist.
|
|
59
|
+
* It automatically:
|
|
60
|
+
* - Creates the property block instance
|
|
61
|
+
* - Registers it in the internal registry
|
|
62
|
+
* - Attaches the necessary render callbacks to the object
|
|
63
|
+
* - Handles Groups by applying overrides to all child meshes
|
|
64
|
+
*
|
|
65
|
+
* @example Basic usage
|
|
66
|
+
* ```typescript
|
|
67
|
+
* // Get or create a property block for an object
|
|
68
|
+
* const block = MaterialPropertyBlock.get(myMesh);
|
|
69
|
+
*
|
|
70
|
+
* // Override the color property
|
|
71
|
+
* block.setOverride("color", new Color(1, 0, 0));
|
|
72
|
+
*
|
|
73
|
+
* // Override a texture with custom UV transform (useful for lightmaps)
|
|
74
|
+
* block.setOverride("lightMap", myLightmapTexture, {
|
|
75
|
+
* offset: new Vector2(0.5, 0.5),
|
|
76
|
+
* repeat: new Vector2(2, 2)
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* // Set a shader define
|
|
80
|
+
* block.setDefine("USE_CUSTOM_FEATURE", 1);
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example Lightmap usage
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const block = MaterialPropertyBlock.get(mesh);
|
|
86
|
+
* block.setOverride("lightMap", lightmapTexture);
|
|
87
|
+
* block.setOverride("lightMapIntensity", 1.5);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example See-through effect
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const block = MaterialPropertyBlock.get(mesh);
|
|
93
|
+
* block.setOverride("transparent", true);
|
|
94
|
+
* block.setOverride("opacity", 0.3);
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @template T The material type this property block is associated with
|
|
98
|
+
*/
|
|
99
|
+
export declare class MaterialPropertyBlock<T extends Material = Material> {
|
|
100
|
+
private _overrides;
|
|
101
|
+
private _defines;
|
|
102
|
+
private _object;
|
|
103
|
+
/** The object this property block is attached to */
|
|
104
|
+
get object(): Object3D | null;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new MaterialPropertyBlock
|
|
107
|
+
* @param object The object this property block is for (optional)
|
|
108
|
+
*/
|
|
109
|
+
protected constructor(object?: Object3D | null);
|
|
110
|
+
/**
|
|
111
|
+
* Gets or creates a MaterialPropertyBlock for the given object.
|
|
112
|
+
* This is the recommended way to obtain a property block instance.
|
|
113
|
+
*
|
|
114
|
+
* @template T The material type
|
|
115
|
+
* @param object The object to get/create a property block for
|
|
116
|
+
* @returns The MaterialPropertyBlock associated with this object
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const block = MaterialPropertyBlock.get(myMesh);
|
|
121
|
+
* block.setOverride("roughness", 0.5);
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
static get<T extends Material = Material>(object: Object3D): MaterialPropertyBlock<T>;
|
|
125
|
+
/**
|
|
126
|
+
* Checks if an object has any property overrides
|
|
127
|
+
* @param object The object to check
|
|
128
|
+
* @returns True if the object has a property block with overrides
|
|
129
|
+
*/
|
|
130
|
+
static hasOverrides(object: Object3D): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Disposes this property block and cleans up associated resources.
|
|
133
|
+
* After calling dispose, this property block should not be used.
|
|
134
|
+
*/
|
|
135
|
+
dispose(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Sets or updates a material property override.
|
|
138
|
+
* The override will be applied to the material during rendering.
|
|
139
|
+
*
|
|
140
|
+
* @param name The name of the material property to override (e.g., "color", "map", "roughness")
|
|
141
|
+
* @param value The value to set
|
|
142
|
+
* @param textureTransform Optional UV transform (only used when value is a Texture)
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Override a simple property
|
|
147
|
+
* block.setOverride("roughness", 0.8);
|
|
148
|
+
*
|
|
149
|
+
* // Override a color
|
|
150
|
+
* block.setOverride("color", new Color(0xff0000));
|
|
151
|
+
*
|
|
152
|
+
* // Override a texture with UV transform
|
|
153
|
+
* block.setOverride("map", texture, {
|
|
154
|
+
* offset: new Vector2(0, 0),
|
|
155
|
+
* repeat: new Vector2(2, 2)
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
setOverride<K extends NonFunctionPropertyNames<T>>(name: K, value: T[K], textureTransform?: TextureTransform): void;
|
|
160
|
+
setOverride(name: string, value: MaterialPropertyType, textureTransform?: TextureTransform): void;
|
|
161
|
+
/**
|
|
162
|
+
* Gets the override for a specific property with type-safe value inference
|
|
163
|
+
* @param name The property name to get
|
|
164
|
+
* @returns The PropertyBlockOverride with correctly typed value if it exists, undefined otherwise
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const block = MaterialPropertyBlock.get<MeshStandardMaterial>(mesh);
|
|
169
|
+
*
|
|
170
|
+
* // Value is inferred as number | undefined
|
|
171
|
+
* const roughness = block.getOverride("roughness")?.value;
|
|
172
|
+
*
|
|
173
|
+
* // Value is inferred as Color | undefined
|
|
174
|
+
* const color = block.getOverride("color")?.value;
|
|
175
|
+
*
|
|
176
|
+
* // Value is inferred as Texture | null | undefined
|
|
177
|
+
* const map = block.getOverride("map")?.value;
|
|
178
|
+
*
|
|
179
|
+
* // Explicitly specify the type for properties not on the base material type
|
|
180
|
+
* const transmission = block.getOverride<number>("transmission")?.value;
|
|
181
|
+
*
|
|
182
|
+
* // Or use a more specific material type
|
|
183
|
+
* const physicalBlock = block as MaterialPropertyBlock<MeshPhysicalMaterial>;
|
|
184
|
+
* const transmissionTyped = physicalBlock.getOverride("transmission")?.value; // number
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
getOverride<K extends NonFunctionPropertyNames<T>>(name: K): PropertyBlockOverride<T[K] & MaterialPropertyType> | undefined;
|
|
188
|
+
getOverride<V extends MaterialPropertyType = MaterialPropertyType>(name: string): PropertyBlockOverride<V> | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Removes a specific property override
|
|
191
|
+
* @param name The property name to clear
|
|
192
|
+
*/
|
|
193
|
+
removeOveride<K extends NonFunctionPropertyNames<T>>(name: K | ({} & string)): void;
|
|
194
|
+
/**
|
|
195
|
+
* Removes all property overrides from this block
|
|
196
|
+
*/
|
|
197
|
+
clearAllOverrides(): void;
|
|
198
|
+
/**
|
|
199
|
+
* Gets all property overrides as a readonly array
|
|
200
|
+
* @returns Array of all property overrides
|
|
201
|
+
*/
|
|
202
|
+
get overrides(): readonly PropertyBlockOverride[];
|
|
203
|
+
/**
|
|
204
|
+
* Checks if this property block has any overrides
|
|
205
|
+
* @returns True if there are any overrides set
|
|
206
|
+
*/
|
|
207
|
+
hasOverrides(): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Set a shader define that will be included in the program cache key.
|
|
210
|
+
* This allows different objects sharing the same material to have different shader programs.
|
|
211
|
+
*
|
|
212
|
+
* Defines affect shader compilation and are useful for enabling/disabling features per-object.
|
|
213
|
+
*
|
|
214
|
+
* @param name The define name (e.g., "USE_LIGHTMAP", "ENABLE_REFLECTIONS")
|
|
215
|
+
* @param value The define value (typically a boolean, number, or string)
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* // Enable a feature for this specific object
|
|
220
|
+
* block.setDefine("USE_CUSTOM_SHADER", true);
|
|
221
|
+
* block.setDefine("QUALITY_LEVEL", 2);
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
setDefine(name: string, value: string | number | boolean): void;
|
|
225
|
+
/**
|
|
226
|
+
* Remove a shader define
|
|
227
|
+
* @param name The define name to remove
|
|
228
|
+
*/
|
|
229
|
+
clearDefine(name: string): void;
|
|
230
|
+
/**
|
|
231
|
+
* Get all defines set on this property block
|
|
232
|
+
* @returns A readonly record of all defines
|
|
233
|
+
*/
|
|
234
|
+
getDefines(): Readonly<Record<string, string | number | boolean>>;
|
|
235
|
+
/**
|
|
236
|
+
* Generates a cache key based on the current overrides and defines.
|
|
237
|
+
* This key is used internally to ensure correct shader program selection
|
|
238
|
+
* when objects share materials but have different property blocks.
|
|
239
|
+
*
|
|
240
|
+
* @returns A string representing the current state of this property block
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
getCacheKey(): string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Checks if an object has a MaterialPropertyBlock attached to it.
|
|
247
|
+
*
|
|
248
|
+
* @param object The object to check
|
|
249
|
+
* @returns True if the object has a property block registered
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* if (objectHasPropertyBlock(myMesh)) {
|
|
254
|
+
* console.log("This mesh has property overrides");
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
export declare function objectHasPropertyBlock(object: Object3D): boolean;
|
|
259
|
+
export {};
|