@react-three/drei 9.114.5 → 9.114.6
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/README.md +6 -0
- package/core/VideoTexture.cjs.js +1 -1
- package/core/VideoTexture.d.ts +1 -1
- package/core/VideoTexture.js +2 -2
- package/index.cjs.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
[](https://codesandbox.io/s/bfplr)
|
|
2
2
|
|
|
3
|
+
[](https://drei.pmnd.rs/)
|
|
3
4
|
[](https://www.npmjs.com/package/@react-three/drei)
|
|
4
5
|
[](https://www.npmjs.com/package/@react-three/drei)
|
|
5
6
|
[](https://discord.com/channels/740090768164651008/741751532592038022)
|
|
@@ -34,6 +35,9 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
34
35
|
|
|
35
36
|
https://pmndrs.github.io/drei
|
|
36
37
|
|
|
38
|
+
<details>
|
|
39
|
+
<summary>Old doc</summary>
|
|
40
|
+
|
|
37
41
|
> [!WARNING]
|
|
38
42
|
> Below is an archive of the anchors links with their new respective locations to the documentation website.
|
|
39
43
|
> Do not update the links below, they are for reference only.
|
|
@@ -790,3 +794,5 @@ https://pmndrs.github.io/drei
|
|
|
790
794
|
#### ShadowAlpha
|
|
791
795
|
|
|
792
796
|
[Documentation has moved here](https://pmndrs.github.io/drei/staging/shadow-alpha)
|
|
797
|
+
|
|
798
|
+
</details>
|
package/core/VideoTexture.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("suspend-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("suspend-react"),o=require("hls.js");function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s,c,i=u(e),l=u(t);const a="undefined"!=typeof window&&"function"==typeof(null==(s=window.document)?void 0:s.createElement)&&"string"==typeof(null==(c=window.navigator)?void 0:c.userAgent);let d=null;function f(t,{unsuspend:s="loadedmetadata",start:c=!0,hls:i={},crossOrigin:f="anonymous",muted:p=!0,loop:g=!0,playsInline:m=!0,...v}={}){const y=r.useThree((e=>e.gl)),w=e.useRef(null),h=n.suspend((()=>new Promise((async e=>{let r,n;"string"==typeof t?r=t:n=t;const c=Object.assign(document.createElement("video"),{src:r,srcObject:n,crossOrigin:f,loop:g,muted:p,playsInline:m,...v});if(r&&a&&r.endsWith(".m3u8")){const e=w.current=await async function(...e){var t;null!==(t=d)&&void 0!==t||(d=await Promise.resolve().then((function(){return u(require("hls.js"))})));const r=d.default;return r.isSupported()?new r(...e):null}(i);e&&(e.on(o.Events.MEDIA_ATTACHED,(()=>{e.loadSource(r)})),e.attachMedia(c))}const h=new l.VideoTexture(c);"colorSpace"in h?h.colorSpace=y.outputColorSpace:h.encoding=y.outputEncoding,c.addEventListener(s,(()=>e(h)))}))),[t]);return e.useEffect((()=>(c&&h.image.play(),()=>{w.current&&(w.current.destroy(),w.current=null)})),[h,c]),h}exports.VideoTexture=({children:t,src:r,...n})=>{const o=f(r,n);return e.useEffect((()=>()=>{o.dispose()}),[o]),i.createElement(i.Fragment,null,null==t?void 0:t(o))},exports.useVideoTexture=f;
|
package/core/VideoTexture.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { type default as Hls } from 'hls.js';
|
|
4
4
|
declare function getHls(...args: ConstructorParameters<typeof Hls>): Promise<Hls | null>;
|
|
5
|
-
export declare function useVideoTexture(srcOrSrcObject: HTMLVideoElement['src' | 'srcObject'], { unsuspend, start, hls: hlsConfig, crossOrigin, muted, loop, ...videoProps }?: {
|
|
5
|
+
export declare function useVideoTexture(srcOrSrcObject: HTMLVideoElement['src' | 'srcObject'], { unsuspend, start, hls: hlsConfig, crossOrigin, muted, loop, playsInline, ...videoProps }?: {
|
|
6
6
|
unsuspend?: keyof HTMLVideoElementEventMap;
|
|
7
7
|
start?: boolean;
|
|
8
8
|
hls?: Parameters<typeof getHls>[0];
|
package/core/VideoTexture.js
CHANGED
|
@@ -24,11 +24,11 @@ function useVideoTexture(srcOrSrcObject, {
|
|
|
24
24
|
crossOrigin = 'anonymous',
|
|
25
25
|
muted = true,
|
|
26
26
|
loop = true,
|
|
27
|
+
playsInline = true,
|
|
27
28
|
...videoProps
|
|
28
29
|
} = {}) {
|
|
29
30
|
const gl = useThree(state => state.gl);
|
|
30
31
|
const hlsRef = useRef(null);
|
|
31
|
-
const videoRef = useRef(null);
|
|
32
32
|
const texture = suspend(() => new Promise(async res => {
|
|
33
33
|
let src = undefined;
|
|
34
34
|
let srcObject = undefined;
|
|
@@ -43,9 +43,9 @@ function useVideoTexture(srcOrSrcObject, {
|
|
|
43
43
|
crossOrigin,
|
|
44
44
|
loop,
|
|
45
45
|
muted,
|
|
46
|
+
playsInline,
|
|
46
47
|
...videoProps
|
|
47
48
|
});
|
|
48
|
-
videoRef.current = video;
|
|
49
49
|
|
|
50
50
|
// hlsjs extension
|
|
51
51
|
if (src && IS_BROWSER && src.endsWith('.m3u8')) {
|