Hello, I get “scene.enableDepthRenderer is not a function” when I create the LensRenderingPipeline, without importing the full Babylon namespace.
It look to me strange because I should have imported all the needed classes…
Here’s my code
import { Engine } from "@babylonjs/core/Engines/engine";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math";
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera";
import { SpotLight } from "@babylonjs/core/Lights/spotLight";
import { Mesh } from "@babylonjs/core/Meshes/mesh";
import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
import { ShadowGenerator } from "@babylonjs/core/Lights/Shadows/shadowGenerator";
// import * as BABYLON from "@babylonjs/core/Legacy/legacy";
import { LensRenderingPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
import { Tools } from "@babylonjs/core/Misc/tools"
const createScene = function () {
var scene = new Scene(engine);
const camera = new ArcRotateCamera("arcamera", Tools.ToRadians(-90), Tools.ToRadians(45), 10, new Vector3.Zero(), scene);
camera.attachControl(canvas, true);
const lensEffect = new LensRenderingPipeline('lens', {
edge_blur: 1.0,
dof_focus_distance: 6,
dof_aperture: 5.0,
}, scene, 1.0, camera);
const box = MeshBuilder.CreateBox("box", { width: 1, depth: 1, height: 4 }, scene);
box.position = new Vector3(0, 2, 0);
const plane = Mesh.CreateGround("Spotlight Hard Shadows", 24, 60, 1, scene, false);
plane.receiveShadows = true;
const light = new SpotLight("SpotLight", new Vector3(-5, 5.16, -5.1), new Vector3(1, -1, 1), 1.2, 24, scene);
const shadowGenerator = new ShadowGenerator(1024, light);
shadowGenerator.getShadowMap().renderList.push(box);
return scene;
};
const canvas = document.getElementById("renderCanvas");
const engine = new Engine(canvas);
const scene = createScene();
engine.runRenderLoop(() => {
scene.render();
});