I've been working on a project that involves using threejs to draw a filled polygon based on its vertices. Initially, I started with a square and was able to get it working perfectly on its own. However, the real issue arose when I tried to integrate this geometry into my main project, which utilizes third-party libraries also using threejs. One of the libraries runs a check
array.buffer instanceof ArrayBuffer
which should return true, but strangely it returns false even though I have confirmed it as true after creation. Even in debugging, the ArrayBuffer does not seem detached, indicating that something is causing the inheritance chain to break.
Given the uncertainty of where this inheritance break is happening, my only solution that comes to mind is to provide a buffer from my custom class that extends ArrayBuffer and overrides the instanceof
method.
Drawing inspiration from this inheritance example
class Float32ArrayBuffer extends ArrayBuffer {
static [Symbol.hasInstance](instance: any) {
var regularCheck = this instanceof instance;
console.log('asdffdsa')
console.log(instance)
return regularCheck;
}
}
Unfortunately, the function within this class never seems to execute. Even with a breakpoint before the instanceof
check, it correctly shows my type. I'm not sure if there's an alternative approach to overriding this behavior or if there's a way to address the root cause of the issue. Any assistance would be greatly appreciated. Thank you