Skip to main content

Class: ThreeEnvironmentPort

Defined in: threejs-environment/src/environment-port.ts:118

Applies an environment to a scene.

Every method takes the whole slot, or null to remove it. The director calls a method ONLY when that slot's value actually changed, so an adapter may treat each call as "this is new, act on it" and does not need to diff. That matters on IWSDK, where applying a change means setting _needsUpdate and re-running a system.

Extended by​

Implements​

Constructors​

Constructor​

new ThreeEnvironmentPort(scene: Scene, options?: ThreeEnvironmentPortOptions): ThreeEnvironmentPort;

Defined in: threejs-environment/src/environment-port.ts:153

Parameters​

ParameterType
sceneScene
optionsThreeEnvironmentPortOptions

Returns​

ThreeEnvironmentPort

Accessors​

root​

Get Signature​

get root(): Group;

Defined in: threejs-environment/src/environment-port.ts:167

The group holding everything this port created. Read-only in practice.

Returns​

Group

Methods​

applyAmbient()​

applyAmbient(light: AmbientLightSpec | null): void;

Defined in: threejs-environment/src/environment-port.ts:248

Parameters​

ParameterType
lightAmbientLightSpec | null

Returns​

void

Implementation of​

EnvironmentPort.applyAmbient


applyFog()​

applyFog(fog: FogSpec | null): void;

Defined in: threejs-environment/src/environment-port.ts:224

Parameters​

ParameterType
fogFogSpec | null

Returns​

void

Implementation of​

EnvironmentPort.applyFog


applyIbl()​

applyIbl(ibl: IblSpec | null): void;

Defined in: threejs-environment/src/environment-port.ts:308

The environment map: what shiny things reflect, and what lights everything the key light does not.

Three kinds, three routes. A gradient is the same generated equirect the sky uses, regenerated in place across a transition. An image is loaded once and swapped in when it lands. A room is three.js's own RoomEnvironment, which has to be prefiltered by a renderer this port does not have - so it is used when the app supplied a prefilter, and approximated with a neutral ramp when it did not.

Parameters​

ParameterType
iblIblSpec | null

Returns​

void

Implementation of​

EnvironmentPort.applyIbl


applyKeyLight()​

applyKeyLight(light: KeyLightSpec | null): void;

Defined in: threejs-environment/src/environment-port.ts:266

Parameters​

ParameterType
lightKeyLightSpec | null

Returns​

void

Implementation of​

EnvironmentPort.applyKeyLight


applyLightEstimation()​

applyLightEstimation(estimation:
| ResolvedLightEstimation
| null): void;

Defined in: threejs-environment/src/environment-port.ts:462

Light estimation, straight from WebXR rather than through XREstimatedLight.

The probe is requested here and read in update, and each reading becomes plain specs the director lays over the ambient, key and ibl slots. Doing it this way means an app can read the estimate, blend it, or ignore it - none of which is possible when the estimate is two lights in a Group that only the renderer can see.

Parameters​

ParameterType
estimation| ResolvedLightEstimation | null

Returns​

void

Implementation of​

EnvironmentPort.applyLightEstimation


applyOcclusion()​

applyOcclusion(spec: OcclusionSpec | null): void;

Defined in: threejs-environment/src/environment-port.ts:394

Real-world depth occlusion, through three.js's own depth sensing.

three.js has done this since r158: when the session grants gpu-optimized depth, WebXRManager reads the depth texture each frame and WebGLRenderer draws a full-screen occlusion mesh before everything else. There is nothing left for this port to render, so its whole job is to decide whether the request can be served and to say so out loud.

Everything it refuses, it refuses with a reason. Depth that is silently absent looks exactly like depth that is working on a scene with nothing in front of the user, which is why the reports exist at all.

Parameters​

ParameterType
specOcclusionSpec | null

Returns​

void

Implementation of​

EnvironmentPort.applyOcclusion


applySky()​

applySky(sky: SkySpec | null): void;

Defined in: threejs-environment/src/environment-port.ts:171

Parameters​

ParameterType
skySkySpec | null

Returns​

void

Implementation of​

EnvironmentPort.applySky


dispose()​

dispose(): void;

Defined in: threejs-environment/src/environment-port.ts:547

Release anything the port created. Optional.

Returns​

void

Implementation of​

EnvironmentPort.dispose


observe()​

observe(host: EnvironmentPortHost): () => void;

Defined in: threejs-environment/src/environment-port.ts:374

Hand the port the object it talks back through.

Called once, at construction, before anything is applied. The returned function is called on dispose. This is the ONLY inbound path: see sensing.ts for why there is one and why it carries what it does.

Parameters​

ParameterType
hostEnvironmentPortHost

Returns​

() => void

Implementation of​

EnvironmentPort.observe


update()​

update(): void;

Defined in: threejs-environment/src/environment-port.ts:542

Poll the two things the host will not push.

Called by the director's own update, so an app that already ticks the director gets this for free, and one that does not gets a scene that never occludes - which the reports will say.

Returns​

void

Implementation of​

EnvironmentPort.update