diff --git a/examples/src/examples/graphics/model-outline.example.mjs b/examples/src/examples/graphics/model-outline.example.mjs index 37b9b552664..59e4cef0377 100644 --- a/examples/src/examples/graphics/model-outline.example.mjs +++ b/examples/src/examples/graphics/model-outline.example.mjs @@ -93,9 +93,9 @@ assetListLoader.load(() => { let renderTarget = createRenderTarget(); - // create a layer for rendering to texture, and add it to the beginning of layers to render into it first + // create a layer for rendering to texture, and add it to the layers const outlineLayer = new pc.Layer({ name: 'OutlineLayer' }); - app.scene.layers.insert(outlineLayer, 0); + app.scene.layers.push(outlineLayer); // get existing layers const worldLayer = app.scene.layers.getLayerByName('World'); @@ -113,7 +113,7 @@ assetListLoader.load(() => { createPrimitive('cone', new pc.Vec3(0, 1, -2), new pc.Vec3(2, 2, 2), new pc.Color(0, 1, 1), [worldLayer.id]); // Create main camera, which renders entities in world layer - const camera = new pc.Entity(); + const camera = new pc.Entity('MainCamera'); camera.addComponent('camera', { clearColor: new pc.Color(0.2, 0.2, 0.4), layers: [worldLayer.id, uiLayer.id] @@ -122,11 +122,15 @@ assetListLoader.load(() => { camera.lookAt(pc.Vec3.ZERO); // Create outline camera, which renders entities in outline layer into the render target - const outlineCamera = new pc.Entity(); + const outlineCamera = new pc.Entity('Outline Camera'); outlineCamera.addComponent('camera', { clearColor: new pc.Color(0.0, 0.0, 0.0, 0.0), layers: [outlineLayer.id], - renderTarget: renderTarget + renderTarget: renderTarget, + + // set the priority of outlineCamera to lower number than the priority of the main camera (which is at default 0) + // to make it rendered first each frame + priority: -1 }); app.root.addChild(outlineCamera);