Unable to rebind ECMAScript instance from godot object in threaded worker.js
- Ngôn ngữ chính
- C++
- Star
- 1.1k
- Fork
- 80
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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) })
}
}
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với parcel.tsx, grid.tsx và worker.js, tập trung vào godot.abandon_value, godot.adopt_value và trình xử lý onmessage của worker. Tái hiện kết quả [Spatial] và xác định hành vi được mong đợi của test_function và call; done phải là một bản sửa lỗi đã được xác nhận hoặc một giới hạn được ghi lại rõ ràng, mặc dù issue không chỉ rõ trường hợp nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, typescript
- Lĩnh vực
- game-dev
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100