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

Add ViewerUiConfigPlugin and SceneUiConfigPlugin for previewing in the editor.

master
Palash Bansal 2 лет назад
Родитель
Сommit
fe1f6e6d96
Аккаунт пользователя с таким Email не найден
3 измененных файлов: 52 добавлений и 0 удалений
  1. 5
    0
      src/plugins/index.ts
  2. 20
    0
      src/plugins/ui/SceneUiConfigPlugin.ts
  3. 27
    0
      src/plugins/ui/ViewerUiConfigPlugin.ts

+ 5
- 0
src/plugins/index.ts Просмотреть файл

@@ -9,6 +9,8 @@ export type {NormalBufferPluginEventTypes, NormalBufferPluginPass, NormalBufferP

// ui
export {RenderTargetPreviewPlugin} from './ui/RenderTargetPreviewPlugin'
export {ViewerUiConfigPlugin} from './ui/ViewerUiConfigPlugin'
export {SceneUiConfigPlugin} from './ui/SceneUiConfigPlugin'

// interaction
export {DropzonePlugin, type DropzonePluginOptions} from './interaction/DropzonePlugin'
@@ -16,3 +18,6 @@ export {FullScreenPlugin} from './interaction/FullScreenPlugin'

// import
export {Rhino3dmLoadPlugin} from './import/Rhino3dmLoadPlugin'

// postprocessing
export {TonemapPlugin} from './postprocessing/TonemapPlugin'

+ 20
- 0
src/plugins/ui/SceneUiConfigPlugin.ts Просмотреть файл

@@ -0,0 +1,20 @@
import {AViewerPluginSync, ThreeViewer} from '../../viewer'
import {serialize} from 'ts-browser-helpers'
import {RootScene} from '../../core'

export class SceneUiConfigPlugin extends AViewerPluginSync<''> {
static readonly PluginType = 'SceneUiConfigPlugin'
enabled = true
serializeWithViewer = false
constructor() {
super()
this.uiConfig = {}
}
onAdded(viewer: ThreeViewer) {
super.onAdded(viewer)
this.uiConfig = viewer.scene.uiConfig
this._scene = viewer.scene
}
@serialize('scene')
protected _scene: RootScene | undefined
}

+ 27
- 0
src/plugins/ui/ViewerUiConfigPlugin.ts Просмотреть файл

@@ -0,0 +1,27 @@
import {AViewerPluginSync, ThreeViewer} from '../../viewer'
import {serialize} from 'ts-browser-helpers'

export class ViewerUiConfigPlugin extends AViewerPluginSync<''> {
static readonly PluginType = 'ViewerUiConfigPlugin'
enabled = true
serializeWithViewer = false
constructor() {
super()
this.uiConfig = {}
}
onAdded(viewer: ThreeViewer) {
super.onAdded(viewer)
this.uiConfig = viewer.uiConfig
}

@serialize('viewer')
protected _viewer: ThreeViewer | undefined // todo: fix deserialization throwing error

// toJSON(): any {
// return this._viewer?.toJSON() ?? {}
// }
// fromJSON(data: ISerializedViewerConfig, meta?: SerializationMetaType): this | null {
// this._viewer?.fromJSON(data, meta)
// return this
// }
}

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