[Feature Request] Translating JavaScript classes to GLSL
- 主要言語
- JavaScript
- スター
- 15.5k
- フォーク
- 663
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I recently discovered a simple way to translate JavaScript classes into GLSL., but I'm not sure if gpu.js can do this yet. This is a JavaScript class:
```
class Circle{
constructor(radius){
this.radius = 1;
}
area(){
return Math.PI*this.radius*this.radius;
}
}
```
In GLSL, the same class could be defined in this way:
```
#define PI 3.1415926538
struct Circle{
float radius;
};
Circle new(float radius){
Circle self; //"this" is a reserved word in GLSL, so "self" is used here instead
self.radius = 1.0;
return self;
}
float area(Circle self){
return PI*self.radius*self.radius;
}
```
And then an "instance" of the class can be initialized:
```
Circle anInstance = new(3.0);
float the_area = area(anInstance);
```
Since functions in GLSL can be overloaded, it would be possible to define constructors for multiple "classes" in this way.
コントリビューションガイド
調査の方向性
ファイル、テスト、エントリーポイントは指定されていません。まず、gpu.js の現在の JavaScript から GLSL への変換サポートを特定し、クラス構文、コンストラクター、メソッド、インスタンスが対象範囲に含まれるかどうかを確認してください。クラスの例に対する動作する変換と、それに相当する GLSL 出力について、合意された設計が完成していれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- computer-graphics
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100