Skip to content

Commit

Permalink
feat: improve material colors
Browse files Browse the repository at this point in the history
  • Loading branch information
seasick committed Dec 30, 2023
1 parent 087ced7 commit 4b64e11
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import ThreeJsCanvas from './components/threeJs/Canvas';
import useFile from './components/threeJs/useFile';
import config from './etc/config.json';
import { ChangedColors, changeColors } from './utils/3mf/changeColors';
import { hexToRgb } from './utils/color';
import createFileFromHttp from './utils/createFileFromHttp';
import { getFaceCount } from './utils/geometry';

Expand Down Expand Up @@ -70,12 +69,14 @@ export default function App() {
const mesh = child as THREE.Mesh;
const facesCount = getFaceCount(mesh);
const filledArray: number[] = [];
const rgb = hexToRgb(color);
const threeColor = new THREE.Color(color);

threeColor.convertSRGBToLinear();

for (let i = 0; i < facesCount; ++i) {
filledArray.push(rgb[0] / 255);
filledArray.push(rgb[1] / 255);
filledArray.push(rgb[2] / 255);
filledArray.push(threeColor.r);
filledArray.push(threeColor.g);
filledArray.push(threeColor.b);
}

const attribute = new THREE.BufferAttribute(
Expand Down

0 comments on commit 4b64e11

Please sign in to comment.