From d86b243df61c9b70db3fd77fd3c285b720024780 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Thu, 22 Apr 2021 12:02:41 +0200 Subject: [PATCH] add onClick to renderer --- src/core/Renderer.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/Renderer.ts b/src/core/Renderer.ts index f812fb8..843a484 100644 --- a/src/core/Renderer.ts +++ b/src/core/Renderer.ts @@ -100,6 +100,7 @@ export default defineComponent({ height: String, xr: Boolean, onReady: Function as PropType<(r: RendererInterface) => void>, + onClick: Function as PropType<(this: HTMLCanvasElement, ev: MouseEvent) => any>, }, setup(props): RendererSetupInterface { const initCallbacks: InitCallbackType[] = [] @@ -126,6 +127,11 @@ export default defineComponent({ const renderFn: {(): void} = () => {} + // we have to handle canvas events ourself (it is not rendered by vue) + if (props.onClick) { + canvas.addEventListener('click', props.onClick) + } + return { canvas, three,