Merge branch 'kurt/customizer-start-320' of https://github.com/Irev-Dev/cadhub into kurt/customizer-start-320
This commit is contained in:
@@ -4,6 +4,7 @@ import { genParams, getParams } from 'src/helpers/cadPackages/jscadParams'
|
|||||||
|
|
||||||
const Customizer = () => {
|
const Customizer = () => {
|
||||||
const [open, setOpen] = React.useState(true)
|
const [open, setOpen] = React.useState(true)
|
||||||
|
const [checked, setChecked] = React.useState(false)
|
||||||
const ref = React.useRef()
|
const ref = React.useRef()
|
||||||
const jsCadCustomizerElement = ref.current
|
const jsCadCustomizerElement = ref.current
|
||||||
const { state } = useIdeContext()
|
const { state } = useIdeContext()
|
||||||
@@ -16,15 +17,14 @@ const Customizer = () => {
|
|||||||
console.log({ jsCadCustomizerElement, customizerParams, lastParameters })
|
console.log({ jsCadCustomizerElement, customizerParams, lastParameters })
|
||||||
if (jsCadCustomizerElement && customizerParams) {
|
if (jsCadCustomizerElement && customizerParams) {
|
||||||
genParams(customizerParams, jsCadCustomizerElement, lastParameters || {}, (values, source)=>{
|
genParams(customizerParams, jsCadCustomizerElement, lastParameters || {}, (values, source)=>{
|
||||||
console.log('change source', source)
|
|
||||||
if(source === 'group'){
|
if(source === 'group'){
|
||||||
// save to local storage but do not render
|
// save to local storage but do not render
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
handleRender(values)
|
if(checked) handleRender(values)
|
||||||
},[])
|
},[])
|
||||||
}
|
}
|
||||||
}, [jsCadCustomizerElement, customizerParams, lastParameters])
|
}, [jsCadCustomizerElement, customizerParams, lastParameters, checked])
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`absolute inset-x-0 bottom-0 bg-ch-gray-600 bg-opacity-60 text-ch-gray-300 text-lg font-fira-sans ${
|
className={`absolute inset-x-0 bottom-0 bg-ch-gray-600 bg-opacity-60 text-ch-gray-300 text-lg font-fira-sans ${
|
||||||
@@ -38,12 +38,19 @@ const Customizer = () => {
|
|||||||
</button>
|
</button>
|
||||||
<div>Parameters</div>
|
<div>Parameters</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<div className='flex items-center'>
|
||||||
className="px-4 py-1 rounded bg-ch-gray-300 text-ch-gray-800"
|
<input className='mr-6' type='checkbox' checked={checked} onChange={({target}) => {
|
||||||
onClick={handleRender2}
|
const newValue = !checked
|
||||||
>
|
if (newValue) handleRender2()
|
||||||
Update
|
setChecked(newValue)}}/>
|
||||||
</button>
|
<button
|
||||||
|
className="px-4 py-1 rounded bg-ch-gray-300 text-ch-gray-800"
|
||||||
|
onClick={handleRender2}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className={`${open ? 'h-full' : 'h-0'} overflow-y-auto py-3 px-12`}>
|
<div className={`${open ? 'h-full' : 'h-0'} overflow-y-auto py-3 px-12`}>
|
||||||
<div id="jscad-customizer-block" ref={ref}>
|
<div id="jscad-customizer-block" ref={ref}>
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ export const render: DefaultKernelExport['render'] = async ({
|
|||||||
let parameterDefinitions = []
|
let parameterDefinitions = []
|
||||||
scriptWorker.addEventListener('message', (e) => {
|
scriptWorker.addEventListener('message', (e) => {
|
||||||
const data = e.data
|
const data = e.data
|
||||||
if (data.action == 'parameterDefinitions') {
|
if (data.action == 'parameterDefinitions') {
|
||||||
console.log('message',data)
|
|
||||||
parameterDefinitions = data.data
|
parameterDefinitions = data.data
|
||||||
} else if (data.action == 'entities') {
|
} else if (data.action == 'entities') {
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
@@ -123,7 +122,7 @@ export const render: DefaultKernelExport['render'] = async ({
|
|||||||
callResolve()
|
callResolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
callResolve()
|
callResolve()
|
||||||
response = null
|
response = null
|
||||||
scriptWorker.postMessage({ action: 'init', baseURI, alias: [] })
|
scriptWorker.postMessage({ action: 'init', baseURI, alias: [] })
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ export const useIdeState = (): [State, (actionOrThunk: any) => any] => {
|
|||||||
...state.objectData,
|
...state.objectData,
|
||||||
type: payload.objectData?.type,
|
type: payload.objectData?.type,
|
||||||
data: payload.objectData?.data,
|
data: payload.objectData?.data,
|
||||||
customizerParams: payload.customizerParams,
|
customizerParams: payload.customizerParams || state.objectData.customizerParams,
|
||||||
lastParameters: payload.lastParameters,
|
lastParameters: payload.lastParameters,
|
||||||
},
|
},
|
||||||
consoleMessages: payload.message
|
consoleMessages: payload.message
|
||||||
|
|||||||
Reference in New Issue
Block a user