diff --git a/.eslintrc.js b/.eslintrc.js index 849d004..0a0effc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -49,5 +49,8 @@ module.exports = { // }], // 'vue/valid-template-root': 'off', 'vue/no-multiple-template-root': 'off', + + 'no-empty-function': 'off', + '@typescript-eslint/no-empty-function': ['warn'], }, } diff --git a/src/core/Camera.ts b/src/core/Camera.ts index 5ca5033..727fcf1 100644 --- a/src/core/Camera.ts +++ b/src/core/Camera.ts @@ -1,5 +1,5 @@ import { defineComponent } from 'vue' -// import Object3D from '../core/Object3D'; +// import Object3D from '../core/Object3D' export default defineComponent({ // TODO: eventually extend Object3D, for now: error 'injection "scene" not found' diff --git a/src/core/Object3D.ts b/src/core/Object3D.ts index b4dba13..c49e312 100644 --- a/src/core/Object3D.ts +++ b/src/core/Object3D.ts @@ -31,7 +31,7 @@ export default defineComponent({ // TODO : fix lookat.x if (this.lookAt) this.o3d.lookAt(this.lookAt.x, this.lookAt.y, this.lookAt.z) - watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z); }, { deep: true }) + watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z) }, { deep: true }) this._parent = this.getParent() if (this.addToParent()) this.$emit('ready', this) diff --git a/src/core/OrthographicCamera.ts b/src/core/OrthographicCamera.ts index 370019b..e952579 100644 --- a/src/core/OrthographicCamera.ts +++ b/src/core/OrthographicCamera.ts @@ -23,11 +23,12 @@ export default defineComponent({ } }, created() { - bindProp(this, 'position', this.camera); + bindProp(this, 'position', this.camera) - ['left', 'right', 'top', 'bottom', 'near', 'far', 'zoom'].forEach(p => { + const watchProps = ['left', 'right', 'top', 'bottom', 'near', 'far', 'zoom'] + watchProps.forEach(p => { watch(() => this[p], () => { - this.camera[p] = this[p]; + this.camera[p] = this[p] this.camera.updateProjectionMatrix() }) }) diff --git a/src/core/Renderer.ts b/src/core/Renderer.ts index 0b3fc6b..777ee69 100644 --- a/src/core/Renderer.ts +++ b/src/core/Renderer.ts @@ -18,6 +18,7 @@ export default defineComponent({ }, setup() { const renderer: null | WebGLRenderer = null + const _render: {(): void} = () => {} const onMountedCallbacks: {(): void}[] = [] const beforeRenderCallbacks: {(): void}[] = [] @@ -27,6 +28,7 @@ export default defineComponent({ three: useThree(), renderer, raf: true, + _render, onMountedCallbacks, beforeRenderCallbacks, afterRenderCallbacks, @@ -64,7 +66,7 @@ export default defineComponent({ } else { requestAnimationFrame(this.renderLoop) } - }; + } this.onMountedCallbacks.forEach(c => c()) }, diff --git a/src/core/usePointer.ts b/src/core/usePointer.ts index d7893c2..5503819 100644 --- a/src/core/usePointer.ts +++ b/src/core/usePointer.ts @@ -16,8 +16,8 @@ export interface PointerIntersectEventInterface { intersect?: Intersection } +export type PointerCallbackType = (e: PointerEventInterface) => void export type PointerIntersectCallbackType = (e: PointerIntersectEventInterface) => void - export type IntersectObject = Mesh | InstancedMesh export interface PointerConfigInterface { @@ -29,15 +29,15 @@ export interface PointerConfigInterface { resetOnEnd?: boolean resetPosition?: Vector2 resetPositionV3?: Vector3 - onEnter?(e: PointerEventInterface): void - onMove?(e: PointerEventInterface): void - onLeave?(e: PointerEventInterface): void - onClick?(e: PointerEventInterface): void - onIntersectEnter: PointerIntersectCallbackType - onIntersectOver: PointerIntersectCallbackType - onIntersectMove: PointerIntersectCallbackType - onIntersectLeave: PointerIntersectCallbackType - onIntersectClick: PointerIntersectCallbackType + onEnter?: PointerCallbackType + onMove?: PointerCallbackType + onLeave?: PointerCallbackType + onClick?: PointerCallbackType + onIntersectEnter?: PointerIntersectCallbackType + onIntersectOver?: PointerIntersectCallbackType + onIntersectMove?: PointerIntersectCallbackType + onIntersectLeave?: PointerIntersectCallbackType + onIntersectClick?: PointerIntersectCallbackType } export interface PointerInterface { diff --git a/src/core/useRaycaster.ts b/src/core/useRaycaster.ts index c161517..d28e862 100644 --- a/src/core/useRaycaster.ts +++ b/src/core/useRaycaster.ts @@ -1,4 +1,4 @@ -import { Camera, Intersection, Plane, Raycaster, Vector2, Vector3 } from 'three'; +import { Camera, Intersection, Plane, Raycaster, Vector2, Vector3 } from 'three' import { IntersectObject } from './usePointer' export interface RaycasterInterface { diff --git a/src/core/useThree.ts b/src/core/useThree.ts index 52461cf..ad31fce 100644 --- a/src/core/useThree.ts +++ b/src/core/useThree.ts @@ -73,9 +73,9 @@ export default function useThree(): ThreeInterface { // const afterInitCallbacks: void[] = [] // let afterResizeCallbacks: void[] = [] // let beforeRenderCallbacks: void[] = [] - const afterInitCallbacks: {(): void;}[] = [] - let afterResizeCallbacks: {(): void;}[] = [] - let beforeRenderCallbacks: {(): void;}[] = [] + const afterInitCallbacks: {(): void}[] = [] + let afterResizeCallbacks: {(): void}[] = [] + let beforeRenderCallbacks: {(): void}[] = [] const intersectObjects: IntersectObject[] = [] @@ -294,7 +294,8 @@ export default function useThree(): ThreeInterface { size.wHeight = oCamera.top - oCamera.bottom } else { const wsize = getCameraSize() - size.wWidth = wsize[0]; size.wHeight = wsize[1] + size.wWidth = wsize[0] + size.wHeight = wsize[1] } }