@react-three/test-renderer 10.0.0-canary.1998a73 → 10.0.0-canary.245de23
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 +5 -5
- package/dist/index.cjs +400 -66
- package/dist/index.mjs +400 -66
- package/dist/legacy.cjs +6 -0
- package/dist/legacy.mjs +6 -0
- package/dist/webgpu/index.cjs +6 -0
- package/dist/webgpu/index.mjs +6 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -32,11 +32,11 @@ 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` | WebGPU, with the mocked GPU context
|
|
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` | WebGPU, with the mocked GPU context |
|
|
40
40
|
|
|
41
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.
|
|
42
42
|
|
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,389 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const react = require('react');
|
|
6
6
|
const fiber = require('@react-three/fiber');
|
|
7
7
|
|
|
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) {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
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
|
+
}
|
|
390
|
+
|
|
8
391
|
const lowerCaseFirstLetter = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
9
392
|
const toEventHandlerName = (eventName) => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
10
393
|
|
|
@@ -47,9 +430,9 @@ const toGraph = (object) => {
|
|
|
47
430
|
});
|
|
48
431
|
};
|
|
49
432
|
|
|
50
|
-
var __defProp$
|
|
51
|
-
var __defNormalProp$
|
|
52
|
-
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);
|
|
53
436
|
const functions = [
|
|
54
437
|
"activeTexture",
|
|
55
438
|
"attachShader",
|
|
@@ -769,18 +1152,18 @@ const extensions = {
|
|
|
769
1152
|
const returnsHandle = (method) => method.startsWith("create") || method === "fenceSync";
|
|
770
1153
|
class WebGL2RenderingContext {
|
|
771
1154
|
constructor(canvas) {
|
|
772
|
-
__publicField$
|
|
1155
|
+
__publicField$1(this, "getShaderPrecisionFormat", () => {
|
|
773
1156
|
return {
|
|
774
1157
|
rangeMin: 127,
|
|
775
1158
|
rangeMax: 127,
|
|
776
1159
|
precision: 23
|
|
777
1160
|
};
|
|
778
1161
|
});
|
|
779
|
-
__publicField$
|
|
780
|
-
__publicField$
|
|
781
|
-
__publicField$
|
|
782
|
-
__publicField$
|
|
783
|
-
__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", () => "");
|
|
784
1167
|
this.canvas = canvas;
|
|
785
1168
|
this.drawingBufferWidth = canvas.width;
|
|
786
1169
|
this.drawingBufferHeight = canvas.height;
|
|
@@ -802,61 +1185,10 @@ class WebGL2RenderingContext {
|
|
|
802
1185
|
getExtension(ext) {
|
|
803
1186
|
return extensions[ext];
|
|
804
1187
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
810
|
-
class MockGPUTexture {
|
|
811
|
-
constructor(descriptor) {
|
|
812
|
-
__publicField$1(this, "width");
|
|
813
|
-
__publicField$1(this, "height");
|
|
814
|
-
__publicField$1(this, "depthOrArrayLayers");
|
|
815
|
-
__publicField$1(this, "mipLevelCount");
|
|
816
|
-
__publicField$1(this, "sampleCount");
|
|
817
|
-
__publicField$1(this, "dimension");
|
|
818
|
-
__publicField$1(this, "format");
|
|
819
|
-
__publicField$1(this, "usage");
|
|
820
|
-
this.width = typeof descriptor.size === "number" ? descriptor.size : descriptor.size.width ?? 1;
|
|
821
|
-
this.height = typeof descriptor.size === "number" ? 1 : descriptor.size.height ?? 1;
|
|
822
|
-
this.depthOrArrayLayers = typeof descriptor.size === "number" ? 1 : descriptor.size.depthOrArrayLayers ?? 1;
|
|
823
|
-
this.mipLevelCount = descriptor.mipLevelCount ?? 1;
|
|
824
|
-
this.sampleCount = descriptor.sampleCount ?? 1;
|
|
825
|
-
this.dimension = descriptor.dimension ?? "2d";
|
|
826
|
-
this.format = descriptor.format;
|
|
827
|
-
this.usage = descriptor.usage;
|
|
828
|
-
}
|
|
829
|
-
createView(_descriptor) {
|
|
830
|
-
return new MockGPUTextureView();
|
|
831
|
-
}
|
|
832
|
-
destroy() {
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
class MockGPUTextureView {
|
|
836
|
-
constructor() {
|
|
837
|
-
__publicField$1(this, "label");
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
class MockGPUCanvasContext {
|
|
841
|
-
constructor(canvas) {
|
|
842
|
-
__publicField$1(this, "canvas");
|
|
843
|
-
__publicField$1(this, "_configuration", null);
|
|
844
|
-
this.canvas = canvas;
|
|
845
|
-
}
|
|
846
|
-
configure(configuration) {
|
|
847
|
-
this._configuration = configuration;
|
|
848
|
-
}
|
|
849
|
-
unconfigure() {
|
|
850
|
-
this._configuration = null;
|
|
851
|
-
}
|
|
852
|
-
getCurrentTexture() {
|
|
853
|
-
const width = this.canvas instanceof HTMLCanvasElement ? this.canvas.width : this.canvas.width;
|
|
854
|
-
const height = this.canvas instanceof HTMLCanvasElement ? this.canvas.height : this.canvas.height;
|
|
855
|
-
return new MockGPUTexture({
|
|
856
|
-
size: { width, height },
|
|
857
|
-
format: this._configuration?.format ?? "bgra8unorm",
|
|
858
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
859
|
-
});
|
|
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);
|
|
860
1192
|
}
|
|
861
1193
|
}
|
|
862
1194
|
|
|
@@ -1046,6 +1378,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1046
1378
|
object,
|
|
1047
1379
|
eventCount: 0,
|
|
1048
1380
|
handlers: {},
|
|
1381
|
+
previousVisible: void 0,
|
|
1049
1382
|
isHidden: false
|
|
1050
1383
|
};
|
|
1051
1384
|
if (object.children && object.children.length > 0) {
|
|
@@ -1217,13 +1550,14 @@ const index$1 = {
|
|
|
1217
1550
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
1218
1551
|
};
|
|
1219
1552
|
|
|
1553
|
+
mockWebGPU();
|
|
1220
1554
|
const renderer = createTestRenderer({
|
|
1221
1555
|
createRoot: fiber.createRoot,
|
|
1222
1556
|
mockRoots: fiber._roots,
|
|
1223
1557
|
reconciler: fiber.reconciler,
|
|
1224
1558
|
act: react.act,
|
|
1225
|
-
mode: "
|
|
1226
|
-
// The root entry renders with
|
|
1559
|
+
mode: "webgpu"
|
|
1560
|
+
// The root entry renders with WebGPURenderer
|
|
1227
1561
|
});
|
|
1228
1562
|
const { create } = renderer;
|
|
1229
1563
|
const index = { create, act: react.act, waitFor };
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,389 @@ import { act } from 'react';
|
|
|
2
2
|
export { act } from 'react';
|
|
3
3
|
import { createRoot, _roots, reconciler } from '@react-three/fiber';
|
|
4
4
|
|
|
5
|
+
var __defProp$2 = Object.defineProperty;
|
|
6
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
class MockGPUBuffer {
|
|
9
|
+
constructor(descriptor) {
|
|
10
|
+
__publicField$2(this, "size");
|
|
11
|
+
__publicField$2(this, "usage");
|
|
12
|
+
__publicField$2(this, "mapState", "unmapped");
|
|
13
|
+
this.size = descriptor.size;
|
|
14
|
+
this.usage = descriptor.usage;
|
|
15
|
+
}
|
|
16
|
+
getMappedRange(_offset, _size) {
|
|
17
|
+
return new ArrayBuffer(this.size);
|
|
18
|
+
}
|
|
19
|
+
unmap() {
|
|
20
|
+
}
|
|
21
|
+
destroy() {
|
|
22
|
+
}
|
|
23
|
+
async mapAsync(_mode, _offset, _size) {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class MockGPUTexture {
|
|
27
|
+
constructor(descriptor) {
|
|
28
|
+
__publicField$2(this, "width");
|
|
29
|
+
__publicField$2(this, "height");
|
|
30
|
+
__publicField$2(this, "depthOrArrayLayers");
|
|
31
|
+
__publicField$2(this, "mipLevelCount");
|
|
32
|
+
__publicField$2(this, "sampleCount");
|
|
33
|
+
__publicField$2(this, "dimension");
|
|
34
|
+
__publicField$2(this, "format");
|
|
35
|
+
__publicField$2(this, "usage");
|
|
36
|
+
this.width = typeof descriptor.size === "number" ? descriptor.size : descriptor.size.width ?? 1;
|
|
37
|
+
this.height = typeof descriptor.size === "number" ? 1 : descriptor.size.height ?? 1;
|
|
38
|
+
this.depthOrArrayLayers = typeof descriptor.size === "number" ? 1 : descriptor.size.depthOrArrayLayers ?? 1;
|
|
39
|
+
this.mipLevelCount = descriptor.mipLevelCount ?? 1;
|
|
40
|
+
this.sampleCount = descriptor.sampleCount ?? 1;
|
|
41
|
+
this.dimension = descriptor.dimension ?? "2d";
|
|
42
|
+
this.format = descriptor.format;
|
|
43
|
+
this.usage = descriptor.usage;
|
|
44
|
+
}
|
|
45
|
+
createView(_descriptor) {
|
|
46
|
+
return new MockGPUTextureView();
|
|
47
|
+
}
|
|
48
|
+
destroy() {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class MockGPUTextureView {
|
|
52
|
+
constructor() {
|
|
53
|
+
__publicField$2(this, "label");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class MockGPUSampler {
|
|
57
|
+
constructor(_descriptor) {
|
|
58
|
+
__publicField$2(this, "label");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class MockGPUShaderModule {
|
|
62
|
+
constructor(_descriptor) {
|
|
63
|
+
__publicField$2(this, "label");
|
|
64
|
+
}
|
|
65
|
+
getCompilationInfo() {
|
|
66
|
+
return Promise.resolve({ messages: [] });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class MockGPUBindGroupLayout {
|
|
70
|
+
constructor(_descriptor) {
|
|
71
|
+
__publicField$2(this, "label");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
class MockGPUBindGroup {
|
|
75
|
+
constructor(_descriptor) {
|
|
76
|
+
__publicField$2(this, "label");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class MockGPUPipelineLayout {
|
|
80
|
+
constructor(_descriptor) {
|
|
81
|
+
__publicField$2(this, "label");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class MockGPURenderPipeline {
|
|
85
|
+
constructor(_descriptor) {
|
|
86
|
+
__publicField$2(this, "label");
|
|
87
|
+
}
|
|
88
|
+
getBindGroupLayout(_index) {
|
|
89
|
+
return new MockGPUBindGroupLayout({ entries: [] });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
class MockGPUComputePipeline {
|
|
93
|
+
constructor(_descriptor) {
|
|
94
|
+
__publicField$2(this, "label");
|
|
95
|
+
}
|
|
96
|
+
getBindGroupLayout(_index) {
|
|
97
|
+
return new MockGPUBindGroupLayout({ entries: [] });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
class MockGPUCommandEncoder {
|
|
101
|
+
constructor() {
|
|
102
|
+
__publicField$2(this, "label");
|
|
103
|
+
}
|
|
104
|
+
beginRenderPass(_descriptor) {
|
|
105
|
+
return new MockGPURenderPassEncoder();
|
|
106
|
+
}
|
|
107
|
+
beginComputePass(_descriptor) {
|
|
108
|
+
return new MockGPUComputePassEncoder();
|
|
109
|
+
}
|
|
110
|
+
copyBufferToBuffer(_source, _sourceOffset, _destination, _destinationOffset, _size) {
|
|
111
|
+
}
|
|
112
|
+
copyBufferToTexture(_source, _destination, _copySize) {
|
|
113
|
+
}
|
|
114
|
+
copyTextureToBuffer(_source, _destination, _copySize) {
|
|
115
|
+
}
|
|
116
|
+
copyTextureToTexture(_source, _destination, _copySize) {
|
|
117
|
+
}
|
|
118
|
+
finish(_descriptor) {
|
|
119
|
+
return new MockGPUCommandBuffer();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
class MockGPURenderPassEncoder {
|
|
123
|
+
setPipeline(_pipeline) {
|
|
124
|
+
}
|
|
125
|
+
setBindGroup(_index, _bindGroup, _dynamicOffsets) {
|
|
126
|
+
}
|
|
127
|
+
setVertexBuffer(_slot, _buffer, _offset, _size) {
|
|
128
|
+
}
|
|
129
|
+
setIndexBuffer(_buffer, _indexFormat, _offset, _size) {
|
|
130
|
+
}
|
|
131
|
+
setViewport(_x, _y, _width, _height, _minDepth, _maxDepth) {
|
|
132
|
+
}
|
|
133
|
+
setScissorRect(_x, _y, _width, _height) {
|
|
134
|
+
}
|
|
135
|
+
setBlendConstant(_color) {
|
|
136
|
+
}
|
|
137
|
+
setStencilReference(_reference) {
|
|
138
|
+
}
|
|
139
|
+
draw(_vertexCount, _instanceCount, _firstVertex, _firstInstance) {
|
|
140
|
+
}
|
|
141
|
+
drawIndexed(_indexCount, _instanceCount, _firstIndex, _baseVertex, _firstInstance) {
|
|
142
|
+
}
|
|
143
|
+
drawIndirect(_indirectBuffer, _indirectOffset) {
|
|
144
|
+
}
|
|
145
|
+
drawIndexedIndirect(_indirectBuffer, _indirectOffset) {
|
|
146
|
+
}
|
|
147
|
+
end() {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
class MockGPUComputePassEncoder {
|
|
151
|
+
setPipeline(_pipeline) {
|
|
152
|
+
}
|
|
153
|
+
setBindGroup(_index, _bindGroup, _dynamicOffsets) {
|
|
154
|
+
}
|
|
155
|
+
dispatchWorkgroups(_workgroupCountX, _workgroupCountY, _workgroupCountZ) {
|
|
156
|
+
}
|
|
157
|
+
dispatchWorkgroupsIndirect(_indirectBuffer, _indirectOffset) {
|
|
158
|
+
}
|
|
159
|
+
end() {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
class MockGPUCommandBuffer {
|
|
163
|
+
constructor() {
|
|
164
|
+
__publicField$2(this, "label");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
class MockGPUQueue {
|
|
168
|
+
constructor() {
|
|
169
|
+
__publicField$2(this, "label");
|
|
170
|
+
}
|
|
171
|
+
submit(_commandBuffers) {
|
|
172
|
+
}
|
|
173
|
+
writeBuffer(_buffer, _bufferOffset, _data, _dataOffset, _size) {
|
|
174
|
+
}
|
|
175
|
+
writeTexture(_destination, _data, _dataLayout, _size) {
|
|
176
|
+
}
|
|
177
|
+
copyExternalImageToTexture(_source, _destination, _copySize) {
|
|
178
|
+
}
|
|
179
|
+
onSubmittedWorkDone() {
|
|
180
|
+
return Promise.resolve();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
class MockGPUQuerySet {
|
|
184
|
+
constructor(descriptor) {
|
|
185
|
+
__publicField$2(this, "type");
|
|
186
|
+
__publicField$2(this, "count");
|
|
187
|
+
this.type = descriptor.type;
|
|
188
|
+
this.count = descriptor.count;
|
|
189
|
+
}
|
|
190
|
+
destroy() {
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
class MockGPUDevice extends EventTarget {
|
|
194
|
+
constructor() {
|
|
195
|
+
super();
|
|
196
|
+
__publicField$2(this, "features", /* @__PURE__ */ new Set());
|
|
197
|
+
__publicField$2(this, "limits", createMockLimits());
|
|
198
|
+
__publicField$2(this, "queue", new MockGPUQueue());
|
|
199
|
+
__publicField$2(this, "lost");
|
|
200
|
+
__publicField$2(this, "label");
|
|
201
|
+
__publicField$2(this, "_destroyed", false);
|
|
202
|
+
this.lost = new Promise(() => {
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
destroy() {
|
|
206
|
+
this._destroyed = true;
|
|
207
|
+
}
|
|
208
|
+
// Buffer Creation --
|
|
209
|
+
createBuffer(descriptor) {
|
|
210
|
+
return new MockGPUBuffer(descriptor);
|
|
211
|
+
}
|
|
212
|
+
// Texture Creation --
|
|
213
|
+
createTexture(descriptor) {
|
|
214
|
+
return new MockGPUTexture(descriptor);
|
|
215
|
+
}
|
|
216
|
+
createSampler(descriptor) {
|
|
217
|
+
return new MockGPUSampler(descriptor);
|
|
218
|
+
}
|
|
219
|
+
// Shader/Pipeline Creation --
|
|
220
|
+
createShaderModule(descriptor) {
|
|
221
|
+
return new MockGPUShaderModule(descriptor);
|
|
222
|
+
}
|
|
223
|
+
createBindGroupLayout(descriptor) {
|
|
224
|
+
return new MockGPUBindGroupLayout(descriptor);
|
|
225
|
+
}
|
|
226
|
+
createBindGroup(descriptor) {
|
|
227
|
+
return new MockGPUBindGroup(descriptor);
|
|
228
|
+
}
|
|
229
|
+
createPipelineLayout(descriptor) {
|
|
230
|
+
return new MockGPUPipelineLayout(descriptor);
|
|
231
|
+
}
|
|
232
|
+
createRenderPipeline(descriptor) {
|
|
233
|
+
return new MockGPURenderPipeline(descriptor);
|
|
234
|
+
}
|
|
235
|
+
async createRenderPipelineAsync(descriptor) {
|
|
236
|
+
return new MockGPURenderPipeline(descriptor);
|
|
237
|
+
}
|
|
238
|
+
createComputePipeline(descriptor) {
|
|
239
|
+
return new MockGPUComputePipeline(descriptor);
|
|
240
|
+
}
|
|
241
|
+
async createComputePipelineAsync(descriptor) {
|
|
242
|
+
return new MockGPUComputePipeline(descriptor);
|
|
243
|
+
}
|
|
244
|
+
// Command Encoding --
|
|
245
|
+
createCommandEncoder(_descriptor) {
|
|
246
|
+
return new MockGPUCommandEncoder();
|
|
247
|
+
}
|
|
248
|
+
// Query Sets --
|
|
249
|
+
createQuerySet(descriptor) {
|
|
250
|
+
return new MockGPUQuerySet(descriptor);
|
|
251
|
+
}
|
|
252
|
+
// Error Handling --
|
|
253
|
+
pushErrorScope(_filter) {
|
|
254
|
+
}
|
|
255
|
+
popErrorScope() {
|
|
256
|
+
return Promise.resolve(null);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
class MockGPUAdapter {
|
|
260
|
+
constructor() {
|
|
261
|
+
__publicField$2(this, "features", /* @__PURE__ */ new Set());
|
|
262
|
+
__publicField$2(this, "limits", createMockLimits());
|
|
263
|
+
__publicField$2(this, "isFallbackAdapter", false);
|
|
264
|
+
}
|
|
265
|
+
async requestDevice(_descriptor) {
|
|
266
|
+
return new MockGPUDevice();
|
|
267
|
+
}
|
|
268
|
+
async requestAdapterInfo() {
|
|
269
|
+
return {
|
|
270
|
+
vendor: "Mock",
|
|
271
|
+
architecture: "Mock",
|
|
272
|
+
device: "Mock Test Renderer",
|
|
273
|
+
description: "Mock WebGPU Adapter for Testing"
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
class MockGPU {
|
|
278
|
+
constructor() {
|
|
279
|
+
__publicField$2(this, "wgslLanguageFeatures", /* @__PURE__ */ new Set());
|
|
280
|
+
}
|
|
281
|
+
async requestAdapter(_options) {
|
|
282
|
+
return new MockGPUAdapter();
|
|
283
|
+
}
|
|
284
|
+
getPreferredCanvasFormat() {
|
|
285
|
+
return "bgra8unorm";
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
class MockGPUCanvasContext {
|
|
289
|
+
constructor(canvas) {
|
|
290
|
+
__publicField$2(this, "canvas");
|
|
291
|
+
__publicField$2(this, "_configuration", null);
|
|
292
|
+
this.canvas = canvas;
|
|
293
|
+
}
|
|
294
|
+
configure(configuration) {
|
|
295
|
+
this._configuration = configuration;
|
|
296
|
+
}
|
|
297
|
+
unconfigure() {
|
|
298
|
+
this._configuration = null;
|
|
299
|
+
}
|
|
300
|
+
getCurrentTexture() {
|
|
301
|
+
const width = this.canvas instanceof HTMLCanvasElement ? this.canvas.width : this.canvas.width;
|
|
302
|
+
const height = this.canvas instanceof HTMLCanvasElement ? this.canvas.height : this.canvas.height;
|
|
303
|
+
return new MockGPUTexture({
|
|
304
|
+
size: { width, height },
|
|
305
|
+
format: this._configuration?.format ?? "bgra8unorm",
|
|
306
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function createMockLimits() {
|
|
311
|
+
return {
|
|
312
|
+
maxTextureDimension1D: 8192,
|
|
313
|
+
maxTextureDimension2D: 8192,
|
|
314
|
+
maxTextureDimension3D: 2048,
|
|
315
|
+
maxTextureArrayLayers: 256,
|
|
316
|
+
maxBindGroups: 4,
|
|
317
|
+
maxBindGroupsPlusVertexBuffers: 24,
|
|
318
|
+
maxBindingsPerBindGroup: 1e3,
|
|
319
|
+
maxDynamicUniformBuffersPerPipelineLayout: 8,
|
|
320
|
+
maxDynamicStorageBuffersPerPipelineLayout: 4,
|
|
321
|
+
maxSampledTexturesPerShaderStage: 16,
|
|
322
|
+
maxSamplersPerShaderStage: 16,
|
|
323
|
+
maxStorageBuffersPerShaderStage: 8,
|
|
324
|
+
maxStorageTexturesPerShaderStage: 4,
|
|
325
|
+
maxUniformBuffersPerShaderStage: 12,
|
|
326
|
+
maxUniformBufferBindingSize: 65536,
|
|
327
|
+
maxStorageBufferBindingSize: 134217728,
|
|
328
|
+
minUniformBufferOffsetAlignment: 256,
|
|
329
|
+
minStorageBufferOffsetAlignment: 256,
|
|
330
|
+
maxVertexBuffers: 8,
|
|
331
|
+
maxBufferSize: 268435456,
|
|
332
|
+
maxVertexAttributes: 16,
|
|
333
|
+
maxVertexBufferArrayStride: 2048,
|
|
334
|
+
maxInterStageShaderVariables: 16,
|
|
335
|
+
maxColorAttachments: 8,
|
|
336
|
+
maxColorAttachmentBytesPerSample: 32,
|
|
337
|
+
maxComputeWorkgroupStorageSize: 16384,
|
|
338
|
+
maxComputeInvocationsPerWorkgroup: 256,
|
|
339
|
+
maxComputeWorkgroupSizeX: 256,
|
|
340
|
+
maxComputeWorkgroupSizeY: 256,
|
|
341
|
+
maxComputeWorkgroupSizeZ: 64,
|
|
342
|
+
maxComputeWorkgroupsPerDimension: 65535
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function mockWebGPU() {
|
|
346
|
+
const mockGPU = new MockGPU();
|
|
347
|
+
if (typeof globalThis.navigator === "undefined") {
|
|
348
|
+
globalThis.navigator = {};
|
|
349
|
+
}
|
|
350
|
+
globalThis.navigator.gpu = mockGPU;
|
|
351
|
+
globalThis.GPUTextureUsage = {
|
|
352
|
+
COPY_SRC: 1,
|
|
353
|
+
COPY_DST: 2,
|
|
354
|
+
TEXTURE_BINDING: 4,
|
|
355
|
+
STORAGE_BINDING: 8,
|
|
356
|
+
RENDER_ATTACHMENT: 16
|
|
357
|
+
};
|
|
358
|
+
globalThis.GPUBufferUsage = {
|
|
359
|
+
MAP_READ: 1,
|
|
360
|
+
MAP_WRITE: 2,
|
|
361
|
+
COPY_SRC: 4,
|
|
362
|
+
COPY_DST: 8,
|
|
363
|
+
INDEX: 16,
|
|
364
|
+
VERTEX: 32,
|
|
365
|
+
UNIFORM: 64,
|
|
366
|
+
STORAGE: 128,
|
|
367
|
+
INDIRECT: 256,
|
|
368
|
+
QUERY_RESOLVE: 512
|
|
369
|
+
};
|
|
370
|
+
globalThis.GPUMapMode = {
|
|
371
|
+
READ: 1,
|
|
372
|
+
WRITE: 2
|
|
373
|
+
};
|
|
374
|
+
globalThis.GPUShaderStage = {
|
|
375
|
+
VERTEX: 1,
|
|
376
|
+
FRAGMENT: 2,
|
|
377
|
+
COMPUTE: 4
|
|
378
|
+
};
|
|
379
|
+
globalThis.GPUColorWrite = {
|
|
380
|
+
RED: 1,
|
|
381
|
+
GREEN: 2,
|
|
382
|
+
BLUE: 4,
|
|
383
|
+
ALPHA: 8,
|
|
384
|
+
ALL: 15
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
5
388
|
const lowerCaseFirstLetter = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
6
389
|
const toEventHandlerName = (eventName) => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
7
390
|
|
|
@@ -44,9 +427,9 @@ const toGraph = (object) => {
|
|
|
44
427
|
});
|
|
45
428
|
};
|
|
46
429
|
|
|
47
|
-
var __defProp$
|
|
48
|
-
var __defNormalProp$
|
|
49
|
-
var __publicField$
|
|
430
|
+
var __defProp$1 = Object.defineProperty;
|
|
431
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
432
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
50
433
|
const functions = [
|
|
51
434
|
"activeTexture",
|
|
52
435
|
"attachShader",
|
|
@@ -766,18 +1149,18 @@ const extensions = {
|
|
|
766
1149
|
const returnsHandle = (method) => method.startsWith("create") || method === "fenceSync";
|
|
767
1150
|
class WebGL2RenderingContext {
|
|
768
1151
|
constructor(canvas) {
|
|
769
|
-
__publicField$
|
|
1152
|
+
__publicField$1(this, "getShaderPrecisionFormat", () => {
|
|
770
1153
|
return {
|
|
771
1154
|
rangeMin: 127,
|
|
772
1155
|
rangeMax: 127,
|
|
773
1156
|
precision: 23
|
|
774
1157
|
};
|
|
775
1158
|
});
|
|
776
|
-
__publicField$
|
|
777
|
-
__publicField$
|
|
778
|
-
__publicField$
|
|
779
|
-
__publicField$
|
|
780
|
-
__publicField$
|
|
1159
|
+
__publicField$1(this, "GL_VERSION", 7938);
|
|
1160
|
+
__publicField$1(this, "SCISSOR_BOX", 3088);
|
|
1161
|
+
__publicField$1(this, "VIEWPORT", 2978);
|
|
1162
|
+
__publicField$1(this, "getProgramInfoLog", () => "");
|
|
1163
|
+
__publicField$1(this, "getShaderInfoLog", () => "");
|
|
781
1164
|
this.canvas = canvas;
|
|
782
1165
|
this.drawingBufferWidth = canvas.width;
|
|
783
1166
|
this.drawingBufferHeight = canvas.height;
|
|
@@ -799,61 +1182,10 @@ class WebGL2RenderingContext {
|
|
|
799
1182
|
getExtension(ext) {
|
|
800
1183
|
return extensions[ext];
|
|
801
1184
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
807
|
-
class MockGPUTexture {
|
|
808
|
-
constructor(descriptor) {
|
|
809
|
-
__publicField$1(this, "width");
|
|
810
|
-
__publicField$1(this, "height");
|
|
811
|
-
__publicField$1(this, "depthOrArrayLayers");
|
|
812
|
-
__publicField$1(this, "mipLevelCount");
|
|
813
|
-
__publicField$1(this, "sampleCount");
|
|
814
|
-
__publicField$1(this, "dimension");
|
|
815
|
-
__publicField$1(this, "format");
|
|
816
|
-
__publicField$1(this, "usage");
|
|
817
|
-
this.width = typeof descriptor.size === "number" ? descriptor.size : descriptor.size.width ?? 1;
|
|
818
|
-
this.height = typeof descriptor.size === "number" ? 1 : descriptor.size.height ?? 1;
|
|
819
|
-
this.depthOrArrayLayers = typeof descriptor.size === "number" ? 1 : descriptor.size.depthOrArrayLayers ?? 1;
|
|
820
|
-
this.mipLevelCount = descriptor.mipLevelCount ?? 1;
|
|
821
|
-
this.sampleCount = descriptor.sampleCount ?? 1;
|
|
822
|
-
this.dimension = descriptor.dimension ?? "2d";
|
|
823
|
-
this.format = descriptor.format;
|
|
824
|
-
this.usage = descriptor.usage;
|
|
825
|
-
}
|
|
826
|
-
createView(_descriptor) {
|
|
827
|
-
return new MockGPUTextureView();
|
|
828
|
-
}
|
|
829
|
-
destroy() {
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
class MockGPUTextureView {
|
|
833
|
-
constructor() {
|
|
834
|
-
__publicField$1(this, "label");
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
class MockGPUCanvasContext {
|
|
838
|
-
constructor(canvas) {
|
|
839
|
-
__publicField$1(this, "canvas");
|
|
840
|
-
__publicField$1(this, "_configuration", null);
|
|
841
|
-
this.canvas = canvas;
|
|
842
|
-
}
|
|
843
|
-
configure(configuration) {
|
|
844
|
-
this._configuration = configuration;
|
|
845
|
-
}
|
|
846
|
-
unconfigure() {
|
|
847
|
-
this._configuration = null;
|
|
848
|
-
}
|
|
849
|
-
getCurrentTexture() {
|
|
850
|
-
const width = this.canvas instanceof HTMLCanvasElement ? this.canvas.width : this.canvas.width;
|
|
851
|
-
const height = this.canvas instanceof HTMLCanvasElement ? this.canvas.height : this.canvas.height;
|
|
852
|
-
return new MockGPUTexture({
|
|
853
|
-
size: { width, height },
|
|
854
|
-
format: this._configuration?.format ?? "bgra8unorm",
|
|
855
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
856
|
-
});
|
|
1185
|
+
// WebGPURenderer's WebGL2 fallback backend lists the supported extensions up front and checks
|
|
1186
|
+
// them with `.includes()`, so this has to return an array rather than the no-op stub's undefined
|
|
1187
|
+
getSupportedExtensions() {
|
|
1188
|
+
return Object.keys(extensions);
|
|
857
1189
|
}
|
|
858
1190
|
}
|
|
859
1191
|
|
|
@@ -1043,6 +1375,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1043
1375
|
object,
|
|
1044
1376
|
eventCount: 0,
|
|
1045
1377
|
handlers: {},
|
|
1378
|
+
previousVisible: void 0,
|
|
1046
1379
|
isHidden: false
|
|
1047
1380
|
};
|
|
1048
1381
|
if (object.children && object.children.length > 0) {
|
|
@@ -1214,13 +1547,14 @@ const index$1 = {
|
|
|
1214
1547
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
1215
1548
|
};
|
|
1216
1549
|
|
|
1550
|
+
mockWebGPU();
|
|
1217
1551
|
const renderer = createTestRenderer({
|
|
1218
1552
|
createRoot,
|
|
1219
1553
|
mockRoots: _roots,
|
|
1220
1554
|
reconciler,
|
|
1221
1555
|
act,
|
|
1222
|
-
mode: "
|
|
1223
|
-
// The root entry renders with
|
|
1556
|
+
mode: "webgpu"
|
|
1557
|
+
// The root entry renders with WebGPURenderer
|
|
1224
1558
|
});
|
|
1225
1559
|
const { create } = renderer;
|
|
1226
1560
|
const index = { create, act, waitFor };
|
package/dist/legacy.cjs
CHANGED
|
@@ -802,6 +802,11 @@ class WebGL2RenderingContext {
|
|
|
802
802
|
getExtension(ext) {
|
|
803
803
|
return extensions[ext];
|
|
804
804
|
}
|
|
805
|
+
// WebGPURenderer's WebGL2 fallback backend lists the supported extensions up front and checks
|
|
806
|
+
// them with `.includes()`, so this has to return an array rather than the no-op stub's undefined
|
|
807
|
+
getSupportedExtensions() {
|
|
808
|
+
return Object.keys(extensions);
|
|
809
|
+
}
|
|
805
810
|
}
|
|
806
811
|
|
|
807
812
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -1046,6 +1051,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1046
1051
|
object,
|
|
1047
1052
|
eventCount: 0,
|
|
1048
1053
|
handlers: {},
|
|
1054
|
+
previousVisible: void 0,
|
|
1049
1055
|
isHidden: false
|
|
1050
1056
|
};
|
|
1051
1057
|
if (object.children && object.children.length > 0) {
|
package/dist/legacy.mjs
CHANGED
|
@@ -799,6 +799,11 @@ class WebGL2RenderingContext {
|
|
|
799
799
|
getExtension(ext) {
|
|
800
800
|
return extensions[ext];
|
|
801
801
|
}
|
|
802
|
+
// WebGPURenderer's WebGL2 fallback backend lists the supported extensions up front and checks
|
|
803
|
+
// them with `.includes()`, so this has to return an array rather than the no-op stub's undefined
|
|
804
|
+
getSupportedExtensions() {
|
|
805
|
+
return Object.keys(extensions);
|
|
806
|
+
}
|
|
802
807
|
}
|
|
803
808
|
|
|
804
809
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -1043,6 +1048,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1043
1048
|
object,
|
|
1044
1049
|
eventCount: 0,
|
|
1045
1050
|
handlers: {},
|
|
1051
|
+
previousVisible: void 0,
|
|
1046
1052
|
isHidden: false
|
|
1047
1053
|
};
|
|
1048
1054
|
if (object.children && object.children.length > 0) {
|
package/dist/webgpu/index.cjs
CHANGED
|
@@ -1195,6 +1195,11 @@ class WebGL2RenderingContext {
|
|
|
1195
1195
|
getExtension(ext) {
|
|
1196
1196
|
return extensions[ext];
|
|
1197
1197
|
}
|
|
1198
|
+
// WebGPURenderer's WebGL2 fallback backend lists the supported extensions up front and checks
|
|
1199
|
+
// them with `.includes()`, so this has to return an array rather than the no-op stub's undefined
|
|
1200
|
+
getSupportedExtensions() {
|
|
1201
|
+
return Object.keys(extensions);
|
|
1202
|
+
}
|
|
1198
1203
|
}
|
|
1199
1204
|
|
|
1200
1205
|
function setupWebGLMocking() {
|
|
@@ -1383,6 +1388,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1383
1388
|
object,
|
|
1384
1389
|
eventCount: 0,
|
|
1385
1390
|
handlers: {},
|
|
1391
|
+
previousVisible: void 0,
|
|
1386
1392
|
isHidden: false
|
|
1387
1393
|
};
|
|
1388
1394
|
if (object.children && object.children.length > 0) {
|
package/dist/webgpu/index.mjs
CHANGED
|
@@ -1193,6 +1193,11 @@ class WebGL2RenderingContext {
|
|
|
1193
1193
|
getExtension(ext) {
|
|
1194
1194
|
return extensions[ext];
|
|
1195
1195
|
}
|
|
1196
|
+
// WebGPURenderer's WebGL2 fallback backend lists the supported extensions up front and checks
|
|
1197
|
+
// them with `.includes()`, so this has to return an array rather than the no-op stub's undefined
|
|
1198
|
+
getSupportedExtensions() {
|
|
1199
|
+
return Object.keys(extensions);
|
|
1200
|
+
}
|
|
1196
1201
|
}
|
|
1197
1202
|
|
|
1198
1203
|
function setupWebGLMocking() {
|
|
@@ -1381,6 +1386,7 @@ const createVirtualInstance = (object, parent) => {
|
|
|
1381
1386
|
object,
|
|
1382
1387
|
eventCount: 0,
|
|
1383
1388
|
handlers: {},
|
|
1389
|
+
previousVisible: void 0,
|
|
1384
1390
|
isHidden: false
|
|
1385
1391
|
};
|
|
1386
1392
|
if (object.children && object.children.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/test-renderer",
|
|
3
|
-
"version": "10.0.0-canary.
|
|
3
|
+
"version": "10.0.0-canary.245de23",
|
|
4
4
|
"description": "Test Renderer for react-three-fiber",
|
|
5
5
|
"author": "Josh Ellis",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@webgpu/types": "^0.1.64",
|
|
49
49
|
"three": ">=0.185.0",
|
|
50
|
-
"@react-three/fiber": "10.0.0-canary.
|
|
51
|
-
"@react-three/tsl": "10.0.0-canary.
|
|
50
|
+
"@react-three/fiber": "10.0.0-canary.245de23",
|
|
51
|
+
"@react-three/tsl": "10.0.0-canary.245de23"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"dist",
|