From 742e841ce04dc0d2ee2f9b2982f7fdd7681d8ae2 Mon Sep 17 00:00:00 2001 From: "azykov@mail.ru" Date: Tue, 2 Jun 2026 13:29:08 +0300 Subject: [PATCH] default voxel colors and transparency fixed --- src/components/ObjectView.tsx | 8 +++++++- src/model/defaultVoxelTypes.ts | 8 ++++---- src/state/world.ts | 16 ++++++++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/components/ObjectView.tsx b/src/components/ObjectView.tsx index 88e2e83..96641c3 100644 --- a/src/components/ObjectView.tsx +++ b/src/components/ObjectView.tsx @@ -56,10 +56,16 @@ export const ObjectView = observer(function ({ object }: ObjectViewProps) { { objectType.voxels.map((v, idx) => { const vt = state.world.getVoxelTypeById(v.typeId); + const color = (v.color ?? vt?.color) ?? 'white'; + const opacity = (v.opacity ?? vt?.opacity) ?? 1; return ( - + {isSelected && } ); diff --git a/src/model/defaultVoxelTypes.ts b/src/model/defaultVoxelTypes.ts index c83503c..b72664a 100644 --- a/src/model/defaultVoxelTypes.ts +++ b/src/model/defaultVoxelTypes.ts @@ -13,7 +13,7 @@ const dirt: VoxelType = { name: 'Dirt', opacity: 1, collidable: true, - color: '302520', + color: '#302520', }; const water: VoxelType = { @@ -21,15 +21,15 @@ const water: VoxelType = { name: 'Stone', opacity: 0.7, collidable: false, - color: 'c0d0ff', + color: '#80a0f0', }; const glass: VoxelType = { id: 'glass', name: 'Glass', - opacity: 0.4, + opacity: 0.3, collidable: true, - color: 'f0f8ff', + color: '#b0d8e8', }; export const DEFAULT_VOXEL_TYPES = { diff --git a/src/state/world.ts b/src/state/world.ts index f717c23..266fddb 100644 --- a/src/state/world.ts +++ b/src/state/world.ts @@ -25,8 +25,9 @@ export class WorldState { public loadMock() { const objTypeId = 'test1'; - const voxelTypeId = 'water'; - const objectId = 'object1'; + const voxelTypeId = 'glass'; + const objectId1 = 'object1'; + const objectId2 = 'object2'; this.data = { objectTypes: { @@ -52,12 +53,18 @@ export class WorldState { look: [0, 0, 0], }, objects: { - [objectId]: { - id: objectId, + [objectId1]: { + id: objectId1, typeId: objTypeId, position: [0, 0, 0], rotation: [0, 0, 0], }, + [objectId2]: { + id: objectId2, + typeId: objTypeId, + position: [1, 0, 0], + rotation: [0, 0, 0], + }, }, }, gameRules: { @@ -67,6 +74,7 @@ export class WorldState { playing: false, }, }; + this.save(); } public load() {