godotjs / godotjs/javascript

Unable to rebind ECMAScript instance from godot object in threaded worker.js

Aperta
#108 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
investigation
Lingua principale
C++
Stelle
1.1k
Fork
80
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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) })
}
}
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.