diff --git a/docsSite/docs/more-features/custom-assets.md b/docsSite/docs/more-features/custom-assets.md index c89e9260..97d1ee68 100644 --- a/docsSite/docs/more-features/custom-assets.md +++ b/docsSite/docs/more-features/custom-assets.md @@ -42,6 +42,7 @@ A model must be included in the folder with the name "model.glb". CAD files must { "name": string // Unique name, required for all asset types "sourceUrl": string // Link to the original file, optional + "disableSimplification": boolean // Whether to disable model simplification, optional "rotations": { "axis": "x" | "y" | "z", "degrees": number }[] // Sequence of rotations along the x, y, and z axes "position": [number, number, number] // Position offset in meters, applied after rotation "cameras": [ // Fixed camera positions, can be empty @@ -59,6 +60,14 @@ A model must be included in the folder with the name "model.glb". CAD files must The simplest way to determine appropriate position and rotation values is by trial and error. We recommend adjusting rotation before position as the transforms are applied in this order. +:::info +AdvantageScope simplifies model geometry automatically to improve performance, where the level of detail depends on the selected [rendering mode](../tab-reference/3d-field.md#rendering-modes). In cases where model simplification produces undesired effects with custom assets, two solutions can be used: + +- To disable automatic removal of a particular mesh, include the string `NOSIMPLIFY` in the mesh name. +- To disable model simplification for an entire robot model, set the `disableSimplification` option in the configuration to `true`. + +::: + ### Articulated Components :::warning diff --git a/src/main/assetsUtil.ts b/src/main/assetsUtil.ts index 8e3de06d..105a8083 100644 --- a/src/main/assetsUtil.ts +++ b/src/main/assetsUtil.ts @@ -333,7 +333,8 @@ export function loadAssets(): AdvantageScopeAssets { rotations: [], position: [0, 0, 0], cameras: [], - components: [] + components: [], + disableSimplification: false }; if ("name" in configRaw && typeof configRaw.name === "string") { config.name = configRaw.name; @@ -341,6 +342,12 @@ export function loadAssets(): AdvantageScopeAssets { if ("sourceUrl" in configRaw && typeof configRaw.sourceUrl === "string") { config.sourceUrl = configRaw.sourceUrl; } + if (config.name === "Preseto") { + console.log(configRaw); + } + if ("disableSimplification" in configRaw && typeof configRaw.disableSimplification === "boolean") { + config.disableSimplification = configRaw.disableSimplification; + } if ( "rotations" in configRaw && Array.isArray(configRaw.rotations) && diff --git a/src/shared/AdvantageScopeAssets.ts b/src/shared/AdvantageScopeAssets.ts index 352e1ce9..465b4964 100644 --- a/src/shared/AdvantageScopeAssets.ts +++ b/src/shared/AdvantageScopeAssets.ts @@ -62,6 +62,7 @@ export interface Config3dRobot { path: string; sourceUrl?: string; + disableSimplification: boolean; rotations: Config3d_Rotation[]; position: [number, number, number]; cameras: Config3dRobot_Camera[]; diff --git a/src/shared/renderers/threeDimension/workers/loadRobot.ts b/src/shared/renderers/threeDimension/workers/loadRobot.ts index fcff3cd2..f1d09854 100644 --- a/src/shared/renderers/threeDimension/workers/loadRobot.ts +++ b/src/shared/renderers/threeDimension/workers/loadRobot.ts @@ -43,7 +43,13 @@ self.onmessage = (event) => { scene.position.set(...robotConfig!.position); } - let optimized = await optimizeGeometries(scene, mode, materialSpecular, materialShininess); + let optimized = await optimizeGeometries( + scene, + mode, + materialSpecular, + materialShininess, + !robotConfig.disableSimplification + ); let sceneMeshes: THREE.Mesh[] = []; if (optimized.normal.length > 0) sceneMeshes.push(optimized.normal[0]); if (optimized.transparent.length > 0) sceneMeshes.push(optimized.transparent[0]);