Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small updates to the ModelOutlineExample #6703

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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