react-native-shine 0.3.0 → 0.3.2

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.
Files changed (99) hide show
  1. package/README.md +21 -6
  2. package/lib/module/components/Content.js +232 -0
  3. package/lib/module/components/Content.js.map +1 -0
  4. package/lib/module/components/Shine.js +18 -254
  5. package/lib/module/components/Shine.js.map +1 -1
  6. package/lib/module/components/ShineGroup.js +11 -23
  7. package/lib/module/components/ShineGroup.js.map +1 -1
  8. package/lib/module/hooks/useAnimationFrame.js +17 -0
  9. package/lib/module/hooks/useAnimationFrame.js.map +1 -0
  10. package/lib/module/hooks/useOrientation.js +2 -8
  11. package/lib/module/hooks/useOrientation.js.map +1 -1
  12. package/lib/module/index.js +3 -2
  13. package/lib/module/index.js.map +1 -1
  14. package/lib/module/shaders/bindGroupLayouts.js +8 -8
  15. package/lib/module/shaders/bindGroupLayouts.js.map +1 -1
  16. package/lib/module/shaders/bindGroupUtils.js +18 -40
  17. package/lib/module/shaders/bindGroupUtils.js.map +1 -1
  18. package/lib/module/shaders/fragmentShaders/glareFragment.js +8 -7
  19. package/lib/module/shaders/fragmentShaders/glareFragment.js.map +1 -1
  20. package/lib/module/shaders/fragmentShaders/holoFragment.js +5 -10
  21. package/lib/module/shaders/fragmentShaders/holoFragment.js.map +1 -1
  22. package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js +3 -3
  23. package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js.map +1 -1
  24. package/lib/module/shaders/pipelineSetups.js +29 -43
  25. package/lib/module/shaders/pipelineSetups.js.map +1 -1
  26. package/lib/module/shaders/resourceManagement/textures.js +7 -0
  27. package/lib/module/shaders/resourceManagement/textures.js.map +1 -1
  28. package/lib/module/shaders/utils.js +8 -22
  29. package/lib/module/shaders/utils.js.map +1 -1
  30. package/lib/module/shaders/vertexShaders/mainRotationEffectVertex.js +2 -2
  31. package/lib/module/shaders/vertexShaders/mainRotationEffectVertex.js.map +1 -1
  32. package/lib/module/types/size.js +2 -0
  33. package/lib/module/types/size.js.map +1 -0
  34. package/lib/module/types/typeUtils.js +0 -14
  35. package/lib/module/types/typeUtils.js.map +1 -1
  36. package/lib/module/types/vector.js +2 -0
  37. package/lib/module/types/vector.js.map +1 -0
  38. package/lib/module/utils/size.js +25 -0
  39. package/lib/module/utils/size.js.map +1 -0
  40. package/lib/module/utils/vector.js +168 -0
  41. package/lib/module/utils/vector.js.map +1 -0
  42. package/lib/typescript/src/components/Content.d.ts +23 -0
  43. package/lib/typescript/src/components/Content.d.ts.map +1 -0
  44. package/lib/typescript/src/components/Shine.d.ts +3 -13
  45. package/lib/typescript/src/components/Shine.d.ts.map +1 -1
  46. package/lib/typescript/src/components/ShineGroup.d.ts +3 -5
  47. package/lib/typescript/src/components/ShineGroup.d.ts.map +1 -1
  48. package/lib/typescript/src/hooks/useAnimationFrame.d.ts +2 -0
  49. package/lib/typescript/src/hooks/useAnimationFrame.d.ts.map +1 -0
  50. package/lib/typescript/src/hooks/useOrientation.d.ts +3 -1
  51. package/lib/typescript/src/hooks/useOrientation.d.ts.map +1 -1
  52. package/lib/typescript/src/index.d.ts +4 -2
  53. package/lib/typescript/src/index.d.ts.map +1 -1
  54. package/lib/typescript/src/shaders/bindGroupLayouts.d.ts +9 -9
  55. package/lib/typescript/src/shaders/bindGroupLayouts.d.ts.map +1 -1
  56. package/lib/typescript/src/shaders/bindGroupUtils.d.ts +3 -3
  57. package/lib/typescript/src/shaders/bindGroupUtils.d.ts.map +1 -1
  58. package/lib/typescript/src/shaders/fragmentShaders/glareFragment.d.ts.map +1 -1
  59. package/lib/typescript/src/shaders/fragmentShaders/holoFragment.d.ts.map +1 -1
  60. package/lib/typescript/src/shaders/pipelineSetups.d.ts +7 -7
  61. package/lib/typescript/src/shaders/pipelineSetups.d.ts.map +1 -1
  62. package/lib/typescript/src/shaders/resourceManagement/textures.d.ts +2 -1
  63. package/lib/typescript/src/shaders/resourceManagement/textures.d.ts.map +1 -1
  64. package/lib/typescript/src/shaders/utils.d.ts +3 -4
  65. package/lib/typescript/src/shaders/utils.d.ts.map +1 -1
  66. package/lib/typescript/src/types/size.d.ts +5 -0
  67. package/lib/typescript/src/types/size.d.ts.map +1 -0
  68. package/lib/typescript/src/types/typeUtils.d.ts +1 -4
  69. package/lib/typescript/src/types/typeUtils.d.ts.map +1 -1
  70. package/lib/typescript/src/types/types.d.ts +3 -1
  71. package/lib/typescript/src/types/types.d.ts.map +1 -1
  72. package/lib/typescript/src/types/vector.d.ts +11 -0
  73. package/lib/typescript/src/types/vector.d.ts.map +1 -0
  74. package/lib/typescript/src/utils/size.d.ts +5 -0
  75. package/lib/typescript/src/utils/size.d.ts.map +1 -0
  76. package/lib/typescript/src/utils/vector.d.ts +33 -0
  77. package/lib/typescript/src/utils/vector.d.ts.map +1 -0
  78. package/package.json +8 -7
  79. package/src/components/Content.tsx +403 -0
  80. package/src/components/Shine.tsx +24 -466
  81. package/src/components/ShineGroup.tsx +17 -24
  82. package/src/hooks/useAnimationFrame.ts +21 -0
  83. package/src/hooks/useOrientation.ts +11 -13
  84. package/src/index.tsx +9 -1
  85. package/src/shaders/bindGroupLayouts.ts +11 -11
  86. package/src/shaders/bindGroupUtils.ts +31 -61
  87. package/src/shaders/fragmentShaders/glareFragment.ts +8 -7
  88. package/src/shaders/fragmentShaders/holoFragment.ts +5 -13
  89. package/src/shaders/fragmentShaders/reverseHoloFragment.ts +4 -4
  90. package/src/shaders/pipelineSetups.ts +54 -69
  91. package/src/shaders/resourceManagement/textures.ts +13 -1
  92. package/src/shaders/utils.ts +13 -27
  93. package/src/shaders/vertexShaders/mainRotationEffectVertex.ts +2 -2
  94. package/src/types/size.ts +4 -0
  95. package/src/types/typeUtils.ts +0 -28
  96. package/src/types/types.ts +11 -1
  97. package/src/types/vector.ts +13 -0
  98. package/src/utils/size.ts +12 -0
  99. package/src/utils/vector.ts +132 -0
@@ -0,0 +1,13 @@
1
+ export interface V1d {
2
+ x: number;
3
+ }
4
+
5
+ export interface V2d extends V1d {
6
+ y: number;
7
+ }
8
+
9
+ export interface V3d extends V2d {
10
+ z: number;
11
+ }
12
+
13
+ export type Transformer = (value: number) => number;
@@ -0,0 +1,12 @@
1
+ import type { Size } from '../types/size';
2
+ import type { V2d } from '../types/vector';
3
+
4
+ export function sizeToV2d({ width: x, height: y }: Size): V2d {
5
+ 'worklet';
6
+ return { x, y };
7
+ }
8
+
9
+ export function sizeFromV2d({ x: width, y: height }: V2d): Size {
10
+ 'worklet';
11
+ return { width, height };
12
+ }
@@ -0,0 +1,132 @@
1
+ import type { Transformer, V2d, V3d } from '../types/vector';
2
+
3
+ // 2d
4
+ export function scaleV2d(a: V2d, value: number): V2d {
5
+ 'worklet';
6
+ return {
7
+ x: value * a.x,
8
+ y: value * a.y,
9
+ };
10
+ }
11
+
12
+ export const multiplyV2d = scaleV2d;
13
+
14
+ export function addV2d(a: V2d, b: V2d): V2d {
15
+ 'worklet';
16
+ return {
17
+ x: a.x + b.x,
18
+ y: a.y + b.y,
19
+ };
20
+ }
21
+
22
+ export function angleToV2d(angle: number): V2d {
23
+ 'worklet';
24
+ return { x: Math.cos(angle), y: Math.sin(angle) };
25
+ }
26
+
27
+ export function rotateV2d({ x, y }: V2d, rad: number): V2d {
28
+ 'worklet';
29
+ const { x: c, y: s } = angleToV2d(rad);
30
+
31
+ return { x: x * c - y * s, y: x * s + y * c };
32
+ }
33
+
34
+ export function negateV2dX({ x, y }: V2d): V2d {
35
+ 'worklet';
36
+ return { x: -x, y };
37
+ }
38
+
39
+ export function negateV2dY({ x, y }: V2d): V2d {
40
+ 'worklet';
41
+ return { x, y: -y };
42
+ }
43
+
44
+ export function transformV2d({ x, y }: V2d, transformer: Transformer): V2d {
45
+ 'worklet';
46
+ return {
47
+ x: transformer(x),
48
+ y: transformer(y),
49
+ };
50
+ }
51
+
52
+ export function clampV2d(v2d: V2d, min: number, max: number): V2d {
53
+ 'worklet';
54
+ return transformV2d(v2d, (value) => clamp(value, min, max));
55
+ }
56
+
57
+ export function round2D(v2d: V2d): V2d {
58
+ 'worklet';
59
+ return transformV2d(v2d, (value) => Math.round(value));
60
+ }
61
+
62
+ export function areV2dEqual(a: V2d, b: V2d): boolean {
63
+ return a.x === b.x && a.y === b.y;
64
+ }
65
+
66
+ export const zeroV2d = { x: 0, y: 0 };
67
+
68
+ // 3d
69
+ export function scaleV3d(a: V3d, value: number): V3d {
70
+ 'worklet';
71
+ return {
72
+ ...scaleV2d(a, value),
73
+ z: value * a.z,
74
+ };
75
+ }
76
+
77
+ export const multiplyV3d = scaleV3d;
78
+
79
+ export function divV3d(a: V3d, value: number): V3d {
80
+ 'worklet';
81
+ return multiplyV3d(a, 1 / value);
82
+ }
83
+
84
+ export function negateV3d(a: V3d): V3d {
85
+ 'worklet';
86
+ return scaleV3d(a, -1);
87
+ }
88
+
89
+ export function addV3d(a: V3d, b: V3d): V3d {
90
+ 'worklet';
91
+ return {
92
+ ...addV2d(a, b),
93
+ z: a.z + b.z,
94
+ };
95
+ }
96
+
97
+ export function subtractV3d(a: V3d, b: V3d): V3d {
98
+ 'worklet';
99
+ return addV3d(a, negateV3d(b));
100
+ }
101
+
102
+ export function componentsFromV3d({ x, y, z }: V3d): [number, number, number] {
103
+ 'worklet';
104
+ return [x, y, z];
105
+ }
106
+
107
+ export function transformV3d(v3d: V3d, transformer: Transformer): V3d {
108
+ 'worklet';
109
+ return {
110
+ ...transformV2d(v3d, transformer),
111
+ z: transformer(v3d.z),
112
+ };
113
+ }
114
+
115
+ export function clamp(v: number, min = -1, max = 1): number {
116
+ 'worklet';
117
+ return Math.max(min, Math.min(max, v));
118
+ }
119
+
120
+ export function clampV3d(v3d: V3d, min: number, max: number): V3d {
121
+ 'worklet';
122
+ return transformV3d(v3d, (value) => clamp(value, min, max));
123
+ }
124
+
125
+ // helpers
126
+
127
+ export function degToRad(deg: number): number {
128
+ 'worklet';
129
+ return (deg * Math.PI) / 180;
130
+ }
131
+
132
+ export const zeroV3d = { x: 0, y: 0, z: 0 };