├── .eslintrc.json
├── .gitignore
├── .gitignore copy
├── .prettierrc
├── LICENSE
├── README.md
├── examples.jpg
├── package.json
├── rollup.config.js
├── src
└── index.tsx
├── tsconfig.json
└── yarn.lock
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "es6": true,
5 | "node": true
6 | },
7 | "extends": [
8 | "prettier",
9 | "prettier/react",
10 | "prettier/@typescript-eslint",
11 | "plugin:prettier/recommended",
12 | "plugin:react-hooks/recommended",
13 | "plugin:import/errors",
14 | "plugin:import/warnings",
15 | "prettier",
16 | "prettier/react",
17 | "prettier/@typescript-eslint"
18 | ],
19 | "plugins": ["@typescript-eslint", "react", "react-hooks", "import", "jest", "prettier"],
20 | "parser": "@typescript-eslint/parser",
21 | "parserOptions": {
22 | "ecmaFeatures": {
23 | "jsx": true
24 | },
25 | "ecmaVersion": 2018,
26 | "sourceType": "module",
27 | "rules": {
28 | "curly": ["warn", "multi-line", "consistent"],
29 | "no-console": "off",
30 | "no-empty-pattern": "warn",
31 | "no-duplicate-imports": "error",
32 | "import/no-unresolved": "off",
33 | "import/export": "error",
34 | // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
35 | // We recommend you do not use the following import/* rules, as TypeScript provides the same checks as part of standard type checking:
36 | "import/named": "off",
37 | "import/namespace": "off",
38 | "import/default": "off",
39 | "no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
40 | "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
41 | "@typescript-eslint/no-use-before-define": "off",
42 | "@typescript-eslint/no-empty-function": "off",
43 | "@typescript-eslint/no-empty-interface": "off",
44 | "@typescript-eslint/no-explicit-any": "off",
45 | "jest/consistent-test-it": ["error", { "fn": "it", "withinDescribe": "it" }]
46 | }
47 | },
48 | "settings": {
49 | "react": {
50 | "version": "detect"
51 | },
52 | "import/extensions": [".js", ".jsx", ".ts", ".tsx"],
53 | "import/parsers": {
54 | "@typescript-eslint/parser": [".js", ".jsx", ".ts", ".tsx"]
55 | },
56 | "import/resolver": {
57 | "node": {
58 | "extensions": [".js", ".jsx", ".ts", ".tsx", ".json"],
59 | "paths": ["src"]
60 | },
61 | "alias": {
62 | "extensions": [".js", ".jsx", ".ts", ".tsx", ".json"],
63 | "map": [["react-three-fiber", "./src/targets/web.tsx"]]
64 | }
65 | }
66 | },
67 | "overrides": [
68 | {
69 | "files": ["src"],
70 | "parserOptions": {
71 | "project": "./tsconfig.json"
72 | }
73 | }
74 | ]
75 | }
76 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/.gitignore copy:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false,
3 | "trailingComma": "es5",
4 | "singleQuote": true,
5 | "tabWidth": 2,
6 | "printWidth": 120
7 | }
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT license statement included in lglTracer:
2 |
3 | GLSL-PathTracer:
4 | Copyright 2019-2021 Asif Ali. MIT License
5 |
6 | ray-tracing-renderer:
7 | Copyright 2019 HOVER. MIT License
8 |
9 | lglTracer is not open source. you are free to use this library except for projects for commercial purposes.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | A React(-[three-fiber](https://github.com/pmndrs/react-three-fiber)) abstraction for the [LGL-Raytracer](http://lgltracer.com/).
4 |
5 | It does its best to remove all unwanted complexity, you can build your scenes as you always would. This is mostly for photorealistic still-images that can take a while to process but will look absolutely stunning. It is side-effect free, when you unmount it goes back to the default WebGLRenderer.
6 |
7 | Demos: [[sandbox](https://codesandbox.io/s/basic-demo-forked-rnuve)], [[studio-setup](https://codesandbox.io/s/lgl-raytracer-forked-8yfnd)]
8 |
9 | ```shell
10 | npm install @react-three/lgl
11 | ```
12 |
13 | ```jsx
14 | import { Canvas } from '@react-three/fiber'
15 | import { Raytracer } from '@react-three/lgl'
16 |
17 | function App() {
18 | return (
19 |
28 | )
29 | }
30 | ```
31 |
32 | ### Options
33 |
34 | - `samples`, How many frames it takes to complete a still-image, `64` by default. Set this to something higher if you want to wait for high-quality images, or `Infinity` if you want it to go on forever, but keep in mind that raytracing is very expensive!
35 |
36 | Otherwise `` takes all the LGL raytracer's options: https://lgltracer.com/docs/index.html#/api/LGLTracerRenderer
37 |
38 | ### Lights
39 |
40 | LGL ignores threejs lights, it wants to use its own. But in three-fiber you can simply extend, and now the JSX natives will refer to LGL.
41 |
42 | ```jsx
43 | import { extend } from '@react-three/fiber'
44 | import { PointLight, RectAreaLight } from 'lgl-tracer'
45 |
46 | extend({ PointLight, RectAreaLight })
47 |
48 |
49 |
50 | ```
51 |
52 | If you plan to switch between renderers you can make lights opt in.
53 |
54 | ```jsx
55 | extend({ LglPointLight: PointLight, LglRectAreaLight: RectAreaLight })
56 |
57 |
58 |
59 | ```
60 |
61 | ### Environmental lighting
62 |
63 | Simply drop the `` component from drei into your scene, it knows how to work with that ootb, just make sure both the raytracer and the environment are under the same suspense boundary so that they are in sync.
64 |
65 | ```jsx
66 | import { Environment } from '@react-three/drei'
67 |
68 |
73 |
74 | ```
75 |
76 | ### Movement
77 |
78 | Your scene has to be static, it will ignore moving parts. This will never be fast enough for runtime usage but you can get away with some camera movement by lowering your resolution (and your expectations). Do not forget to mark your controls as `makeDefault` so that the raycaster can react to it. Try something like this for example:
79 |
80 | ```jsx
81 | import { OrbitControls } from '@react-three/drei'
82 |
83 |