fix: automatically re-apply baked UV projections on model reload
Build and Deploy / build-and-push (push) Successful in 31s

This commit is contained in:
AI Bot
2026-10-05 13:00:01 +05:30
parent e8b88fcead
commit 66206c7ce5
2 changed files with 15 additions and 4 deletions
+8 -1
View File
@@ -3,6 +3,7 @@ import * as THREE from "three";
import { useFrame, useThree, createPortal } from "@react-three/fiber";
import { MaterialFactory } from "../materials/MaterialFactory";
import { useTexturePipeline } from "../hooks/useTexturePipeline";
import { reprojectUVs, bakeTextureToNewUVs } from '../lib/bakingUtils';
interface ModelViewerProps {
object: THREE.Object3D | null;
@@ -27,6 +28,12 @@ const MeshMaterialManager = ({ mesh, sceneObj, textureCache }: MeshMaterialManag
const uvTiling = props.uvTiling || [1, 1];
const uvOffset = props.uvOffset || [0, 0];
const uvRotation = props.uvRotation || 0;
const bakedMappingType = props.bakedMappingType;
// Automatically re-apply baked UV projections on load
if (bakedMappingType && ['planar', 'cylinder', 'sphere', 'box'].includes(bakedMappingType)) {
reprojectUVs(mesh.geometry, bakedMappingType as any);
}
const origMat = (Array.isArray(mesh.material) ? mesh.material[0] : mesh.material) as THREE.MeshPhysicalMaterial;
@@ -213,7 +220,7 @@ const FillMesh = ({ fillProps, originalMesh }: { fillProps: any, originalMesh: T
return createPortal(fillNode, originalMesh);
};
import { reprojectUVs, bakeTextureToNewUVs } from '../lib/bakingUtils';
export const ModelViewer = forwardRef<THREE.Group, ModelViewerProps>(({ object, sceneObjects, bakeRequest, onBakeComplete }, ref) => {
const internalRef = useRef<THREE.Group>(null);
+7 -3
View File
@@ -2540,9 +2540,13 @@ export default function Editor() {
sceneObjects={sceneObjects}
bakeRequest={bakeRequest}
onBakeComplete={(dataUrl) => {
if (bakeRequest) {
updateObjectMaterial(bakeRequest.id, { map: dataUrl, mappingType: 'uv' });
}
if (bakeRequest) {
updateObjectMaterial(bakeRequest.id, {
map: dataUrl,
mappingType: 'uv',
bakedMappingType: bakeRequest.type
});
}
setBakeRequest(null);
}}
/>