Files
lucidia-metaverse/node_modules/three/examples/jsm/nodes/lighting/PointLightNode.js
Alexa Louise 47cf47f624 Initial commit: Lucidia Metaverse
Complete 3D metaverse platform with:
- Three.js 3D rendering
- Cannon.js physics engine
- Pointer lock controls
- Procedural cityscape
- Floating islands
- Portal system
- Particle effects
- WebXR/VR support ready
- Multiplayer ready (Socket.io)

Features:
- First-person controls (WASD + mouse)
- Jump and run mechanics
- Chat system
- Real-time HUD
- Loading screen
- Responsive design

Built with Vite for fast builds and hot reload.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-22 19:02:56 -06:00

69 lines
1.6 KiB
JavaScript

import AnalyticLightNode from './AnalyticLightNode.js';
import { addLightNode } from './LightsNode.js';
import { getDistanceAttenuation } from './LightUtils.js';
import { uniform } from '../core/UniformNode.js';
import { objectViewPosition } from '../accessors/Object3DNode.js';
import { positionView } from '../accessors/PositionNode.js';
import { addNodeClass } from '../core/Node.js';
import { PointLight } from 'three';
class PointLightNode extends AnalyticLightNode {
constructor( light = null ) {
super( light );
this.cutoffDistanceNode = uniform( 0 );
this.decayExponentNode = uniform( 0 );
}
update( frame ) {
const { light } = this;
super.update( frame );
this.cutoffDistanceNode.value = light.distance;
this.decayExponentNode.value = light.decay;
}
setup( builder ) {
const { colorNode, cutoffDistanceNode, decayExponentNode, light } = this;
const lightingModel = builder.context.lightingModel;
const lVector = objectViewPosition( light ).sub( positionView ); // @TODO: Add it into LightNode
const lightDirection = lVector.normalize();
const lightDistance = lVector.length();
const lightAttenuation = getDistanceAttenuation( {
lightDistance,
cutoffDistance: cutoffDistanceNode,
decayExponent: decayExponentNode
} );
const lightColor = colorNode.mul( lightAttenuation );
const reflectedLight = builder.context.reflectedLight;
lightingModel.direct( {
lightDirection,
lightColor,
reflectedLight
}, builder.stack, builder );
}
}
export default PointLightNode;
addNodeClass( 'PointLightNode', PointLightNode );
addLightNode( PointLight, PointLightNode );