Bläddra i källkod

Load properties from legacy files in SSAO, fix edge case in LoadingScreenPlugin

master
Palash Bansal 1 år sedan
förälder
incheckning
90171abaf9
Inget konto är kopplat till bidragsgivarens mejladress
2 ändrade filer med 39 tillägg och 14 borttagningar
  1. 27
    14
      src/plugins/interaction/LoadingScreenPlugin.ts
  2. 12
    0
      src/plugins/pipeline/SSAOPlugin.ts

+ 27
- 14
src/plugins/interaction/LoadingScreenPlugin.ts Visa fil

this._mainDiv.style.color = this.textColor this._mainDiv.style.color = this.textColor
this._setHTML(this.logoElement, this.logoImage ? `<img class="loadingScreenLogoImage" src="${this.logoImage}"/>` : '') this._setHTML(this.logoElement, this.logoImage ? `<img class="loadingScreenLogoImage" src="${this.logoImage}"/>` : '')
if (updateVisibility) { if (updateVisibility) {
if (this.hideOnFilesLoad && (processState.size === 0 ||
errors.length === processState.size && this.hideOnOnlyErrors)) {
this.hideDelay ? this.hideWithDelay() : this.hide()
} else if (processState.size > 0 && this.showOnFilesLoading) {
const sceneObjects = this._viewer.scene.modelRoot.children
if (sceneObjects.length > 0 && this.minimizeOnSceneObjectLoad && this._viewer.scene.environment) this.minimize()
else this.maximize()
this.show()
}
this._updateVisibility(processState, errors.length)
}
}

protected _updateVisibility(processState: Map<string, {state: string, progress?: number|undefined}>, errors: number) {
if (!this._viewer) return false
if (this.hideOnFilesLoad && (processState.size === 0 ||
errors === processState.size && this.hideOnOnlyErrors) && !this._isHidden) {
this.hideDelay ? this.hideWithDelay() : this.hide()
return true
} else if (processState.size > 0 && this.showOnFilesLoading && this._isHidden) {
const sceneObjects = this._viewer.scene.modelRoot.children
if (sceneObjects.length > 0 && this.minimizeOnSceneObjectLoad && this._viewer.scene.environment) this.minimize()
else this.maximize()
this.show()
return true
} }
return false
} }


// disables showOnSceneEmpty // disables showOnSceneEmpty
if (sceneObjects.length === 0 && this.showOnSceneEmpty && !this.isEditor) { if (sceneObjects.length === 0 && this.showOnSceneEmpty && !this.isEditor) {
this.show() this.show()
} }
// console.log(sceneObjects.length)
if (sceneObjects.length > 0) { if (sceneObjects.length > 0) {
if (this.hideOnSceneObjectLoad)
this.hideWithDelay()
else if (this.minimizeOnSceneObjectLoad && this._viewer.scene.environment)
timeout(this.hideDelay + 300).then(()=>this.minimize())
// case - objects loaded, clear current scene, load loaded objects
// load - process state 0, hide with delay. clear scene shows loading screen, loading current object doesnt change process state...
const processState = this._viewer.assetManager.processState
const errors = [...processState.values()].filter(v => v.state === 'error')
if (!this._updateVisibility(processState, errors.length)) {
if (this.hideOnSceneObjectLoad)
this.hideWithDelay()
else if (this.minimizeOnSceneObjectLoad && this._viewer.scene.environment)
timeout(this.hideDelay + 300).then(() => this.minimize())
}
} else if (this.minimizeOnSceneObjectLoad) } else if (this.minimizeOnSceneObjectLoad)
this.maximize() this.maximize()
} }

+ 12
- 0
src/plugins/pipeline/SSAOPlugin.ts Visa fil



readonly passId = 'ssao' readonly passId = 'ssao'
public static readonly PluginType = 'SSAOPlugin' public static readonly PluginType = 'SSAOPlugin'
public static readonly OldPluginType = 'SSAO'


dependencies = [GBufferPlugin] dependencies = [GBufferPlugin]


return super.onRemove(viewer) return super.onRemove(viewer)
} }


fromJSON(data: any, meta?: any): this|null|Promise<this|null> {
// legacy
if (data.passes?.ssao) {
data = {...data}
data.pass = data.passes.ssao
delete data.passes
if (data.pass.enabled !== undefined) data.enabled = data.pass.enabled
}
return super.fromJSON(data, meta)
}

updateGBufferFlags(data: Vector4, c: GBufferUpdaterContext): void { updateGBufferFlags(data: Vector4, c: GBufferUpdaterContext): void {
if (!c.material || !c.material.userData) return if (!c.material || !c.material.userData) return
const disabled = c.material.userData.ssaoCastDisabled || c.material.userData.pluginsDisabled const disabled = c.material.userData.ssaoCastDisabled || c.material.userData.pluginsDisabled

Laddar…
Avbryt
Spara