Skip to content

Commit

Permalink
updates back on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Valigursky committed Nov 29, 2024
1 parent de84a19 commit 31a6062
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions scripts/utils/cubemap-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ CubemapRenderer.prototype.initialize = function () {
}

// Before the first camera renders, trigger onCubemapPreRender event on the entity.
this.evtPreRender = this.app.scene.on(pc.EVENT_PRERENDER, (cameraComponent) => {
this.evtPreRender = this.app.scene.on('prerender', (cameraComponent) => {
if (cameraComponent === firstCamera) {
this.entity.fire('onCubemapPreRender');
}
});

// When last camera is finished rendering, trigger onCubemapPostRender event on the entity.
// This can be listened to by the user, and the resulting cubemap can be further processed (e.g pre-filtering)
this.evtPostRender = this.app.scene.on(pc.EVENT_POSTRENDER, (cameraComponent) => {
this.evtPostRender = this.app.scene.on('postrender', (cameraComponent) => {
if (cameraComponent === lastCamera) {
this.entity.fire('onCubemapPostRender');
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/planar-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ PlanarRenderer.prototype.initialize = function () {

// When the camera is finished rendering, trigger onPlanarPostRender event on the entity.
// This can be listened to by the user, and the resulting texture can be further processed (e.g prefiltered)
this.evtPostRender = this.app.scene.on(pc.EVENT_POSTRENDER, (cameraComponent) => {
this.evtPostRender = this.app.scene.on('postrender', (cameraComponent) => {
if (planarCamera === cameraComponent) {
this.entity.fire('onPlanarPostRender');
}
Expand Down
5 changes: 2 additions & 3 deletions src/extras/renderers/outline-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { DepthState } from '../../platform/graphics/depth-state.js';
import { RenderTarget } from '../../platform/graphics/render-target.js';
import { Texture } from '../../platform/graphics/texture.js';
import { EVENT_POSTRENDER, EVENT_PRERENDER_LAYER } from '../../scene/constants.js';
import { drawQuadWithShader } from '../../scene/graphics/quad-render-utils.js';
import { QuadRender } from '../../scene/graphics/quad-render.js';
import { StandardMaterialOptions } from '../../scene/materials/standard-material-options.js';
Expand Down Expand Up @@ -98,7 +97,7 @@ class OutlineRenderer {
this.outlineShaderPass = this.outlineCameraEntity.camera.setShaderPass('OutlineShaderPass');

// function called after the camera has rendered the outline objects to the texture
app.scene.on(EVENT_POSTRENDER, (cameraComponent) => {
app.scene.on('postrender', (cameraComponent) => {
if (this.outlineCameraEntity.camera === cameraComponent) {
this.onPostRender();
}
Expand Down Expand Up @@ -334,7 +333,7 @@ class OutlineRenderer {
this.updateRenderTarget(sceneCamera);

// function called before the scene camera renders a layer
const evt = this.app.scene.on(EVENT_PRERENDER_LAYER, (cameraComponent, layer, transparent) => {
const evt = this.app.scene.on('prerender:layer', (cameraComponent, layer, transparent) => {
if (sceneCamera === cameraComponent && transparent === blendLayerTransparent && layer === blendLayer) {
this.blendOutlines();
evt.off();
Expand Down
12 changes: 6 additions & 6 deletions src/scene/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -1061,44 +1061,44 @@ export const DITHER_IGNNOISE = 'ignnoise';
* @type {string}
* @category Graphics
*/
export const EVENT_PRERENDER = 'preRender';
export const EVENT_PRERENDER = 'prerender';

/**
* Name of event fired after the camera renders the scene.
*
* @type {string}
* @category Graphics
*/
export const EVENT_POSTRENDER = 'postRender';
export const EVENT_POSTRENDER = 'postrender';

/**
* Name of event fired before a layer is rendered by a camera.
*
* @type {string}
* @category Graphics
*/
export const EVENT_PRERENDER_LAYER = 'preRenderLayer';
export const EVENT_PRERENDER_LAYER = 'prerender:layer';

/**
* Name of event fired after a layer is rendered by a camera.
*
* @type {string}
* @category Graphics
*/
export const EVENT_POSTRENDER_LAYER = 'postRenderLayer';
export const EVENT_POSTRENDER_LAYER = 'postrender:layer';

/**
* Name of event fired before visibility culling is performed for the camera
*
* @type {string}
* @category Graphics
*/
export const EVENT_PRECULL = 'preCull';
export const EVENT_PRECULL = 'precull';

/**
* Name of event after before visibility culling is performed for the camera
*
* @type {string}
* @category Graphics
*/
export const EVENT_POSTCULL = 'postCull';
export const EVENT_POSTCULL = 'postcull';
24 changes: 12 additions & 12 deletions src/scene/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@ class Scene extends EventHandler {
*
* @event
* @example
* app.scene.on(EVENT_PRERENDER, (camera) => {
* app.scene.on('prerender', (camera) => {
* console.log(`Camera ${camera.entity.name} will render the scene`);
* });
*/
static EVENT_PRERENDER = 'preRender';
static EVENT_PRERENDER = 'prerender';

/**
* Fired when the camera renders the scene. The handler is passed the {@link CameraComponent}
* that rendered the scene.
*
* @event
* @example
* app.scene.on(EVENT_POSTRENDER, (camera) => {
* app.scene.on('postrender', (camera) => {
* console.log(`Camera ${camera.entity.name} rendered the scene`);
* });
*/
static EVENT_POSTRENDER = 'postRender';
static EVENT_POSTRENDER = 'postrender';

/**
* Fired before the camera renders a layer. The handler is passed the {@link CameraComponent},
Expand All @@ -99,11 +99,11 @@ class Scene extends EventHandler {
*
* @event
* @example
* app.scene.on(EVENT_PRERENDER_LAYER, (camera, layer, transparent) => {
* app.scene.on('prerender:layer', (camera, layer, transparent) => {
* console.log(`Camera ${camera.entity.name} will render the layer ${layer.name} (transparent: ${transparent})`);
* });
*/
static EVENT_PRERENDER_LAYER = 'preRenderLayer';
static EVENT_PRERENDER_LAYER = 'prerender:layer';

/**
* Fired when the camera renders a layer. The handler is passed the {@link CameraComponent},
Expand All @@ -113,33 +113,33 @@ class Scene extends EventHandler {
*
* @event
* @example
* app.scene.on(EVENT_PRERENDER_LAYER, (camera, layer, transparent) => {
* app.scene.on('postrender:layer', (camera, layer, transparent) => {
* console.log(`Camera ${camera.entity.name} rendered the layer ${layer.name} (transparent: ${transparent})`);
* });
*/
static EVENT_POSTRENDER_LAYER = 'postRenderLayer';
static EVENT_POSTRENDER_LAYER = 'postrender:layer';

/**
* Fired before visibility culling is performed for the camera.
*
* @event
* @example
* app.scene.on(EVENT_PRECULL, (camera) => {
* app.scene.on('precull', (camera) => {
* console.log(`Visibility culling will be performed for camera ${camera.entity.name}`);
* });
*/
static EVENT_PRECULL = 'preCull';
static EVENT_PRECULL = 'precull';

/**
* Fired after visibility culling is performed for the camera.
*
* @event
* @example
* app.scene.on(EVENT_POSTCULL, (camera) => {
* app.scene.on('postcull', (camera) => {
* console.log(`Visibility culling was performed for camera ${camera.entity.name}`);
* });
*/
static EVENT_POSTCULL = 'postCull';
static EVENT_POSTCULL = 'postcull';

/**
* If enabled, the ambient lighting will be baked into lightmaps. This will be either the
Expand Down

0 comments on commit 31a6062

Please sign in to comment.