diff --git a/app/web/src/components/Customizer/Customizer.tsx b/app/web/src/components/Customizer/Customizer.tsx index e89633d..84da796 100644 --- a/app/web/src/components/Customizer/Customizer.tsx +++ b/app/web/src/components/Customizer/Customizer.tsx @@ -1,24 +1,41 @@ import { useRender } from 'src/components/IdeWrapper/useRender' +import { useIdeContext } from 'src/helpers/hooks/useIdeContext' const Customizer = () => { const [open, setOpen] = React.useState(true) const ref = React.useRef() const jsCadCustomizerElement = ref.current + const { state } = useIdeContext() + const customizerParams = state?.objectData?.customizerParams + console.log(state) React.useEffect(() => { - console.log(jsCadCustomizerElement) - if (jsCadCustomizerElement) { - jsCadCustomizerElement.innerHTML = `
hi there
` + console.log({ jsCadCustomizerElement, customizerParams }) + if (jsCadCustomizerElement && customizerParams) { + jsCadCustomizerElement.innerHTML = `
${JSON.stringify( + customizerParams + )}
` } - }, [jsCadCustomizerElement]) + }, [jsCadCustomizerElement, customizerParams]) const handleRender = useRender() return ( -
+
- +
Parameters
- +
diff --git a/app/web/src/helpers/cadPackages/common.ts b/app/web/src/helpers/cadPackages/common.ts index cbe789a..3f5480c 100644 --- a/app/web/src/helpers/cadPackages/common.ts +++ b/app/web/src/helpers/cadPackages/common.ts @@ -30,6 +30,7 @@ export interface HealthyResponse { data: any type: 'stl' | 'png' | 'geometry' } + customizerParams?: any } export function createHealthyResponse({ @@ -37,11 +38,13 @@ export function createHealthyResponse({ data, consoleMessage, type, + customizerParams, }: { date: Date data: any consoleMessage: string type: HealthyResponse['objectData']['type'] + customizerParams?: any }): HealthyResponse { return { status: 'healthy', @@ -54,6 +57,7 @@ export function createHealthyResponse({ message: consoleMessage, time: date, }, + customizerParams, } } diff --git a/app/web/src/helpers/cadPackages/jsCadController.ts b/app/web/src/helpers/cadPackages/jsCadController.ts index e26f92e..02d7124 100644 --- a/app/web/src/helpers/cadPackages/jsCadController.ts +++ b/app/web/src/helpers/cadPackages/jsCadController.ts @@ -108,6 +108,7 @@ self.addEventListener('message', (e)=>worker.postMessage(e.data)) data: [...data.entities.map(CSG2Object3D).filter((o) => o)], consoleMessage: data.scriptStats, date: new Date(), + customizerParams: ['param1', 'abc'], }) } callResolve() diff --git a/app/web/src/helpers/hooks/useIdeState.ts b/app/web/src/helpers/hooks/useIdeState.ts index 9b671be..9f5e68c 100644 --- a/app/web/src/helpers/hooks/useIdeState.ts +++ b/app/web/src/helpers/hooks/useIdeState.ts @@ -89,6 +89,7 @@ export interface State { type: 'INIT' | 'stl' | 'png' | 'geometry' data: any quality: 'low' | 'high' + customizerParams?: any } layout: any camera: { @@ -153,6 +154,7 @@ export const useIdeState = (): [State, (actionOrThunk: any) => any] => { ...state.objectData, type: payload.objectData?.type, data: payload.objectData?.data, + customizerParams: payload.customizerParams, }, consoleMessages: payload.message ? [...state.consoleMessages, payload.message] @@ -248,7 +250,7 @@ export const requestRender = ({ quality, }, }) - .then(({ objectData, message, status }) => { + .then(({ objectData, message, status, customizerParams }) => { if (status === 'error') { dispatch({ type: 'errorRender', @@ -257,7 +259,12 @@ export const requestRender = ({ } else { dispatch({ type: 'healthyRender', - payload: { objectData, message, lastRunCode: code }, + payload: { + objectData, + message, + lastRunCode: code, + customizerParams, + }, }) return objectData }