@@ -161,8 +161,9 @@ const IdeViewer = ({ Loading }) => {
|
|||||||
setImage(state.objectData?.type === 'png' && state.objectData?.data)
|
setImage(state.objectData?.type === 'png' && state.objectData?.data)
|
||||||
setIsDragging(false)
|
setIsDragging(false)
|
||||||
}, [state.objectData?.type, state.objectData?.data])
|
}, [state.objectData?.type, state.objectData?.data])
|
||||||
const R3FComponent = React.useMemo(
|
const PrimitiveArray = React.useMemo(
|
||||||
() => state.objectData?.type === 'r3f-component' && state.objectData?.data,
|
() =>
|
||||||
|
state.objectData?.type === 'primitive-array' && state.objectData?.data,
|
||||||
[state.objectData?.type, state.objectData?.data]
|
[state.objectData?.type, state.objectData?.data]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -266,7 +267,10 @@ const IdeViewer = ({ Loading }) => {
|
|||||||
{state.objectData?.type === 'geometry' && state.objectData?.data && (
|
{state.objectData?.type === 'geometry' && state.objectData?.data && (
|
||||||
<Asset geometry={state.objectData?.data} />
|
<Asset geometry={state.objectData?.data} />
|
||||||
)}
|
)}
|
||||||
{R3FComponent && <R3FComponent />}
|
{PrimitiveArray &&
|
||||||
|
PrimitiveArray.map((mesh, index) => (
|
||||||
|
<primitive object={mesh} key={index} />
|
||||||
|
))}
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</div>
|
</div>
|
||||||
<DelayedPingAnimation isLoading={state.isLoading} />
|
<DelayedPingAnimation isLoading={state.isLoading} />
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export interface RenderArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ArtifactTypes = 'stl' | 'png' | 'geometry' | 'r3f-component'
|
export type ArtifactTypes = 'stl' | 'png' | 'geometry' | 'primitive-array'
|
||||||
|
|
||||||
export interface HealthyResponse {
|
export interface HealthyResponse {
|
||||||
status: 'healthy'
|
status: 'healthy'
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ interface CsgObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CSGArray2R3fComponent(Csgs: CsgObj[]): React.ReactNode {
|
function CSGArray2R3fComponent(Csgs: CsgObj[]): React.ReactNode {
|
||||||
return () =>
|
return Csgs.map(({ vertices, indices, color, transforms, type }, index) => {
|
||||||
Csgs.map(({ vertices, indices, color, transforms, type }, index) => {
|
|
||||||
const materialDef = materials[type]
|
const materialDef = materials[type]
|
||||||
if (!materialDef) {
|
if (!materialDef) {
|
||||||
console.error('Can not hangle object type: ' + type, {
|
console.error('Can not hangle object type: ' + type, {
|
||||||
@@ -83,7 +82,7 @@ function CSGArray2R3fComponent(Csgs: CsgObj[]): React.ReactNode {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if (transforms) mesh.applyMatrix4({ elements: transforms })
|
if (transforms) mesh.applyMatrix4({ elements: transforms })
|
||||||
return <primitive object={mesh} key={index} />
|
return mesh
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +145,7 @@ export const render: DefaultKernelExport['render'] = async ({
|
|||||||
} else {
|
} else {
|
||||||
workerHelper.resolver(
|
workerHelper.resolver(
|
||||||
createHealthyResponse({
|
createHealthyResponse({
|
||||||
type: 'r3f-component',
|
type: 'primitive-array',
|
||||||
data: CSGArray2R3fComponent(data.entities),
|
data: CSGArray2R3fComponent(data.entities),
|
||||||
consoleMessage: data.scriptStats,
|
consoleMessage: data.scriptStats,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
|
|||||||
Reference in New Issue
Block a user