fix(09): _recreateMesh studs пересоздаёт материал (паритет со студией)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ae83926a5a
commit
8504549928
@ -799,7 +799,14 @@ export class PrimitiveManager {
|
|||||||
const newMesh = this._createMeshForType(typeDef, data.id, data.sx, data.sy, data.sz, data.material, data.studDensity);
|
const newMesh = this._createMeshForType(typeDef, data.id, data.sx, data.sy, data.sz, data.material, data.studDensity);
|
||||||
newMesh.position = oldPos;
|
newMesh.position = oldPos;
|
||||||
if (oldRot) newMesh.rotation = oldRot;
|
if (oldRot) newMesh.rotation = oldRot;
|
||||||
|
// studs — материал пересоздаём заново (свежий faceUV/тайлинг). Иначе перенос.
|
||||||
|
if (data.material === 'studs') {
|
||||||
|
newMesh._studsDims = { type: data.type, sx: data.sx, sy: data.sy, sz: data.sz, density: data.studDensity };
|
||||||
|
this._applyMaterial(newMesh, typeDef, data.color, data.material);
|
||||||
|
try { oldMat?.dispose(); } catch (e) { /* ignore */ }
|
||||||
|
} else {
|
||||||
newMesh.material = oldMat;
|
newMesh.material = oldMat;
|
||||||
|
}
|
||||||
newMesh.isPickable = true;
|
newMesh.isPickable = true;
|
||||||
newMesh.metadata = { ...oldMesh.metadata };
|
newMesh.metadata = { ...oldMesh.metadata };
|
||||||
newMesh.setEnabled(data.visible);
|
newMesh.setEnabled(data.visible);
|
||||||
@ -809,24 +816,7 @@ export class PrimitiveManager {
|
|||||||
catch (e) { /* ignore */ }
|
catch (e) { /* ignore */ }
|
||||||
|
|
||||||
data.mesh = newMesh;
|
data.mesh = newMesh;
|
||||||
newMesh._studsDims = { type: data.type, sx: data.sx, sy: data.sy, sz: data.sz, density: data.studDensity };
|
// _studsDims и материал studs уже выставлены выше.
|
||||||
// studs-материал: пересчитать тайлинг под новый размер меша.
|
|
||||||
// Куб уже пересоздан с новым faceUV (тайлинг в геометрии) — uScale=1.
|
|
||||||
// Для остальных форм пересчитываем uScale/vScale по размеру.
|
|
||||||
if (data.material === 'studs' && oldMat && oldMat.diffuseTexture) {
|
|
||||||
if (data.type === 'cube' || data.type === 'trigger') {
|
|
||||||
oldMat.diffuseTexture.uScale = oldMat.diffuseTexture.vScale = 1;
|
|
||||||
if (oldMat.bumpTexture) oldMat.bumpTexture.uScale = oldMat.bumpTexture.vScale = 1;
|
|
||||||
} else {
|
|
||||||
const tile = _studsTiling(data.type, data.sx, data.sy, data.sz, data.studDensity);
|
|
||||||
oldMat.diffuseTexture.uScale = tile.u;
|
|
||||||
oldMat.diffuseTexture.vScale = tile.v;
|
|
||||||
if (oldMat.bumpTexture) {
|
|
||||||
oldMat.bumpTexture.uScale = tile.u;
|
|
||||||
oldMat.bumpTexture.vScale = tile.v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Удалить инстанс. */
|
/** Удалить инстанс. */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user