Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEB-2417: Shadowcatcher updates when switching versions #3777

Merged
merged 2 commits into from
Jan 9, 2025
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
4 changes: 0 additions & 4 deletions packages/viewer-sandbox/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { SectionTool } from '@speckle/viewer'
import { SectionOutlines } from '@speckle/viewer'
import { ViewModesKeys } from './Extensions/ViewModesKeys'
import { BoxSelection } from './Extensions/BoxSelection'
import { SnowPipeline } from './Pipelines/Snow/SnowPipeline'

const createViewer = async (containerName: string, _stream: string) => {
const container = document.querySelector<HTMLElement>(containerName)
Expand Down Expand Up @@ -83,9 +82,6 @@ const createViewer = async (containerName: string, _stream: string) => {
Object.assign(sandbox.sceneParams.worldSize, viewer.World.worldSize)
Object.assign(sandbox.sceneParams.worldOrigin, viewer.World.worldOrigin)
sandbox.refresh()
const snowPipeline = new SnowPipeline(viewer.getRenderer())
viewer.getRenderer().pipeline = snowPipeline
void snowPipeline.start()
})

viewer.on(ViewerEvent.UnloadComplete, () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/viewer/src/modules/SpeckleRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export default class SpeckleRenderer {
this.updateHelpers()

/** We'll just update the shadowcatcher after all batches are loaded */
this.updateShadowCatcher()
this.updateShadowCatcher(true)
this.updateClippingPlanes()
if (this._speckleCamera) this._speckleCamera.updateCameraPlanes(this.sceneBox)
delete this.cancel[renderTree.id]
Expand Down Expand Up @@ -641,7 +641,6 @@ export default class SpeckleRenderer {

public removeRenderTree(subtreeId: string) {
this.rootGroup.remove(this.rootGroup.getObjectByName(subtreeId) as Object3D)
this.updateShadowCatcher()

const batches = this.batcher.getBatches(subtreeId)
batches.forEach((value) => {
Expand All @@ -651,6 +650,7 @@ export default class SpeckleRenderer {
this.batcher.purgeBatches(subtreeId)
this.updateDirectLights()
this.updateHelpers()
this.updateShadowCatcher(true)
}

public cancelRenderTree(subtreeId: string) {
Expand Down Expand Up @@ -844,14 +844,15 @@ export default class SpeckleRenderer {
this._shadowcatcher?.updateClippingPlanes(planes)
}

public updateShadowCatcher() {
public updateShadowCatcher(force: boolean = false) {
if (this.sunConfiguration.shadowcatcher !== undefined)
this._shadowcatcher.shadowcatcherMesh.visible =
this.sunConfiguration.shadowcatcher
if (this.sunConfiguration.shadowcatcher) {
this._shadowcatcher.bake(
this.clippingVolume,
this._renderer.capabilities.maxTextureSize
this._renderer.capabilities.maxTextureSize,
force
)
this.needsRender = true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/modules/Viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export class Viewer extends EventEmitter implements IViewer {
this.speckleRenderer.removeRenderTree(resource)
this.tree.getRenderTree(resource)?.purge()
this.tree.purge(resource)
this.requestRender(UpdateFlags.RENDER | UpdateFlags.SHADOWS)
this.requestRender(UpdateFlags.RENDER_RESET | UpdateFlags.SHADOWS)
}
} finally {
if (--this.inProgressOperations === 0) {
Expand Down
Loading