Skip to content

Commit d45dab8

Browse files
Merge pull request #77 from yushiang-demo/dev
v2.1.1
2 parents 8dd1ba4 + 4f092ad commit d45dab8

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

CHANGELOG.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ The format is based on [Keep a Changelog](https://github.com/olivierlacan/keep-a
1313

1414
### Removed
1515

16+
## [2.1.1] - 2024-03-05
17+
18+
### Added
19+
20+
### Changed
21+
22+
### Fixed
23+
24+
- Fix texture not load. (https://github.com/yushiang-demo/pano-to-mesh/pull/76)
25+
26+
### Removed
27+
1628
## [2.1.0] - 2024-02-18
1729

1830
### Added
@@ -213,7 +225,8 @@ Codes without pull requests won't be recorded.
213225

214226
### Removed
215227

216-
[unreleased]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.1.0...HEAD
228+
[unreleased]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.1.1...HEAD
229+
[2.1.1]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.0.0...v2.1.0
217230
[2.1.0]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.0.1...v2.1.0
218231
[2.0.1]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.0.0...v2.0.1
219232
[2.0.0]: https://github.com/yushiang-demo/PanoToMesh/compare/v1.4.1...v2.0.0

apps/editors/decoration/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const dev = process.env.NODE_ENV === "development";
3232
const Editor = ({ data }) => {
3333
const threeRef = useRef(null);
3434
const mediaIndexMap = useRef(null);
35+
const panorama = Loaders.useTexture({ src: data.panorama });
3536
const [baseMesh, setBaseMesh] = useState(null);
3637
const [mouse, setMouse] = useState([0, 0]);
3738
const [camera, setCamera] = useState(null);
@@ -109,7 +110,7 @@ const Editor = ({ data }) => {
109110
const textureMeshProps = {
110111
...data,
111112
layout2D,
112-
panorama: Loaders.useTexture({ src: data.panorama }),
113+
panorama,
113114
};
114115

115116
const onLoad = useCallback((mesh) => {

apps/editors/layout2d.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ const Editor = ({ data }) => {
8888
)}
8989
</Toolbar>
9090
<RatioLockedDiv>
91-
<ThreeCanvas {...eventHandlers} dev={dev}>
92-
<PanoramaOutline {...props} />
93-
</ThreeCanvas>
91+
{panorama && (
92+
<ThreeCanvas {...eventHandlers} dev={dev}>
93+
<PanoramaOutline {...props} />
94+
</ThreeCanvas>
95+
)}
9496
</RatioLockedDiv>
9597
</PageContainer>
9698
);

apps/editors/layout3d.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const dev = process.env.NODE_ENV === "development";
3636
const Editor = ({ data }) => {
3737
const canvas3DRef = useRef(null);
3838
const textureCanvasRef = useRef(null);
39+
const panorama = Loaders.useTexture({ src: data.panorama });
3940
const [panoramaOrigin, setPanoramaOrigin] = useState(data.panoramaOrigin);
4041
const [floorY] = useState(data.floorY);
4142
const [ceilingY, setCeilingY] = useState(data.ceilingY);
@@ -58,7 +59,7 @@ const Editor = ({ data }) => {
5859
floorY,
5960
ceilingY,
6061
layout2D,
61-
panorama: Loaders.useTexture({ src: data.panorama }),
62+
panorama,
6263
panoramaOrigin,
6364
};
6465

@@ -78,6 +79,8 @@ const Editor = ({ data }) => {
7879
canvas3DRef.current.cameraControls.focus(mesh, false, false, false);
7980
};
8081

82+
if (!panorama) return null;
83+
8184
return (
8285
<>
8386
<ThreeCanvas dev={dev} ref={canvas3DRef}>

apps/viewer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const dev = process.env.NODE_ENV === "development";
2020
const Viewer = ({ data }) => {
2121
const threeRef = useRef(null);
2222
const [isTopView, setIsTopView] = useState(true);
23+
const panorama = Loaders.useTexture({ src: data.panorama });
2324
const [isCameraMoving, setIsCameraMoving] = useState(false);
2425
const [baseMesh, setBaseMesh] = useState(null);
2526
const geometryInfo = useMemo(
@@ -39,7 +40,7 @@ const Viewer = ({ data }) => {
3940
const textureMeshProps = {
4041
...data,
4142
layout2D,
42-
panorama: Loaders.useTexture({ src: data.panorama }),
43+
panorama,
4344
};
4445

4546
const onLoad = useCallback((mesh) => {

packages/three/hooks/texture.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const useTexture = ({ src }) => {
77
const [texture, setTexture] = useState(null);
88

99
useEffect(() => {
10-
setTexture(loader.load(src));
10+
loader.load(src, setTexture);
1111
}, [src]);
1212

1313
return texture;

0 commit comments

Comments
 (0)