SelectiveOutlineEffectDesc
SelectiveOutlineEffectDescクラスは、Selective Outline エフェクトを適用する Descriptor です。マスクベースのフィルタリングを使用して、特定のオブジェクトにのみ Outline を描画できます。Sobelフィルタを使用したエッジ検出により、オブジェクトの輪郭を強調します。
Properties
Section titled “Properties”visible
Section titled “visible”Type: boolean | undefined
Description: エフェクトの表示/非表示を制御します。
Default: true
Type: Color | undefined
Description: Outline の色をColorで指定します。
Default: 0xffffff
Example:
import { Color } from "@navaramap/three";
{ selectiveOutline: { color: new Color().setStyle("#ff0000"), }}thickness
Section titled “thickness”Type: number | undefined
Description: Outline の太さを指定します。
Default: 1.0
Example:
{ selectiveOutline: { thickness: 2.0, }}edgeStrength
Section titled “edgeStrength”Type: number | undefined
Description: エッジ検出の強度を指定します。値が大きいほどエッジが強調されます。
Default: 1.0
Example:
{ selectiveOutline: { edgeStrength: 1.5, }}resolutionScale
Section titled “resolutionScale”Type: number | undefined
Description: レンダリング解像度のスケール係数を指定します。低い値でパフォーマンスが向上します。
Default: 1.0
Example:
{ selectiveOutline: { resolutionScale: 0.5, }}innerEdges
Section titled “innerEdges”Type: boolean | undefined
Description: Outline の対象領域の内側の線も描画します。画面上で Outline 対象のオブジェクトが接したり重なったりする位置、壁の上の屋根の縁のような折れ目、奥行きの異なる面の段差に線が入ります。指定しない場合は Outline 対象のオブジェクト全体の外側の輪郭だけを描画するため、接したり重なったりする建物は 1 つの形にまとまります。内側の線の色と太さは Outline の color と thickness に従います。制約は備考にまとめています。
Default: false
Example:
{ selectiveOutline: { innerEdges: true, }}innerEdgeThreshold
Section titled “innerEdgeThreshold”Type: number | undefined
Description: 内側の線を描く折れ目の鋭さを、カメラから 2 つの面が見える角度で比較して指定します。同じ値は距離や解像度によらず同じ結果になります。低い値では、円形の建物の側面の多角形の継ぎ目のような浅い折れ目にも線が入ります。高い値では、鋭い折れ目と深度の段差だけに線が入ります。innerEdges が有効なときに適用されます。
Default: 0.5
Example:
{ selectiveOutline: { innerEdges: true, innerEdgeThreshold: 1.0, }}innerEdgeFadeDistance
Section titled “innerEdgeFadeDistance”Type: readonly [number, number] | null | undefined
Description: 内側の線がフェードアウトするカメラからの距離をメートル単位の [start, end] で指定します。start までは完全に描画し、end から先は描画しません。両方とも有限の値で 0 <= start < end を満たす必要があり、満たさない場合は RangeError が投げられます。指定しない場合や null の場合は、どの距離でも内側の線を描画します。update() で null を指定すると、設定済みのフェードを解除します。外側の輪郭はフェードしません。innerEdges が有効なときに適用されます。
Default: undefined(フェードしない)
Example:
{ selectiveOutline: { innerEdges: true, innerEdgeFadeDistance: [700, 1200], }}オブジェクトへのエフェクト適用
Section titled “オブジェクトへのエフェクト適用”Selective Outline エフェクトを特定のオブジェクトに適用するには、対象オブジェクトのeffectIdsプロパティに Outline エフェクトのIDを指定します。
effectIds
Section titled “effectIds”対象オブジェクトに適用する Selective Effect の ID の配列です。Outline エフェクトを追加すると一意のIDが割り当てられ、このIDを対象オブジェクトのeffectIdsに指定することでエフェクトが適用されます。
Usage Examples
Section titled “Usage Examples”基本的な Selective Outline の追加
Section titled “基本的な Selective Outline の追加”import ThreeView, { Color } from "@navaramap/three";import { BoxMeshDesc, SelectiveOutlineEffectDesc,} from "@navaramap/three-default-descs";
const view = new ThreeView();await view.init();
// Selective Outline エフェクトを追加const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({ selectiveOutline: { color: new Color().setHex(0xffffff), thickness: 1.0, edgeStrength: 1.0, },});
// オブジェクトに Outline エフェクトを適用const cubeDesc = view.addMesh<BoxMeshDesc>({ box: { width: 100, height: 100, depth: 100, color: new Color().setHex(0x0088ff), effectIds: [outlineDesc.id], // Outline エフェクトを適用 }, position: { x: 0, y: 0, z: 1000 },});カラー Outline の追加
Section titled “カラー 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();
// 赤色の太い Outline を追加const outlineDesc = view.addEffect<SelectiveOutlineEffectDesc>({ selectiveOutline: { color: new Color().setHex(0xff0000), thickness: 2.5, edgeStrength: 1.5, },});パフォーマンス重視の設定
Section titled “パフォーマンス重視の設定”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, edgeStrength: 1.0, resolutionScale: 0.5, // 低解像度でパフォーマンス向上 },});Outline エフェクトの動的更新
Section titled “Outline エフェクトの動的更新”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, },});
// 後からパラメータを更新outlineDesc.update({ selectiveOutline: { color: new Color().setHex(0x00ff00), // 緑 thickness: 2.0, },});内側の線を含めて建物に Outline を描画する
Section titled “内側の線を含めて建物に Outline を描画する”都市を見渡す視点では、遠くの建物は 1 棟あたり数ピクセルにしかならず、内側の線で Outline の色に塗りつぶされます。innerEdgeFadeDistance を指定すると、外側の輪郭を残したまま内側の線を距離に応じてフェードアウトできます。
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, // 建物の接する位置、屋根の縁、段差にも線を描画 innerEdgeFadeDistance: [700, 1200], // 内側の線を 700 m から 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], },});3D Tiles への Outline 適用
Section titled “3D Tiles への Outline 適用”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, },});
// 3D Tiles の建物に Outline を適用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], },});Bloom と Outline を組み合わせる
Section titled “Bloom と 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, },});
// 両方のエフェクトを適用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], // 両方を適用 }, position: { x: 0, y: 0, z: 1000 },});- Selective Outline エフェクトは、Sobel フィルタを使用したエッジ検出により、オブジェクトの輪郭を描画します。
- 選択したオブジェクトのハイライト表示やフォーカス表示に適しています。
- 内側の線(
innerEdges)はシーンの深度から検出します。- 接する 2 つの建物の揃った壁のように同じ平面上にある 2 つの面の間には、線が入りません。
- 円形の塔やチューブのように、平らな面の集まりを滑らかに陰影付けした曲面では、
innerEdgeThresholdより鋭い面の継ぎ目ごとに線が入ります。 - ほとんど接している 2 つの建物の間のように、Outline 対象のオブジェクトの間の隙間が 1 ピクセルより狭いと、隙間の奥が見えるピクセルだけに線が入り、途切れた線になります。
- エフェクトを適用していないオブジェクトが Outline 対象のオブジェクトの手前に描画されると、重なる部分に Outline の色で内側の線が入ることがあります。
hideUnderground: falseで Outline 対象のオブジェクト越しに見える地形も同様です。