Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
Refactor; Add loaders; Start debugger refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
FarazzShaikh committed May 1, 2022
1 parent 7538403 commit 7eed7de
Show file tree
Hide file tree
Showing 41 changed files with 911 additions and 890 deletions.
150 changes: 150 additions & 0 deletions examples/example-configurator/public/Monkey w_ freckles.json

Large diffs are not rendered by default.

Binary file added examples/example-configurator/public/UV.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 10 additions & 22 deletions examples/example-configurator/src/Monkey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Auto-generated by: https://github.com/pmndrs/gltfjsx
*/

import React, { useEffect, useMemo, useState } from 'react'
import { useGLTF, TransformControls, OrbitControls } from '@react-three/drei'
import { Color, DebugLayerMaterial, Depth, LayerMaterial } from 'lamina'
import React, { useState } from 'react'
import { useGLTF, TransformControls, OrbitControls, useTexture } from '@react-three/drei'
import { DebugLayerMaterial } from 'lamina/debug'
import * as LAYERS from 'lamina'
import { button, useControls } from 'leva'
import { SerializedLayer } from 'lamina/types'
import { Texture } from 'lamina'

export default function Monkey() {
const { nodes, scene } = useGLTF('/monkey.glb') as any
const { nodes } = useGLTF('/monkey.glb') as any
const orbitControls = React.useRef<any>(null!)
const transformControls = React.useRef<any>(null!)

Expand All @@ -24,21 +24,7 @@ export default function Monkey() {
})

const [layers, setLayers] = useState<any[]>([])
const [materialProps, setMaterialProps] = useState<{ [key: string]: any }>({})

useEffect(() => {
;(async () => {
const json = await (await fetch('/initialMaterial.json')).json()
const l = json.layers.map((layer: SerializedLayer) => {
// @ts-ignore
const Component = LAYERS[layer.constructor]
return <Component {...layer.properties} />
})

setMaterialProps(json.properties)
setLayers(l)
})()
}, [])
const InitialMaterial = LAYERS.useLamina('/Monkey w_ freckles.json')

useControls('Layers', {
Type: {
Expand All @@ -64,13 +50,15 @@ export default function Monkey() {
}),
})

const tex = useTexture('/UV.jpg')

return (
<>
<TransformControls ref={transformControls}>
<group scale={0.1} rotation={[0, -Math.PI / 2, Math.PI / 4]}>
<mesh matrixAutoUpdate geometry={nodes.Suzanne.geometry} rotation-y={Math.PI / 2} scale={30}>
<DebugLayerMaterial transparent {...materialProps}>
{...layers}
<DebugLayerMaterial>
<InitialMaterial>{layers}</InitialMaterial>
</DebugLayerMaterial>
</mesh>
</group>
Expand Down
57 changes: 22 additions & 35 deletions examples/example-configurator/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1519,9 +1519,9 @@ destroy@1.2.0:
integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==

detect-gpu@^4.0.19:
version "4.0.19"
resolved "https://registry.yarnpkg.com/detect-gpu/-/detect-gpu-4.0.19.tgz#e89abefb7de298405186e8a0b6f7fb6a156ad66e"
integrity sha512-ZOPhyEkOBc1WqCfrdB6ymLW5MZqxge2QPvqPt/MhWev+vBrAwxH452dkghRfdNYvCikmjUnsZsHQtBpmXH4uJA==
version "4.0.20"
resolved "https://registry.yarnpkg.com/detect-gpu/-/detect-gpu-4.0.20.tgz#e0eb95bfc6f6e96303c8140dc7b206be43dd5a0a"
integrity sha512-pHQnqxYn4TC9Xw6b4DZCJxn+X+YGcPp4c+Eq6u6OhjbrniZeqiQiBFN3Sz2JuNanx4IzyDvm2FTdj3yEmrAjYQ==
dependencies:
webgl-constants "^1.1.1"

Expand Down Expand Up @@ -1603,9 +1603,9 @@ ee-first@1.1.1:
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=

electron-to-chromium@^1.4.118:
version "1.4.127"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.127.tgz#4ef19d5d920abe2676d938f4170729b44f7f423a"
integrity sha512-nhD6S8nKI0O2MueC6blNOEZio+/PWppE/pevnf3LOlQA/fKPCrDp2Ao4wx4LFwmIkJpVdFdn2763YWLy9ENIZg==
version "1.4.129"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.129.tgz#c675793885721beefff99da50f57c6525c2cd238"
integrity sha512-GgtN6bsDtHdtXJtlMYZWGB/uOyjZWjmRDumXTas7dGBaB9zUyCjzHet1DY2KhyHN8R0GLbzZWqm4efeddqqyRQ==

encodeurl@~1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -1713,9 +1713,9 @@ execa@^5.0.0:
strip-final-newline "^2.0.0"

express@^4.17.3:
version "4.18.0"
resolved "https://registry.yarnpkg.com/express/-/express-4.18.0.tgz#7a426773325d0dd5406395220614c0db10b6e8e2"
integrity sha512-EJEXxiTQJS3lIPrU1AE2vRuT7X7E+0KBbpm5GSoK524yl0K8X+er8zS2P14E64eqsVNoWbMCT7MpmQ+ErAhgRg==
version "4.18.1"
resolved "https://registry.yarnpkg.com/express/-/express-4.18.1.tgz#7797de8b9c72c857b9cd0e14a5eea80666267caf"
integrity sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q==
dependencies:
accepts "~1.3.8"
array-flatten "1.1.1"
Expand Down Expand Up @@ -1837,9 +1837,9 @@ for-in@^1.0.2:
integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=

fork-ts-checker-webpack-plugin@^7.2.1:
version "7.2.8"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-7.2.8.tgz#afe403ed92bb49a3456549ee518e28b35d213452"
integrity sha512-kvOM0w3Hi66o3qNLWNN9mWcMXwZNjuQ0+LMloxAM+QL5ZRGV6sLZnFyM86qKLNWklEG5XofcYWSAVosjtNg+vg==
version "7.2.9"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-7.2.9.tgz#4677c1bde10b492df6dc56ebaa538c14f0370782"
integrity sha512-tiK7gAyND3pK7CFXgKXjzBQ4w2SuxPCHDsIUSN7qJD6vUNKt2LHAb+4nxm5GhxI5ADK8aFYIWQv3knC24k4sRg==
dependencies:
"@babel/code-frame" "^7.16.7"
chalk "^4.1.2"
Expand Down Expand Up @@ -2389,20 +2389,7 @@ ktx-parse@^0.2.1:
resolved "https://registry.yarnpkg.com/ktx-parse/-/ktx-parse-0.2.2.tgz#b037b66044855215b332cb73104590af49e47791"
integrity sha512-cFBc1jnGG2WlUf52NbDUXK2obJ+Mo9WUkBRvr6tP6CKxRMvZwDDFNV3JAS4cewETp5KyexByfWm9sm+O8AffiQ==

lamina@^1.1.16, lamina@^1.1.17:
version "1.1.17"
resolved "https://registry.yarnpkg.com/lamina/-/lamina-1.1.17.tgz#9f2141debac6b1d9e4e2b23bb08f205a8166ccd1"
integrity sha512-VwsS791VZ/IPH+DQ7nIqJZz9Orcwbb6KmMZeKSbKeQleKYDMVAJLvAf7yXb8D0N3hYo67anc+HkoeacGgh3e6w==
dependencies:
glsl-token-descope "^1.0.2"
glsl-token-functions "^1.0.1"
glsl-token-string "^1.0.1"
glsl-tokenizer "^2.1.5"
lamina "^1.1.16"
leva "^0.9.20"
three-custom-shader-material "^3.3.3"

lamina@^1.1.18:
lamina@^1.1.17, lamina@^1.1.18:
version "1.1.18"
resolved "https://registry.yarnpkg.com/lamina/-/lamina-1.1.18.tgz#0de06c2698eba89708426f0f22e9a77a066f1bfa"
integrity sha512-v9xWmIqTfRSpp2VFg+Y6IpXvRtRsVlLxvdq1iLpl2yxukMvumFdp8M79QNciVgHh7UbaK3C9sOF6bUTsPwNipA==
Expand Down Expand Up @@ -2628,7 +2615,7 @@ multicast-dns@^7.2.4:
dns-packet "^5.2.2"
thunky "^1.0.2"

nanoid@*, nanoid@^3.3.1, nanoid@^3.3.3:
nanoid@*, nanoid@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25"
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
Expand Down Expand Up @@ -2916,11 +2903,11 @@ postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==

postcss@^8.4.7:
version "8.4.12"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.12.tgz#1e7de78733b28970fa4743f7da6f3763648b1905"
integrity sha512-lg6eITwYe9v6Hr5CncVbK70SoioNQIq81nsaG86ev5hAidQvmOeETBqs7jm43K2F5/Ley3ytDtriImV6TpNiSg==
version "8.4.13"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.13.tgz#7c87bc268e79f7f86524235821dfdf9f73e5d575"
integrity sha512-jtL6eTBrza5MPzy8oJLFuUscHDXTV5KcLlqAWHl5q5WYRfnNRGSmOZmOZ1T6Gy7A99mOZfqungmZMpMmCVJ8ZA==
dependencies:
nanoid "^3.3.1"
nanoid "^3.3.3"
picocolors "^1.0.0"
source-map-js "^1.0.2"

Expand Down Expand Up @@ -3554,7 +3541,7 @@ terser@^5.10.0, terser@^5.7.2:
source-map "~0.8.0-beta.0"
source-map-support "~0.5.20"

three-custom-shader-material@^3.3.3, three-custom-shader-material@^3.3.4:
three-custom-shader-material@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/three-custom-shader-material/-/three-custom-shader-material-3.3.4.tgz#e96e50d6d29b9647bcaa089deee65e4942b46521"
integrity sha512-WjdFw/eobZfr5ezzzpFWF7Jn/YHYOKshDDboF1rplfCePSKUegwlZyfkC3/Et3m7RCNb7QHmYqb542ad2+m2hw==
Expand Down Expand Up @@ -3651,9 +3638,9 @@ troika-worker-utils@^0.46.0:
integrity sha512-bzOx5f2ZBxkFhXtIvDJlLn2AI3bzCkGVbCndl/2dL5QZrwHEKl45OEIilCxYQQWJG1rEbOD9O80tMjoYjw19OA==

ts-loader@^9.2.8:
version "9.2.9"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.9.tgz#0653e07fa1b4f225d0ca57a84fddbfd43d930f9e"
integrity sha512-b0+vUY2/enb0qYtDQuNlDnJ9900NTiPiJcDJ6sY7ax1CCCwXfYIqPOMm/BwW7jsF1km+Oz8W9s31HLuD+FLIMg==
version "9.3.0"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.3.0.tgz#980f4dbfb60e517179e15e10ed98e454b132159f"
integrity sha512-2kLLAdAD+FCKijvGKi9sS0OzoqxLCF3CxHpok7rVgCZ5UldRzH0TkbwG9XECKjBzHsAewntC5oDaI/FwKzEUog==
dependencies:
chalk "^4.1.0"
enhanced-resolve "^5.0.0"
Expand Down
40 changes: 20 additions & 20 deletions examples/mesh-gradients/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3790,9 +3790,9 @@ destroy@1.2.0:
integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==

detect-gpu@^4.0.19:
version "4.0.19"
resolved "https://registry.yarnpkg.com/detect-gpu/-/detect-gpu-4.0.19.tgz#e89abefb7de298405186e8a0b6f7fb6a156ad66e"
integrity sha512-ZOPhyEkOBc1WqCfrdB6ymLW5MZqxge2QPvqPt/MhWev+vBrAwxH452dkghRfdNYvCikmjUnsZsHQtBpmXH4uJA==
version "4.0.20"
resolved "https://registry.yarnpkg.com/detect-gpu/-/detect-gpu-4.0.20.tgz#e0eb95bfc6f6e96303c8140dc7b206be43dd5a0a"
integrity sha512-pHQnqxYn4TC9Xw6b4DZCJxn+X+YGcPp4c+Eq6u6OhjbrniZeqiQiBFN3Sz2JuNanx4IzyDvm2FTdj3yEmrAjYQ==
dependencies:
webgl-constants "^1.1.1"

Expand Down Expand Up @@ -3977,9 +3977,9 @@ ejs@^3.1.6:
jake "^10.8.5"

electron-to-chromium@^1.4.118:
version "1.4.127"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.127.tgz#4ef19d5d920abe2676d938f4170729b44f7f423a"
integrity sha512-nhD6S8nKI0O2MueC6blNOEZio+/PWppE/pevnf3LOlQA/fKPCrDp2Ao4wx4LFwmIkJpVdFdn2763YWLy9ENIZg==
version "1.4.129"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.129.tgz#c675793885721beefff99da50f57c6525c2cd238"
integrity sha512-GgtN6bsDtHdtXJtlMYZWGB/uOyjZWjmRDumXTas7dGBaB9zUyCjzHet1DY2KhyHN8R0GLbzZWqm4efeddqqyRQ==

emittery@^0.10.2:
version "0.10.2"
Expand Down Expand Up @@ -4421,9 +4421,9 @@ expect@^27.5.1:
jest-message-util "^27.5.1"

express@^4.17.3:
version "4.18.0"
resolved "https://registry.yarnpkg.com/express/-/express-4.18.0.tgz#7a426773325d0dd5406395220614c0db10b6e8e2"
integrity sha512-EJEXxiTQJS3lIPrU1AE2vRuT7X7E+0KBbpm5GSoK524yl0K8X+er8zS2P14E64eqsVNoWbMCT7MpmQ+ErAhgRg==
version "4.18.1"
resolved "https://registry.yarnpkg.com/express/-/express-4.18.1.tgz#7797de8b9c72c857b9cd0e14a5eea80666267caf"
integrity sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q==
dependencies:
accepts "~1.3.8"
array-flatten "1.1.1"
Expand Down Expand Up @@ -6070,9 +6070,9 @@ jsonpointer@^5.0.0:
integrity sha512-PNYZIdMjVIvVgDSYKTT63Y+KZ6IZvGRNNWcxwD+GNnUz1MKPfv30J8ueCjdwcN0nDx2SlshgyB7Oy0epAzVRRg==

"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.2.1:
version "3.2.2"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.2.2.tgz#6ab1e52c71dfc0c0707008a91729a9491fe9f76c"
integrity sha512-HDAyJ4MNQBboGpUnHAVUNJs6X0lh058s6FuixsFGP7MgJYpD6Vasd6nzSG5iIfXu1zAYlHJ/zsOKNlrenTUBnw==
version "3.3.0"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.0.tgz#e624f259143b9062c92b6413ff92a164c80d3ccb"
integrity sha512-XzO9luP6L0xkxwhIJMTJQpZo/eeN60K08jHdexfD569AGxeNug6UketeHXEhROoM8aR7EcUoOQmIhcJQjcuq8Q==
dependencies:
array-includes "^3.1.4"
object.assign "^4.1.2"
Expand Down Expand Up @@ -6470,7 +6470,7 @@ multicast-dns@^7.2.4:
dns-packet "^5.2.2"
thunky "^1.0.2"

nanoid@*, nanoid@^3.3.1, nanoid@^3.3.3:
nanoid@*, nanoid@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25"
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
Expand Down Expand Up @@ -7416,11 +7416,11 @@ postcss@^7.0.35:
source-map "^0.6.1"

postcss@^8.3.5, postcss@^8.4.12, postcss@^8.4.4, postcss@^8.4.7:
version "8.4.12"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.12.tgz#1e7de78733b28970fa4743f7da6f3763648b1905"
integrity sha512-lg6eITwYe9v6Hr5CncVbK70SoioNQIq81nsaG86ev5hAidQvmOeETBqs7jm43K2F5/Ley3ytDtriImV6TpNiSg==
version "8.4.13"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.13.tgz#7c87bc268e79f7f86524235821dfdf9f73e5d575"
integrity sha512-jtL6eTBrza5MPzy8oJLFuUscHDXTV5KcLlqAWHl5q5WYRfnNRGSmOZmOZ1T6Gy7A99mOZfqungmZMpMmCVJ8ZA==
dependencies:
nanoid "^3.3.1"
nanoid "^3.3.3"
picocolors "^1.0.0"
source-map-js "^1.0.2"

Expand Down Expand Up @@ -7974,9 +7974,9 @@ rollup-plugin-terser@^7.0.0:
terser "^5.0.0"

rollup@^2.43.1:
version "2.70.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.70.2.tgz#808d206a8851628a065097b7ba2053bd83ba0c0d"
integrity sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==
version "2.71.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.71.1.tgz#82b259af7733dfd1224a8171013aaaad02971a22"
integrity sha512-lMZk3XfUBGjrrZQpvPSoXcZSfKcJ2Bgn+Z0L1MoW2V8Wh7BVM+LOBJTPo16yul2MwL59cXedzW1ruq3rCjSRgw==
optionalDependencies:
fsevents "~2.3.2"

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"types": "./vanilla.d.ts",
"require": "./vanilla.cjs.js",
"import": "./vanilla.js"
},
"./debug": {
"types": "./debug.d.ts",
"require": "./debug.cjs.js",
"import": "./debug.js"
}
},
"keywords": [
Expand Down
16 changes: 14 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ const getBabelOptions = ({ useESModules }) => ({

export default [
{
input: `./src/index.tsx`,
input: `./src/index.ts`,
output: { file: `dist/index.js`, format: 'esm' },
external,
plugins: [babel(getBabelOptions({ useESModules: true })), resolve({ extensions })],
},
{
input: `./src/index.tsx`,
input: `./src/index.ts`,
output: { file: `dist/index.cjs.js`, format: 'cjs' },
external,
plugins: [babel(getBabelOptions({ useESModules: false })), resolve({ extensions })],
Expand All @@ -58,4 +58,16 @@ export default [
external,
plugins: [babel(getBabelOptions({ useESModules: false })), resolve({ extensions })],
},
{
input: `./src/debug.ts`,
output: { file: `dist/debug.js`, format: 'esm' },
external,
plugins: [babel(getBabelOptions({ useESModules: true })), resolve({ extensions })],
},
{
input: `./src/debug.ts`,
output: { file: `dist/debug.cjs.js`, format: 'cjs' },
external,
plugins: [babel(getBabelOptions({ useESModules: false })), resolve({ extensions })],
},
]
10 changes: 10 additions & 0 deletions scripts/link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ cd ../../../
yarn link three
yarn link @react-three/fiber
cd ../../

cd ./examples/example-configurator
rm -rf ./node_modeules ./yarn.lock
yarn

yarn link lamina
yarn link react
yarn link three
yarn link @react-three/fiber
cd ../../
13 changes: 0 additions & 13 deletions src/CSM/index.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions src/CSM/keywords.ts

This file was deleted.

42 changes: 0 additions & 42 deletions src/CSM/patchMaps.ts

This file was deleted.

Loading

0 comments on commit 7eed7de

Please sign in to comment.