main df7a0d77a8a1 cached
21 files
44.6 KB
12.1k tokens
1 symbols
1 requests
Download .txt
Repository: SuboptimalEng/volume-rendering
Branch: main
Commit: df7a0d77a8a1
Files: 21
Total size: 44.6 KB

Directory structure:
gitextract_8cedh4io/

├── .eslintrc.cjs
├── .gitignore
├── LICENSE
├── README.md
├── index.html
├── package.json
├── postcss.config.js
├── src/
│   ├── App.tsx
│   ├── ThreeSceneV1.tsx
│   ├── ThreeSceneV2.tsx
│   ├── index.css
│   ├── main.tsx
│   ├── shaders/
│   │   ├── fragmentV1.glsl
│   │   ├── fragmentV2.glsl
│   │   ├── vertexV1.glsl
│   │   └── vertexV2.glsl
│   └── vite-env.d.ts
├── tailwind.config.js
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts

================================================
FILE CONTENTS
================================================

================================================
FILE: .eslintrc.cjs
================================================
module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:react-hooks/recommended',
  ],
  ignorePatterns: ['dist', '.eslintrc.cjs'],
  parser: '@typescript-eslint/parser',
  plugins: ['react-refresh'],
  rules: {
    'react-refresh/only-export-components': [
      'warn',
      { allowConstantExport: true },
    ],
  },
}


================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# MacOS
.DS_Store

# 3D models
models


================================================
FILE: LICENSE
================================================
Attribution-NonCommercial-ShareAlike 4.0 International

=======================================================================

Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.

Using Creative Commons Public Licenses

Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.

     Considerations for licensors: Our public licenses are
     intended for use by those authorized to give the public
     permission to use material in ways otherwise restricted by
     copyright and certain other rights. Our licenses are
     irrevocable. Licensors should read and understand the terms
     and conditions of the license they choose before applying it.
     Licensors should also secure all rights necessary before
     applying our licenses so that the public can reuse the
     material as expected. Licensors should clearly mark any
     material not subject to the license. This includes other CC-
     licensed material, or material used under an exception or
     limitation to copyright. More considerations for licensors:
    wiki.creativecommons.org/Considerations_for_licensors

     Considerations for the public: By using one of our public
     licenses, a licensor grants the public permission to use the
     licensed material under specified terms and conditions. If
     the licensor's permission is not necessary for any reason--for
     example, because of any applicable exception or limitation to
     copyright--then that use is not regulated by the license. Our
     licenses grant only permissions under copyright and certain
     other rights that a licensor has authority to grant. Use of
     the licensed material may still be restricted for other
     reasons, including because others have copyright or other
     rights in the material. A licensor may make special requests,
     such as asking that all changes be marked or described.
     Although not required by our licenses, you are encouraged to
     respect those requests where reasonable. More considerations
     for the public:
    wiki.creativecommons.org/Considerations_for_licensees

=======================================================================

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Public License

By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International Public License
("Public License"). To the extent this Public License may be
interpreted as a contract, You are granted the Licensed Rights in
consideration of Your acceptance of these terms and conditions, and the
Licensor grants You such rights in consideration of benefits the
Licensor receives from making the Licensed Material available under
these terms and conditions.

Section 1 -- Definitions.

a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.

b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.

c. BY-NC-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.

d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.

e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.

f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.

g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution, NonCommercial, and ShareAlike.

h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.

i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.

j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.

k. NonCommercial means not primarily intended for or directed towards
commercial advantage or monetary compensation. For purposes of
this Public License, the exchange of the Licensed Material for
other material subject to Copyright and Similar Rights by digital
file-sharing or similar means is NonCommercial provided there is
no payment of monetary compensation in connection with the
exchange.

l. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.

m. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.

n. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.

Section 2 -- Scope.

a. License grant.

       1. Subject to the terms and conditions of this Public License,
          the Licensor hereby grants You a worldwide, royalty-free,
          non-sublicensable, non-exclusive, irrevocable license to
          exercise the Licensed Rights in the Licensed Material to:

            a. reproduce and Share the Licensed Material, in whole or
               in part, for NonCommercial purposes only; and

            b. produce, reproduce, and Share Adapted Material for
               NonCommercial purposes only.

       2. Exceptions and Limitations. For the avoidance of doubt, where
          Exceptions and Limitations apply to Your use, this Public
          License does not apply, and You do not need to comply with
          its terms and conditions.

       3. Term. The term of this Public License is specified in Section
          6(a).

       4. Media and formats; technical modifications allowed. The
          Licensor authorizes You to exercise the Licensed Rights in
          all media and formats whether now known or hereafter created,
          and to make technical modifications necessary to do so. The
          Licensor waives and/or agrees not to assert any right or
          authority to forbid You from making technical modifications
          necessary to exercise the Licensed Rights, including
          technical modifications necessary to circumvent Effective
          Technological Measures. For purposes of this Public License,
          simply making modifications authorized by this Section 2(a)
          (4) never produces Adapted Material.

       5. Downstream recipients.

            a. Offer from the Licensor -- Licensed Material. Every
               recipient of the Licensed Material automatically
               receives an offer from the Licensor to exercise the
               Licensed Rights under the terms and conditions of this
               Public License.

            b. Additional offer from the Licensor -- Adapted Material.
               Every recipient of Adapted Material from You
               automatically receives an offer from the Licensor to
               exercise the Licensed Rights in the Adapted Material
               under the conditions of the Adapter's License You apply.

            c. No downstream restrictions. You may not offer or impose
               any additional or different terms or conditions on, or
               apply any Effective Technological Measures to, the
               Licensed Material if doing so restricts exercise of the
               Licensed Rights by any recipient of the Licensed
               Material.

       6. No endorsement. Nothing in this Public License constitutes or
          may be construed as permission to assert or imply that You
          are, or that Your use of the Licensed Material is, connected
          with, or sponsored, endorsed, or granted official status by,
          the Licensor or others designated to receive attribution as
          provided in Section 3(a)(1)(A)(i).

b. Other rights.

       1. Moral rights, such as the right of integrity, are not
          licensed under this Public License, nor are publicity,
          privacy, and/or other similar personality rights; however, to
          the extent possible, the Licensor waives and/or agrees not to
          assert any such rights held by the Licensor to the limited
          extent necessary to allow You to exercise the Licensed
          Rights, but not otherwise.

       2. Patent and trademark rights are not licensed under this
          Public License.

       3. To the extent possible, the Licensor waives any right to
          collect royalties from You for the exercise of the Licensed
          Rights, whether directly or through a collecting society
          under any voluntary or waivable statutory or compulsory
          licensing scheme. In all other cases the Licensor expressly
          reserves any right to collect such royalties, including when
          the Licensed Material is used other than for NonCommercial
          purposes.

Section 3 -- License Conditions.

Your exercise of the Licensed Rights is expressly made subject to the
following conditions.

a. Attribution.

       1. If You Share the Licensed Material (including in modified
          form), You must:

            a. retain the following if it is supplied by the Licensor
               with the Licensed Material:

                 i. identification of the creator(s) of the Licensed
                    Material and any others designated to receive
                    attribution, in any reasonable manner requested by
                    the Licensor (including by pseudonym if
                    designated);

                ii. a copyright notice;

               iii. a notice that refers to this Public License;

                iv. a notice that refers to the disclaimer of
                    warranties;

                 v. a URI or hyperlink to the Licensed Material to the
                    extent reasonably practicable;

            b. indicate if You modified the Licensed Material and
               retain an indication of any previous modifications; and

            c. indicate the Licensed Material is licensed under this
               Public License, and include the text of, or the URI or
               hyperlink to, this Public License.

       2. You may satisfy the conditions in Section 3(a)(1) in any
          reasonable manner based on the medium, means, and context in
          which You Share the Licensed Material. For example, it may be
          reasonable to satisfy the conditions by providing a URI or
          hyperlink to a resource that includes the required
          information.
       3. If requested by the Licensor, You must remove any of the
          information required by Section 3(a)(1)(A) to the extent
          reasonably practicable.

b. ShareAlike.

     In addition to the conditions in Section 3(a), if You Share
     Adapted Material You produce, the following conditions also apply.

       1. The Adapter's License You apply must be a Creative Commons
          license with the same License Elements, this version or
          later, or a BY-NC-SA Compatible License.

       2. You must include the text of, or the URI or hyperlink to, the
          Adapter's License You apply. You may satisfy this condition
          in any reasonable manner based on the medium, means, and
          context in which You Share Adapted Material.

       3. You may not offer or impose any additional or different terms
          or conditions on, or apply any Effective Technological
          Measures to, Adapted Material that restrict exercise of the
          rights granted under the Adapter's License You apply.

Section 4 -- Sui Generis Database Rights.

Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:

a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database for NonCommercial purposes
only;

b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and

c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.

For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.

Section 5 -- Disclaimer of Warranties and Limitation of Liability.

a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.

b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.

c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.

Section 6 -- Term and Termination.

a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.

b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:

       1. automatically as of the date the violation is cured, provided
          it is cured within 30 days of Your discovery of the
          violation; or

       2. upon express reinstatement by the Licensor.

     For the avoidance of doubt, this Section 6(b) does not affect any
     right the Licensor may have to seek remedies for Your violations
     of this Public License.

c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.

d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.

Section 7 -- Other Terms and Conditions.

a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.

b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.

Section 8 -- Interpretation.

a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.

b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.

c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.

d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.

=======================================================================

Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.

Creative Commons may be contacted at creativecommons.org.

================================================
FILE: README.md
================================================
# 🌊 Volume Rendering

Volume rendering is a common technique used to render 3D medical imaging data like MRIs or CT scans. This repo contains the code for my implementation in Three.js and GLSL. Here's a 30-second demo on [Twitter](https://x.com/SuboptimalEng/status/1781808470985003035) and [Reddit](https://www.reddit.com/r/GraphicsProgramming/comments/1c9ke0p/volume_rendering_in_threejs_and_glsl/).

Huge thanks to Will Usher for his blog post on [Volume Rendering in WebGL](https://www.willusher.io/webgl/2019/01/13/volume-rendering-with-webgl).

<img src="/_demos/foot-01.png" width="100%">
<img src="/_demos/foot-02.png" width="100%">
<img src="/_demos/bonsai-01.png" width="100%">

## Setup

```
git clone https://github.com/SuboptimalEng/volume-rendering.git
cd volume-rendering/
npm install
npm run dev
```

But wait, there's more! After running these commands, you will be able to open the project in localhost. However, there will be no image rendered on screen. Why, you may ask? Simple, I did not want to upload multiple 16MB data files to GitHub. To see the demo in action, you will need to download one of these files and upload them via the UI.

- Foot - https://klacansky.com/open-scivis-datasets/foot/foot_256x256x256_uint8.raw
- Skull - https://klacansky.com/open-scivis-datasets/skull/skull_256x256x256_uint8.raw
- Bonsai - https://klacansky.com/open-scivis-datasets/bonsai/bonsai_256x256x256_uint8.raw

Note: The website I linked has tons of models, but not all of them will work. I've hard-coded this project to work with `256x256x256 uint8` files that are scaled `1x1x1`.

## References

- Will Usher's Blog Post - https://www.willusher.io/webgl/2019/01/13/volume-rendering-with-webgl
- Open Scientific Visualization Datasets - https://klacansky.com/open-scivis-datasets
- The Art of Code - https://www.youtube.com/watch?v=S8AWd66hoCo
- Inigo Quilez - https://iquilezles.org/articles/palettes/

## License

Shield: [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa]

This work is licensed under a
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].

[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa]

[cc-by-nc-sa]: http://creativecommons.org/licenses/by-nc-sa/4.0/
[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png
[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg


================================================
FILE: index.html
================================================
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite + React + TS</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
  </body>
</html>


================================================
FILE: package.json
================================================
{
  "name": "volume-rendering",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "three": "^0.163.0"
  },
  "devDependencies": {
    "@types/dat.gui": "^0.7.13",
    "@types/react": "^18.2.66",
    "@types/react-dom": "^18.2.22",
    "@types/three": "^0.163.0",
    "@typescript-eslint/eslint-plugin": "^7.2.0",
    "@typescript-eslint/parser": "^7.2.0",
    "@vitejs/plugin-react": "^4.2.1",
    "autoprefixer": "^10.4.19",
    "dat.gui": "^0.7.9",
    "eslint": "^8.57.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.6",
    "postcss": "^8.4.38",
    "tailwindcss": "^3.4.3",
    "typescript": "^5.2.2",
    "vite": "^5.2.0"
  }
}


================================================
FILE: postcss.config.js
================================================
export default {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}


================================================
FILE: src/App.tsx
================================================
import { ThreeSceneV1 } from './ThreeSceneV1';
import { ThreeSceneV2 } from './ThreeSceneV2';

function App() {
  const version = 'v2';
  const map = {
    v1: <ThreeSceneV1 />,
    v2: <ThreeSceneV2 />,
  }[version];

  return (
    <>
      <div>{map}</div>
    </>
  );
}

export default App;


================================================
FILE: src/ThreeSceneV1.tsx
================================================
import { useEffect, useRef } from 'react';
import * as Three from 'three';
import { OrbitControls } from 'three/examples/jsm/Addons.js';
import vertexV1 from './shaders/vertexV1.glsl?raw';
import fragmentV1 from './shaders/fragmentV1.glsl?raw';

const generateCube = (p: Three.Vector3 = new Three.Vector3(0, 0, 0)) => {
  const geo1 = new Three.BoxGeometry(1, 1, 1);
  const mat1 = new Three.MeshBasicMaterial({ color: 0x00ff00 });
  const cube = new Three.Mesh(geo1, mat1);
  cube.position.set(p.x, p.y, p.z);
  return cube;
};

export const ThreeSceneV1 = () => {
  const canvasRef = useRef(null);

  useEffect(() => {
    if (canvasRef.current === null) {
      return;
    }

    const width = window.innerWidth;
    const height = window.innerHeight;
    const renderer = new Three.WebGLRenderer({ canvas: canvasRef.current });
    renderer.setSize(width, height);

    const myCamera = new Three.PerspectiveCamera(75, width / height, 0.1, 1000);
    myCamera.position.set(0, 0, -5);
    myCamera.lookAt(new Three.Vector3(0, 0, 0));
    myCamera.up.set(0, 1, 0);

    const scene = new Three.Scene();
    const cube1 = generateCube(new Three.Vector3(-2, 0, 0));
    const cube2 = generateCube(new Three.Vector3(2, 0, 0));
    scene.add(cube1);
    scene.add(cube2);

    // const geo1 = new Three.PlaneGeometry(2, 2, 2);
    const geo1 = new Three.BoxGeometry(2, 2, 2);
    const mat1 = new Three.ShaderMaterial({
      uniforms: {
        u_camera: {
          value: myCamera.position,
        },
        u_resolution: {
          value: new Three.Vector3(width, height, 1),
        },
      },
      vertexShader: vertexV1,
      fragmentShader: fragmentV1,
    });
    const m1 = new Three.Mesh(geo1, mat1);
    // Changing this position will change world space coords of the mesh.
    // Since transform camera coordinates to object space, this will
    // also work on the ray march. Same for rotataion + scale.
    // m1.position.x = 2;
    // m1.rotation.x = 10;
    // m1.scale.x = 2;
    scene.add(m1);

    const controls = new OrbitControls(myCamera, renderer.domElement);

    const animate = () => {
      controls.update();
      renderer.render(scene, myCamera);
      requestAnimationFrame(animate);
    };
    animate();
  }, []);

  return (
    <>
      <canvas ref={canvasRef}></canvas>
    </>
  );
};


================================================
FILE: src/ThreeSceneV2.tsx
================================================
import { useEffect, useRef, useState } from 'react';
import * as Three from 'three';
import { GUI } from 'dat.gui';
import { OrbitControls } from 'three/examples/jsm/Addons.js';
import Stats from 'three/addons/libs/stats.module.js';
import vertexV2 from './shaders/vertexV2.glsl?raw';
import fragmentV2 from './shaders/fragmentV2.glsl?raw';

const handleVolumeFileUpload = (event: any, dim: number, setDataFn: any) => {
  const file = event.target.files[0];
  const reader = new FileReader();
  reader.onload = (e: any) => {
    const arrayBuffer = e.target.result;

    const uint8Array = new Uint8Array(arrayBuffer);
    // Assuming the raw file contains 256x256x256 uint8 values
    const data = new Uint8Array(dim * dim * dim);
    for (let i = 0; i < uint8Array.length; i++) {
      data[i] = uint8Array[i];
    }
    setDataFn(data);
  };
  reader.readAsArrayBuffer(file);
};

const initData = (canvasRef: any, volumeData: any, dim: number) => {
  const width = window.innerWidth;
  const height = window.innerHeight;

  const camera = new Three.PerspectiveCamera(75, width / height, 0.1, 1000);
  camera.position.set(0, 0, -2);
  camera.lookAt(new Three.Vector3(0, 0, 0));
  camera.up.set(0, 1, 0);

  const renderer = new Three.WebGLRenderer({ canvas: canvasRef.current });
  const stats = new Stats();
  const clock = new Three.Clock();
  const controls = new OrbitControls(camera, renderer.domElement);

  renderer.setSize(width, height);
  clock.start();
  document.body.appendChild(stats.dom);

  const gui = new GUI();
  const folder = gui.addFolder('Display Settings');
  folder.open();

  const crossFolder = folder.addFolder('Cross Section Settings');
  const crossSectionSize = new Three.Vector3(0.5, 0.5, 0.5);
  crossFolder.add(crossSectionSize, 'x', 0.02, 0.5, 0.02);
  crossFolder.add(crossSectionSize, 'y', 0.02, 0.5, 0.02);
  crossFolder.add(crossSectionSize, 'z', 0.02, 0.5, 0.02);
  crossFolder.open();

  const volumeDataTexture = new Three.Data3DTexture(volumeData, dim, dim, dim);
  volumeDataTexture.format = Three.RedFormat;
  // volumeDataTexture.type = Three.UnsignedByteType;
  volumeDataTexture.minFilter = Three.LinearFilter;
  volumeDataTexture.magFilter = Three.LinearFilter;
  // volumeDataTexture.wrapS = Three.RepeatWrapping;
  volumeDataTexture.wrapT = Three.RepeatWrapping;
  // volumeDataTexture.wrapR = Three.RepeatWrapping;
  volumeDataTexture.needsUpdate = true;
  console.log(volumeDataTexture);

  const uniforms = {
    u_camera: {
      value: camera.position,
    },
    u_resolution: {
      value: new Three.Vector3(width, height, 1),
    },
    u_dt: {
      value: 0.01,
    },
    u_time: {
      value: 0.0,
    },
    u_crossSectionSize: {
      value: crossSectionSize,
    },
    u_color: {
      value: 1,
    },
    u_volume: {
      value: volumeDataTexture,
    },
    u_isoValue: {
      value: 1,
    },
    u_alphaVal: {
      value: 0.2,
    },
  };

  const algoFolder = folder.addFolder('Algorithm Settings');
  algoFolder.add(uniforms.u_dt, 'value', 0.004, 0.016, 0.002).name('step size');
  algoFolder.add(uniforms.u_color, 'value', 1, 3, 1).name('color');
  const alphaSetting = algoFolder
    .add(uniforms.u_alphaVal, 'value', 0.01, 0.4, 0.01)
    .name('alpha val');
  algoFolder.add(uniforms.u_isoValue, 'value', 0, 1, 0.04).name('iso value');
  algoFolder.open();

  return {
    camera,
    stats,
    clock,
    uniforms,
    gui,
    renderer,
    controls,
    alphaSetting,
  };
};

export const ThreeSceneV2 = () => {
  const dim = 256;
  const canvasRef = useRef(null);
  const [volumeData, setVolumeData] = useState<Uint8Array | null>(null);

  useEffect(() => {
    if (canvasRef.current === null) {
      console.log('No canvas!');
      return;
    }

    if (volumeData === null) {
      console.log('No volume data!');
      return;
    }

    // todo: I should clean this up...
    const { camera, stats, clock, uniforms, gui, renderer, controls } =
      initData(canvasRef, volumeData, dim);

    // Note: Plane works, but looks very weird...
    // const geo1 = new Three.PlaneGeometry(2, 2, 2);
    const scene = new Three.Scene();
    const geo1 = new Three.BoxGeometry(2, 2, 2);
    const mat1 = new Three.ShaderMaterial({
      uniforms: { ...uniforms },
      vertexShader: vertexV2,
      fragmentShader: fragmentV2,
    });
    const mesh1 = new Three.Mesh(geo1, mat1);
    mesh1.rotateY(Math.PI / 2);
    scene.add(mesh1);

    const animate = () => {
      controls.update();
      stats.update();
      renderer.render(scene, camera);
      uniforms.u_time.value = clock.getElapsedTime();
      requestAnimationFrame(animate);
    };

    animate();

    return () => {
      document.body.removeChild(stats.dom);
      stats.end();
      gui.destroy();
    };
  }, [volumeData]);

  return (
    <>
      <div className="absolute top-16">
        <input
          type="file"
          onChange={(e) => handleVolumeFileUpload(e, dim, setVolumeData)}
        />
      </div>
      <canvas ref={canvasRef}></canvas>
    </>
  );
};


================================================
FILE: src/index.css
================================================
:root {
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}
a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  display: flex;
  place-items: center;
  min-width: 320px;
  min-height: 100vh;
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}
button:hover {
  border-color: #646cff;
}
button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
  }
  a:hover {
    color: #747bff;
  }
  button {
    background-color: #f9f9f9;
  }
}

@tailwind base;
@tailwind components;
@tailwind utilities;


================================================
FILE: src/main.tsx
================================================
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);


================================================
FILE: src/shaders/fragmentV1.glsl
================================================
uniform vec3 u_camera;
uniform vec3 u_resolution;

varying vec3 v_hitPos;
varying vec3 v_hitPosWorldSpace;
varying vec3 v_cameraObjectSpace;

float sdCircle(vec3 p, float r) {
  return length(p) - r;
}

float sdTorus(vec3 p, vec2 t) {
  vec2 q = vec2(length(p.xz) - t.x, p.y);
  return length(q) - t.y;
}

float map(vec3 p) {
  // return sdCircle(p, 0.5);
  return sdTorus(p, vec2(0.5, 0.2));
}

void main() {
  vec3 rayOrigin = vec3(0.0, 0.0, -3.0);
  // rayOrigin = u_camera;
  rayOrigin = v_cameraObjectSpace;

  vec2 uv = 2.0 * gl_FragCoord.xy / u_resolution.xy - 1.0;
  vec3 rayDir = normalize(vec3(uv, 1.0));
  // rayDir = normalize(vec3(uv, 1.0) - rayOrigin);
  rayDir = normalize(v_hitPos - rayOrigin);
  // rayDir = normalize(v_hitPosWorldSpace - rayOrigin);

  float totalDistance = 0.0;
  bool discardCheck = true;

  for (int i = 0; i < 32; i++) {
    vec3 p = rayOrigin + rayDir * totalDistance;

    float d = map(p);

    totalDistance += d;

    if (d < 0.001) {
      discardCheck = false;
      break;
    }

    if (totalDistance >= 100.0) {
      // If you want to truly discard, set discardCheck to true here.
      // discardCheck = true;
      discardCheck = false;
      break;
    }
  }

  if (discardCheck) {
    discard;
  }

  gl_FragColor = vec4(1.0);
  gl_FragColor.xyz = rayDir;
  gl_FragColor.xyz = vec3(totalDistance * 0.1);
}

================================================
FILE: src/shaders/fragmentV2.glsl
================================================
precision mediump int;
precision mediump float;

uniform vec3 u_camera;
uniform vec3 u_resolution;
uniform mediump sampler3D u_volume;
uniform vec3 u_crossSectionSize;
uniform float u_dt;
uniform float u_time;
uniform float u_color;
uniform float u_isoValue;
uniform float u_alphaVal;

// Inigo Quilez - https://iquilezles.org/articles/palettes/
vec3 palette(in float t) {
  vec3 a = vec3(0.5, 0.5, 0.5);
  vec3 b = vec3(0.5, 0.5, 0.5);
  vec3 c = vec3(1.0, 1.0, 1.0);
  vec3 d = vec3(0.00, 0.33, 0.67);

  return a + b * cos(6.28318 * (c * t + d));
}

varying vec3 v_hitPos;
varying vec3 v_hitPosWorldSpace;
varying vec3 v_cameraObjectSpace;

// Will Usher - https://www.willusher.io/webgl/2019/01/13/volume-rendering-with-webgl
vec2 intersect_box(vec3 orig, vec3 dir) {
  // note: used this for testing purposes
  // const float halfBoxSize = 0.5;
  // const vec3 box_min = vec3(-halfBoxSize);
  // const vec3 box_max = vec3(halfBoxSize);

  vec3 box_min = vec3(-u_crossSectionSize);
  vec3 box_max = vec3(u_crossSectionSize);
  vec3 inv_dir = 1.0 / dir;
  vec3 tmin_tmp = (box_min - orig) * inv_dir;
  vec3 tmax_tmp = (box_max - orig) * inv_dir;
  vec3 tmin = min(tmin_tmp, tmax_tmp);
  vec3 tmax = max(tmin_tmp, tmax_tmp);
  float t0 = max(tmin.x, max(tmin.y, tmin.z));
  float t1 = min(tmax.x, min(tmax.y, tmax.z));
  return vec2(t0, t1);
}

void main() {
  vec3 rayOrigin = vec3(0.0, 0.0, -3.0);
  // rayOrigin = u_camera;
  rayOrigin = v_cameraObjectSpace;

  vec2 uv = 2.0 * gl_FragCoord.xy / u_resolution.xy - 1.0;
  vec3 rayDir = normalize(vec3(uv, 1.0));
  // rayDir = normalize(vec3(uv, 1.0) - rayOrigin);
  rayDir = normalize(v_hitPos - rayOrigin);
  // rayDir = normalize(v_hitPosWorldSpace - rayOrigin);

  // Step 2: Intersect the ray with the volume bounds to find the interval
  // along the ray overlapped by the volume.
  vec2 t_hit = intersect_box(rayOrigin, rayDir);
  if (t_hit.x > t_hit.y) {
    discard;
  }

  // We don't want to sample voxels behind the eye if it's
  // inside the volume, so keep the starting point at or in front
  // of the eye
  t_hit.x = max(t_hit.x, 0.0);

  // Step 3: Compute the step size to march through the volume grid
  // vec3 dt_vec = 1.0 / (vec3(20.0) * abs(rayDir));

  // float dt = min(dt_vec.x, min(dt_vec.y, dt_vec.z));
  // float dt = 0.002;
  float dt = u_dt;

  vec4 color = vec4(0.0);

  // note: 0.5 offset centers on cube
  vec3 p = rayOrigin + t_hit.x * rayDir + 0.5;
  for (float t = t_hit.x; t < t_hit.y; t += dt) {
    // note: used this for testing purposes
    // float textureVal = texture(u_volume, vec3(0.4, 0.2, 0.4)).r;

    float textureVal = texture(u_volume, p).r;

    vec4 val_color = vec4(0.0);
    float val_color_alpha = textureVal * 0.1;

    // looks a little nicer when using this alpha
    // val_color_alpha = smoothstep(0.0, 0.25, textureVal * 0.1);

    // looks even nicer
    val_color_alpha = smoothstep(0.0, u_alphaVal, val_color_alpha);

    vec3 red = vec3(1.0, 0.0, 0.0);
    vec3 white = vec3(1.0);
    if (abs(u_color - 1.0) <= 0.01) {
      val_color = vec4(white, val_color_alpha);
    } else if (abs(u_color - 2.0) <= 0.01) {
      val_color = vec4(mix(red, white, val_color_alpha), val_color_alpha);
    } else {
      val_color = vec4(palette(textureVal), val_color_alpha);
    }

    // Step 4.2: Accumulate the color and opacity using the front-to-back
    // compositing equation
    color.rgb += (1.0 - color.a) * val_color.a * val_color.rgb;
    color.a += (1.0 - color.a) * val_color.a;

    // todo: Add blinn-phong lighting? (done, kinda)
    // todo: Iso value slider? (done, kinda)
    // todo: Clean this up? (Is this even the right approach?)
    if (textureVal > u_isoValue) {
      // calculate normal at point by central differences method
      float gxLess = texture(u_volume, vec3(p.x - rayDir.x * u_dt, p.y, p.z)).r;
      float gxMore = texture(u_volume, vec3(p.x + rayDir.x * u_dt, p.y, p.z)).r;
      float dgx = gxMore - gxLess;

      float gyLess = texture(u_volume, vec3(p.x, p.y - rayDir.y * u_dt, p.z)).r;
      float gyMore = texture(u_volume, vec3(p.x, p.y + rayDir.y * u_dt, p.z)).r;
      float dgy = gyMore - gyLess;

      float gzLess = texture(u_volume, vec3(p.x, p.y, p.z - rayDir.z * u_dt)).r;
      float gzMore = texture(u_volume, vec3(p.x, p.y, p.z + rayDir.z * u_dt)).r;
      float dgz = gzMore - gzLess;
      vec3 n = normalize(vec3(dgx, dgy, dgz));

      // calculate diffuse lighting
      vec3 lightSource = vec3(1.0);
      vec3 lightDir = normalize(lightSource);
      float diffuseStrength = max(dot(n, lightDir), 0.0);

      // calculate specular lighting
      vec3 viewSource = normalize(rayOrigin);
      vec3 reflectSource = normalize(reflect(-lightSource, n));
      float specularStrength = max(0.0, dot(viewSource, reflectSource));
      specularStrength = pow(specularStrength, 64.0);

      // add lighting
      color.rgb = diffuseStrength * val_color.rgb + specularStrength * val_color.rgb;
      color.rgb *= val_color.rgb;
      color.a = 0.95;
      break;
    }

    // Optimization: break out of the loop when the color is near opaque
    if (color.a >= 0.95) {
      break;
    }

    p += rayDir * dt;
  }

  gl_FragColor = color;
}

================================================
FILE: src/shaders/vertexV1.glsl
================================================
uniform vec3 u_camera; // default in world space
uniform vec3 u_resolution;

// The Art of Code: https://www.youtube.com/watch?v=S8AWd66hoCo
// It is important to keep camera + (vertex) position in same space.
// We can either move (vertex) position to world space, or the camera
// to object space. In this example, we transform camera to object
// space and use that as the rayOrigin in the fragment shader.

varying vec3 v_hitPos; // default in object space
varying vec3 v_hitPosWorldSpace;
varying vec3 v_cameraObjectSpace;

void main() {
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);

  v_hitPos = position.xyz;

  // In this case, we move the (vertex) position to world space.
  // Notice we multiply by modelMatrix, not modelViewMatrix.
  v_hitPosWorldSpace = (modelMatrix * vec4(position, 1.0)).xyz;

  // In this case, we move the camera to object space.
  // Notice we use inverse(modelMatrix) + put camera in homogeneous coords.
  v_cameraObjectSpace = (inverse(modelMatrix) * vec4(u_camera, 1.0)).xyz;
}

================================================
FILE: src/shaders/vertexV2.glsl
================================================
precision mediump float;

uniform vec3 u_camera; // default in world space
uniform vec3 u_resolution;
uniform float u_time;

// The Art of Code - https://www.youtube.com/watch?v=S8AWd66hoCo
// It is important to keep camera + (vertex) position in same space.
// We can either move (vertex) position to world space, or the camera
// to object space. In this example, we transform camera to object
// space and use that as the rayOrigin in the fragment shader.

varying vec3 v_hitPos; // default in object space
varying vec3 v_hitPosWorldSpace;
varying vec3 v_cameraObjectSpace;

void main() {
  // Three.js variables: position, projectionMatrix, modelViewMatrix, modelMatrix
  vec3 pos = position;

  gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);

  v_hitPos = position.xyz;

  // In this case, we move the (vertex) position to world space.
  // Notice we multiply by modelMatrix, not modelViewMatrix.
  v_hitPosWorldSpace = (modelMatrix * vec4(position, 1.0)).xyz;

  // In this case, we move the camera to object space.
  // Notice we use inverse(modelMatrix) + put camera in homogeneous coords.
  v_cameraObjectSpace = (inverse(modelMatrix) * vec4(u_camera, 1.0)).xyz;
}

================================================
FILE: src/vite-env.d.ts
================================================
/// <reference types="vite/client" />


================================================
FILE: tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
  content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
  theme: {
    extend: {},
  },
  plugins: [],
};


================================================
FILE: tsconfig.json
================================================
{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}


================================================
FILE: tsconfig.node.json
================================================
{
  "compilerOptions": {
    "composite": true,
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true,
    "strict": true
  },
  "include": ["vite.config.ts"]
}


================================================
FILE: vite.config.ts
================================================
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
});
Download .txt
gitextract_8cedh4io/

├── .eslintrc.cjs
├── .gitignore
├── LICENSE
├── README.md
├── index.html
├── package.json
├── postcss.config.js
├── src/
│   ├── App.tsx
│   ├── ThreeSceneV1.tsx
│   ├── ThreeSceneV2.tsx
│   ├── index.css
│   ├── main.tsx
│   ├── shaders/
│   │   ├── fragmentV1.glsl
│   │   ├── fragmentV2.glsl
│   │   ├── vertexV1.glsl
│   │   └── vertexV2.glsl
│   └── vite-env.d.ts
├── tailwind.config.js
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts
Download .txt
SYMBOL INDEX (1 symbols across 1 files)

FILE: src/App.tsx
  function App (line 4) | function App() {
Condensed preview — 21 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (48K chars).
[
  {
    "path": ".eslintrc.cjs",
    "chars": 436,
    "preview": "module.exports = {\n  root: true,\n  env: { browser: true, es2020: true },\n  extends: [\n    'eslint:recommended',\n    'plu"
  },
  {
    "path": ".gitignore",
    "chars": 2086,
    "preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n.pnpm-debug.log*\n\n# Diagnostic reports"
  },
  {
    "path": "LICENSE",
    "chars": 20263,
    "preview": "Attribution-NonCommercial-ShareAlike 4.0 International\n\n================================================================"
  },
  {
    "path": "README.md",
    "chars": 2408,
    "preview": "# 🌊 Volume Rendering\n\nVolume rendering is a common technique used to render 3D medical imaging data like MRIs or CT scan"
  },
  {
    "path": "index.html",
    "chars": 366,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <link rel=\"icon\" type=\"image/svg+xml\" href=\"/"
  },
  {
    "path": "package.json",
    "chars": 953,
    "preview": "{\n  \"name\": \"volume-rendering\",\n  \"private\": true,\n  \"version\": \"0.0.0\",\n  \"type\": \"module\",\n  \"scripts\": {\n    \"dev\": \""
  },
  {
    "path": "postcss.config.js",
    "chars": 80,
    "preview": "export default {\n  plugins: {\n    tailwindcss: {},\n    autoprefixer: {},\n  },\n}\n"
  },
  {
    "path": "src/App.tsx",
    "chars": 296,
    "preview": "import { ThreeSceneV1 } from './ThreeSceneV1';\nimport { ThreeSceneV2 } from './ThreeSceneV2';\n\nfunction App() {\n  const "
  },
  {
    "path": "src/ThreeSceneV1.tsx",
    "chars": 2329,
    "preview": "import { useEffect, useRef } from 'react';\nimport * as Three from 'three';\nimport { OrbitControls } from 'three/examples"
  },
  {
    "path": "src/ThreeSceneV2.tsx",
    "chars": 5036,
    "preview": "import { useEffect, useRef, useState } from 'react';\nimport * as Three from 'three';\nimport { GUI } from 'dat.gui';\nimpo"
  },
  {
    "path": "src/index.css",
    "chars": 1221,
    "preview": ":root {\n  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;\n  line-height: 1.5;\n  font-weight: 400;\n\n"
  },
  {
    "path": "src/main.tsx",
    "chars": 241,
    "preview": "import React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport App from './App.tsx';\nimport './index.css';\n\n"
  },
  {
    "path": "src/shaders/fragmentV1.glsl",
    "chars": 1359,
    "preview": "uniform vec3 u_camera;\nuniform vec3 u_resolution;\n\nvarying vec3 v_hitPos;\nvarying vec3 v_hitPosWorldSpace;\nvarying vec3 "
  },
  {
    "path": "src/shaders/fragmentV2.glsl",
    "chars": 5215,
    "preview": "precision mediump int;\nprecision mediump float;\n\nuniform vec3 u_camera;\nuniform vec3 u_resolution;\nuniform mediump sampl"
  },
  {
    "path": "src/shaders/vertexV1.glsl",
    "chars": 1043,
    "preview": "uniform vec3 u_camera; // default in world space\nuniform vec3 u_resolution;\n\n// The Art of Code: https://www.youtube.com"
  },
  {
    "path": "src/shaders/vertexV2.glsl",
    "chars": 1193,
    "preview": "precision mediump float;\n\nuniform vec3 u_camera; // default in world space\nuniform vec3 u_resolution;\nuniform float u_ti"
  },
  {
    "path": "src/vite-env.d.ts",
    "chars": 38,
    "preview": "/// <reference types=\"vite/client\" />\n"
  },
  {
    "path": "tailwind.config.js",
    "chars": 170,
    "preview": "/** @type {import('tailwindcss').Config} */\nexport default {\n  content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],\n"
  },
  {
    "path": "tsconfig.json",
    "chars": 605,
    "preview": "{\n  \"compilerOptions\": {\n    \"target\": \"ES2020\",\n    \"useDefineForClassFields\": true,\n    \"lib\": [\"ES2020\", \"DOM\", \"DOM."
  },
  {
    "path": "tsconfig.node.json",
    "chars": 233,
    "preview": "{\n  \"compilerOptions\": {\n    \"composite\": true,\n    \"skipLibCheck\": true,\n    \"module\": \"ESNext\",\n    \"moduleResolution\""
  },
  {
    "path": "vite.config.ts",
    "chars": 136,
    "preview": "import { defineConfig } from 'vite';\nimport react from '@vitejs/plugin-react';\n\nexport default defineConfig({\n  plugins:"
  }
]

About this extraction

This page contains the full source code of the SuboptimalEng/volume-rendering GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 21 files (44.6 KB), approximately 12.1k tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!