mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 11:42:19 -05:00
50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
import { EventDispatcher } from 'three'
|
|
|
|
export class CanvasProxy extends EventDispatcher {
|
|
style = { touchAction: '' }
|
|
clientWidth: number = 100
|
|
clientHeight: number = 100
|
|
realCanvas: HTMLCanvasElement
|
|
|
|
ownerDocument = this
|
|
|
|
constructor (canvas: HTMLCanvasElement) {
|
|
super()
|
|
this.realCanvas = canvas
|
|
}
|
|
|
|
getBoundingClientRect (): DOMRect {
|
|
return {
|
|
left: 0,
|
|
top: 0,
|
|
x: 0,
|
|
y: 0,
|
|
width: this.clientWidth,
|
|
height: this.clientHeight,
|
|
right: this.clientWidth,
|
|
bottom: this.clientHeight,
|
|
toJSON: () => ('')
|
|
}
|
|
}
|
|
|
|
resize (width, height): void {
|
|
this.clientWidth = width
|
|
this.clientHeight = height
|
|
this.realCanvas.width = width
|
|
this.realCanvas.height = height
|
|
}
|
|
|
|
handleEvent (event: Event): void {
|
|
event.preventDefault = function () { }
|
|
super.dispatchEvent(event)
|
|
}
|
|
|
|
// Pretend we can handle capture events
|
|
getRootNode (): CanvasProxy {
|
|
return this
|
|
}
|
|
|
|
setPointerCapture (): void {}
|
|
releasePointerCapture (): void {}
|
|
}
|