removed: liveblock
This commit is contained in:
+7
-27
@@ -1,21 +1,20 @@
|
|||||||
import "./App.css";
|
import "./App.css";
|
||||||
import { OrbitControls } from "@react-three/drei";
|
import { OrbitControls } from "@react-three/drei";
|
||||||
import { Canvas } from "@react-three/fiber";
|
import { Canvas } from "@react-three/fiber";
|
||||||
import { Suspense, useEffect } from "react";
|
import { Suspense } from "react";
|
||||||
import { LinearToneMapping } from "three";
|
import { LinearToneMapping } from "three";
|
||||||
import { InfoPanel, Scene } from "./components";
|
import { InfoPanel, Scene } from "./components";
|
||||||
import useStore from "./store";
|
|
||||||
|
|
||||||
const LegoRoom = () => {
|
const LegoRoom = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Canvas
|
<Canvas
|
||||||
// gl={{
|
gl={{
|
||||||
// alpha: false,
|
alpha: false,
|
||||||
// antialias: false,
|
antialias: false,
|
||||||
// powerPreference: "high-performance",
|
powerPreference: "high-performance",
|
||||||
// toneMapping: LinearToneMapping,
|
toneMapping: LinearToneMapping,
|
||||||
// }}
|
}}
|
||||||
camera={{
|
camera={{
|
||||||
position: [17.43, 657.76, 943.51],
|
position: [17.43, 657.76, 943.51],
|
||||||
near: 0.1,
|
near: 0.1,
|
||||||
@@ -36,25 +35,6 @@ const LegoRoom = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
// const enterRoom = useStore((state) => state.liveblocks.enterRoom);
|
|
||||||
// const leaveRoom = useStore((state) => state.liveblocks.leaveRoom);
|
|
||||||
// const isLoading = useStore((state) => state.liveblocks.isStorageLoading);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// enterRoom("lego-demo-room");
|
|
||||||
// return () => {
|
|
||||||
// leaveRoom("lego-demo-room");
|
|
||||||
// };
|
|
||||||
// }, [enterRoom, leaveRoom]);
|
|
||||||
|
|
||||||
// if (isLoading) {
|
|
||||||
// return (
|
|
||||||
// <>
|
|
||||||
// <h1>Loading.....</h1>
|
|
||||||
// </>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<LegoRoom />
|
<LegoRoom />
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ export const BrickCursor = forwardRef(
|
|||||||
0,
|
0,
|
||||||
(offsetZ * width) / dimensions.z,
|
(offsetZ * width) / dimensions.z,
|
||||||
]}
|
]}
|
||||||
castShadow={true}
|
|
||||||
receiveShadow={true}
|
|
||||||
>
|
>
|
||||||
<boxGeometry args={[width, height, depth]} />
|
<boxGeometry args={[width, height, depth]} />
|
||||||
<meshBasicMaterial
|
<meshBasicMaterial
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import useStore from "../store/index";
|
|
||||||
|
|
||||||
export const InfoPanel = () => {
|
export const InfoPanel = () => {
|
||||||
const clearBricks = useStore((state) => state.clearBricks);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -16,8 +13,9 @@ export const InfoPanel = () => {
|
|||||||
width: "200px",
|
width: "200px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* Use panel on right top corner to customize the Lego Bricks Properties */}
|
Use panel on right top corner to customize the Lego Bricks Properties Use
|
||||||
<button onClick={clearBricks}>Clear Scene</button>
|
<br />
|
||||||
|
"AWSD" to chnage the anchor points of bricks
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,15 +8,10 @@ import {
|
|||||||
useAnchorShorcuts,
|
useAnchorShorcuts,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
import { useControls } from "leva";
|
import { useControls } from "leva";
|
||||||
import useStore from "../store";
|
|
||||||
// import { ContactShadows } from "@react-three/drei";
|
|
||||||
|
|
||||||
let t;
|
let t;
|
||||||
|
|
||||||
export const Scene = () => {
|
export const Scene = () => {
|
||||||
// const bricks = useStore((state) => state.bricksState);
|
|
||||||
// const setBricks = useStore((state) => state.setBricks);
|
|
||||||
|
|
||||||
const [bricks, setBricks] = useState([]);
|
const [bricks, setBricks] = useState([]);
|
||||||
|
|
||||||
const bricksBoundBox = useRef([]);
|
const bricksBoundBox = useRef([]);
|
||||||
@@ -111,7 +106,6 @@ export const Scene = () => {
|
|||||||
translation: { x: anchorX, z: anchorZ },
|
translation: { x: anchorX, z: anchorZ },
|
||||||
};
|
};
|
||||||
|
|
||||||
// setBricks(brickData);
|
|
||||||
setBricks((prevBricks) => [...prevBricks, brickData]);
|
setBricks((prevBricks) => [...prevBricks, brickData]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import create from "zustand";
|
|
||||||
import { createClient } from "@liveblocks/client";
|
|
||||||
import { liveblocks } from "@liveblocks/zustand";
|
|
||||||
|
|
||||||
const client = createClient({
|
|
||||||
publicApiKey:
|
|
||||||
"pk_dev_TZ6PEVqkJbtrcNqq8bnqghwmoxDr1WuSOcxycuo-_qYBLp9jDPQ12nhRcyNU_L_o",
|
|
||||||
});
|
|
||||||
|
|
||||||
const useStore = create(
|
|
||||||
liveblocks(
|
|
||||||
(set, get) => ({
|
|
||||||
bricksState: [],
|
|
||||||
setBricks: (newBrick) => {
|
|
||||||
const { bricksState } = get();
|
|
||||||
|
|
||||||
set({
|
|
||||||
bricksState: [...bricksState, newBrick],
|
|
||||||
});
|
|
||||||
},
|
|
||||||
clearBricks: () => {
|
|
||||||
set({
|
|
||||||
bricksState: [],
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
{ client, storageMapping: { bricksState: true } }
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
export default useStore;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user