Skip to content

Commit

Permalink
Merge pull request #1 from lumalabs/george/worlds-within-worlds
Browse files Browse the repository at this point in the history
George/worlds within worlds
  • Loading branch information
haxiomic authored Dec 4, 2023
2 parents 71e7e3c + 04e4ee9 commit 68aaf43
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 323 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ scene.background = scene.fog.color;
## Scene Lighting
[![scene-lighting-demo](https://cdn-luma.com/public/lumalabs.ai/luma-web-library/assets/images/scene-lighting-preview.jpg)](https://cdn-luma.com/public/lumalabs.ai/luma-web-library/index.html#scene-lighting)

It's possible to illuminate three.js scenes with Luma splats. To do so, we can render a cubemap of the splats and use it as the scene environment. This is done by calling `captureCubeMap` on the splats object. We first wait for the splats to fully load before capturing the cubemap. To ensure the splats are fully rendered at the time of capture, we disable the loading animation.
It's possible to illuminate three.js scenes with Luma splats. To do so, we can render a cubemap of the splats and use it as the scene environment. This is done by calling `captureCubemap()` on the splats object. We first wait for the splats to fully load before capturing the cubemap. To ensure the splats are fully rendered at the time of capture, we disable the loading animation.

**[DemoLighting.ts](https://cdn-luma.com/public/lumalabs.ai/luma-web-library/src/DemoLighting.ts)**
```ts
Expand All @@ -102,10 +102,11 @@ let splats = new LumaSplatsThree({
});

splats.onLoad = () => {
let capturedTexture = splats.captureCubeMap(renderer);
scene.environment = capturedTexture;
scene.background = capturedTexture;
scene.backgroundBlurriness = 0.5;
splats.captureCubemap(renderer).then((capturedTexture) => {
scene.environment = capturedTexture;
scene.background = capturedTexture;
scene.backgroundBlurriness = 0.5;
});
}
```

Expand Down
441 changes: 221 additions & 220 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"scripts": {
"build": "npx esbuild src/index.tsx --bundle --outdir=dist --sourcemap --preserve-symlinks --loader:.md=text --minify",
"dev": "npx esbuild src/index.tsx --bundle --outdir=dist --sourcemap --preserve-symlinks --watch --serve=localhost:3002 --servedir=. --loader:.md=text",
"start": "npm run dev"
"start": "npm run dev",
"deploy": "./misc/deploy.sh"
},
"author": "",
"license": "ISC",
"dependencies": {
"@lumaai/luma-web": "^0.1.8",
"@lumaai/luma-web": "^0.1.9",
"@react-three/drei": "^9.88.17",
"@react-three/fiber": "^8.15.11",
"@types/react": "^18.2.38",
Expand Down
15 changes: 8 additions & 7 deletions src/DemoFog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ export function DemoFog(props: DemoProps) {
};

splats.onLoad = () => {
let environmentMap = splats.captureCubeMap(renderer);
scene.environment = environmentMap;
let environmentProbes = new EnvironmentProbes(4);
environmentProbes.position.set(-3, 1, 0.25);
environmentProbes.rotation.y = Math.PI / 2;
environmentProbes.scale.setScalar(3);
scene.add(environmentProbes);
splats.captureCubemap(renderer).then(environmentMap => {
scene.environment = environmentMap;
let environmentProbes = new EnvironmentProbes(4);
environmentProbes.position.set(-3, 1, 0.25);
environmentProbes.rotation.y = Math.PI / 2;
environmentProbes.scale.setScalar(3);
scene.add(environmentProbes);
});
}

// gui for fog
Expand Down
9 changes: 5 additions & 4 deletions src/DemoLighting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export function DemoLighting(props: DemoProps) {
});

splats.onLoad = () => {
let capturedTexture = splats.captureCubeMap(renderer);
scene.environment = capturedTexture;
scene.background = capturedTexture;
scene.backgroundBlurriness = 0.5;
splats.captureCubemap(renderer).then(capturedTexture => {
scene.environment = capturedTexture;
scene.background = capturedTexture;
scene.backgroundBlurriness = 0.5;
});
}

scene.add(splats);
Expand Down
Loading

0 comments on commit 68aaf43

Please sign in to comment.