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