From 8504549928616c8fbd44f6bebd2d1c175dd44a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=98=D0=9D?= Date: Sun, 31 May 2026 13:37:44 +0300 Subject: [PATCH] =?UTF-8?q?fix(09):=20=5FrecreateMesh=20studs=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D1=91=D1=82=20?= =?UTF-8?q?=D0=BC=D0=B0=D1=82=D0=B5=D1=80=D0=B8=D0=B0=D0=BB=20(=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D1=82=D0=B5=D1=82=20=D1=81=D0=BE=20=D1=81?= =?UTF-8?q?=D1=82=D1=83=D0=B4=D0=B8=D0=B5=D0=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- src/engine/PrimitiveManager.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/engine/PrimitiveManager.js b/src/engine/PrimitiveManager.js index 8b6b38a..ad2f045 100644 --- a/src/engine/PrimitiveManager.js +++ b/src/engine/PrimitiveManager.js @@ -799,7 +799,14 @@ export class PrimitiveManager { const newMesh = this._createMeshForType(typeDef, data.id, data.sx, data.sy, data.sz, data.material, data.studDensity); newMesh.position = oldPos; if (oldRot) newMesh.rotation = oldRot; - newMesh.material = oldMat; + // 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.isPickable = true; newMesh.metadata = { ...oldMesh.metadata }; newMesh.setEnabled(data.visible); @@ -809,24 +816,7 @@ export class PrimitiveManager { catch (e) { /* ignore */ } data.mesh = newMesh; - newMesh._studsDims = { type: data.type, sx: data.sx, sy: data.sy, sz: data.sz, density: data.studDensity }; - // 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; - } - } - } + // _studsDims и материал studs уже выставлены выше. } /** Удалить инстанс. */