Skip to content

Commit

Permalink
Small updates to the ModelOutlineExample (#6703)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jun 14, 2024
1 parent e059f55 commit 4bd2cd9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/src/examples/graphics/model-outline.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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]
Expand All @@ -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);

Expand Down

0 comments on commit 4bd2cd9

Please sign in to comment.