@react-three/drei 11.0.0-alpha.1 → 11.0.0-alpha.4

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 (119) hide show
  1. package/core/index.d.mts +1858 -0
  2. package/core/index.d.ts +1858 -0
  3. package/core/index.mjs +8559 -0
  4. package/experimental/index.d.mts +222 -0
  5. package/experimental/index.d.ts +222 -0
  6. package/experimental/index.mjs +353 -0
  7. package/external/index.d.mts +464 -0
  8. package/external/index.d.ts +464 -0
  9. package/external/index.mjs +5079 -0
  10. package/index.d.mts +1746 -2147
  11. package/index.d.ts +2166 -0
  12. package/index.mjs +12940 -19766
  13. package/legacy/index.d.mts +2350 -0
  14. package/legacy/index.d.ts +2350 -0
  15. package/legacy/index.mjs +12325 -0
  16. package/native/index.d.mts +2515 -0
  17. package/native/index.d.ts +2515 -0
  18. package/native/index.mjs +12383 -0
  19. package/package.json +18 -15
  20. package/webgpu/index.d.mts +2514 -0
  21. package/webgpu/index.d.ts +2514 -0
  22. package/webgpu/index.mjs +12547 -0
  23. package/_chunks/hls.mjs +0 -3
  24. package/_chunks/libs/@mediapipe/tasks-vision.mjs +0 -4781
  25. package/_chunks/libs/@monogrid/gainmap-js.mjs +0 -1137
  26. package/_chunks/libs/@use-gesture/core.mjs +0 -1650
  27. package/_chunks/libs/@use-gesture/react.mjs +0 -207
  28. package/_chunks/libs/camera-controls.mjs +0 -2207
  29. package/_chunks/libs/detect-gpu.mjs +0 -515
  30. package/_chunks/libs/hls.js.mjs +0 -21925
  31. package/_chunks/libs/maath.mjs +0 -5200
  32. package/_chunks/libs/stats-gl.mjs +0 -301
  33. package/_chunks/libs/stats.js.mjs +0 -90
  34. package/_chunks/libs/suspend-react.mjs +0 -60
  35. package/_chunks/libs/three.mjs +0 -23169
  36. package/_chunks/libs/tunnel-rat.mjs +0 -458
  37. package/_chunks/libs/zustand.mjs +0 -104
  38. package/_chunks/rolldown-runtime.mjs +0 -47
  39. package/_chunks/vision_bundle.mjs +0 -3
  40. package/core/_chunks/hls.mjs +0 -3
  41. package/core/_chunks/libs/@monogrid/gainmap-js.mjs +0 -1137
  42. package/core/_chunks/libs/@use-gesture/core.mjs +0 -1650
  43. package/core/_chunks/libs/@use-gesture/react.mjs +0 -207
  44. package/core/_chunks/libs/detect-gpu.mjs +0 -515
  45. package/core/_chunks/libs/hls.js.mjs +0 -21925
  46. package/core/_chunks/libs/maath.mjs +0 -5200
  47. package/core/_chunks/libs/stats-gl.mjs +0 -301
  48. package/core/_chunks/libs/stats.js.mjs +0 -90
  49. package/core/_chunks/libs/suspend-react.mjs +0 -60
  50. package/core/_chunks/libs/three.mjs +0 -22457
  51. package/core/_chunks/libs/tunnel-rat.mjs +0 -458
  52. package/core/_chunks/libs/zustand.mjs +0 -104
  53. package/core/_chunks/rolldown-runtime.mjs +0 -47
  54. package/core/core/index.d.mts +0 -2232
  55. package/core/core/index.mjs +0 -11082
  56. package/experimental/_chunks/libs/three.mjs +0 -15386
  57. package/experimental/experimental/index.d.mts +0 -253
  58. package/experimental/experimental/index.mjs +0 -434
  59. package/external/_chunks/hls.mjs +0 -3
  60. package/external/_chunks/libs/@mediapipe/tasks-vision.mjs +0 -4781
  61. package/external/_chunks/libs/camera-controls.mjs +0 -2207
  62. package/external/_chunks/libs/hls.js.mjs +0 -21925
  63. package/external/_chunks/libs/maath.mjs +0 -5200
  64. package/external/_chunks/libs/suspend-react.mjs +0 -58
  65. package/external/_chunks/libs/three.mjs +0 -15387
  66. package/external/_chunks/rolldown-runtime.mjs +0 -32
  67. package/external/_chunks/vision_bundle.mjs +0 -3
  68. package/external/external/index.d.mts +0 -499
  69. package/external/external/index.mjs +0 -9422
  70. package/legacy/_chunks/hls.mjs +0 -3
  71. package/legacy/_chunks/libs/@monogrid/gainmap-js.mjs +0 -1137
  72. package/legacy/_chunks/libs/@use-gesture/core.mjs +0 -1650
  73. package/legacy/_chunks/libs/@use-gesture/react.mjs +0 -207
  74. package/legacy/_chunks/libs/bidi-js.mjs +0 -675
  75. package/legacy/_chunks/libs/detect-gpu.mjs +0 -515
  76. package/legacy/_chunks/libs/hls.js.mjs +0 -21925
  77. package/legacy/_chunks/libs/maath.mjs +0 -5200
  78. package/legacy/_chunks/libs/stats-gl.mjs +0 -301
  79. package/legacy/_chunks/libs/stats.js.mjs +0 -90
  80. package/legacy/_chunks/libs/suspend-react.mjs +0 -60
  81. package/legacy/_chunks/libs/three.mjs +0 -26062
  82. package/legacy/_chunks/libs/troika-three-text.mjs +0 -6494
  83. package/legacy/_chunks/libs/tunnel-rat.mjs +0 -458
  84. package/legacy/_chunks/libs/zustand.mjs +0 -104
  85. package/legacy/_chunks/rolldown-runtime.mjs +0 -47
  86. package/legacy/legacy/index.d.mts +0 -2788
  87. package/legacy/legacy/index.mjs +0 -14984
  88. package/native/_chunks/hls.mjs +0 -3
  89. package/native/_chunks/libs/@monogrid/gainmap-js.mjs +0 -1137
  90. package/native/_chunks/libs/@use-gesture/core.mjs +0 -1650
  91. package/native/_chunks/libs/@use-gesture/react.mjs +0 -207
  92. package/native/_chunks/libs/detect-gpu.mjs +0 -515
  93. package/native/_chunks/libs/hls.js.mjs +0 -21925
  94. package/native/_chunks/libs/maath.mjs +0 -5200
  95. package/native/_chunks/libs/stats-gl.mjs +0 -301
  96. package/native/_chunks/libs/stats.js.mjs +0 -90
  97. package/native/_chunks/libs/suspend-react.mjs +0 -60
  98. package/native/_chunks/libs/three.mjs +0 -22592
  99. package/native/_chunks/libs/tunnel-rat.mjs +0 -458
  100. package/native/_chunks/libs/zustand.mjs +0 -104
  101. package/native/_chunks/rolldown-runtime.mjs +0 -47
  102. package/native/native/index.d.mts +0 -3168
  103. package/native/native/index.mjs +0 -14863
  104. package/webgpu/_chunks/hls.mjs +0 -3
  105. package/webgpu/_chunks/libs/@monogrid/gainmap-js.mjs +0 -1137
  106. package/webgpu/_chunks/libs/@use-gesture/core.mjs +0 -1650
  107. package/webgpu/_chunks/libs/@use-gesture/react.mjs +0 -207
  108. package/webgpu/_chunks/libs/detect-gpu.mjs +0 -515
  109. package/webgpu/_chunks/libs/hls.js.mjs +0 -21925
  110. package/webgpu/_chunks/libs/maath.mjs +0 -5200
  111. package/webgpu/_chunks/libs/stats-gl.mjs +0 -301
  112. package/webgpu/_chunks/libs/stats.js.mjs +0 -90
  113. package/webgpu/_chunks/libs/suspend-react.mjs +0 -60
  114. package/webgpu/_chunks/libs/three.mjs +0 -22592
  115. package/webgpu/_chunks/libs/tunnel-rat.mjs +0 -458
  116. package/webgpu/_chunks/libs/zustand.mjs +0 -104
  117. package/webgpu/_chunks/rolldown-runtime.mjs +0 -47
  118. package/webgpu/webgpu/index.d.mts +0 -3166
  119. package/webgpu/webgpu/index.mjs +0 -15015
@@ -1,253 +0,0 @@
1
- import * as React from "react";
2
- import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
3
- import { MarchingCubes as MarchingCubes$1 } from "three/examples/jsm/objects/MarchingCubes";
4
- import { ReactThreeFiber, ThreeElement, ThreeElements } from "@react-three/fiber";
5
- import "three-mesh-bvh";
6
- import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass";
7
- import { ShaderPass } from "three/examples/jsm/postprocessing/ShaderPass";
8
- import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer";
9
- import * as THREE from "three";
10
- import { ColorRepresentation, Object3D } from "three";
11
- import { Line2 } from "three/examples/jsm/lines/Line2.js";
12
- import "three/examples/jsm/lines/LineSegments2.js";
13
- import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
14
- import * as THREE$1 from "#three";
15
- import { Color, Matrix4, MeshStandardMaterial, Texture } from "#three";
16
-
17
- //#region src/utils/ts-utils.d.ts
18
- type ForwardRefComponent<P, T> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
19
- //#endregion
20
- //#region src/experimental/Geometry/MarchingCubes/MarchingCubes.d.ts
21
- type MarchingCubesProps = {
22
- resolution?: number;
23
- maxPolyCount?: number;
24
- enableUvs?: boolean;
25
- enableColors?: boolean;
26
- } & Omit<ThreeElements['group'], 'ref'>;
27
- declare const MarchingCubes: ForwardRefComponent<MarchingCubesProps, MarchingCubes$1>;
28
- type MarchingCubeProps = {
29
- strength?: number;
30
- subtract?: number;
31
- color?: Color;
32
- } & ThreeElements['group'];
33
- declare const MarchingCube: ForwardRefComponent<MarchingCubeProps, THREE$1.Group>;
34
- type MarchingPlaneProps = {
35
- planeType?: 'x' | 'y' | 'z';
36
- strength?: number;
37
- subtract?: number;
38
- } & ThreeElements['group'];
39
- declare const MarchingPlane: ForwardRefComponent<MarchingPlaneProps, THREE$1.Group>;
40
- //#endregion
41
- //#region src/experimental/Effects/Outlines/Outlines.d.ts
42
- type OutlinesProps = Omit<ThreeElements['group'], 'ref'> & {
43
- color?: ReactThreeFiber.Color;
44
- screenspace?: boolean;
45
- opacity?: number;
46
- transparent?: boolean;
47
- thickness?: number;
48
- angle?: number;
49
- clippingPlanes?: THREE$1.Plane[];
50
- toneMapped?: boolean;
51
- polygonOffset?: boolean;
52
- polygonOffsetFactor?: number;
53
- renderOrder?: number;
54
- };
55
- declare function Outlines({
56
- color,
57
- opacity,
58
- transparent,
59
- screenspace,
60
- toneMapped,
61
- polygonOffset,
62
- polygonOffsetFactor,
63
- renderOrder,
64
- thickness,
65
- angle,
66
- clippingPlanes,
67
- ...props
68
- }: OutlinesProps): React.JSX.Element;
69
- //#endregion
70
- //#region src/legacy/Materials/AccumulativeShadows/AccumulativeShadows.d.ts
71
- type SoftShadowMaterialProps = {
72
- map: THREE$1.Texture;
73
- color?: ReactThreeFiber.Color;
74
- alphaTest?: number;
75
- blend?: number;
76
- };
77
- declare module '@react-three/fiber' {
78
- interface ThreeElements {
79
- softShadowMaterial: ThreeElements['shaderMaterial'] & SoftShadowMaterialProps;
80
- }
81
- }
82
- //#endregion
83
- //#region src/legacy/Materials/Caustics/Caustics.d.ts
84
- declare module '@react-three/fiber' {
85
- interface ThreeElements {
86
- causticsProjectionMaterial: ThreeElements['meshNormalMaterial'] & {
87
- viewMatrix?: {
88
- value: THREE$1.Matrix4;
89
- };
90
- color?: ReactThreeFiber.Color;
91
- causticsTexture?: THREE$1.Texture;
92
- causticsTextureB?: THREE$1.Texture;
93
- lightProjMatrix?: THREE$1.Matrix4;
94
- lightViewMatrix?: THREE$1.Matrix4;
95
- };
96
- }
97
- }
98
- //#endregion
99
- //#region src/legacy/Materials/MeshTransmissionMaterial/MeshTransmissionMaterial.d.ts
100
- type MeshTransmissionMaterialType = Omit<ThreeElements['meshPhysicalMaterial'], 'args' | 'roughness' | 'thickness' | 'transmission'> & {
101
- transmission?: number;
102
- thickness?: number;
103
- roughness?: number;
104
- chromaticAberration?: number;
105
- anisotropy?: number;
106
- anisotropicBlur?: number;
107
- distortion?: number;
108
- distortionScale?: number;
109
- temporalDistortion?: number;
110
- buffer?: THREE$1.Texture;
111
- time?: number;
112
- args?: [samples: number, transmissionSampler: boolean];
113
- };
114
- declare module '@react-three/fiber' {
115
- interface ThreeElements {
116
- meshTransmissionMaterial: MeshTransmissionMaterialType;
117
- }
118
- }
119
- //#endregion
120
- //#region src/legacy/Materials/MeshReflectorMaterial/MeshReflectorMaterialClass.d.ts
121
- declare class MeshReflectorMaterial extends MeshStandardMaterial {
122
- private _tDepth;
123
- private _distortionMap;
124
- private _tDiffuse;
125
- private _tDiffuseBlur;
126
- private _textureMatrix;
127
- private _hasBlur;
128
- private _mirror;
129
- private _mixBlur;
130
- private _blurStrength;
131
- private _minDepthThreshold;
132
- private _maxDepthThreshold;
133
- private _depthScale;
134
- private _depthToBlurRatioBias;
135
- private _distortion;
136
- private _mixContrast;
137
- constructor(parameters?: {});
138
- onBeforeCompile(shader: any): void;
139
- get tDiffuse(): Texture | null;
140
- set tDiffuse(v: Texture | null);
141
- get tDepth(): Texture | null;
142
- set tDepth(v: Texture | null);
143
- get distortionMap(): Texture | null;
144
- set distortionMap(v: Texture | null);
145
- get tDiffuseBlur(): Texture | null;
146
- set tDiffuseBlur(v: Texture | null);
147
- get textureMatrix(): Matrix4 | null;
148
- set textureMatrix(v: Matrix4 | null);
149
- get hasBlur(): boolean;
150
- set hasBlur(v: boolean);
151
- get mirror(): number;
152
- set mirror(v: number);
153
- get mixBlur(): number;
154
- set mixBlur(v: number);
155
- get mixStrength(): number;
156
- set mixStrength(v: number);
157
- get minDepthThreshold(): number;
158
- set minDepthThreshold(v: number);
159
- get maxDepthThreshold(): number;
160
- set maxDepthThreshold(v: number);
161
- get depthScale(): number;
162
- set depthScale(v: number);
163
- get depthToBlurRatioBias(): number;
164
- set depthToBlurRatioBias(v: number);
165
- get distortion(): number;
166
- set distortion(v: number);
167
- get mixContrast(): number;
168
- set mixContrast(v: number);
169
- }
170
- //#endregion
171
- //#region src/legacy/Materials/MeshReflectorMaterial/MeshReflectorMaterial.d.ts
172
- declare module '@react-three/fiber' {
173
- interface ThreeElements {
174
- meshReflectorMaterialImpl: ThreeElement<typeof MeshReflectorMaterial>;
175
- }
176
- }
177
- //#endregion
178
- //#region src/legacy/Materials/MeshPortalMaterial/MeshPortalMaterial.d.ts
179
- declare module '@react-three/fiber' {
180
- interface ThreeElements {
181
- portalMaterialImpl: ThreeElements['shaderMaterial'] & {
182
- resolution: ReactThreeFiber.Vector2;
183
- blur: number;
184
- blend: number;
185
- size?: number;
186
- sdf?: THREE$1.Texture;
187
- map?: THREE$1.Texture;
188
- };
189
- }
190
- }
191
- //#endregion
192
- //#region src/legacy/Materials/MeshDistortMaterial/MeshDistortMaterial.d.ts
193
- declare module '@react-three/fiber' {
194
- interface ThreeElements {
195
- distortMaterialImpl: ThreeElements['meshPhysicalMaterial'] & {
196
- time?: number;
197
- distort?: number;
198
- radius?: number;
199
- };
200
- }
201
- }
202
- //#endregion
203
- //#region src/legacy/Materials/MeshWobbleMaterial/MeshWobbleMaterial.d.ts
204
- declare module '@react-three/fiber' {
205
- interface ThreeElements {
206
- wobbleMaterialImpl: ThreeElements['meshStandardMaterial'] & {
207
- time?: number;
208
- factor?: number;
209
- speed?: number;
210
- };
211
- }
212
- }
213
- //#endregion
214
- //#region src/legacy/Abstractions/Effects/Effects.d.ts
215
- declare module '@react-three/fiber' {
216
- interface ThreeElements {
217
- effectComposer: ThreeElement<typeof EffectComposer>;
218
- renderPass: ThreeElement<typeof RenderPass>;
219
- shaderPass: ThreeElement<typeof ShaderPass>;
220
- }
221
- }
222
- //#endregion
223
- //#region src/legacy/Geometry/Segments/Segments.d.ts
224
- declare module '@react-three/fiber' {
225
- interface ThreeElements {
226
- segmentObject: ThreeElement<typeof SegmentObject>;
227
- }
228
- }
229
- declare class SegmentObject {
230
- color: THREE.Color;
231
- start: THREE.Vector3;
232
- end: THREE.Vector3;
233
- constructor();
234
- }
235
- //#endregion
236
- //#region src/legacy/Effects/Trail/Trail.d.ts
237
- type Settings = {
238
- width: number;
239
- length: number;
240
- decay: number;
241
- local: boolean;
242
- stride: number;
243
- interval: number;
244
- };
245
- type TrailProps = {
246
- color?: ColorRepresentation;
247
- attenuation?: (t: number) => number;
248
- target?: React.RefObject<Object3D>;
249
- } & Partial<Settings>;
250
- declare function useTrail(target: Object3D, settings: Partial<Settings>, pointCount: number): React.RefObject<Float32Array>;
251
- declare const Trail: ForwardRefComponent<React.PropsWithChildren<TrailProps>, Line2>;
252
- //#endregion
253
- export { MarchingCube, MarchingCubeProps, MarchingCubes, MarchingCubesProps, MarchingPlane, MarchingPlaneProps, Outlines, OutlinesProps, Trail, type TrailProps, useTrail };
@@ -1,434 +0,0 @@
1
- import { a as Mesh, c as SkinnedMesh, d as Vector2$1, f as Vector3$1, i as MathUtils, l as Uniform, n as Color, o as REVISION, r as InstancedMesh, s as ShaderMaterial, t as BackSide, u as UniformsUtils } from "../_chunks/libs/three.mjs";
2
- import * as React from "react";
3
- import { MarchingCubes as MarchingCubes$1 } from "three/examples/jsm/objects/MarchingCubes";
4
- import { applyProps, createPortal, extend, useFrame, useThree } from "@react-three/fiber";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { toCreasedNormals } from "three/examples/jsm/utils/BufferGeometryUtils";
7
- import * as THREE from "three";
8
- import { Object3D, Vector2, Vector3 } from "three";
9
- import { Line2 } from "three/examples/jsm/lines/Line2.js";
10
- import { LineGeometry } from "three/examples/jsm/lines/LineGeometry.js";
11
- import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
12
-
13
- //#region src/experimental/Geometry/MarchingCubes/MarchingCubes.tsx
14
- const globalContext = /* @__PURE__ */ React.createContext(null);
15
- /**
16
- * An abstraction for three's [MarchingCubes](https://threejs.org/examples/#webgl_marchingcubes).
17
- *
18
- * @example Basic usage
19
- * ```jsx
20
- * <MarchingCubes resolution={50} maxPolyCount={20000} enableUvs={false} enableColors={true}>
21
- * <MarchingCube strength={0.5} subtract={12} color={new Color('#f0f')} position={[0.5, 0.5, 0.5]} />
22
- * <MarchingPlane planeType="y" strength={0.5} subtract={12} />
23
- * </MarchingCubes>
24
- * ```
25
- */
26
- const MarchingCubes = /* @__PURE__ */ React.forwardRef(({ resolution = 28, maxPolyCount = 1e4, enableUvs = false, enableColors = false, children, ...props }, ref) => {
27
- const marchingCubesRef = React.useRef(null);
28
- React.useImperativeHandle(ref, () => marchingCubesRef.current, []);
29
- const marchingCubes = React.useMemo(() => new MarchingCubes$1(resolution, null, enableUvs, enableColors, maxPolyCount), [
30
- resolution,
31
- maxPolyCount,
32
- enableUvs,
33
- enableColors
34
- ]);
35
- const api = React.useMemo(() => ({ getParent: () => marchingCubesRef }), []);
36
- useFrame(() => {
37
- marchingCubes.update();
38
- marchingCubes.reset();
39
- }, -1);
40
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("primitive", {
41
- object: marchingCubes,
42
- ref: marchingCubesRef,
43
- ...props,
44
- children: /* @__PURE__ */ jsx(globalContext.Provider, {
45
- value: api,
46
- children
47
- })
48
- }) });
49
- });
50
- const MarchingCube = /* @__PURE__ */ React.forwardRef(({ strength = .5, subtract = 12, color, ...props }, ref) => {
51
- const { getParent } = React.useContext(globalContext);
52
- const parentRef = React.useMemo(() => getParent(), [getParent]);
53
- const cubeRef = React.useRef(null);
54
- React.useImperativeHandle(ref, () => cubeRef.current, []);
55
- const vec = new Vector3$1();
56
- useFrame((state) => {
57
- if (!parentRef.current || !cubeRef.current) return;
58
- cubeRef.current.getWorldPosition(vec);
59
- parentRef.current.addBall(.5 + vec.x * .5, .5 + vec.y * .5, .5 + vec.z * .5, strength, subtract, color);
60
- });
61
- return /* @__PURE__ */ jsx("group", {
62
- ref: cubeRef,
63
- ...props
64
- });
65
- });
66
- const MarchingPlane = /* @__PURE__ */ React.forwardRef(({ planeType: _planeType = "x", strength = .5, subtract = 12, ...props }, ref) => {
67
- const { getParent } = React.useContext(globalContext);
68
- const parentRef = React.useMemo(() => getParent(), [getParent]);
69
- const wallRef = React.useRef(null);
70
- React.useImperativeHandle(ref, () => wallRef.current, []);
71
- const planeType = React.useMemo(() => _planeType === "x" ? "addPlaneX" : _planeType === "y" ? "addPlaneY" : "addPlaneZ", [_planeType]);
72
- useFrame(() => {
73
- if (!parentRef.current || !wallRef.current) return;
74
- parentRef.current[planeType](strength, subtract);
75
- });
76
- return /* @__PURE__ */ jsx("group", {
77
- ref: wallRef,
78
- ...props
79
- });
80
- });
81
-
82
- //#endregion
83
- //#region src/legacy/Materials/shaderMaterial/shaderMaterial.tsx
84
- /**
85
- * Creates a ShaderMaterial class with uniforms as setter/getters and constructor args.
86
- * Includes a unique `key` property for hot-reload support.
87
- *
88
- * @param uniforms - Default uniform values
89
- * @param vertexShader - GLSL vertex shader
90
- * @param fragmentShader - GLSL fragment shader
91
- * @param onInit - Optional callback after material creation
92
- *
93
- * @example
94
- * ```jsx
95
- * const MyMaterial = shaderMaterial(
96
- * { time: 0, color: new THREE.Color(0.2, 0, 0.1) },
97
- * vertexShader,
98
- * fragmentShader
99
- * )
100
- * extend({ MyMaterial })
101
- * <mesh><myMaterial key={MyMaterial.key} time={1} /></mesh>
102
- * ```
103
- */
104
- function shaderMaterial(uniforms, vertexShader, fragmentShader, onInit) {
105
- return class extends ShaderMaterial {
106
- static key = MathUtils.generateUUID();
107
- constructor(parameters) {
108
- super({
109
- vertexShader,
110
- fragmentShader,
111
- ...parameters
112
- });
113
- for (const key in uniforms) {
114
- this.uniforms[key] = new Uniform(uniforms[key]);
115
- Object.defineProperty(this, key, {
116
- get() {
117
- return this.uniforms[key].value;
118
- },
119
- set(value) {
120
- this.uniforms[key].value = value;
121
- }
122
- });
123
- }
124
- this.uniforms = UniformsUtils.clone(this.uniforms);
125
- onInit?.(this);
126
- }
127
- };
128
- }
129
-
130
- //#endregion
131
- //#region src/utils/constants.ts
132
- const getVersion = () => parseInt(REVISION.replace(/\D+/g, ""));
133
- const version = /* @__PURE__ */ getVersion();
134
-
135
- //#endregion
136
- //#region src/experimental/Effects/Outlines/Outlines.tsx
137
- const OutlinesMaterial = /* @__PURE__ */ shaderMaterial({
138
- screenspace: false,
139
- color: /* @__PURE__ */ new Color("black"),
140
- opacity: 1,
141
- thickness: .05,
142
- size: /* @__PURE__ */ new Vector2$1()
143
- }, `#include <common>
144
- #include <morphtarget_pars_vertex>
145
- #include <skinning_pars_vertex>
146
- #include <clipping_planes_pars_vertex>
147
- uniform float thickness;
148
- uniform bool screenspace;
149
- uniform vec2 size;
150
- void main() {
151
- #if defined (USE_SKINNING)
152
- #include <beginnormal_vertex>
153
- #include <morphnormal_vertex>
154
- #include <skinbase_vertex>
155
- #include <skinnormal_vertex>
156
- #include <defaultnormal_vertex>
157
- #endif
158
- #include <begin_vertex>
159
- #include <morphtarget_vertex>
160
- #include <skinning_vertex>
161
- #include <project_vertex>
162
- #include <clipping_planes_vertex>
163
- vec4 tNormal = vec4(normal, 0.0);
164
- vec4 tPosition = vec4(transformed, 1.0);
165
- #ifdef USE_INSTANCING
166
- tNormal = instanceMatrix * tNormal;
167
- tPosition = instanceMatrix * tPosition;
168
- #endif
169
- if (screenspace) {
170
- vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;
171
- gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
172
- } else {
173
- vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition;
174
- vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal;
175
- vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0;
176
- clipPosition.xy += offset;
177
- gl_Position = clipPosition;
178
- }
179
- }`, `uniform vec3 color;
180
- uniform float opacity;
181
- #include <clipping_planes_pars_fragment>
182
- void main(){
183
- #include <clipping_planes_fragment>
184
- gl_FragColor = vec4(color, opacity);
185
- #include <tonemapping_fragment>
186
- #include <${version >= 154 ? "colorspace_fragment" : "encodings_fragment"}>
187
- }`);
188
- /**
189
- * An ornamental component that extracts the geometry from its parent and displays an
190
- * [inverted-hull outline](https://bnpr.gitbook.io/bnpr/outline/inverse-hull-method).
191
- * Supported parents are `<mesh>`, `<skinnedMesh>` and `<instancedMesh>`.
192
- *
193
- * @example Basic usage
194
- * ```jsx
195
- * <mesh>
196
- * <boxGeometry />
197
- * <meshBasicMaterial />
198
- * <Outlines thickness={0.05} color="hotpink" />
199
- * </mesh>
200
- * ```
201
- */
202
- function Outlines({ color = "black", opacity = 1, transparent = false, screenspace = false, toneMapped = true, polygonOffset = false, polygonOffsetFactor = 0, renderOrder = 0, thickness = .05, angle = Math.PI, clippingPlanes, ...props }) {
203
- const ref = React.useRef(null);
204
- const [material] = React.useState(() => new OutlinesMaterial({ side: BackSide }));
205
- const { gl } = useThree();
206
- const contextSize = gl.getDrawingBufferSize(new Vector2$1());
207
- React.useMemo(() => extend({ OutlinesMaterial }), []);
208
- const oldAngle = React.useRef(0);
209
- const oldGeometry = React.useRef(null);
210
- React.useLayoutEffect(() => {
211
- const group = ref.current;
212
- if (!group) return;
213
- const parent = group.parent;
214
- if (parent && parent.geometry) {
215
- if (oldAngle.current !== angle || oldGeometry.current !== parent.geometry) {
216
- oldAngle.current = angle;
217
- oldGeometry.current = parent.geometry;
218
- let mesh = group.children?.[0];
219
- if (mesh) {
220
- if (angle) mesh.geometry.dispose();
221
- group.remove(mesh);
222
- }
223
- if (parent.skeleton) {
224
- mesh = new SkinnedMesh();
225
- mesh.material = material;
226
- mesh.bind(parent.skeleton, parent.bindMatrix);
227
- group.add(mesh);
228
- } else if (parent.isInstancedMesh) {
229
- mesh = new InstancedMesh(parent.geometry, material, parent.count);
230
- mesh.instanceMatrix = parent.instanceMatrix;
231
- group.add(mesh);
232
- } else {
233
- mesh = new Mesh();
234
- mesh.material = material;
235
- group.add(mesh);
236
- }
237
- mesh.geometry = angle ? toCreasedNormals(parent.geometry, angle) : parent.geometry;
238
- mesh.morphTargetInfluences = parent.morphTargetInfluences;
239
- mesh.morphTargetDictionary = parent.morphTargetDictionary;
240
- }
241
- }
242
- });
243
- React.useLayoutEffect(() => {
244
- const group = ref.current;
245
- if (!group) return;
246
- const mesh = group.children[0];
247
- if (mesh) {
248
- mesh.renderOrder = renderOrder;
249
- const parent = group.parent;
250
- applyProps(mesh, {
251
- morphTargetInfluences: parent.morphTargetInfluences,
252
- morphTargetDictionary: parent.morphTargetDictionary
253
- });
254
- applyProps(mesh.material, {
255
- transparent,
256
- thickness,
257
- color,
258
- opacity,
259
- size: contextSize,
260
- screenspace,
261
- toneMapped,
262
- polygonOffset,
263
- polygonOffsetFactor,
264
- clippingPlanes,
265
- clipping: clippingPlanes && clippingPlanes.length > 0
266
- });
267
- }
268
- });
269
- React.useEffect(() => {
270
- return () => {
271
- const group = ref.current;
272
- if (!group) return;
273
- const mesh = group.children[0];
274
- if (mesh) {
275
- if (angle) mesh.geometry.dispose();
276
- group.remove(mesh);
277
- }
278
- };
279
- }, []);
280
- return /* @__PURE__ */ jsx("group", {
281
- ref,
282
- ...props
283
- });
284
- }
285
-
286
- //#endregion
287
- //#region src/legacy/Effects/Trail/Trail.tsx
288
- const defaults = {
289
- width: .2,
290
- length: 1,
291
- decay: 1,
292
- local: false,
293
- stride: 0,
294
- interval: 1
295
- };
296
- const shiftLeft = (collection, steps = 1) => {
297
- const lastX = collection[collection.length - 3];
298
- const lastY = collection[collection.length - 2];
299
- const lastZ = collection[collection.length - 1];
300
- collection.set(collection.subarray(steps));
301
- const fillStart = collection.length - steps;
302
- for (let i = fillStart; i < collection.length; i += 3) {
303
- collection[i] = lastX;
304
- collection[i + 1] = lastY;
305
- collection[i + 2] = lastZ;
306
- }
307
- return collection;
308
- };
309
- function useTrail(target, settings, pointCount) {
310
- const { local, decay, interval, stride } = {
311
- ...defaults,
312
- ...settings
313
- };
314
- const points = React.useRef(null);
315
- const [worldPosition] = React.useState(() => new Vector3());
316
- React.useLayoutEffect(() => {
317
- if (target) {
318
- const pos = target.position;
319
- points.current = Float32Array.from({ length: pointCount * 3 }, (_, i) => pos.getComponent(i % 3));
320
- }
321
- }, [pointCount, target]);
322
- const prevPosition = React.useRef(new Vector3());
323
- const frameCount = React.useRef(0);
324
- useFrame(() => {
325
- if (!target) return;
326
- if (!points.current) return;
327
- if (frameCount.current === 0) {
328
- let newPosition;
329
- if (local) newPosition = target.position;
330
- else {
331
- target.getWorldPosition(worldPosition);
332
- newPosition = worldPosition;
333
- }
334
- const steps = 1 * decay;
335
- for (let i = 0; i < steps; i++) {
336
- if (newPosition.distanceTo(prevPosition.current) < stride) continue;
337
- shiftLeft(points.current, 3);
338
- points.current.set(newPosition.toArray(), points.current.length - 3);
339
- }
340
- prevPosition.current.copy(newPosition);
341
- }
342
- frameCount.current++;
343
- frameCount.current = frameCount.current % interval;
344
- });
345
- return points;
346
- }
347
- /**
348
- * A declarative trail effect using Line2.
349
- * WebGL version using LineMaterial.
350
- */
351
- const Trail = /* @__PURE__ */ React.forwardRef((props, forwardRef) => {
352
- const { children } = props;
353
- const { width, length, decay, local, stride, interval } = {
354
- ...defaults,
355
- ...props
356
- };
357
- const { color = "hotpink", attenuation, target } = props;
358
- const size = useThree((s) => s.size);
359
- const scene = useThree((s) => s.scene);
360
- const ref = React.useRef(null);
361
- const [anchor, setAnchor] = React.useState(null);
362
- const pointCount = length * 10;
363
- const points = useTrail(anchor, {
364
- decay,
365
- local,
366
- stride,
367
- interval
368
- }, pointCount);
369
- React.useEffect(() => {
370
- const t = target?.current || ref.current.children.find((o) => o instanceof Object3D);
371
- if (t) setAnchor(t);
372
- }, [points, target]);
373
- const line = React.useMemo(() => new Line2(), []);
374
- const geo = React.useMemo(() => {
375
- const geometry = new LineGeometry();
376
- const initialPositions = new Float32Array(pointCount * 3).fill(0);
377
- const initialColors = new Float32Array(pointCount * 3).fill(1);
378
- geometry.setPositions(initialPositions);
379
- geometry.setColors(initialColors);
380
- return geometry;
381
- }, [pointCount]);
382
- const [resolution] = React.useState(() => new Vector2(size.width, size.height));
383
- const colorsRef = React.useRef(new Float32Array(pointCount * 3));
384
- const baseColor = React.useMemo(() => new THREE.Color(color), [color]);
385
- const mat = React.useMemo(() => new LineMaterial({
386
- color: 16777215,
387
- linewidth: width,
388
- vertexColors: true,
389
- resolution: new Vector2(size.width, size.height),
390
- transparent: true,
391
- alphaToCoverage: true
392
- }), [width, size]);
393
- React.useEffect(() => {
394
- resolution.set(size.width, size.height);
395
- mat.resolution.set(size.width, size.height);
396
- }, [
397
- size,
398
- mat,
399
- resolution
400
- ]);
401
- useFrame(() => {
402
- if (!points.current) return;
403
- const count = points.current.length / 3;
404
- const colors = colorsRef.current;
405
- for (let i = 0; i < count; i++) {
406
- const t = i / (count - 1);
407
- const alpha = attenuation ? attenuation(t) : t;
408
- colors[i * 3 + 0] = baseColor.r * alpha;
409
- colors[i * 3 + 1] = baseColor.g * alpha;
410
- colors[i * 3 + 2] = baseColor.b * alpha;
411
- }
412
- geo.setPositions(points.current);
413
- geo.setColors(colors);
414
- line.computeLineDistances();
415
- });
416
- React.useLayoutEffect(() => {
417
- line.geometry = geo;
418
- line.material = mat;
419
- }, [
420
- line,
421
- geo,
422
- mat
423
- ]);
424
- return /* @__PURE__ */ jsxs("group", { children: [createPortal(/* @__PURE__ */ jsx("primitive", {
425
- object: line,
426
- ref: forwardRef
427
- }), scene), /* @__PURE__ */ jsx("group", {
428
- ref,
429
- children
430
- })] });
431
- });
432
-
433
- //#endregion
434
- export { MarchingCube, MarchingCubes, MarchingPlane, Outlines, Trail, useTrail };
@@ -1,3 +0,0 @@
1
- import { A as LoadStats, B as isSupported, C as HlsSkip, D as Level, E as KeySystems, F as SubtitleStreamController, I as SubtitleTrackController, L as TimelineController, M as NetworkErrorAction, N as Part, O as LevelDetails, P as PlaylistLevelType, R as getMediaSource, S as Hls, T as KeySystemFormats, _ as ErrorDetails, a as BasePlaylistController, b as FPSController, c as BufferController, d as ChunkMetadata, f as ContentSteeringController, g as ErrorController, h as ErrorActionFlags, i as AudioTrackController, j as MetadataSchema, k as LevelKey, l as CMCDController, m as EMEController, n as AttrList, o as BaseSegment, p as DateRange, r as AudioStreamController, s as BaseStreamController, t as AbrController, u as CapLevelController, v as ErrorTypes, w as HlsUrlParameters, x as Fragment, y as Events, z as isMSESupported } from "./libs/hls.js.mjs";
2
-
3
- export { AbrController, AttrList, AudioStreamController, AudioTrackController, BasePlaylistController, BaseSegment, BaseStreamController, BufferController, CMCDController, CapLevelController, ChunkMetadata, ContentSteeringController, DateRange, EMEController, ErrorActionFlags, ErrorController, ErrorDetails, ErrorTypes, Events, FPSController, Fragment, Hls, Hls as default, HlsSkip, HlsUrlParameters, KeySystemFormats, KeySystems, Level, LevelDetails, LevelKey, LoadStats, MetadataSchema, NetworkErrorAction, Part, PlaylistLevelType, SubtitleStreamController, SubtitleTrackController, TimelineController, getMediaSource, isMSESupported, isSupported };