Skip to content

feat: Add Light node for scene lighting#157

Merged
ashconnell merged 1 commit intohyperfy-xyz:devfrom
jb0gie:light-node
Apr 21, 2026
Merged

feat: Add Light node for scene lighting#157
ashconnell merged 1 commit intohyperfy-xyz:devfrom
jb0gie:light-node

Conversation

@jb0gie
Copy link
Copy Markdown

@jb0gie jb0gie commented Mar 6, 2026

Summary

Add a new Light node supporting three light types (directional, point, spot) for scene lighting in Hyperfy worlds.

Changes

  • New file: src/core/nodes/Light.js - Light node implementation (305 lines)
  • Modified: src/core/nodes/index.js - Export light node (+1 line)

Light Types

  • directional: Infinite light with direction (e.g., sun)
  • point: Omnidirectional light from a point (e.g., bulb)
  • spot: Cone-shaped light with angle and penumbra (e.g., flashlight)

Properties

Property Type Default Description
type string 'point' Light type
color string '#ffffff' Light color (hex)
intensity number 1 Light brightness
distance number 100 Max distance (point/spot)
decay number 2 Falloff rate (point/spot)
angle number Math.PI/3 Cone angle (spot)
penumbra number 0 Edge softness (spot)
castShadow boolean false Cast shadows

Usage Example

const light = app.create('light', {
  type: 'point',
  color: '#ff00ff',
  intensity: 2,
  distance: 50
})
light.position.set(0, 2, 0)
app.add(light)

Testing

  • Create directional light
  • Create point light
  • Create spot light
  • Modify properties at runtime
  • Verify shadows work when castShadow=true

Add a new Light node supporting three light types:
- directional: Infinite light with direction (e.g., sun)
- point: Omnidirectional light from a point (e.g., bulb)
- spot: Cone-shaped light with angle and penumbra (e.g., flashlight)

Properties:
- type: Light type ('directional' | 'point' | 'spot')
- color: Light color in hex format (default: '#ffffff')
- intensity: Light brightness (default: 1)
- distance: Maximum light distance for point/spot (default: 100)
- decay: Light falloff rate for point/spot (default: 2)
- angle: Cone angle for spot lights in radians (default: Math.PI / 3)
- penumbra: Edge softness for spot lights (default: 0)
- castShadow: Whether the light casts shadows (default: false)

Usage:
  const light = world.createNode('light', {
    type: 'point',
    color: '#ff00ff',
    intensity: 2,
    distance: 50
  })

Co-Authored-By: jb0gie <wxzvrd@protonmail.com>
@jb0gie jb0gie marked this pull request as ready for review March 15, 2026 17:57
@ashconnell ashconnell merged commit b4081eb into hyperfy-xyz:dev Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants