Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions examples/jsm/libs/mikktspace.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 40 additions & 2 deletions src/nodes/lighting/IESSpotLightNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ class IESSpotLightNode extends SpotLightNode {

}

/**
* Constructs a new IES spot light node.
*
* @param {?SpotLight} [light=null] - The spot light source.
*/
constructor( light = null ) {

super( light );

/**
* The texture node representing the IES texture.
*
* @type {?TextureNode}
* @default null
*/
this._iesTextureNode = null;

}

/**
* Overwrites the default implementation to compute an IES conform spot attenuation.
*
Expand All @@ -32,18 +51,37 @@ class IESSpotLightNode extends SpotLightNode {

const angle = angleCosine.acos().mul( 1.0 / Math.PI );

spotAttenuation = texture( iesMap, vec2( angle, 0 ), 0 ).r;
this._iesTextureNode = texture( iesMap, vec2( angle, 0 ), 0 );

spotAttenuation = this._iesTextureNode.r;

} else {

spotAttenuation = super.getSpotAttenuation( angleCosine );
spotAttenuation = super.getSpotAttenuation( builder, angleCosine );

}

return spotAttenuation;

}

/**
* Overwritten to update the IES spot light texture.
*
* @param {NodeFrame} frame - A reference to the current node frame.
*/
update( frame ) {

super.update( frame );

if ( this._iesTextureNode !== null && this.light.iesMap ) {

this._iesTextureNode.value = this.light.iesMap;

}

}

}

export default IESSpotLightNode;
Loading