From 907a54cbfe07b7f0127973051ec0a4f5e165edc5 Mon Sep 17 00:00:00 2001 From: paireks Date: Mon, 11 Mar 2024 21:15:24 +0100 Subject: [PATCH] Update colors to be normalized --- packages/dotbim/src/loadDotBIM.ts | 4 ++-- packages/dotbim/src/saveDotBIM.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/dotbim/src/loadDotBIM.ts b/packages/dotbim/src/loadDotBIM.ts index 833899678..663380b12 100644 --- a/packages/dotbim/src/loadDotBIM.ts +++ b/packages/dotbim/src/loadDotBIM.ts @@ -97,8 +97,8 @@ function parseDotBIM(ctx: any) { const mesh = ctx.sceneModel.createMesh({ id: meshId, geometryId, - color: color ? [color.r, color.g, color.b] : undefined, - opacity: color? color.a : 1.0, + color: color ? [color.r / 255.0, color.g / 255.0, color.b / 255.0] : undefined, + opacity: color? color.a / 255.0 : 1.0, quaternion: rotation ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined, position: vector ? [vector.x, vector.y, vector.z] : undefined }); diff --git a/packages/dotbim/src/saveDotBIM.ts b/packages/dotbim/src/saveDotBIM.ts index eb178911e..7f3d905f7 100644 --- a/packages/dotbim/src/saveDotBIM.ts +++ b/packages/dotbim/src/saveDotBIM.ts @@ -158,10 +158,10 @@ function modelToDotBIM(params: { dataModel: DataModel; sceneModel: SceneModel }) mesh_id: dbMesh.mesh_id, type: info.type, color: { - r: color[0], - g: color[1], - b: color[2], - a: firstMesh.opacity + r: color[0] * 255.0, + g: color[1] * 255.0, + b: color[2] * 255.0, + a: firstMesh.opacity * 255.0 }, vector: { x: position[0], @@ -181,4 +181,4 @@ function modelToDotBIM(params: { dataModel: DataModel; sceneModel: SceneModel }) } return dotBim; -} \ No newline at end of file +}