Skip to content

Commit

Permalink
chore: move eslint method rule to TS files only
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaellis committed Mar 19, 2021
1 parent 028fb4f commit 6bef9ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"import/namespace": "off",
"import/default": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/explicit-member-accessibility": ["error", { "overrides": { "constructors": "no-public" } }],
"no-unused-vars": ["off"],
"no-var": "error",
"react/jsx-uses-react": "error",
Expand Down Expand Up @@ -73,7 +72,8 @@
// enable the rule specifically for TypeScript files
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["error", { "allowHigherOrderFunctions": true }]
"@typescript-eslint/explicit-function-return-type": ["error", { "allowHigherOrderFunctions": true }],
"@typescript-eslint/explicit-member-accessibility": ["error", { "overrides": { "constructors": "no-public" } }]
}
}
]
Expand Down
11 changes: 9 additions & 2 deletions .storybook/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Camera, Scene, PerspectiveCamera, WebGLRenderer, Clock } from 'three'
//@ts-ignore
import { OrbitControls } from '../src'

interface useThreeReturn {
camera: Camera
Expand Down Expand Up @@ -42,9 +44,10 @@ export const useThree = ({ useFrame }: useThreeProps = {}): useThreeReturn => {

const clock = new Clock()

function animate() {
requestAnimationFrame(animate)
const controls = new OrbitControls(camera, container)
controls.enableDamping = true

function animate() {
if (useFrame) {
useFrame(
{
Expand All @@ -54,7 +57,11 @@ export const useThree = ({ useFrame }: useThreeProps = {}): useThreeReturn => {
)
}

controls.update()

render()

requestAnimationFrame(animate)
}

function render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const Default = () => {
const spotLight = new SpotLight('white', 2, 35, Math.PI / 4, 2, 3.5)
spotLight.position.set(-3, 6, -4)

const { scene } = useThree({
const { scene, renderer } = useThree({
useFrame: (_, delta) => {
mesh.rotation.x += delta
mesh.rotation.y += delta
Expand All @@ -40,7 +40,11 @@ export const Default = () => {

scene.background = new Color(0x0000ff).convertSRGBToLinear()
scene.add(ambientLight, directionalLight, pointLight1, pointLight2, spotLight, mesh)
})

return () => {
renderer.dispose()
}
}, [])

return ''
}

0 comments on commit 6bef9ab

Please sign in to comment.