diff --git a/src/ts/assets/procedural/landingPad/landingPad.ts b/src/ts/assets/procedural/landingPad/landingPad.ts index a778fc4c7..97eb9c7b0 100644 --- a/src/ts/assets/procedural/landingPad/landingPad.ts +++ b/src/ts/assets/procedural/landingPad/landingPad.ts @@ -45,7 +45,15 @@ export class LandingPad implements Transformable, TypedObject, BoundingSphere { this.deckMaterial = new LandingPadMaterial(padNumber, scene); - this.deck = MeshBuilder.CreateBox(`Landing Pad ${padNumber}`, { width: width, depth: depth, height: 0.5 }, scene); + this.deck = MeshBuilder.CreateBox( + `Landing Pad ${padNumber}`, + { + width: width, + depth: depth, + height: 0.5 + }, + scene + ); this.deck.material = this.deckMaterial; this.deckAggregate = new PhysicsAggregate(this.deck, PhysicsShapeType.BOX, { mass: 0, friction: 10 }, scene); @@ -83,8 +91,13 @@ export class LandingPad implements Transformable, TypedObject, BoundingSphere { } } - update(stellarObjects: Transformable[]): void { + update(stellarObjects: Transformable[], cameraWorldPosition: Vector3): void { this.deckMaterial.update(stellarObjects); + + const padCameraDistance2 = Vector3.DistanceSquared(cameraWorldPosition, this.deck.getAbsolutePosition()); + const distanceThreshold = 12e3; + const isEnabled = padCameraDistance2 < distanceThreshold * distanceThreshold; + this.getTransform().setEnabled(isEnabled); } getTransform(): TransformNode { diff --git a/src/ts/assets/procedural/spaceStation/landingBay.ts b/src/ts/assets/procedural/spaceStation/landingBay.ts index 38f0bd3ed..73b34fe9c 100644 --- a/src/ts/assets/procedural/spaceStation/landingBay.ts +++ b/src/ts/assets/procedural/spaceStation/landingBay.ts @@ -155,7 +155,7 @@ export class LandingBay { this.getTransform().rotate(Axis.Y, deltaSeconds / computeRingRotationPeriod(this.radius, Settings.G_EARTH * 0.1)); this.landingBayMaterial.update(stellarObjects); this.metalSectionMaterial.update(stellarObjects); - this.landingPads.forEach((landingPad) => landingPad.update(stellarObjects)); + this.landingPads.forEach((landingPad) => landingPad.update(stellarObjects, cameraWorldPosition)); const distanceToCamera = Vector3.Distance(cameraWorldPosition, this.getTransform().getAbsolutePosition());