@react-three/test-renderer 10.0.0-canary.777b94d → 10.0.0-canary.88b1ca7
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 +22 -27
- package/dist/index.cjs +398 -82
- package/dist/index.mjs +402 -72
- package/dist/legacy.cjs +7 -19
- package/dist/legacy.mjs +8 -6
- package/dist/webgpu/index.cjs +7 -19
- package/dist/webgpu/index.mjs +8 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -32,11 +32,13 @@ Essentially, this package makes it easy to grab a snapshot of the Scene Graph re
|
|
|
32
32
|
|
|
33
33
|
Choose the entry point that matches your `@react-three/fiber` import:
|
|
34
34
|
|
|
35
|
-
| Your Fiber Import | Test Renderer Import | Use Case
|
|
36
|
-
| --------------------------- | ----------------------------------- |
|
|
37
|
-
| `@react-three/fiber` | `@react-three/test-renderer` | Default (
|
|
38
|
-
| `@react-three/fiber/legacy` | `@react-three/test-renderer/legacy` | WebGL only
|
|
39
|
-
| `@react-three/fiber/webgpu` | `@react-three/test-renderer/webgpu` |
|
|
35
|
+
| Your Fiber Import | Test Renderer Import | Use Case |
|
|
36
|
+
| --------------------------- | ----------------------------------- | ------------------------------------- |
|
|
37
|
+
| `@react-three/fiber` | `@react-three/test-renderer` | Default (WebGPU, mocked GPU context) |
|
|
38
|
+
| `@react-three/fiber/legacy` | `@react-three/test-renderer/legacy` | WebGL only |
|
|
39
|
+
| `@react-three/fiber/webgpu` | `@react-three/test-renderer/webgpu` | Deprecated, removed in the first beta |
|
|
40
|
+
|
|
41
|
+
Whichever entry you pick, the root resolves JSX elements from the three namespace of the renderer it loads, exactly as in the app: node materials exist under WebGPU and not under WebGL.
|
|
40
42
|
|
|
41
43
|
### Default Entry
|
|
42
44
|
|
|
@@ -72,15 +74,16 @@ import { Canvas } from '@react-three/fiber/legacy'
|
|
|
72
74
|
const renderer = await ReactThreeTestRenderer.create(<MyScene />)
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
###
|
|
77
|
+
### TSL (Three Shading Language)
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
The default entry renders with `WebGPURenderer`, so node materials and the TSL hooks work without
|
|
80
|
+
any setup. `@react-three/test-renderer/webgpu` does the same and is deprecated.
|
|
78
81
|
|
|
79
82
|
```tsx
|
|
80
|
-
import ReactThreeTestRenderer from '@react-three/test-renderer
|
|
81
|
-
import {
|
|
83
|
+
import ReactThreeTestRenderer from '@react-three/test-renderer'
|
|
84
|
+
import { color } from 'three/tsl'
|
|
82
85
|
// The TSL hooks come from @react-three/tsl, in tests as in app code
|
|
83
|
-
import {
|
|
86
|
+
import { useUniforms, useNodes } from '@react-three/tsl'
|
|
84
87
|
|
|
85
88
|
// Component using WebGPU hooks
|
|
86
89
|
function MyWebGPUScene() {
|
|
@@ -131,12 +134,12 @@ console.log(renderer.toGraph())
|
|
|
131
134
|
|
|
132
135
|
## Testing WebGPU Hooks
|
|
133
136
|
|
|
134
|
-
|
|
137
|
+
Test TSL uniforms and nodes with the default entry and the hooks from `@react-three/tsl`:
|
|
135
138
|
|
|
136
139
|
```tsx
|
|
137
|
-
import ReactThreeTestRenderer from '@react-three/test-renderer
|
|
138
|
-
import {
|
|
139
|
-
import {
|
|
140
|
+
import ReactThreeTestRenderer from '@react-three/test-renderer'
|
|
141
|
+
import { color } from 'three/tsl'
|
|
142
|
+
import { useUniforms, useNodes } from '@react-three/tsl'
|
|
140
143
|
|
|
141
144
|
describe('My WebGPU Scene', () => {
|
|
142
145
|
it('should create and use uniforms', async () => {
|
|
@@ -186,23 +189,15 @@ describe('My WebGPU Scene', () => {
|
|
|
186
189
|
|
|
187
190
|
---
|
|
188
191
|
|
|
189
|
-
##
|
|
192
|
+
## Upgrading from v9
|
|
190
193
|
|
|
191
|
-
|
|
194
|
+
v9 had one entry, which rendered with WebGL. In v10 the default entry renders with WebGPU, to match
|
|
195
|
+
`@react-three/fiber`. If your app imports `Canvas` from `@react-three/fiber/legacy`, test with the
|
|
196
|
+
`/legacy` entry:
|
|
192
197
|
|
|
193
198
|
```diff
|
|
194
|
-
// Before (v8) - single entry point
|
|
195
199
|
-import ReactThreeTestRenderer from '@react-three/test-renderer'
|
|
196
|
-
|
|
197
|
-
// After (v9+) - choose matching entry
|
|
198
|
-
// For WebGPU apps:
|
|
199
|
-
+import ReactThreeTestRenderer from '@react-three/test-renderer/webgpu'
|
|
200
|
-
|
|
201
|
-
// For legacy WebGL apps:
|
|
202
200
|
+import ReactThreeTestRenderer from '@react-three/test-renderer/legacy'
|
|
203
|
-
|
|
204
|
-
// For default (auto-detection):
|
|
205
|
-
+import ReactThreeTestRenderer from '@react-three/test-renderer'
|
|
206
201
|
```
|
|
207
202
|
|
|
208
203
|
---
|
|
@@ -211,4 +206,4 @@ If you're upgrading from v8 and using WebGPU features:
|
|
|
211
206
|
|
|
212
207
|
- [React Three Test Renderer API](./markdown/rttr.md)
|
|
213
208
|
- [React Three Test Instance API](./markdown/rttr-instance.md)
|
|
214
|
-
- [WebGPU
|
|
209
|
+
- [Testing WebGPU and TSL](https://r3f.docs.pmnd.rs/next/api/testing#testing-webgpu-and-tsl)
|
package/dist/index.cjs
CHANGED
|
@@ -3,22 +3,390 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const react = require('react');
|
|
6
|
-
const THREE = require('three');
|
|
7
6
|
const fiber = require('@react-three/fiber');
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
var __defProp$2 = Object.defineProperty;
|
|
9
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
+
class MockGPUBuffer {
|
|
12
|
+
constructor(descriptor) {
|
|
13
|
+
__publicField$2(this, "size");
|
|
14
|
+
__publicField$2(this, "usage");
|
|
15
|
+
__publicField$2(this, "mapState", "unmapped");
|
|
16
|
+
this.size = descriptor.size;
|
|
17
|
+
this.usage = descriptor.usage;
|
|
18
|
+
}
|
|
19
|
+
getMappedRange(_offset, _size) {
|
|
20
|
+
return new ArrayBuffer(this.size);
|
|
21
|
+
}
|
|
22
|
+
unmap() {
|
|
23
|
+
}
|
|
24
|
+
destroy() {
|
|
25
|
+
}
|
|
26
|
+
async mapAsync(_mode, _offset, _size) {
|
|
16
27
|
}
|
|
17
|
-
n.default = e;
|
|
18
|
-
return n;
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
class MockGPUTexture {
|
|
30
|
+
constructor(descriptor) {
|
|
31
|
+
__publicField$2(this, "width");
|
|
32
|
+
__publicField$2(this, "height");
|
|
33
|
+
__publicField$2(this, "depthOrArrayLayers");
|
|
34
|
+
__publicField$2(this, "mipLevelCount");
|
|
35
|
+
__publicField$2(this, "sampleCount");
|
|
36
|
+
__publicField$2(this, "dimension");
|
|
37
|
+
__publicField$2(this, "format");
|
|
38
|
+
__publicField$2(this, "usage");
|
|
39
|
+
this.width = typeof descriptor.size === "number" ? descriptor.size : descriptor.size.width ?? 1;
|
|
40
|
+
this.height = typeof descriptor.size === "number" ? 1 : descriptor.size.height ?? 1;
|
|
41
|
+
this.depthOrArrayLayers = typeof descriptor.size === "number" ? 1 : descriptor.size.depthOrArrayLayers ?? 1;
|
|
42
|
+
this.mipLevelCount = descriptor.mipLevelCount ?? 1;
|
|
43
|
+
this.sampleCount = descriptor.sampleCount ?? 1;
|
|
44
|
+
this.dimension = descriptor.dimension ?? "2d";
|
|
45
|
+
this.format = descriptor.format;
|
|
46
|
+
this.usage = descriptor.usage;
|
|
47
|
+
}
|
|
48
|
+
createView(_descriptor) {
|
|
49
|
+
return new MockGPUTextureView();
|
|
50
|
+
}
|
|
51
|
+
destroy() {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class MockGPUTextureView {
|
|
55
|
+
constructor() {
|
|
56
|
+
__publicField$2(this, "label");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class MockGPUSampler {
|
|
60
|
+
constructor(_descriptor) {
|
|
61
|
+
__publicField$2(this, "label");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class MockGPUShaderModule {
|
|
65
|
+
constructor(_descriptor) {
|
|
66
|
+
__publicField$2(this, "label");
|
|
67
|
+
}
|
|
68
|
+
getCompilationInfo() {
|
|
69
|
+
return Promise.resolve({ messages: [] });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class MockGPUBindGroupLayout {
|
|
73
|
+
constructor(_descriptor) {
|
|
74
|
+
__publicField$2(this, "label");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
class MockGPUBindGroup {
|
|
78
|
+
constructor(_descriptor) {
|
|
79
|
+
__publicField$2(this, "label");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
class MockGPUPipelineLayout {
|
|
83
|
+
constructor(_descriptor) {
|
|
84
|
+
__publicField$2(this, "label");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class MockGPURenderPipeline {
|
|
88
|
+
constructor(_descriptor) {
|
|
89
|
+
__publicField$2(this, "label");
|
|
90
|
+
}
|
|
91
|
+
getBindGroupLayout(_index) {
|
|
92
|
+
return new MockGPUBindGroupLayout({ entries: [] });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
class MockGPUComputePipeline {
|
|
96
|
+
constructor(_descriptor) {
|
|
97
|
+
__publicField$2(this, "label");
|
|
98
|
+
}
|
|
99
|
+
getBindGroupLayout(_index) {
|
|
100
|
+
return new MockGPUBindGroupLayout({ entries: [] });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class MockGPUCommandEncoder {
|
|
104
|
+
constructor() {
|
|
105
|
+
__publicField$2(this, "label");
|
|
106
|
+
}
|
|
107
|
+
beginRenderPass(_descriptor) {
|
|
108
|
+
return new MockGPURenderPassEncoder();
|
|
109
|
+
}
|
|
110
|
+
beginComputePass(_descriptor) {
|
|
111
|
+
return new MockGPUComputePassEncoder();
|
|
112
|
+
}
|
|
113
|
+
copyBufferToBuffer(_source, _sourceOffset, _destination, _destinationOffset, _size) {
|
|
114
|
+
}
|
|
115
|
+
copyBufferToTexture(_source, _destination, _copySize) {
|
|
116
|
+
}
|
|
117
|
+
copyTextureToBuffer(_source, _destination, _copySize) {
|
|
118
|
+
}
|
|
119
|
+
copyTextureToTexture(_source, _destination, _copySize) {
|
|
120
|
+
}
|
|
121
|
+
finish(_descriptor) {
|
|
122
|
+
return new MockGPUCommandBuffer();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
class MockGPURenderPassEncoder {
|
|
126
|
+
setPipeline(_pipeline) {
|
|
127
|
+
}
|
|
128
|
+
setBindGroup(_index, _bindGroup, _dynamicOffsets) {
|
|
129
|
+
}
|
|
130
|
+
setVertexBuffer(_slot, _buffer, _offset, _size) {
|
|
131
|
+
}
|
|
132
|
+
setIndexBuffer(_buffer, _indexFormat, _offset, _size) {
|
|
133
|
+
}
|
|
134
|
+
setViewport(_x, _y, _width, _height, _minDepth, _maxDepth) {
|
|
135
|
+
}
|
|
136
|
+
setScissorRect(_x, _y, _width, _height) {
|
|
137
|
+
}
|
|
138
|
+
setBlendConstant(_color) {
|
|
139
|
+
}
|
|
140
|
+
setStencilReference(_reference) {
|
|
141
|
+
}
|
|
142
|
+
draw(_vertexCount, _instanceCount, _firstVertex, _firstInstance) {
|
|
143
|
+
}
|
|
144
|
+
drawIndexed(_indexCount, _instanceCount, _firstIndex, _baseVertex, _firstInstance) {
|
|
145
|
+
}
|
|
146
|
+
drawIndirect(_indirectBuffer, _indirectOffset) {
|
|
147
|
+
}
|
|
148
|
+
drawIndexedIndirect(_indirectBuffer, _indirectOffset) {
|
|
149
|
+
}
|
|
150
|
+
end() {
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
class MockGPUComputePassEncoder {
|
|
154
|
+
setPipeline(_pipeline) {
|
|
155
|
+
}
|
|
156
|
+
setBindGroup(_index, _bindGroup, _dynamicOffsets) {
|
|
157
|
+
}
|
|
158
|
+
dispatchWorkgroups(_workgroupCountX, _workgroupCountY, _workgroupCountZ) {
|
|
159
|
+
}
|
|
160
|
+
dispatchWorkgroupsIndirect(_indirectBuffer, _indirectOffset) {
|
|
161
|
+
}
|
|
162
|
+
end() {
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
class MockGPUCommandBuffer {
|
|
166
|
+
constructor() {
|
|
167
|
+
__publicField$2(this, "label");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
class MockGPUQueue {
|
|
171
|
+
constructor() {
|
|
172
|
+
__publicField$2(this, "label");
|
|
173
|
+
}
|
|
174
|
+
submit(_commandBuffers) {
|
|
175
|
+
}
|
|
176
|
+
writeBuffer(_buffer, _bufferOffset, _data, _dataOffset, _size) {
|
|
177
|
+
}
|
|
178
|
+
writeTexture(_destination, _data, _dataLayout, _size) {
|
|
179
|
+
}
|
|
180
|
+
copyExternalImageToTexture(_source, _destination, _copySize) {
|
|
181
|
+
}
|
|
182
|
+
onSubmittedWorkDone() {
|
|
183
|
+
return Promise.resolve();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class MockGPUQuerySet {
|
|
187
|
+
constructor(descriptor) {
|
|
188
|
+
__publicField$2(this, "type");
|
|
189
|
+
__publicField$2(this, "count");
|
|
190
|
+
this.type = descriptor.type;
|
|
191
|
+
this.count = descriptor.count;
|
|
192
|
+
}
|
|
193
|
+
destroy() {
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
class MockGPUDevice extends EventTarget {
|
|
197
|
+
constructor() {
|
|
198
|
+
super();
|
|
199
|
+
__publicField$2(this, "features", /* @__PURE__ */ new Set());
|
|
200
|
+
__publicField$2(this, "limits", createMockLimits());
|
|
201
|
+
__publicField$2(this, "queue", new MockGPUQueue());
|
|
202
|
+
__publicField$2(this, "lost");
|
|
203
|
+
__publicField$2(this, "label");
|
|
204
|
+
__publicField$2(this, "_destroyed", false);
|
|
205
|
+
this.lost = new Promise(() => {
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
destroy() {
|
|
209
|
+
this._destroyed = true;
|
|
210
|
+
}
|
|
211
|
+
// Buffer Creation --
|
|
212
|
+
createBuffer(descriptor) {
|
|
213
|
+
return new MockGPUBuffer(descriptor);
|
|
214
|
+
}
|
|
215
|
+
// Texture Creation --
|
|
216
|
+
createTexture(descriptor) {
|
|
217
|
+
return new MockGPUTexture(descriptor);
|
|
218
|
+
}
|
|
219
|
+
createSampler(descriptor) {
|
|
220
|
+
return new MockGPUSampler(descriptor);
|
|
221
|
+
}
|
|
222
|
+
// Shader/Pipeline Creation --
|
|
223
|
+
createShaderModule(descriptor) {
|
|
224
|
+
return new MockGPUShaderModule(descriptor);
|
|
225
|
+
}
|
|
226
|
+
createBindGroupLayout(descriptor) {
|
|
227
|
+
return new MockGPUBindGroupLayout(descriptor);
|
|
228
|
+
}
|
|
229
|
+
createBindGroup(descriptor) {
|
|
230
|
+
return new MockGPUBindGroup(descriptor);
|
|
231
|
+
}
|
|
232
|
+
createPipelineLayout(descriptor) {
|
|
233
|
+
return new MockGPUPipelineLayout(descriptor);
|
|
234
|
+
}
|
|
235
|
+
createRenderPipeline(descriptor) {
|
|
236
|
+
return new MockGPURenderPipeline(descriptor);
|
|
237
|
+
}
|
|
238
|
+
async createRenderPipelineAsync(descriptor) {
|
|
239
|
+
return new MockGPURenderPipeline(descriptor);
|
|
240
|
+
}
|
|
241
|
+
createComputePipeline(descriptor) {
|
|
242
|
+
return new MockGPUComputePipeline(descriptor);
|
|
243
|
+
}
|
|
244
|
+
async createComputePipelineAsync(descriptor) {
|
|
245
|
+
return new MockGPUComputePipeline(descriptor);
|
|
246
|
+
}
|
|
247
|
+
// Command Encoding --
|
|
248
|
+
createCommandEncoder(_descriptor) {
|
|
249
|
+
return new MockGPUCommandEncoder();
|
|
250
|
+
}
|
|
251
|
+
// Query Sets --
|
|
252
|
+
createQuerySet(descriptor) {
|
|
253
|
+
return new MockGPUQuerySet(descriptor);
|
|
254
|
+
}
|
|
255
|
+
// Error Handling --
|
|
256
|
+
pushErrorScope(_filter) {
|
|
257
|
+
}
|
|
258
|
+
popErrorScope() {
|
|
259
|
+
return Promise.resolve(null);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
class MockGPUAdapter {
|
|
263
|
+
constructor() {
|
|
264
|
+
__publicField$2(this, "features", /* @__PURE__ */ new Set());
|
|
265
|
+
__publicField$2(this, "limits", createMockLimits());
|
|
266
|
+
__publicField$2(this, "isFallbackAdapter", false);
|
|
267
|
+
}
|
|
268
|
+
async requestDevice(_descriptor) {
|
|
269
|
+
return new MockGPUDevice();
|
|
270
|
+
}
|
|
271
|
+
async requestAdapterInfo() {
|
|
272
|
+
return {
|
|
273
|
+
vendor: "Mock",
|
|
274
|
+
architecture: "Mock",
|
|
275
|
+
device: "Mock Test Renderer",
|
|
276
|
+
description: "Mock WebGPU Adapter for Testing"
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
class MockGPU {
|
|
281
|
+
constructor() {
|
|
282
|
+
__publicField$2(this, "wgslLanguageFeatures", /* @__PURE__ */ new Set());
|
|
283
|
+
}
|
|
284
|
+
async requestAdapter(_options) {
|
|
285
|
+
return new MockGPUAdapter();
|
|
286
|
+
}
|
|
287
|
+
getPreferredCanvasFormat() {
|
|
288
|
+
return "bgra8unorm";
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
class MockGPUCanvasContext {
|
|
292
|
+
constructor(canvas) {
|
|
293
|
+
__publicField$2(this, "canvas");
|
|
294
|
+
__publicField$2(this, "_configuration", null);
|
|
295
|
+
this.canvas = canvas;
|
|
296
|
+
}
|
|
297
|
+
configure(configuration) {
|
|
298
|
+
this._configuration = configuration;
|
|
299
|
+
}
|
|
300
|
+
unconfigure() {
|
|
301
|
+
this._configuration = null;
|
|
302
|
+
}
|
|
303
|
+
getCurrentTexture() {
|
|
304
|
+
const width = this.canvas instanceof HTMLCanvasElement ? this.canvas.width : this.canvas.width;
|
|
305
|
+
const height = this.canvas instanceof HTMLCanvasElement ? this.canvas.height : this.canvas.height;
|
|
306
|
+
return new MockGPUTexture({
|
|
307
|
+
size: { width, height },
|
|
308
|
+
format: this._configuration?.format ?? "bgra8unorm",
|
|
309
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function createMockLimits() {
|
|
314
|
+
return {
|
|
315
|
+
maxTextureDimension1D: 8192,
|
|
316
|
+
maxTextureDimension2D: 8192,
|
|
317
|
+
maxTextureDimension3D: 2048,
|
|
318
|
+
maxTextureArrayLayers: 256,
|
|
319
|
+
maxBindGroups: 4,
|
|
320
|
+
maxBindGroupsPlusVertexBuffers: 24,
|
|
321
|
+
maxBindingsPerBindGroup: 1e3,
|
|
322
|
+
maxDynamicUniformBuffersPerPipelineLayout: 8,
|
|
323
|
+
maxDynamicStorageBuffersPerPipelineLayout: 4,
|
|
324
|
+
maxSampledTexturesPerShaderStage: 16,
|
|
325
|
+
maxSamplersPerShaderStage: 16,
|
|
326
|
+
maxStorageBuffersPerShaderStage: 8,
|
|
327
|
+
maxStorageTexturesPerShaderStage: 4,
|
|
328
|
+
maxUniformBuffersPerShaderStage: 12,
|
|
329
|
+
maxUniformBufferBindingSize: 65536,
|
|
330
|
+
maxStorageBufferBindingSize: 134217728,
|
|
331
|
+
minUniformBufferOffsetAlignment: 256,
|
|
332
|
+
minStorageBufferOffsetAlignment: 256,
|
|
333
|
+
maxVertexBuffers: 8,
|
|
334
|
+
maxBufferSize: 268435456,
|
|
335
|
+
maxVertexAttributes: 16,
|
|
336
|
+
maxVertexBufferArrayStride: 2048,
|
|
337
|
+
maxInterStageShaderVariables: 16,
|
|
338
|
+
maxColorAttachments: 8,
|
|
339
|
+
maxColorAttachmentBytesPerSample: 32,
|
|
340
|
+
maxComputeWorkgroupStorageSize: 16384,
|
|
341
|
+
maxComputeInvocationsPerWorkgroup: 256,
|
|
342
|
+
maxComputeWorkgroupSizeX: 256,
|
|
343
|
+
maxComputeWorkgroupSizeY: 256,
|
|
344
|
+
maxComputeWorkgroupSizeZ: 64,
|
|
345
|
+
maxComputeWorkgroupsPerDimension: 65535
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function mockWebGPU() {
|
|
349
|
+
const mockGPU = new MockGPU();
|
|
350
|
+
if (typeof globalThis.navigator === "undefined") {
|
|
351
|
+
globalThis.navigator = {};
|
|
352
|
+
}
|
|
353
|
+
globalThis.navigator.gpu = mockGPU;
|
|
354
|
+
globalThis.GPUTextureUsage = {
|
|
355
|
+
COPY_SRC: 1,
|
|
356
|
+
COPY_DST: 2,
|
|
357
|
+
TEXTURE_BINDING: 4,
|
|
358
|
+
STORAGE_BINDING: 8,
|
|
359
|
+
RENDER_ATTACHMENT: 16
|
|
360
|
+
};
|
|
361
|
+
globalThis.GPUBufferUsage = {
|
|
362
|
+
MAP_READ: 1,
|
|
363
|
+
MAP_WRITE: 2,
|
|
364
|
+
COPY_SRC: 4,
|
|
365
|
+
COPY_DST: 8,
|
|
366
|
+
INDEX: 16,
|
|
367
|
+
VERTEX: 32,
|
|
368
|
+
UNIFORM: 64,
|
|
369
|
+
STORAGE: 128,
|
|
370
|
+
INDIRECT: 256,
|
|
371
|
+
QUERY_RESOLVE: 512
|
|
372
|
+
};
|
|
373
|
+
globalThis.GPUMapMode = {
|
|
374
|
+
READ: 1,
|
|
375
|
+
WRITE: 2
|
|
376
|
+
};
|
|
377
|
+
globalThis.GPUShaderStage = {
|
|
378
|
+
VERTEX: 1,
|
|
379
|
+
FRAGMENT: 2,
|
|
380
|
+
COMPUTE: 4
|
|
381
|
+
};
|
|
382
|
+
globalThis.GPUColorWrite = {
|
|
383
|
+
RED: 1,
|
|
384
|
+
GREEN: 2,
|
|
385
|
+
BLUE: 4,
|
|
386
|
+
ALPHA: 8,
|
|
387
|
+
ALL: 15
|
|
388
|
+
};
|
|
389
|
+
}
|
|
22
390
|
|
|
23
391
|
const lowerCaseFirstLetter = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
24
392
|
const toEventHandlerName = (eventName) => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
@@ -62,9 +430,9 @@ const toGraph = (object) => {
|
|
|
62
430
|
});
|
|
63
431
|
};
|
|
64
432
|
|
|
65
|
-
var __defProp$
|
|
66
|
-
var __defNormalProp$
|
|
67
|
-
var __publicField$
|
|
433
|
+
var __defProp$1 = Object.defineProperty;
|
|
434
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
435
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
68
436
|
const functions = [
|
|
69
437
|
"activeTexture",
|
|
70
438
|
"attachShader",
|
|
@@ -784,18 +1152,18 @@ const extensions = {
|
|
|
784
1152
|
const returnsHandle = (method) => method.startsWith("create") || method === "fenceSync";
|
|
785
1153
|
class WebGL2RenderingContext {
|
|
786
1154
|
constructor(canvas) {
|
|
787
|
-
__publicField$
|
|
1155
|
+
__publicField$1(this, "getShaderPrecisionFormat", () => {
|
|
788
1156
|
return {
|
|
789
1157
|
rangeMin: 127,
|
|
790
1158
|
rangeMax: 127,
|
|
791
1159
|
precision: 23
|
|
792
1160
|
};
|
|
793
1161
|
});
|
|
794
|
-
__publicField$
|
|
795
|
-
__publicField$
|
|
796
|
-
__publicField$
|
|
797
|
-
__publicField$
|
|
798
|
-
__publicField$
|
|
1162
|
+
__publicField$1(this, "GL_VERSION", 7938);
|
|
1163
|
+
__publicField$1(this, "SCISSOR_BOX", 3088);
|
|
1164
|
+
__publicField$1(this, "VIEWPORT", 2978);
|
|
1165
|
+
__publicField$1(this, "getProgramInfoLog", () => "");
|
|
1166
|
+
__publicField$1(this, "getShaderInfoLog", () => "");
|
|
799
1167
|
this.canvas = canvas;
|
|
800
1168
|
this.drawingBufferWidth = canvas.width;
|
|
801
1169
|
this.drawingBufferHeight = canvas.height;
|
|
@@ -817,61 +1185,10 @@ class WebGL2RenderingContext {
|
|
|
817
1185
|
getExtension(ext) {
|
|
818
1186
|
return extensions[ext];
|
|
819
1187
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
825
|
-
class MockGPUTexture {
|
|
826
|
-
constructor(descriptor) {
|
|
827
|
-
__publicField$1(this, "width");
|
|
828
|
-
__publicField$1(this, "height");
|
|
829
|
-
__publicField$1(this, "depthOrArrayLayers");
|
|
830
|
-
__publicField$1(this, "mipLevelCount");
|
|
831
|
-
__publicField$1(this, "sampleCount");
|
|
832
|
-
__publicField$1(this, "dimension");
|
|
833
|
-
__publicField$1(this, "format");
|
|
834
|
-
__publicField$1(this, "usage");
|
|
835
|
-
this.width = typeof descriptor.size === "number" ? descriptor.size : descriptor.size.width ?? 1;
|
|
836
|
-
this.height = typeof descriptor.size === "number" ? 1 : descriptor.size.height ?? 1;
|
|
837
|
-
this.depthOrArrayLayers = typeof descriptor.size === "number" ? 1 : descriptor.size.depthOrArrayLayers ?? 1;
|
|
838
|
-
this.mipLevelCount = descriptor.mipLevelCount ?? 1;
|
|
839
|
-
this.sampleCount = descriptor.sampleCount ?? 1;
|
|
840
|
-
this.dimension = descriptor.dimension ?? "2d";
|
|
841
|
-
this.format = descriptor.format;
|
|
842
|
-
this.usage = descriptor.usage;
|
|
843
|
-
}
|
|
844
|
-
createView(_descriptor) {
|
|
845
|
-
return new MockGPUTextureView();
|
|
846
|
-
}
|
|
847
|
-
destroy() {
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
class MockGPUTextureView {
|
|
851
|
-
constructor() {
|
|
852
|
-
__publicField$1(this, "label");
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
class MockGPUCanvasContext {
|
|
856
|
-
constructor(canvas) {
|
|
857
|
-
__publicField$1(this, "canvas");
|
|
858
|
-
__publicField$1(this, "_configuration", null);
|
|
859
|
-
this.canvas = canvas;
|
|
860
|
-
}
|
|
861
|
-
configure(configuration) {
|
|
862
|
-
this._configuration = configuration;
|
|
863
|
-
}
|
|
864
|
-
unconfigure() {
|
|
865
|
-
this._configuration = null;
|
|
866
|
-
}
|
|
867
|
-
getCurrentTexture() {
|
|
868
|
-
const width = this.canvas instanceof HTMLCanvasElement ? this.canvas.width : this.canvas.width;
|
|
869
|
-
const height = this.canvas instanceof HTMLCanvasElement ? this.canvas.height : this.canvas.height;
|
|
870
|
-
return new MockGPUTexture({
|
|
871
|
-
size: { width, height },
|
|
872
|
-
format: this._configuration?.format ?? "bgra8unorm",
|
|
873
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
874
|
-
});
|
|
1188
|
+
// WebGPURenderer's WebGL2 fallback backend lists the supported extensions up front and checks
|
|
1189
|
+
// them with `.includes()`, so this has to return an array rather than the no-op stub's undefined
|
|
1190
|
+
getSupportedExtensions() {
|
|
1191
|
+
return Object.keys(extensions);
|
|
875
1192
|
}
|
|
876
1193
|
}
|
|
877
1194
|
|
|
@@ -1061,6 +1378,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1061
1378
|
object,
|
|
1062
1379
|
eventCount: 0,
|
|
1063
1380
|
handlers: {},
|
|
1381
|
+
previousVisible: void 0,
|
|
1064
1382
|
isHidden: false
|
|
1065
1383
|
};
|
|
1066
1384
|
if (object.children && object.children.length > 0) {
|
|
@@ -1144,8 +1462,7 @@ async function waitFor(callback, { interval = 50, timeout = 5e3 } = {}) {
|
|
|
1144
1462
|
}
|
|
1145
1463
|
|
|
1146
1464
|
function createTestRenderer(deps) {
|
|
1147
|
-
const {
|
|
1148
|
-
extend(THREE2);
|
|
1465
|
+
const { createRoot, mockRoots, reconciler, act, mode } = deps;
|
|
1149
1466
|
const create = async (element, options) => {
|
|
1150
1467
|
const canvas = createCanvas({ ...options, mode });
|
|
1151
1468
|
const _root = createRoot(canvas);
|
|
@@ -1233,15 +1550,14 @@ const index$1 = {
|
|
|
1233
1550
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
1234
1551
|
};
|
|
1235
1552
|
|
|
1553
|
+
mockWebGPU();
|
|
1236
1554
|
const renderer = createTestRenderer({
|
|
1237
|
-
THREE: THREE__namespace,
|
|
1238
1555
|
createRoot: fiber.createRoot,
|
|
1239
1556
|
mockRoots: fiber._roots,
|
|
1240
1557
|
reconciler: fiber.reconciler,
|
|
1241
1558
|
act: react.act,
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
// Default uses WebGL context
|
|
1559
|
+
mode: "webgpu"
|
|
1560
|
+
// The root entry renders with WebGPURenderer
|
|
1245
1561
|
});
|
|
1246
1562
|
const { create } = renderer;
|
|
1247
1563
|
const index = { create, act: react.act, waitFor };
|