Skip to content

Commit

Permalink
Merge pull request #41 from yushiang-demo/refactor-yarn-workspace-pac…
Browse files Browse the repository at this point in the history
…kages

Refactor: yarn workspace
  • Loading branch information
tsengyushiang committed Sep 24, 2023
2 parents eb8c3dc + 282e4a2 commit 6c6d939
Show file tree
Hide file tree
Showing 50 changed files with 64 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://github.com/olivierlacan/keep-a

### Changed

- Use yarn workspace for `three`, `js-base64` and `pako` packages. (https://github.com/yushiang-demo/PanoToMesh/pull/41)

### Fixed

- Avoid creating backface plane and bbox. (https://github.com/yushiang-demo/PanoToMesh/pull/39)
Expand Down
2 changes: 1 addition & 1 deletion apps/editors/decoration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ThreeCanvas,
PanoramaProjectionMesh,
MeshIndexMap,
} from "../../../three";
} from "@pano-to-mesh/three";
import useClick2AddWalls from "../../../hooks/useClick2AddWalls";
import useDragTransformation from "../../../hooks/useDragTransformation";
import { useStoreDataToHash } from "../../../hooks/useHash";
Expand Down
2 changes: 1 addition & 1 deletion apps/editors/layout2d.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo, useState } from "react";

import { Loaders, PanoramaOutline, ThreeCanvas } from "../../three";
import { Loaders, PanoramaOutline, ThreeCanvas } from "@pano-to-mesh/three";
import useClick2AddWalls from "../../hooks/useClick2AddWalls";
import PageContainer from "../../components/PageContainer";
import Input from "../../components/Input";
Expand Down
7 changes: 6 additions & 1 deletion apps/editors/layout3d.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, { useMemo, useRef, useState } from "react";
import ToolbarRnd from "../../components/ToolbarRnd";
import { Loaders, ThreeCanvas, PanoramaTextureMesh, Core } from "../../three";
import {
Loaders,
ThreeCanvas,
PanoramaTextureMesh,
Core,
} from "@pano-to-mesh/three";
import useClick2AddWalls from "../../hooks/useClick2AddWalls";
import Icons from "../../components/Icon";
import Toolbar from "../../components/Toolbar";
Expand Down
6 changes: 5 additions & 1 deletion apps/viewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React, { useRef, useMemo } from "react";

import { Loaders, ThreeCanvas, PanoramaProjectionMesh } from "../three";
import {
Loaders,
ThreeCanvas,
PanoramaProjectionMesh,
} from "@pano-to-mesh/three";
import useClick2AddWalls from "../hooks/useClick2AddWalls";
import MediaManager from "../components/MediaManager";

Expand Down
2 changes: 1 addition & 1 deletion components/MediaManager/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Css3DObject, Placeholder } from "../../three";
import { Css3DObject, Placeholder } from "@pano-to-mesh/three";

import RawHTML from "./RawHTML";
import { MEDIA } from "../../constant/media";
Expand Down
2 changes: 1 addition & 1 deletion hooks/useClick2AddWalls.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from "react";

import { Core } from "../three";
import { Core } from "@pano-to-mesh/three";

const pointSelector = (x, y, unitParser, threshold) => {
return ([candidateX, candidateY]) => {
Expand Down
2 changes: 1 addition & 1 deletion hooks/useDragTransformation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";

import { Core } from "../three";
import { Core } from "@pano-to-mesh/three";

const useDrag2AddPlane = ({ camera, raycasterTarget, onEnd }) => {
const [startPoint, setStartPoint] = useState(null);
Expand Down
2 changes: 1 addition & 1 deletion hooks/useHash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from "react";
import { encodeString, decodeString } from "../helpers/pako";
import { encodeString, decodeString } from "@pano-to-mesh/base64";

export const useStoreDataToHash = (data) => {
const [hash, setHash] = useState("");
Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
{
"name": "PanoToMesh",
"version": "0.1.0",
"name": "pano-to-mesh",
"version": "1.2.0",
"private": true,
"license": "MIT",
"workspaces": {
"packages": [
"packages/*"
]
},
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"js-base64": "^3.7.5",
"@pano-to-mesh/three": "1.0.0",
"@pano-to-mesh/base64": "1.0.0",
"next": "13.2.4",
"pako": "^2.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-rnd": "^10.4.1",
"styled-components": "^6.0.4",
"three": "^0.149.0",
"uuid": "^9.0.0"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions packages/base64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fromUint8Array, toUint8Array } from "js-base64";
import { deflate, inflate } from "pako";

export const encodeString = (text) => {
const data = new TextEncoder().encode(text);
const compressed = deflate(data, { level: 9 });
const uint8Array = fromUint8Array(compressed, true);
return encodeURIComponent(uint8Array);
};

export const decodeString = (text) => {
const decodedText = decodeURIComponent(text);
const data = toUint8Array(decodedText);
return inflate(data, { to: "string" });
};
8 changes: 8 additions & 0 deletions packages/base64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": "1.0.0",
"name": "@pano-to-mesh/base64",
"dependencies": {
"js-base64": "^3.7.5",
"pako": "^2.1.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions three/core/index.js → packages/three/core/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as THREE from "three";
import { v4 as uuidv4 } from "uuid";
import CameraControls from "./helpers/CameraControls";

function Three({ canvas, alpha = true, interactElement }) {
Expand Down Expand Up @@ -41,10 +40,10 @@ function Three({ canvas, alpha = true, interactElement }) {
};

const addBeforeRenderFunction = (func) => {
let id = uuidv4();
let id = THREE.MathUtils.generateUUID();

while (customRender[id] !== undefined) {
id = uuidv4();
id = THREE.MathUtils.generateUUID();
}

customRender[id] = func;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/three/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "1.0.0",
"name": "@pano-to-mesh/three",
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"three": "^0.149.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added public/resources/Xbot.glb
Binary file not shown.

0 comments on commit 6c6d939

Please sign in to comment.