Skip to content

Commit

Permalink
🥕 v0.17.0-b19 🌱 ThreeD: Home Design
Browse files Browse the repository at this point in the history
  • Loading branch information
marty-mcgee committed Jan 8, 2025
1 parent f2a475b commit d6eaf1e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/api/graphql/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ export const isCanvasStatePaperSetVar = makeVar(false) // boolean: false | true
// ** canvasStateThreeD(s)
export const canvasStateThreeDVar = makeVar(canvasStateThreeDVarDefaults)
// console.debug('canvasStateThreeDVar()', canvasStateThreeDVar())
// console.debug('canvasStateThreeDVar().state.scene', canvasStateThreeDVar().state.scene)
export const isCanvasStateThreeDSetVar = makeVar(false) // boolean: false | true
// console.debug('isCanvasStatePaperSetVar()', isCanvasStatePaperSetVar())

Expand Down
27 changes: 21 additions & 6 deletions src/lib/threed/HomeDesign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3267,6 +3267,9 @@ function closeAllModals() {
const ViewProperties = () => {
// console.debug('PropertiesView loading...')

// ** HOOKS
const useCanvasStateThreeDVar: Object = useReactiveVar(canvasStateThreeDVar)

return (
<>
<div
Expand All @@ -3293,7 +3296,16 @@ const ViewProperties = () => {
Preview
</button>
<button className='moreInfoBtn'
onClick={(event) => addThreed(event, draggingThreedItem, canvasStateThreeDVar().state.scene)}
// @ts-expect-error
// onClick={(event) => addThreed(event, draggingThreedItem, canvasStateThreeDVar().state.scene)}
onClick={(event) => addThreed(event, draggingThreedItem, useCanvasStateThreeDVar.state.scene)}
// onClick={(event) => {
// if (("state" in useCanvasStateThreeDVar)) {
// if (("scene" in useCanvasStateThreeDVar.state)) {
// addThreed(event, draggingThreedItem, useCanvasStateThreeDVar.state.scene)
// }
// }
// }}
>
Add To Canvas
</button>
Expand Down Expand Up @@ -5273,7 +5285,7 @@ function initThreed(threedItem: any, scene: any) {
imageN.visible = false

// scene.add(meshN)
// canvasStateThreeDVar().scene.add(meshN)
// @ts-expect-error
canvasStateThreeDVar().state.scene.add(meshN)
console.debug('meshN added to scene')

Expand All @@ -5283,7 +5295,7 @@ function initThreed(threedItem: any, scene: any) {


// scene.add(OBJa)
// canvasStateThreeDVar().scene.add(OBJa)
// @ts-expect-error
canvasStateThreeDVar().state.scene.add(OBJa)
console.debug('OBJa added to scene')

Expand Down Expand Up @@ -5467,7 +5479,9 @@ function redrawGrid(): boolean {
const planViewHeight = planView.clientHeight
console.debug('redrawGrid: planView.width:height', planViewWidth, planViewHeight)
const planCanvas = document.getElementById('planCanvas')
// @ts-expect-error
planCanvas.width = planViewWidth
// @ts-expect-error
planCanvas.height = planViewHeight
const planCanvasWidth = planCanvas.clientWidth
const planCanvasHeight = planCanvas.clientHeight
Expand Down Expand Up @@ -5799,8 +5813,8 @@ export default function ThreeDHomeDesign({
// const [isPrefsLoaded, setIsPrefsLoaded] = useState(isPreferencesSetVar())

// ** USE CANVAS STATE
// const canvasState = useReactiveVar(canvasStateThreeDVar) // YES !!
// console.debug('%c⚙️ ThreeD Home Design canvasState', ccm.orangeAlert, canvasState)
const useCanvasStateThreeDVar = useReactiveVar(canvasStateThreeDVar) // YES !!
// console.debug('%c⚙️ ThreeD Home Design useCanvasStateThreeDVar', ccm.orangeAlert, useCanvasStateThreeDVar)
// ** INIT CANVAS STATE
// const [isCanvasLoaded, setIsCanvasLoaded] = useState(false)
// const [isCanvasStateLoaded, setIsCanvasStateLoaded] = useState(isCanvasStateSetVar())
Expand Down Expand Up @@ -6479,8 +6493,9 @@ export default function ThreeDHomeDesign({

// ** [MM] CLOSER.. NOT EVEN CLOSE
if (draggingThreedItem) {
// @ts-expect-error
addThreed(e, draggingThreedItem, canvasStateThreeDVar().state.scene)
// addThreed(e, draggingThreedItem, canvasState.state.scene)
// addThreed(e, draggingThreedItem, useCanvasStateThreeDVar.state.scene)
void (draggingNewGuide && (draggingNewGuide = false))
}

Expand Down

0 comments on commit d6eaf1e

Please sign in to comment.