@react-three/test-renderer 9.0.1 → 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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @react-three/test-renderer
|
|
2
2
|
|
|
3
|
+
## 9.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 31781e5a1fdc464cb67617cc3d7bc5d8690cd4cd: feat(RTTR): handle primitives in test-renderer and fix queries in TestInstances
|
|
8
|
+
|
|
3
9
|
## 9.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -298,7 +304,7 @@
|
|
|
298
304
|
|
|
299
305
|
### Patch Changes
|
|
300
306
|
|
|
301
|
-
- 7aa2eab: fix: remove zustand
|
|
307
|
+
- 7aa2eab: fix: remove zustand subscribe selector
|
|
302
308
|
- Updated dependencies [7aa2eab]
|
|
303
309
|
- @react-three/fiber@7.0.19
|
|
304
310
|
|
|
@@ -330,7 +336,7 @@
|
|
|
330
336
|
|
|
331
337
|
### Patch Changes
|
|
332
338
|
|
|
333
|
-
- c5645e8: fix
|
|
339
|
+
- c5645e8: fix primitive leftovers on switch
|
|
334
340
|
- Updated dependencies [c5645e8]
|
|
335
341
|
- @react-three/fiber@7.0.15
|
|
336
342
|
|
|
@@ -43,10 +43,25 @@ const graphObjectFactory = (type, name, children) => ({
|
|
|
43
43
|
name,
|
|
44
44
|
children
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
|
|
47
|
+
// Helper function to process raw THREE.js children objects
|
|
48
|
+
function processThreeChildren(children) {
|
|
49
|
+
return children.map(object => graphObjectFactory(object.type, object.name || '', object.children && object.children.length > 0 ? processThreeChildren(object.children) : []));
|
|
50
|
+
}
|
|
51
|
+
const toGraph = object => {
|
|
52
|
+
return object.children.map(child => {
|
|
53
|
+
var _child$object$childre, _child$object$name;
|
|
54
|
+
// Process standard R3F children
|
|
55
|
+
const children = toGraph(child);
|
|
56
|
+
|
|
57
|
+
// For primitives, also include THREE.js object children
|
|
58
|
+
if (child.type === 'primitive' && (_child$object$childre = child.object.children) != null && _child$object$childre.length) {
|
|
59
|
+
const threeChildren = processThreeChildren(child.object.children);
|
|
60
|
+
children.push(...threeChildren);
|
|
61
|
+
}
|
|
62
|
+
return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', children);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
50
65
|
|
|
51
66
|
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
67
|
const enums = {
|
|
@@ -671,23 +686,76 @@ const matchProps = (props, filter) => {
|
|
|
671
686
|
}
|
|
672
687
|
return true;
|
|
673
688
|
};
|
|
674
|
-
const findAll = (root, decider
|
|
689
|
+
const findAll = (root, decider, options = {
|
|
690
|
+
includeRoot: true
|
|
691
|
+
}) => {
|
|
675
692
|
const results = [];
|
|
676
|
-
|
|
693
|
+
|
|
694
|
+
// Only include the root node if the option is enabled
|
|
695
|
+
if (options.includeRoot !== false && decider(root)) {
|
|
677
696
|
results.push(root);
|
|
678
697
|
}
|
|
698
|
+
|
|
699
|
+
// Always search through children
|
|
679
700
|
root.allChildren.forEach(child => {
|
|
680
|
-
|
|
701
|
+
// When recursively searching children, we always want to include their roots
|
|
702
|
+
results.push(...findAll(child, decider, {
|
|
703
|
+
includeRoot: true
|
|
704
|
+
}));
|
|
681
705
|
});
|
|
682
706
|
return results;
|
|
683
707
|
};
|
|
684
708
|
|
|
709
|
+
// Helper to create a minimal wrapper for THREE.Object3D children of primitives
|
|
710
|
+
const createVirtualInstance = (object, parent) => {
|
|
711
|
+
// Create the virtual instance for this object
|
|
712
|
+
// we can't import the prepare method from packages/fiber/src/core/utils.tsx so we do what we can
|
|
713
|
+
const instance = {
|
|
714
|
+
root: parent.root,
|
|
715
|
+
type: object.type.toLowerCase(),
|
|
716
|
+
// Convert to lowercase to match R3F convention
|
|
717
|
+
parent,
|
|
718
|
+
children: [],
|
|
719
|
+
props: {
|
|
720
|
+
object
|
|
721
|
+
},
|
|
722
|
+
object,
|
|
723
|
+
eventCount: 0,
|
|
724
|
+
handlers: {},
|
|
725
|
+
isHidden: false
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
// Recursively process children if they exist
|
|
729
|
+
if (object.children && object.children.length > 0) {
|
|
730
|
+
const objectChildren = object.children;
|
|
731
|
+
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
732
|
+
}
|
|
733
|
+
return instance;
|
|
734
|
+
};
|
|
685
735
|
class ReactThreeTestInstance {
|
|
686
736
|
constructor(_fiber) {
|
|
687
737
|
this.getChildren = (fiber, opts = {
|
|
688
738
|
exhaustive: false
|
|
689
|
-
}) =>
|
|
690
|
-
|
|
739
|
+
}) => {
|
|
740
|
+
var _fiber$object$childre;
|
|
741
|
+
// Get standard R3F children
|
|
742
|
+
const r3fChildren = fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
|
|
743
|
+
|
|
744
|
+
// For primitives, also add THREE.js object children
|
|
745
|
+
if (fiber.type === 'primitive' && (_fiber$object$childre = fiber.object.children) != null && _fiber$object$childre.length) {
|
|
746
|
+
const threeChildren = fiber.object.children.map(child => {
|
|
747
|
+
// Create a virtual instance that wraps the THREE.js child
|
|
748
|
+
const virtualInstance = createVirtualInstance(child, fiber);
|
|
749
|
+
return wrapFiber(virtualInstance);
|
|
750
|
+
});
|
|
751
|
+
r3fChildren.push(...threeChildren);
|
|
752
|
+
return r3fChildren;
|
|
753
|
+
}
|
|
754
|
+
return r3fChildren;
|
|
755
|
+
};
|
|
756
|
+
this.findAll = decider => findAll(this, decider, {
|
|
757
|
+
includeRoot: false
|
|
758
|
+
});
|
|
691
759
|
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
692
760
|
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
693
761
|
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|
|
@@ -43,10 +43,25 @@ const graphObjectFactory = (type, name, children) => ({
|
|
|
43
43
|
name,
|
|
44
44
|
children
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
|
|
47
|
+
// Helper function to process raw THREE.js children objects
|
|
48
|
+
function processThreeChildren(children) {
|
|
49
|
+
return children.map(object => graphObjectFactory(object.type, object.name || '', object.children && object.children.length > 0 ? processThreeChildren(object.children) : []));
|
|
50
|
+
}
|
|
51
|
+
const toGraph = object => {
|
|
52
|
+
return object.children.map(child => {
|
|
53
|
+
var _child$object$childre, _child$object$name;
|
|
54
|
+
// Process standard R3F children
|
|
55
|
+
const children = toGraph(child);
|
|
56
|
+
|
|
57
|
+
// For primitives, also include THREE.js object children
|
|
58
|
+
if (child.type === 'primitive' && (_child$object$childre = child.object.children) != null && _child$object$childre.length) {
|
|
59
|
+
const threeChildren = processThreeChildren(child.object.children);
|
|
60
|
+
children.push(...threeChildren);
|
|
61
|
+
}
|
|
62
|
+
return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', children);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
50
65
|
|
|
51
66
|
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
67
|
const enums = {
|
|
@@ -671,23 +686,76 @@ const matchProps = (props, filter) => {
|
|
|
671
686
|
}
|
|
672
687
|
return true;
|
|
673
688
|
};
|
|
674
|
-
const findAll = (root, decider
|
|
689
|
+
const findAll = (root, decider, options = {
|
|
690
|
+
includeRoot: true
|
|
691
|
+
}) => {
|
|
675
692
|
const results = [];
|
|
676
|
-
|
|
693
|
+
|
|
694
|
+
// Only include the root node if the option is enabled
|
|
695
|
+
if (options.includeRoot !== false && decider(root)) {
|
|
677
696
|
results.push(root);
|
|
678
697
|
}
|
|
698
|
+
|
|
699
|
+
// Always search through children
|
|
679
700
|
root.allChildren.forEach(child => {
|
|
680
|
-
|
|
701
|
+
// When recursively searching children, we always want to include their roots
|
|
702
|
+
results.push(...findAll(child, decider, {
|
|
703
|
+
includeRoot: true
|
|
704
|
+
}));
|
|
681
705
|
});
|
|
682
706
|
return results;
|
|
683
707
|
};
|
|
684
708
|
|
|
709
|
+
// Helper to create a minimal wrapper for THREE.Object3D children of primitives
|
|
710
|
+
const createVirtualInstance = (object, parent) => {
|
|
711
|
+
// Create the virtual instance for this object
|
|
712
|
+
// we can't import the prepare method from packages/fiber/src/core/utils.tsx so we do what we can
|
|
713
|
+
const instance = {
|
|
714
|
+
root: parent.root,
|
|
715
|
+
type: object.type.toLowerCase(),
|
|
716
|
+
// Convert to lowercase to match R3F convention
|
|
717
|
+
parent,
|
|
718
|
+
children: [],
|
|
719
|
+
props: {
|
|
720
|
+
object
|
|
721
|
+
},
|
|
722
|
+
object,
|
|
723
|
+
eventCount: 0,
|
|
724
|
+
handlers: {},
|
|
725
|
+
isHidden: false
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
// Recursively process children if they exist
|
|
729
|
+
if (object.children && object.children.length > 0) {
|
|
730
|
+
const objectChildren = object.children;
|
|
731
|
+
instance.children = Array.from(objectChildren).map(child => createVirtualInstance(child, instance));
|
|
732
|
+
}
|
|
733
|
+
return instance;
|
|
734
|
+
};
|
|
685
735
|
class ReactThreeTestInstance {
|
|
686
736
|
constructor(_fiber) {
|
|
687
737
|
this.getChildren = (fiber, opts = {
|
|
688
738
|
exhaustive: false
|
|
689
|
-
}) =>
|
|
690
|
-
|
|
739
|
+
}) => {
|
|
740
|
+
var _fiber$object$childre;
|
|
741
|
+
// Get standard R3F children
|
|
742
|
+
const r3fChildren = fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
|
|
743
|
+
|
|
744
|
+
// For primitives, also add THREE.js object children
|
|
745
|
+
if (fiber.type === 'primitive' && (_fiber$object$childre = fiber.object.children) != null && _fiber$object$childre.length) {
|
|
746
|
+
const threeChildren = fiber.object.children.map(child => {
|
|
747
|
+
// Create a virtual instance that wraps the THREE.js child
|
|
748
|
+
const virtualInstance = createVirtualInstance(child, fiber);
|
|
749
|
+
return wrapFiber(virtualInstance);
|
|
750
|
+
});
|
|
751
|
+
r3fChildren.push(...threeChildren);
|
|
752
|
+
return r3fChildren;
|
|
753
|
+
}
|
|
754
|
+
return r3fChildren;
|
|
755
|
+
};
|
|
756
|
+
this.findAll = decider => findAll(this, decider, {
|
|
757
|
+
includeRoot: false
|
|
758
|
+
});
|
|
691
759
|
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
692
760
|
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
693
761
|
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|
|
@@ -20,10 +20,25 @@ const graphObjectFactory = (type, name, children) => ({
|
|
|
20
20
|
name,
|
|
21
21
|
children
|
|
22
22
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
|
|
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
|
+
});
|
|
41
|
+
};
|
|
27
42
|
|
|
28
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'];
|
|
29
44
|
const enums = {
|
|
@@ -648,23 +663,76 @@ const matchProps = (props, filter) => {
|
|
|
648
663
|
}
|
|
649
664
|
return true;
|
|
650
665
|
};
|
|
651
|
-
const findAll = (root, decider
|
|
666
|
+
const findAll = (root, decider, options = {
|
|
667
|
+
includeRoot: true
|
|
668
|
+
}) => {
|
|
652
669
|
const results = [];
|
|
653
|
-
|
|
670
|
+
|
|
671
|
+
// Only include the root node if the option is enabled
|
|
672
|
+
if (options.includeRoot !== false && decider(root)) {
|
|
654
673
|
results.push(root);
|
|
655
674
|
}
|
|
675
|
+
|
|
676
|
+
// Always search through children
|
|
656
677
|
root.allChildren.forEach(child => {
|
|
657
|
-
|
|
678
|
+
// When recursively searching children, we always want to include their roots
|
|
679
|
+
results.push(...findAll(child, decider, {
|
|
680
|
+
includeRoot: true
|
|
681
|
+
}));
|
|
658
682
|
});
|
|
659
683
|
return results;
|
|
660
684
|
};
|
|
661
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
|
+
};
|
|
662
712
|
class ReactThreeTestInstance {
|
|
663
713
|
constructor(_fiber) {
|
|
664
714
|
this.getChildren = (fiber, opts = {
|
|
665
715
|
exhaustive: false
|
|
666
|
-
}) =>
|
|
667
|
-
|
|
716
|
+
}) => {
|
|
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;
|
|
730
|
+
}
|
|
731
|
+
return r3fChildren;
|
|
732
|
+
};
|
|
733
|
+
this.findAll = decider => findAll(this, decider, {
|
|
734
|
+
includeRoot: false
|
|
735
|
+
});
|
|
668
736
|
this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
|
|
669
737
|
this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
|
|
670
738
|
this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
|