@bbki.ng/site 1.7.6 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 1.7.8
4
+
5
+ ## 1.7.7
6
+
3
7
  ## 1.7.6
4
8
 
5
9
  ## 1.7.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "1.7.6",
3
+ "version": "1.7.8",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@
16
16
  "url": "git+https://github.com/bbbottle/bbki.ng.git"
17
17
  },
18
18
  "dependencies": {
19
- "@bbki.ng/components": "workspace:2.5.6",
19
+ "@bbki.ng/components": "workspace:2.5.7",
20
20
  "@supabase/supabase-js": "^1.35.4",
21
21
  "classnames": "2.3.1",
22
22
  "react": "^18.0.0",
@@ -7,7 +7,7 @@ export const EffectContextProvider = (props: { children: ReactNode }) => {
7
7
  return (
8
8
  <EffectContext.Provider value={{}}>
9
9
  <>
10
- {/*<EffectLayer />*/}
10
+ <EffectLayer />
11
11
  {props.children}
12
12
  </>
13
13
  </EffectContext.Provider>
@@ -1,19 +1,27 @@
1
- import {useCallback, useState} from "react";
2
- import {useMousePosition} from "@/hooks/use_mouse_position";
1
+ import { useCallback, useState } from "react";
2
+ import { useMousePosition } from "@/hooks/use_mouse_position";
3
+ import { useResolution } from "@/components/effect-layer/hooks/useResolution";
3
4
 
4
5
  export const useRender = () => {
5
- const [inst, setInst] = useState<any>(null)
6
+ const [inst, setInst] = useState<any>(null);
6
7
  const pos = useMousePosition();
8
+ const resolution = useResolution();
7
9
 
8
- const onRender = useCallback((p: any) => {
9
- if (inst === null) {
10
- setInst(p)
11
- return;
12
- }
10
+ const onRender = useCallback(
11
+ (p: any) => {
12
+ if (inst === null) {
13
+ setInst(p);
14
+ return;
15
+ }
13
16
 
14
- inst.uniforms.uMouse.value[0] = pos.current.x;
15
- inst.uniforms.uMouse.value[1] = pos.current.y;
16
- }, [inst]);
17
+ inst.uniforms.uResolution.value[0] = resolution.current[0];
18
+ inst.uniforms.uResolution.value[1] = resolution.current[1];
17
19
 
18
- return { inst, onRender }
19
- }
20
+ inst.uniforms.uMouse.value[0] = pos.current.x;
21
+ inst.uniforms.uMouse.value[1] = pos.current.y;
22
+ },
23
+ [inst]
24
+ );
25
+
26
+ return { inst, onRender };
27
+ };
@@ -0,0 +1,25 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ export const useResolution = () => {
4
+ const resolution = useRef<[number, number]>([
5
+ window.innerWidth,
6
+ window.innerHeight,
7
+ ]);
8
+ useEffect(() => {
9
+ const updateResolution = () => {
10
+ resolution.current = [window.innerWidth, window.innerHeight];
11
+ };
12
+
13
+ window.addEventListener("resize", updateResolution);
14
+
15
+ // touch move
16
+ window.addEventListener("touchmove", updateResolution);
17
+
18
+ return () => {
19
+ window.removeEventListener("resize", updateResolution);
20
+ window.removeEventListener("touchmove", updateResolution);
21
+ };
22
+ }, []);
23
+
24
+ return resolution;
25
+ };
@@ -3,11 +3,8 @@ precision mediump float;
3
3
  uniform vec2 uResolution;
4
4
  uniform float uProgress;
5
5
  uniform float uDevicePixelRatio;
6
- uniform vec2 uCenter;
7
- uniform vec2 uOffset;
8
6
 
9
7
  #define DefaultColor vec4(0.0, 0.0, 0.0, 0.0)
10
- #define CenterPos uCenter * uDevicePixelRatio / uResolution
11
8
 
12
9
  #include "effects/grain.frag"
13
10
  //#include "shapes/circle.frag"
@@ -2,29 +2,17 @@ export default {
2
2
  uResolution: {
3
3
  type: "vec2",
4
4
  value: [
5
- Math.min(innerWidth, innerHeight),
6
- Math.min(innerWidth, innerHeight),
5
+ innerWidth, innerHeight,
7
6
  ],
8
7
  },
9
8
  uDevicePixelRatio: {
10
9
  type: "float",
11
10
  value: [devicePixelRatio],
12
11
  },
13
- uOffset: {
14
- type: "vec2",
15
- value: [
16
- (innerWidth / innerHeight) > 1 ? (innerWidth - innerHeight) / 2 : 0,
17
- (innerWidth / innerHeight) < 1 ? (innerHeight - innerWidth) / 2 : 0,
18
- ],
19
- },
20
12
  pi: {
21
13
  type: "float",
22
14
  value: [Math.PI],
23
15
  },
24
- uCenter: {
25
- type: "vec2",
26
- value: [innerWidth / 2, innerHeight / 2],
27
- },
28
16
  uMouse: {
29
17
  type: "vec2",
30
18
  value: [0, 0],