Skip to content

SelectiveOutlineEffectDesc

The SelectiveOutlineEffectDesc class is a Descriptor that applies a selective outline effect. It uses mask-based filtering to draw outlines only on specific objects. It highlights object contours using edge detection with a Sobel filter.

Type: boolean | undefined

Description: Controls the visibility of the effect descriptor.

Default: true

Type: Color | undefined

Description: Specifies the outline color as a Color.

Default: 0xffffff

Example:

import { Color } from "@navaramap/three";
{
selectiveOutline: {
color: new Color().setStyle("#ff0000"),
}
}

Type: number | undefined

Description: Specifies the thickness of the outline.

Default: 1.0

Example:

{
selectiveOutline: {
thickness: 2.0,
}
}

Type: number | undefined

Description: Specifies the edge detection strength. Higher values emphasize edges more.

Default: 1.0

Example:

{
selectiveOutline: {
edgeStrength: 1.5,
}
}

Type: number | undefined

Description: Specifies the rendering resolution scale factor. Lower values improve performance.

Default: 1.0

Example:

{
selectiveOutline: {
resolutionScale: 0.5,
}
}

Type: boolean | undefined

Description: Also draws the edges inside the outlined region: where outlined objects meet or overlap on screen, along creases such as a roof edge over its walls, and at steps between surfaces at different depths. Without it, only the outer contour of all outlined objects together is drawn, so touching or overlapping buildings merge into one shape. Inner edges use the outline’s color and thickness. Their limits are listed under Notes.

Default: false

Example:

{
selectiveOutline: {
innerEdges: true,
}
}

Type: number | undefined

Description: How sharp a crease has to be to get an inner edge, compared by the angles at which the camera sees the two faces. The same value gives the same result at any distance and resolution. Lower values also draw shallow creases, such as the facets of round buildings. Higher values keep only sharp creases and steps in depth. Applies while innerEdges is on.

Default: 0.5

Example:

{
selectiveOutline: {
innerEdges: true,
innerEdgeThreshold: 1.0,
}
}

Type: readonly [number, number] | null | undefined

Description: Distances from the camera in meters [start, end] over which inner edges fade out: drawn in full up to start and gone from end. Both values must be finite, with 0 <= start < end, or a RangeError is thrown. When unset or null, inner edges are drawn at every distance, and update() with null removes a fade set earlier. The outer contour is never faded. Applies while innerEdges is on.

Default: undefined (no fade)

Example:

{
selectiveOutline: {
innerEdges: true,
innerEdgeFadeDistance: [700, 1200],
}
}

To apply the selective outline effect to specific objects, specify the outline effect descriptor’s ID in the target object’s effectIds property.

An array of selective effect descriptor IDs to apply to the target object. When an outline effect descriptor is added, a unique ID is assigned, and the effect is applied by specifying this ID in the target object’s effectIds.

import ThreeView, { Color } from "@navaramap/three";
import {
BoxMeshDesc,
SelectiveOutlineEffectDesc,
} from "@navaramap/three-default-descs";
const view = new ThreeView();
await view.init();
// Add selective outline effect descriptor
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setHex(0xffffff),
thickness: 1.0,
edgeStrength: 1.0,
},
});
// Apply outline effect to an object
const cubeDesc = view.addMesh<BoxMeshDesc>({
box: {
width: 100,
height: 100,
depth: 100,
color: new Color().setHex(0x0088ff),
effectIds: [outlineDesc.id], // Apply outline effect
},
position: { x: 0, y: 0, z: 1000 },
});
import ThreeView, { Color } from "@navaramap/three";
import { SelectiveOutlineEffectDesc } from "@navaramap/three-default-descs";
import { DefaultPlugin } from "@navaramap/three-default-plugin";
const view = new ThreeView();
const plugin = new DefaultPlugin();
view.addPlugin(plugin);
await view.init();
plugin.addDefaultPhotorealScene();
// Add a thick red outline
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setHex(0xff0000),
thickness: 2.5,
edgeStrength: 1.5,
},
});
import ThreeView, { Color } from "@navaramap/three";
import { SelectiveOutlineEffectDesc } from "@navaramap/three-default-descs";
const view = new ThreeView();
await view.init();
// Performance-oriented settings
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setHex(0xffffff),
thickness: 1.0,
edgeStrength: 1.0,
resolutionScale: 0.5, // Lower resolution for improved performance
},
});
import ThreeView, { Color } from "@navaramap/three";
import { SelectiveOutlineEffectDesc } from "@navaramap/three-default-descs";
const view = new ThreeView();
await view.init();
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setHex(0xffffff),
thickness: 1.0,
},
});
// Update parameters later
outlineDesc.update({
selectiveOutline: {
color: new Color().setHex(0x00ff00), // Green
thickness: 2.0,
},
});

In a city view, distant buildings cover only a few pixels each, and their inner edges fill them with the outline color. innerEdgeFadeDistance fades the inner edges out with distance while the outer contour stays.

import ThreeView, { Color } from "@navaramap/three";
import { SelectiveOutlineEffectDesc } from "@navaramap/three-default-descs";
const view = new ThreeView();
await view.init();
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setStyle("#0091ff"),
thickness: 2.0,
innerEdges: true, // Also draw where buildings meet, roof edges and steps
innerEdgeFadeDistance: [700, 1200], // Fade inner edges out from 700 m to 1200 m
},
});
const buildingsSource = view.addSource({
type: "geojson",
data: "https://example.com/buildings.geojson",
});
view.addLayer({
type: "vector",
source: buildingsSource,
polygon: {
extrudedHeight: 20,
clampToGround: false,
effectIds: [outlineDesc.id],
},
});
import ThreeView, { Color } from "@navaramap/three";
import { SelectiveOutlineEffectDesc } from "@navaramap/three-default-descs";
const view = new ThreeView();
await view.init();
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setHex(0xff0000),
thickness: 2.0,
},
});
// Apply outline to 3D Tiles buildings
const buildingsSource = view.addSource({
type: "3d-tiles",
url: "https://example.com/tileset.json",
});
const buildingsLayer = view.addLayer({
type: "3d-tiles",
source: buildingsSource,
model: {
show: true,
color: new Color().setHex(0xffffff),
effectIds: [outlineDesc.id],
},
});
import ThreeView, { Color } from "@navaramap/three";
import {
BoxMeshDesc,
SelectiveBloomEffectDesc,
SelectiveOutlineEffectDesc,
} from "@navaramap/three-default-descs";
const view = new ThreeView();
await view.init();
const bloomDesc = view.addEffect<SelectiveBloomEffectDesc>({
selectiveBloom: {
strength: 1.0,
},
});
const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({
selectiveOutline: {
color: new Color().setHex(0xff0000),
thickness: 2.0,
},
});
// Apply both effects
const cubeDesc = view.addMesh<BoxMeshDesc>({
box: {
width: 100,
height: 100,
depth: 100,
color: new Color().setHex(0xff0000),
emissiveIntensity: 1.0,
effectIds: [bloomDesc.id, outlineDesc.id], // Apply both
},
position: { x: 0, y: 0, z: 1000 },
});
  • The selective outline effect draws object contours using edge detection with a Sobel filter.
  • It is suitable for highlighting or focusing on selected objects.
  • Inner edges (innerEdges) come from the depth of the scene:
    • Two faces in one plane, such as the flush walls of two touching buildings, get no line between them.
    • A curved surface built from flat facets but shaded smooth, such as a round tower or a tube, gets a line at each facet edge sharper than innerEdgeThreshold.
    • A gap between outlined objects narrower than a pixel, such as two buildings that almost touch, gets a broken line where some pixels see into the gap.
    • An object without the effect that is drawn over an outlined object can get inner lines in the outline color where it covers it. This includes terrain shown through an outlined object with hideUnderground: false.