Restored IViewer

This commit is contained in:
AlexandruPopovici
2022-05-10 14:18:53 +03:00
parent 4d877cba42
commit 0074a784e6
2 changed files with 34 additions and 30 deletions
+32
View File
@@ -0,0 +1,32 @@
export interface ViewerParams {
postprocessing: boolean
reflections: boolean
showStats: boolean
}
export const DefaultViewerParams: ViewerParams = {
postprocessing: false,
reflections: true,
showStats: true
}
/**
* Carried over from the old Viewer. To be extended/changed
*/
export interface IViewer {
init(): Promise<void>
toggleSectionBox(): void
sectionBoxOff(): void
sectionBoxOn(): void
zoomExtents(fit: number, transition: boolean): void
toggleCameraProjection(): void
loadObject(url: string, token: string, enableCaching?: boolean): Promise<void>
cancelLoad(url: string, unload?: boolean): Promise<void>
unloadObject(url: string): Promise<void>
unloadAll(): Promise<void>
applyFilter(filter: any): Promise<any>
getObjectsProperties(includeAll?: boolean): any
dispose(): void
}
+2 -30
View File
@@ -14,28 +14,13 @@ import { Scene } from 'three'
import { WebGLRenderer } from 'three'
import { Assets } from './Assets'
import { Optional } from '../helpers/typeHelper'
import { DefaultViewerParams, IViewer, ViewerParams } from '../IViewer'
export interface ViewerParams {
postprocessing: boolean
reflections: boolean
showStats: boolean
}
export const DefaultViewerParams: ViewerParams = {
postprocessing: false,
reflections: true,
showStats: true
}
export class Viewer extends EventEmitter {
export class Viewer extends EventEmitter implements IViewer {
private clock: Clock
// private postprocessing: boolean
// private reflections: boolean
// private reflectionsNeedUpdate: boolean
private container: HTMLElement
private cubeCamera: CubeCamera
private stats: Optional<Stats>
// private mouseOverRenderer: boolean
private loaders: any
private needsRender: boolean
private inProgressOperations: number
@@ -60,7 +45,6 @@ export class Viewer extends EventEmitter {
this.clock = new THREE.Clock()
this.container = container || document.getElementById('renderer')
// this.postprocessing = params.postprocessing
this.scene = new THREE.Scene()
this.renderer = new THREE.WebGLRenderer({
@@ -80,8 +64,6 @@ export class Viewer extends EventEmitter {
this.cameraHandler = new CameraHandler(this)
// this.reflections = params.reflections
// this.reflectionsNeedUpdate = true
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget(512, {
format: THREE.RGBFormat,
generateMipmaps: true,
@@ -97,14 +79,6 @@ export class Viewer extends EventEmitter {
window.addEventListener('resize', this.onWindowResize.bind(this), false)
// this.mouseOverRenderer = false
this.renderer.domElement.addEventListener('mouseover', () => {
// this.mouseOverRenderer = true
})
this.renderer.domElement.addEventListener('mouseout', () => {
// this.mouseOverRenderer = false
})
this.loaders = {}
this.sectionBox = new SectionBox(this)
@@ -190,7 +164,6 @@ export class Viewer extends EventEmitter {
onWindowResize() {
this.renderer.setSize(this.container.offsetWidth, this.container.offsetHeight)
// this.composer.setSize( this.container.offsetWidth, this.container.offsetHeight )
this.needsRender = true
}
@@ -198,7 +171,6 @@ export class Viewer extends EventEmitter {
const delta = this.clock.getDelta()
const hasControlsUpdated = this.cameraHandler.controls.update(delta)
// const hasOrthoControlsUpdated = this.cameraHandler.cameras[1].controls.update( delta )
requestAnimationFrame(this.animate.bind(this))