You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you set onBeforeCompile to itself or to that of another derived material, the setter for that property will assign it to this[privateBeforeCompileProp], and the function will call itself infinitely.
The reason this came up for me is that I needed to clone some materials, including the callbacks. Three.js Material .clone()does not copy callbacks, so I had to write my own code to do it. I tried checking with Object.hasOwn to avoid copying the callback function if it's on the prototype, but it doesn't work here. So I can't find a good workaround.
You could easily check against setting the function to itself by making a change like this:
...but that won't work if you copy it over from another material. Another option might be to put every internal onBeforeCompile function in a shared WeakSet and check that. Or tag it somehow by adding a property.
The text was updated successfully, but these errors were encountered:
If you set
onBeforeCompile
to itself or to that of another derived material, the setter for that property will assign it tothis[privateBeforeCompileProp]
, and the function will call itself infinitely.For example:
The reason this came up for me is that I needed to clone some materials, including the callbacks. Three.js Material
.clone()
does not copy callbacks, so I had to write my own code to do it. I tried checking withObject.hasOwn
to avoid copying the callback function if it's on the prototype, but it doesn't work here. So I can't find a good workaround.You could easily check against setting the function to itself by making a change like this:
...but that won't work if you copy it over from another material. Another option might be to put every internal
onBeforeCompile
function in a shared WeakSet and check that. Or tag it somehow by adding a property.The text was updated successfully, but these errors were encountered: