@react-three/test-renderer 9.0.0 → 9.1.0
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/CHANGELOG.md +476 -397
- package/README.md +61 -61
- package/dist/declarations/src/createTestInstance.d.ts +22 -20
- package/dist/declarations/src/helpers/waitFor.d.ts +5 -0
- package/dist/declarations/src/index.d.ts +14 -8
- package/dist/declarations/src/types/index.d.ts +1 -1
- package/dist/declarations/src/types/internal.d.ts +20 -31
- package/dist/declarations/src/types/public.d.ts +38 -39
- package/dist/react-three-test-renderer.cjs.d.ts +1 -0
- package/dist/react-three-test-renderer.cjs.dev.js +359 -206
- package/dist/react-three-test-renderer.cjs.prod.js +359 -206
- package/dist/react-three-test-renderer.esm.js +354 -206
- package/package.json +4 -4
- package/dist/declarations/src/createTestCanvas.d.ts +0 -2
- package/dist/declarations/src/createWebGLContext.d.ts +0 -18
- package/dist/declarations/src/fireEvent.d.ts +0 -4
- package/dist/declarations/src/helpers/graph.d.ts +0 -3
- package/dist/declarations/src/helpers/is.d.ts +0 -9
- package/dist/declarations/src/helpers/strings.d.ts +0 -2
- package/dist/declarations/src/helpers/testInstance.d.ts +0 -5
- package/dist/declarations/src/helpers/tree.d.ts +0 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import { act, extend, createRoot, _roots, reconciler } from '@react-three/fiber';
|
|
3
|
+
export { act } from '@react-three/fiber';
|
|
3
4
|
|
|
4
5
|
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
5
6
|
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
@@ -9,14 +10,10 @@ const treeObjectFactory = (type, props, children) => ({
|
|
|
9
10
|
props,
|
|
10
11
|
children
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return treeObjectFactory(lowerCaseFirstLetter(child.type || child.constructor.name), { ...child.__r3f.memoizedProps
|
|
15
|
-
}, toTreeBranch([...(child.children || []), ...child.__r3f.objects]));
|
|
13
|
+
const toTreeBranch = children => children.map(child => {
|
|
14
|
+
return treeObjectFactory(lowerCaseFirstLetter(child.object.type || child.object.constructor.name), child.props, toTreeBranch(child.children));
|
|
16
15
|
});
|
|
17
|
-
|
|
18
|
-
const toTree = root => root.children.map(obj => treeObjectFactory(lowerCaseFirstLetter(obj.type), { ...obj.__r3f.memoizedProps
|
|
19
|
-
}, toTreeBranch([...obj.children, ...obj.__r3f.objects])));
|
|
16
|
+
const toTree = root => toTreeBranch(root.children);
|
|
20
17
|
|
|
21
18
|
const graphObjectFactory = (type, name, children) => ({
|
|
22
19
|
type,
|
|
@@ -24,56 +21,26 @@ const graphObjectFactory = (type, name, children) => ({
|
|
|
24
21
|
children
|
|
25
22
|
});
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let i;
|
|
46
|
-
|
|
47
|
-
for (i in a) if (!(i in b)) return false;
|
|
48
|
-
|
|
49
|
-
for (i in b) if (a[i] !== b[i]) return false;
|
|
50
|
-
|
|
51
|
-
return is.und(i) ? a === b : true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const createCanvas = ({
|
|
57
|
-
beforeReturn,
|
|
58
|
-
width = 1280,
|
|
59
|
-
height = 800
|
|
60
|
-
} = {}) => {
|
|
61
|
-
const canvas = document.createElement('canvas');
|
|
62
|
-
canvas.height = height;
|
|
63
|
-
canvas.width = width;
|
|
64
|
-
|
|
65
|
-
canvas.addEventListener = () => {};
|
|
66
|
-
|
|
67
|
-
canvas.removeEventListener = () => {};
|
|
68
|
-
|
|
69
|
-
if (beforeReturn) {
|
|
70
|
-
beforeReturn(canvas);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return canvas;
|
|
24
|
+
// Helper function to process raw THREE.js children objects
|
|
25
|
+
function processThreeChildren(children) {
|
|
26
|
+
return children.map(object => graphObjectFactory(object.type, object.name || '', object.children && object.children.length > 0 ? processThreeChildren(object.children) : []));
|
|
27
|
+
}
|
|
28
|
+
const toGraph = object => {
|
|
29
|
+
return object.children.map(child => {
|
|
30
|
+
var _child$object$childre, _child$object$name;
|
|
31
|
+
// Process standard R3F children
|
|
32
|
+
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) {
|
|
36
|
+
const threeChildren = processThreeChildren(child.object.children);
|
|
37
|
+
children.push(...threeChildren);
|
|
38
|
+
}
|
|
39
|
+
return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', children);
|
|
40
|
+
});
|
|
74
41
|
};
|
|
75
42
|
|
|
76
|
-
const functions = ['attachShader', 'bindAttribLocation', '
|
|
43
|
+
const functions = ['activeTexture', 'attachShader', 'beginQuery', 'beginTransformFeedback', 'bindAttribLocation', 'bindBufferBase', 'bindBufferRange', 'bindRenderbuffer', 'bindSampler', 'bindTransformFeedback', 'bindVertexArray', 'blendColor', 'blendEquation', 'blendEquationSeparate', 'blendFunc', 'blendFuncSeparate', 'blitFramebuffer', 'bufferData', 'bufferSubData', 'checkFramebufferStatus', 'clientWaitSync', 'compileShader', 'compressedTexImage2D', 'compressedTexImage3D', 'compressedTexSubImage2D', 'compressedTexSubImage3D', 'copyBufferSubData', 'copyTexImage2D', 'copyTexSubImage2D', 'copyTexSubImage3D', 'createBuffer', 'createFramebuffer', 'createProgram', 'createQuery', 'createRenderbuffer', 'createSampler', 'createShader', 'createTexture', 'createTransformFeedback', 'createVertexArray', 'cullFace', 'deleteBuffer', 'deleteFramebuffer', 'deleteProgram', 'deleteQuery', 'deleteRenderbuffer', 'deleteSampler', 'deleteShader', 'deleteSync', 'deleteTexture', 'deleteTransformFeedback', 'deleteVertexArray', 'depthFunc', 'depthMask', 'depthRange', 'detachShader', 'disable', 'drawArraysInstanced', 'drawElementsInstanced', 'drawRangeElements', 'enable', 'endQuery', 'endTransformFeedback', 'fenceSync', 'finish', 'flush', 'framebufferRenderbuffer', 'framebufferTexture2D', 'framebufferTextureLayer', 'frontFace', 'generateMipmap', 'getActiveAttrib', 'getActiveUniform', 'getActiveUniformBlockName', 'getActiveUniformBlockParameter', 'getActiveUniforms', 'getAttachedShaders', 'getAttribLocation', 'getBufferParameter', 'getBufferSubData', 'getContextAttributes', 'getError', 'getExtension', 'getFragDataLocation', 'getFramebufferAttachmentParameter', 'getIndexedParameter', 'getInternalformatParameter', 'getParameter', 'getProgramInfoLog', 'getProgramParameter', 'getQuery', 'getQueryParameter', 'getRenderbufferParameter', 'getSamplerParameter', 'getShaderInfoLog', 'getShaderParameter', 'getShaderPrecisionFormat', 'getShaderSource', 'getSupportedExtensions', 'getSyncParameter', 'getTexParameter', 'getTransformFeedbackVarying', 'getUniform', 'getUniformBlockIndex', 'getUniformIndices', 'getUniformLocation', 'getVertexAttrib', 'getVertexAttribOffset', 'hint', 'invalidateFramebuffer', 'invalidateSubFramebuffer', 'isBuffer', 'isContextLost', 'isEnabled', 'isFramebuffer', 'isProgram', 'isQuery', 'isRenderbuffer', 'isSampler', 'isShader', 'isSync', 'isTexture', 'isTransformFeedback', 'isVertexArray', 'lineWidth', 'linkProgram', 'pauseTransformFeedback', 'pixelStorei', 'polygonOffset', 'readBuffer', 'readPixels', 'renderbufferStorage', 'renderbufferStorageMultisample', 'resumeTransformFeedback', 'sampleCoverage', 'samplerParameterf', 'samplerParameteri', 'shaderSource', 'stencilFunc', 'stencilFuncSeparate', 'stencilMask', 'stencilMaskSeparate', 'stencilOp', 'stencilOpSeparate', 'texImage2D', 'texImage3D', 'texParameterf', 'texParameteri', 'texStorage2D', 'texStorage3D', 'texSubImage2D', 'texSubImage3D', 'transformFeedbackVaryings', 'uniform1ui', 'uniform2ui', 'uniform3ui', 'uniform4ui', 'uniformBlockBinding', 'useProgram', 'validateProgram', 'vertexAttribDivisor', 'vertexAttribI4i', 'vertexAttribI4ui', 'vertexAttribIPointer', 'waitSync', 'bindBuffer', 'bindFramebuffer', 'bindTexture', 'clear', 'clearBufferfi', 'clearBufferfv', 'clearBufferiv', 'clearBufferuiv', 'clearColor', 'clearDepth', 'clearStencil', 'colorMask', 'disableVertexAttribArray', 'drawArrays', 'drawBuffers', 'drawElements', 'enableVertexAttribArray', 'scissor', 'uniform1f', 'uniform1fv', 'uniform1i', 'uniform1iv', 'uniform1uiv', 'uniform2f', 'uniform2fv', 'uniform2i', 'uniform2iv', 'uniform2uiv', 'uniform3f', 'uniform3fv', 'uniform3i', 'uniform3iv', 'uniform3uiv', 'uniform4f', 'uniform4fv', 'uniform4i', 'uniform4iv', 'uniform4uiv', 'uniformMatrix2fv', 'uniformMatrix2x3fv', 'uniformMatrix2x4fv', 'uniformMatrix3fv', 'uniformMatrix3x2fv', 'uniformMatrix3x4fv', 'uniformMatrix4fv', 'uniformMatrix4x2fv', 'uniformMatrix4x3fv', 'vertexAttrib1f', 'vertexAttrib1fv', 'vertexAttrib2f', 'vertexAttrib2fv', 'vertexAttrib3f', 'vertexAttrib3fv', 'vertexAttrib4f', 'vertexAttrib4fv', 'vertexAttribI4iv', 'vertexAttribI4uiv', 'vertexAttribPointer', 'viewport', 'makeXRCompatible'];
|
|
77
44
|
const enums = {
|
|
78
45
|
DEPTH_BUFFER_BIT: 256,
|
|
79
46
|
STENCIL_BUFFER_BIT: 1024,
|
|
@@ -371,7 +338,159 @@ const enums = {
|
|
|
371
338
|
UNPACK_PREMULTIPLY_ALPHA_WEBGL: 37441,
|
|
372
339
|
CONTEXT_LOST_WEBGL: 37442,
|
|
373
340
|
UNPACK_COLORSPACE_CONVERSION_WEBGL: 37443,
|
|
374
|
-
BROWSER_DEFAULT_WEBGL: 37444
|
|
341
|
+
BROWSER_DEFAULT_WEBGL: 37444,
|
|
342
|
+
READ_BUFFER: 3074,
|
|
343
|
+
UNPACK_ROW_LENGTH: 3314,
|
|
344
|
+
UNPACK_SKIP_ROWS: 3315,
|
|
345
|
+
UNPACK_SKIP_PIXELS: 3316,
|
|
346
|
+
PACK_ROW_LENGTH: 3330,
|
|
347
|
+
PACK_SKIP_ROWS: 3331,
|
|
348
|
+
PACK_SKIP_PIXELS: 3332,
|
|
349
|
+
COLOR: 6144,
|
|
350
|
+
DEPTH: 6145,
|
|
351
|
+
STENCIL: 6146,
|
|
352
|
+
RED: 6403,
|
|
353
|
+
UNPACK_SKIP_IMAGES: 32877,
|
|
354
|
+
UNPACK_IMAGE_HEIGHT: 32878,
|
|
355
|
+
TEXTURE_WRAP_R: 32882,
|
|
356
|
+
MAX_ELEMENTS_VERTICES: 33000,
|
|
357
|
+
MAX_ELEMENTS_INDICES: 33001,
|
|
358
|
+
TEXTURE_MIN_LOD: 33082,
|
|
359
|
+
TEXTURE_MAX_LOD: 33083,
|
|
360
|
+
TEXTURE_BASE_LEVEL: 33084,
|
|
361
|
+
TEXTURE_MAX_LEVEL: 33085,
|
|
362
|
+
MIN: 32775,
|
|
363
|
+
MAX: 32776,
|
|
364
|
+
MAX_TEXTURE_LOD_BIAS: 34045,
|
|
365
|
+
TEXTURE_COMPARE_MODE: 34892,
|
|
366
|
+
TEXTURE_COMPARE_FUNC: 34893,
|
|
367
|
+
CURRENT_QUERY: 34917,
|
|
368
|
+
QUERY_RESULT: 34918,
|
|
369
|
+
QUERY_RESULT_AVAILABLE: 34919,
|
|
370
|
+
STREAM_READ: 35041,
|
|
371
|
+
STREAM_COPY: 35042,
|
|
372
|
+
STATIC_READ: 35045,
|
|
373
|
+
STATIC_COPY: 35046,
|
|
374
|
+
DYNAMIC_READ: 35049,
|
|
375
|
+
DYNAMIC_COPY: 35050,
|
|
376
|
+
MAX_DRAW_BUFFERS: 34852,
|
|
377
|
+
MAX_FRAGMENT_UNIFORM_COMPONENTS: 35657,
|
|
378
|
+
MAX_VERTEX_UNIFORM_COMPONENTS: 35658,
|
|
379
|
+
FRAGMENT_SHADER_DERIVATIVE_HINT: 35723,
|
|
380
|
+
PIXEL_PACK_BUFFER: 35051,
|
|
381
|
+
PIXEL_UNPACK_BUFFER: 35052,
|
|
382
|
+
PIXEL_PACK_BUFFER_BINDING: 35053,
|
|
383
|
+
PIXEL_UNPACK_BUFFER_BINDING: 35055,
|
|
384
|
+
SRGB: 35904,
|
|
385
|
+
COMPARE_REF_TO_TEXTURE: 34894,
|
|
386
|
+
VERTEX_ATTRIB_ARRAY_INTEGER: 35069,
|
|
387
|
+
MAX_ARRAY_TEXTURE_LAYERS: 35071,
|
|
388
|
+
MIN_PROGRAM_TEXEL_OFFSET: 35076,
|
|
389
|
+
MAX_PROGRAM_TEXEL_OFFSET: 35077,
|
|
390
|
+
MAX_VARYING_COMPONENTS: 35659,
|
|
391
|
+
TRANSFORM_FEEDBACK_BUFFER_MODE: 35967,
|
|
392
|
+
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 35968,
|
|
393
|
+
TRANSFORM_FEEDBACK_VARYINGS: 35971,
|
|
394
|
+
TRANSFORM_FEEDBACK_BUFFER_START: 35972,
|
|
395
|
+
TRANSFORM_FEEDBACK_BUFFER_SIZE: 35973,
|
|
396
|
+
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 35976,
|
|
397
|
+
RASTERIZER_DISCARD: 35977,
|
|
398
|
+
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 35978,
|
|
399
|
+
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 35979,
|
|
400
|
+
INTERLEAVED_ATTRIBS: 35980,
|
|
401
|
+
SEPARATE_ATTRIBS: 35981,
|
|
402
|
+
TRANSFORM_FEEDBACK_BUFFER: 35982,
|
|
403
|
+
TRANSFORM_FEEDBACK_BUFFER_BINDING: 35983,
|
|
404
|
+
RED_INTEGER: 36244,
|
|
405
|
+
RGB_INTEGER: 36248,
|
|
406
|
+
RGBA_INTEGER: 36249,
|
|
407
|
+
SAMPLER_CUBE_SHADOW: 36293,
|
|
408
|
+
INT_SAMPLER_CUBE: 36300,
|
|
409
|
+
UNSIGNED_INT_SAMPLER_CUBE: 36308,
|
|
410
|
+
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 33296,
|
|
411
|
+
FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 33297,
|
|
412
|
+
FRAMEBUFFER_ATTACHMENT_RED_SIZE: 33298,
|
|
413
|
+
FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 33299,
|
|
414
|
+
FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 33300,
|
|
415
|
+
FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 33301,
|
|
416
|
+
FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 33302,
|
|
417
|
+
FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 33303,
|
|
418
|
+
FRAMEBUFFER_DEFAULT: 33304,
|
|
419
|
+
UNSIGNED_NORMALIZED: 35863,
|
|
420
|
+
DRAW_FRAMEBUFFER_BINDING: 36006,
|
|
421
|
+
READ_FRAMEBUFFER: 36008,
|
|
422
|
+
DRAW_FRAMEBUFFER: 36009,
|
|
423
|
+
READ_FRAMEBUFFER_BINDING: 36010,
|
|
424
|
+
RENDERBUFFER_SAMPLES: 36011,
|
|
425
|
+
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 36052,
|
|
426
|
+
MAX_COLOR_ATTACHMENTS: 36063,
|
|
427
|
+
FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 36182,
|
|
428
|
+
MAX_SAMPLES: 36183,
|
|
429
|
+
HALF_FLOAT: 5131,
|
|
430
|
+
RG: 33319,
|
|
431
|
+
RG_INTEGER: 33320,
|
|
432
|
+
VERTEX_ARRAY_BINDING: 34229,
|
|
433
|
+
SIGNED_NORMALIZED: 36764,
|
|
434
|
+
COPY_READ_BUFFER: 36662,
|
|
435
|
+
COPY_WRITE_BUFFER: 36663,
|
|
436
|
+
COPY_READ_BUFFER_BINDING: 36662,
|
|
437
|
+
COPY_WRITE_BUFFER_BINDING: 36663,
|
|
438
|
+
UNIFORM_BUFFER: 35345,
|
|
439
|
+
UNIFORM_BUFFER_BINDING: 35368,
|
|
440
|
+
UNIFORM_BUFFER_START: 35369,
|
|
441
|
+
UNIFORM_BUFFER_SIZE: 35370,
|
|
442
|
+
MAX_VERTEX_UNIFORM_BLOCKS: 35371,
|
|
443
|
+
MAX_FRAGMENT_UNIFORM_BLOCKS: 35373,
|
|
444
|
+
MAX_COMBINED_UNIFORM_BLOCKS: 35374,
|
|
445
|
+
MAX_UNIFORM_BUFFER_BINDINGS: 35375,
|
|
446
|
+
MAX_UNIFORM_BLOCK_SIZE: 35376,
|
|
447
|
+
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 35377,
|
|
448
|
+
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 35379,
|
|
449
|
+
UNIFORM_BUFFER_OFFSET_ALIGNMENT: 35380,
|
|
450
|
+
ACTIVE_UNIFORM_BLOCKS: 35382,
|
|
451
|
+
UNIFORM_TYPE: 35383,
|
|
452
|
+
UNIFORM_SIZE: 35384,
|
|
453
|
+
UNIFORM_BLOCK_INDEX: 35386,
|
|
454
|
+
UNIFORM_OFFSET: 35387,
|
|
455
|
+
UNIFORM_ARRAY_STRIDE: 35388,
|
|
456
|
+
UNIFORM_MATRIX_STRIDE: 35389,
|
|
457
|
+
UNIFORM_IS_ROW_MAJOR: 35390,
|
|
458
|
+
UNIFORM_BLOCK_BINDING: 35391,
|
|
459
|
+
UNIFORM_BLOCK_DATA_SIZE: 35392,
|
|
460
|
+
UNIFORM_BLOCK_ACTIVE_UNIFORMS: 35394,
|
|
461
|
+
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 35395,
|
|
462
|
+
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 35396,
|
|
463
|
+
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 35398,
|
|
464
|
+
INVALID_INDEX: 4294967295,
|
|
465
|
+
MAX_VERTEX_OUTPUT_COMPONENTS: 37154,
|
|
466
|
+
MAX_FRAGMENT_INPUT_COMPONENTS: 37157,
|
|
467
|
+
MAX_SERVER_WAIT_TIMEOUT: 37137,
|
|
468
|
+
OBJECT_TYPE: 37138,
|
|
469
|
+
SYNC_CONDITION: 37139,
|
|
470
|
+
SYNC_STATUS: 37140,
|
|
471
|
+
SYNC_FLAGS: 37141,
|
|
472
|
+
SYNC_FENCE: 37142,
|
|
473
|
+
SYNC_GPU_COMMANDS_COMPLETE: 37143,
|
|
474
|
+
UNSIGNALED: 37144,
|
|
475
|
+
SIGNALED: 37145,
|
|
476
|
+
ALREADY_SIGNALED: 37146,
|
|
477
|
+
TIMEOUT_EXPIRED: 37147,
|
|
478
|
+
CONDITION_SATISFIED: 37148,
|
|
479
|
+
WAIT_FAILED: 37149,
|
|
480
|
+
SYNC_FLUSH_COMMANDS_BIT: 1,
|
|
481
|
+
VERTEX_ATTRIB_ARRAY_DIVISOR: 35070,
|
|
482
|
+
ANY_SAMPLES_PASSED: 35887,
|
|
483
|
+
ANY_SAMPLES_PASSED_CONSERVATIVE: 36202,
|
|
484
|
+
SAMPLER_BINDING: 35097,
|
|
485
|
+
TRANSFORM_FEEDBACK: 36386,
|
|
486
|
+
TRANSFORM_FEEDBACK_PAUSED: 36387,
|
|
487
|
+
TRANSFORM_FEEDBACK_ACTIVE: 36388,
|
|
488
|
+
TRANSFORM_FEEDBACK_BINDING: 36389,
|
|
489
|
+
TEXTURE_IMMUTABLE_FORMAT: 37167,
|
|
490
|
+
MAX_ELEMENT_INDEX: 36203,
|
|
491
|
+
TEXTURE_IMMUTABLE_LEVELS: 33503,
|
|
492
|
+
TIMEOUT_IGNORED: -1,
|
|
493
|
+
MAX_CLIENT_WAIT_TIMEOUT_WEBGL: 37447
|
|
375
494
|
};
|
|
376
495
|
const extensions = {
|
|
377
496
|
// ratified
|
|
@@ -410,8 +529,7 @@ const extensions = {
|
|
|
410
529
|
EXT_sRGB: null,
|
|
411
530
|
WEBGL_compressed_texture_etc1: null
|
|
412
531
|
};
|
|
413
|
-
|
|
414
|
-
class WebGLRenderingContext {
|
|
532
|
+
class WebGL2RenderingContext {
|
|
415
533
|
constructor(canvas) {
|
|
416
534
|
this.getShaderPrecisionFormat = () => {
|
|
417
535
|
return {
|
|
@@ -420,62 +538,84 @@ class WebGLRenderingContext {
|
|
|
420
538
|
precision: 23
|
|
421
539
|
};
|
|
422
540
|
};
|
|
423
|
-
|
|
424
541
|
this.GL_VERSION = 7938;
|
|
425
542
|
this.SCISSOR_BOX = 3088;
|
|
426
543
|
this.VIEWPORT = 2978;
|
|
427
|
-
|
|
428
|
-
this.getParameter = paramId => {
|
|
429
|
-
switch (paramId) {
|
|
430
|
-
case this.GL_VERSION:
|
|
431
|
-
return ['WebGL1'];
|
|
432
|
-
|
|
433
|
-
case this.SCISSOR_BOX:
|
|
434
|
-
case this.VIEWPORT:
|
|
435
|
-
return [0, 0, 1, 1];
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
this.getExtension = ext => {
|
|
440
|
-
return extensions[ext];
|
|
441
|
-
};
|
|
442
|
-
|
|
443
544
|
this.getProgramInfoLog = () => '';
|
|
444
|
-
|
|
445
545
|
this.getShaderInfoLog = () => '';
|
|
446
|
-
|
|
447
546
|
this.canvas = canvas;
|
|
448
547
|
this.drawingBufferWidth = canvas.width;
|
|
449
548
|
this.drawingBufferHeight = canvas.height;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
});
|
|
549
|
+
for (const method of functions) {
|
|
550
|
+
var _this$method;
|
|
551
|
+
(_this$method = this[method]) != null ? _this$method : this[method] = () => {};
|
|
552
|
+
}
|
|
455
553
|
Object.assign(this, enums);
|
|
456
554
|
}
|
|
457
|
-
|
|
555
|
+
getParameter(paramId) {
|
|
556
|
+
switch (paramId) {
|
|
557
|
+
case this.GL_VERSION:
|
|
558
|
+
return ['WebGL2'];
|
|
559
|
+
case this.SCISSOR_BOX:
|
|
560
|
+
case this.VIEWPORT:
|
|
561
|
+
return [0, 0, 1, 1];
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
getExtension(ext) {
|
|
565
|
+
return extensions[ext];
|
|
566
|
+
}
|
|
458
567
|
}
|
|
459
568
|
|
|
460
|
-
const
|
|
569
|
+
const createCanvas = ({
|
|
570
|
+
beforeReturn,
|
|
571
|
+
width = 1280,
|
|
572
|
+
height = 800
|
|
573
|
+
} = {}) => {
|
|
574
|
+
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
575
|
+
let canvas;
|
|
576
|
+
if (typeof document !== 'undefined' && typeof document.createElement === 'function') {
|
|
577
|
+
canvas = document.createElement('canvas');
|
|
578
|
+
} else {
|
|
579
|
+
canvas = {
|
|
580
|
+
style: {},
|
|
581
|
+
addEventListener: () => {},
|
|
582
|
+
removeEventListener: () => {},
|
|
583
|
+
clientWidth: width,
|
|
584
|
+
clientHeight: height,
|
|
585
|
+
getContext: () => new WebGL2RenderingContext(canvas)
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
canvas.width = width;
|
|
589
|
+
canvas.height = height;
|
|
590
|
+
if (globalThis.HTMLCanvasElement) {
|
|
591
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
592
|
+
HTMLCanvasElement.prototype.getContext = function (id) {
|
|
593
|
+
if (id.startsWith('webgl')) return new WebGL2RenderingContext(this);
|
|
594
|
+
return getContext.apply(this, arguments);
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
beforeReturn == null ? void 0 : beforeReturn(canvas);
|
|
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;
|
|
603
|
+
return canvas;
|
|
604
|
+
};
|
|
461
605
|
|
|
462
606
|
const createEventFirer = (act, store) => {
|
|
463
607
|
const findEventHandler = (element, eventName) => {
|
|
464
608
|
const eventHandlerName = toEventHandlerName(eventName);
|
|
465
609
|
const props = element.props;
|
|
466
|
-
|
|
467
610
|
if (typeof props[eventHandlerName] === 'function') {
|
|
468
611
|
return props[eventHandlerName];
|
|
469
612
|
}
|
|
470
|
-
|
|
471
613
|
if (typeof props[eventName] === 'function') {
|
|
472
614
|
return props[eventName];
|
|
473
615
|
}
|
|
474
|
-
|
|
475
616
|
console.warn(`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`);
|
|
476
617
|
return null;
|
|
477
618
|
};
|
|
478
|
-
|
|
479
619
|
const createSyntheticEvent = (element, data) => {
|
|
480
620
|
const raycastEvent = {
|
|
481
621
|
camera: store.getState().camera,
|
|
@@ -487,23 +627,18 @@ const createEventFirer = (act, store) => {
|
|
|
487
627
|
};
|
|
488
628
|
return raycastEvent;
|
|
489
629
|
};
|
|
490
|
-
|
|
491
630
|
const invokeEvent = async (element, eventName, data) => {
|
|
492
631
|
const handler = findEventHandler(element, eventName);
|
|
493
|
-
|
|
494
632
|
if (!handler) {
|
|
495
633
|
return;
|
|
496
634
|
}
|
|
497
|
-
|
|
498
635
|
let returnValue;
|
|
499
636
|
await act(async () => {
|
|
500
637
|
returnValue = handler(createSyntheticEvent(element, data));
|
|
501
638
|
});
|
|
502
639
|
return returnValue;
|
|
503
640
|
};
|
|
504
|
-
|
|
505
641
|
const fireEvent = async (element, eventName, data = {}) => await invokeEvent(element, eventName, data);
|
|
506
|
-
|
|
507
642
|
return fireEvent;
|
|
508
643
|
};
|
|
509
644
|
|
|
@@ -511,7 +646,6 @@ const expectOne = (items, msg) => {
|
|
|
511
646
|
if (items.length === 1) {
|
|
512
647
|
return items[0];
|
|
513
648
|
}
|
|
514
|
-
|
|
515
649
|
const prefix = items.length === 0 ? 'RTTR: No instances found' : `RTTR: Expected 1 but found ${items.length} instances`;
|
|
516
650
|
throw new Error(`${prefix} ${msg}`);
|
|
517
651
|
};
|
|
@@ -520,201 +654,214 @@ const matchProps = (props, filter) => {
|
|
|
520
654
|
// Check for matches if filter contains regex matchers
|
|
521
655
|
const isRegex = filter[key] instanceof RegExp;
|
|
522
656
|
const shouldMatch = isRegex && typeof props[key] === 'string';
|
|
523
|
-
const match = shouldMatch && filter[key].test(props[key]);
|
|
657
|
+
const match = shouldMatch && filter[key].test(props[key]);
|
|
524
658
|
|
|
659
|
+
// Bail if props aren't identical and filters found no match
|
|
525
660
|
if (props[key] !== filter[key] && !match) {
|
|
526
661
|
return false;
|
|
527
662
|
}
|
|
528
663
|
}
|
|
529
|
-
|
|
530
664
|
return true;
|
|
531
665
|
};
|
|
532
|
-
const findAll = (root, decider
|
|
666
|
+
const findAll = (root, decider, options = {
|
|
667
|
+
includeRoot: true
|
|
668
|
+
}) => {
|
|
533
669
|
const results = [];
|
|
534
670
|
|
|
535
|
-
|
|
671
|
+
// Only include the root node if the option is enabled
|
|
672
|
+
if (options.includeRoot !== false && decider(root)) {
|
|
536
673
|
results.push(root);
|
|
537
674
|
}
|
|
538
675
|
|
|
676
|
+
// Always search through children
|
|
539
677
|
root.allChildren.forEach(child => {
|
|
540
|
-
|
|
678
|
+
// When recursively searching children, we always want to include their roots
|
|
679
|
+
results.push(...findAll(child, decider, {
|
|
680
|
+
includeRoot: true
|
|
681
|
+
}));
|
|
541
682
|
});
|
|
542
683
|
return results;
|
|
543
684
|
};
|
|
544
685
|
|
|
686
|
+
// Helper to create a minimal wrapper for THREE.Object3D children of primitives
|
|
687
|
+
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
|
+
const instance = {
|
|
691
|
+
root: parent.root,
|
|
692
|
+
type: object.type.toLowerCase(),
|
|
693
|
+
// Convert to lowercase to match R3F convention
|
|
694
|
+
parent,
|
|
695
|
+
children: [],
|
|
696
|
+
props: {
|
|
697
|
+
object
|
|
698
|
+
},
|
|
699
|
+
object,
|
|
700
|
+
eventCount: 0,
|
|
701
|
+
handlers: {},
|
|
702
|
+
isHidden: false
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
// Recursively process children if they exist
|
|
706
|
+
if (object.children && object.children.length > 0) {
|
|
707
|
+
const objectChildren = object.children;
|
|
708
|
+
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
709
|
+
}
|
|
710
|
+
return instance;
|
|
711
|
+
};
|
|
545
712
|
class ReactThreeTestInstance {
|
|
546
713
|
constructor(_fiber) {
|
|
547
714
|
this.getChildren = (fiber, opts = {
|
|
548
715
|
exhaustive: false
|
|
549
716
|
}) => {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
717
|
+
var _fiber$object$childre;
|
|
718
|
+
// Get standard R3F children
|
|
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
|
|
725
|
+
const virtualInstance = createVirtualInstance(child, fiber);
|
|
726
|
+
return wrapFiber(virtualInstance);
|
|
727
|
+
});
|
|
728
|
+
r3fChildren.push(...threeChildren);
|
|
729
|
+
return r3fChildren;
|
|
558
730
|
}
|
|
731
|
+
return r3fChildren;
|
|
559
732
|
};
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
this.
|
|
564
|
-
|
|
565
|
-
this.
|
|
566
|
-
|
|
567
|
-
this.findAllByType = type => findAll(this, node => Boolean(node.type && node.type === type));
|
|
568
|
-
|
|
733
|
+
this.findAll = decider => findAll(this, decider, {
|
|
734
|
+
includeRoot: false
|
|
735
|
+
});
|
|
736
|
+
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
737
|
+
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
738
|
+
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|
|
569
739
|
this.findByProps = props => expectOne(this.findAllByProps(props), `with props: ${JSON.stringify(props)}`);
|
|
570
|
-
|
|
571
|
-
this.findAllByProps = props => findAll(this, node => Boolean(node.props && matchProps(node.props, props)));
|
|
572
|
-
|
|
740
|
+
this.findAllByProps = props => this.findAll(node => Boolean(node.props && matchProps(node.props, props)));
|
|
573
741
|
this._fiber = _fiber;
|
|
574
742
|
}
|
|
575
|
-
|
|
576
|
-
get instance() {
|
|
743
|
+
get fiber() {
|
|
577
744
|
return this._fiber;
|
|
578
745
|
}
|
|
579
|
-
|
|
746
|
+
get instance() {
|
|
747
|
+
return this._fiber.object;
|
|
748
|
+
}
|
|
580
749
|
get type() {
|
|
581
|
-
return this._fiber.type;
|
|
750
|
+
return this._fiber.object.type;
|
|
582
751
|
}
|
|
583
|
-
|
|
584
752
|
get props() {
|
|
585
|
-
return this._fiber.
|
|
753
|
+
return this._fiber.props;
|
|
586
754
|
}
|
|
587
|
-
|
|
588
755
|
get parent() {
|
|
589
|
-
const parent = this._fiber.
|
|
590
|
-
|
|
756
|
+
const parent = this._fiber.parent;
|
|
591
757
|
if (parent !== null) {
|
|
592
758
|
return wrapFiber(parent);
|
|
593
759
|
}
|
|
594
|
-
|
|
595
760
|
return parent;
|
|
596
761
|
}
|
|
597
|
-
|
|
598
762
|
get children() {
|
|
599
763
|
return this.getChildren(this._fiber);
|
|
600
764
|
}
|
|
601
|
-
|
|
602
765
|
get allChildren() {
|
|
603
766
|
return this.getChildren(this._fiber, {
|
|
604
767
|
exhaustive: true
|
|
605
768
|
});
|
|
606
769
|
}
|
|
607
|
-
|
|
608
770
|
}
|
|
609
771
|
const fiberToWrapper = new WeakMap();
|
|
610
772
|
const wrapFiber = fiber => {
|
|
611
773
|
let wrapper = fiberToWrapper.get(fiber);
|
|
612
|
-
|
|
613
774
|
if (wrapper === undefined) {
|
|
614
775
|
wrapper = new ReactThreeTestInstance(fiber);
|
|
615
776
|
fiberToWrapper.set(fiber, wrapper);
|
|
616
777
|
}
|
|
617
|
-
|
|
618
778
|
return wrapper;
|
|
619
779
|
};
|
|
620
780
|
|
|
781
|
+
async function waitFor(callback, {
|
|
782
|
+
interval = 50,
|
|
783
|
+
timeout = 5000
|
|
784
|
+
} = {}) {
|
|
785
|
+
await act(async () => {
|
|
786
|
+
const start = performance.now();
|
|
787
|
+
while (true) {
|
|
788
|
+
const result = callback();
|
|
789
|
+
if (result || result == null) break;
|
|
790
|
+
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
791
|
+
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
|
|
621
796
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
622
797
|
__proto__: null,
|
|
623
798
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
624
799
|
});
|
|
625
800
|
|
|
801
|
+
// Extend catalogue for render API in tests.
|
|
626
802
|
extend(THREE);
|
|
627
|
-
const act = act$1;
|
|
628
|
-
|
|
629
803
|
const create = async (element, options) => {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
//@ts-ignore
|
|
635
|
-
canvas.getContext = type => {
|
|
636
|
-
if (type === 'webgl' || type === 'webgl2') {
|
|
637
|
-
return createWebGLContext(canvas);
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
const _fiber = canvas;
|
|
643
|
-
|
|
644
|
-
const _root = createRoot(_fiber).configure({
|
|
804
|
+
var _options$width, _options$height;
|
|
805
|
+
const canvas = createCanvas(options);
|
|
806
|
+
const _root = createRoot(canvas);
|
|
807
|
+
await _root.configure({
|
|
645
808
|
frameloop: 'never',
|
|
809
|
+
// TODO: remove and use default behavior
|
|
810
|
+
size: {
|
|
811
|
+
width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
|
|
812
|
+
height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
|
|
813
|
+
top: 0,
|
|
814
|
+
left: 0
|
|
815
|
+
},
|
|
646
816
|
...options,
|
|
647
817
|
events: undefined
|
|
648
818
|
});
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
scene = _root.render(element).getState().scene;
|
|
653
|
-
});
|
|
654
|
-
const _store = _roots.get(_fiber).store;
|
|
819
|
+
const _store = _roots.get(canvas).store;
|
|
820
|
+
await act(async () => _root.render(element));
|
|
821
|
+
const _scene = _store.getState().scene.__r3f;
|
|
655
822
|
return {
|
|
656
|
-
scene: wrapFiber(
|
|
657
|
-
|
|
823
|
+
scene: wrapFiber(_scene),
|
|
824
|
+
async unmount() {
|
|
658
825
|
await act(async () => {
|
|
659
826
|
_root.unmount();
|
|
660
827
|
});
|
|
661
828
|
},
|
|
662
|
-
getInstance
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
// this is our root
|
|
666
|
-
const fiber = (_mockRoots$get = _roots.get(_fiber)) == null ? void 0 : _mockRoots$get.fiber;
|
|
667
|
-
const current = fiber == null ? void 0 : fiber.current.child.child;
|
|
668
|
-
|
|
669
|
-
if (current) {
|
|
670
|
-
const root = {
|
|
671
|
-
/**
|
|
672
|
-
* we wrap our child in a Provider component
|
|
673
|
-
* and context.Provider, so do a little
|
|
674
|
-
* artificial dive to get round this and
|
|
675
|
-
* pass context.Provider as if it was the
|
|
676
|
-
* actual react root
|
|
677
|
-
*/
|
|
678
|
-
current
|
|
679
|
-
};
|
|
680
|
-
/**
|
|
681
|
-
* so this actually returns the instance
|
|
682
|
-
* the user has passed through as a Fiber
|
|
683
|
-
*/
|
|
684
|
-
|
|
685
|
-
return reconciler.getPublicRootInstance(root);
|
|
686
|
-
} else {
|
|
687
|
-
return null;
|
|
688
|
-
}
|
|
689
|
-
},
|
|
690
|
-
update: async newElement => {
|
|
691
|
-
var _mockRoots$get2;
|
|
829
|
+
getInstance() {
|
|
830
|
+
// Bail if canvas is unmounted
|
|
831
|
+
if (!_roots.has(canvas)) return null;
|
|
692
832
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
833
|
+
// Traverse fiber nodes for R3F root
|
|
834
|
+
const root = {
|
|
835
|
+
current: _roots.get(canvas).fiber.current
|
|
836
|
+
};
|
|
837
|
+
while (!((_root$current$child = root.current.child) != null && _root$current$child.stateNode)) {
|
|
838
|
+
var _root$current$child;
|
|
839
|
+
root.current = root.current.child;
|
|
699
840
|
}
|
|
700
841
|
|
|
701
|
-
|
|
842
|
+
// Return R3F instance from root
|
|
843
|
+
return reconciler.getPublicRootInstance(root);
|
|
702
844
|
},
|
|
703
|
-
|
|
704
|
-
return
|
|
845
|
+
async update(newElement) {
|
|
846
|
+
if (!_roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
|
|
847
|
+
await act(async () => {
|
|
848
|
+
_root.render(newElement);
|
|
849
|
+
});
|
|
705
850
|
},
|
|
706
|
-
|
|
707
|
-
return
|
|
851
|
+
toTree() {
|
|
852
|
+
return toTree(_scene);
|
|
853
|
+
},
|
|
854
|
+
toGraph() {
|
|
855
|
+
return toGraph(_scene);
|
|
708
856
|
},
|
|
709
857
|
fireEvent: createEventFirer(act, _store),
|
|
710
|
-
|
|
858
|
+
async advanceFrames(frames, delta = 1) {
|
|
711
859
|
const state = _store.getState();
|
|
712
|
-
|
|
713
860
|
const storeSubscribers = state.internal.subscribers;
|
|
714
861
|
const promises = [];
|
|
715
862
|
storeSubscribers.forEach(subscriber => {
|
|
716
863
|
for (let i = 0; i < frames; i++) {
|
|
717
|
-
if (
|
|
864
|
+
if (Array.isArray(delta)) {
|
|
718
865
|
promises.push(new Promise(() => subscriber.ref.current(state, delta[i] || delta[-1])));
|
|
719
866
|
} else {
|
|
720
867
|
promises.push(new Promise(() => subscriber.ref.current(state, delta)));
|
|
@@ -727,7 +874,8 @@ const create = async (element, options) => {
|
|
|
727
874
|
};
|
|
728
875
|
var index = {
|
|
729
876
|
create,
|
|
730
|
-
act
|
|
877
|
+
act,
|
|
878
|
+
waitFor
|
|
731
879
|
};
|
|
732
880
|
|
|
733
|
-
export { index$1 as ReactThreeTest, index as default };
|
|
881
|
+
export { index$1 as ReactThreeTest, create, index as default, waitFor };
|