Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/polygonjs/polygonjs-react-three-fiber-raymarching-example

Example of a raymarching material created with Polygonjs integrated to a react-three-fiber scene
https://github.com/polygonjs/polygonjs-react-three-fiber-raymarching-example

Last synced: 21 days ago
JSON representation

Example of a raymarching material created with Polygonjs integrated to a react-three-fiber scene

Awesome Lists containing this project

README

        

# Raymarching + React-Three-Fiber

This repo demonstrates how to add raymarching materials created with [Polygonjs](https://polygonjs.com) to any react-three-fiber scene, using the [Polygonjs R3F component](https://github.com/polygonjs/polygonjs-react-three-fiber).

![Raymarching_with_threejs](https://github.com/polygonjs/polygonjs-react-three-fiber-raymarching-example/blob/main/assets/r3f.gif?raw=true)

See [live example](https://polygonjs.com/demo?example=bynode/mat/raymarchingbuilder/refractions) or learn more about [Polygonjs](https://polygonjs.com)

# How it works

1. install polygonjs-editor with `npm install polygonjs-editor`

2. create and save [your first scene](https://polygonjs.com/docs/getting_started) using the editor. This will save several files under `src/polygonjs/scenes/`.

3. import the polygonjs scene, using the created files.

``` ts
import {PolygonjsScene} from '@polygonjs/react-three-fiber';
import {loadScene_scene_01} from './polygonjs/scenes/scene_01/autogenerated/loadScene';
import {
PolySceneWithNodeMap_scene_01,
PolySceneProps_scene_01,
} from './polygonjs/scenes/scene_01/autogenerated/PolySceneWithNodeMap';
```

4. mount the component

``` ts

sceneName={'scene_01'}
loadFunction={loadScene_scene_01 as any}
/>
```

And you're done. Check [index.ts](./src/index.tsx) to see how it is set up in this repository. And note that while this demonstrates it in typescript, it works just as well in javascript.