@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
|
@@ -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,71 +10,22 @@ 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,
|
|
23
20
|
name,
|
|
24
21
|
children
|
|
25
22
|
});
|
|
23
|
+
const toGraph = object => object.children.map(child => {
|
|
24
|
+
var _child$object$name;
|
|
25
|
+
return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', toGraph(child));
|
|
26
|
+
});
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const is = {
|
|
30
|
-
obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
|
|
31
|
-
fun: a => typeof a === 'function',
|
|
32
|
-
str: a => typeof a === 'string',
|
|
33
|
-
num: a => typeof a === 'number',
|
|
34
|
-
und: a => a === void 0,
|
|
35
|
-
arr: a => Array.isArray(a),
|
|
36
|
-
|
|
37
|
-
equ(a, b) {
|
|
38
|
-
// Wrong type or one of the two undefined, doesn't match
|
|
39
|
-
if (typeof a !== typeof b || !!a !== !!b) return false; // Atomic, just compare a against b
|
|
40
|
-
|
|
41
|
-
if (is.str(a) || is.num(a) || is.obj(a)) return a === b; // Array, shallow compare first to see if it's a match
|
|
42
|
-
|
|
43
|
-
if (is.arr(a) && a == b) return true; // Last resort, go through keys
|
|
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;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
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'];
|
|
28
|
+
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
29
|
const enums = {
|
|
78
30
|
DEPTH_BUFFER_BIT: 256,
|
|
79
31
|
STENCIL_BUFFER_BIT: 1024,
|
|
@@ -371,7 +323,159 @@ const enums = {
|
|
|
371
323
|
UNPACK_PREMULTIPLY_ALPHA_WEBGL: 37441,
|
|
372
324
|
CONTEXT_LOST_WEBGL: 37442,
|
|
373
325
|
UNPACK_COLORSPACE_CONVERSION_WEBGL: 37443,
|
|
374
|
-
BROWSER_DEFAULT_WEBGL: 37444
|
|
326
|
+
BROWSER_DEFAULT_WEBGL: 37444,
|
|
327
|
+
READ_BUFFER: 3074,
|
|
328
|
+
UNPACK_ROW_LENGTH: 3314,
|
|
329
|
+
UNPACK_SKIP_ROWS: 3315,
|
|
330
|
+
UNPACK_SKIP_PIXELS: 3316,
|
|
331
|
+
PACK_ROW_LENGTH: 3330,
|
|
332
|
+
PACK_SKIP_ROWS: 3331,
|
|
333
|
+
PACK_SKIP_PIXELS: 3332,
|
|
334
|
+
COLOR: 6144,
|
|
335
|
+
DEPTH: 6145,
|
|
336
|
+
STENCIL: 6146,
|
|
337
|
+
RED: 6403,
|
|
338
|
+
UNPACK_SKIP_IMAGES: 32877,
|
|
339
|
+
UNPACK_IMAGE_HEIGHT: 32878,
|
|
340
|
+
TEXTURE_WRAP_R: 32882,
|
|
341
|
+
MAX_ELEMENTS_VERTICES: 33000,
|
|
342
|
+
MAX_ELEMENTS_INDICES: 33001,
|
|
343
|
+
TEXTURE_MIN_LOD: 33082,
|
|
344
|
+
TEXTURE_MAX_LOD: 33083,
|
|
345
|
+
TEXTURE_BASE_LEVEL: 33084,
|
|
346
|
+
TEXTURE_MAX_LEVEL: 33085,
|
|
347
|
+
MIN: 32775,
|
|
348
|
+
MAX: 32776,
|
|
349
|
+
MAX_TEXTURE_LOD_BIAS: 34045,
|
|
350
|
+
TEXTURE_COMPARE_MODE: 34892,
|
|
351
|
+
TEXTURE_COMPARE_FUNC: 34893,
|
|
352
|
+
CURRENT_QUERY: 34917,
|
|
353
|
+
QUERY_RESULT: 34918,
|
|
354
|
+
QUERY_RESULT_AVAILABLE: 34919,
|
|
355
|
+
STREAM_READ: 35041,
|
|
356
|
+
STREAM_COPY: 35042,
|
|
357
|
+
STATIC_READ: 35045,
|
|
358
|
+
STATIC_COPY: 35046,
|
|
359
|
+
DYNAMIC_READ: 35049,
|
|
360
|
+
DYNAMIC_COPY: 35050,
|
|
361
|
+
MAX_DRAW_BUFFERS: 34852,
|
|
362
|
+
MAX_FRAGMENT_UNIFORM_COMPONENTS: 35657,
|
|
363
|
+
MAX_VERTEX_UNIFORM_COMPONENTS: 35658,
|
|
364
|
+
FRAGMENT_SHADER_DERIVATIVE_HINT: 35723,
|
|
365
|
+
PIXEL_PACK_BUFFER: 35051,
|
|
366
|
+
PIXEL_UNPACK_BUFFER: 35052,
|
|
367
|
+
PIXEL_PACK_BUFFER_BINDING: 35053,
|
|
368
|
+
PIXEL_UNPACK_BUFFER_BINDING: 35055,
|
|
369
|
+
SRGB: 35904,
|
|
370
|
+
COMPARE_REF_TO_TEXTURE: 34894,
|
|
371
|
+
VERTEX_ATTRIB_ARRAY_INTEGER: 35069,
|
|
372
|
+
MAX_ARRAY_TEXTURE_LAYERS: 35071,
|
|
373
|
+
MIN_PROGRAM_TEXEL_OFFSET: 35076,
|
|
374
|
+
MAX_PROGRAM_TEXEL_OFFSET: 35077,
|
|
375
|
+
MAX_VARYING_COMPONENTS: 35659,
|
|
376
|
+
TRANSFORM_FEEDBACK_BUFFER_MODE: 35967,
|
|
377
|
+
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 35968,
|
|
378
|
+
TRANSFORM_FEEDBACK_VARYINGS: 35971,
|
|
379
|
+
TRANSFORM_FEEDBACK_BUFFER_START: 35972,
|
|
380
|
+
TRANSFORM_FEEDBACK_BUFFER_SIZE: 35973,
|
|
381
|
+
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 35976,
|
|
382
|
+
RASTERIZER_DISCARD: 35977,
|
|
383
|
+
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 35978,
|
|
384
|
+
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 35979,
|
|
385
|
+
INTERLEAVED_ATTRIBS: 35980,
|
|
386
|
+
SEPARATE_ATTRIBS: 35981,
|
|
387
|
+
TRANSFORM_FEEDBACK_BUFFER: 35982,
|
|
388
|
+
TRANSFORM_FEEDBACK_BUFFER_BINDING: 35983,
|
|
389
|
+
RED_INTEGER: 36244,
|
|
390
|
+
RGB_INTEGER: 36248,
|
|
391
|
+
RGBA_INTEGER: 36249,
|
|
392
|
+
SAMPLER_CUBE_SHADOW: 36293,
|
|
393
|
+
INT_SAMPLER_CUBE: 36300,
|
|
394
|
+
UNSIGNED_INT_SAMPLER_CUBE: 36308,
|
|
395
|
+
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 33296,
|
|
396
|
+
FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 33297,
|
|
397
|
+
FRAMEBUFFER_ATTACHMENT_RED_SIZE: 33298,
|
|
398
|
+
FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 33299,
|
|
399
|
+
FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 33300,
|
|
400
|
+
FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 33301,
|
|
401
|
+
FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 33302,
|
|
402
|
+
FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 33303,
|
|
403
|
+
FRAMEBUFFER_DEFAULT: 33304,
|
|
404
|
+
UNSIGNED_NORMALIZED: 35863,
|
|
405
|
+
DRAW_FRAMEBUFFER_BINDING: 36006,
|
|
406
|
+
READ_FRAMEBUFFER: 36008,
|
|
407
|
+
DRAW_FRAMEBUFFER: 36009,
|
|
408
|
+
READ_FRAMEBUFFER_BINDING: 36010,
|
|
409
|
+
RENDERBUFFER_SAMPLES: 36011,
|
|
410
|
+
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 36052,
|
|
411
|
+
MAX_COLOR_ATTACHMENTS: 36063,
|
|
412
|
+
FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 36182,
|
|
413
|
+
MAX_SAMPLES: 36183,
|
|
414
|
+
HALF_FLOAT: 5131,
|
|
415
|
+
RG: 33319,
|
|
416
|
+
RG_INTEGER: 33320,
|
|
417
|
+
VERTEX_ARRAY_BINDING: 34229,
|
|
418
|
+
SIGNED_NORMALIZED: 36764,
|
|
419
|
+
COPY_READ_BUFFER: 36662,
|
|
420
|
+
COPY_WRITE_BUFFER: 36663,
|
|
421
|
+
COPY_READ_BUFFER_BINDING: 36662,
|
|
422
|
+
COPY_WRITE_BUFFER_BINDING: 36663,
|
|
423
|
+
UNIFORM_BUFFER: 35345,
|
|
424
|
+
UNIFORM_BUFFER_BINDING: 35368,
|
|
425
|
+
UNIFORM_BUFFER_START: 35369,
|
|
426
|
+
UNIFORM_BUFFER_SIZE: 35370,
|
|
427
|
+
MAX_VERTEX_UNIFORM_BLOCKS: 35371,
|
|
428
|
+
MAX_FRAGMENT_UNIFORM_BLOCKS: 35373,
|
|
429
|
+
MAX_COMBINED_UNIFORM_BLOCKS: 35374,
|
|
430
|
+
MAX_UNIFORM_BUFFER_BINDINGS: 35375,
|
|
431
|
+
MAX_UNIFORM_BLOCK_SIZE: 35376,
|
|
432
|
+
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 35377,
|
|
433
|
+
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 35379,
|
|
434
|
+
UNIFORM_BUFFER_OFFSET_ALIGNMENT: 35380,
|
|
435
|
+
ACTIVE_UNIFORM_BLOCKS: 35382,
|
|
436
|
+
UNIFORM_TYPE: 35383,
|
|
437
|
+
UNIFORM_SIZE: 35384,
|
|
438
|
+
UNIFORM_BLOCK_INDEX: 35386,
|
|
439
|
+
UNIFORM_OFFSET: 35387,
|
|
440
|
+
UNIFORM_ARRAY_STRIDE: 35388,
|
|
441
|
+
UNIFORM_MATRIX_STRIDE: 35389,
|
|
442
|
+
UNIFORM_IS_ROW_MAJOR: 35390,
|
|
443
|
+
UNIFORM_BLOCK_BINDING: 35391,
|
|
444
|
+
UNIFORM_BLOCK_DATA_SIZE: 35392,
|
|
445
|
+
UNIFORM_BLOCK_ACTIVE_UNIFORMS: 35394,
|
|
446
|
+
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 35395,
|
|
447
|
+
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 35396,
|
|
448
|
+
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 35398,
|
|
449
|
+
INVALID_INDEX: 4294967295,
|
|
450
|
+
MAX_VERTEX_OUTPUT_COMPONENTS: 37154,
|
|
451
|
+
MAX_FRAGMENT_INPUT_COMPONENTS: 37157,
|
|
452
|
+
MAX_SERVER_WAIT_TIMEOUT: 37137,
|
|
453
|
+
OBJECT_TYPE: 37138,
|
|
454
|
+
SYNC_CONDITION: 37139,
|
|
455
|
+
SYNC_STATUS: 37140,
|
|
456
|
+
SYNC_FLAGS: 37141,
|
|
457
|
+
SYNC_FENCE: 37142,
|
|
458
|
+
SYNC_GPU_COMMANDS_COMPLETE: 37143,
|
|
459
|
+
UNSIGNALED: 37144,
|
|
460
|
+
SIGNALED: 37145,
|
|
461
|
+
ALREADY_SIGNALED: 37146,
|
|
462
|
+
TIMEOUT_EXPIRED: 37147,
|
|
463
|
+
CONDITION_SATISFIED: 37148,
|
|
464
|
+
WAIT_FAILED: 37149,
|
|
465
|
+
SYNC_FLUSH_COMMANDS_BIT: 1,
|
|
466
|
+
VERTEX_ATTRIB_ARRAY_DIVISOR: 35070,
|
|
467
|
+
ANY_SAMPLES_PASSED: 35887,
|
|
468
|
+
ANY_SAMPLES_PASSED_CONSERVATIVE: 36202,
|
|
469
|
+
SAMPLER_BINDING: 35097,
|
|
470
|
+
TRANSFORM_FEEDBACK: 36386,
|
|
471
|
+
TRANSFORM_FEEDBACK_PAUSED: 36387,
|
|
472
|
+
TRANSFORM_FEEDBACK_ACTIVE: 36388,
|
|
473
|
+
TRANSFORM_FEEDBACK_BINDING: 36389,
|
|
474
|
+
TEXTURE_IMMUTABLE_FORMAT: 37167,
|
|
475
|
+
MAX_ELEMENT_INDEX: 36203,
|
|
476
|
+
TEXTURE_IMMUTABLE_LEVELS: 33503,
|
|
477
|
+
TIMEOUT_IGNORED: -1,
|
|
478
|
+
MAX_CLIENT_WAIT_TIMEOUT_WEBGL: 37447
|
|
375
479
|
};
|
|
376
480
|
const extensions = {
|
|
377
481
|
// ratified
|
|
@@ -410,8 +514,7 @@ const extensions = {
|
|
|
410
514
|
EXT_sRGB: null,
|
|
411
515
|
WEBGL_compressed_texture_etc1: null
|
|
412
516
|
};
|
|
413
|
-
|
|
414
|
-
class WebGLRenderingContext {
|
|
517
|
+
class WebGL2RenderingContext {
|
|
415
518
|
constructor(canvas) {
|
|
416
519
|
this.getShaderPrecisionFormat = () => {
|
|
417
520
|
return {
|
|
@@ -420,62 +523,84 @@ class WebGLRenderingContext {
|
|
|
420
523
|
precision: 23
|
|
421
524
|
};
|
|
422
525
|
};
|
|
423
|
-
|
|
424
526
|
this.GL_VERSION = 7938;
|
|
425
527
|
this.SCISSOR_BOX = 3088;
|
|
426
528
|
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
529
|
this.getProgramInfoLog = () => '';
|
|
444
|
-
|
|
445
530
|
this.getShaderInfoLog = () => '';
|
|
446
|
-
|
|
447
531
|
this.canvas = canvas;
|
|
448
532
|
this.drawingBufferWidth = canvas.width;
|
|
449
533
|
this.drawingBufferHeight = canvas.height;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
});
|
|
534
|
+
for (const method of functions) {
|
|
535
|
+
var _this$method;
|
|
536
|
+
(_this$method = this[method]) != null ? _this$method : this[method] = () => {};
|
|
537
|
+
}
|
|
455
538
|
Object.assign(this, enums);
|
|
456
539
|
}
|
|
457
|
-
|
|
540
|
+
getParameter(paramId) {
|
|
541
|
+
switch (paramId) {
|
|
542
|
+
case this.GL_VERSION:
|
|
543
|
+
return ['WebGL2'];
|
|
544
|
+
case this.SCISSOR_BOX:
|
|
545
|
+
case this.VIEWPORT:
|
|
546
|
+
return [0, 0, 1, 1];
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
getExtension(ext) {
|
|
550
|
+
return extensions[ext];
|
|
551
|
+
}
|
|
458
552
|
}
|
|
459
553
|
|
|
460
|
-
const
|
|
554
|
+
const createCanvas = ({
|
|
555
|
+
beforeReturn,
|
|
556
|
+
width = 1280,
|
|
557
|
+
height = 800
|
|
558
|
+
} = {}) => {
|
|
559
|
+
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
560
|
+
let canvas;
|
|
561
|
+
if (typeof document !== 'undefined' && typeof document.createElement === 'function') {
|
|
562
|
+
canvas = document.createElement('canvas');
|
|
563
|
+
} else {
|
|
564
|
+
canvas = {
|
|
565
|
+
style: {},
|
|
566
|
+
addEventListener: () => {},
|
|
567
|
+
removeEventListener: () => {},
|
|
568
|
+
clientWidth: width,
|
|
569
|
+
clientHeight: height,
|
|
570
|
+
getContext: () => new WebGL2RenderingContext(canvas)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
canvas.width = width;
|
|
574
|
+
canvas.height = height;
|
|
575
|
+
if (globalThis.HTMLCanvasElement) {
|
|
576
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
577
|
+
HTMLCanvasElement.prototype.getContext = function (id) {
|
|
578
|
+
if (id.startsWith('webgl')) return new WebGL2RenderingContext(this);
|
|
579
|
+
return getContext.apply(this, arguments);
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
beforeReturn == null ? void 0 : beforeReturn(canvas);
|
|
583
|
+
class WebGLRenderingContext extends WebGL2RenderingContext {}
|
|
584
|
+
// @ts-expect-error
|
|
585
|
+
(_globalThis$WebGLRend = globalThis.WebGLRenderingContext) != null ? _globalThis$WebGLRend : globalThis.WebGLRenderingContext = WebGLRenderingContext;
|
|
586
|
+
// @ts-expect-error
|
|
587
|
+
(_globalThis$WebGL2Ren = globalThis.WebGL2RenderingContext) != null ? _globalThis$WebGL2Ren : globalThis.WebGL2RenderingContext = WebGL2RenderingContext;
|
|
588
|
+
return canvas;
|
|
589
|
+
};
|
|
461
590
|
|
|
462
591
|
const createEventFirer = (act, store) => {
|
|
463
592
|
const findEventHandler = (element, eventName) => {
|
|
464
593
|
const eventHandlerName = toEventHandlerName(eventName);
|
|
465
594
|
const props = element.props;
|
|
466
|
-
|
|
467
595
|
if (typeof props[eventHandlerName] === 'function') {
|
|
468
596
|
return props[eventHandlerName];
|
|
469
597
|
}
|
|
470
|
-
|
|
471
598
|
if (typeof props[eventName] === 'function') {
|
|
472
599
|
return props[eventName];
|
|
473
600
|
}
|
|
474
|
-
|
|
475
601
|
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
602
|
return null;
|
|
477
603
|
};
|
|
478
|
-
|
|
479
604
|
const createSyntheticEvent = (element, data) => {
|
|
480
605
|
const raycastEvent = {
|
|
481
606
|
camera: store.getState().camera,
|
|
@@ -487,23 +612,18 @@ const createEventFirer = (act, store) => {
|
|
|
487
612
|
};
|
|
488
613
|
return raycastEvent;
|
|
489
614
|
};
|
|
490
|
-
|
|
491
615
|
const invokeEvent = async (element, eventName, data) => {
|
|
492
616
|
const handler = findEventHandler(element, eventName);
|
|
493
|
-
|
|
494
617
|
if (!handler) {
|
|
495
618
|
return;
|
|
496
619
|
}
|
|
497
|
-
|
|
498
620
|
let returnValue;
|
|
499
621
|
await act(async () => {
|
|
500
622
|
returnValue = handler(createSyntheticEvent(element, data));
|
|
501
623
|
});
|
|
502
624
|
return returnValue;
|
|
503
625
|
};
|
|
504
|
-
|
|
505
626
|
const fireEvent = async (element, eventName, data = {}) => await invokeEvent(element, eventName, data);
|
|
506
|
-
|
|
507
627
|
return fireEvent;
|
|
508
628
|
};
|
|
509
629
|
|
|
@@ -511,7 +631,6 @@ const expectOne = (items, msg) => {
|
|
|
511
631
|
if (items.length === 1) {
|
|
512
632
|
return items[0];
|
|
513
633
|
}
|
|
514
|
-
|
|
515
634
|
const prefix = items.length === 0 ? 'RTTR: No instances found' : `RTTR: Expected 1 but found ${items.length} instances`;
|
|
516
635
|
throw new Error(`${prefix} ${msg}`);
|
|
517
636
|
};
|
|
@@ -520,22 +639,20 @@ const matchProps = (props, filter) => {
|
|
|
520
639
|
// Check for matches if filter contains regex matchers
|
|
521
640
|
const isRegex = filter[key] instanceof RegExp;
|
|
522
641
|
const shouldMatch = isRegex && typeof props[key] === 'string';
|
|
523
|
-
const match = shouldMatch && filter[key].test(props[key]);
|
|
642
|
+
const match = shouldMatch && filter[key].test(props[key]);
|
|
524
643
|
|
|
644
|
+
// Bail if props aren't identical and filters found no match
|
|
525
645
|
if (props[key] !== filter[key] && !match) {
|
|
526
646
|
return false;
|
|
527
647
|
}
|
|
528
648
|
}
|
|
529
|
-
|
|
530
649
|
return true;
|
|
531
650
|
};
|
|
532
651
|
const findAll = (root, decider) => {
|
|
533
652
|
const results = [];
|
|
534
|
-
|
|
535
653
|
if (decider(root)) {
|
|
536
654
|
results.push(root);
|
|
537
655
|
}
|
|
538
|
-
|
|
539
656
|
root.allChildren.forEach(child => {
|
|
540
657
|
results.push(...findAll(child, decider));
|
|
541
658
|
});
|
|
@@ -546,175 +663,137 @@ class ReactThreeTestInstance {
|
|
|
546
663
|
constructor(_fiber) {
|
|
547
664
|
this.getChildren = (fiber, opts = {
|
|
548
665
|
exhaustive: false
|
|
549
|
-
}) =>
|
|
550
|
-
if (opts.exhaustive) {
|
|
551
|
-
/**
|
|
552
|
-
* this will return objects like
|
|
553
|
-
* color or effects etc.
|
|
554
|
-
*/
|
|
555
|
-
return [...(fiber.children || []).map(fib => wrapFiber(fib)), ...fiber.__r3f.objects.map(fib => wrapFiber(fib))];
|
|
556
|
-
} else {
|
|
557
|
-
return (fiber.children || []).map(fib => wrapFiber(fib));
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
this.find = decider => expectOne(findAll(this, decider), `matching custom checker: ${decider.toString()}`);
|
|
562
|
-
|
|
666
|
+
}) => fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
|
|
563
667
|
this.findAll = decider => findAll(this, decider);
|
|
564
|
-
|
|
565
|
-
this.findByType = type => expectOne(findAll(
|
|
566
|
-
|
|
567
|
-
this.findAllByType = type => findAll(this, node => Boolean(node.type && node.type === type));
|
|
568
|
-
|
|
668
|
+
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
669
|
+
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
670
|
+
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|
|
569
671
|
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
|
-
|
|
672
|
+
this.findAllByProps = props => this.findAll(node => Boolean(node.props && matchProps(node.props, props)));
|
|
573
673
|
this._fiber = _fiber;
|
|
574
674
|
}
|
|
575
|
-
|
|
576
|
-
get instance() {
|
|
675
|
+
get fiber() {
|
|
577
676
|
return this._fiber;
|
|
578
677
|
}
|
|
579
|
-
|
|
678
|
+
get instance() {
|
|
679
|
+
return this._fiber.object;
|
|
680
|
+
}
|
|
580
681
|
get type() {
|
|
581
|
-
return this._fiber.type;
|
|
682
|
+
return this._fiber.object.type;
|
|
582
683
|
}
|
|
583
|
-
|
|
584
684
|
get props() {
|
|
585
|
-
return this._fiber.
|
|
685
|
+
return this._fiber.props;
|
|
586
686
|
}
|
|
587
|
-
|
|
588
687
|
get parent() {
|
|
589
|
-
const parent = this._fiber.
|
|
590
|
-
|
|
688
|
+
const parent = this._fiber.parent;
|
|
591
689
|
if (parent !== null) {
|
|
592
690
|
return wrapFiber(parent);
|
|
593
691
|
}
|
|
594
|
-
|
|
595
692
|
return parent;
|
|
596
693
|
}
|
|
597
|
-
|
|
598
694
|
get children() {
|
|
599
695
|
return this.getChildren(this._fiber);
|
|
600
696
|
}
|
|
601
|
-
|
|
602
697
|
get allChildren() {
|
|
603
698
|
return this.getChildren(this._fiber, {
|
|
604
699
|
exhaustive: true
|
|
605
700
|
});
|
|
606
701
|
}
|
|
607
|
-
|
|
608
702
|
}
|
|
609
703
|
const fiberToWrapper = new WeakMap();
|
|
610
704
|
const wrapFiber = fiber => {
|
|
611
705
|
let wrapper = fiberToWrapper.get(fiber);
|
|
612
|
-
|
|
613
706
|
if (wrapper === undefined) {
|
|
614
707
|
wrapper = new ReactThreeTestInstance(fiber);
|
|
615
708
|
fiberToWrapper.set(fiber, wrapper);
|
|
616
709
|
}
|
|
617
|
-
|
|
618
710
|
return wrapper;
|
|
619
711
|
};
|
|
620
712
|
|
|
713
|
+
async function waitFor(callback, {
|
|
714
|
+
interval = 50,
|
|
715
|
+
timeout = 5000
|
|
716
|
+
} = {}) {
|
|
717
|
+
await act(async () => {
|
|
718
|
+
const start = performance.now();
|
|
719
|
+
while (true) {
|
|
720
|
+
const result = callback();
|
|
721
|
+
if (result || result == null) break;
|
|
722
|
+
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
723
|
+
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
|
|
621
728
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
622
729
|
__proto__: null,
|
|
623
730
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
624
731
|
});
|
|
625
732
|
|
|
733
|
+
// Extend catalogue for render API in tests.
|
|
626
734
|
extend(THREE);
|
|
627
|
-
const act = act$1;
|
|
628
|
-
|
|
629
735
|
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({
|
|
736
|
+
var _options$width, _options$height;
|
|
737
|
+
const canvas = createCanvas(options);
|
|
738
|
+
const _root = createRoot(canvas);
|
|
739
|
+
await _root.configure({
|
|
645
740
|
frameloop: 'never',
|
|
741
|
+
// TODO: remove and use default behavior
|
|
742
|
+
size: {
|
|
743
|
+
width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
|
|
744
|
+
height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
|
|
745
|
+
top: 0,
|
|
746
|
+
left: 0
|
|
747
|
+
},
|
|
646
748
|
...options,
|
|
647
749
|
events: undefined
|
|
648
750
|
});
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
scene = _root.render(element).getState().scene;
|
|
653
|
-
});
|
|
654
|
-
const _store = _roots.get(_fiber).store;
|
|
751
|
+
const _store = _roots.get(canvas).store;
|
|
752
|
+
await act(async () => _root.render(element));
|
|
753
|
+
const _scene = _store.getState().scene.__r3f;
|
|
655
754
|
return {
|
|
656
|
-
scene: wrapFiber(
|
|
657
|
-
|
|
755
|
+
scene: wrapFiber(_scene),
|
|
756
|
+
async unmount() {
|
|
658
757
|
await act(async () => {
|
|
659
758
|
_root.unmount();
|
|
660
759
|
});
|
|
661
760
|
},
|
|
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;
|
|
761
|
+
getInstance() {
|
|
762
|
+
// Bail if canvas is unmounted
|
|
763
|
+
if (!_roots.has(canvas)) return null;
|
|
692
764
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
765
|
+
// Traverse fiber nodes for R3F root
|
|
766
|
+
const root = {
|
|
767
|
+
current: _roots.get(canvas).fiber.current
|
|
768
|
+
};
|
|
769
|
+
while (!((_root$current$child = root.current.child) != null && _root$current$child.stateNode)) {
|
|
770
|
+
var _root$current$child;
|
|
771
|
+
root.current = root.current.child;
|
|
699
772
|
}
|
|
700
773
|
|
|
701
|
-
|
|
774
|
+
// Return R3F instance from root
|
|
775
|
+
return reconciler.getPublicRootInstance(root);
|
|
702
776
|
},
|
|
703
|
-
|
|
704
|
-
return
|
|
777
|
+
async update(newElement) {
|
|
778
|
+
if (!_roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
|
|
779
|
+
await act(async () => {
|
|
780
|
+
_root.render(newElement);
|
|
781
|
+
});
|
|
782
|
+
},
|
|
783
|
+
toTree() {
|
|
784
|
+
return toTree(_scene);
|
|
705
785
|
},
|
|
706
|
-
toGraph
|
|
707
|
-
return toGraph(
|
|
786
|
+
toGraph() {
|
|
787
|
+
return toGraph(_scene);
|
|
708
788
|
},
|
|
709
789
|
fireEvent: createEventFirer(act, _store),
|
|
710
|
-
|
|
790
|
+
async advanceFrames(frames, delta = 1) {
|
|
711
791
|
const state = _store.getState();
|
|
712
|
-
|
|
713
792
|
const storeSubscribers = state.internal.subscribers;
|
|
714
793
|
const promises = [];
|
|
715
794
|
storeSubscribers.forEach(subscriber => {
|
|
716
795
|
for (let i = 0; i < frames; i++) {
|
|
717
|
-
if (
|
|
796
|
+
if (Array.isArray(delta)) {
|
|
718
797
|
promises.push(new Promise(() => subscriber.ref.current(state, delta[i] || delta[-1])));
|
|
719
798
|
} else {
|
|
720
799
|
promises.push(new Promise(() => subscriber.ref.current(state, delta)));
|
|
@@ -727,7 +806,8 @@ const create = async (element, options) => {
|
|
|
727
806
|
};
|
|
728
807
|
var index = {
|
|
729
808
|
create,
|
|
730
|
-
act
|
|
809
|
+
act,
|
|
810
|
+
waitFor
|
|
731
811
|
};
|
|
732
812
|
|
|
733
|
-
export { index$1 as ReactThreeTest, index as default };
|
|
813
|
+
export { index$1 as ReactThreeTest, create, index as default, waitFor };
|