Skip to content

Commit

Permalink
Merge pull request #77 from yushiang-demo/dev
Browse files Browse the repository at this point in the history
v2.1.1
  • Loading branch information
tsengyushiang authored Mar 5, 2024
2 parents 8dd1ba4 + 4f092ad commit d45dab8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ The format is based on [Keep a Changelog](https://github.com/olivierlacan/keep-a

### Removed

## [2.1.1] - 2024-03-05

### Added

### Changed

### Fixed

- Fix texture not load. (https://github.com/yushiang-demo/pano-to-mesh/pull/76)

### Removed

## [2.1.0] - 2024-02-18

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

### Removed

[unreleased]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.1.0...HEAD
[unreleased]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.1.1...HEAD
[2.1.1]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.0.0...v2.1.0
[2.1.0]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/yushiang-demo/PanoToMesh/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/yushiang-demo/PanoToMesh/compare/v1.4.1...v2.0.0
Expand Down
3 changes: 2 additions & 1 deletion apps/editors/decoration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const dev = process.env.NODE_ENV === "development";
const Editor = ({ data }) => {
const threeRef = useRef(null);
const mediaIndexMap = useRef(null);
const panorama = Loaders.useTexture({ src: data.panorama });
const [baseMesh, setBaseMesh] = useState(null);
const [mouse, setMouse] = useState([0, 0]);
const [camera, setCamera] = useState(null);
Expand Down Expand Up @@ -109,7 +110,7 @@ const Editor = ({ data }) => {
const textureMeshProps = {
...data,
layout2D,
panorama: Loaders.useTexture({ src: data.panorama }),
panorama,
};

const onLoad = useCallback((mesh) => {
Expand Down
8 changes: 5 additions & 3 deletions apps/editors/layout2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ const Editor = ({ data }) => {
)}
</Toolbar>
<RatioLockedDiv>
<ThreeCanvas {...eventHandlers} dev={dev}>
<PanoramaOutline {...props} />
</ThreeCanvas>
{panorama && (
<ThreeCanvas {...eventHandlers} dev={dev}>
<PanoramaOutline {...props} />
</ThreeCanvas>
)}
</RatioLockedDiv>
</PageContainer>
);
Expand Down
5 changes: 4 additions & 1 deletion apps/editors/layout3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const dev = process.env.NODE_ENV === "development";
const Editor = ({ data }) => {
const canvas3DRef = useRef(null);
const textureCanvasRef = useRef(null);
const panorama = Loaders.useTexture({ src: data.panorama });
const [panoramaOrigin, setPanoramaOrigin] = useState(data.panoramaOrigin);
const [floorY] = useState(data.floorY);
const [ceilingY, setCeilingY] = useState(data.ceilingY);
Expand All @@ -58,7 +59,7 @@ const Editor = ({ data }) => {
floorY,
ceilingY,
layout2D,
panorama: Loaders.useTexture({ src: data.panorama }),
panorama,
panoramaOrigin,
};

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

if (!panorama) return null;

return (
<>
<ThreeCanvas dev={dev} ref={canvas3DRef}>
Expand Down
3 changes: 2 additions & 1 deletion apps/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const dev = process.env.NODE_ENV === "development";
const Viewer = ({ data }) => {
const threeRef = useRef(null);
const [isTopView, setIsTopView] = useState(true);
const panorama = Loaders.useTexture({ src: data.panorama });
const [isCameraMoving, setIsCameraMoving] = useState(false);
const [baseMesh, setBaseMesh] = useState(null);
const geometryInfo = useMemo(
Expand All @@ -39,7 +40,7 @@ const Viewer = ({ data }) => {
const textureMeshProps = {
...data,
layout2D,
panorama: Loaders.useTexture({ src: data.panorama }),
panorama,
};

const onLoad = useCallback((mesh) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/three/hooks/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useTexture = ({ src }) => {
const [texture, setTexture] = useState(null);

useEffect(() => {
setTexture(loader.load(src));
loader.load(src, setTexture);
}, [src]);

return texture;
Expand Down

0 comments on commit d45dab8

Please sign in to comment.