Skip to content

[FIX] Fix glTF spot light default cone angle#8305

Merged
willeastcott merged 1 commit intomainfrom
gltf-lights
Dec 22, 2025
Merged

[FIX] Fix glTF spot light default cone angle#8305
willeastcott merged 1 commit intomainfrom
gltf-lights

Conversation

@willeastcott
Copy link
Contributor

@willeastcott willeastcott commented Dec 22, 2025

Fixes incorrect default outerConeAngle when loading spot lights from glTF/GLB files.

Changes

  • Fixed outerConeAngle default value from radians to degrees
  • Added safe fallbacks for cone angles in luminance calculation
  • Fixed typo in comment ("clapms" → "clamps")

Technical Details

The glTF KHR_lights_punctual extension specifies cone angles in radians with a default outerConeAngle of π/4. When converting to degrees, this default was incorrectly left in radians.

Before:

lightProps.outerConeAngle = gltfLight.spot.hasOwnProperty('outerConeAngle') ? gltfLight.spot.outerConeAngle * math.RAD_TO_DEG : Math.PI / 4;

After:

lightProps.outerConeAngle = gltfLight.spot.hasOwnProperty('outerConeAngle') ? gltfLight.spot.outerConeAngle * math.RAD_TO_DEG : 45;

The previous code resulted in spot lights without explicit outerConeAngle having a cone of ~0.785° instead of 45°, making them nearly invisible.

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an incorrect default value for the outerConeAngle property when loading spot lights from glTF/GLB files. The glTF specification uses radians with a default of π/4, but PlayCanvas expects degrees, so the default should be 45° instead of the unconverted π/4 (≈0.785°).

Key Changes:

  • Fixed default outerConeAngle from Math.PI / 4 (radians) to 45 (degrees)
  • Added safe fallbacks using nullish coalescing for cone angles in luminance calculation
  • Fixed typo in comment ("clapms" → "clamps") and improved comment clarity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@willeastcott willeastcott merged commit ffcf06e into main Dec 22, 2025
13 checks passed
@willeastcott willeastcott deleted the gltf-lights branch December 22, 2025 11:03
@mvaligursky
Copy link
Contributor

please see the comment by copilot above, seems it might be right @willeastcott

@willeastcott
Copy link
Contributor Author

please see the comment by copilot above, seems it might be right @willeastcott

Yep, creating a follow up PR now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants