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