Skip to content

Commit

Permalink
Object3D: Add onBeforeShadow and onAfterShadow callbacks (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 authored Nov 27, 2023
1 parent 095a698 commit f8293b7
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions types/three/src/core/Object3D.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,49 @@ export class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap> ext
*/
customDistanceMaterial?: Material | undefined;

/**
* An optional callback that is executed immediately before a 3D object is rendered to a shadow map.
* @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
* depthMaterial, group.
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onBeforeShadow(
renderer: WebGLRenderer,
scene: Scene,
shadowCamera: Camera,
geometry: BufferGeometry,
depthMaterial: Material,
group: Group,
): void;

/**
* An optional callback that is executed immediately after a 3D object is rendered to a shadow map.
* @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
* depthMaterial, group.
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onAfterShadow(
renderer: WebGLRenderer,
scene: Scene,
shadowCamera: Camera,
geometry: BufferGeometry,
depthMaterial: Material,
group: Group,
): void;

/**
* An optional callback that is executed immediately before a 3D object is rendered.
* @remarks This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
* @remarks Please notice that this callback is only executed for `renderable` 3D objects.
* Meaning 3D objects which define their visual appearance with geometries and materials like
* instances of {@link THREE.Object3DMesh | Mesh}, {@link THREE.Object3DLine | Line}, {@link THREE.Object3DPoints | Points} or {@link THREE.Object3DSprite | Sprite}.
* Instances of {@link THREE.Object3DObject3D | Object3D}, {@link THREE.Object3DGroup | Group} or {@link THREE.Object3DBone | Bone}
* are not renderable and thus this callback is not executed for such objects.
* @defaultValue `() => {}`
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onBeforeRender(
renderer: WebGLRenderer,
Expand All @@ -247,12 +281,10 @@ export class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap> ext
/**
* An optional callback that is executed immediately after a 3D object is rendered.
* @remarks This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
* @remarks Please notice that this callback is only executed for `renderable` 3D objects.
* Meaning 3D objects which define their visual appearance with geometries and materials like
* instances of {@link THREE.Object3DMesh | Mesh}, {@link THREE.Object3DLine | Line}, {@link THREE.Object3DPoints | Points} or {@link THREE.Object3DSprite | Sprite}.
* Instances of {@link THREE.Object3DObject3D | Object3D}, {@link THREE.Object3DGroup | Group} or {@link THREE.Object3DBone | Bone}
* are not renderable and thus this callback is not executed for such objects.
* @defaultValue `() => {}`
* @remarks Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onAfterRender(
renderer: WebGLRenderer,
Expand Down

0 comments on commit f8293b7

Please sign in to comment.