| @@ -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 | |||
| @@ -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 | |||
| }, | |||
| @@ -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 | |||