Unable to rebind ECMAScript instance from godot object in threaded worker.js
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
My main thread is sending out a ECMAscript class as a message to a worker thread using `godot.abandon_value` & `godot.adopt_value`, but I only get the godot object and cannot call any of the js methods on the class:
```javascript
// parcel.tsx
export default class Parcel extends godot.Spatial {
test_function(){
console.log("stuff I wana run here"))
}
}
// worker.js
onmessage = function(e) {
let parcel = godot.adopt_value(e.parcel)
console.log(parcel) // [Spatial:2362]
console.log(parcel.test_function()) // undefined
console.log(parcel.call("test_function")) // error
}
// grid.tsx
export default class Grid extends godot.Spatial {
featureLoadThread
_ready(){
let p = new Parcel()
this.featureLoadThread = new Worker('res://src/worker.js')
this.featureLoadThread.onmessage = this._onmessage.bind(this);
this.featureLoadThread.postMessage({ type:"featureLoad", parcel: godot.abandon_value(p) })
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.