Просмотр исходного кода

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

master
Palash Bansal 2 лет назад
Родитель
Сommit
11107d4a49
Аккаунт пользователя с таким Email не найден

+ 7
- 2
src/core/geometry/iGeometryCommons.ts Просмотреть файл

@@ -16,6 +16,10 @@ export const iGeometryCommons = {
if (!force && (this.userData.disposeOnIdle === false || isInScene(this))) return
superDispose.call(this)
},
clone: (superClone: BufferGeometry['clone']): IGeometry['clone'] =>
function(this: IGeometry): IGeometry {
return iGeometryCommons.upgradeGeometry.call(superClone.call(this))
},
upgradeGeometry: upgradeGeometry,
center: (superCenter: BufferGeometry['center']): IGeometry['center'] =>
function(this: IGeometry, offset?: Vector3, keepWorldPosition = false): IGeometry {
@@ -157,15 +161,16 @@ export const iGeometryCommons = {
}

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

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

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

+ 2
- 1
src/plugins/pipeline/SSAOPlugin.ts Просмотреть файл

@@ -207,6 +207,7 @@ export class SSAOPluginPass extends ExtendedShaderPass implements IPipelinePass
this.clear = true
// 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._getUiConfig = this._getUiConfig.bind(this)
}

render(renderer: IWebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget, deltaTime: number, maskActive: boolean) {
@@ -282,7 +283,7 @@ export class SSAOPluginPass extends ExtendedShaderPass implements IPipelinePass
return this.enabled ? '1' : '0' + getOrCall(this.target)?.texture?.colorSpace
},
uuid: SSAOPlugin.PluginType,
...uiConfigMaterialExtension(this._getUiConfig, SSAOPlugin.PluginType),
...uiConfigMaterialExtension(this._getUiConfig.bind(this), SSAOPlugin.PluginType),
isCompatible: material => {
return (material as PhysicalMaterial).isPhysicalMaterial
},

+ 6
- 4
src/viewer/ThreeViewer.ts Просмотреть файл

@@ -7,6 +7,7 @@ import {
LinearSRGBColorSpace,
Object3D,
Quaternion,
Scene,
Vector2,
Vector3,
} from 'three'
@@ -243,8 +244,8 @@ export class ThreeViewer extends EventDispatcher<IViewerEvent, IViewerEventTypes
/**
* 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.
@@ -654,8 +655,9 @@ export class ThreeViewer extends EventDispatcher<IViewerEvent, IViewerEventTypes
this.dispatchEvent({type: 'preRender', target: this})

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) {
this.console.error(e)
if (this.debug) throw e

Загрузка…
Отмена
Сохранить