@@ -4,6 +4,7 @@ import { ReactThreeFiber, extend, useFrame } from '@react-three/fiber'
4
4
import mergeRefs from 'react-merge-refs'
5
5
import Composer from 'react-composer'
6
6
import { ForwardRefComponent } from '../helpers/ts-utils'
7
+ import { setUpdateRange } from '../helpers/deprecated'
7
8
8
9
declare global {
9
10
namespace JSX {
@@ -129,18 +130,18 @@ export const Instances: ForwardRefComponent<InstancesProps, InstancedMesh> = /*
129
130
parentRef . current . instanceMatrix . needsUpdate = true
130
131
} )
131
132
133
+ let iterations = 0
132
134
let count = 0
133
- let updateRange = 0
134
135
useFrame ( ( ) => {
135
- if ( frames === Infinity || count < frames ) {
136
+ if ( frames === Infinity || iterations < frames ) {
136
137
parentRef . current . updateMatrix ( )
137
138
parentRef . current . updateMatrixWorld ( )
138
139
parentMatrix . copy ( parentRef . current . matrixWorld ) . invert ( )
139
140
140
- updateRange = Math . min ( limit , range !== undefined ? range : limit , instances . length )
141
- parentRef . current . count = updateRange
142
- parentRef . current . instanceMatrix . updateRange . count = updateRange * 16
143
- parentRef . current . instanceColor . updateRange . count = updateRange * 3
141
+ count = Math . min ( limit , range !== undefined ? range : limit , instances . length )
142
+ parentRef . current . count = count
143
+ setUpdateRange ( parentRef . current . instanceMatrix , { offset : 0 , count : count * 16 } )
144
+ setUpdateRange ( parentRef . current . instanceColor , { offset : 0 , count : count * 3 } )
144
145
145
146
for ( let i = 0 ; i < instances . length ; i ++ ) {
146
147
const instance = instances [ i ] . current
@@ -153,7 +154,7 @@ export const Instances: ForwardRefComponent<InstancesProps, InstancedMesh> = /*
153
154
instance . color . toArray ( colors , i * 3 )
154
155
parentRef . current . instanceColor . needsUpdate = true
155
156
}
156
- count ++
157
+ iterations ++
157
158
}
158
159
} )
159
160
0 commit comments