Skip to content

Commit 617939a

Browse files
marklundinCopilot
andauthored
Fully Removes Deprecated <EnvAtlas/> component (#247)
* refactor: remove deprecated EnvAtlas component and update references to Environment component * chore: fully remove deprecated <EnvAtlas/> component * Update packages/docs/templates/HomePageExample.jsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: replace EnvAtlas component with Environment component and update related imports --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3082203 commit 617939a

File tree

9 files changed

+18
-170
lines changed

9 files changed

+18
-170
lines changed

.changeset/green-llamas-repeat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@playcanvas/react": minor
3+
---
4+
5+
Fully removes the deprecated <EnvAtlas/> component

packages/docs/client-mdx-components.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Application, Entity } from '@playcanvas/react'
22
import { OrbitControls } from '@playcanvas/react/scripts'
3-
import { Align, Light, Anim, Camera, Collision, EnvAtlas, GSplat, Script, Render, RigidBody, Environment } from '@playcanvas/react/components'
3+
import { Align, Light, Anim, Camera, Collision, GSplat, Script, Render, RigidBody, Environment } from '@playcanvas/react/components'
44

55
import ReactQueryProvider from '@docs-components/ReactQueryProvider'
66

@@ -21,7 +21,7 @@ export const defaultComponents = {
2121
ReactQueryProvider,
2222
Application,
2323
Entity,
24-
Align, Anim, Camera, Collision, EnvAtlas, GSplat, Script, Render, RigidBody, Light, Environment,
24+
Align, Anim, Camera, Collision, GSplat, Script, Render, RigidBody, Light, Environment,
2525
OrbitControls,
2626
EnvAtlasComponent,
2727
Grid,

packages/docs/components/EnvAtlas.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"use client";
22

3-
import { FC/*, useLayoutEffect */ } from "react";
3+
import React, { FC, ComponentProps } from "react";
44
import { useEnvAtlas } from "./hooks/use-asset";
5-
import type { Asset } from "playcanvas";
6-
import { EnvAtlas } from "@playcanvas/react/components";
7-
// import { useApp } from "@playcanvas/react/hooks";
5+
import { Environment } from "@playcanvas/react/components";
86

9-
type EnvAtlasComponentsProps = {
7+
type EnvAtlasComponentsProps = ComponentProps<typeof Environment> & {
108
src: string;
119
intensity?: number;
1210
}
@@ -19,7 +17,7 @@ type EnvAtlasComponentsProps = {
1917

2018
const { data } = useEnvAtlas(src);
2119

22-
return <EnvAtlas asset={data as Asset} {...props} skyboxIntensity={intensity} showSkybox={false}/>
20+
return <Environment envAtlas={data} {...props} skyboxIntensity={intensity} showSkybox={false}/>
2321

2422
}
2523

packages/docs/content/docs/api/components/envatlas.mdx

Lines changed: 0 additions & 59 deletions
This file was deleted.

packages/docs/content/docs/api/hooks/use-asset.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ See the [useMaterial](/docs/api/hooks/use-asset/useMaterial) hook and [Render](/
163163

164164
## useEnvAtlas
165165

166-
A specialized hook for loading environment atlas textures. Pass the source URL of the texture file and any additional properties to pass to the asset loader and use the resulting asset in the [`<EnvAtlas/>`](/docs/api/components/EnvAtlas) component.
166+
A specialized hook for loading environment atlas textures. Pass the source URL of the texture file and any additional properties to pass to the asset loader and use the resulting asset in the [`<Environment/>`](/docs/api/components/Environment) component.
167167

168168
```tsx copy filename="render-env-atlas.tsx"
169169
import { useEnvAtlas } from '@playcanvas/react/hooks';
170+
import { Environment } from '@playcanvas/react/components';
170171

171172
export function RenderEnvAtlas() {
172173
const { asset, loading, error } = useEnvAtlas('env.jpg');
@@ -175,7 +176,7 @@ export function RenderEnvAtlas() {
175176
if (error) return <ErrorMessage message={error} />;
176177
if (!asset) return null;
177178

178-
return <EnvAtlas asset={asset} />;
179+
return <Environment envAtlas={asset} />;
179180
}
180181
```
181182

packages/docs/templates/HomePageExample.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { Container, Entity } from '@playcanvas/react';
4-
import { Camera, EnvAtlas } from '@playcanvas/react/components';
4+
import { Camera, Environment } from '@playcanvas/react/components';
55
import { OrbitControls } from '@playcanvas/react/scripts';
66

77
import { useEnvAtlas, useModel } from '@components/hooks/use-asset';
@@ -12,11 +12,11 @@ import ShadowCatcher from '@components/ShadowCatcher';
1212

1313
const Example = () => {
1414

15-
const { data: envMap } = useEnvAtlas('/environment-map.png');
15+
const { data: envAtlas } = useEnvAtlas('/environment-map.png');
1616
const { data: model } = useModel('/lamborghini_vision_gt.glb');
1717

1818
return (<Entity>
19-
<EnvAtlas asset={envMap} skyboxIntensity={1.2} showSkybox={false} />
19+
{ envAtlas && <Environment envAtlas={envAtlas} showSkybox={false}/> }
2020
<Grid />
2121
<ShadowCatcher width={5} depth={5} />
2222
<Entity name='camera' position={[4, 1, 4]}>

packages/lib/src/components/EnvAtlas.tsx

Lines changed: 0 additions & 96 deletions
This file was deleted.

packages/lib/src/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client"
22

3-
export { EnvAtlas } from './EnvAtlas.tsx'
43
export { Camera } from './Camera.tsx'
54
export { GSplat } from './GSplat.tsx'
65
export { Light } from './Light.tsx'

packages/lib/src/hooks/use-asset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export const useTexture = (
229229
* if (error) return <ErrorMessage message={error} />;
230230
* if (!asset) return null;
231231
*
232-
* return <EnvAtlas asset={asset} />;
232+
* return <Environment envAtlas={asset} />;
233233
* ```
234234
*/
235235
export const useEnvAtlas = (

0 commit comments

Comments
 (0)