mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
wip: renderer
This commit is contained in:
parent
b5e03c5600
commit
3b53044f14
@ -65,16 +65,16 @@ interface RendererSetupInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RendererInterface extends RendererSetupInterface {
|
export interface RendererInterface extends RendererSetupInterface {
|
||||||
// onInit(cb: InitCallbackType): void
|
onInit(cb: InitCallbackType): void
|
||||||
// onMounted(cb: MountedCallbackType): void
|
onMounted(cb: MountedCallbackType): void
|
||||||
|
|
||||||
// onBeforeRender(cb: RenderCallbackType): void
|
onBeforeRender(cb: RenderCallbackType): void
|
||||||
// offBeforeRender(cb: RenderCallbackType): void
|
offBeforeRender(cb: RenderCallbackType): void
|
||||||
// onAfterRender(cb: RenderCallbackType): void
|
onAfterRender(cb: RenderCallbackType): void
|
||||||
// offAfterRender(cb: RenderCallbackType): void
|
offAfterRender(cb: RenderCallbackType): void
|
||||||
|
|
||||||
// onResize(cb: ResizeCallbackType): void
|
onResize(cb: ResizeCallbackType): void
|
||||||
// offResize(cb: ResizeCallbackType): void
|
offResize(cb: ResizeCallbackType): void
|
||||||
|
|
||||||
addListener<T extends keyof EventCallbackMap>(t: T, cb: EventCallbackMap[T]): void
|
addListener<T extends keyof EventCallbackMap>(t: T, cb: EventCallbackMap[T]): void
|
||||||
removeListener<T extends keyof EventCallbackMap>(t: T, cb: EventCallbackMap[T]): void
|
removeListener<T extends keyof EventCallbackMap>(t: T, cb: EventCallbackMap[T]): void
|
||||||
@ -151,10 +151,12 @@ export default defineComponent({
|
|||||||
// this.pointerPositionV3 = this.three.pointer.positionV3
|
// this.pointerPositionV3 = this.three.pointer.positionV3
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// TODO : don't use config
|
||||||
this.three.config.onResize = (size) => {
|
this.three.config.onResize = (size) => {
|
||||||
this.resizeCallbacks.forEach(e => e({ type: 'resize', renderer: this, size }))
|
this.resizeCallbacks.forEach(e => e({ type: 'resize', renderer: this, size }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO : improve shadow params
|
||||||
this.renderer.shadowMap.enabled = this.shadow
|
this.renderer.shadowMap.enabled = this.shadow
|
||||||
|
|
||||||
this.renderFn = this.three.composer ? this.three.renderC : this.three.render
|
this.renderFn = this.three.composer ? this.three.renderC : this.three.render
|
||||||
@ -180,30 +182,14 @@ export default defineComponent({
|
|||||||
this.three.dispose()
|
this.three.dispose()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// onInit(cb: InitCallbackType) {
|
onInit(cb: InitCallbackType) { this.addListener('init', cb) },
|
||||||
// this.initCallbacks.push(cb)
|
onMounted(cb: MountedCallbackType) { this.addListener('mounted', cb) },
|
||||||
// },
|
onBeforeRender(cb: RenderCallbackType) { this.addListener('beforerender', cb) },
|
||||||
// onMounted(cb: MountedCallbackType) {
|
offBeforeRender(cb: RenderCallbackType) { this.removeListener('beforerender', cb) },
|
||||||
// this.mountedCallbacks.push(cb)
|
onAfterRender(cb: RenderCallbackType) { this.addListener('afterrender', cb) },
|
||||||
// },
|
offAfterRender(cb: RenderCallbackType) { this.removeListener('afterrender', cb) },
|
||||||
// onBeforeRender(cb: RenderCallbackType) {
|
onResize(cb: ResizeCallbackType) { this.addListener('resize', cb) },
|
||||||
// this.beforeRenderCallbacks.push(cb)
|
offResize(cb: ResizeCallbackType) { this.removeListener('resize', cb) },
|
||||||
// },
|
|
||||||
// offBeforeRender(cb: RenderCallbackType) {
|
|
||||||
// this.beforeRenderCallbacks = this.beforeRenderCallbacks.filter(e => e !== cb)
|
|
||||||
// },
|
|
||||||
// onAfterRender(cb: RenderCallbackType) {
|
|
||||||
// this.afterRenderCallbacks.push(cb)
|
|
||||||
// },
|
|
||||||
// offAfterRender(cb: RenderCallbackType) {
|
|
||||||
// this.afterRenderCallbacks = this.afterRenderCallbacks.filter(e => e !== cb)
|
|
||||||
// },
|
|
||||||
// onResize(cb: ResizeCallbackType) {
|
|
||||||
// this.resizeCallbacks.push(cb)
|
|
||||||
// },
|
|
||||||
// offResize(cb: ResizeCallbackType) {
|
|
||||||
// this.resizeCallbacks = this.resizeCallbacks.filter(e => e !== cb)
|
|
||||||
// },
|
|
||||||
addListener(type: string, cb: {(): void}) {
|
addListener(type: string, cb: {(): void}) {
|
||||||
const callbacks = this.getCallbacks(type)
|
const callbacks = this.getCallbacks(type)
|
||||||
callbacks.push(cb)
|
callbacks.push(cb)
|
||||||
|
Loading…
Reference in New Issue
Block a user