{"id":19014247,"url":"https://github.com/spritejs/sprite-extend-3d","last_synced_at":"2025-04-23T00:42:15.443Z","repository":{"id":87731600,"uuid":"230854596","full_name":"spritejs/sprite-extend-3d","owner":"spritejs","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-08T09:21:50.000Z","size":10848,"stargazers_count":17,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-23T00:42:04.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/spritejs.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":"2019-12-30T05:38:38.000Z","updated_at":"2024-01-11T00:18:57.000Z","dependencies_parsed_at":"2023-04-11T04:35:20.049Z","dependency_job_id":null,"html_url":"https://github.com/spritejs/sprite-extend-3d","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"spritejs/sprite-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spritejs%2Fsprite-extend-3d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spritejs%2Fsprite-extend-3d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spritejs%2Fsprite-extend-3d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spritejs%2Fsprite-extend-3d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spritejs","download_url":"https://codeload.github.com/spritejs/sprite-extend-3d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250348894,"owners_count":21415907,"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":[],"created_at":"2024-11-08T19:28:28.301Z","updated_at":"2025-04-23T00:42:15.437Z","avatar_url":"https://github.com/spritejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sprite extend 3D\n\nThe 3d extension for spritejs.\n\n## Usage\n\n```html\n\u003cscript src=\"https://unpkg.com/spritejs/dist/spritejs.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"http://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.js\"\u003e\u003c/script\u003e\n```\n\n```js\nconst vertex = /* glsl */ `\n    precision highp float;\n    precision highp int;\n\n    attribute vec2 uv;\n    attribute vec3 position;\n    attribute vec3 normal;\n\n    uniform mat4 modelViewMatrix;\n    uniform mat4 projectionMatrix;\n    uniform mat3 normalMatrix;\n\n    varying vec2 vUv;\n    varying vec3 vNormal;\n\n    void main() {\n        vUv = uv;\n        vNormal = normalize(normalMatrix * normal);\n        \n        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n`;\n\nconst fragment = /* glsl */ `\n    precision highp float;\n    precision highp int;\n\n    uniform float uTime;\n    uniform sampler2D tMap;\n\n    varying vec2 vUv;\n    varying vec3 vNormal;\n\n    void main() {\n        vec3 normal = normalize(vNormal);\n        vec3 tex = texture2D(tMap, vUv).rgb;\n        \n        vec3 light = normalize(vec3(0.5, 1.0, -0.3));\n        float shading = dot(normal, light) * 0.15;\n        gl_FragColor.rgb = tex + shading;\n        gl_FragColor.a = 1.0;\n    }\n`;\n\nconst {Scene} = spritejs;\nconst {Mesh3d} = spritejs.ext3d;\nconst container = document.getElementById('container');\nconst scene = new Scene({\n  container,\n  displayRatio: 2,\n});\nconst layer = scene.layer3d('fglayer', {\n  camera: {\n    fov: 35,\n  },\n});\n\nlayer.camera.attributes.pos = [8, 5, 15];\nlayer.camera.lookAt([0, 1.5, 0]);\n\n(async function () {\n  const texture = await layer.createTexture('https://p3.ssl.qhimg.com/t01d6c6c93fdddf1e42.jpg');\n  const program = layer.createProgram({\n    vertex,\n    fragment,\n    uniforms: {\n      tMap: {value: texture},\n    },\n  });\n  const model = await layer.loadModel('https://s5.ssl.qhres.com/static/1eb3e9b91a296abd.json');\n  const fox = new Mesh3d(program);\n  fox.setGeometry(model);\n  layer.append(fox);\n  fox.animate([\n    {rotateY: 0},\n    {rotateY: 360},\n  ], {\n    duration: 5000,\n    iterations: Infinity,\n  });\n}());\n```\n\nFor more details, see [here](https://spritejs.com/#/zh-cn/guide/3d).\n\n## Roadmap\n\n- [x] Shared Geometry\n- [x] RenderTarget\n- [x] GPGPU\n- [x] Polyline 3D\n- [x] Cubic Bezier Curve 3D\n- [ ] GLTF Loader\n- [ ] Flowmap\n- [ ] Documentation\n- [ ] More examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspritejs%2Fsprite-extend-3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspritejs%2Fsprite-extend-3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspritejs%2Fsprite-extend-3d/lists"}