{"id":15903004,"url":"https://github.com/danielesteban/three-raymarcher","last_synced_at":"2025-04-12T20:44:10.515Z","repository":{"id":57690113,"uuid":"457038471","full_name":"danielesteban/three-raymarcher","owner":"danielesteban","description":"Raymarching abstraction for creating simple SDF animations with threejs","archived":false,"fork":false,"pushed_at":"2025-01-23T21:14:08.000Z","size":161,"stargazers_count":170,"open_issues_count":1,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-04T03:05:03.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielesteban.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-08T17:39:05.000Z","updated_at":"2025-03-30T21:00:28.000Z","dependencies_parsed_at":"2025-02-25T09:00:20.338Z","dependency_job_id":null,"html_url":"https://github.com/danielesteban/three-raymarcher","commit_stats":{"total_commits":76,"total_committers":2,"mean_commits":38.0,"dds":"0.013157894736842146","last_synced_commit":"44e92c76fade0932c766b4493df8762f3f8fb944"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielesteban%2Fthree-raymarcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielesteban%2Fthree-raymarcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielesteban%2Fthree-raymarcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielesteban%2Fthree-raymarcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielesteban","download_url":"https://codeload.github.com/danielesteban/three-raymarcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631687,"owners_count":21136556,"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-10-06T12:00:45.973Z","updated_at":"2025-04-12T20:44:10.488Z","avatar_url":"https://github.com/danielesteban.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[three-raymarcher](https://github.com/danielesteban/three-raymarcher)\n[![npm-version](https://img.shields.io/npm/v/three-raymarcher.svg)](https://www.npmjs.com/package/three-raymarcher)\n==\n\n## Examples\n\n * Animation: [glitch.com/~three-raymarcher](https://glitch.com/edit/#!/three-raymarcher)\n * Interactive: [glitch.com/~three-raymarcher-interactive](https://glitch.com/edit/#!/three-raymarcher-interactive)\n * Physics: [glitch.com/~three-raymarcher-physics](https://glitch.com/edit/#!/three-raymarcher-physics)\n * Reactive: [glitch.com/~three-raymarcher-reactive](https://glitch.com/edit/#!/three-raymarcher-reactive)\n * Skinning: [glitch.com/~three-raymarcher-skinning](https://glitch.com/edit/#!/three-raymarcher-skinning)\n * Transform: [glitch.com/~three-raymarcher-transform](https://glitch.com/edit/#!/three-raymarcher-transform)\n * react-three-fiber: [codesandbox.io/s/three-raymarcher-3xdor](https://codesandbox.io/s/three-raymarcher-3xdor)\n\n## Installation\n\n```bash\nnpm i three-raymarcher\n```\n\n## Basic usage\n\n```js\nimport {\n  Color, PerspectiveCamera, Quaternion, Scene, Vector3, WebGLRenderer\n} from 'three';\nimport Raymarcher from 'three-raymarcher';\n\nconst aspect = window.innerWidth / window.innerHeight;\nconst camera = new PerspectiveCamera(70, aspect, 0.01, 1000);\nconst renderer = new WebGLRenderer();\nrenderer.setSize(window.innerWidth, window.innerHeight);\ndocument.body.appendChild(renderer.domElement);\n\nconst scene = new Scene();\nconst raymarcher = new Raymarcher({\n  layers: [\n    [\n      {\n        color: new Color(0xFF0000),\n        operation: Raymarcher.operations.union,\n        position: new Vector3(-1.5, 0, -4),\n        rotation: new Quaternion(0, 0, 0, 1),\n        scale: new Vector3(1, 1, 1),\n        shape: Raymarcher.shapes.box,\n      },\n    ],\n    [\n      {\n        color: new Color(0x00FF00),\n        operation: Raymarcher.operations.union,\n        position: new Vector3(0, 0, -4),\n        rotation: new Quaternion(0, 0, 0, 1),\n        scale: new Vector3(0.5, 1, 0.5),\n        shape: Raymarcher.shapes.capsule,\n      },\n    ],\n    [\n      {\n        color: new Color(0x0000FF),\n        operation: Raymarcher.operations.union,\n        position: new Vector3(1.5, 0, -4),\n        rotation: new Quaternion(0, 0, 0, 1),\n        scale: new Vector3(1, 1, 1),\n        shape: Raymarcher.shapes.sphere,\n      }\n    ],\n  ],\n});\nscene.add(raymarcher);\n\nrenderer.setAnimationLoop(() =\u003e (\n  renderer.render(scene, camera)\n));\n```\n\n## Lighting\n\nthree-raymarcher uses indirect PBR lighting only. Direct light support (DirectionalLight/PointLight/SpotLight) will come in future versions.\n\nAssign a CubeUVMap texture to `userData.envMap` and control it's intensity with `userData.envMapIntensity`:\n\n```js\n(new RGBELoader()).load('environment.hdr', (texture) =\u003e {\n  raymarcher.userData.envMap = (new PMREMGenerator(renderer)).fromEquirectangular(texture).texture;\n  raymarcher.userData.envMapIntensity = 0.7;\n});\n```\n\n`userData.metalness` controls the global metalness of the material.\n\n`userData.roughness` controls the global roughness of the material.\n\nIf you don't set an envMap, the shader will use `vec3(envMapIntensity)` as the ambient light.\n\n## Raymarching\n\n`userData.blending` controls the global smoothing of the union, substraction and intersection operations.\n\n`userData.conetracing` enables/disables conetracing (sort of antialias).\n\nYou can increase the performance by setting `userData.resolution` to something less than 1. In most of the examples is set to 0.5 (2x downsampling), which seems to give the best quality/performance trade-off.\n\n## Raycasting\n\nthree-raymarcher supports the three.js [Raycaster](https://threejs.org/docs/api/en/core/Raycaster) out of the box:\n\n```js\nconst [hit] = raycaster.intersectObject(raymarcher);\nif (hit) {\n  console.log(\n    hit.entityId, // The index of the intersected entity\n    hit.entity, // A reference to the intersected entity\n    hit.layerId, // The index of the intersected entity layer\n    hit.layer, // A reference to the intersected entity layer\n  );\n}\n```\n\n## Want to contribute?\n\nHere's how to setup the module dev environment:\n\n```bash\n# clone this repo\ngit clone https://github.com/danielesteban/three-raymarcher.git\ncd three-raymarcher\n# install dependencies\npnpm install\n# start the environment:\npnpm start\n# open http://localhost:8080/examples/animation in your browser\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielesteban%2Fthree-raymarcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielesteban%2Fthree-raymarcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielesteban%2Fthree-raymarcher/lists"}