@react-three/test-renderer 10.0.0-alpha.2 → 10.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.
- package/LICENSE +21 -0
- package/README.md +228 -228
- package/dist/{react-three-test-renderer.cjs.prod.js → index.cjs} +567 -225
- package/dist/index.d.cts +117 -0
- package/dist/index.d.mts +115 -0
- package/dist/index.d.ts +117 -0
- package/dist/{react-three-test-renderer.esm.js → index.mjs} +555 -204
- package/dist/legacy.cjs +1252 -0
- package/dist/legacy.d.cts +117 -0
- package/dist/legacy.d.mts +115 -0
- package/dist/legacy.d.ts +117 -0
- package/dist/{react-three-test-renderer.cjs.dev.js → legacy.mjs} +557 -237
- package/dist/webgpu/index.cjs +1603 -0
- package/dist/webgpu/index.d.cts +128 -0
- package/dist/webgpu/index.d.mts +126 -0
- package/dist/webgpu/index.d.ts +128 -0
- package/dist/webgpu/index.mjs +1570 -0
- package/package.json +60 -57
- package/CHANGELOG.md +0 -525
- package/dist/declarations/src/createTestInstance.d.ts +0 -22
- package/dist/declarations/src/helpers/waitFor.d.ts +0 -5
- package/dist/declarations/src/index.d.ts +0 -14
- package/dist/declarations/src/types/index.d.ts +0 -1
- package/dist/declarations/src/types/internal.d.ts +0 -20
- package/dist/declarations/src/types/public.d.ts +0 -38
- package/dist/react-three-test-renderer.cjs.d.ts +0 -3
- package/dist/react-three-test-renderer.cjs.js +0 -7
|
@@ -2,68 +2,296 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const react = require('react');
|
|
6
|
+
const THREE = require('three');
|
|
7
|
+
const fiber = require('@react-three/fiber');
|
|
7
8
|
|
|
8
|
-
function
|
|
9
|
-
if (e && e
|
|
10
|
-
|
|
9
|
+
function _interopNamespaceCompat(e) {
|
|
10
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
11
|
+
const n = Object.create(null);
|
|
11
12
|
if (e) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
13
|
+
for (const k in e) {
|
|
14
|
+
n[k] = e[k];
|
|
15
|
+
}
|
|
21
16
|
}
|
|
22
|
-
n
|
|
23
|
-
return
|
|
17
|
+
n.default = e;
|
|
18
|
+
return n;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
const THREE__namespace = /*#__PURE__*/_interopNamespaceCompat(THREE);
|
|
27
22
|
|
|
28
|
-
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
29
|
-
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
23
|
+
const lowerCaseFirstLetter = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
24
|
+
const toEventHandlerName = (eventName) => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
30
25
|
|
|
31
26
|
const treeObjectFactory = (type, props, children) => ({
|
|
32
27
|
type,
|
|
33
28
|
props,
|
|
34
29
|
children
|
|
35
30
|
});
|
|
36
|
-
const toTreeBranch = children => children.map(child => {
|
|
37
|
-
return treeObjectFactory(
|
|
31
|
+
const toTreeBranch = (children) => children.map((child) => {
|
|
32
|
+
return treeObjectFactory(
|
|
33
|
+
lowerCaseFirstLetter(child.object.type || child.object.constructor.name),
|
|
34
|
+
child.props,
|
|
35
|
+
toTreeBranch(child.children)
|
|
36
|
+
);
|
|
38
37
|
});
|
|
39
|
-
const toTree = root => toTreeBranch(root.children);
|
|
38
|
+
const toTree = (root) => toTreeBranch(root.children);
|
|
40
39
|
|
|
41
40
|
const graphObjectFactory = (type, name, children) => ({
|
|
42
41
|
type,
|
|
43
42
|
name,
|
|
44
43
|
children
|
|
45
44
|
});
|
|
46
|
-
|
|
47
|
-
// Helper function to process raw THREE.js children objects
|
|
48
45
|
function processThreeChildren(children) {
|
|
49
|
-
return children.map(
|
|
46
|
+
return children.map(
|
|
47
|
+
(object) => graphObjectFactory(
|
|
48
|
+
object.type,
|
|
49
|
+
object.name || "",
|
|
50
|
+
object.children && object.children.length > 0 ? processThreeChildren(object.children) : []
|
|
51
|
+
)
|
|
52
|
+
);
|
|
50
53
|
}
|
|
51
|
-
const toGraph = object => {
|
|
52
|
-
return object.children.map(child => {
|
|
53
|
-
var _child$object$childre, _child$object$name;
|
|
54
|
-
// Process standard R3F children
|
|
54
|
+
const toGraph = (object) => {
|
|
55
|
+
return object.children.map((child) => {
|
|
55
56
|
const children = toGraph(child);
|
|
56
|
-
|
|
57
|
-
// For primitives, also include THREE.js object children
|
|
58
|
-
if (child.type === 'primitive' && (_child$object$childre = child.object.children) != null && _child$object$childre.length) {
|
|
57
|
+
if (child.type === "primitive" && child.object.children?.length) {
|
|
59
58
|
const threeChildren = processThreeChildren(child.object.children);
|
|
60
59
|
children.push(...threeChildren);
|
|
61
60
|
}
|
|
62
|
-
return graphObjectFactory(child.object.type,
|
|
61
|
+
return graphObjectFactory(child.object.type, child.object.name ?? "", children);
|
|
63
62
|
});
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
var __defProp$2 = Object.defineProperty;
|
|
66
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
67
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
68
|
+
const functions = [
|
|
69
|
+
"activeTexture",
|
|
70
|
+
"attachShader",
|
|
71
|
+
"beginQuery",
|
|
72
|
+
"beginTransformFeedback",
|
|
73
|
+
"bindAttribLocation",
|
|
74
|
+
"bindBufferBase",
|
|
75
|
+
"bindBufferRange",
|
|
76
|
+
"bindRenderbuffer",
|
|
77
|
+
"bindSampler",
|
|
78
|
+
"bindTransformFeedback",
|
|
79
|
+
"bindVertexArray",
|
|
80
|
+
"blendColor",
|
|
81
|
+
"blendEquation",
|
|
82
|
+
"blendEquationSeparate",
|
|
83
|
+
"blendFunc",
|
|
84
|
+
"blendFuncSeparate",
|
|
85
|
+
"blitFramebuffer",
|
|
86
|
+
"bufferData",
|
|
87
|
+
"bufferSubData",
|
|
88
|
+
"checkFramebufferStatus",
|
|
89
|
+
"clientWaitSync",
|
|
90
|
+
"compileShader",
|
|
91
|
+
"compressedTexImage2D",
|
|
92
|
+
"compressedTexImage3D",
|
|
93
|
+
"compressedTexSubImage2D",
|
|
94
|
+
"compressedTexSubImage3D",
|
|
95
|
+
"copyBufferSubData",
|
|
96
|
+
"copyTexImage2D",
|
|
97
|
+
"copyTexSubImage2D",
|
|
98
|
+
"copyTexSubImage3D",
|
|
99
|
+
"createBuffer",
|
|
100
|
+
"createFramebuffer",
|
|
101
|
+
"createProgram",
|
|
102
|
+
"createQuery",
|
|
103
|
+
"createRenderbuffer",
|
|
104
|
+
"createSampler",
|
|
105
|
+
"createShader",
|
|
106
|
+
"createTexture",
|
|
107
|
+
"createTransformFeedback",
|
|
108
|
+
"createVertexArray",
|
|
109
|
+
"cullFace",
|
|
110
|
+
"deleteBuffer",
|
|
111
|
+
"deleteFramebuffer",
|
|
112
|
+
"deleteProgram",
|
|
113
|
+
"deleteQuery",
|
|
114
|
+
"deleteRenderbuffer",
|
|
115
|
+
"deleteSampler",
|
|
116
|
+
"deleteShader",
|
|
117
|
+
"deleteSync",
|
|
118
|
+
"deleteTexture",
|
|
119
|
+
"deleteTransformFeedback",
|
|
120
|
+
"deleteVertexArray",
|
|
121
|
+
"depthFunc",
|
|
122
|
+
"depthMask",
|
|
123
|
+
"depthRange",
|
|
124
|
+
"detachShader",
|
|
125
|
+
"disable",
|
|
126
|
+
"drawArraysInstanced",
|
|
127
|
+
"drawElementsInstanced",
|
|
128
|
+
"drawRangeElements",
|
|
129
|
+
"enable",
|
|
130
|
+
"endQuery",
|
|
131
|
+
"endTransformFeedback",
|
|
132
|
+
"fenceSync",
|
|
133
|
+
"finish",
|
|
134
|
+
"flush",
|
|
135
|
+
"framebufferRenderbuffer",
|
|
136
|
+
"framebufferTexture2D",
|
|
137
|
+
"framebufferTextureLayer",
|
|
138
|
+
"frontFace",
|
|
139
|
+
"generateMipmap",
|
|
140
|
+
"getActiveAttrib",
|
|
141
|
+
"getActiveUniform",
|
|
142
|
+
"getActiveUniformBlockName",
|
|
143
|
+
"getActiveUniformBlockParameter",
|
|
144
|
+
"getActiveUniforms",
|
|
145
|
+
"getAttachedShaders",
|
|
146
|
+
"getAttribLocation",
|
|
147
|
+
"getBufferParameter",
|
|
148
|
+
"getBufferSubData",
|
|
149
|
+
"getContextAttributes",
|
|
150
|
+
"getError",
|
|
151
|
+
"getExtension",
|
|
152
|
+
"getFragDataLocation",
|
|
153
|
+
"getFramebufferAttachmentParameter",
|
|
154
|
+
"getIndexedParameter",
|
|
155
|
+
"getInternalformatParameter",
|
|
156
|
+
"getParameter",
|
|
157
|
+
"getProgramInfoLog",
|
|
158
|
+
"getProgramParameter",
|
|
159
|
+
"getQuery",
|
|
160
|
+
"getQueryParameter",
|
|
161
|
+
"getRenderbufferParameter",
|
|
162
|
+
"getSamplerParameter",
|
|
163
|
+
"getShaderInfoLog",
|
|
164
|
+
"getShaderParameter",
|
|
165
|
+
"getShaderPrecisionFormat",
|
|
166
|
+
"getShaderSource",
|
|
167
|
+
"getSupportedExtensions",
|
|
168
|
+
"getSyncParameter",
|
|
169
|
+
"getTexParameter",
|
|
170
|
+
"getTransformFeedbackVarying",
|
|
171
|
+
"getUniform",
|
|
172
|
+
"getUniformBlockIndex",
|
|
173
|
+
"getUniformIndices",
|
|
174
|
+
"getUniformLocation",
|
|
175
|
+
"getVertexAttrib",
|
|
176
|
+
"getVertexAttribOffset",
|
|
177
|
+
"hint",
|
|
178
|
+
"invalidateFramebuffer",
|
|
179
|
+
"invalidateSubFramebuffer",
|
|
180
|
+
"isBuffer",
|
|
181
|
+
"isContextLost",
|
|
182
|
+
"isEnabled",
|
|
183
|
+
"isFramebuffer",
|
|
184
|
+
"isProgram",
|
|
185
|
+
"isQuery",
|
|
186
|
+
"isRenderbuffer",
|
|
187
|
+
"isSampler",
|
|
188
|
+
"isShader",
|
|
189
|
+
"isSync",
|
|
190
|
+
"isTexture",
|
|
191
|
+
"isTransformFeedback",
|
|
192
|
+
"isVertexArray",
|
|
193
|
+
"lineWidth",
|
|
194
|
+
"linkProgram",
|
|
195
|
+
"pauseTransformFeedback",
|
|
196
|
+
"pixelStorei",
|
|
197
|
+
"polygonOffset",
|
|
198
|
+
"readBuffer",
|
|
199
|
+
"readPixels",
|
|
200
|
+
"renderbufferStorage",
|
|
201
|
+
"renderbufferStorageMultisample",
|
|
202
|
+
"resumeTransformFeedback",
|
|
203
|
+
"sampleCoverage",
|
|
204
|
+
"samplerParameterf",
|
|
205
|
+
"samplerParameteri",
|
|
206
|
+
"shaderSource",
|
|
207
|
+
"stencilFunc",
|
|
208
|
+
"stencilFuncSeparate",
|
|
209
|
+
"stencilMask",
|
|
210
|
+
"stencilMaskSeparate",
|
|
211
|
+
"stencilOp",
|
|
212
|
+
"stencilOpSeparate",
|
|
213
|
+
"texImage2D",
|
|
214
|
+
"texImage3D",
|
|
215
|
+
"texParameterf",
|
|
216
|
+
"texParameteri",
|
|
217
|
+
"texStorage2D",
|
|
218
|
+
"texStorage3D",
|
|
219
|
+
"texSubImage2D",
|
|
220
|
+
"texSubImage3D",
|
|
221
|
+
"transformFeedbackVaryings",
|
|
222
|
+
"uniform1ui",
|
|
223
|
+
"uniform2ui",
|
|
224
|
+
"uniform3ui",
|
|
225
|
+
"uniform4ui",
|
|
226
|
+
"uniformBlockBinding",
|
|
227
|
+
"useProgram",
|
|
228
|
+
"validateProgram",
|
|
229
|
+
"vertexAttribDivisor",
|
|
230
|
+
"vertexAttribI4i",
|
|
231
|
+
"vertexAttribI4ui",
|
|
232
|
+
"vertexAttribIPointer",
|
|
233
|
+
"waitSync",
|
|
234
|
+
"bindBuffer",
|
|
235
|
+
"bindFramebuffer",
|
|
236
|
+
"bindTexture",
|
|
237
|
+
"clear",
|
|
238
|
+
"clearBufferfi",
|
|
239
|
+
"clearBufferfv",
|
|
240
|
+
"clearBufferiv",
|
|
241
|
+
"clearBufferuiv",
|
|
242
|
+
"clearColor",
|
|
243
|
+
"clearDepth",
|
|
244
|
+
"clearStencil",
|
|
245
|
+
"colorMask",
|
|
246
|
+
"disableVertexAttribArray",
|
|
247
|
+
"drawArrays",
|
|
248
|
+
"drawBuffers",
|
|
249
|
+
"drawElements",
|
|
250
|
+
"enableVertexAttribArray",
|
|
251
|
+
"scissor",
|
|
252
|
+
"uniform1f",
|
|
253
|
+
"uniform1fv",
|
|
254
|
+
"uniform1i",
|
|
255
|
+
"uniform1iv",
|
|
256
|
+
"uniform1uiv",
|
|
257
|
+
"uniform2f",
|
|
258
|
+
"uniform2fv",
|
|
259
|
+
"uniform2i",
|
|
260
|
+
"uniform2iv",
|
|
261
|
+
"uniform2uiv",
|
|
262
|
+
"uniform3f",
|
|
263
|
+
"uniform3fv",
|
|
264
|
+
"uniform3i",
|
|
265
|
+
"uniform3iv",
|
|
266
|
+
"uniform3uiv",
|
|
267
|
+
"uniform4f",
|
|
268
|
+
"uniform4fv",
|
|
269
|
+
"uniform4i",
|
|
270
|
+
"uniform4iv",
|
|
271
|
+
"uniform4uiv",
|
|
272
|
+
"uniformMatrix2fv",
|
|
273
|
+
"uniformMatrix2x3fv",
|
|
274
|
+
"uniformMatrix2x4fv",
|
|
275
|
+
"uniformMatrix3fv",
|
|
276
|
+
"uniformMatrix3x2fv",
|
|
277
|
+
"uniformMatrix3x4fv",
|
|
278
|
+
"uniformMatrix4fv",
|
|
279
|
+
"uniformMatrix4x2fv",
|
|
280
|
+
"uniformMatrix4x3fv",
|
|
281
|
+
"vertexAttrib1f",
|
|
282
|
+
"vertexAttrib1fv",
|
|
283
|
+
"vertexAttrib2f",
|
|
284
|
+
"vertexAttrib2fv",
|
|
285
|
+
"vertexAttrib3f",
|
|
286
|
+
"vertexAttrib3fv",
|
|
287
|
+
"vertexAttrib4f",
|
|
288
|
+
"vertexAttrib4fv",
|
|
289
|
+
"vertexAttribI4iv",
|
|
290
|
+
"vertexAttribI4uiv",
|
|
291
|
+
"vertexAttribPointer",
|
|
292
|
+
"viewport",
|
|
293
|
+
"makeXRCompatible"
|
|
294
|
+
];
|
|
67
295
|
const enums = {
|
|
68
296
|
DEPTH_BUFFER_BIT: 256,
|
|
69
297
|
STENCIL_BUFFER_BIT: 1024,
|
|
@@ -270,7 +498,7 @@ const enums = {
|
|
|
270
498
|
TEXTURE13: 33997,
|
|
271
499
|
TEXTURE14: 33998,
|
|
272
500
|
TEXTURE15: 33999,
|
|
273
|
-
TEXTURE16:
|
|
501
|
+
TEXTURE16: 34e3,
|
|
274
502
|
TEXTURE17: 34001,
|
|
275
503
|
TEXTURE18: 34002,
|
|
276
504
|
TEXTURE19: 34003,
|
|
@@ -376,7 +604,7 @@ const enums = {
|
|
|
376
604
|
UNPACK_SKIP_IMAGES: 32877,
|
|
377
605
|
UNPACK_IMAGE_HEIGHT: 32878,
|
|
378
606
|
TEXTURE_WRAP_R: 32882,
|
|
379
|
-
MAX_ELEMENTS_VERTICES:
|
|
607
|
+
MAX_ELEMENTS_VERTICES: 33e3,
|
|
380
608
|
MAX_ELEMENTS_INDICES: 33001,
|
|
381
609
|
TEXTURE_MIN_LOD: 33082,
|
|
382
610
|
TEXTURE_MAX_LOD: 33083,
|
|
@@ -520,13 +748,17 @@ const extensions = {
|
|
|
520
748
|
OES_texture_float: {},
|
|
521
749
|
OES_texture_half_float: {},
|
|
522
750
|
WEBGL_lose_context: {
|
|
523
|
-
loseContext: () => {
|
|
751
|
+
loseContext: () => {
|
|
752
|
+
}
|
|
524
753
|
},
|
|
525
754
|
OES_standard_derivatives: {},
|
|
526
755
|
OES_vertex_array_object: {
|
|
527
|
-
createVertexArrayOES: () => {
|
|
528
|
-
|
|
529
|
-
|
|
756
|
+
createVertexArrayOES: () => {
|
|
757
|
+
},
|
|
758
|
+
bindVertexArrayOES: () => {
|
|
759
|
+
},
|
|
760
|
+
deleteVertexArrayOES: () => {
|
|
761
|
+
}
|
|
530
762
|
},
|
|
531
763
|
WEBGL_debug_renderer_info: null,
|
|
532
764
|
WEBGL_debug_shaders: null,
|
|
@@ -539,10 +771,7 @@ const extensions = {
|
|
|
539
771
|
ANGLE_instanced_arrays: null,
|
|
540
772
|
OES_texture_float_linear: null,
|
|
541
773
|
OES_texture_half_float_linear: null,
|
|
542
|
-
EXT_blend_minmax: {
|
|
543
|
-
MIN_EXT: 0,
|
|
544
|
-
MAX_EXT: 0
|
|
545
|
-
},
|
|
774
|
+
EXT_blend_minmax: { MIN_EXT: 0, MAX_EXT: 0 },
|
|
546
775
|
EXT_shader_texture_lod: null,
|
|
547
776
|
// community
|
|
548
777
|
WEBGL_compressed_texture_atc: null,
|
|
@@ -552,33 +781,34 @@ const extensions = {
|
|
|
552
781
|
EXT_sRGB: null,
|
|
553
782
|
WEBGL_compressed_texture_etc1: null
|
|
554
783
|
};
|
|
784
|
+
const returnsHandle = (method) => method.startsWith("create") || method === "fenceSync";
|
|
555
785
|
class WebGL2RenderingContext {
|
|
556
786
|
constructor(canvas) {
|
|
557
|
-
this
|
|
787
|
+
__publicField$2(this, "getShaderPrecisionFormat", () => {
|
|
558
788
|
return {
|
|
559
789
|
rangeMin: 127,
|
|
560
790
|
rangeMax: 127,
|
|
561
791
|
precision: 23
|
|
562
792
|
};
|
|
563
|
-
};
|
|
564
|
-
this
|
|
565
|
-
this
|
|
566
|
-
this
|
|
567
|
-
this
|
|
568
|
-
this
|
|
793
|
+
});
|
|
794
|
+
__publicField$2(this, "GL_VERSION", 7938);
|
|
795
|
+
__publicField$2(this, "SCISSOR_BOX", 3088);
|
|
796
|
+
__publicField$2(this, "VIEWPORT", 2978);
|
|
797
|
+
__publicField$2(this, "getProgramInfoLog", () => "");
|
|
798
|
+
__publicField$2(this, "getShaderInfoLog", () => "");
|
|
569
799
|
this.canvas = canvas;
|
|
570
800
|
this.drawingBufferWidth = canvas.width;
|
|
571
801
|
this.drawingBufferHeight = canvas.height;
|
|
572
802
|
for (const method of functions) {
|
|
573
|
-
|
|
574
|
-
|
|
803
|
+
this[method] ?? (this[method] = returnsHandle(method) ? () => ({}) : () => {
|
|
804
|
+
});
|
|
575
805
|
}
|
|
576
806
|
Object.assign(this, enums);
|
|
577
807
|
}
|
|
578
808
|
getParameter(paramId) {
|
|
579
809
|
switch (paramId) {
|
|
580
810
|
case this.GL_VERSION:
|
|
581
|
-
return [
|
|
811
|
+
return ["WebGL2"];
|
|
582
812
|
case this.SCISSOR_BOX:
|
|
583
813
|
case this.VIEWPORT:
|
|
584
814
|
return [0, 0, 1, 1];
|
|
@@ -589,60 +819,183 @@ class WebGL2RenderingContext {
|
|
|
589
819
|
}
|
|
590
820
|
}
|
|
591
821
|
|
|
822
|
+
var __defProp$1 = Object.defineProperty;
|
|
823
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
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
|
+
});
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function setupWebGLMocking() {
|
|
879
|
+
if (globalThis.HTMLCanvasElement) {
|
|
880
|
+
const originalGetContext = HTMLCanvasElement.prototype.getContext;
|
|
881
|
+
HTMLCanvasElement.prototype.getContext = function(id, options) {
|
|
882
|
+
if (id.startsWith("webgl")) {
|
|
883
|
+
return new WebGL2RenderingContext(this);
|
|
884
|
+
}
|
|
885
|
+
return originalGetContext.call(this, id, options);
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
class WebGLRenderingContext extends WebGL2RenderingContext {
|
|
889
|
+
}
|
|
890
|
+
globalThis.WebGLRenderingContext ?? (globalThis.WebGLRenderingContext = WebGLRenderingContext);
|
|
891
|
+
globalThis.WebGL2RenderingContext ?? (globalThis.WebGL2RenderingContext = WebGL2RenderingContext);
|
|
892
|
+
}
|
|
893
|
+
function setupWebGPUMocking() {
|
|
894
|
+
if (globalThis.HTMLCanvasElement) {
|
|
895
|
+
const originalGetContext = HTMLCanvasElement.prototype.getContext;
|
|
896
|
+
HTMLCanvasElement.prototype.getContext = function(id, options) {
|
|
897
|
+
if (id === "webgpu") {
|
|
898
|
+
return new MockGPUCanvasContext(this);
|
|
899
|
+
}
|
|
900
|
+
if (id.startsWith("webgl")) {
|
|
901
|
+
return new WebGL2RenderingContext(this);
|
|
902
|
+
}
|
|
903
|
+
return originalGetContext.call(this, id, options);
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
class WebGLRenderingContext extends WebGL2RenderingContext {
|
|
907
|
+
}
|
|
908
|
+
globalThis.WebGLRenderingContext ?? (globalThis.WebGLRenderingContext = WebGLRenderingContext);
|
|
909
|
+
globalThis.WebGL2RenderingContext ?? (globalThis.WebGL2RenderingContext = WebGL2RenderingContext);
|
|
910
|
+
}
|
|
592
911
|
const createCanvas = ({
|
|
593
912
|
beforeReturn,
|
|
594
913
|
width = 1280,
|
|
595
|
-
height = 800
|
|
914
|
+
height = 800,
|
|
915
|
+
mode = "webgl"
|
|
596
916
|
} = {}) => {
|
|
597
|
-
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
598
917
|
let canvas;
|
|
599
|
-
if (typeof document !==
|
|
600
|
-
canvas = document.createElement(
|
|
918
|
+
if (typeof document !== "undefined" && typeof document.createElement === "function") {
|
|
919
|
+
canvas = document.createElement("canvas");
|
|
601
920
|
} else {
|
|
602
|
-
canvas =
|
|
603
|
-
style: {},
|
|
604
|
-
addEventListener: () => {},
|
|
605
|
-
removeEventListener: () => {},
|
|
606
|
-
clientWidth: width,
|
|
607
|
-
clientHeight: height,
|
|
608
|
-
getContext: () => new WebGL2RenderingContext(canvas)
|
|
609
|
-
};
|
|
921
|
+
canvas = createMockCanvas(width, height, mode);
|
|
610
922
|
}
|
|
611
923
|
canvas.width = width;
|
|
612
924
|
canvas.height = height;
|
|
613
|
-
if (
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return getContext.apply(this, arguments);
|
|
618
|
-
};
|
|
925
|
+
if (mode === "webgpu") {
|
|
926
|
+
setupWebGPUMocking();
|
|
927
|
+
} else {
|
|
928
|
+
setupWebGLMocking();
|
|
619
929
|
}
|
|
620
|
-
beforeReturn
|
|
621
|
-
class WebGLRenderingContext extends WebGL2RenderingContext {}
|
|
622
|
-
// @ts-expect-error
|
|
623
|
-
(_globalThis$WebGLRend = globalThis.WebGLRenderingContext) != null ? _globalThis$WebGLRend : globalThis.WebGLRenderingContext = WebGLRenderingContext;
|
|
624
|
-
// @ts-expect-error
|
|
625
|
-
(_globalThis$WebGL2Ren = globalThis.WebGL2RenderingContext) != null ? _globalThis$WebGL2Ren : globalThis.WebGL2RenderingContext = WebGL2RenderingContext;
|
|
930
|
+
beforeReturn?.(canvas);
|
|
626
931
|
return canvas;
|
|
627
932
|
};
|
|
933
|
+
function createMockCanvas(width, height, mode) {
|
|
934
|
+
const canvas = {
|
|
935
|
+
style: {},
|
|
936
|
+
width,
|
|
937
|
+
height,
|
|
938
|
+
clientWidth: width,
|
|
939
|
+
clientHeight: height,
|
|
940
|
+
addEventListener: (() => {
|
|
941
|
+
}),
|
|
942
|
+
removeEventListener: (() => {
|
|
943
|
+
}),
|
|
944
|
+
getContext: ((id) => {
|
|
945
|
+
if (mode === "webgpu" && id === "webgpu") {
|
|
946
|
+
return new MockGPUCanvasContext(canvas);
|
|
947
|
+
}
|
|
948
|
+
if (id.startsWith("webgl")) {
|
|
949
|
+
return new WebGL2RenderingContext(canvas);
|
|
950
|
+
}
|
|
951
|
+
return null;
|
|
952
|
+
}),
|
|
953
|
+
// Additional properties that Three.js might check
|
|
954
|
+
getBoundingClientRect: () => ({
|
|
955
|
+
left: 0,
|
|
956
|
+
top: 0,
|
|
957
|
+
right: width,
|
|
958
|
+
bottom: height,
|
|
959
|
+
width,
|
|
960
|
+
height,
|
|
961
|
+
x: 0,
|
|
962
|
+
y: 0,
|
|
963
|
+
toJSON: () => {
|
|
964
|
+
}
|
|
965
|
+
}),
|
|
966
|
+
// For WebGPU texture creation
|
|
967
|
+
transferControlToOffscreen: () => ({
|
|
968
|
+
width,
|
|
969
|
+
height,
|
|
970
|
+
getContext: (id) => {
|
|
971
|
+
if (id === "webgpu") return new MockGPUCanvasContext(canvas);
|
|
972
|
+
return null;
|
|
973
|
+
}
|
|
974
|
+
})
|
|
975
|
+
};
|
|
976
|
+
return canvas;
|
|
977
|
+
}
|
|
628
978
|
|
|
629
979
|
const createEventFirer = (act, store) => {
|
|
630
980
|
const findEventHandler = (element, eventName) => {
|
|
631
981
|
const eventHandlerName = toEventHandlerName(eventName);
|
|
632
982
|
const props = element.props;
|
|
633
|
-
if (typeof props[eventHandlerName] ===
|
|
983
|
+
if (typeof props[eventHandlerName] === "function") {
|
|
634
984
|
return props[eventHandlerName];
|
|
635
985
|
}
|
|
636
|
-
if (typeof props[eventName] ===
|
|
986
|
+
if (typeof props[eventName] === "function") {
|
|
637
987
|
return props[eventName];
|
|
638
988
|
}
|
|
639
|
-
console.warn(
|
|
989
|
+
console.warn(
|
|
990
|
+
`Handler for ${eventName} was not found. You must pass event names in camelCase or name of the handler https://github.com/pmndrs/react-three-fiber/blob/master/packages/test-renderer/markdown/rttr.md#create-fireevent`
|
|
991
|
+
);
|
|
640
992
|
return null;
|
|
641
993
|
};
|
|
642
994
|
const createSyntheticEvent = (element, data) => {
|
|
643
995
|
const raycastEvent = {
|
|
644
996
|
camera: store.getState().camera,
|
|
645
|
-
stopPropagation: () => {
|
|
997
|
+
stopPropagation: () => {
|
|
998
|
+
},
|
|
646
999
|
target: element,
|
|
647
1000
|
currentTarget: element,
|
|
648
1001
|
sourceEvent: data,
|
|
@@ -669,82 +1022,60 @@ const expectOne = (items, msg) => {
|
|
|
669
1022
|
if (items.length === 1) {
|
|
670
1023
|
return items[0];
|
|
671
1024
|
}
|
|
672
|
-
const prefix = items.length === 0 ?
|
|
1025
|
+
const prefix = items.length === 0 ? "RTTR: No instances found" : `RTTR: Expected 1 but found ${items.length} instances`;
|
|
673
1026
|
throw new Error(`${prefix} ${msg}`);
|
|
674
1027
|
};
|
|
675
1028
|
const matchProps = (props, filter) => {
|
|
676
1029
|
for (const key in filter) {
|
|
677
|
-
// Check for matches if filter contains regex matchers
|
|
678
1030
|
const isRegex = filter[key] instanceof RegExp;
|
|
679
|
-
const shouldMatch = isRegex && typeof props[key] ===
|
|
1031
|
+
const shouldMatch = isRegex && typeof props[key] === "string";
|
|
680
1032
|
const match = shouldMatch && filter[key].test(props[key]);
|
|
681
|
-
|
|
682
|
-
// Bail if props aren't identical and filters found no match
|
|
683
1033
|
if (props[key] !== filter[key] && !match) {
|
|
684
1034
|
return false;
|
|
685
1035
|
}
|
|
686
1036
|
}
|
|
687
1037
|
return true;
|
|
688
1038
|
};
|
|
689
|
-
const findAll = (root, decider, options = {
|
|
690
|
-
includeRoot: true
|
|
691
|
-
}) => {
|
|
1039
|
+
const findAll = (root, decider, options = { includeRoot: true }) => {
|
|
692
1040
|
const results = [];
|
|
693
|
-
|
|
694
|
-
// Only include the root node if the option is enabled
|
|
695
1041
|
if (options.includeRoot !== false && decider(root)) {
|
|
696
1042
|
results.push(root);
|
|
697
1043
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
root.allChildren.forEach(child => {
|
|
701
|
-
// When recursively searching children, we always want to include their roots
|
|
702
|
-
results.push(...findAll(child, decider, {
|
|
703
|
-
includeRoot: true
|
|
704
|
-
}));
|
|
1044
|
+
root.allChildren.forEach((child) => {
|
|
1045
|
+
results.push(...findAll(child, decider, { includeRoot: true }));
|
|
705
1046
|
});
|
|
706
1047
|
return results;
|
|
707
1048
|
};
|
|
708
1049
|
|
|
709
|
-
|
|
1050
|
+
var __defProp = Object.defineProperty;
|
|
1051
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1052
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
710
1053
|
const createVirtualInstance = (object, parent) => {
|
|
711
|
-
// Create the virtual instance for this object
|
|
712
|
-
// we can't import the prepare method from packages/fiber/src/core/utils.tsx so we do what we can
|
|
713
1054
|
const instance = {
|
|
714
1055
|
root: parent.root,
|
|
715
1056
|
type: object.type.toLowerCase(),
|
|
716
1057
|
// Convert to lowercase to match R3F convention
|
|
717
1058
|
parent,
|
|
718
1059
|
children: [],
|
|
719
|
-
props: {
|
|
720
|
-
object
|
|
721
|
-
},
|
|
1060
|
+
props: { object },
|
|
722
1061
|
object,
|
|
723
1062
|
eventCount: 0,
|
|
724
1063
|
handlers: {},
|
|
725
1064
|
isHidden: false
|
|
726
1065
|
};
|
|
727
|
-
|
|
728
|
-
// Recursively process children if they exist
|
|
729
1066
|
if (object.children && object.children.length > 0) {
|
|
730
1067
|
const objectChildren = object.children;
|
|
731
|
-
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
1068
|
+
instance.children = Array.from(objectChildren).map((child) => createVirtualInstance(child, instance));
|
|
732
1069
|
}
|
|
733
1070
|
return instance;
|
|
734
1071
|
};
|
|
735
1072
|
class ReactThreeTestInstance {
|
|
736
|
-
constructor(
|
|
737
|
-
this
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
const r3fChildren = fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
|
|
743
|
-
|
|
744
|
-
// For primitives, also add THREE.js object children
|
|
745
|
-
if (fiber.type === 'primitive' && (_fiber$object$childre = fiber.object.children) != null && _fiber$object$childre.length) {
|
|
746
|
-
const threeChildren = fiber.object.children.map(child => {
|
|
747
|
-
// Create a virtual instance that wraps the THREE.js child
|
|
1073
|
+
constructor(fiber) {
|
|
1074
|
+
__publicField(this, "_fiber");
|
|
1075
|
+
__publicField(this, "getChildren", (fiber, opts = { exhaustive: false }) => {
|
|
1076
|
+
const r3fChildren = fiber.children.filter((child) => !child.props.attach || opts.exhaustive).map((fib) => wrapFiber(fib));
|
|
1077
|
+
if (fiber.type === "primitive" && fiber.object.children?.length) {
|
|
1078
|
+
const threeChildren = fiber.object.children.map((child) => {
|
|
748
1079
|
const virtualInstance = createVirtualInstance(child, fiber);
|
|
749
1080
|
return wrapFiber(virtualInstance);
|
|
750
1081
|
});
|
|
@@ -752,16 +1083,17 @@ class ReactThreeTestInstance {
|
|
|
752
1083
|
return r3fChildren;
|
|
753
1084
|
}
|
|
754
1085
|
return r3fChildren;
|
|
755
|
-
};
|
|
756
|
-
this.findAll = decider => findAll(this, decider, {
|
|
757
|
-
includeRoot: false
|
|
758
1086
|
});
|
|
759
|
-
this
|
|
760
|
-
this
|
|
761
|
-
this
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1087
|
+
__publicField(this, "findAll", (decider) => findAll(this, decider, { includeRoot: false }));
|
|
1088
|
+
__publicField(this, "find", (decider) => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`));
|
|
1089
|
+
__publicField(this, "findByType", (type) => expectOne(
|
|
1090
|
+
this.findAll((node) => Boolean(node.type && node.type === type)),
|
|
1091
|
+
`with node type: "${type || "Unknown"}"`
|
|
1092
|
+
));
|
|
1093
|
+
__publicField(this, "findAllByType", (type) => this.findAll((node) => Boolean(node.type && node.type === type)));
|
|
1094
|
+
__publicField(this, "findByProps", (props) => expectOne(this.findAllByProps(props), `with props: ${JSON.stringify(props)}`));
|
|
1095
|
+
__publicField(this, "findAllByProps", (props) => this.findAll((node) => Boolean(node.props && matchProps(node.props, props))));
|
|
1096
|
+
this._fiber = fiber;
|
|
765
1097
|
}
|
|
766
1098
|
get fiber() {
|
|
767
1099
|
return this._fiber;
|
|
@@ -786,126 +1118,136 @@ class ReactThreeTestInstance {
|
|
|
786
1118
|
return this.getChildren(this._fiber);
|
|
787
1119
|
}
|
|
788
1120
|
get allChildren() {
|
|
789
|
-
return this.getChildren(this._fiber, {
|
|
790
|
-
exhaustive: true
|
|
791
|
-
});
|
|
1121
|
+
return this.getChildren(this._fiber, { exhaustive: true });
|
|
792
1122
|
}
|
|
793
1123
|
}
|
|
794
|
-
const fiberToWrapper = new WeakMap();
|
|
795
|
-
const wrapFiber = fiber => {
|
|
1124
|
+
const fiberToWrapper = /* @__PURE__ */ new WeakMap();
|
|
1125
|
+
const wrapFiber = (fiber) => {
|
|
796
1126
|
let wrapper = fiberToWrapper.get(fiber);
|
|
797
|
-
if (wrapper ===
|
|
1127
|
+
if (wrapper === void 0) {
|
|
798
1128
|
wrapper = new ReactThreeTestInstance(fiber);
|
|
799
1129
|
fiberToWrapper.set(fiber, wrapper);
|
|
800
1130
|
}
|
|
801
1131
|
return wrapper;
|
|
802
1132
|
};
|
|
803
1133
|
|
|
804
|
-
async function waitFor(callback, {
|
|
805
|
-
|
|
806
|
-
timeout = 5000
|
|
807
|
-
} = {}) {
|
|
808
|
-
await fiber.act(async () => {
|
|
1134
|
+
async function waitFor(callback, { interval = 50, timeout = 5e3 } = {}) {
|
|
1135
|
+
await react.act(async () => {
|
|
809
1136
|
const start = performance.now();
|
|
810
1137
|
while (true) {
|
|
811
1138
|
const result = callback();
|
|
812
1139
|
if (result || result == null) break;
|
|
813
|
-
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
1140
|
+
if (interval) await new Promise((resolve) => setTimeout(resolve, interval));
|
|
814
1141
|
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
815
1142
|
}
|
|
816
1143
|
});
|
|
817
1144
|
}
|
|
818
1145
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
async advanceFrames(frames, delta = 1) {
|
|
882
|
-
const state = _store.getState();
|
|
883
|
-
const storeSubscribers = state.internal.subscribers;
|
|
884
|
-
const promises = [];
|
|
885
|
-
storeSubscribers.forEach(subscriber => {
|
|
886
|
-
for (let i = 0; i < frames; i++) {
|
|
887
|
-
if (Array.isArray(delta)) {
|
|
888
|
-
promises.push(new Promise(() => subscriber.ref.current(state, delta[i] || delta[-1])));
|
|
889
|
-
} else {
|
|
890
|
-
promises.push(new Promise(() => subscriber.ref.current(state, delta)));
|
|
1146
|
+
function createTestRenderer(deps) {
|
|
1147
|
+
const { THREE: THREE2, createRoot, mockRoots, reconciler, act, extend, mode } = deps;
|
|
1148
|
+
extend(THREE2);
|
|
1149
|
+
const create = async (element, options) => {
|
|
1150
|
+
const canvas = createCanvas({ ...options, mode });
|
|
1151
|
+
const _root = createRoot(canvas);
|
|
1152
|
+
await _root.configure({
|
|
1153
|
+
frameloop: "never",
|
|
1154
|
+
// TODO: remove and use default behavior
|
|
1155
|
+
size: {
|
|
1156
|
+
width: options?.width ?? 1280,
|
|
1157
|
+
height: options?.height ?? 800,
|
|
1158
|
+
top: 0,
|
|
1159
|
+
left: 0
|
|
1160
|
+
},
|
|
1161
|
+
...options,
|
|
1162
|
+
events: void 0
|
|
1163
|
+
});
|
|
1164
|
+
const _store = mockRoots.get(canvas).store;
|
|
1165
|
+
await act(async () => _root.render(element));
|
|
1166
|
+
const _scene = _store.getState().scene.__r3f;
|
|
1167
|
+
return {
|
|
1168
|
+
scene: wrapFiber(_scene),
|
|
1169
|
+
async unmount() {
|
|
1170
|
+
await act(async () => {
|
|
1171
|
+
_root.unmount();
|
|
1172
|
+
});
|
|
1173
|
+
},
|
|
1174
|
+
getInstance() {
|
|
1175
|
+
if (!mockRoots.has(canvas)) return null;
|
|
1176
|
+
const root = { current: mockRoots.get(canvas).fiber.current };
|
|
1177
|
+
while (root.current.child && !root.current.child.stateNode) root.current = root.current.child;
|
|
1178
|
+
if (!root.current.child) return null;
|
|
1179
|
+
return reconciler.getPublicRootInstance(root);
|
|
1180
|
+
},
|
|
1181
|
+
async update(newElement) {
|
|
1182
|
+
if (!mockRoots.has(canvas)) return console.warn("RTTR: attempted to update an unmounted root!");
|
|
1183
|
+
await act(async () => {
|
|
1184
|
+
_root.render(newElement);
|
|
1185
|
+
});
|
|
1186
|
+
},
|
|
1187
|
+
toTree() {
|
|
1188
|
+
return toTree(_scene);
|
|
1189
|
+
},
|
|
1190
|
+
toGraph() {
|
|
1191
|
+
return toGraph(_scene);
|
|
1192
|
+
},
|
|
1193
|
+
fireEvent: createEventFirer(act, _store),
|
|
1194
|
+
async advanceFrames(frames, delta = 1) {
|
|
1195
|
+
const state = _store.getState();
|
|
1196
|
+
const scheduler = state.internal.scheduler;
|
|
1197
|
+
if (scheduler) {
|
|
1198
|
+
if (scheduler.resetTiming) {
|
|
1199
|
+
scheduler.resetTiming();
|
|
1200
|
+
}
|
|
1201
|
+
let baseTime = 0;
|
|
1202
|
+
scheduler.step(baseTime);
|
|
1203
|
+
for (let i = 0; i < frames; i++) {
|
|
1204
|
+
const frameDeltaSeconds = Array.isArray(delta) ? delta[i] ?? delta[delta.length - 1] : delta;
|
|
1205
|
+
const frameDeltaMs = frameDeltaSeconds * 1e3;
|
|
1206
|
+
baseTime += frameDeltaMs;
|
|
1207
|
+
scheduler.step(baseTime);
|
|
891
1208
|
}
|
|
1209
|
+
return;
|
|
892
1210
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1211
|
+
const storeSubscribers = state.internal.subscribers;
|
|
1212
|
+
const promises = [];
|
|
1213
|
+
storeSubscribers.forEach((subscriber) => {
|
|
1214
|
+
for (let i = 0; i < frames; i++) {
|
|
1215
|
+
if (Array.isArray(delta)) {
|
|
1216
|
+
promises.push(
|
|
1217
|
+
new Promise(() => subscriber.ref.current(state, delta[i] || delta[-1]))
|
|
1218
|
+
);
|
|
1219
|
+
} else {
|
|
1220
|
+
promises.push(new Promise(() => subscriber.ref.current(state, delta)));
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
Promise.all(promises);
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
896
1227
|
};
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1228
|
+
return { create, act, waitFor };
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
const index$1 = {
|
|
1232
|
+
__proto__: null,
|
|
1233
|
+
ReactThreeTestInstance: ReactThreeTestInstance
|
|
902
1234
|
};
|
|
903
1235
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1236
|
+
const renderer = createTestRenderer({
|
|
1237
|
+
THREE: THREE__namespace,
|
|
1238
|
+
createRoot: fiber.createRoot,
|
|
1239
|
+
mockRoots: fiber._roots,
|
|
1240
|
+
reconciler: fiber.reconciler,
|
|
1241
|
+
act: react.act,
|
|
1242
|
+
extend: fiber.extend,
|
|
1243
|
+
mode: "webgl"
|
|
1244
|
+
// Default uses WebGL context
|
|
907
1245
|
});
|
|
1246
|
+
const { create } = renderer;
|
|
1247
|
+
const index = { create, act: react.act, waitFor };
|
|
1248
|
+
|
|
1249
|
+
exports.act = react.act;
|
|
908
1250
|
exports.ReactThreeTest = index$1;
|
|
909
1251
|
exports.create = create;
|
|
910
|
-
exports
|
|
1252
|
+
exports.default = index;
|
|
911
1253
|
exports.waitFor = waitFor;
|