@react-three/test-renderer 9.0.1 → 9.1.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 +482 -470
- package/README.md +61 -61
- package/dist/declarations/src/createTestInstance.d.ts +22 -22
- package/dist/declarations/src/helpers/waitFor.d.ts +5 -5
- package/dist/declarations/src/index.d.ts +14 -14
- package/dist/declarations/src/types/index.d.ts +1 -1
- package/dist/declarations/src/types/internal.d.ts +20 -20
- package/dist/declarations/src/types/public.d.ts +38 -38
- package/dist/react-three-test-renderer.cjs.dev.js +85 -16
- package/dist/react-three-test-renderer.cjs.prod.js +85 -16
- package/dist/react-three-test-renderer.esm.js +80 -11
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var react = require('react');
|
|
5
6
|
var THREE = require('three');
|
|
6
7
|
var fiber = require('@react-three/fiber');
|
|
7
8
|
|
|
@@ -43,10 +44,25 @@ const graphObjectFactory = (type, name, children) => ({
|
|
|
43
44
|
name,
|
|
44
45
|
children
|
|
45
46
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
|
|
48
|
+
// Helper function to process raw THREE.js children objects
|
|
49
|
+
function processThreeChildren(children) {
|
|
50
|
+
return children.map(object => graphObjectFactory(object.type, object.name || '', object.children && object.children.length > 0 ? processThreeChildren(object.children) : []));
|
|
51
|
+
}
|
|
52
|
+
const toGraph = object => {
|
|
53
|
+
return object.children.map(child => {
|
|
54
|
+
var _child$object$childre, _child$object$name;
|
|
55
|
+
// Process standard R3F children
|
|
56
|
+
const children = toGraph(child);
|
|
57
|
+
|
|
58
|
+
// For primitives, also include THREE.js object children
|
|
59
|
+
if (child.type === 'primitive' && (_child$object$childre = child.object.children) != null && _child$object$childre.length) {
|
|
60
|
+
const threeChildren = processThreeChildren(child.object.children);
|
|
61
|
+
children.push(...threeChildren);
|
|
62
|
+
}
|
|
63
|
+
return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', children);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
50
66
|
|
|
51
67
|
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'];
|
|
52
68
|
const enums = {
|
|
@@ -671,23 +687,76 @@ const matchProps = (props, filter) => {
|
|
|
671
687
|
}
|
|
672
688
|
return true;
|
|
673
689
|
};
|
|
674
|
-
const findAll = (root, decider
|
|
690
|
+
const findAll = (root, decider, options = {
|
|
691
|
+
includeRoot: true
|
|
692
|
+
}) => {
|
|
675
693
|
const results = [];
|
|
676
|
-
|
|
694
|
+
|
|
695
|
+
// Only include the root node if the option is enabled
|
|
696
|
+
if (options.includeRoot !== false && decider(root)) {
|
|
677
697
|
results.push(root);
|
|
678
698
|
}
|
|
699
|
+
|
|
700
|
+
// Always search through children
|
|
679
701
|
root.allChildren.forEach(child => {
|
|
680
|
-
|
|
702
|
+
// When recursively searching children, we always want to include their roots
|
|
703
|
+
results.push(...findAll(child, decider, {
|
|
704
|
+
includeRoot: true
|
|
705
|
+
}));
|
|
681
706
|
});
|
|
682
707
|
return results;
|
|
683
708
|
};
|
|
684
709
|
|
|
710
|
+
// Helper to create a minimal wrapper for THREE.Object3D children of primitives
|
|
711
|
+
const createVirtualInstance = (object, parent) => {
|
|
712
|
+
// Create the virtual instance for this object
|
|
713
|
+
// we can't import the prepare method from packages/fiber/src/core/utils.tsx so we do what we can
|
|
714
|
+
const instance = {
|
|
715
|
+
root: parent.root,
|
|
716
|
+
type: object.type.toLowerCase(),
|
|
717
|
+
// Convert to lowercase to match R3F convention
|
|
718
|
+
parent,
|
|
719
|
+
children: [],
|
|
720
|
+
props: {
|
|
721
|
+
object
|
|
722
|
+
},
|
|
723
|
+
object,
|
|
724
|
+
eventCount: 0,
|
|
725
|
+
handlers: {},
|
|
726
|
+
isHidden: false
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
// Recursively process children if they exist
|
|
730
|
+
if (object.children && object.children.length > 0) {
|
|
731
|
+
const objectChildren = object.children;
|
|
732
|
+
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
733
|
+
}
|
|
734
|
+
return instance;
|
|
735
|
+
};
|
|
685
736
|
class ReactThreeTestInstance {
|
|
686
737
|
constructor(_fiber) {
|
|
687
738
|
this.getChildren = (fiber, opts = {
|
|
688
739
|
exhaustive: false
|
|
689
|
-
}) =>
|
|
690
|
-
|
|
740
|
+
}) => {
|
|
741
|
+
var _fiber$object$childre;
|
|
742
|
+
// Get standard R3F children
|
|
743
|
+
const r3fChildren = fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
|
|
744
|
+
|
|
745
|
+
// For primitives, also add THREE.js object children
|
|
746
|
+
if (fiber.type === 'primitive' && (_fiber$object$childre = fiber.object.children) != null && _fiber$object$childre.length) {
|
|
747
|
+
const threeChildren = fiber.object.children.map(child => {
|
|
748
|
+
// Create a virtual instance that wraps the THREE.js child
|
|
749
|
+
const virtualInstance = createVirtualInstance(child, fiber);
|
|
750
|
+
return wrapFiber(virtualInstance);
|
|
751
|
+
});
|
|
752
|
+
r3fChildren.push(...threeChildren);
|
|
753
|
+
return r3fChildren;
|
|
754
|
+
}
|
|
755
|
+
return r3fChildren;
|
|
756
|
+
};
|
|
757
|
+
this.findAll = decider => findAll(this, decider, {
|
|
758
|
+
includeRoot: false
|
|
759
|
+
});
|
|
691
760
|
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
692
761
|
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
693
762
|
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|
|
@@ -737,7 +806,7 @@ async function waitFor(callback, {
|
|
|
737
806
|
interval = 50,
|
|
738
807
|
timeout = 5000
|
|
739
808
|
} = {}) {
|
|
740
|
-
await
|
|
809
|
+
await react.act(async () => {
|
|
741
810
|
const start = performance.now();
|
|
742
811
|
while (true) {
|
|
743
812
|
const result = callback();
|
|
@@ -772,12 +841,12 @@ const create = async (element, options) => {
|
|
|
772
841
|
events: undefined
|
|
773
842
|
});
|
|
774
843
|
const _store = fiber._roots.get(canvas).store;
|
|
775
|
-
await
|
|
844
|
+
await react.act(async () => _root.render(element));
|
|
776
845
|
const _scene = _store.getState().scene.__r3f;
|
|
777
846
|
return {
|
|
778
847
|
scene: wrapFiber(_scene),
|
|
779
848
|
async unmount() {
|
|
780
|
-
await
|
|
849
|
+
await react.act(async () => {
|
|
781
850
|
_root.unmount();
|
|
782
851
|
});
|
|
783
852
|
},
|
|
@@ -799,7 +868,7 @@ const create = async (element, options) => {
|
|
|
799
868
|
},
|
|
800
869
|
async update(newElement) {
|
|
801
870
|
if (!fiber._roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
|
|
802
|
-
await
|
|
871
|
+
await react.act(async () => {
|
|
803
872
|
_root.render(newElement);
|
|
804
873
|
});
|
|
805
874
|
},
|
|
@@ -809,7 +878,7 @@ const create = async (element, options) => {
|
|
|
809
878
|
toGraph() {
|
|
810
879
|
return toGraph(_scene);
|
|
811
880
|
},
|
|
812
|
-
fireEvent: createEventFirer(
|
|
881
|
+
fireEvent: createEventFirer(react.act, _store),
|
|
813
882
|
async advanceFrames(frames, delta = 1) {
|
|
814
883
|
const state = _store.getState();
|
|
815
884
|
const storeSubscribers = state.internal.subscribers;
|
|
@@ -829,13 +898,13 @@ const create = async (element, options) => {
|
|
|
829
898
|
};
|
|
830
899
|
var index = {
|
|
831
900
|
create,
|
|
832
|
-
act:
|
|
901
|
+
act: react.act,
|
|
833
902
|
waitFor
|
|
834
903
|
};
|
|
835
904
|
|
|
836
905
|
Object.defineProperty(exports, 'act', {
|
|
837
906
|
enumerable: true,
|
|
838
|
-
get: function () { return
|
|
907
|
+
get: function () { return react.act; }
|
|
839
908
|
});
|
|
840
909
|
exports.ReactThreeTest = index$1;
|
|
841
910
|
exports.create = create;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { act } from 'react';
|
|
2
|
+
export { act } from 'react';
|
|
1
3
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
3
|
-
export { act } from '@react-three/fiber';
|
|
4
|
+
import { extend, createRoot, _roots, reconciler } from '@react-three/fiber';
|
|
4
5
|
|
|
5
6
|
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
6
7
|
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
@@ -20,10 +21,25 @@ const graphObjectFactory = (type, name, children) => ({
|
|
|
20
21
|
name,
|
|
21
22
|
children
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
|
|
25
|
+
// Helper function to process raw THREE.js children objects
|
|
26
|
+
function processThreeChildren(children) {
|
|
27
|
+
return children.map(object => graphObjectFactory(object.type, object.name || '', object.children && object.children.length > 0 ? processThreeChildren(object.children) : []));
|
|
28
|
+
}
|
|
29
|
+
const toGraph = object => {
|
|
30
|
+
return object.children.map(child => {
|
|
31
|
+
var _child$object$childre, _child$object$name;
|
|
32
|
+
// Process standard R3F children
|
|
33
|
+
const children = toGraph(child);
|
|
34
|
+
|
|
35
|
+
// For primitives, also include THREE.js object children
|
|
36
|
+
if (child.type === 'primitive' && (_child$object$childre = child.object.children) != null && _child$object$childre.length) {
|
|
37
|
+
const threeChildren = processThreeChildren(child.object.children);
|
|
38
|
+
children.push(...threeChildren);
|
|
39
|
+
}
|
|
40
|
+
return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', children);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
27
43
|
|
|
28
44
|
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'];
|
|
29
45
|
const enums = {
|
|
@@ -648,23 +664,76 @@ const matchProps = (props, filter) => {
|
|
|
648
664
|
}
|
|
649
665
|
return true;
|
|
650
666
|
};
|
|
651
|
-
const findAll = (root, decider
|
|
667
|
+
const findAll = (root, decider, options = {
|
|
668
|
+
includeRoot: true
|
|
669
|
+
}) => {
|
|
652
670
|
const results = [];
|
|
653
|
-
|
|
671
|
+
|
|
672
|
+
// Only include the root node if the option is enabled
|
|
673
|
+
if (options.includeRoot !== false && decider(root)) {
|
|
654
674
|
results.push(root);
|
|
655
675
|
}
|
|
676
|
+
|
|
677
|
+
// Always search through children
|
|
656
678
|
root.allChildren.forEach(child => {
|
|
657
|
-
|
|
679
|
+
// When recursively searching children, we always want to include their roots
|
|
680
|
+
results.push(...findAll(child, decider, {
|
|
681
|
+
includeRoot: true
|
|
682
|
+
}));
|
|
658
683
|
});
|
|
659
684
|
return results;
|
|
660
685
|
};
|
|
661
686
|
|
|
687
|
+
// Helper to create a minimal wrapper for THREE.Object3D children of primitives
|
|
688
|
+
const createVirtualInstance = (object, parent) => {
|
|
689
|
+
// Create the virtual instance for this object
|
|
690
|
+
// we can't import the prepare method from packages/fiber/src/core/utils.tsx so we do what we can
|
|
691
|
+
const instance = {
|
|
692
|
+
root: parent.root,
|
|
693
|
+
type: object.type.toLowerCase(),
|
|
694
|
+
// Convert to lowercase to match R3F convention
|
|
695
|
+
parent,
|
|
696
|
+
children: [],
|
|
697
|
+
props: {
|
|
698
|
+
object
|
|
699
|
+
},
|
|
700
|
+
object,
|
|
701
|
+
eventCount: 0,
|
|
702
|
+
handlers: {},
|
|
703
|
+
isHidden: false
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// Recursively process children if they exist
|
|
707
|
+
if (object.children && object.children.length > 0) {
|
|
708
|
+
const objectChildren = object.children;
|
|
709
|
+
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
710
|
+
}
|
|
711
|
+
return instance;
|
|
712
|
+
};
|
|
662
713
|
class ReactThreeTestInstance {
|
|
663
714
|
constructor(_fiber) {
|
|
664
715
|
this.getChildren = (fiber, opts = {
|
|
665
716
|
exhaustive: false
|
|
666
|
-
}) =>
|
|
667
|
-
|
|
717
|
+
}) => {
|
|
718
|
+
var _fiber$object$childre;
|
|
719
|
+
// Get standard R3F children
|
|
720
|
+
const r3fChildren = fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
|
|
721
|
+
|
|
722
|
+
// For primitives, also add THREE.js object children
|
|
723
|
+
if (fiber.type === 'primitive' && (_fiber$object$childre = fiber.object.children) != null && _fiber$object$childre.length) {
|
|
724
|
+
const threeChildren = fiber.object.children.map(child => {
|
|
725
|
+
// Create a virtual instance that wraps the THREE.js child
|
|
726
|
+
const virtualInstance = createVirtualInstance(child, fiber);
|
|
727
|
+
return wrapFiber(virtualInstance);
|
|
728
|
+
});
|
|
729
|
+
r3fChildren.push(...threeChildren);
|
|
730
|
+
return r3fChildren;
|
|
731
|
+
}
|
|
732
|
+
return r3fChildren;
|
|
733
|
+
};
|
|
734
|
+
this.findAll = decider => findAll(this, decider, {
|
|
735
|
+
includeRoot: false
|
|
736
|
+
});
|
|
668
737
|
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
669
738
|
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
670
739
|
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|