Obj file with colors

  • Hello, as on my workflow I'm using obj files where I have groups (facets) that I colored, I was wondering if it could be done with jcsad 2. I didn't realize that immediately, but obj require handle groups by creating an array instead of a sole polyhedron, so it was not hard to do. For the moment I read the groups colors by hand, but they are into the companion file .mtl and could be fetched (I suppose it's for each group on 'kd' entry. Anyway that's already very nice.

    const jscad = require('@jscad/modeling')
    const { colors } = jscad
    const { colorize } = colors
    //const obj = require('./Gargouille692.obj')
    const obj = require('./6ZonesMat.obj')
    const main = () => {
      let cols = [
      ].map(x=> x.map(y => y/255))
      let r = obj.map((x, index)=> colorize(cols[index], x))
      return r
    module.exports = { main }

    Capture d’écran de 2020-09-17 10-30-47.png

Log in to reply