// @ts-nocheck /** * OR @ ts-ignore * OR @ ts-expect-error */ // ============================================================== // RESOURCES // ** React Imports import { useEffect, // useRef, useState, // useCallback, // ReactNode, FunctionComponent, MouseEventHandler, SyntheticEvent } from 'react' // ** Apollo Client 3 -- Cache Store Imports // state management (instead of React.useState, Redux, Zustand) import { ApolloConsumer, useQuery, gql } from '@apollo/client' // import { TestAC3Store } from '~/stores/old' import stores from '~/stores/apollo' // ** Next Imports import Image from 'next/future/image' // import dynamic from 'next/dynamic' // ** MUI Imports import { styled, useTheme } from '@mui/material/styles' // mui: ui import MuiAppBar from '@mui/material/AppBar' import MuiToolbar from '@mui/material/Toolbar' import Container from '@mui/material/Container' import Box from '@mui/material/Box' import MuiButton from '@mui/material/Button' import IconButton from '@mui/material/IconButton' import Menu from '@mui/material/Menu' import MenuItem from '@mui/material/MenuItem' // import MenuList from '@mui/material/MenuList' // import MenuIcon from '@mui/icons-material/Menu' import Grid from '@mui/material/Grid' // import Modal from '@mui/material/Modal' import MuiTabs from '@mui/material/Tabs' import Tab from '@mui/material/Tab' import Tooltip from '@mui/material/Tooltip' import Typography from '@mui/material/Typography' // import Avatar from '@mui/material/Avatar' import MDTabPanel, { tabProps } from '~/components/mui/MDTabPanel' // HMM ??? import button from '~/themes/theme-dark/components/button' // ** Icon Imports // Tool Mode Icons import ToolIconPointer from '@mui/icons-material/TouchApp' import ToolIconHand from '@mui/icons-material/PanTool' import ToolIconAddWall from '@mui/icons-material/HouseSiding' import ToolIconAddFloor from '@mui/icons-material/ViewModule' import ToolIconAddRoof from '@mui/icons-material/Roofing' import ToolIconAddRuler from '@mui/icons-material/Straighten' import ToolIconAddText from '@mui/icons-material/TextFields' // ** Three JS Imports (not here, use R3F) // import * as THREE from 'three' // ** Three JS Controls import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls.js' // ** Three JS Loaders // -- use React Three Fiber R3F hooks: useFBX, useOBJ, etc -- // import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader' // import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader' // import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader' // ** Three JS Objects import { Sky } from 'three/examples/jsm/objects/Sky.js' // ** Three JS Libraries // import { TWEEN } from 'three/examples/jsm/libs/tween.module.min' import TWEEN from '@tweenjs/tween.js' // use tween at all ?? // ** ThreeD R3F Imports // import { Canvas } from '@react-three/fiber' import ThreeDCanvas from '~/components/threed/components/canvas' // import BoxComponent from '~/components/threed/components/canvas/Box' // import ShaderComponent from '~/components/threed/components/canvas/Shader' // ** Modal Imports import modals from '~/components/threed/components/modals' // ** CSS Styles Imports // import stylesDemo from '~/styles/demo/demo.module.css' import stylesGarden from '~/components/threed/styles/garden.module.css' // ** Paper Imports (DEPRECATED -- requires jQuery) // import paper from 'paper' // ** jQuery Imports (DEPRECATED -- no no no, never again) // import * as $ from 'jquery' // ** UUID (DEPRECATED -- use THREE math util UUID generator) // import { v4 as newUUID } from 'uuid' // ** HELPFUL UTIL: DELETE OBJECT KEYS: RESET OBJECT TO {} import clearObject from '~/@core/utils/clear-object' // ** HELPFUL UTIL: COLORFUL CONSOLE MESSAGES (ccm) import { ccm0, ccm1, ccm2, ccm3, ccm4, ccm5, ccm6 } from '~/@core/utils/console-colors' // ========================================================== // IMPORTS COMPLETE console.debug('%cThreeDGarden: {.tsx}', ccm4) console.debug(`%c====================================`, ccm5) // ========================================================== // TS INTERFACES + TYPES // ========================================================== // none yet, but soon type THeyHeyHey = { heyheyhey: string yoyoyo: string } interface IYoYoYo { heyheyhey: string yoyoyo: string } interface IYoYoYos { // array of interfaces yoyoyos: Array } interface IHeyHeyHeys { // array of types heyheyheys: Array } // ========================================================== // STYLES const stylesModal = { position: "absolute" as "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)", width: "80vw", height: "60vh", bgcolor: "#09090D", border: "2px solid #000000", boxShadow: 24, p: 2 } const AppBar = styled(MuiAppBar)(({ theme }) => ({ position: 'static', // transition: 'none', alignItems: 'center', justifyContent: 'center', padding: theme.spacing(0, 6), backgroundColor: 'transparent', color: theme.palette.text.primary, minHeight: `42px !important`, // [theme.breakpoints.down('sm')]: { // paddingLeft: theme.spacing(4), // paddingRight: theme.spacing(4) // } })) const Toolbar = styled(MuiToolbar)(({ theme }) => ({ // width: '100%', // borderBottomLeftRadius: 10, // borderBottomRightRadius: 10, // padding: `${theme.spacing(0)} !important`, minHeight: `42px !important`, // transition: 'padding .25s ease-in-out, box-shadow .25s ease-in-out, backdrop-filter .25s ease-in-out' })) const Tabs = styled(MuiTabs)(({ theme }) => ({ overflow: `scroll !important`, })) const Button = styled(MuiButton)(({ theme }) => ({ marginRight: `0.25rem !important`, padding: `0.5rem 0.5rem !important`, minWidth: `1.8rem !important`, })) // ========================================================== // FUNCTIONAL STORES // ========================================================== const { nounStore, projectStore, workspaceStore, planStore, threedStore, fileStore, sceneStore, allotmentStore, bedStore, plantStore, plantingPlanStore, bearStore, modalStore, modalAboutStore, modalModel3dStore, modalLoadingStore, modalShareStore, modalStoreNoun, } = stores // console.debug('%cstores available', ccm3, stores) // console.debug(`%c====================================`, ccm5) // console.debug('%csceneStore', ccm2, sceneStore) // console.debug(`%c====================================`, ccm5) // ========================================================== // FUNCTIONAL NOUNS // ========================================================== // ========================================================== // Project const ProjectInfoPanel: FunctionComponent = (_type: string = 'project'): JSX.Element => { const projectCount = projectStore.store.useStore("count") const projects = projectStore.store.useStore("all") const project = projectStore.store.useStore("one") const projectsDB = projectStore.store.useStore("allDB") const projectDB = projectStore.store.useStore("oneDB") return ( {/* {projectCount} projects around here ... */} projects: {projects.length} projectsDB: {projectsDB.length} project._id: {project._id} project._ts: {project._ts} project._name: {project._name} project.layer._name: {project.layer?._name} project.data.title: {project.data?.title} ) } const ProjectControlPanel: FunctionComponent = (_type: string = 'project'): JSX.Element => { const increaseCount = () => projectStore.update("count", projectStore.actions.increaseCount()) const addNew = () => projectStore.actions.addNew() const saveToDisk = () => projectStore.actions.saveToDisk() const loadFromDisk = () => projectStore.actions.loadFromDisk() const loadFromDB = (client) => projectStore.actions.loadFromDB(client) const saveToDB = (client) => projectStore.actions.saveToDB(client) const removeAll = () => projectStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // Workspace const WorkspaceInfoPanel: FunctionComponent = (_type: string = 'workspace'): JSX.Element => { const workspaceCount = workspaceStore.store.useStore("count") const workspaces = workspaceStore.store.useStore("all") const workspace = workspaceStore.store.useStore("one") const workspacesDB = workspaceStore.store.useStore("allDB") const workspaceDB = workspaceStore.store.useStore("oneDB") return ( {/* {workspaceCount} workspaces around here ... */} workspaces: {workspaces.length} workspacesDB: {workspacesDB.length} workspace._id: {workspace._id} workspace._ts: {workspace._ts} workspace._name: {workspace._name} workspace.layer._name: {workspace.layer?._name} workspace.data.title: {workspace.data?.title} ) } const WorkspaceControlPanel: FunctionComponent = (_type: string = 'workspace'): JSX.Element => { const increaseCount = () => workspaceStore.update("count", workspaceStore.actions.increaseCount()) const addNew = () => workspaceStore.actions.addNew() const saveToDisk = () => workspaceStore.actions.saveToDisk() const loadFromDisk = () => workspaceStore.actions.loadFromDisk() const loadFromDB = (client) => workspaceStore.actions.loadFromDB(client) const saveToDB = (client) => workspaceStore.actions.saveToDB(client) const removeAll = () => workspaceStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // Plan const PlanInfoPanel: FunctionComponent = (_type: string = 'plan'): JSX.Element => { const planCount = planStore.store.useStore("count") const plans = planStore.store.useStore("all") const plan = planStore.store.useStore("one") const plansDB = planStore.store.useStore("allDB") const planDB = planStore.store.useStore("oneDB") return ( {/* {planCount} plans around here ... */} plans: {plans.length} plansDB: {plansDB.length} plan._id: {plan._id} plan._ts: {plan._ts} plan._name: {plan._name} plan.layer._name: {plan.layer?._name} plan.data.title: {plan.data?.title} ) } const PlanControlPanel: FunctionComponent = (_type: string = 'plan'): JSX.Element => { const increaseCount = () => planStore.update("count", planStore.actions.increaseCount()) const addNew = () => planStore.actions.addNew() const saveToDisk = () => planStore.actions.saveToDisk() const loadFromDisk = () => planStore.actions.loadFromDisk() const loadFromDB = (client) => planStore.actions.loadFromDB(client) const saveToDB = (client) => planStore.actions.saveToDB(client) const removeAll = () => planStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // ThreeD const ThreeDInfoPanel: FunctionComponent = (_type: string = 'threed'): JSX.Element => { const threedCount = threedStore.store.useStore("count") const threeds = threedStore.store.useStore("all") const threed = threedStore.store.useStore("one") const threedsDB = threedStore.store.useStore("allDB") const threedDB = threedStore.store.useStore("oneDB") return ( {/* {threedCount} threeds around here ... */} threeds: {threeds.length} threedsDB: {threedsDB.length} threed._id: {threed._id} threed._ts: {threed._ts} threed._name: {threed._name} threed.layer._name: {threed.layer?._name} threed.data.title: {threed.data?.title} ) } const ThreeDControlPanel: FunctionComponent = (_type: string = 'threed'): JSX.Element => { const increaseCount = () => threedStore.update("count", threedStore.actions.increaseCount()) const addNew = () => threedStore.actions.addNew() const saveToDisk = () => threedStore.actions.saveToDisk() const loadFromDisk = () => threedStore.actions.loadFromDisk() const loadFromDB = (client) => threedStore.actions.loadFromDB(client) const saveToDB = (client) => threedStore.actions.saveToDB(client) const removeAll = () => threedStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // File const FileInfoPanel: FunctionComponent = (_type: string = 'file'): JSX.Element => { const fileCount = fileStore.store.useStore("count") const files = fileStore.store.useStore("all") const file = fileStore.store.useStore("one") const filesDB = fileStore.store.useStore("allDB") const fileDB = fileStore.store.useStore("oneDB") return ( {/* {fileCount} files around here ... */} files: {files.length} filesDB: {filesDB.length} file._id: {file._id} file._ts: {file._ts} file._name: {file._name} file.layer._name: {file.layer?._name} file.data.title: {file.data?.title} ) } const FileControlPanel: FunctionComponent = (_type: string = 'file'): JSX.Element => { const increaseCount = () => fileStore.update("count", fileStore.actions.increaseCount()) const addNew = () => fileStore.actions.addNew() const saveToDisk = () => fileStore.actions.saveToDisk() const loadFromDisk = () => fileStore.actions.loadFromDisk() const loadFromDB = (client) => fileStore.actions.loadFromDB(client) const saveToDB = (client) => fileStore.actions.saveToDB(client) const removeAll = () => fileStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // Simulation // ========================================================== // Scene const SceneInfoPanel: FunctionComponent = (_type: string = 'scene'): JSX.Element => { const sceneCount = sceneStore.store.useStore("count") const sceneCountDB = sceneStore.store.useStore("countDB") const scenes = sceneStore.store.useStore("all") const scene = sceneStore.store.useStore("one") const scenesDB = sceneStore.store.useStore("allDB") const sceneDB = sceneStore.store.useStore("oneDB") return ( _type: {JSON.stringify(_type)}
count: {sceneCount} countDB: {sceneCountDB}
all.length: {scenes.length} one._id: {scene._id} one._ts: {scene._ts} one._name: {scene._name} one.layer._name: {scene.layer?._name} one.data.title: {scene.data?.title}
allDB.length: {scenesDB.length} oneDB._id: {sceneDB._id} oneDB._ts: {sceneDB._ts} oneDB._name: {sceneDB._name} oneDB.layer._name: {sceneDB.layer?._name} oneDB.data.title: {sceneDB.data?.title}
) } const SceneControlPanel: FunctionComponent = (_type: string = 'scene'): JSX.Element => { const increaseCount = () => sceneStore.store.update("count", sceneStore.actions.increaseCount()) const decreaseCount = () => sceneStore.store.update("count", sceneStore.actions.decreaseCount()) const loadToWorkspace = () => { const scene = sceneStore.actions.loadToWorkspace() console.debug("%cSceneControlPanel: loadToWorkspace {scene}", ccm3, scene) console.debug(`%c====================================`, ccm5) // return scene // ??? return true } const addNew = () => sceneStore.actions.addNew() const saveToDisk = () => sceneStore.actions.saveToDisk() const loadFromDisk = () => sceneStore.actions.loadFromDisk() const loadFromDB = (client) => sceneStore.actions.loadFromDB(client) const saveToDB = (client) => sceneStore.actions.saveToDB(client) const removeAll = () => sceneStore.actions.removeAll() const getState = () => sceneStore.actions.getState() return ( {client => ( <> )} ) } // ========================================================== // Allotment const AllotmentInfoPanel: FunctionComponent = (_type: string = 'allotment'): JSX.Element => { const allotmentCount = allotmentStore.store.useStore("count") const allotments = allotmentStore.store.useStore("all") const allotment = allotmentStore.store.useStore("one") const allotmentsDB = allotmentStore.store.useStore("allDB") const allotmentDB = allotmentStore.store.useStore("oneDB") return ( {/* {allotmentCount} allotments around here ... */} allotments: {allotments.length} allotmentsDB: {allotmentsDB.length} allotment._id: {allotment._id} allotment._ts: {allotment._ts} allotment._name: {allotment._name} allotment.layer._name: {allotment.layer?._name} allotment.data.title: {allotment.data?.title} ) } const AllotmentControlPanel: FunctionComponent = (_type: string = 'allotment'): JSX.Element => { const increaseCount = () => allotmentStore.update("count", allotmentStore.actions.increaseCount()) const addNew = () => allotmentStore.actions.addNew() const saveToDisk = () => allotmentStore.actions.saveToDisk() const loadFromDisk = () => allotmentStore.actions.loadFromDisk() const loadFromDB = (client) => allotmentStore.actions.loadFromDB(client) const saveToDB = (client) => allotmentStore.actions.saveToDB(client) const removeAll = () => allotmentStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // Bed const BedInfoPanel: FunctionComponent = (_type: string = 'bed'): JSX.Element => { const bedCount = bedStore.store.useStore("count") const beds = bedStore.store.useStore("all") const bed = bedStore.store.useStore("one") const bedsDB = bedStore.store.useStore("allDB") const bedDB = bedStore.store.useStore("oneDB") return ( {/* {bedCount} beds around here ... */} beds: {beds.length} bedsDB: {bedsDB.length} bed._id: {bed._id} bed._ts: {bed._ts} bed._name: {bed._name} bed.layer._name: {bed.layer?._name} bed.data.title: {bed.data?.title} ) } const BedControlPanel: FunctionComponent = (_type: string = 'bed'): JSX.Element => { const increaseCount = () => bedStore.update("count", bedStore.actions.increaseCount()) const addNew = () => bedStore.actions.addNew() const saveToDisk = () => bedStore.actions.saveToDisk() const loadFromDisk = () => bedStore.actions.loadFromDisk() const loadFromDB = (client) => bedStore.actions.loadFromDB(client) const saveToDB = (client) => bedStore.actions.saveToDB(client) const removeAll = () => bedStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // Plant const PlantInfoPanel: FunctionComponent = (_type: string = 'plant'): JSX.Element => { const plantCount = plantStore.store.useStore("count") const plants = plantStore.store.useStore("all") const plant = plantStore.store.useStore("one") const plantsDB = plantStore.store.useStore("allDB") const plantDB = plantStore.store.useStore("oneDB") return ( {/* {plantCount} plants around here ... */} plants: {plants.length} plantsDB: {plantsDB.length} plant._id: {plant._id} plant._ts: {plant._ts} plant._name: {plant._name} plant.layer._name: {plant.layer?._name} plant.data.title: {plant.data?.title} ) } const PlantControlPanel: FunctionComponent = (_type: string = 'plant'): JSX.Element => { const increaseCount = () => plantStore.update("count", plantStore.actions.increaseCount()) const addNew = () => plantStore.actions.addNew() const saveToDisk = () => plantStore.actions.saveToDisk() const loadFromDisk = () => plantStore.actions.loadFromDisk() const loadFromDB = (client) => plantStore.actions.loadFromDB(client) const saveToDB = (client) => plantStore.actions.saveToDB(client) const removeAll = () => plantStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // PlantingPlan const PlantingPlanInfoPanel: FunctionComponent = (_type: string = 'planting_plan'): JSX.Element => { const plantingPlanCount = plantingPlanStore.store.useStore("count") const plantingPlans = plantingPlanStore.store.useStore("all") const plantingPlan = plantingPlanStore.store.useStore("one") const plantingPlansDB = plantingPlanStore.store.useStore("allDB") const plantingPlanDB = plantingPlanStore.store.useStore("oneDB") return ( {/* {plantingPlanCount} plantingPlans around here ... */} plantingPlans: {plantingPlans.length} plantingPlansDB: {plantingPlansDB.length} plantingPlan._id: {plantingPlan._id} plantingPlan._ts: {plantingPlan._ts} plantingPlan._name: {plantingPlan._name} plantingPlan.layer._name: {plantingPlan.layer?._name} plantingPlan.data.title: {plantingPlan.data?.title} ) } const PlantingPlanControlPanel: FunctionComponent = (_type: string = 'planting_plan'): JSX.Element => { const increaseCount = () => plantingPlanStore.update("count", plantingPlanStore.actions.increaseCount()) const addNew = () => plantingPlanStore.actions.addNew() const saveToDisk = () => plantingPlanStore.actions.saveToDisk() const loadFromDisk = () => plantingPlanStore.actions.loadFromDisk() const loadFromDB = (client) => plantingPlanStore.actions.loadFromDB(client) const saveToDB = (client) => plantingPlanStore.actions.saveToDB(client) const removeAll = () => plantingPlanStore.actions.removeAll() return ( { client => ( <> ) } {/* */} ) } // ========================================================== // Bear (zustand) function BearInfoPanel() { const bears = bearStore((state: any) => state.bears) return {bears} bears around here ... } function BearControlPanel() { const increaseBearCount = bearActions((state: any) => state.increaseBearCount) return } // ========================================================== // ========================================================== // ========================================================== // COMPONENTS // ** Modal Windows const { ModalAbout, ModalLoading, ModalModel3d, ModalShare, } = modals // ** Main ToolBar const ToolBar: FunctionComponent = (): JSX.Element => { const word = `[MM] @ ${new Date().toISOString()}` // console.debug("ToolBar", word) // const [anchorElNav, setAnchorElNav] = useState(null) const [anchorElActions, setAnchorElActions] = useState(null) const [anchorElFiles, setAnchorElFiles] = useState(null) const [anchorElEdits, setAnchorElEdits] = useState(null) const [anchorElViews, setAnchorElViews] = useState(null) const [anchorElLayers, setAnchorElLayers] = useState(null) const [anchorElTools, setAnchorElTools] = useState(null) // const handleOpenNavMenu = (event: MouseEvent) => { // setAnchorElNav(event.currentTarget) // } // const handleCloseNavMenu = () => { // setAnchorElNav(null) // } const handleOpenActionsMenu = (event: MouseEvent) => { setAnchorElActions(event.currentTarget) } const handleCloseActionsMenu = () => { setAnchorElActions(null) } const handleOpenFilesMenu = (event: MouseEvent) => { setAnchorElFiles(event.currentTarget) } const handleCloseFilesMenu = () => { setAnchorElFiles(null) } const handleOpenEditsMenu = (event: MouseEvent) => { setAnchorElEdits(event.currentTarget) } const handleCloseEditsMenu = () => { setAnchorElEdits(null) } const handleOpenViewsMenu = (event: MouseEvent) => { setAnchorElViews(event.currentTarget) } const handleCloseViewsMenu = () => { setAnchorElViews(null) } const handleOpenLayersMenu = (event: MouseEvent) => { setAnchorElLayers(event.currentTarget) } const handleCloseLayersMenu = () => { setAnchorElLayers(null) } const handleOpenToolsMenu = (event: MouseEvent) => { setAnchorElTools(event.currentTarget) } const handleCloseToolsMenu = () => { setAnchorElTools(null) } // ======================================================= // FUNCTIONAL ACTIONS (FUNCTIONS ON FUNCTIONAL NOUNS) // ======================================================= // doThings // OLD const resetPlan: any = (): any => { // alert("[MM] resetPlan") try { const resetPlan = { _ts: new Date().toISOString() } // save to disk localStorage.setItem("threed_resetPlan", JSON.stringify({ subject: "plan:reset", payload: resetPlan })) // console.debug("[MM] TRY: resetPlan") } catch (e) { console.debug("[MM] CATCH: resetPlan", e) } try { Object.keys(Texts).forEach(function (e) { let t = Texts[e] "object" === typeof t && deleteTextByKey(e) }), (textIdCounter = 0) } catch (e) { console.log("resetPlan : 1 : " + e) } try { Object.keys(Dimensions).forEach(function (e) { let t = Dimensions[e] "object" === typeof t && deleteDimensionByKey(e) }), (dimensionIdCounter = 0) } catch (e) { console.log("resetPlan : 2 : " + e) } try { Object.keys(Furniture).forEach(function (e) { let t = Furniture[e] "object" === typeof t && (Furniture[e].data.toolsRectangleInner && Furniture[e].data.toolsRectangleInner.remove(), Furniture[e].remove(), delete Furniture[e]) }) } catch (e) { console.log("resetPlan : 3 : " + e) } try { Object.keys(Floors).forEach(function (e) { let t = Floors[e] "object" === typeof t && (Floors[e].remove(), delete Floors[e]) }), Object.keys(Floors3d).forEach(function (e) { let t = Floors3d[e] "object" === typeof t && (scene.remove(Floors3d[e]), delete Floors3d[e]) }), (floorIdCounter = 0) } catch (e) { console.log("resetPlan : 4 : " + e) } try { Object.keys(Walls).forEach(function (e) { let t = Walls[e] "object" === typeof t && (Walls[e].remove(), delete Walls[e]) }) for (let e in wallsRectangles) wallsRectangles[e].remove() } catch (e) { console.log("resetPlan : 5 : " + e) } try { Object.keys(wallsRectangles3d).forEach(function (e) { let t = wallsRectangles3d[e] "object" === typeof t && scene.remove(wallsRectangles3d[e]) }) } catch (e) { console.log("resetPlan : 6 : " + e) } try { Object.keys(Roofs).forEach(function (e) { "object" === typeof Roofs[e] && (Roofs[e].remove(), delete Roofs[e]) }) for (let t in roofsRectangles) roofsRectangles[t].remove() } catch (e) { console.log("resetPlan : 5.1 : " + e) } try { Object.keys(roofsRectangles3d).forEach(function (e) { "object" === typeof roofsRectangles3d[e] && scene.remove(roofsRectangles3d[e]) }) } catch (e) { console.log("resetPlan : 6.1 : " + e) } try { Object.keys(maskObjectsApplied).forEach(function (e) { "object" === typeof maskObjectsApplied[e] && scene.remove(maskObjectsApplied[e]) }) } catch (e) { console.log("resetPlan : 6.5 : " + e) } try { Object.keys(maskObjectsAppliedRoof).forEach(function (e) { "object" === typeof maskObjectsAppliedRoof[e] && scene.remove(maskObjectsAppliedRoof[e]) }) } catch (e) { console.log("resetPlan : 6.6 : " + e) } try { Object.keys(clickableObjects).forEach(function (e) { let t = clickableObjects[e] "object" === typeof t && "groundLayer" !== t._name && (scene.remove(clickableObjects[e]), delete clickableObjects[e]) }) } catch (e) { console.log("resetPlan : 7 : " + e) } try { Object.keys(maskObjects).forEach(function (e) { let t = maskObjects[e] "object" === typeof t && (scene.remove(maskObjects[e]), delete maskObjects[e]) }), (clickableObjectsCounter = 0) } catch (e) { console.log("resetPlan : 8 : " + e) } try { backgroundRaster && backgroundRaster.data && (backgroundRaster.data.toolsRectangleInner && backgroundRaster.data.toolsRectangleInner.remove(), backgroundRaster.remove(), (backgroundRaster = null), clearFileInput(document.getElementById("backgroundImageFile"))) } catch (e) { console.log("resetPlan : 9 : " + e) } try { Object.keys(verticalGuides).forEach(function (e) { verticalGuides[e].remove(), delete verticalGuides[e] }), Object.keys(horizontalGuides).forEach(function (e) { horizontalGuides[e].remove(), delete horizontalGuides[e] }), (guideCounter = 0) } catch (e) { console.log("resetPlan : 10 : " + e) } try { furnitureToLoadCount = 0 loadedFurnitureCount = 0 wallIdCounter = 0 clearObject(wallsRectangles) clearObject(wallsRectangles3d) clearObject(maskObjectsApplied) clearObject(maskObjectsAppliedRoof) roofIdCounter = 0 clearObject(roofsRectangles) clearObject(roofsRectangles3d) clearObject(Dimensions) clearObject(Floors) clearObject(Floors3d) clearObject(Roofs) clearObject(Walls) clearObject(Texts) clearObject(Furniture) // clearObject(plan) // ; // (plan.furniture = {}), // (plan.walls = {}), // (plan.roofs = {}), // (plan.levels = []), // (plan.levels[0] = { id: 0, height: 0 }), // (plan.floors = {}), // (plan.dimensions = {}), // (plan.texts = {}), // (plan.verticalGuides = {}), // (plan.horizontalGuides = {}), // (plan.furnitureAddedKey = null), // (plan.furnitureDirtyKey = null), // (plan.furnitureDeletedKey = null), // (plan.wallAddedKey = null), // (plan.wallDirtyKey = null), // (plan.wallDeletedKey = null), // (plan.roofAddedKey = null), // (plan.roofDirtyKey = null), // (plan.roofDeletedKey = null), // (plan.floorAddedKey = null), // (plan.floorDirtyKey = null), // (plan.floorDeletedKey = null), // (plan.dimensionAddedKey = null), // (plan.dimensionEditedKey = null), // (plan.dimensionDeletedKey = null), // (plan.textAddedKey = null), // (plan.textEditedKey = null), // (plan.textDeletedKey = null), // (plan.wallDiffuse = wallMaterial.color), // (plan.wallOpacity = wallMaterial.opacity), // (plan.wallSpecular = wallMaterial.specular), // (plan.roofDiffuse = roofMaterial.color), // (plan.roofOpacity = roofMaterial.opacity), // (plan.roofSpecular = roofMaterial.specular), // (plan.floorDiffuse = floorMaterial.color), // (plan.floorOpacity = floorMaterial.opacity), // (plan.floorSpecular = floorMaterial.specular), // (plan.groundDiffuse = groundMaterial.color.getHexString()), // (plan.groundOpacity = groundMaterial.opacity), // (plan.groundSpecular = groundMaterial.specular.getHexString()), // // (plan.depthWrite = document.getElementById("depthWriteMode").checked), // // (plan.sortObjects = document.getElementById("sortObjectsMode").checked), // (plan.azimuth = azimuth), // (plan.inclination = inclination) // console.debug("%cresetPlan success", ccm1) } catch (e) { console.log("resetPlan : 11 : " + e) } try { otherLayerWallsRasters && otherLayerWallsRasters.length > 0 && (otherLayerWallsRasters.forEach(function (e) { e.remove() }), (otherLayerWallsRasters = [])), otherLayerFurnitureRasters && otherLayerFurnitureRasters.length > 0 && (otherLayerFurnitureRasters.forEach(function (e) { e.remove() }), (otherLayerFurnitureRasters = [])) } catch (e) { console.log("resetPlan : 12 : " + e) } try { levelButtons || doAddNewLevel("0"), doSetLevel("0") } catch (e) { console.log("resetPlan : 13 : " + e) } try { Object.keys(levelButtons).forEach(function (e) { "0" !== e.toString() && (levelButtons[e].parentNode.removeChild(levelButtons[e]), delete levelButtons[e], project.layers["level" + e].remove() ) }) } catch (e) { console.log("resetPlan : 14 : " + e) } try { project.layers.forEach(function (e: { data: { id: any }; remove: () => any }) { "0" !== e.data.id && e.remove() }) project.layer._name = "level0" project.layer.data = { id: "0", height: 0 } } catch (e) { console.log("resetPlan : 15 : " + e) } try { // reset Groups // floorsGroup = {} floorsGroup.length = 0 // clearArray // floorsGroup[0] = new paper.Group() // roofsGroup = {} roofsGroup.length = 0 // clearArray // roofsGroup[0] = new paper.Group() // wallsGroup = {} wallsGroup.length = 0 // clearArray // wallsGroup[0] = new paper.Group() // dimensionsGroup = {} dimensionsGroup.length = 0 // clearArray // dimensionsGroup[0] = new paper.Group() // furnitureGroup = {} furnitureGroup.length = 0 // clearArray // furnitureGroup[0] = new paper.Group() // textsGroup = {} textsGroup.length = 0 // clearArray // textsGroup[0] = new paper.Group() // guidesGroup = new paper.Group() // deselectAll() // render() } catch (e) { console.log("resetPlan : 16 : " + e) } } const setToolMode: any = (mode): string => { try { switch ( ("walls" === toolMode ? setEndDrawingWalls() : "floor" === toolMode ? setEndDrawingFloors() : "roof" === toolMode ? setEndDrawingRoofs() : "dimension" === toolMode ? setEndDrawingDimension() : "text" === toolMode ? setEndDrawingText() : "ground" === toolMode && setEndDrawingGround(), (toolMode = mode), mode) ) { case "pointer": // modalsActive || showMouseIndicators() defaultCursor = "default" // deselectAll() // document.getElementById("pointerTool").classList.add("activeTool") // document.getElementById("addWallTool").classList.remove("activeTool") // document.getElementById("addFloorTool").classList.remove("activeTool") // document.getElementById("addRoofTool").classList.remove("activeTool") // document.getElementById("addRulerTool").classList.remove("activeTool") // document.getElementById("addTextTool").classList.remove("activeTool") break case "walls": ; (defaultCursor = "crosshair"), deselectAll(), recalcAllUnjoinedWallSegments(-1), recalcAllWallSegmentsOnOtherLevels(-1, project.layer.data.id), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.add("activeTool"), document.getElementById("addFloorTool").classList.remove("activeTool"), document.getElementById("addRoofTool").classList.remove("activeTool"), document.getElementById("addRulerTool").classList.remove("activeTool"), document.getElementById("addTextTool").classList.remove("activeTool"), setPropertiesView("wallDefaults") break case "floor": ; (defaultCursor = "crosshair"), deselectAll(), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.remove("activeTool"), document.getElementById("addFloorTool").classList.add("activeTool"), document.getElementById("addRoofTool").classList.remove("activeTool"), document.getElementById("addRulerTool").classList.remove("activeTool"), document.getElementById("addTextTool").classList.remove("activeTool"), recalcAllWallCorners(), setPropertiesView("floorDefaults") break case "roof": ; (defaultCursor = "crosshair"), deselectAll(), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.remove("activeTool"), document.getElementById("addFloorTool").classList.remove("activeTool"), document.getElementById("addRoofTool").classList.add("activeTool"), document.getElementById("addRulerTool").classList.remove("activeTool"), document.getElementById("addTextTool").classList.remove("activeTool"), recalcAllRoofCorners(), setPropertiesView("roofDefaults") break case "dimension": ; (defaultCursor = "crosshair"), deselectAll(), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.remove("activeTool"), document.getElementById("addFloorTool").classList.remove("activeTool"), document.getElementById("addRoofTool").classList.remove("activeTool"), document.getElementById("addRulerTool").classList.add("activeTool"), document.getElementById("addTextTool").classList.remove("activeTool"), recalcAllWallCorners(), recalcAllRoofCorners(), setPropertiesView("dimensionDefaults") break case "text": ; (defaultCursor = "crosshair"), deselectAll(), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.remove("activeTool"), document.getElementById("addFloorTool").classList.remove("activeTool"), document.getElementById("addRoofTool").classList.remove("activeTool"), document.getElementById("addRulerTool").classList.remove("activeTool"), document.getElementById("addTextTool").classList.add("activeTool"), setPropertiesView("textnDefaults") break case "background": ; (defaultCursor = "default"), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.remove("activeTool"), document.getElementById("addFloorTool").classList.remove("activeTool"), document.getElementById("addRoofTool").classList.remove("activeTool"), document.getElementById("addRulerTool").classList.remove("activeTool"), document.getElementById("addTextTool").classList.remove("activeTool") break case "ground": doSetLevel("0"), (toolMode = e), (defaultCursor = "default"), (wallsGroup[0].opacity = 0.25), (floorsGroup[0].opacity = 0.25), (furnitureGroup[0].opacity = 0.25), document.getElementById("pointerTool").classList.remove("activeTool"), document.getElementById("addWallTool").classList.remove("activeTool"), document.getElementById("addFloorTool").classList.remove("activeTool"), document.getElementById("addRoofTool").classList.remove("activeTool"), document.getElementById("addRulerTool").classList.remove("activeTool"), document.getElementById("addTextTool").classList.remove("activeTool"), setPropertiesView("ground") break default: defaultCursor = "default" // deselectAll() // document.getElementById("pointerTool").classList.remove("activeTool") // document.getElementById("addWallTool").classList.remove("activeTool") // document.getElementById("addFloorTool").classList.remove("activeTool") // document.getElementById("addRoofTool").classList.remove("activeTool") // document.getElementById("addRulerTool").classList.remove("activeTool") // document.getElementById("addTextTool").classList.remove("activeTool") } // planView.style.cursor = defaultCursor } catch (e) { console.debug("ERROR: setToolMode", mode, e) } } const doLoadFile: MouseEventHandler = (): any => { // alert("[MM] doLoadFile") try { const loaded = { ts: new Date().toISOString() } // save to disk // localStorage.clear() localStorage.setItem("threed_doLoadFile", JSON.stringify({ subject: "load", payload: loaded })) console.debug("[MM] TRY: doLoadFile") } catch (e) { console.debug("[MM] CATCH: doLoadFile", e) } } const doSaveFile: MouseEventHandler = (): any => { // alert("[MM] doSaveFile") try { const saved = { ts: new Date().toISOString() } // save to disk // localStorage.clear() localStorage.setItem("threed_doSaveFile", JSON.stringify({ subject: "save", payload: saved })) console.debug("[MM] TRY: doSaveFile") } catch (e) { console.debug("[MM] CATCH: doSaveFile", e) } } const doLoadFileAsText = (f: any) => { try { let t = f.target let o = new FileReader() // console.debug("%cFileReader", ccm1, o) o.onload = function () { let g = o.result // resetPlan() // loadingProgressTxt = "Plan decoding\n" + loadingProgressTxt // document.getElementById("modalLoadingDataInfo").innerHTML = loadingProgressTxt console.debug("drawPlan", g) // drawPlan(JSON.parse(g)) // clearFileInput(document.getElementById("file")) } // loadingProgressTxt = "Loading Saved Plan" // document.getElementById("modalLoadingDataInfo").innerHTML = loadingProgressTxt // $("#ModalLoading").show() // hideMouseIndicators() o.readAsText(t.files[0]) console.debug("%cFileReader", ccm1, o) } catch (e) { console.log("%cloadFileAsText : " + e, ccm2) } } const doOpenShareDialog = () => { try { $("#ModalShare").show() } catch (e) { console.log("doOpenShareDialog : " + e) } } const doOpenFullscreen = (el: string) => { try { // alert(el) // let t = document.getElementById(el) let t = document.querySelector(el) if (!document.fullscreenElement) { t.requestFullscreen().catch(err => { alert(`Error attempting to enable full-screen mode: ${err.message} (${err._name})`) }) } else { document.exitFullscreen() } t.requestFullscreen ? t.requestFullscreen() : t.mozRequestFullScreen ? t.mozRequestFullScreen() : t.webkitRequestFullscreen ? t.webkitRequestFullscreen() : t.msRequestFullscreen && t.msRequestFullscreen() } catch (e) { // alert(e) console.log("doOpenFullscreen : " + e) } } const doAddNewLevel = (level) => { console.debug("%caddNewLevel called", ccm1, level) return ( !1 ) } const doSetLevel = (level) => { console.debug("%csetLevel called", ccm1, level) return ( !1 ) } const doUndo: MouseEventHandler = (): any => { // alert("[MM] doUndo") try { const undid = { ts: new Date().toISOString() } // save to disk // localStorage.clear() localStorage.setItem("threed_doUndo", JSON.stringify({ subject: "undo", payload: undid })) console.debug("[MM] TRY: doUndo") } catch (e) { console.debug("[MM] CATCH: doUndo", e) } } const doRedo: MouseEventHandler = (): any => { // alert("[MM] doRedo") try { const redid = { ts: new Date().toISOString() } // save to disk // localStorage.clear() localStorage.setItem("threed_doRedo", JSON.stringify({ subject: "redo", payload: redid })) console.debug("[MM] TRY: doRedo") } catch (e) { console.debug("[MM] CATCH: doRedo", e) } } // ============================================================ // Component onMount hook useEffect(() => { const word = "YO YO YO" // console.debug("ToolBar onMount", word) return () => { // console.debug("ToolBar onUnmount", word) } }, []) const pages = ['Products', 'Pricing', 'Blog']; const settings = ['Profile', 'Account', 'Dashboard', 'Logout']; return ( threedStore.actions.getState().addNew()}>New ThreeD useProjectStore.getState().addProject()}>New Project useProjectStore.getState().saveProject()}>Save Project usePlanStore.getState().addPlan()}>New Plan usePlanStore.getState().savePlan()}>Save Plan New Simulation Load File Save File exportToObj}>Export As OBJ createThumbForHistory}>Create Thumb Undo Redo modalAboutStore.actions.handleOpen(e)}>Modal: About modalModel3dStore.actions.handleOpen(e)}>Modal: Model3d modalLoadingStore.actions.handleOpen(e)}>Modal: Loading modalShareStore.actions.handleOpen(e)}>Modal: Share ============== {/* Dialog: Share */} setPropertiesView('planView')}>2D Plan Properties doOpenFullscreen('#planView')}>2D Plan Fullscreen setPropertiesView('3dView')}>3D Plan Properties doOpenFullscreen('#view3d')}>3D Plan Fullscreen {/* setPropertiesView('defaults')}>Defaults */} {/* setToolMode('ground')} id="groundPropertiesBtn">Ground Properties */} doOpenFullscreen('body')} id="fullscreenApp">Fullscreen newLevel("noun")}>New Noun Layer tool1}>Tool 1 tool2}>Tool 2 tool3}>Tool 3 doLog}>Do Log showAbout}>Show About {/* */} setToolMode('pointer')} aria-label="Pointer Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 1 }} > setToolMode('hand')} aria-label="Hand Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 1 }} > setToolMode('walls')} aria-label="Wall Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 1 }} > setToolMode('floor')} aria-label="Floor Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 1 }} > setToolMode('roof')} aria-label="Roof Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 1 }} > setToolMode('dimension')} aria-label="Ruler Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 1 }} > setToolMode('text')} aria-label="Text Tool" aria-controls="menu-appbar" aria-haspopup="true" size="medium" color="inherit" sx={{ mr: 0 }} > ) } // ** Different Views const CatalogView: FunctionComponent = (): JSX.Element => { // console.debug("CatalogView") useEffect(() => { console.debug('CatalogView onMount') return () => { console.debug('CatalogView onUnmount') } }, []) return (
) } const PropertiesView: FunctionComponent = (): JSX.Element => { // console.debug("PropertiesView") useEffect(() => { console.debug('PropertiesView onMount') return () => { console.debug('PropertiesView onUnmount') } }, []) return (

3d Model Properties

Name
Author
License
3D Model

Furniture Properties

Id
Name
X cm
Z cm
Y cm
Width cm Flip X
Depth cm Flip Z
Height cm
Angle °
Level
3D Model

Default Settings

Compass Heading 0°

Default Wall Settings

Wall Height cm
Wall Thickness cm

Default Floor Settings

Floor Thickness cm

Default Roof Settings

Roof Thickness cm
Rise cm
Base Offset cm
Run cm
Rafter Length cm
Roof Pitch °

Default Dimension Settings

Default Text Settings

Background Template

File
Opacity
Flip Horizontal
Flip Vertical

3d View Properties

Wall Color
Wall Specular
Wall Emissive
Floor Color
Floor Specular
Roof Color
Roof Specular
Ground Color
Ground Specular
Depth Write
Sort Objects
Sun Azimuth
Sun Incline
Ambient Intensity
Directional Intensity
Hemisphere Intensity

Wall Properties

Id
Height cm
Height Start cm
Height End cm
Thickness cm
Level

Roof Properties

Id
Thickness cm
Rise cm
Base Offset cm
Run cm
Rafter Length cm
Roof Pitch °
Level

Floor Properties

Id
Area
Thickness
Level

Dimension Properties

Id
Length
Adjacent
Level

Text Annotation Properties

Id
Text
X
Y
Level
Type

Level Properties

Id
Name
Height

Ground Layer Properties

Width cm
Legth cm
) } const PlanView: FunctionComponent = (): JSX.Element => { // console.debug("PlanView") useEffect(() => { console.debug('PlanView onMount') return () => { console.debug('PlanView onUnmount') } }, []) return (
) } const TheBottom: FunctionComponent = (): JSX.Element => { const word = `[MM] @ ${new Date().toISOString()}` // console.debug("MyComponent") useEffect(() => { console.debug('MyComponent onMount') return () => { console.debug('MyComponent onUnmount') } }, []) return (
HEY HEY HEY
fullscreenPlanViewBtn fullscreen3dViewBtn ) } // ========================================================== // ** R3F Main Component const ReactThreeFiberView: FunctionComponent = (): JSX.Element => { // component params const word = `[MM] @ ${new Date().toISOString()}` // IMPORTANT: WHICH STORE ?? // in this case: sceneStore SCENE! THE SCENE !! FOR R3F boogie !! const store = sceneStore // <-- HEY HEY HEY [MM] console.debug('%cReactThreeFiberView {store}', ccm1, store) console.debug(`%c====================================`, ccm5) // return r3f: testing... {word} // throw new Error(`r3f: testing... "${word}"`) const noun = store.store.useStore('one') const noun_title = noun.data?.title ? noun.data.title : 'NOTHING YET SIR' console.debug('%cReactThreeFiberView {noun}', ccm1, noun) const loadNoun = (noun) => { // load this noun into r3f canvas store.actions.loadToWorkspace(noun, 'r3fCanvas') return true // true } useEffect(() => { // console.debug('ReactThreeFiberView onMount') console.debug(`%c====================================`, ccm5) return () => { // console.debug('ReactThreeFiberView onUnmount') console.debug(`%c====================================`, ccm5) } }, []) // console.debug(`%c====================================`, ccm5) return ( {noun._type} title: {noun_title} {/* */} {/* */} {/* */} ) } const MyComponent: FunctionComponent = (): JSX.Element => { const word = `[MM] @ ${new Date().toISOString()}` // console.debug("MyComponent") useEffect(() => { console.debug('MyComponent onMount') return () => { console.debug('MyComponent onUnmount') } }, []) return (
...MyComponent [returns] JSX here...
) } const ThreeDGarden: FunctionComponent = (): JSX.Element => { // ========================================================== // LOCAL VARS const word: string = `[MM] @ ${new Date().toISOString()}` // const title = useRef() // const root = useRef() // const scene = new THREE.Scene() // ========================================================== // Tabs const [tabInfoControl, setTabInfoControl] = useState(0) const handleChangeTabInfoControl = (event: SyntheticEvent, newValue: number) => { setTabInfoControl(newValue) localStorage.setItem('threed_tabInfoControl', newValue) } // ========================================================== // Component onMount hook useEffect(() => { console.debug("%cThreeDGarden: onMount", ccm4, word) console.debug(`%c====================================`, ccm5) // begin here ?? yes // bootManager()... // ========================================================== // set open tab const openTab: number = Number(localStorage.getItem('threed_tabInfoControl')) setTabInfoControl(openTab ? openTab : 0) // ========================================================== // LOAD HISTORIES FROM DISK ?? // ** AND/OR ** // DO THIS STUFF WHEN ASKED BY AN EVENT/REQUEST // ** PROJECT HISTORY // projectStore.actions.loadFromDisk() // projectStore.actions.loadFromDB() // ** WORKSPACE HISTORY // workspaceStore.actions.loadFromDisk() // workspaceStore.actions.loadFromDB() // ** PLAN HISTORY // planStore.actions.loadFromDisk() // planStore.actions.loadFromDB() // ** THREED HISTORY // threedStore.actions.loadFromDisk() // threedStore.actions.loadFromDB() // ** SCENE HISTORY // sceneStore.actions.loadFromDisk() // sceneStore.actions.loadFromDB() return () => { // console.debug('ThreeDGarden onUnmount', word) } }, []) // ========================================================== // FC returns JSX return (
{/*
ThreeDGarden: {word}
*/} {/*
Three root
*/} {/* jQuery Three Happy Messy */}
{/* store access */}
{/* React Three Fiber - View */} {/* */} Testing Panel {/* */} {/* */} {/*
*/} {/* */} {/* */} {/*
*/} {/* */} {/* */} {/*
*/} {/* */} {/* */} {/*
*/} {/* */} {/* */} {/*
*/}
{/* */}0 {/* */} {/* */} {/* */}
) } export default ThreeDGarden