Browse Source

iGeometry upgrade changes, disable render when camera is not visible, fix UI in SSAOPluginPass.

master
Palash Bansal 2 years ago
parent
commit
11107d4a49
No account linked to committer's email address

+ 7
- 2
src/core/geometry/iGeometryCommons.ts View File

if (!force && (this.userData.disposeOnIdle === false || isInScene(this))) return if (!force && (this.userData.disposeOnIdle === false || isInScene(this))) return
superDispose.call(this) superDispose.call(this)
}, },
clone: (superClone: BufferGeometry['clone']): IGeometry['clone'] =>
function(this: IGeometry): IGeometry {
return iGeometryCommons.upgradeGeometry.call(superClone.call(this))
},
upgradeGeometry: upgradeGeometry, upgradeGeometry: upgradeGeometry,
center: (superCenter: BufferGeometry['center']): IGeometry['center'] => center: (superCenter: BufferGeometry['center']): IGeometry['center'] =>
function(this: IGeometry, offset?: Vector3, keepWorldPosition = false): IGeometry { function(this: IGeometry, offset?: Vector3, keepWorldPosition = false): IGeometry {
} }


function upgradeGeometry(this: IGeometry) { function upgradeGeometry(this: IGeometry) {
if (this.assetType === 'geometry') return // already upgraded
if (this.assetType === 'geometry') return this// already upgraded
if (!this.isBufferGeometry) { if (!this.isBufferGeometry) {
console.error('Geometry is not a BufferGeometry', this) console.error('Geometry is not a BufferGeometry', this)
return
return this
} }
this.assetType = 'geometry' this.assetType = 'geometry'


this.dispose = iGeometryCommons.dispose(this.dispose) this.dispose = iGeometryCommons.dispose(this.dispose)
this.center = iGeometryCommons.center(this.center) this.center = iGeometryCommons.center(this.center)
this.clone = iGeometryCommons.clone(this.clone)


if (!this.setDirty) this.setDirty = iGeometryCommons.setDirty if (!this.setDirty) this.setDirty = iGeometryCommons.setDirty
if (!this.refreshUi) this.refreshUi = iGeometryCommons.refreshUi if (!this.refreshUi) this.refreshUi = iGeometryCommons.refreshUi

+ 2
- 1
src/plugins/pipeline/SSAOPlugin.ts View File

this.clear = true this.clear = true
// this.bilateralPass = new BilateralFilterPass(this._target as any, gBufferUnpack, 'rrrr') // this.bilateralPass = new BilateralFilterPass(this._target as any, gBufferUnpack, 'rrrr')
// this._multiplyPass = new GenericBlendTexturePass(this._target.texture as any, 'c = vec4((1.0-b.r) * a.xyz, a.a);') // this._multiplyPass = new GenericBlendTexturePass(this._target.texture as any, 'c = vec4((1.0-b.r) * a.xyz, a.a);')
// this._getUiConfig = this._getUiConfig.bind(this)
} }


render(renderer: IWebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget, deltaTime: number, maskActive: boolean) { render(renderer: IWebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget, deltaTime: number, maskActive: boolean) {
return this.enabled ? '1' : '0' + getOrCall(this.target)?.texture?.colorSpace return this.enabled ? '1' : '0' + getOrCall(this.target)?.texture?.colorSpace
}, },
uuid: SSAOPlugin.PluginType, uuid: SSAOPlugin.PluginType,
...uiConfigMaterialExtension(this._getUiConfig, SSAOPlugin.PluginType),
...uiConfigMaterialExtension(this._getUiConfig.bind(this), SSAOPlugin.PluginType),
isCompatible: material => { isCompatible: material => {
return (material as PhysicalMaterial).isPhysicalMaterial return (material as PhysicalMaterial).isPhysicalMaterial
}, },

+ 6
- 4
src/viewer/ThreeViewer.ts View File

LinearSRGBColorSpace, LinearSRGBColorSpace,
Object3D, Object3D,
Quaternion, Quaternion,
Scene,
Vector2, Vector2,
Vector3, Vector3,
} from 'three' } from 'three'
/** /**
* Scene with object hierarchy used for rendering * Scene with object hierarchy used for rendering
*/ */
get scene(): RootScene {
return this._scene
get scene(): RootScene&Scene {
return this._scene as RootScene&Scene
} }
/** /**
* Specifies how many frames to render in a single request animation frame. Keep to 1 for realtime rendering. * Specifies how many frames to render in a single request animation frame. Keep to 1 for realtime rendering.
this.dispatchEvent({type: 'preRender', target: this}) this.dispatchEvent({type: 'preRender', target: this})


try { try {
this._scene.renderCamera = this._scene.mainCamera
this.renderManager.render(this._scene, this.renderManager.defaultRenderToScreen)
const cam = this._scene.mainCamera
this._scene.renderCamera = cam
if (cam.visible) this.renderManager.render(this._scene, this.renderManager.defaultRenderToScreen)
} catch (e) { } catch (e) {
this.console.error(e) this.console.error(e)
if (this.debug) throw e if (this.debug) throw e

Loading…
Cancel
Save