Skip to content

Commit b9c192d

Browse files
authored
Add Splat Viewer example (#78)
* Add Splat Viewer example and enhance EnvAtlasComponent functionality * Fix example links and improve formatting in Splat Viewer documentation * Add publish workflow and update CI configuration * Add repository field to package.json
1 parent 29e1674 commit b9c192d

File tree

8 files changed

+573
-10
lines changed

8 files changed

+573
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,4 @@ jobs:
2727
run: npm i
2828

2929
- name: Lint ESLint
30-
run: npm run lint
31-
32-
- name: Continuous Release
33-
run: npx pkg-pr-new publish './packages/lib' --compact
30+
run: npm run lint

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Cancel Previous Runs
13+
uses: styfle/[email protected]
14+
with:
15+
access_token: ${{ github.token }}
16+
17+
- name: Checkout Main
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js 18.x
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 18.x
24+
cache: 'npm'
25+
26+
- name: Install Dependencies
27+
run: npm i
28+
29+
- name: Continuous Release
30+
run: npx pkg-pr-new publish './packages/lib' --compact

package-lock.json

Lines changed: 499 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "playcanvas-react-monorepo",
33
"description": "A monorepo for PlayCanvas React renderer and examples. Please see the packages directory for more information.",
44
"private": true,
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/playcanvas/react/tree/main/packages/lib"
8+
},
59
"workspaces": [
610
"packages/*"
711
],

packages/docs/src/app/_meta.global.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const examples = {
2121
'model-viewer' : {
2222
href: '/examples/model-viewer'
2323
},
24+
'splats' : {
25+
title: "Splat Viewer",
26+
href: '/examples/splats'
27+
},
2428
'physics' : {
2529
href: '/examples/physics'
2630
},
@@ -71,7 +75,6 @@ export default {
7175
items: {
7276
...examples,
7377
'splats': {
74-
display: 'hidden'
7578
}
7679
},
7780
},

packages/docs/src/components/EnvAtlas.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import { useApp } from "@playcanvas/react/hooks";
88

99
type EnvAtlasComponentsProps = {
1010
src: string;
11+
hideSkybox: boolean;
1112
intensity?: number;
1213
}
1314

14-
const EnvAtlasComponent: FC<EnvAtlasComponentsProps> = ({ src, intensity = 1, ...props }) => {
15+
const EnvAtlasComponent: FC<EnvAtlasComponentsProps> = ({ src, intensity = 1, hideSkybox = true, ...props }) => {
1516

1617
const app = useApp();
1718

1819
useLayoutEffect(() => {
1920
const layer = app?.scene?.layers?.getLayerByName('Skybox');
20-
if(layer){
21+
if(hideSkybox && layer){
2122
layer.enabled = false;
2223
}
2324
app.scene.skyboxIntensity = intensity;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export const Example = () => {
2+
3+
/**
4+
* Loading a Gaussian Splat ply
5+
*/
6+
7+
const splatURL = "https://6rpjo46zo7.ufs.sh/f/dTTBXSHFOX4z7irrg5DfZElT6yeQYKvdjgi5IsoB0cmu9OtF"
8+
const { data: splat } = useSplat(splatURL);
9+
10+
return <Entity>
11+
{/* Create a camera entity */}
12+
<EnvAtlasComponent
13+
src='/environment-map.png'
14+
hideSkybox={false}/>
15+
16+
<Entity>
17+
<Camera fov={30} />
18+
{ splat && <OrbitControls
19+
distanceMin={3}
20+
distanceMax={6} /> }
21+
</Entity>
22+
{/* Create the splat entity */}
23+
<Entity
24+
rotation={[0, -40, 0]}
25+
position={[0.2, -1.7, -6]}>
26+
{ splat && <GSplat asset={splat}/> }
27+
</Entity>
28+
</Entity>
29+
}
30+
31+
<Example />

packages/lib/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"access": "public"
8686
},
8787
"devDependencies": {
88+
"pkg-pr-new": "^0.0.41",
8889
"typescript": "5.7.3"
8990
},
9091
"dependencies": {

0 commit comments

Comments
 (0)