{"id":26071728,"url":"https://github.com/hpugis/GEngine","last_synced_at":"2025-03-09T00:04:27.307Z","repository":{"id":131758133,"uuid":"551830160","full_name":"GEngine-js/GEngine","owner":"GEngine-js","description":"Rendering engine based on webgpu","archived":false,"fork":false,"pushed_at":"2023-11-17T07:30:18.000Z","size":38480,"stargazers_count":125,"open_issues_count":5,"forks_count":9,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-05-21T12:52:09.976Z","etag":null,"topics":["gpu","webgl","webgpu","wgsl"],"latest_commit_sha":null,"homepage":"https://gengine-js.github.io/Docs/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GEngine-js.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-15T07:16:41.000Z","updated_at":"2024-06-04T15:07:53.565Z","dependencies_parsed_at":"2024-06-04T15:07:38.731Z","dependency_job_id":"efdd9390-f655-4c4c-b2c9-0fb99c4c441c","html_url":"https://github.com/GEngine-js/GEngine","commit_stats":null,"previous_names":["hpugis/gengine"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GEngine-js%2FGEngine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GEngine-js%2FGEngine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GEngine-js%2FGEngine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GEngine-js%2FGEngine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GEngine-js","download_url":"https://codeload.github.com/GEngine-js/GEngine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242623570,"owners_count":20159706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpu","webgl","webgpu","wgsl"],"created_at":"2025-03-09T00:01:35.414Z","updated_at":"2025-03-09T00:04:27.293Z","avatar_url":"https://github.com/GEngine-js.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["Safari"],"readme":"# GEngine.js\n\nWebGPU Engine\n\n## install\n\n```shell\n$ yarn add @gengine-js/gengine\n```\n\n## develop\n\n```shell\n# install\n$ yarn\n\n# dev\n$ yarn dev\n\n# build\n$ yarn build\n```\n\n## Usage\n\n```html\n\u003cscript type=\"module\"\u003e\n\timport {\n\t\tMesh,\n\t\tPerspectiveCamera,\n\t\tScene,\n\t\tPhongMaterial,\n\t\tVector3,\n\t\tColor,\n\t\tSpotLight,\n\t\tPointLight,\n\t\tSphereGeometry,\n\t\tOrbitControl\n\t} from \"../dist/index.js\";\n\tconst init = async () =\u003e {\n\t\tconst geometry = new SphereGeometry(10);\n\n\t\tconst phongMaterial = new PhongMaterial();\n\t\tphongMaterial.color = new Color(1.0, 0.0, 0.0);\n\n\t\tconst primitive = new Mesh(geometry, phongMaterial);\n\n\t\tprimitive.rotateX(-Math.PI / 2);\n\n\t\tconst camera = new PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.01, 1000);\n\n\t\tcamera.position.set(0, 20, 0);\n\n\t\tcamera.lookAt(0, 0, 0);\n\n\t\tconst spotLight = new SpotLight(new Vector3(1.0, 1.0, 1.0), 1.0, 15, 6, 1);\n\t\tspotLight.position = new Vector3(0, 20, 0);\n\n\t\tconst scene = new Scene({ container: \"app\" });\n\n\t\taxes.scale.set(10, 10, 10);\n\n\t\tconst control = new OrbitControl(camera, document.getElementById(\"app\"));\n\n\t\tscene.add(primitive);\n\n\t\tscene.setCamera(camera);\n\n\t\tscene.add(pointLight);\n\n\t\twindow.addEventListener(\"resize\", onWindowResize);\n\n\t\tfunction onWindowResize() {\n\t\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\t\tscene.resize(window.innerWidth, window.innerHeight);\n\t\t}\n\t\tfunction animate() {\n\t\t\tcontrol.update();\n\t\t\trequestAnimationFrame(animate);\n\t\t\tscene.render();\n\t\t}\n\t\tanimate();\n\t};\n\tinit();\n\u003c/script\u003e\n```\n\n## Native\n\n```html\n\u003cscript type=\"module\"\u003e\n\timport { Model, Context, Texture, RenderTarget, Attachment } from \"webgpu-gengine-js\";\n\timport { mat4, vec3 } from \"gl-matrix\";\n\tconst init = async () =\u003e {\n\t\t//init context\n\t\tconst context = new Context({\n\t\t\tcanvas: null,\n\t\t\tcontainer: document.getElementById(\"app\"),\n\t\t\tpixelRatio: 1\n\t\t});\n\t\tconst { canvas, presentationFormat } = context;\n\t\tawait context.init();\n\t\tconst { width, height, depth } = context.presentationSize;\n\t\tconst colorAttachment = new Attachment(\n\t\t\t{ r: 0.0, g: 0.0, b: 0.0, a: 0 },\n\t\t\t{\n\t\t\t\ttextureView: () =\u003e {\n\t\t\t\t\treturn context.context.getCurrentTexture().createView();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\tconst depthTexture = new Texture({\n\t\t\tlabel: \"resolveDepth\",\n\t\t\tsize: { width, height, depth },\n\t\t\tformat: \"depth24plus\",\n\t\t\tusage: GPUTextureUsage.RENDER_ATTACHMENT\n\t\t});\n\t\tconst depthAttachment = new Attachment(1.0, { texture: depthTexture });\n\t\t//fbo\n\t\tconst canvasRenderTarget = new RenderTarget(\"render\", [colorAttachment], depthAttachment);\n\t\tconst aspect = canvas.width / canvas.height;\n\t\tconst projectionMatrix = mat4.perspective([], (2 * Math.PI) / 5, aspect, 1, 100.0);\n\t\tconst modelViewProjectionMatrix = mat4.create();\n\t\tconst model = new Model({\n\t\t\tshaderId: \"model\",\n\t\t\tfrag: `\n                            @fragment\n                            fn main(@location(0) fragPosition: vec4\u003cf32\u003e) -\u003e @location(0) vec4\u003cf32\u003e {\n                                 return fragPosition;\n                            }\n                        `,\n\t\t\tvert: `\n                            struct Uniforms {\n                                modelViewProjectionMatrix : mat4x4\u003cf32\u003e,\n                            }\n                            @binding(0) @group(0) var\u003cuniform\u003e uniforms : Uniforms;\n                            struct VertexOutput {\n                                @builtin(position) Position : vec4\u003cf32\u003e,\n                                @location(0) fragPosition: vec4\u003cf32\u003e,\n                            }\n                            @vertex\n                            fn main(@location(0) position : vec4\u003cf32\u003e,@location(1) color : vec4\u003cf32\u003e) -\u003e VertexOutput {\n                                var output : VertexOutput;\n                                output.Position = uniforms.modelViewProjectionMatrix * position;\n                                output.fragPosition = 0.5 * (position + vec4(1.0, 1.0, 1.0, 1.0));\n                                return output;\n                            }\n                        `,\n\t\t\tvertexBuffers: [\n\t\t\t\t{\n\t\t\t\t\tstepMode: \"vertex\", //optional\n\t\t\t\t\tuid: \"vertAttr\", //must\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tposition: { size: 4, value: positions },\n\t\t\t\t\t\tcolor: { size: 4, value: colors }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\tuniformBuffers: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"uniform\",\n\t\t\t\t\tuid: \"systemMatrix\",\n\t\t\t\t\tuniforms: {\n\t\t\t\t\t\tmodelViewProjectionMatrix: {\n\t\t\t\t\t\t\ttype: \"mat4\",\n\t\t\t\t\t\t\tvalue: () =\u003e {\n\t\t\t\t\t\t\t\tlet viewMatrix = mat4.identity([]);\n\t\t\t\t\t\t\t\tmat4.translate(viewMatrix, viewMatrix, vec3.fromValues(0, 0, -4));\n\t\t\t\t\t\t\t\tconst now = Date.now() / 1000;\n\t\t\t\t\t\t\t\tmat4.rotate(\n\t\t\t\t\t\t\t\t\tviewMatrix,\n\t\t\t\t\t\t\t\t\tviewMatrix,\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\tvec3.fromValues(Math.sin(now), Math.cos(now), 0)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tmat4.multiply(modelViewProjectionMatrix, projectionMatrix, viewMatrix);\n\t\t\t\t\t\t\t\treturn modelViewProjectionMatrix;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\trenderState: {\n\t\t\t\ttargets: [\n\t\t\t\t\t{\n\t\t\t\t\t\tformat: presentationFormat\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tprimitive: {\n\t\t\t\t\ttopology: \"triangle-list\",\n\t\t\t\t\tcullMode: \"back\"\n\t\t\t\t},\n\t\t\t\tdepthStencil: {\n\t\t\t\t\tdepthWriteEnabled: true,\n\t\t\t\t\tdepthCompare: \"less\",\n\t\t\t\t\tformat: \"depth24plus\"\n\t\t\t\t}\n\t\t\t},\n\t\t\tdraw: {\n\t\t\t\tcount: 36,\n\t\t\t\tinstanceCount: 1\n\t\t\t}\n\t\t});\n\n\t\tfunction animate() {\n\t\t\trequestAnimationFrame(animate);\n\t\t\tconst passEncoder = canvasRenderTarget.beginRenderPass(context.device);\n\t\t\tmodel.render({ device: context.device, passEncoder });\n\t\t\tcanvasRenderTarget.endRenderPass();\n\t\t}\n\t\tanimate();\n\t};\n\tinit();\n\u003c/script\u003e\n```\n\n## feature\n\n-   [✔] Camera\n    -   [✔] PerspectiveCamera\n    -   [✔] OrthographicCamera\n-   [✔] Math\n-   [✔] control\n    -   [✔] OrbitControl\n-   [✔] Light\n    -   [✔] AmbientLight\n    -   [✔] DirectionalLight\n    -   [✔] PointLight\n    -   [✔] SpotLight\n-   [✔] Loader\n    -   [✔] GLTFLoader\n    -   [✔] CubeTextureLoader\n-   [✔] Materials\n    -   [✔] ColorMaterial\n    -   [✔] Material\n    -   [✔] PbrMaterial(IBL/Light Render)\n    -   [✔] BlinPhongMaterial\n    -   [✔] ShaderMaterial\n    -   [✔] SkyBoxMaterial\n-   [✔] Post-Effect\n    -   [✔] BloomPostEffect\n-   [✔] Shadow\n    -   [✔] DirectionalLightShadow\n    -   [✔] PointLightShadow\n    -   [✔] SpotLightShadow\n\n## Next\n\n1. Complete animation\n2. Complete core glTF 2.0\n3. Text and Sprite\n4. Pick\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpugis%2FGEngine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhpugis%2FGEngine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpugis%2FGEngine/lists"}