Skip to content

Commit

Permalink
Merge pull request #13 from RyugaRyuzaki/develop
Browse files Browse the repository at this point in the history
new project
  • Loading branch information
RyugaRyuzaki authored May 9, 2024
2 parents 0e34614 + 456c765 commit c588511
Show file tree
Hide file tree
Showing 58 changed files with 2,469 additions and 206 deletions.
301 changes: 301 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
},
"dependencies": {
"@preact/signals-react": "^1.3.7",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
Expand Down Expand Up @@ -60,4 +62,4 @@
"typescript": "^5.0.2",
"vite": "^4.3.9"
}
}
}
2 changes: 1 addition & 1 deletion src/BaseRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const BaseRoute = () => {
<>
<Routes>
<Route
path="/bim-modeling"
path={import.meta.env.PROD ? "/bim-modeling" : "/"}
element={
<>
<Helmet>
Expand Down
5 changes: 4 additions & 1 deletion src/BimModel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
PropertyComponent,
RendererComponent,
StructureComponent,
ProjectComponent,
} from "./src";

export class BimModel {
Expand All @@ -33,13 +34,15 @@ export class BimModel {
this.components = new Components(this.container);
const materialManager = this.components.tools.get(MaterialComponent);
materialManager.enabled = true;
const projectComponent = this.components.tools.get(ProjectComponent);
projectComponent.enabled = true;
const renderer = this.components.tools.get(RendererComponent);
renderer.enabled = true;
const cubeMapComponent = this.components.tools.get(CubeMapComponent);
cubeMapComponent.enabled = true;
const modelingComponent = this.components.tools.get(ModelingComponent);
modelingComponent.enabled = true;
modelingComponent.init(this.modeling);
modelingComponent.init(this.modeling, this.option);
const propertyComponent = this.components.tools.get(PropertyComponent);
propertyComponent.enabled = true;
const structureComponent = this.components.tools.get(StructureComponent);
Expand Down
2 changes: 1 addition & 1 deletion src/BimModel/src/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Components implements Disposable {
this.canvas.style.width = "100%";
this.canvas.style.height = "100%";
this.canvas.style.position = "absolute";
this.canvas.style.zIndex = "5000";
this.canvas.style.zIndex = "10";
this.clock = this.initClock();
}
private onResize = () => {
Expand Down
25 changes: 21 additions & 4 deletions src/BimModel/src/CubeMapComponent/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import * as THREE from "three";
import {Components} from "../Components";
import {ToolComponent} from "../Tool";
import {Component, Disposable, pixelRatio, Updateable, UUID} from "../types";
import {
Component,
Disposable,
INavigation,
pixelRatio,
Updateable,
UUID,
} from "../types";
import {CubeMapMaterial, BoxCube} from "./src";
import {RendererComponent} from "../RendererComponent";
import {defaultBox, defaultSphere, switchPick} from "../utils";

const near = 1,
far = 10000;
Expand All @@ -22,7 +30,8 @@ export class CubeMapComponent
static readonly uuid = UUID.CubeMapComponent;
enabled = false;
private materials = new CubeMapMaterial();

private box: THREE.Box3 = defaultBox;
private sphere: THREE.Sphere = defaultSphere();
private container!: HTMLDivElement;
private canvas!: HTMLCanvasElement;
set align(position: ICubeMapPosition) {
Expand Down Expand Up @@ -148,7 +157,7 @@ export class CubeMapComponent
this.container.style.width = this.width + "px";
this.container.style.height = this.height + "px";
this.container.style.position = "absolute";
this.container.style.zIndex = "6000";
this.container.style.zIndex = "20";
this.container.appendChild(this.canvas);
container.appendChild(this.container);
this.align = "top-right";
Expand Down Expand Up @@ -231,7 +240,7 @@ export class CubeMapComponent
if (!this.found) return;
const name = this.found.object.name;
if (!name) return;
// this.onNavigationView(name);
this.onNavigationView(name);
});
}
/**
Expand Down Expand Up @@ -267,5 +276,13 @@ export class CubeMapComponent
camera.lookAt(0, 0, 0);
return camera;
}
private onNavigationView(name: INavigation) {
const controls =
this.components.tools.get(RendererComponent).camera.cameraControls;
const {center} = this.sphere;
const pos = switchPick(name, this.sphere, this.box);
controls.setLookAt(pos.x, pos.y, pos.z, center.x, center.y, center.z);
controls.fitToSphere(this.sphere, true);
}
}
ToolComponent.libraryUUIDs.add(CubeMapComponent.uuid);
13 changes: 10 additions & 3 deletions src/BimModel/src/ModelingComponent/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import * as THREE from "three";
import {Components} from "../Components";
import {ProjectComponent} from "../ProjectComponent";
import {ToolComponent} from "../Tool";
import {Component, Disposable, UUID} from "../types";
import {createModelingContainer} from "./src";
import {createModelingContainer, createOptionContainer} from "./src";
export class ModelingComponent extends Component<any> implements Disposable {
static readonly uuid = UUID.ModelingComponent;
enabled = false;
private modelingContainer!: HTMLDivElement;
private optionContainer!: HTMLDivElement;
get ProjectComponent(): ProjectComponent {
return this.components.tools.get(ProjectComponent);
}
/**
*
*/
Expand All @@ -16,14 +20,17 @@ export class ModelingComponent extends Component<any> implements Disposable {
}
async dispose() {
this.modelingContainer?.remove();
this.optionContainer?.remove();
(this.modelingContainer as any) = null;
}
get() {
throw new Error("Method not implemented.");
}
init(container: HTMLDivElement) {
init(container: HTMLDivElement, option: HTMLDivElement) {
this.modelingContainer = createModelingContainer(this);
container.appendChild(this.modelingContainer);
this.optionContainer = createOptionContainer(this);
option.appendChild(this.optionContainer);
}
}
ToolComponent.libraryUUIDs.add(ModelingComponent.uuid);
27 changes: 24 additions & 3 deletions src/BimModel/src/ModelingComponent/src/InitComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import React from "react";
import ReactDOM from "react-dom/client";
import {ModelingComponent} from "..";
import ModelingTabs from "./Components/ModelingTabs";
import ModelingTabs from "./Modeling/ModelingTabs";
import ProjectInfo from "./Project/ProjectInfo";
import ModelingOption from "./ModelingOption/ModelingOption";
import Units from "./Units/Units";
import NewProject from "./Project/NewProject";

export function createModelingContainer(_modeling: ModelingComponent) {
export function createModelingContainer(modeling: ModelingComponent) {
const div = document.createElement("div");
div.className = "h-full w-full relative";
ReactDOM.createRoot(div).render(<ModelingTabs></ModelingTabs>);
ReactDOM.createRoot(div).render(
<>
<ModelingTabs></ModelingTabs>
<ProjectInfo modeling={modeling}></ProjectInfo>
<NewProject modeling={modeling}></NewProject>
</>
);
return div;
}
export function createOptionContainer(_modeling: ModelingComponent) {
const div = document.createElement("div");
div.className = "h-full w-full relative flex justify-between";
ReactDOM.createRoot(div).render(
<>
<ModelingOption />
<Units />
</>
);
return div;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, {FC, useState} from "react";
import {IDiscipline, IModeling, ITool} from "@BimModel/src/types";
import {IModeling, ITool} from "@BimModel/src/types";
import ModelingButton from "./ModelingButton";
import {useSignalEffect} from "@preact/signals-react";
import {modelingSignal} from "@BimModel/src/Signals";
import {getModelings} from "../constants";
import {getModelings} from "../utils";
import ToolButton from "./ToolButton";

const ContentModeling: FC<Props> = ({types, discipline}) => {
Expand Down Expand Up @@ -39,6 +39,6 @@ const ContentModeling: FC<Props> = ({types, discipline}) => {
};
interface Props {
types: ITool[];
discipline: IDiscipline;
discipline: string;
}
export default ContentModeling;
112 changes: 112 additions & 0 deletions src/BimModel/src/ModelingComponent/src/Modeling/FileTabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React, {FC} from "react";
import {iConClassName} from "../constants";
//#region File
import {MdOutlineCreateNewFolder as NewProject} from "react-icons/md";
import {GoFileDirectory as Open} from "react-icons/go";
import {GoInfo as Project} from "react-icons/go";
import {CiSaveDown2 as Save} from "react-icons/ci";
import dotbim from "@assets/dotbim.png";
import gltf from "@assets/gltf-icon.png";
import ifc from "@assets/ifc-icon.png";
import revit from "@assets/revit-256.png";
import {ITool} from "@BimModel/src/types";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import {Button} from "@/components/ui/button";
import {
newProjectInfoSignal,
openProjectInfoSignal,
projectSignal,
} from "@BimModel/src/Signals";
//#endregion

const FileButton = ({
tool,
onClick,
}: {
tool: ITool;
onClick: (e: any) => void;
}) => {
return (
<TooltipProvider delayDuration={10}>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="outline"
className={`my-auto mx-1 hover:bg-green-400 disabled:cursor-none `}
onClick={onClick}
>
{tool.icon}
</Button>
</TooltipTrigger>
<TooltipContent side="bottom">
<p>{tool.type}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
};

const FileTabs = () => {
const New = {
type: "New Project",
icon: <NewProject className={iConClassName} />,
};
const OpenProject = {
type: "Open",
icon: <Open className={iConClassName} />,
};
const ProjectInfo = {
type: "Project Info",
icon: <Project className={iConClassName} />,
};
const SaveProject = {
type: "Save",
icon: <Save className={iConClassName} />,
};
const ExportIfc = {
type: "Export Ifc",
icon: <img src={ifc} className={iConClassName} />,
};
const ExportDotBim = {
type: "Export .bim",
icon: <img src={dotbim} className={iConClassName} />,
};
const ExportGlb = {
type: "Export .glb",
icon: <img src={gltf} className={iConClassName} />,
};

const handleNewProject = (_e: any) => {
newProjectInfoSignal.value = true;
};
const handleOpenProject = (_e: any) => {};
const handleOpenProjectInfo = (_e: any) => {
openProjectInfoSignal.value = true;
};
const handleSaveProject = (_e: any) => {};
const handleExportIfc = (_e: any) => {};
const handleExportDotBim = (_e: any) => {};
const handleExportGlb = (_e: any) => {};
return (
<div className="relative h-full w-full flex justify-start items-center">
<FileButton tool={New} onClick={handleNewProject} />
<FileButton tool={OpenProject} onClick={handleOpenProject} />
{projectSignal.value && (
<>
<FileButton tool={ProjectInfo} onClick={handleOpenProjectInfo} />
<FileButton tool={SaveProject} onClick={handleSaveProject} />
<FileButton tool={ExportIfc} onClick={handleExportIfc} />
<FileButton tool={ExportDotBim} onClick={handleExportDotBim} />
<FileButton tool={ExportGlb} onClick={handleExportGlb} />
</>
)}
</div>
);
};

export default FileTabs;
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import React, {FC} from "react";
import {
IArchitectureModeling,
IDiscipline,
IFile,
IModify,
IPlumbingModeling,
IStructureModeling,
ITool,
} from "@BimModel/src/types";
import {ITool} from "@BimModel/src/types";
import {Button} from "@/components/ui/button";
import {
Tooltip,
Expand All @@ -19,14 +11,7 @@ import {modelingSignal} from "@BimModel/src/Signals";
import {useComputed} from "@preact/signals-react";

const ModelingButton: FC<Props> = ({type, discipline}) => {
const handleModeling = (
type:
| IArchitectureModeling
| IStructureModeling
| IPlumbingModeling
| IFile
| IModify
) => {
const handleModeling = (type: string) => {
modelingSignal.value = {discipline, type};
};
const disabled = useComputed(() => {
Expand All @@ -51,7 +36,6 @@ const ModelingButton: FC<Props> = ({type, discipline}) => {
onClick={() => handleModeling(type.type)}
disabled={disabled.value}
>
<p className="mx-2">{type.type}</p>
{type.icon}
</Button>
</TooltipTrigger>
Expand All @@ -64,6 +48,6 @@ const ModelingButton: FC<Props> = ({type, discipline}) => {
};
interface Props {
type: ITool;
discipline: IDiscipline;
discipline: string;
}
export default ModelingButton;
Loading

0 comments on commit c588511

Please sign in to comment.