Skip to content

Commit

Permalink
Naming
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Aug 25, 2023
1 parent a005977 commit 3c7d4aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions viser/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ function BackgroundImage() {
hasDepth: { value: false },
},
});
const { backgroundMaterialRef } =
React.useContext(ViewerContext)!;
const { backgroundMaterialRef } = React.useContext(ViewerContext)!;
backgroundMaterialRef.current = backgroundMaterial;
const backgroundMesh = React.useRef<THREE.Mesh>(null);
useFrame(({ camera }) => {
Expand Down
10 changes: 4 additions & 6 deletions viser/client/src/WebsocketInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,13 @@ function useMessageHandler() {
new TextureLoader().load(
`data:${message.media_type};base64,${message.base64_rgb}`,
(texture) => {
// TODO: this onLoad callback prevents flickering, but could cause messages to be handled slightly out-of-order.
texture.encoding = THREE.sRGBEncoding;

const oldBackground =
const oldBackgroundTexture =
viewer.backgroundMaterialRef.current!.uniforms.colorMap.value;
viewer.backgroundMaterialRef.current!.uniforms.colorMap.value =
texture;
if (isTexture(oldBackground)) oldBackground.dispose();
if (isTexture(oldBackgroundTexture)) oldBackgroundTexture.dispose();

viewer.useGui.setState({ backgroundAvailable: true });
},
Expand All @@ -439,12 +438,11 @@ function useMessageHandler() {
new TextureLoader().load(
`data:image/png;base64,${message.base64_depth}`,
(texture) => {
// TODO: this onLoad callback prevents flickering, but could cause messages to be handled slightly out-of-order.);
const olddepthtex =
const oldDepthTexture =
viewer.backgroundMaterialRef.current?.uniforms.depthMap.value;
viewer.backgroundMaterialRef.current!.uniforms.depthMap.value =
texture;
if (isTexture(olddepthtex)) olddepthtex.dispose();
if (isTexture(oldDepthTexture)) oldDepthTexture.dispose();
},
);
}
Expand Down

0 comments on commit 3c7d4aa

Please sign in to comment.