Compare commits

..
3 Commits
2 changed files with 18 additions and 6 deletions
+13 -1
View File
@@ -58,7 +58,7 @@ const MeshMaterialManager = ({ mesh, sceneObj, textureCache }: MeshMaterialManag
activeMat.triplanarUniforms.uTriplanarScale.value = uvScale; activeMat.triplanarUniforms.uTriplanarScale.value = uvScale;
activeMat.triplanarUniforms.uBlendSharpness.value = 5.0; // Default or from props activeMat.triplanarUniforms.uBlendSharpness.value = 5.0; // Default or from props
} else { } else if (mappingType !== 'uv') {
activeMat = MaterialFactory.getInstance().getStandardUVMaterial( activeMat = MaterialFactory.getInstance().getStandardUVMaterial(
baseParams, baseParams,
mesh.uuid mesh.uuid
@@ -71,6 +71,9 @@ const MeshMaterialManager = ({ mesh, sceneObj, textureCache }: MeshMaterialManag
activeMat.uvUniforms.uMappingMode.value = modeIndex; activeMat.uvUniforms.uMappingMode.value = modeIndex;
activeMat.updateUVTransform(uvOffset, [uvTiling[0] * uvScale, uvTiling[1] * uvScale], uvRotation * (Math.PI / 180)); activeMat.updateUVTransform(uvOffset, [uvTiling[0] * uvScale, uvTiling[1] * uvScale], uvRotation * (Math.PI / 180));
} else {
// Use the native material to preserve exact GLTF UV behavior
activeMat = origMat;
} }
// Apply basic props // Apply basic props
@@ -103,6 +106,7 @@ const MeshMaterialManager = ({ mesh, sceneObj, textureCache }: MeshMaterialManag
tex.name = url; tex.name = url;
if (type === 'map') tex.colorSpace = THREE.SRGBColorSpace; if (type === 'map') tex.colorSpace = THREE.SRGBColorSpace;
tex.wrapS = tex.wrapT = THREE.RepeatWrapping; tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
tex.flipY = false;
textureCache.current.set(url, tex); textureCache.current.set(url, tex);
activeMat[type] = tex; activeMat[type] = tex;
@@ -116,6 +120,14 @@ const MeshMaterialManager = ({ mesh, sceneObj, textureCache }: MeshMaterialManag
if (mappingType === 'triplanar') activeMat.triplanarUniforms['t' + type.charAt(0).toUpperCase() + type.slice(1).replace('Map', '')].value = null; if (mappingType === 'triplanar') activeMat.triplanarUniforms['t' + type.charAt(0).toUpperCase() + type.slice(1).replace('Map', '')].value = null;
activeMat.needsUpdate = true; activeMat.needsUpdate = true;
} }
// Native UV mapping transforms
if (mappingType === 'uv' && activeMat[type]) {
activeMat[type].repeat.set(uvTiling[0] * uvScale, uvTiling[1] * uvScale);
activeMat[type].offset.set(uvOffset[0], uvOffset[1]);
activeMat[type].rotation = uvRotation * (Math.PI / 180);
activeMat[type].needsUpdate = true;
}
}); });
mesh.visible = sceneObj.visible; mesh.visible = sceneObj.visible;
+5 -5
View File
@@ -5232,11 +5232,12 @@ export default function Editor() {
} }
}); });
// Save model data for scene persistence
const modelBlob = await fetch(modelUrl).then(r => r.blob()); const modelBlob = await fetch(modelUrl).then(r => r.blob());
const blobUrl = URL.createObjectURL(modelBlob); setImportStatus("Uploading to cloud storage... 0%");
setBlobURLs(prev => [...prev, blobUrl]); const cloudUrl = await uploadAssetToStorage(modelBlob, 'assets', `models/${user?.id || 'guest'}_${Date.now()}_Generated_Model.glb`, (prog) => {
setModelData({ name: "Generated_Model.glb", data: blobUrl, extension: 'glb' }); setImportStatus(`Uploading to cloud storage... ${prog}%`);
});
setModelData({ name: "Generated_Model.glb", data: cloudUrl, extension: 'glb' });
const boundingBox = new THREE.Box3().setFromObject(object); const boundingBox = new THREE.Box3().setFromObject(object);
const center = new THREE.Vector3(); const center = new THREE.Vector3();
@@ -5290,7 +5291,6 @@ export default function Editor() {
} }
setLoadedModel(object); setLoadedModel(object);
setBlobURLs(prev => [...prev, modelUrl]);
setSceneObjects(prev => [ setSceneObjects(prev => [
...prev.filter(obj => obj.type !== 'cube'), ...prev.filter(obj => obj.type !== 'cube'),
...newSceneObjects ...newSceneObjects