Skip to content

Commit

Permalink
fix theatre
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed May 24, 2024
1 parent 16ce5a4 commit 6a2e08d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 166 deletions.
19 changes: 19 additions & 0 deletions app/(pages)/r3f/(components)/box/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { useFrame } from '@darkroom.engineering/hamo'
import { OrbitControls } from '@react-three/drei'
import { useSheet } from 'libs/theatre'
import { useTheatre } from 'libs/theatre/hooks/use-theatre'
import { WebGLTunnel } from 'libs/webgl/components/tunnel'
import { useRef } from 'react'

Expand All @@ -14,6 +16,23 @@ export function Box() {
meshRef.current.rotation.y = time * 0.0001
})

const sheet = useSheet('webgl')
useTheatre(
sheet,
'box',
{
x: 0,
y: 0,
z: 0,
},
{
onValuesChange: ({ x, y, z }) => {
if (!meshRef.current) return
meshRef.current.position.set(x, y, z)
},
},
)

return (
<WebGLTunnel>
<OrbitControls />
Expand Down
6 changes: 2 additions & 4 deletions libs/theatre/hooks/use-theatre.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { useCurrentRafDriver } from '..'
import { useStudio } from './use-studio'

export function useTheatreObject(sheet, theatreKey, config, deps = []) {
Expand All @@ -25,7 +24,6 @@ export function useTheatre(
{ onValuesChange, lazy = true, deps = [] } = {},
) {
const object = useTheatreObject(sheet, theatreKey, config, deps)
const rafDriver = useCurrentRafDriver()

const [values, setValues] = useState({})
const lazyValues = useRef({})
Expand All @@ -39,11 +37,11 @@ export function useTheatre(
if (!lazy) setValues(values)

onValuesChange?.(values)
}, rafDriver)
})

return unsubscribe
}
}, [object, rafDriver, lazy, ...deps])
}, [object, lazy, ...deps])

const studio = useStudio()

Expand Down
1 change: 1 addition & 0 deletions libs/theatre/studio/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@theatre/core'
import studio from '@theatre/studio'
import { useEffect } from 'react'
import s from './studio.module.scss'
Expand Down
182 changes: 26 additions & 156 deletions public/sw.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions public/swe-worker-development.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
/******/ "use strict";
/******/ var __webpack_modules__ = ({

/***/ "./node_modules/.pnpm/@[email protected].0-preview.21_next@14.2.[email protected][email protected]/node_modules/@serwist/next/dist/sw-entry-worker.js":
/*!**********************************************************************************************************************************************************!*\
!*** ./node_modules/.pnpm/@[email protected].0-preview.21_next@14.2.[email protected][email protected]/node_modules/@serwist/next/dist/sw-entry-worker.js ***!
\**********************************************************************************************************************************************************/
/***/ "./node_modules/.pnpm/@[email protected].2_next@14.2.3_@[email protected][email protected][email protected][email protected]._e2nkmeterpqllgsh44wfxk7k2q/node_modules/@serwist/next/dist/sw-entry-worker.js":
/*!********************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/.pnpm/@[email protected].2_next@14.2.3_@[email protected][email protected][email protected][email protected]._e2nkmeterpqllgsh44wfxk7k2q/node_modules/@serwist/next/dist/sw-entry-worker.js ***!
\********************************************************************************************************************************************************************************************************/
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

eval(__webpack_require__.ts("__webpack_require__.r(__webpack_exports__);\nself.onmessage = async (ev)=>{\n switch(ev.data.type){\n case \"__START_URL_CACHE__\":\n {\n const url = ev.data.url;\n const response = await fetch(url);\n if (!response.redirected) {\n const startUrlCache = await caches.open(\"start-url\");\n return startUrlCache.put(url, response);\n }\n return Promise.resolve();\n }\n case \"__FRONTEND_NAV_CACHE__\":\n {\n const url = ev.data.url;\n const pagesCache = await caches.open(\"pages\");\n const isPageCached = !!await pagesCache.match(url, {\n ignoreSearch: true\n });\n if (isPageCached) {\n return;\n }\n const page = await fetch(url);\n if (!page.ok) {\n return;\n }\n pagesCache.put(url, page.clone());\n return Promise.resolve();\n }\n default:\n return Promise.resolve();\n }\n};\n//# sourceURL=[module]\n//# sourceM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XJlc3BvbnNlLnJlZGlyZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RhcnRVcmxDYWNoZSA9IGF3YWl0IGNhY2hlcy5vcGVuKFwic3RhcnQtdXJsXCIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RhcnRVcmxDYWNoZS5wdXQodXJsLCByZXNwb25zZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgY2FzZSBcIl9fRlJPTlRFTkRfTkFWX0NBQ0hFX19cIjpcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBldi5kYXRhLnVybDtcbiAgICAgICAgICAgICAgICBjb25zdCBwYWdlc0NhY2hlID0gYXdhaXQgY2FjaGVzLm9wZW4oXCJwYWdlc1wiKTtcbiAgICAgICAgICAgICAgICBjb25zdCBpc1BhZ2VDYWNoZWQgPSAhIWF3YWl0IHBhZ2VzQ2FjaGUubWF0Y2godXJsLCB7XG4gICAgICAgICAgICAgICAgICAgIGlnbm9yZVNlYXJjaDogdHJ1ZVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmIChpc1BhZ2VDYWNoZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gYXdhaXQgZmV0Y2godXJsKTtcbiAgICAgICAgICAgICAgICBpZiAoIXBhZ2Uub2spIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwYWdlc0NhY2hlLnB1dCh1cmwsIHBhZ2UuY2xvbmUoKSk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSgpO1xuICAgIH1cbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@serwist/next/dist/sw-entry-worker.js\n"));
eval(__webpack_require__.ts("__webpack_require__.r(__webpack_exports__);\nself.onmessage = async (ev)=>{\n switch(ev.data.type){\n case \"__START_URL_CACHE__\":\n {\n const url = ev.data.url;\n const response = await fetch(url);\n if (!response.redirected) {\n const startUrlCache = await caches.open(\"start-url\");\n return startUrlCache.put(url, response);\n }\n return Promise.resolve();\n }\n case \"__FRONTEND_NAV_CACHE__\":\n {\n const url = ev.data.url;\n const pagesCache = await caches.open(\"pages\");\n const isPageCached = !!await pagesCache.match(url, {\n ignoreSearch: true\n });\n if (isPageCached) {\n return;\n }\n const page = await fetch(url);\n if (!page.ok) {\n return;\n }\n pagesCache.put(url, page.clone());\n return Promise.resolve();\n }\n default:\n return Promise.resolve();\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9ub2RlX21vZHVsZXMvLnBucG0vQHNlcndpc3QrbmV4dEA5LjAuMl9uZXh0QDE0LjIuM19AYmFiZWwrY29yZUA3LjI0LjVfcmVhY3QtZG9tQDE4LjMuMV9yZWFjdEAxOC4zLjFfX3JlYWN0QDE4LjMuX2UybmttZXRlcnBxbGxnc2g0NHdmeGs3azJxL25vZGVfbW9kdWxlcy9Ac2Vyd2lzdC9uZXh0L2Rpc3Qvc3ctZW50cnktd29ya2VyLmpzIiwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO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EVfX1wiOlxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIGNvbnN0IHVybCA9IGV2LmRhdGEudXJsO1xuICAgICAgICAgICAgICAgIGNvbnN0IHBhZ2VzQ2FjaGUgPSBhd2FpdCBjYWNoZXMub3BlbihcInBhZ2VzXCIpO1xuICAgICAgICAgICAgICAgIGNvbnN0IGlzUGFnZUNhY2hlZCA9ICEhYXdhaXQgcGFnZXNDYWNoZS5tYXRjaCh1cmwsIHtcbiAgICAgICAgICAgICAgICAgICAgaWdub3JlU2VhcmNoOiB0cnVlXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgaWYgKGlzUGFnZUNhY2hlZCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnN0IHBhZ2UgPSBhd2FpdCBmZXRjaCh1cmwpO1xuICAgICAgICAgICAgICAgIGlmICghcGFnZS5vaykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHBhZ2VzQ2FjaGUucHV0KHVybCwgcGFnZS5jbG9uZSgpKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKCk7XG4gICAgfVxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///./node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected][email protected]._e2nkmeterpqllgsh44wfxk7k2q/node_modules/@serwist/next/dist/sw-entry-worker.js\n"));

/***/ })

Expand Down Expand Up @@ -96,7 +96,7 @@ eval(__webpack_require__.ts("__webpack_require__.r(__webpack_exports__);\nself.o
/******/ // Load entry module and return exports
/******/ // This entry module can't be inlined because the eval-source-map devtool is used.
/******/ var __webpack_exports__ = {};
/******/ __webpack_modules__["./node_modules/.pnpm/@[email protected].0-preview.21_next@14.2.[email protected][email protected]/node_modules/@serwist/next/dist/sw-entry-worker.js"](0, __webpack_exports__, __webpack_require__);
/******/ __webpack_modules__["./node_modules/.pnpm/@[email protected].2_next@14.2.3_@[email protected][email protected][email protected][email protected]._e2nkmeterpqllgsh44wfxk7k2q/node_modules/@serwist/next/dist/sw-entry-worker.js"](0, __webpack_exports__, __webpack_require__);
/******/
/******/ })()
;

1 comment on commit 6a2e08d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"⚡️ Lighthouse report for the changes in this commit:

🟢 Performance: 99
🟢 Accessibility: 94
🟢 Best practices: 96
🟢 SEO: 92
🟠 PWA: 88

Lighthouse ran on https://satus-lp5t3si62-darkroom-engineering.vercel.app/"

Please sign in to comment.