Skip to content

Commit

Permalink
Fix for adding lights after render
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsmalm committed Oct 2, 2020
1 parent 03c45a8 commit 7633838
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion examples/example.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = env => {
devtool: "source-map",
mode: "development",
devServer: {
host: "0.0.0.0",
contentBase: "./examples"
},
module: {
Expand Down
11 changes: 11 additions & 0 deletions src/material/standard/standard-material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class StandardMaterial extends Material {
private _metallicRoughnessTexture?: PIXI.Texture
private _transparent = false
private _shadowCastingLight?: ShadowCastingLight
private _lightsCount?: number

/** The roughness of the material. */
roughness = 1
Expand Down Expand Up @@ -251,6 +252,16 @@ export class StandardMaterial extends Material {
return material
}

render(mesh: Mesh3D, renderer: PIXI.Renderer, state?: PIXI.State) {
let lightingEnvironment = this.lightingEnvironment || LightingEnvironment.main
if (lightingEnvironment.lights.length !== this._lightsCount) {
// Invalidate shader when the number of punctual lights has changed.
this.invalidateShader()
this._lightsCount = lightingEnvironment.lights.length
}
super.render(mesh, renderer, state)
}

createShader(mesh: Mesh3D, renderer: PIXI.Renderer) {
if (renderer.context.webGLVersion === 1) {
let extensions = ["EXT_shader_texture_lod", "OES_standard_derivatives"]
Expand Down

0 comments on commit 7633838

Please sign in to comment.