[Feature Request] Translating JavaScript classes to GLSL
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
没有指定文件、测试或入口点。首先定位 gpu.js 当前对 JavaScript 到 GLSL 转换的支持,并确定类语法、构造函数、方法和实例是否在范围内。完成的标准是:为类示例达成一致的设计并实现可工作的转换,同时生成等效的 GLSL 输出。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- JavaScript
- 星标
- 15.5k
- 派生
- 663
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
gpujs/gpu.js 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 65/100
-
WebGL backend silently returns all zeros for long-running kernels (no GL error, no context loss) 未关闭
难度 5/5 一周以上 新手友好度 42/100
-
难度 5/5 一周以上 新手友好度 20/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 25/100
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 78/100
Mintplex-Labs/anything-llm#6490 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
[quality] workflow-scripts guard reads test:unit:coverage as skipping the unit suite, blocking #632 未关闭agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
area-clientside-dartpad
难度 2/5 1-3 小时 新手友好度 62/100