@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/README.md CHANGED
@@ -1,61 +1,61 @@
1
- # React Three Test Renderer ⚛️🔼🧪
2
-
3
- [![Version](https://img.shields.io/npm/v/@react-three/test-renderer?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/@react-three/test-renderer)
4
- [![Downloads](https://img.shields.io/npm/dt/@react-three/test-renderer.svg?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/@react-three/test-renderer)
5
- [![Twitter](https://img.shields.io/twitter/follow/pmndrs?label=%40pmndrs&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000)](https://twitter.com/pmndrs)
6
- [![Twitter](https://img.shields.io/twitter/follow/_josh_ellis_?label=%40_josh_ellis_&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000)](https://twitter.com/_josh_ellis_)
7
- [![Discord](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=000000)](https://discord.gg/ZZjjNvJ)
8
-
9
- `@react-three/test-renderer` is a React testing <a href="https://reactjs.org/docs/codebase-overview.html#renderers">renderer</a> for threejs in node.
10
-
11
- ```bash
12
- yarn add @react-three/fiber three
13
- yarn add -D @react-three/test-renderer
14
- ```
15
-
16
- ---
17
-
18
- ## The problem
19
-
20
- You've written a complex and amazing webgl experience using [`@react-three/fiber`](https://github.com/pmndrs/react-three-fiber) and you want to test it to make sure it works even after you add even more features.
21
-
22
- You go to use `react-dom` but hang on, `THREE` elements aren't in the DOM! You decide to use `@react-three/test-renderer` you can see the container & the canvas but you can't see the tree for the scene!? That's because `@react-three/fiber` renders to a different react root with it's own reconciler.
23
-
24
- ## The solution
25
-
26
- You use `@react-three/test-renderer` ⚛️-🔼-🧪, an experimental React renderer using `@react-three/fiber` under the hood to expose the scene graph wrapped in a test instance providing helpful utilities to test with.
27
-
28
- Essentially, this package makes it easy to grab a snapshot of the Scene Graph rendered by `three` without the need for webgl & browser.
29
-
30
- ---
31
-
32
- ## Usage
33
-
34
- RTTR is testing library agnostic, so we hope that it works with libraries such as [`jest`](https://jestjs.io/), [`jasmine`](https://jasmine.github.io/) etc.
35
-
36
- ```tsx
37
- import ReactThreeTestRenderer from '@react-three/test-renderer'
38
-
39
- const renderer = await ReactThreeTestRenderer.create(
40
- <mesh>
41
- <boxGeometry args={[2, 2]} />
42
- <meshStandardMaterial
43
- args={[
44
- {
45
- color: 0x0000ff,
46
- },
47
- ]}
48
- />
49
- </mesh>,
50
- )
51
-
52
- // assertions using the TestInstance & Scene Graph
53
- console.log(renderer.toGraph())
54
- ```
55
-
56
- ---
57
-
58
- ## API
59
-
60
- - [React Three Test Renderer API](/packages/test-renderer/markdown/rttr.md)
61
- - [React Three Test Instance API](/packages/test-renderer/markdown/rttr-instance.md)
1
+ # React Three Test Renderer ⚛️🔼🧪
2
+
3
+ [![Version](https://img.shields.io/npm/v/@react-three/test-renderer?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/@react-three/test-renderer)
4
+ [![Downloads](https://img.shields.io/npm/dt/@react-three/test-renderer.svg?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/@react-three/test-renderer)
5
+ [![Twitter](https://img.shields.io/twitter/follow/pmndrs?label=%40pmndrs&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000)](https://twitter.com/pmndrs)
6
+ [![Twitter](https://img.shields.io/twitter/follow/_josh_ellis_?label=%40_josh_ellis_&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000)](https://twitter.com/_josh_ellis_)
7
+ [![Discord](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=000000)](https://discord.gg/ZZjjNvJ)
8
+
9
+ `@react-three/test-renderer` is a React testing <a href="https://reactjs.org/docs/codebase-overview.html#renderers">renderer</a> for threejs in node.
10
+
11
+ ```bash
12
+ yarn add @react-three/fiber three
13
+ yarn add -D @react-three/test-renderer
14
+ ```
15
+
16
+ ---
17
+
18
+ ## The problem
19
+
20
+ You've written a complex and amazing webgl experience using [`@react-three/fiber`](https://github.com/pmndrs/react-three-fiber) and you want to test it to make sure it works even after you add even more features.
21
+
22
+ You go to use `react-dom` but hang on, `THREE` elements aren't in the DOM! You decide to use `@react-three/test-renderer` you can see the container & the canvas but you can't see the tree for the scene!? That's because `@react-three/fiber` renders to a different react root with it's own reconciler.
23
+
24
+ ## The solution
25
+
26
+ You use `@react-three/test-renderer` ⚛️-🔼-🧪, an experimental React renderer using `@react-three/fiber` under the hood to expose the scene graph wrapped in a test instance providing helpful utilities to test with.
27
+
28
+ Essentially, this package makes it easy to grab a snapshot of the Scene Graph rendered by `three` without the need for webgl & browser.
29
+
30
+ ---
31
+
32
+ ## Usage
33
+
34
+ RTTR is testing library agnostic, so we hope that it works with libraries such as [`jest`](https://jestjs.io/), [`jasmine`](https://jasmine.github.io/) etc.
35
+
36
+ ```tsx
37
+ import ReactThreeTestRenderer from '@react-three/test-renderer'
38
+
39
+ const renderer = await ReactThreeTestRenderer.create(
40
+ <mesh>
41
+ <boxGeometry args={[2, 2]} />
42
+ <meshStandardMaterial
43
+ args={[
44
+ {
45
+ color: 0x0000ff,
46
+ },
47
+ ]}
48
+ />
49
+ </mesh>,
50
+ )
51
+
52
+ // assertions using the TestInstance & Scene Graph
53
+ console.log(renderer.toGraph())
54
+ ```
55
+
56
+ ---
57
+
58
+ ## API
59
+
60
+ - [React Three Test Renderer API](/packages/test-renderer/markdown/rttr.md)
61
+ - [React Three Test Instance API](/packages/test-renderer/markdown/rttr-instance.md)
@@ -1,22 +1,22 @@
1
- import type * as THREE from 'three';
2
- import type { Instance } from '@react-three/fiber';
3
- import type { Obj } from "./types/internal.js";
4
- export declare class ReactThreeTestInstance<TObject extends THREE.Object3D = THREE.Object3D> {
5
- _fiber: Instance<TObject>;
6
- constructor(fiber: Instance<TObject>);
7
- get fiber(): Instance<TObject>;
8
- get instance(): TObject;
9
- get type(): string;
10
- get props(): Obj;
11
- get parent(): ReactThreeTestInstance | null;
12
- get children(): ReactThreeTestInstance[];
13
- get allChildren(): ReactThreeTestInstance[];
14
- private getChildren;
15
- findAll: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance[];
16
- find: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance;
17
- findByType: (type: string) => ReactThreeTestInstance;
18
- findAllByType: (type: string) => ReactThreeTestInstance[];
19
- findByProps: (props: Obj) => ReactThreeTestInstance;
20
- findAllByProps: (props: Obj) => ReactThreeTestInstance[];
21
- }
22
- export declare const wrapFiber: (fiber: Instance) => ReactThreeTestInstance;
1
+ import type * as THREE from 'three';
2
+ import type { Instance } from '@react-three/fiber';
3
+ import type { Obj } from "./types/internal.js";
4
+ export declare class ReactThreeTestInstance<TObject extends THREE.Object3D = THREE.Object3D> {
5
+ _fiber: Instance<TObject>;
6
+ constructor(fiber: Instance<TObject>);
7
+ get fiber(): Instance<TObject>;
8
+ get instance(): TObject;
9
+ get type(): string;
10
+ get props(): Obj;
11
+ get parent(): ReactThreeTestInstance | null;
12
+ get children(): ReactThreeTestInstance[];
13
+ get allChildren(): ReactThreeTestInstance[];
14
+ private getChildren;
15
+ findAll: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance[];
16
+ find: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance;
17
+ findByType: (type: string) => ReactThreeTestInstance;
18
+ findAllByType: (type: string) => ReactThreeTestInstance[];
19
+ findByProps: (props: Obj) => ReactThreeTestInstance;
20
+ findAllByProps: (props: Obj) => ReactThreeTestInstance[];
21
+ }
22
+ export declare const wrapFiber: (fiber: Instance) => ReactThreeTestInstance;
@@ -1,5 +1,5 @@
1
- export interface WaitOptions {
2
- interval?: number;
3
- timeout?: number;
4
- }
5
- export declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
1
+ export interface WaitOptions {
2
+ interval?: number;
3
+ timeout?: number;
4
+ }
5
+ export declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
@@ -1,14 +1,14 @@
1
- import * as React from 'react';
2
- import { act } from '@react-three/fiber';
3
- import type { CreateOptions, Renderer } from "./types/public.js";
4
- import { waitFor, WaitOptions } from "./helpers/waitFor.js";
5
- declare const create: (element: React.ReactNode, options?: Partial<CreateOptions>) => Promise<Renderer>;
6
- export { create, act, waitFor };
7
- export type { WaitOptions };
8
- export * as ReactThreeTest from "./types/index.js";
9
- declare const _default: {
10
- create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
11
- act: import("@react-three/fiber").Act;
12
- waitFor: typeof waitFor;
13
- };
14
- export default _default;
1
+ import * as React from 'react';
2
+ import { act } from 'react';
3
+ import type { CreateOptions, Renderer } from "./types/public.js";
4
+ import { waitFor, WaitOptions } from "./helpers/waitFor.js";
5
+ declare const create: (element: React.ReactNode, options?: Partial<CreateOptions>) => Promise<Renderer>;
6
+ export { create, act, waitFor };
7
+ export type { WaitOptions };
8
+ export * as ReactThreeTest from "./types/index.js";
9
+ declare const _default: {
10
+ create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
11
+ act: typeof React.act;
12
+ waitFor: typeof waitFor;
13
+ };
14
+ export default _default;
@@ -1 +1 @@
1
- export * from "./public.js";
1
+ export * from "./public.js";
@@ -1,20 +1,20 @@
1
- export type CreateCanvasParameters = {
2
- beforeReturn?: (canvas: HTMLCanvasElement) => void;
3
- width?: number;
4
- height?: number;
5
- };
6
- export interface Obj {
7
- [key: string]: any;
8
- }
9
- /**
10
- * this is an empty object of any,
11
- * the data is passed to a new event
12
- * and subsequently passed to the
13
- * event handler you're calling
14
- */
15
- export type MockEventData = {
16
- [key: string]: any;
17
- };
18
- export interface TestInstanceChildOpts {
19
- exhaustive: boolean;
20
- }
1
+ export type CreateCanvasParameters = {
2
+ beforeReturn?: (canvas: HTMLCanvasElement) => void;
3
+ width?: number;
4
+ height?: number;
5
+ };
6
+ export interface Obj {
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * this is an empty object of any,
11
+ * the data is passed to a new event
12
+ * and subsequently passed to the
13
+ * event handler you're calling
14
+ */
15
+ export type MockEventData = {
16
+ [key: string]: any;
17
+ };
18
+ export interface TestInstanceChildOpts {
19
+ exhaustive: boolean;
20
+ }
@@ -1,38 +1,38 @@
1
- import type { Camera, RenderProps } from '@react-three/fiber';
2
- import { ReactThreeTestInstance } from "../createTestInstance.js";
3
- import type { MockEventData, CreateCanvasParameters } from "./internal.js";
4
- export { ReactThreeTestInstance };
5
- export type MockSyntheticEvent = {
6
- camera: Camera;
7
- stopPropagation: () => void;
8
- target: ReactThreeTestInstance;
9
- currentTarget: ReactThreeTestInstance;
10
- sourceEvent: MockEventData;
11
- [key: string]: any;
12
- };
13
- export type CreateOptions = CreateCanvasParameters & RenderProps<HTMLCanvasElement>;
14
- export type Renderer = {
15
- scene: ReactThreeTestInstance;
16
- unmount: () => Promise<void>;
17
- getInstance: () => null | unknown;
18
- update: (el: React.ReactNode) => Promise<void>;
19
- toTree: () => Tree | undefined;
20
- toGraph: () => SceneGraph | undefined;
21
- fireEvent: (element: ReactThreeTestInstance, handler: string, data?: MockEventData) => Promise<any>;
22
- advanceFrames: (frames: number, delta: number | number[]) => Promise<void>;
23
- };
24
- export interface SceneGraphItem {
25
- type: string;
26
- name: string;
27
- children: SceneGraphItem[] | null;
28
- }
29
- export type SceneGraph = SceneGraphItem[];
30
- export interface TreeNode {
31
- type: string;
32
- props: {
33
- [key: string]: any;
34
- };
35
- children: TreeNode[];
36
- }
37
- export type Tree = TreeNode[];
38
- export type { Act } from '@react-three/fiber';
1
+ import type { Camera, RenderProps } from '@react-three/fiber';
2
+ import { ReactThreeTestInstance } from "../createTestInstance.js";
3
+ import type { MockEventData, CreateCanvasParameters } from "./internal.js";
4
+ export { ReactThreeTestInstance };
5
+ export type MockSyntheticEvent = {
6
+ camera: Camera;
7
+ stopPropagation: () => void;
8
+ target: ReactThreeTestInstance;
9
+ currentTarget: ReactThreeTestInstance;
10
+ sourceEvent: MockEventData;
11
+ [key: string]: any;
12
+ };
13
+ export type CreateOptions = CreateCanvasParameters & RenderProps<HTMLCanvasElement>;
14
+ export type Renderer = {
15
+ scene: ReactThreeTestInstance;
16
+ unmount: () => Promise<void>;
17
+ getInstance: () => null | unknown;
18
+ update: (el: React.ReactNode) => Promise<void>;
19
+ toTree: () => Tree | undefined;
20
+ toGraph: () => SceneGraph | undefined;
21
+ fireEvent: (element: ReactThreeTestInstance, handler: string, data?: MockEventData) => Promise<any>;
22
+ advanceFrames: (frames: number, delta: number | number[]) => Promise<void>;
23
+ };
24
+ export interface SceneGraphItem {
25
+ type: string;
26
+ name: string;
27
+ children: SceneGraphItem[] | null;
28
+ }
29
+ export type SceneGraph = SceneGraphItem[];
30
+ export interface TreeNode {
31
+ type: string;
32
+ props: {
33
+ [key: string]: any;
34
+ };
35
+ children: TreeNode[];
36
+ }
37
+ export type Tree = TreeNode[];
38
+ export type { Act } from '@react-three/fiber';
@@ -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
- 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
- });
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
- if (decider(root)) {
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
- results.push(...findAll(child, decider));
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
- }) => fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
690
- this.findAll = decider => findAll(this, decider);
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 fiber.act(async () => {
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 fiber.act(async () => _root.render(element));
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 fiber.act(async () => {
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 fiber.act(async () => {
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(fiber.act, _store),
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: fiber.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 fiber.act; }
907
+ get: function () { return react.act; }
839
908
  });
840
909
  exports.ReactThreeTest = index$1;
841
910
  exports.create = create;