Skip to content

Commit f8293b7

Browse files
authored
Object3D: Add onBeforeShadow and onAfterShadow callbacks (#693)
1 parent 095a698 commit f8293b7

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

types/three/src/core/Object3D.d.ts

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,49 @@ export class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap> ext
225225
*/
226226
customDistanceMaterial?: Material | undefined;
227227

228+
/**
229+
* An optional callback that is executed immediately before a 3D object is rendered to a shadow map.
230+
* @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
231+
* depthMaterial, group.
232+
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
233+
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
234+
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
235+
* and thus this callback is not executed for such objects.
236+
*/
237+
onBeforeShadow(
238+
renderer: WebGLRenderer,
239+
scene: Scene,
240+
shadowCamera: Camera,
241+
geometry: BufferGeometry,
242+
depthMaterial: Material,
243+
group: Group,
244+
): void;
245+
246+
/**
247+
* An optional callback that is executed immediately after a 3D object is rendered to a shadow map.
248+
* @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
249+
* depthMaterial, group.
250+
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
251+
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
252+
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
253+
* and thus this callback is not executed for such objects.
254+
*/
255+
onAfterShadow(
256+
renderer: WebGLRenderer,
257+
scene: Scene,
258+
shadowCamera: Camera,
259+
geometry: BufferGeometry,
260+
depthMaterial: Material,
261+
group: Group,
262+
): void;
263+
228264
/**
229265
* An optional callback that is executed immediately before a 3D object is rendered.
230266
* @remarks This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
231-
* @remarks Please notice that this callback is only executed for `renderable` 3D objects.
232-
* Meaning 3D objects which define their visual appearance with geometries and materials like
233-
* instances of {@link THREE.Object3DMesh | Mesh}, {@link THREE.Object3DLine | Line}, {@link THREE.Object3DPoints | Points} or {@link THREE.Object3DSprite | Sprite}.
234-
* Instances of {@link THREE.Object3DObject3D | Object3D}, {@link THREE.Object3DGroup | Group} or {@link THREE.Object3DBone | Bone}
235-
* are not renderable and thus this callback is not executed for such objects.
236-
* @defaultValue `() => {}`
267+
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
268+
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
269+
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
270+
* and thus this callback is not executed for such objects.
237271
*/
238272
onBeforeRender(
239273
renderer: WebGLRenderer,
@@ -247,12 +281,10 @@ export class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap> ext
247281
/**
248282
* An optional callback that is executed immediately after a 3D object is rendered.
249283
* @remarks This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
250-
* @remarks Please notice that this callback is only executed for `renderable` 3D objects.
251-
* Meaning 3D objects which define their visual appearance with geometries and materials like
252-
* instances of {@link THREE.Object3DMesh | Mesh}, {@link THREE.Object3DLine | Line}, {@link THREE.Object3DPoints | Points} or {@link THREE.Object3DSprite | Sprite}.
253-
* Instances of {@link THREE.Object3DObject3D | Object3D}, {@link THREE.Object3DGroup | Group} or {@link THREE.Object3DBone | Bone}
254-
* are not renderable and thus this callback is not executed for such objects.
255-
* @defaultValue `() => {}`
284+
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
285+
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
286+
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
287+
* and thus this callback is not executed for such objects.
256288
*/
257289
onAfterRender(
258290
renderer: WebGLRenderer,

0 commit comments

Comments
 (0)