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 c65c818 commit 617cccd
Showing 1 changed file with 61 additions and 30 deletions.
91 changes: 61 additions & 30 deletions src/lib/threed/HomeDesign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,11 @@ const PaperCanvas = (props: any) => {

// ** ================================================

console.debug('%c PaperCanvas paper.view.bounds.width:height = ', ccm.darkredAlert,
roundTo(paper.view.bounds.width, 0)
+ ' : ' +
roundTo(paper.view.bounds.height, 0)
)
// console.debug('%c PaperCanvas paper.view.bounds.width:height = ', ccm.darkredAlert,
// roundTo(paper.view.bounds.width, 0)
// + ' : ' +
// roundTo(paper.view.bounds.height, 0)
// )

// ** ================================================

Expand Down Expand Up @@ -639,8 +639,9 @@ const PaperCanvas = (props: any) => {

// ** THREED PAPER.JS

// draw1()
initThreeDPaperPlanView(planCanvas)
initPaperOrbitControls()
draw1()
// **
// console.debug('%c PaperCanvas THREED PAPER JS: initThreeDPaperPlanView(planCanvasRef)', ccm.darkorangeAlert, planCanvasRef.current)
// console.debug(`%c PaperCanvas planCanvas`, ccm.darkgreenAlert, planCanvas)
Expand Down Expand Up @@ -697,32 +698,62 @@ const draw1 = () => {
paper.view.draw()
}

// ** SIMPLE 2D PAPER ORBITCONTROLS FUNCTION
const initPaperOrbitControls = () => {
// let myPath = new paper.Path()
// **
paper.view.onMouseDown = (event: any) => {
// // myPath.remove()
// // @ts-expect-error
// myPath.strokeColor = 'orange'
// myPath.strokeWidth = 3
}
// **
paper.view.onMouseDrag = (event: any) => {
// myPath.add(event.point)
// // myPath.remove()
}
// **
paper.view.onMouseUp = (event: any) => {
// // @ts-expect-error
// myPath.strokeColor = 'darkgreen'
// myPath.strokeWidth = 3
// // reset myPath
// myPath = new paper.Path()
}
// **
// // @ts-expect-error
// paper.view.draw()
}

// ** MAIN PAPER VIEW on a PaperCanvas
function initThreeDPaperPlanView(planCanvas: any) {

// ** let planView is parent container for planCanvas
planView = document.getElementById('planView')

// ** let planCanvas is the main paper canvas
// planCanvas = document.getElementById('planCanvas')
// planCanvas.width = roundTo(planCanvas.parentNode.getBoundingClientRect().width, 0)
// planCanvas.height = roundTo(planCanvas.parentNode.getBoundingClientRect().height, 0)
// planCanvas.width = roundTo(planView.getBoundingClientRect().width, 0)
// planCanvas.height = roundTo(planView.getBoundingClientRect().height, 0)
console.debug(
'%c PaperCanvas: initThreeDPaperPlanView: planCanvas width:height',
ccm.blueAlert,
planCanvas.width,
planCanvas.height
)
// ** disable default context menu on planCanvas
planCanvas.oncontextmenu = function () {
return false
}
// console.debug(
// '%c PaperCanvas: initThreeDPaperPlanView: planCanvas width:height',
// ccm.blueAlert,
// planCanvas.width,
// planCanvas.height
// )
// // ** disable default context menu on planCanvas
// planCanvas.oncontextmenu = function () {
// return false
// }

// ** ================================================

// ** CURRENT SCREEN DIMENSIONS
screenScale = ((screen.width + screen.height) / 2) / paper.view.zoom / 75
// screenScale = ((screen.width + screen.height) / 2) / paper.view.zoom / 75
screenScale = ((screen.width + screen.height) / 2) / paper.view.zoom

// **
focusPoint = new paper.Point(0, 0)
Expand Down Expand Up @@ -5427,7 +5458,7 @@ function drawGridNew(paperScope: paper.PaperScope, gridSize: number) {
from: [x, 0],
to: [x, height],
strokeColor: new paper.Color(96, 96, 96, 1),
strokeWidth: 0.25,
strokeWidth: 0.50,
strokeScaling: true,
})
xLines.push(pathLineX)
Expand All @@ -5440,7 +5471,7 @@ function drawGridNew(paperScope: paper.PaperScope, gridSize: number) {
from: [0, y],
to: [width, y],
strokeColor: new paper.Color(96, 96, 96, 1),
strokeWidth: 0.25,
strokeWidth: 0.50,
strokeScaling: true,
})
yLines.push(pathLineY)
Expand All @@ -5454,46 +5485,46 @@ function redrawTexts() {
var t = Dimensions[e as any]
// @ts-expect-error
"object" == typeof t && (Dimensions[e].text.fontSize = screenScale / 1.5)
}),
Object.keys(Texts).forEach(function (e: any) {
var t = Texts[e as any]
// @ts-expect-error
"object" == typeof t && (Texts[e].fontSize = screenScale / 1.5)
})
})
Object.keys(Texts).forEach(function (e: any) {
var t = Texts[e as any]
// @ts-expect-error
"object" == typeof t && (Texts[e].fontSize = screenScale / 1.5)
})
}
function redrawGrid(): boolean {
// **
if (redrawing = true && threedUILayout != '3dView') {
console.debug('redrawGrid: redrawing?', true)

if (paper.view == null) {
// ...do we need this?
// ...do we need this? yes
// redrawing = false
// default: did not redrawGrid
return false

} else {

// dimensions of planView container of planCanvas
const planView = document.getElementById('planView')
const planViewWidth = planView.clientWidth
const planViewHeight = planView.clientHeight
console.debug('redrawGrid: planView.width:height', planViewWidth, planViewHeight)
// console.debug('redrawGrid: planView.width:height', planViewWidth, planViewHeight)
// dimensions of planCanvas
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
console.debug('redrawGrid: planCanvas.width:height', planCanvasWidth, planCanvasHeight)
// console.debug('redrawGrid: planCanvas.width:height', planCanvasWidth, planCanvasHeight)

// console.debug('redrawGrid: screen.width:height', screen.width, screen.height)
// screenScale = ((screen.width + screen.height) / 2) / paper.view.zoom / 75
// screenScale = ((screen.width + screen.height) / 2)
// console.debug('redrawGrid: screenScale', screenScale)

// dimensions of planView container of planCanvas


// ** [MM] SELECTED ITEM -- Testing
console.debug('selectedItem?', selectedItem)
Expand Down

1 comment on commit 617cccd

@vercel
Copy link

@vercel vercel bot commented on 617cccd Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.