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.
Properties
Section titled “Properties”visible
Section titled “visible”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"), }}thickness
Section titled “thickness”Type: number | undefined
Description: Specifies the thickness of the outline.
Default: 1.0
Example:
{ selectiveOutline: { thickness: 2.0, }}edgeStrength
Section titled “edgeStrength”Type: number | undefined
Description: Specifies the edge detection strength. Higher values emphasize edges more.
Default: 1.0
Example:
{ selectiveOutline: { edgeStrength: 1.5, }}resolutionScale
Section titled “resolutionScale”Type: number | undefined
Description: Specifies the rendering resolution scale factor. Lower values improve performance.
Default: 1.0
Example:
{ selectiveOutline: { resolutionScale: 0.5, }}innerEdges
Section titled “innerEdges”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, }}innerEdgeThreshold
Section titled “innerEdgeThreshold”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, }}innerEdgeFadeDistance
Section titled “innerEdgeFadeDistance”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], }}Applying the Effect to Objects
Section titled “Applying the Effect to Objects”To apply the selective outline effect to specific objects, specify the outline effect descriptor’s ID in the target object’s effectIds property.
effectIds
Section titled “effectIds”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.
Usage Examples
Section titled “Usage Examples”Adding a basic selective outline
Section titled “Adding a basic selective outline”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 descriptorconst outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({ selectiveOutline: { color: new Color().setHex(0xffffff), thickness: 1.0, edgeStrength: 1.0, },});
// Apply outline effect to an objectconst 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 },});Adding a colored outline
Section titled “Adding a colored outline”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 outlineconst outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({ selectiveOutline: { color: new Color().setHex(0xff0000), thickness: 2.5, edgeStrength: 1.5, },});Performance-oriented settings
Section titled “Performance-oriented settings”import ThreeView, { Color } from "@navaramap/three";import { SelectiveOutlineEffectDesc } from "@navaramap/three-default-descs";
const view = new ThreeView();await view.init();
// Performance-oriented settingsconst outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({ selectiveOutline: { color: new Color().setHex(0xffffff), thickness: 1.0, edgeStrength: 1.0, resolutionScale: 0.5, // Lower resolution for improved performance },});Dynamic outline effect updates
Section titled “Dynamic outline effect updates”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 lateroutlineDesc.update({ selectiveOutline: { color: new Color().setHex(0x00ff00), // Green thickness: 2.0, },});Outlining buildings with inner edges
Section titled “Outlining buildings with inner edges”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], },});Applying outlines to 3D Tiles
Section titled “Applying outlines to 3D Tiles”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 buildingsconst 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], },});Combining bloom and outline
Section titled “Combining bloom and outline”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 effectsconst 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.