@react-three/fiber 10.0.0-canary.de17310 → 10.0.0-canary.de8b03c

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 (39) hide show
  1. package/dist/chunks/webgl.cjs +27 -0
  2. package/dist/chunks/webgl.mjs +11 -0
  3. package/dist/chunks/webgpu.cjs +37 -0
  4. package/dist/chunks/webgpu.mjs +21 -0
  5. package/dist/extension.cjs +8 -273
  6. package/dist/extension.d.cts +14 -624
  7. package/dist/extension.d.mts +14 -624
  8. package/dist/extension.d.ts +14 -624
  9. package/dist/extension.mjs +1 -258
  10. package/dist/index.cjs +97 -15406
  11. package/dist/index.d.cts +120 -3574
  12. package/dist/index.d.mts +120 -3574
  13. package/dist/index.d.ts +120 -3546
  14. package/dist/index.mjs +10 -15305
  15. package/dist/legacy.cjs +97 -15364
  16. package/dist/legacy.d.cts +110 -3545
  17. package/dist/legacy.d.mts +110 -3545
  18. package/dist/legacy.d.ts +110 -3519
  19. package/dist/legacy.mjs +12 -15264
  20. package/dist/shared/fiber.B0oukOFO.mjs +364 -0
  21. package/dist/shared/fiber.BDWBTuAk.d.mts +2797 -0
  22. package/dist/shared/fiber.BU0vBHc9.d.mts +48 -0
  23. package/dist/shared/fiber.Cx-UAmMb.d.ts +48 -0
  24. package/dist/shared/fiber.DAl4H27x.d.cts +48 -0
  25. package/dist/shared/fiber.DNgUv56V.d.ts +2797 -0
  26. package/dist/shared/fiber.DlTSmVjz.d.cts +2797 -0
  27. package/dist/shared/fiber.I5Q4dVvl.d.cts +778 -0
  28. package/dist/shared/fiber.I5Q4dVvl.d.mts +778 -0
  29. package/dist/shared/fiber.I5Q4dVvl.d.ts +778 -0
  30. package/dist/shared/fiber.khFlPHPf.cjs +397 -0
  31. package/dist/shared/fiber.oKEFddXj.cjs +16059 -0
  32. package/dist/shared/fiber.tsM9NKZ9.mjs +15961 -0
  33. package/dist/webgpu/index.cjs +101 -15399
  34. package/dist/webgpu/index.d.cts +112 -3555
  35. package/dist/webgpu/index.d.mts +112 -3555
  36. package/dist/webgpu/index.d.ts +112 -3527
  37. package/dist/webgpu/index.mjs +17 -15300
  38. package/package.json +6 -8
  39. package/readme.md +1 -1
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const THREE = require('three');
4
+
5
+ function _interopNamespaceCompat(e) {
6
+ if (e && typeof e === 'object' && 'default' in e) return e;
7
+ const n = Object.create(null);
8
+ if (e) {
9
+ for (const k in e) {
10
+ n[k] = e[k];
11
+ }
12
+ }
13
+ n.default = e;
14
+ return n;
15
+ }
16
+
17
+ const THREE__namespace = /*#__PURE__*/_interopNamespaceCompat(THREE);
18
+
19
+ const webglSupport = {
20
+ kind: "webgl",
21
+ three: THREE__namespace,
22
+ Renderer: THREE__namespace.WebGLRenderer,
23
+ RenderTarget: THREE__namespace.WebGLRenderTarget,
24
+ CubeRenderTarget: THREE__namespace.WebGLCubeRenderTarget
25
+ };
26
+
27
+ exports.webglSupport = webglSupport;
@@ -0,0 +1,11 @@
1
+ import * as THREE from 'three';
2
+
3
+ const webglSupport = {
4
+ kind: "webgl",
5
+ three: THREE,
6
+ Renderer: THREE.WebGLRenderer,
7
+ RenderTarget: THREE.WebGLRenderTarget,
8
+ CubeRenderTarget: THREE.WebGLCubeRenderTarget
9
+ };
10
+
11
+ export { webglSupport };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const THREE = require('three/webgpu');
4
+ const tsl = require('three/tsl');
5
+
6
+ function _interopNamespaceCompat(e) {
7
+ if (e && typeof e === 'object' && 'default' in e) return e;
8
+ const n = Object.create(null);
9
+ if (e) {
10
+ for (const k in e) {
11
+ n[k] = e[k];
12
+ }
13
+ }
14
+ n.default = e;
15
+ return n;
16
+ }
17
+
18
+ const THREE__namespace = /*#__PURE__*/_interopNamespaceCompat(THREE);
19
+
20
+ const webgpuSupport = {
21
+ kind: "webgpu",
22
+ three: THREE__namespace,
23
+ Renderer: THREE__namespace.WebGPURenderer,
24
+ RenderTarget: THREE__namespace.RenderTarget,
25
+ CubeRenderTarget: THREE__namespace.CubeRenderTarget,
26
+ CanvasTarget: THREE__namespace.CanvasTarget,
27
+ // What the occlusion observer (core/visibility.ts) is built from
28
+ occlusion: {
29
+ Node: THREE__namespace.Node,
30
+ NodeUpdateType: THREE__namespace.NodeUpdateType,
31
+ MeshBasicNodeMaterial: THREE__namespace.MeshBasicNodeMaterial,
32
+ uniform: tsl.uniform,
33
+ nodeObject: tsl.nodeObject
34
+ }
35
+ };
36
+
37
+ exports.webgpuSupport = webgpuSupport;
@@ -0,0 +1,21 @@
1
+ import * as THREE from 'three/webgpu';
2
+ import { nodeObject, uniform } from 'three/tsl';
3
+
4
+ const webgpuSupport = {
5
+ kind: "webgpu",
6
+ three: THREE,
7
+ Renderer: THREE.WebGPURenderer,
8
+ RenderTarget: THREE.RenderTarget,
9
+ CubeRenderTarget: THREE.CubeRenderTarget,
10
+ CanvasTarget: THREE.CanvasTarget,
11
+ // What the occlusion observer (core/visibility.ts) is built from
12
+ occlusion: {
13
+ Node: THREE.Node,
14
+ NodeUpdateType: THREE.NodeUpdateType,
15
+ MeshBasicNodeMaterial: THREE.MeshBasicNodeMaterial,
16
+ uniform,
17
+ nodeObject
18
+ }
19
+ };
20
+
21
+ export { webgpuSupport };
@@ -1,278 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const React = require('react');
4
- require('react/jsx-runtime');
5
- require('its-fine');
6
- const scheduler = require('@pmndrs/scheduler');
3
+ const extensions = require('./shared/fiber.khFlPHPf.cjs');
7
4
 
8
- function _interopNamespaceCompat(e) {
9
- if (e && typeof e === 'object' && 'default' in e) return e;
10
- const n = Object.create(null);
11
- if (e) {
12
- for (const k in e) {
13
- n[k] = e[k];
14
- }
15
- }
16
- n.default = e;
17
- return n;
18
- }
19
5
 
20
- const React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
21
6
 
22
- const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
23
- const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React__namespace.createContext(null));
24
-
25
- function useStore() {
26
- const store = React.useContext(context);
27
- if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
28
- return store;
29
- }
30
- function useThree(selector = (state) => state, equalityFn) {
31
- return useStore()(selector, equalityFn);
32
- }
33
-
34
- const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
35
- function useMutableCallback(fn) {
36
- const ref = React__namespace.useRef(fn);
37
- useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
38
- return ref;
39
- }
40
-
41
- const shownNotices = /* @__PURE__ */ new Set();
42
- function notifyDepreciated({ heading, body, link }) {
43
- if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
44
- return;
45
- }
46
- if (shownNotices.has(heading)) return;
47
- shownNotices.add(heading);
48
- const caller = getCallerFrame();
49
- if (caller) {
50
- console.log();
51
- }
52
- const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
53
- if (caller) {
54
- console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
55
- }
56
- {
57
- let message = "";
58
- message += body;
59
- message += ("\n\n" ) + `More info: ${link}`;
60
- console.warn(`%c${message}`, "font-weight: bold;");
61
- }
62
- }
63
- function getCallerFrame(depth = 3) {
64
- const stack = new Error().stack;
65
- if (!stack) return null;
66
- const lines = stack.split("\n");
67
- const frame = lines[depth];
68
- if (!frame) return null;
69
- let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
70
- if (!match) {
71
- match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
72
- }
73
- if (!match) return null;
74
- const [, fn, url, line] = match;
75
- return {
76
- functionName: fn ?? "<anonymous>",
77
- location: formatLocation(url, Number(line))
78
- };
79
- }
80
- function formatLocation(url, line) {
81
- const clean = url.split("?")[0];
82
- const file = clean.split("/").pop() ?? clean;
83
- return `${file}:${line}`;
84
- }
85
-
86
- function useFrame(callback, priorityOrOptions) {
87
- const store = React__namespace.useContext(context);
88
- const isInsideCanvas = store !== null;
89
- const scheduler$1 = scheduler.getScheduler();
90
- const optionsKey = typeof priorityOrOptions === "number" ? `p:${priorityOrOptions}` : priorityOrOptions ? JSON.stringify({
91
- id: priorityOrOptions.id,
92
- phase: priorityOrOptions.phase,
93
- priority: priorityOrOptions.priority,
94
- fps: priorityOrOptions.fps,
95
- drop: priorityOrOptions.drop,
96
- enabled: priorityOrOptions.enabled,
97
- before: priorityOrOptions.before,
98
- after: priorityOrOptions.after
99
- }) : "";
100
- const options = React__namespace.useMemo(() => {
101
- return typeof priorityOrOptions === "number" ? { priority: priorityOrOptions } : priorityOrOptions ?? {};
102
- }, [optionsKey]);
103
- const reactId = React__namespace.useId();
104
- const id = options.id ?? reactId;
105
- const callbackRef = useMutableCallback(callback);
106
- const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
107
- useIsomorphicLayoutEffect(() => {
108
- if (!callback) return;
109
- if (isInsideCanvas) {
110
- const state = store.getState();
111
- const rootId = state.internal.rootId;
112
- if (isLegacyPriority) {
113
- state.internal.priority++;
114
- let parentRoot = state.previousRoot;
115
- while (parentRoot) {
116
- const parentState = parentRoot.getState();
117
- if (parentState?.internal) parentState.internal.priority++;
118
- parentRoot = parentState?.previousRoot;
119
- }
120
- notifyDepreciated({
121
- heading: "useFrame with numeric priority is deprecated",
122
- body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within update phase, use: useFrame(callback, { priority: number })',
123
- link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
124
- });
125
- }
126
- const wrappedCallback = (frameState, delta) => {
127
- const localState = store.getState();
128
- const mergedState = {
129
- ...localState,
130
- time: frameState.time,
131
- delta: frameState.delta,
132
- elapsed: frameState.elapsed,
133
- frame: frameState.frame
134
- };
135
- callbackRef.current?.(mergedState, delta);
136
- };
137
- const unregister = scheduler$1.register(wrappedCallback, {
138
- id,
139
- rootId,
140
- ...options
141
- });
142
- return () => {
143
- unregister();
144
- if (isLegacyPriority) {
145
- const currentState = store.getState();
146
- if (currentState.internal) {
147
- currentState.internal.priority--;
148
- let parentRoot = currentState.previousRoot;
149
- while (parentRoot) {
150
- const parentState = parentRoot.getState();
151
- if (parentState?.internal) parentState.internal.priority--;
152
- parentRoot = parentState?.previousRoot;
153
- }
154
- }
155
- }
156
- };
157
- } else {
158
- return scheduler$1.register(
159
- (state, delta) => {
160
- const frameState = state;
161
- if (!frameState.renderer) return;
162
- callbackRef.current?.(frameState, delta);
163
- },
164
- { id, ...options }
165
- );
166
- }
167
- }, [store, scheduler$1, id, optionsKey, isLegacyPriority, isInsideCanvas]);
168
- const isPaused = React__namespace.useSyncExternalStore(
169
- // Subscribe function
170
- React__namespace.useCallback(
171
- (onStoreChange) => {
172
- return scheduler.getScheduler().subscribeJobState(id, onStoreChange);
173
- },
174
- [id]
175
- ),
176
- // getSnapshot function
177
- React__namespace.useCallback(() => scheduler.getScheduler().isJobPaused(id), [id]),
178
- // getServerSnapshot function (SSR)
179
- React__namespace.useCallback(() => false, [])
180
- );
181
- const controls = React__namespace.useMemo(() => {
182
- const scheduler2 = scheduler.getScheduler();
183
- return {
184
- /** The job's unique ID */
185
- id,
186
- /**
187
- * Access to the global scheduler for frame loop control.
188
- * Use for controlling the entire frame loop, adding phases, etc.
189
- */
190
- scheduler: scheduler2,
191
- /**
192
- * The root that currently owns this job. Resolve on access because ambient
193
- * jobs can be adopted by a Canvas after the controls object is created.
194
- */
195
- get rootId() {
196
- return scheduler.getScheduler().getJobRootId(id);
197
- },
198
- /**
199
- * Manually step this job only.
200
- * Bypasses FPS limiting - always runs.
201
- * @param timestamp Optional timestamp (defaults to performance.now())
202
- */
203
- step: (timestamp) => {
204
- scheduler.getScheduler().stepJob(id, timestamp);
205
- },
206
- /**
207
- * Manually step ALL jobs in the scheduler.
208
- * Useful for frameloop='never' mode.
209
- * @param timestamp Optional timestamp (defaults to performance.now())
210
- */
211
- stepAll: (timestamp) => {
212
- scheduler.getScheduler().step(timestamp);
213
- },
214
- /**
215
- * Request frames for this job's owning root without waking sibling roots.
216
- */
217
- invalidate: (frames, stackFrames) => {
218
- const scheduler3 = scheduler.getScheduler();
219
- const rootId = scheduler3.getJobRootId(id);
220
- if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
221
- },
222
- /**
223
- * Pause this job (set enabled=false).
224
- * Job remains registered but won't run.
225
- */
226
- pause: () => {
227
- scheduler.getScheduler().pauseJob(id);
228
- },
229
- /**
230
- * Resume this job (set enabled=true).
231
- */
232
- resume: () => {
233
- scheduler.getScheduler().resumeJob(id);
234
- },
235
- /**
236
- * Reactive paused state - automatically updates when pause/resume is called.
237
- * No need for forceUpdate() in your components.
238
- */
239
- isPaused
240
- };
241
- }, [id, isPaused]);
242
- return controls;
243
- }
244
-
245
- const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
246
- function getRegistry() {
247
- return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
248
- extensions: /* @__PURE__ */ new Map(),
249
- roots: /* @__PURE__ */ new Set(),
250
- applied: /* @__PURE__ */ new WeakMap()
251
- });
252
- }
253
- function setupRoot(registry, store, extension) {
254
- let applied = registry.applied.get(store);
255
- if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
256
- if (applied.has(extension.name)) return;
257
- applied.set(extension.name, extension);
258
- const patch = extension.setup?.(store);
259
- if (patch) store.setState(patch);
260
- }
261
- function registerRootExtension(extension) {
262
- const registry = getRegistry();
263
- registry.extensions.set(extension.name, extension);
264
- for (const store of registry.roots) setupRoot(registry, store, extension);
265
- return () => {
266
- if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
267
- };
268
- }
269
- function setRenderOverride(store, render) {
270
- store.getState().internal.renderOverride = render;
271
- }
272
-
273
- exports.context = context;
274
- exports.registerRootExtension = registerRootExtension;
275
- exports.setRenderOverride = setRenderOverride;
276
- exports.useFrame = useFrame;
277
- exports.useStore = useStore;
278
- exports.useThree = useThree;
7
+ exports.context = extensions.context;
8
+ exports.getTextureView = extensions.getTextureView;
9
+ exports.registerRootExtension = extensions.registerRootExtension;
10
+ exports.setRenderOverride = extensions.setRenderOverride;
11
+ exports.useFrame = extensions.useFrame;
12
+ exports.useStore = extensions.useStore;
13
+ exports.useThree = extensions.useThree;