feat(09): Studs материал + окрашиваемые блоки + лего-сет #13

Merged
min merged 5 commits from feat/studs-material-09 into main 2026-05-31 11:17:42 +00:00
4 changed files with 16 additions and 11 deletions
Showing only changes of commit d5968f7cb8 - Show all commits

View File

@ -373,8 +373,9 @@ export class BlockManager {
if (blockType.normal) { if (blockType.normal) {
try { mat.bumpTexture = new Texture(blockType.normal, this.scene); } catch (e) {} try { mat.bumpTexture = new Texture(blockType.normal, this.scene); } catch (e) {}
} }
mat.specularColor = new Color3(0.2, 0.2, 0.2); // Сочность (Roblox-look): почти-белая текстура × яркий vertex color,
mat.specularPower = 24; // specular убран (он белит/тускнит цвет).
mat.specularColor = new Color3(0, 0, 0);
mat.useVertexColors = true; mat.useVertexColors = true;
return mat; return mat;
} }

View File

@ -108,8 +108,8 @@ export const BLOCK_TYPES = [
// === ОКРАШИВАЕМЫЕ (задача 09) — паритет со студией === // === ОКРАШИВАЕМЫЕ (задача 09) — паритет со студией ===
cube('studs-block', 'Лего-кирпич', 'Окрашиваемые', cube('studs-block', 'Лего-кирпич', 'Окрашиваемые',
'/kubikon-assets/materials/studs_diffuse.png', '/kubikon-assets/materials/studs_v4_diffuse.png',
{ colorable: true, normal: '/kubikon-assets/materials/studs_normal.png', defaultColor: '#3a7aff' }), { colorable: true, normal: '/kubikon-assets/materials/studs_v4_normal.png', defaultColor: '#3a7aff' }),
]; ];
/** Все доступные категории в порядке появления. */ /** Все доступные категории в порядке появления. */

View File

@ -2407,6 +2407,9 @@ export class GameRuntime {
if (data.material === 'neon') { if (data.material === 'neon') {
data.mesh.material.emissiveColor = c; data.mesh.material.emissiveColor = c;
} }
if (data.material === 'studs') {
data.mesh.material.emissiveColor = new Color3(c.r * 0.45, c.g * 0.45, c.b * 0.45);
}
} }
} }
} catch (e) { } catch (e) {

View File

@ -34,8 +34,8 @@ import { Texture } from '@babylonjs/core/Materials/Textures/texture';
import { getPrimitiveType } from './PrimitiveTypes'; import { getPrimitiveType } from './PrimitiveTypes';
// === Материал «studs» (лего-кружки, задача 09) — паритет со студией === // === Материал «studs» (лего-кружки, задача 09) — паритет со студией ===
const STUDS_DIFFUSE_URL = '/kubikon-assets/materials/studs_diffuse.png'; const STUDS_DIFFUSE_URL = '/kubikon-assets/materials/studs_v4_diffuse.png';
const STUDS_NORMAL_URL = '/kubikon-assets/materials/studs_normal.png'; const STUDS_NORMAL_URL = '/kubikon-assets/materials/studs_v4_normal.png';
const STUD_UNIT = 1; const STUD_UNIT = 1;
const STUDS_GRID = 4; const STUDS_GRID = 4;
const _studsTexCache = new WeakMap(); const _studsTexCache = new WeakMap();
@ -457,8 +457,8 @@ export class PrimitiveManager {
mat.specularColor = new Color3(0, 0, 0); mat.specularColor = new Color3(0, 0, 0);
break; break;
case 'studs': { case 'studs': {
// Лего-материал (паритет со студией): серая diffuse с кружками // Лего-материал (паритет со студией): почти-белая diffuse × цвет
// × цвет меша + normal map. Тайлинг по размеру меша. // меша + normal map. emissive = доля цвета → сочность (Roblox-look).
const tex = _getStudsTextures(this.scene); const tex = _getStudsTextures(this.scene);
const dt = tex.diffuse.clone(); const dt = tex.diffuse.clone();
const nt = tex.normal.clone(); const nt = tex.normal.clone();
@ -468,9 +468,10 @@ export class PrimitiveManager {
dt.vScale = nt.vScale = tile.v; dt.vScale = nt.vScale = tile.v;
mat.diffuseTexture = dt; mat.diffuseTexture = dt;
mat.bumpTexture = nt; mat.bumpTexture = nt;
mat.diffuseColor = Color3.FromHexString(color || '#cccccc'); const sc = Color3.FromHexString(color || '#cccccc');
mat.specularColor = new Color3(0.25, 0.25, 0.25); mat.diffuseColor = sc;
mat.specularPower = 24; mat.emissiveColor = new Color3(sc.r * 0.45, sc.g * 0.45, sc.b * 0.45);
mat.specularColor = new Color3(0, 0, 0);
break; break;
} }
case 'matte': case 'matte':