Skip to content

@orillusion/core


Class: LODGroup ​

Defined in: src/components/renderer/LODGroup.ts:65

Level-of-detail switcher. Registers N sets of objects with a threshold each and, every frame, enables exactly one set (or none, when the object is too small / far and cullBeyondLast is on) based on the view's camera.

Levels are kept sorted from most to least detailed no matter the order they were added in, so addLevel can be called in any order.

ts
const lod = obj.addComponent(LODGroup);
lod.addLevel([highMesh], 0.4);   // shown while ≥40 % of viewport height
lod.addLevel([midMesh],  0.12);  // 12 %–40 %
lod.addLevel([lowMesh],  0.03);  // 3 %–12 %, below that: culled

Extends ​

Constructors ​

Constructor ​

new LODGroup(): LODGroup

Returns ​

LODGroup

Inherited from ​

ComponentBase.constructor

Properties ​

CULLED ​

readonly static CULLED: -1 = -1

Defined in: src/components/renderer/LODGroup.ts:67

currentLevel value while every level is hidden.


object3D ​

object3D: Object3D = null

Defined in: src/components/ComponentBase.ts:29

owner object3D

Inherited from ​

ComponentBase.object3D


isDestroyed ​

isDestroyed: boolean = false

Defined in: src/components/ComponentBase.ts:77

Inherited from ​

ComponentBase.isDestroyed


bias ​

bias: number = 1

Defined in: src/components/renderer/LODGroup.ts:77

Global scale on the metric. In ScreenSize mode >1 keeps detailed levels visible longer (like Unity's QualitySettings.lodBias); in Distance mode the measured distance is divided by it, so the same direction applies.


hysteresis ​

hysteresis: number = 0.1

Defined in: src/components/renderer/LODGroup.ts:85

Fraction of the threshold used as a dead-band so a group parked right on a boundary does not flicker between two levels. A level is only dropped for a coarser one when the metric is past the threshold, and only re-promoted when it is past threshold * (1 + hysteresis).


cullBeyondLast ​

cullBeyondLast: boolean = true

Defined in: src/components/renderer/LODGroup.ts:88

Hide every level once the last threshold is crossed.


forceLevel ​

forceLevel: number = null

Defined in: src/components/renderer/LODGroup.ts:94

Debug/authoring override: null = automatic, otherwise the level index to force (clamped). LODGroup.CULLED forces everything hidden.


camera ​

camera: Camera3D = null

Defined in: src/components/renderer/LODGroup.ts:100

Optional camera override; defaults to the camera of the view that updates this component.


radius ​

radius: number = null

Defined in: src/components/renderer/LODGroup.ts:108

Bounding-sphere radius (world units) used for ScreenSize. null (default) derives it from the world bounds of every level's objects the first time it is needed; call recalculateBounds() after changing geometry or scale.

Accessors ​

visibleLayer ​

Get Signature ​

get visibleLayer(): number

Defined in: src/components/ComponentBase.ts:46

Composition-layer membership bitmask. The pass / camera / collector filters via

(component.visibleLayer & pass.layerMask & camera.cullingMask) !== 0

Defaults to VisibleLayer.Default (bit 0) so a fresh subclass is visible to passes whose layerMask is VisibleLayer.All (which includes bit 0). Application code can assign project-specific bits (1..31) to organise the scene into composition layers.

Returns ​

number

Set Signature ​

set visibleLayer(value): void

Defined in: src/components/ComponentBase.ts:50

Parameters ​
value ​

number

Returns ​

void

Inherited from ​

ComponentBase.visibleLayer


eventDispatcher ​

Get Signature ​

get eventDispatcher(): CEventDispatcher

Defined in: src/components/ComponentBase.ts:63

Returns ​

CEventDispatcher

Set Signature ​

set eventDispatcher(value): void

Defined in: src/components/ComponentBase.ts:68

Parameters ​
value ​

CEventDispatcher

Returns ​

void

Inherited from ​

ComponentBase.eventDispatcher


isStart ​

Get Signature ​

get isStart(): boolean

Defined in: src/components/ComponentBase.ts:79

Returns ​

boolean

Inherited from ​

ComponentBase.isStart


transform ​

Get Signature ​

get transform(): Transform

Defined in: src/components/ComponentBase.ts:89

Return the Transform component attached to the Object3D. Null before the component is attached — addComponent assigns object3D only after construction — so constructor-time callers can probe safely via this.transform?..

Returns ​

Transform

Inherited from ​

ComponentBase.transform


enable ​

Get Signature ​

get enable(): boolean

Defined in: src/components/ComponentBase.ts:113

Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.

Returns ​

boolean

Set Signature ​

set enable(value): void

Defined in: src/components/ComponentBase.ts:96

Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ComponentBase.enable


mode ​

Get Signature ​

get mode(): LODMode

Defined in: src/components/renderer/LODGroup.ts:125

Metric used to pick a level. Thresholds are in the metric's unit, so after switching modes hand in matching values via setThresholds. The level order (finest first) is kept across the switch on purpose: re-sorting by the old thresholds would reverse it, and the new thresholds are assigned by that order.

Returns ​

LODMode

Set Signature ​

set mode(value): void

Defined in: src/components/renderer/LODGroup.ts:129

Parameters ​
value ​

LODMode

Returns ​

void


levels ​

Get Signature ​

get levels(): readonly LODLevel[]

Defined in: src/components/renderer/LODGroup.ts:136

Levels, most detailed first. Treat as read-only; use addLevel / removeLevel.

Returns ​

readonly LODLevel[]


currentLevel ​

Get Signature ​

get currentLevel(): number

Defined in: src/components/renderer/LODGroup.ts:141

Index into levels of the level currently shown, or LODGroup.CULLED.

Returns ​

number


lastMetric ​

Get Signature ​

get lastMetric(): number

Defined in: src/components/renderer/LODGroup.ts:146

Metric (screen-relative height or distance) measured on the last update.

Returns ​

number


onLevelChange ​

Set Signature ​

set onLevelChange(cb): void

Defined in: src/components/renderer/LODGroup.ts:151

Called after the shown level changes.

Parameters ​
cb ​

(level, previous) => void

Returns ​

void

Methods ​

init() ​

init(param?): void

Defined in: src/components/ComponentBase.ts:161

Parameters ​

param? ​

any

Returns ​

void

Inherited from ​

ComponentBase.init


start() ​

start(): void

Defined in: src/components/ComponentBase.ts:162

Returns ​

void

Inherited from ​

ComponentBase.start


stop() ​

stop(): void

Defined in: src/components/ComponentBase.ts:163

Returns ​

void

Inherited from ​

ComponentBase.stop


onDisable()? ​

optional onDisable(view?): any

Defined in: src/components/ComponentBase.ts:165

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onDisable


onLateUpdate()? ​

optional onLateUpdate(view?): any

Defined in: src/components/ComponentBase.ts:167

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onLateUpdate


onBeforeUpdate()? ​

optional onBeforeUpdate(view?): any

Defined in: src/components/ComponentBase.ts:168

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onBeforeUpdate


onCompute()? ​

optional onCompute(view?, command?): any

Defined in: src/components/ComponentBase.ts:169

Parameters ​

view? ​

View3D

command? ​

GPUCommandEncoder

Returns ​

any

Inherited from ​

ComponentBase.onCompute


onGraphic()? ​

optional onGraphic(view?): any

Defined in: src/components/ComponentBase.ts:170

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onGraphic


onParentChange()? ​

optional onParentChange(lastParent?, currentParent?): any

Defined in: src/components/ComponentBase.ts:171

Parameters ​

lastParent? ​

Object3D

currentParent? ​

Object3D

Returns ​

any

Inherited from ​

ComponentBase.onParentChange


onAddChild()? ​

optional onAddChild(child): any

Defined in: src/components/ComponentBase.ts:172

Parameters ​

child ​

Object3D

Returns ​

any

Inherited from ​

ComponentBase.onAddChild


onRemoveChild()? ​

optional onRemoveChild(child): any

Defined in: src/components/ComponentBase.ts:173

Parameters ​

child ​

Object3D

Returns ​

any

Inherited from ​

ComponentBase.onRemoveChild


copyComponent() ​

copyComponent(from): this

Defined in: src/components/ComponentBase.ts:182

Parameters ​

from ​

this

Returns ​

this

Inherited from ​

ComponentBase.copyComponent


beforeDestroy() ​

beforeDestroy(force?): void

Defined in: src/components/ComponentBase.ts:249

before release this component, object refrences are not be set null now.

Parameters ​

force? ​

boolean

Returns ​

void

Inherited from ​

ComponentBase.beforeDestroy


addLevel() ​

addLevel(objects, threshold): number

Defined in: src/components/renderer/LODGroup.ts:159

Register a level. Objects are hidden immediately; the right one is enabled on the next update. Returns the level's index after sorting.

Parameters ​

objects ​

Object3D | Object3D[]

threshold ​

number

Returns ​

number


removeLevel() ​

removeLevel(index): void

Defined in: src/components/renderer/LODGroup.ts:171

Remove a level (its objects are re-enabled and no longer managed).

Parameters ​

index ​

number

Returns ​

void


setThreshold() ​

setThreshold(index, threshold): void

Defined in: src/components/renderer/LODGroup.ts:185

Change one level's threshold at runtime. Levels are re-sorted, so the index of other levels may move; to rewrite several thresholds use setThresholds, which assigns them all before sorting.

Parameters ​

index ​

number

threshold ​

number

Returns ​

void


setThresholds() ​

setThresholds(thresholds): void

Defined in: src/components/renderer/LODGroup.ts:197

Rewrite every threshold in the current (finest-first) level order, then re-sort once. The usual companion of a mode switch.

Parameters ​

thresholds ​

number[]

Returns ​

void


recalculateBounds() ​

recalculateBounds(): void

Defined in: src/components/renderer/LODGroup.ts:205

Forget the cached auto radius; recomputed on next update.

Returns ​

void


measure() ​

measure(camera): number

Defined in: src/components/renderer/LODGroup.ts:213

Compute the metric this group would use for camera right now, without changing any state. Useful for tooling and tests.

Parameters ​

camera ​

Camera3D

Returns ​

number


selectLevel() ​

selectLevel(metric, from?): number

Defined in: src/components/renderer/LODGroup.ts:234

Pick the level for a metric value, applying hysteresis relative to from (the level currently shown). Pure function of the inputs.

Parameters ​

metric ​

number

from? ​

number = ...

Returns ​

number


onUpdate() ​

onUpdate(view?): void

Defined in: src/components/renderer/LODGroup.ts:261

Parameters ​

view? ​

View3D

Returns ​

void

Overrides ​

ComponentBase.onUpdate


onEnable() ​

onEnable(): void

Defined in: src/components/renderer/LODGroup.ts:268

Returns ​

void

Overrides ​

ComponentBase.onEnable


destroy() ​

destroy(force?): void

Defined in: src/components/renderer/LODGroup.ts:274

release this component

Parameters ​

force? ​

boolean

Returns ​

void

Overrides ​

ComponentBase.destroy


cloneTo() ​

cloneTo(obj): void

Defined in: src/components/renderer/LODGroup.ts:281

clone component data to target object3D

Parameters ​

obj ​

Object3D

target object3D

Returns ​

void

Overrides ​

ComponentBase.cloneTo

Released under the MIT License