File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,20 @@ export type VFXProps = {
85
85
*/
86
86
uniforms ?: VFXUniforms ;
87
87
88
+ /**
89
+ * The opacity for the original HTML element.
90
+ *
91
+ * By default, VFX-JS hides the original element by setting its opacity to 0.
92
+ * However, in some cases you might want not to hide the original element.
93
+ * `overlay` allows you to specify the opacity to be set explicitly.
94
+ *
95
+ * If you pass `true`, VFX-JS will preserve the original element's opacity.
96
+ *
97
+ * You can also specify the opacity by passing a number.
98
+ * For example, `overlay: 0.5` will set the opacity of the orignal element to 0.5.
99
+ */
100
+ overlay ?: true | number ;
101
+
88
102
/**
89
103
* Allow shader outputs to oveflow the original element area.
90
104
* If true, REACT-VFX will render the shader in fullscreen.
Original file line number Diff line number Diff line change @@ -217,8 +217,14 @@ export class VFXPlayer {
217
217
texture . needsUpdate = true ;
218
218
219
219
// Hide original element
220
- const opacity = type === "video" ? "0.0001" : "0" ; // don't hide video element completely to prevent jank frames
221
- element . style . setProperty ( "opacity" , opacity ) ;
220
+ if ( opts . overlay === true ) {
221
+ /* Overlay mode. Do not hide the element */
222
+ } else if ( typeof opts . overlay === "number" ) {
223
+ element . style . setProperty ( "opacity" , opts . overlay . toString ( ) ) ;
224
+ } else {
225
+ const opacity = type === "video" ? "0.0001" : "0" ; // don't hide video element completely to prevent jank frames
226
+ element . style . setProperty ( "opacity" , opacity . toString ( ) ) ;
227
+ }
222
228
223
229
const uniforms : { [ name : string ] : THREE . IUniform } = {
224
230
src : { value : texture } ,
You can’t perform that action at this time.
0 commit comments