nicky-nym / city3d

3D architectural building models made using the three.js Javascript API
The Unlicense
9 stars 4 forks source link

Building JSON spec: syntax for Walls? #30

Closed nicky-nym closed 4 years ago

nicky-nym commented 4 years ago

Currently our JSON building spec only allows for exterior walls. To add support for interior walls we'll need to change what the JSON spec files look like.

What should we pick for the new syntax for defining walls?

Idea A:

SPEC_OPTION_A = {
  name: 'Cottage',
  shape: { type: 'rectangle', data: xy(30.333, 21) },
  walls: [{
    name: 'front wall',
    windows: [/* ... */]
  }, {
    name: 'right wall',
    windows: [/* ... */]
  }, {
    name: 'back wall',
    windows: [/* ... */]
  }, {
    name: 'left wall',
    windows: [/* ... */]
  }],
  partitions: [{
    name: 'bedroom wall',
    ends: [
      xy(18.833, 21),
      xy(18.833, 0)
    ],
    doors: [/* ... */]
  }, {
    name: 'bathroom wall',
    ends: [
      xy(19.333, 15.333),
      xy(0, 15.333)
    ],
    doors: [/* ... */]
  }, {
    name: 'closet wall',
    ends: [
      xy(22.333, 13),
      xy(0, 13)
    ],
    doors: [/* ... */]
  }, {
    name: 'wall toward bathroom',
    ends: [
      xy(22.333, 15.333),
      xy(22.333, 13)
    ]
  }, {
    name: 'laundry room wall',
    ends: [
      xy(0, 13.333),
      xy(10 + 6 / 12, 13.333)
    ],
    doors: [/* ... */]
  }, {
    name: 'kitchen/laundry wall',
    ends: [
      xy(7, 0),
      xy(7, -(7 + 2 / 12))
    ]
  }]
}

Idea B:

SPEC_OPTION_B = {
  name: 'Cottage',
  walls: {
    exterior: [{
      name: 'front wall',
      // at: y(0),    // default value
      // begin: x(0), // default value
      end: x(30.333),
      windows: [/* ... */]
    }, {
      name: 'right wall',
      // at: x(30.333), // default to end of previous wall
      // begin:         // defaults to end of previous wall
      end: y(21),
      windows: [/* ... */]
    }, {
      name: 'back wall',
      // at: y(21), // default to end of previous wall
      // begin:     // defaults to end of previous wall
      end: x(-30.333),
      windows: [/* ... */]
    }, {
      name: 'left wall',
      // at: x(0), // default to end of previous wall
      // begin:    // defaults to end of previous wall
      end: y(-21),
      windows: [/* ... */]
    }],
    interior: [{
      name: 'bedroom wall',
      at: x(18.833),
      begin: 'back wall',
      end: 'front wall',
      doors: [/* ... */]
    }, {
      name: 'bathroom wall',
      at: y(15.333),
      begin: 'bedroom wall',
      end: 'right wall',
      doors: [/* ... */]
    }, {
      name: 'closet wall',
      at: y(13),
      begin: x(22.333),
      end: 'right wall',
      doors: [/* ... */]
    }, {
      name: 'wall toward bathroom',
      at: x(22.333),
      begin: 'bathroom wall',
      end: 'closet wall'
    }, {
      name: 'laundry room wall',
      at: y(13.333),
      begin: 'left wall',
      end: x(10.5),
      doors: [/* ... */]
    }, {
      name: 'kitchen/laundry wall',
      at: x(7),
      begin: 'back wall',
      end: 'laundry room wall'
    }]
  }
}

Idea C:

SPEC_OPTION_C = {
  name: 'Cottage',
  points: {
    SW: xy(0, 0),
    SE: xy(30.333, 0),
    NE: xy(30.333, 21),
    NW: xy(0, 21),
    S1: xy(18.833, 0),
    N1: xy(18.833, 21),
    N2: xy(7, 21),
    W1: xy(0, 13.333),
    A: xy(7, 13.333),
    B: xy(10.5, 13.333),
    C: xy(18.833, 15.333),
    D: xy(22.333, 15.333),
    E1: xy(30.333, 15.333),
    E2: xy(30.333, 13),
    F: xy(22.333, 13)
  },
  walls: {
    exterior: [{
      name: 'front wall',
      begin: 'SW',
      end: 'SE',
      windows: [/* ... */]
    }, {
      name: 'right wall',
      // begin:         // defaults to end of previous wall
      end: 'NE',
      windows: [/* ... */]
    }, {
      name: 'back wall',
      // begin:     // defaults to end of previous wall
      end: 'NW',
      windows: [/* ... */]
    }, {
      name: 'left wall',
      // begin:    // defaults to end of previous wall
      end: 'SW',
      windows: [/* ... */]
    }],
    interior: [{
      name: 'bedroom wall',
      begin: 'N1',
      end: 'S1',
      doors: [/* ... */]
    }, {
      name: 'bathroom wall',
      begin: 'C',
      end: 'E1',
      doors: [/* ... */]
    }, {
      name: 'closet wall',
      begin: 'F',
      end: 'E2',
      doors: [/* ... */]
    }, {
      name: 'wall toward bathroom',
      begin: 'D',
      end: 'F'
    }, {
      name: 'laundry room wall',
      begin: 'W1',
      end: 'B',
      doors: [/* ... */]
    }, {
      name: 'kitchen/laundry wall',
      begin: 'N2',
      end: 'A'
    }]
  }
}

Idea D:

// some other option?
MignonBelongie commented 4 years ago

I like C. I think it's easiest to visualize, and it's easy to illustrate in a comment:

NW----N2---------N1----------NE
|      |          |           |
|      |          |           |
|      |          C---D------E1
|      |          |   |       |
W1-----A--B       |   F------E2
|                 |           |
|                 |           |
SW---------------S1----------SE
nicky-nym commented 4 years ago

Peachy. I'll work on implementing option C in the wall schema.