@@ -34,7 +34,7 @@ export function invalidateInstance(instance: TresObject) {
34
34
35
35
export const nodeOps : ( ) => RendererOptions < TresObject , TresObject | null > = ( ) => {
36
36
let scene : TresScene | null = null
37
- return { createElement ( tag , _isSVG , _anchor , props ) : TresObject | null {
37
+ function createElement ( tag , _isSVG , _anchor , props ) : TresObject | null {
38
38
if ( ! props ) props = { }
39
39
40
40
if ( ! props . args ) {
@@ -92,8 +92,8 @@ export const nodeOps: () => RendererOptions<TresObject, TresObject | null> = ()
92
92
}
93
93
94
94
return instance as TresObject
95
- } ,
96
- insert ( child , parent ) {
95
+ }
96
+ function insert ( child , parent ) {
97
97
if ( ! child ) return
98
98
99
99
if ( parent && parent . isScene ) {
@@ -131,8 +131,8 @@ export const nodeOps: () => RendererOptions<TresObject, TresObject | null> = ()
131
131
parentObject [ child . attach ] = child
132
132
}
133
133
}
134
- } ,
135
- remove ( node ) {
134
+ }
135
+ function remove ( node ) {
136
136
if ( ! node ) return
137
137
const ctx = node . __tres
138
138
// remove is only called on the node being removed and not on child nodes.
@@ -187,14 +187,14 @@ export const nodeOps: () => RendererOptions<TresObject, TresObject | null> = ()
187
187
188
188
}
189
189
190
- } ,
191
- patchProp ( node , prop , prevValue , nextValue ) {
190
+ }
191
+ function patchProp ( node , prop , prevValue , nextValue ) {
192
192
if ( node ) {
193
193
let root = node
194
194
let key = prop
195
195
if ( node . __tres . primitive && key === 'object' && prevValue !== null ) {
196
196
// If the prop 'object' is changed, we need to re-instance the object and swap the old one with the new one
197
- const newInstance = nodeOps . createElement ( 'primitive' , undefined , undefined , {
197
+ const newInstance = createElement ( 'primitive' , undefined , undefined , {
198
198
object : nextValue ,
199
199
} )
200
200
for ( const subkey in newInstance ) {
@@ -285,23 +285,26 @@ export const nodeOps: () => RendererOptions<TresObject, TresObject | null> = ()
285
285
286
286
invalidateInstance ( node as TresObject )
287
287
}
288
- } ,
288
+ }
289
289
290
- parentNode ( node ) {
290
+ function parentNode ( node ) {
291
291
return node ?. parent || null
292
- } ,
293
- createText : ( ) => noop ( 'createText' ) ,
294
- createComment : ( ) => noop ( 'createComment' ) ,
295
-
296
- setText : ( ) => noop ( 'setText' ) ,
297
-
298
- setElementText : ( ) => noop ( 'setElementText' ) ,
299
- nextSibling : ( ) => noop ( 'nextSibling' ) ,
300
-
301
- querySelector : ( ) => noop ( 'querySelector' ) ,
302
-
303
- setScopeId : ( ) => noop ( 'setScopeId' ) ,
304
- cloneNode : ( ) => noop ( 'cloneNode' ) ,
292
+ }
305
293
306
- insertStaticContent : ( ) => noop ( 'insertStaticContent' ) }
294
+ return {
295
+ insert,
296
+ remove,
297
+ createElement,
298
+ patchProp,
299
+ parentNode,
300
+ createText : ( ) => noop ( 'createText' ) ,
301
+ createComment : ( ) => noop ( 'createComment' ) ,
302
+ setText : ( ) => noop ( 'setText' ) ,
303
+ setElementText : ( ) => noop ( 'setElementText' ) ,
304
+ nextSibling : ( ) => noop ( 'nextSibling' ) ,
305
+ querySelector : ( ) => noop ( 'querySelector' ) ,
306
+ setScopeId : ( ) => noop ( 'setScopeId' ) ,
307
+ cloneNode : ( ) => noop ( 'cloneNode' ) ,
308
+ insertStaticContent : ( ) => noop ( 'insertStaticContent' ) ,
309
+ }
307
310
}
0 commit comments