-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some refactoring of the fire audio class to work like existing scenes…
… with the voxel tracer code. Also fixed some issues with the fire to better respond to audio.
- Loading branch information
Showing
6 changed files
with
163 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as THREE from 'three'; | ||
import {clamp} from '../MathUtils'; | ||
|
||
class VTEmissionMaterial { | ||
constructor(colour, alpha=1, texture=null) { | ||
this.colour = colour; | ||
this.alpha = alpha; | ||
this.texture = texture; | ||
} | ||
|
||
dispose() {} | ||
|
||
emission(uv) { | ||
return this.albedo(uv); | ||
} | ||
|
||
isVisible() { | ||
return Math.round(this.alpha*255) >= 1; | ||
} | ||
|
||
albedo(uv) { | ||
const albedoColour = this.colour.clone(); | ||
if (uv && this.texture && this.texture.isLoaded()) { | ||
albedoColour.multiply(this.texture.sample(uv)); | ||
} | ||
return albedoColour; | ||
} | ||
|
||
brdf(nObjToLightVec, normal, uv, lightColour) { | ||
const dot = clamp(nObjToLightVec.dot(normal), 0, 1); | ||
return this.brdfAmbient(uv, lightColour).multiplyScalar(dot); | ||
} | ||
|
||
brdfAmbient(uv, lightColour) { | ||
const albedoColour = this.albedo(uv); | ||
albedoColour.add(lightColour).multiplyScalar(this.alpha); | ||
return albedoColour; | ||
} | ||
} | ||
|
||
export default VTEmissionMaterial; |
Oops, something went wrong.