@react-three/test-renderer 10.0.0-alpha.1 → 10.0.0-alpha.3
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 +29 -26
- package/CHANGELOG.md +0 -521
- 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,69 +1,280 @@
|
|
|
1
|
-
|
|
1
|
+
import { act } from 'react';
|
|
2
|
+
export { act } from 'react';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { extend, createRoot, _roots, reconciler } from '@react-three/fiber/legacy';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var THREE = require('three');
|
|
6
|
-
var fiber = require('@react-three/fiber');
|
|
7
|
-
|
|
8
|
-
function _interopNamespace(e) {
|
|
9
|
-
if (e && e.__esModule) return e;
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n["default"] = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
27
|
-
|
|
28
|
-
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
29
|
-
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)}`;
|
|
30
8
|
|
|
31
9
|
const treeObjectFactory = (type, props, children) => ({
|
|
32
10
|
type,
|
|
33
11
|
props,
|
|
34
12
|
children
|
|
35
13
|
});
|
|
36
|
-
const toTreeBranch = children => children.map(child => {
|
|
37
|
-
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
|
+
);
|
|
38
20
|
});
|
|
39
|
-
const toTree = root => toTreeBranch(root.children);
|
|
21
|
+
const toTree = (root) => toTreeBranch(root.children);
|
|
40
22
|
|
|
41
23
|
const graphObjectFactory = (type, name, children) => ({
|
|
42
24
|
type,
|
|
43
25
|
name,
|
|
44
26
|
children
|
|
45
27
|
});
|
|
46
|
-
|
|
47
|
-
// Helper function to process raw THREE.js children objects
|
|
48
28
|
function processThreeChildren(children) {
|
|
49
|
-
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
|
+
);
|
|
50
36
|
}
|
|
51
|
-
const toGraph = object => {
|
|
52
|
-
return object.children.map(child => {
|
|
53
|
-
var _child$object$childre, _child$object$name;
|
|
54
|
-
// Process standard R3F children
|
|
37
|
+
const toGraph = (object) => {
|
|
38
|
+
return object.children.map((child) => {
|
|
55
39
|
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) {
|
|
40
|
+
if (child.type === "primitive" && child.object.children?.length) {
|
|
59
41
|
const threeChildren = processThreeChildren(child.object.children);
|
|
60
42
|
children.push(...threeChildren);
|
|
61
43
|
}
|
|
62
|
-
return graphObjectFactory(child.object.type,
|
|
44
|
+
return graphObjectFactory(child.object.type, child.object.name ?? "", children);
|
|
63
45
|
});
|
|
64
46
|
};
|
|
65
47
|
|
|
66
|
-
|
|
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
|
+
];
|
|
67
278
|
const enums = {
|
|
68
279
|
DEPTH_BUFFER_BIT: 256,
|
|
69
280
|
STENCIL_BUFFER_BIT: 1024,
|
|
@@ -270,7 +481,7 @@ const enums = {
|
|
|
270
481
|
TEXTURE13: 33997,
|
|
271
482
|
TEXTURE14: 33998,
|
|
272
483
|
TEXTURE15: 33999,
|
|
273
|
-
TEXTURE16:
|
|
484
|
+
TEXTURE16: 34e3,
|
|
274
485
|
TEXTURE17: 34001,
|
|
275
486
|
TEXTURE18: 34002,
|
|
276
487
|
TEXTURE19: 34003,
|
|
@@ -376,7 +587,7 @@ const enums = {
|
|
|
376
587
|
UNPACK_SKIP_IMAGES: 32877,
|
|
377
588
|
UNPACK_IMAGE_HEIGHT: 32878,
|
|
378
589
|
TEXTURE_WRAP_R: 32882,
|
|
379
|
-
MAX_ELEMENTS_VERTICES:
|
|
590
|
+
MAX_ELEMENTS_VERTICES: 33e3,
|
|
380
591
|
MAX_ELEMENTS_INDICES: 33001,
|
|
381
592
|
TEXTURE_MIN_LOD: 33082,
|
|
382
593
|
TEXTURE_MAX_LOD: 33083,
|
|
@@ -520,13 +731,17 @@ const extensions = {
|
|
|
520
731
|
OES_texture_float: {},
|
|
521
732
|
OES_texture_half_float: {},
|
|
522
733
|
WEBGL_lose_context: {
|
|
523
|
-
loseContext: () => {
|
|
734
|
+
loseContext: () => {
|
|
735
|
+
}
|
|
524
736
|
},
|
|
525
737
|
OES_standard_derivatives: {},
|
|
526
738
|
OES_vertex_array_object: {
|
|
527
|
-
createVertexArrayOES: () => {
|
|
528
|
-
|
|
529
|
-
|
|
739
|
+
createVertexArrayOES: () => {
|
|
740
|
+
},
|
|
741
|
+
bindVertexArrayOES: () => {
|
|
742
|
+
},
|
|
743
|
+
deleteVertexArrayOES: () => {
|
|
744
|
+
}
|
|
530
745
|
},
|
|
531
746
|
WEBGL_debug_renderer_info: null,
|
|
532
747
|
WEBGL_debug_shaders: null,
|
|
@@ -539,10 +754,7 @@ const extensions = {
|
|
|
539
754
|
ANGLE_instanced_arrays: null,
|
|
540
755
|
OES_texture_float_linear: null,
|
|
541
756
|
OES_texture_half_float_linear: null,
|
|
542
|
-
EXT_blend_minmax: {
|
|
543
|
-
MIN_EXT: 0,
|
|
544
|
-
MAX_EXT: 0
|
|
545
|
-
},
|
|
757
|
+
EXT_blend_minmax: { MIN_EXT: 0, MAX_EXT: 0 },
|
|
546
758
|
EXT_shader_texture_lod: null,
|
|
547
759
|
// community
|
|
548
760
|
WEBGL_compressed_texture_atc: null,
|
|
@@ -552,33 +764,34 @@ const extensions = {
|
|
|
552
764
|
EXT_sRGB: null,
|
|
553
765
|
WEBGL_compressed_texture_etc1: null
|
|
554
766
|
};
|
|
767
|
+
const returnsHandle = (method) => method.startsWith("create") || method === "fenceSync";
|
|
555
768
|
class WebGL2RenderingContext {
|
|
556
769
|
constructor(canvas) {
|
|
557
|
-
this
|
|
770
|
+
__publicField$2(this, "getShaderPrecisionFormat", () => {
|
|
558
771
|
return {
|
|
559
772
|
rangeMin: 127,
|
|
560
773
|
rangeMax: 127,
|
|
561
774
|
precision: 23
|
|
562
775
|
};
|
|
563
|
-
};
|
|
564
|
-
this
|
|
565
|
-
this
|
|
566
|
-
this
|
|
567
|
-
this
|
|
568
|
-
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", () => "");
|
|
569
782
|
this.canvas = canvas;
|
|
570
783
|
this.drawingBufferWidth = canvas.width;
|
|
571
784
|
this.drawingBufferHeight = canvas.height;
|
|
572
785
|
for (const method of functions) {
|
|
573
|
-
|
|
574
|
-
|
|
786
|
+
this[method] ?? (this[method] = returnsHandle(method) ? () => ({}) : () => {
|
|
787
|
+
});
|
|
575
788
|
}
|
|
576
789
|
Object.assign(this, enums);
|
|
577
790
|
}
|
|
578
791
|
getParameter(paramId) {
|
|
579
792
|
switch (paramId) {
|
|
580
793
|
case this.GL_VERSION:
|
|
581
|
-
return [
|
|
794
|
+
return ["WebGL2"];
|
|
582
795
|
case this.SCISSOR_BOX:
|
|
583
796
|
case this.VIEWPORT:
|
|
584
797
|
return [0, 0, 1, 1];
|
|
@@ -589,60 +802,183 @@ class WebGL2RenderingContext {
|
|
|
589
802
|
}
|
|
590
803
|
}
|
|
591
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
|
+
}
|
|
592
894
|
const createCanvas = ({
|
|
593
895
|
beforeReturn,
|
|
594
896
|
width = 1280,
|
|
595
|
-
height = 800
|
|
897
|
+
height = 800,
|
|
898
|
+
mode = "webgl"
|
|
596
899
|
} = {}) => {
|
|
597
|
-
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
598
900
|
let canvas;
|
|
599
|
-
if (typeof document !==
|
|
600
|
-
canvas = document.createElement(
|
|
901
|
+
if (typeof document !== "undefined" && typeof document.createElement === "function") {
|
|
902
|
+
canvas = document.createElement("canvas");
|
|
601
903
|
} else {
|
|
602
|
-
canvas =
|
|
603
|
-
style: {},
|
|
604
|
-
addEventListener: () => {},
|
|
605
|
-
removeEventListener: () => {},
|
|
606
|
-
clientWidth: width,
|
|
607
|
-
clientHeight: height,
|
|
608
|
-
getContext: () => new WebGL2RenderingContext(canvas)
|
|
609
|
-
};
|
|
904
|
+
canvas = createMockCanvas(width, height, mode);
|
|
610
905
|
}
|
|
611
906
|
canvas.width = width;
|
|
612
907
|
canvas.height = height;
|
|
613
|
-
if (
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return getContext.apply(this, arguments);
|
|
618
|
-
};
|
|
908
|
+
if (mode === "webgpu") {
|
|
909
|
+
setupWebGPUMocking();
|
|
910
|
+
} else {
|
|
911
|
+
setupWebGLMocking();
|
|
619
912
|
}
|
|
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;
|
|
913
|
+
beforeReturn?.(canvas);
|
|
626
914
|
return canvas;
|
|
627
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
|
+
}
|
|
628
961
|
|
|
629
962
|
const createEventFirer = (act, store) => {
|
|
630
963
|
const findEventHandler = (element, eventName) => {
|
|
631
964
|
const eventHandlerName = toEventHandlerName(eventName);
|
|
632
965
|
const props = element.props;
|
|
633
|
-
if (typeof props[eventHandlerName] ===
|
|
966
|
+
if (typeof props[eventHandlerName] === "function") {
|
|
634
967
|
return props[eventHandlerName];
|
|
635
968
|
}
|
|
636
|
-
if (typeof props[eventName] ===
|
|
969
|
+
if (typeof props[eventName] === "function") {
|
|
637
970
|
return props[eventName];
|
|
638
971
|
}
|
|
639
|
-
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
|
+
);
|
|
640
975
|
return null;
|
|
641
976
|
};
|
|
642
977
|
const createSyntheticEvent = (element, data) => {
|
|
643
978
|
const raycastEvent = {
|
|
644
979
|
camera: store.getState().camera,
|
|
645
|
-
stopPropagation: () => {
|
|
980
|
+
stopPropagation: () => {
|
|
981
|
+
},
|
|
646
982
|
target: element,
|
|
647
983
|
currentTarget: element,
|
|
648
984
|
sourceEvent: data,
|
|
@@ -669,82 +1005,60 @@ const expectOne = (items, msg) => {
|
|
|
669
1005
|
if (items.length === 1) {
|
|
670
1006
|
return items[0];
|
|
671
1007
|
}
|
|
672
|
-
const prefix = items.length === 0 ?
|
|
1008
|
+
const prefix = items.length === 0 ? "RTTR: No instances found" : `RTTR: Expected 1 but found ${items.length} instances`;
|
|
673
1009
|
throw new Error(`${prefix} ${msg}`);
|
|
674
1010
|
};
|
|
675
1011
|
const matchProps = (props, filter) => {
|
|
676
1012
|
for (const key in filter) {
|
|
677
|
-
// Check for matches if filter contains regex matchers
|
|
678
1013
|
const isRegex = filter[key] instanceof RegExp;
|
|
679
|
-
const shouldMatch = isRegex && typeof props[key] ===
|
|
1014
|
+
const shouldMatch = isRegex && typeof props[key] === "string";
|
|
680
1015
|
const match = shouldMatch && filter[key].test(props[key]);
|
|
681
|
-
|
|
682
|
-
// Bail if props aren't identical and filters found no match
|
|
683
1016
|
if (props[key] !== filter[key] && !match) {
|
|
684
1017
|
return false;
|
|
685
1018
|
}
|
|
686
1019
|
}
|
|
687
1020
|
return true;
|
|
688
1021
|
};
|
|
689
|
-
const findAll = (root, decider, options = {
|
|
690
|
-
includeRoot: true
|
|
691
|
-
}) => {
|
|
1022
|
+
const findAll = (root, decider, options = { includeRoot: true }) => {
|
|
692
1023
|
const results = [];
|
|
693
|
-
|
|
694
|
-
// Only include the root node if the option is enabled
|
|
695
1024
|
if (options.includeRoot !== false && decider(root)) {
|
|
696
1025
|
results.push(root);
|
|
697
1026
|
}
|
|
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
|
-
}));
|
|
1027
|
+
root.allChildren.forEach((child) => {
|
|
1028
|
+
results.push(...findAll(child, decider, { includeRoot: true }));
|
|
705
1029
|
});
|
|
706
1030
|
return results;
|
|
707
1031
|
};
|
|
708
1032
|
|
|
709
|
-
|
|
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);
|
|
710
1036
|
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
1037
|
const instance = {
|
|
714
1038
|
root: parent.root,
|
|
715
1039
|
type: object.type.toLowerCase(),
|
|
716
1040
|
// Convert to lowercase to match R3F convention
|
|
717
1041
|
parent,
|
|
718
1042
|
children: [],
|
|
719
|
-
props: {
|
|
720
|
-
object
|
|
721
|
-
},
|
|
1043
|
+
props: { object },
|
|
722
1044
|
object,
|
|
723
1045
|
eventCount: 0,
|
|
724
1046
|
handlers: {},
|
|
725
1047
|
isHidden: false
|
|
726
1048
|
};
|
|
727
|
-
|
|
728
|
-
// Recursively process children if they exist
|
|
729
1049
|
if (object.children && object.children.length > 0) {
|
|
730
1050
|
const objectChildren = object.children;
|
|
731
|
-
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
1051
|
+
instance.children = Array.from(objectChildren).map((child) => createVirtualInstance(child, instance));
|
|
732
1052
|
}
|
|
733
1053
|
return instance;
|
|
734
1054
|
};
|
|
735
1055
|
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
|
|
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) => {
|
|
748
1062
|
const virtualInstance = createVirtualInstance(child, fiber);
|
|
749
1063
|
return wrapFiber(virtualInstance);
|
|
750
1064
|
});
|
|
@@ -752,16 +1066,17 @@ class ReactThreeTestInstance {
|
|
|
752
1066
|
return r3fChildren;
|
|
753
1067
|
}
|
|
754
1068
|
return r3fChildren;
|
|
755
|
-
};
|
|
756
|
-
this.findAll = decider => findAll(this, decider, {
|
|
757
|
-
includeRoot: false
|
|
758
1069
|
});
|
|
759
|
-
this
|
|
760
|
-
this
|
|
761
|
-
this
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
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;
|
|
765
1080
|
}
|
|
766
1081
|
get fiber() {
|
|
767
1082
|
return this._fiber;
|
|
@@ -786,126 +1101,131 @@ class ReactThreeTestInstance {
|
|
|
786
1101
|
return this.getChildren(this._fiber);
|
|
787
1102
|
}
|
|
788
1103
|
get allChildren() {
|
|
789
|
-
return this.getChildren(this._fiber, {
|
|
790
|
-
exhaustive: true
|
|
791
|
-
});
|
|
1104
|
+
return this.getChildren(this._fiber, { exhaustive: true });
|
|
792
1105
|
}
|
|
793
1106
|
}
|
|
794
|
-
const fiberToWrapper = new WeakMap();
|
|
795
|
-
const wrapFiber = fiber => {
|
|
1107
|
+
const fiberToWrapper = /* @__PURE__ */ new WeakMap();
|
|
1108
|
+
const wrapFiber = (fiber) => {
|
|
796
1109
|
let wrapper = fiberToWrapper.get(fiber);
|
|
797
|
-
if (wrapper ===
|
|
1110
|
+
if (wrapper === void 0) {
|
|
798
1111
|
wrapper = new ReactThreeTestInstance(fiber);
|
|
799
1112
|
fiberToWrapper.set(fiber, wrapper);
|
|
800
1113
|
}
|
|
801
1114
|
return wrapper;
|
|
802
1115
|
};
|
|
803
1116
|
|
|
804
|
-
async function waitFor(callback, {
|
|
805
|
-
|
|
806
|
-
timeout = 5000
|
|
807
|
-
} = {}) {
|
|
808
|
-
await fiber.act(async () => {
|
|
1117
|
+
async function waitFor(callback, { interval = 50, timeout = 5e3 } = {}) {
|
|
1118
|
+
await act(async () => {
|
|
809
1119
|
const start = performance.now();
|
|
810
1120
|
while (true) {
|
|
811
1121
|
const result = callback();
|
|
812
1122
|
if (result || result == null) break;
|
|
813
|
-
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
1123
|
+
if (interval) await new Promise((resolve) => setTimeout(resolve, interval));
|
|
814
1124
|
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
815
1125
|
}
|
|
816
1126
|
});
|
|
817
1127
|
}
|
|
818
1128
|
|
|
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)));
|
|
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();
|
|
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);
|
|
891
1191
|
}
|
|
1192
|
+
return;
|
|
892
1193
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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
|
+
};
|
|
896
1210
|
};
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1211
|
+
return { create, act, waitFor };
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
const index = {
|
|
1215
|
+
__proto__: null,
|
|
1216
|
+
ReactThreeTestInstance: ReactThreeTestInstance
|
|
902
1217
|
};
|
|
903
1218
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1219
|
+
const renderer = createTestRenderer({
|
|
1220
|
+
THREE,
|
|
1221
|
+
createRoot,
|
|
1222
|
+
mockRoots: _roots,
|
|
1223
|
+
reconciler,
|
|
1224
|
+
act,
|
|
1225
|
+
extend,
|
|
1226
|
+
mode: "webgl"
|
|
907
1227
|
});
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1228
|
+
const { create } = renderer;
|
|
1229
|
+
const legacy = { create, act, waitFor };
|
|
1230
|
+
|
|
1231
|
+
export { index as ReactThreeTest, create, legacy as default, waitFor };
|