├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── box.js ├── changelog.md ├── package.json └── tests.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | tests.js 2 | changelog.md -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Greg Tatum 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 3d Box Geometry 2 | 3 | Generate a 3d box, with optional segments, centered on the origin. 4 | 5 | ![Spinning Box](http://fat.gfycat.com/IgnorantDependentGorilla.gif) 6 | 7 | var box = require('geo-3d-box')({ 8 | size: [5,5,5], 9 | segments: [2,2,2] 10 | }) 11 | 12 | or 13 | 14 | var box = require('geo-3d-box')({ 15 | size: 5, 16 | segments: 2 17 | }) 18 | 19 | The returned object is in the format of a simplicial complex with positions and cell indices (faces). In addition uvs and normals are generated. 20 | 21 | box = { 22 | positions: [ [x,y,z], [x,y,z], ... ], 23 | cells: [ [0,1,4], [4,3,0], ... ], 24 | uvs: [ [u,v], [u,v], ... ], 25 | normals: [ [x,y,z], [x,y,z], ... ], 26 | } 27 | 28 | ## Size (Array or Number) 29 | 30 | Either an array or a single number. Sets the width, height, and depth of the box. Defaults to [1,1,1]. 31 | 32 | ## Segments (Array or Number) 33 | 34 | Subdivide the cube. 35 | 36 | ## Migrating from v1.x.x 37 | 38 | The data is now all chunked in tuples like `[ [x,y,z], [x,y,z], ... ]` instead of `[ x,y,z,x,y,z,... ]` to be more in-line with stack.gl's ecosystem. In addition normals are now provided by default. -------------------------------------------------------------------------------- /box.js: -------------------------------------------------------------------------------- 1 | function _createConfig( properties ) { 2 | 3 | var config = { 4 | size : [1,1,1], 5 | segments : [1,1,1] 6 | } 7 | 8 | if( properties ) { 9 | 10 | if( Array.isArray( properties.size ) ) { 11 | config.size = properties.size 12 | } else if( typeof properties.size === "number" ) { 13 | config.size = [properties.size, properties.size, properties.size] 14 | } 15 | 16 | if( Array.isArray( properties.segments ) ) { 17 | config.segments = properties.segments 18 | } else if( typeof properties.segments === "number" ) { 19 | config.segments = [properties.segments, properties.segments, properties.segments] 20 | } 21 | } 22 | 23 | return config 24 | } 25 | 26 | function _flatten( array ) { 27 | var results = [] 28 | 29 | for( var i=0; i < array.length; i++ ) { 30 | var subarray = array[i] 31 | for( var j=0; j < subarray.length; j++ ) { 32 | results.push(subarray[j]) 33 | } 34 | } 35 | return results 36 | } 37 | 38 | function _generatePanel( config ) { 39 | 40 | var rows = _generateGrid( config ) 41 | var cells = _generateCells( config, rows ) 42 | var positions = _flatten( rows ) 43 | var uvs = _generateUvs( config, positions ) 44 | 45 | return { 46 | positions : positions, 47 | cells : cells, 48 | uvs : uvs, 49 | vertexCount : (config.sx + 1) * (config.sy + 1) 50 | } 51 | } 52 | 53 | function _generateUvs( config, positions ) { 54 | 55 | return positions.map(function(p) { 56 | return [ 57 | p[0] / config.wx + 0.5, 58 | p[1] / config.wy + 0.5 59 | ] 60 | }) 61 | } 62 | 63 | function _generateGrid( config ) { 64 | 65 | var step = config.wy / config.sy 66 | var halfY = config.wy / 2 67 | var length = config.sy + 1 68 | var grid = Array(length) 69 | 70 | for( var i=0; i < length; i++ ) { 71 | grid[i] = _generateRow( config, step * i - halfY) 72 | } 73 | 74 | return grid 75 | } 76 | 77 | function _generateRow( config, height ) { 78 | 79 | var halfX = config.wx / 2 80 | var step = config.wx / config.sx 81 | var length = config.sx + 1 82 | var row = Array(length) 83 | 84 | for( var i=0; i < length; i++ ) { 85 | row[i] = [ step * i - halfX, height ] 86 | } 87 | 88 | return row 89 | } 90 | 91 | function _generateCells( config ) { 92 | 93 | function index( x, y ) { 94 | return (config.sx + 1) * y + x 95 | } 96 | 97 | var cells = [] 98 | 99 | for( var x=0; x < config.sx; x++ ) { 100 | 101 | for( var y=0; y < config.sy; y++ ) { 102 | 103 | var a = index( x + 0, y + 0 ) // d __ c 104 | var b = index( x + 1, y + 0 ) // | | 105 | var c = index( x + 1, y + 1 ) // |__| 106 | var d = index( x + 0, y + 1 ) // a b 107 | 108 | cells.push( [ a, b, c ] ) 109 | cells.push( [ c, d, a ] ) 110 | } 111 | } 112 | 113 | return cells 114 | } 115 | 116 | function _clonePanel( panel ) { 117 | 118 | return { 119 | positions : panel.positions, 120 | cells : panel.cells, 121 | uvs : panel.uvs, 122 | vertexCount : panel.vertexCount 123 | } 124 | } 125 | 126 | function _generateBoxPanels( config ) { 127 | 128 | var size = config.size 129 | var segs = config.segments 130 | 131 | // yp zm 132 | // | / 133 | // |/ 134 | // xm ----+----- xp 135 | // /| 136 | // / | 137 | // zp ym 138 | 139 | var zp = _generatePanel({ 140 | wx: size[0], wy: size[1], 141 | sx: segs[0], sy: segs[1] 142 | }) 143 | var xp = _generatePanel({ 144 | wx: size[2], wy: size[1], 145 | sx: segs[2], sy: segs[1] 146 | }) 147 | var yp = _generatePanel({ 148 | wx: size[0], wy: size[2], 149 | sx: segs[0], sy: segs[2] 150 | }) 151 | 152 | var zm = _clonePanel(zp) 153 | var xm = _clonePanel(xp) 154 | var ym = _clonePanel(yp) 155 | 156 | zp.positions = zp.positions.map( function(p) { return [ p[0], p[1], size[2]/2 ] } ) 157 | zm.positions = zm.positions.map( function(p) { return [ p[0], -p[1], -size[2]/2 ] } ) 158 | xp.positions = xp.positions.map( function(p) { return [ size[0]/2, -p[1], p[0] ] } ) 159 | xm.positions = xm.positions.map( function(p) { return [ -size[0]/2, p[1], p[0] ] } ) 160 | yp.positions = yp.positions.map( function(p) { return [ p[0], size[1]/2, -p[1] ] } ) 161 | ym.positions = ym.positions.map( function(p) { return [ p[0], -size[1]/2, p[1] ] } ) 162 | 163 | zp.normals = _makeNormals( [ 0, 0, 1], zp.positions.length ) 164 | zm.normals = _makeNormals( [ 0, 0,-1], zm.positions.length ) 165 | xp.normals = _makeNormals( [ 1, 0, 0], xp.positions.length ) 166 | xm.normals = _makeNormals( [-1, 0, 0], xm.positions.length ) 167 | yp.normals = _makeNormals( [ 0, 1, 0], yp.positions.length ) 168 | ym.normals = _makeNormals( [ 0,-1, 0], ym.positions.length ) 169 | 170 | return [ zp, zm, xp, xm, yp, ym ] 171 | } 172 | 173 | function _makeNormals( normal, count ) { 174 | 175 | var normals = Array(count) 176 | 177 | for( var i=0; i < count; i++ ) { 178 | normals[i] = normal.slice() 179 | } 180 | 181 | return normals 182 | } 183 | 184 | function _generateBox( config ) { 185 | 186 | var panels = _generateBoxPanels( config ) 187 | 188 | var positions = panels.map(function(panel) { return panel.positions }) 189 | var uvs = panels.map(function(panel) { return panel.uvs }) 190 | var normals = panels.map(function(panel) { return panel.normals }) 191 | var cells = _offsetCellIndices( panels ) 192 | 193 | return { 194 | positions: _flatten( positions ), 195 | uvs: _flatten( uvs ), 196 | cells: _flatten( cells ), 197 | normals: _flatten( normals ), 198 | } 199 | } 200 | 201 | function _offsetCellIndices( panels ) { 202 | 203 | /* 204 | From: [[[0,1,2],[2,3,0]],[[0,1,2],[2,3,0]]] 205 | To: [[[0,1,2],[2,3,0]],[[6,7,8],[8,9,6]]] 206 | */ 207 | 208 | var offset = 0 209 | 210 | return panels.map(function(panel) { 211 | 212 | var offsetCells = panel.cells.map( function(cell) { 213 | return cell.map(function(v) { 214 | return v + offset 215 | }) 216 | }) 217 | 218 | offset += panel.vertexCount 219 | 220 | return offsetCells 221 | }) 222 | } 223 | 224 | module.exports = function( properties ) { 225 | 226 | var config = _createConfig( properties ) 227 | 228 | return _generateBox( config ) 229 | } -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### 2.0.0 4 | 5 | Removed dependencies, and rewrote to be ES5 only. Note the require('geo-3d-box/es5') is no longer an option. The data is now all chunked in tuples like `[ [x,y,z], [x,y,z], ... ]` instead of `[ x,y,z,x,y,z,... ]` to be more in-line with stack.gl's ecosystem. In addition normals are now provided by default. 6 | 7 | ### 1.0.4 8 | 9 | Noted the presence of ES6, and added an ES5 build. 10 | 11 | ### 1.0.3 12 | 13 | Fixed a winding order issue 14 | 15 | ### 1.0.2 16 | 17 | Fixed a few issues with the package.json dependencies 18 | 19 | ### 1.0.1 20 | 21 | Fixed a few issues with the package.json dependencies -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "geo-3d-box", 3 | "version": "2.0.2", 4 | "description": "Generate 3d box geometry", 5 | "main": "box.js", 6 | "scripts": { 7 | "test": "browserify tests.js | node | faucet" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/TatumCreative/geo-3d-box" 12 | }, 13 | "keywords": [ 14 | "3d", 15 | "geometry", 16 | "WebGL", 17 | "box", 18 | "cube", 19 | "simplicial" 20 | ], 21 | "author": "Greg Tatum", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/TatumCreative/geo-3d-box/issues" 25 | }, 26 | "homepage": "https://github.com/TatumCreative/geo-3d-box", 27 | "dependencies": {}, 28 | "devDependencies": { 29 | "faucet": "0.0.1", 30 | "lodash": "^3.7.0", 31 | "tape": "^4.0.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests.js: -------------------------------------------------------------------------------- 1 | var Box = require('./box') 2 | , _ = require('lodash') 3 | , test = require('tape') 4 | 5 | function boxSize( positions, d ) { 6 | 7 | var max = _.reduce( positions, function( memo, position ) { 8 | return Math.max( memo, position[d] ) 9 | }, 0) 10 | var min = _.reduce( positions, function( memo, position ) { 11 | return Math.min( memo, position[d] ) 12 | }, 0) 13 | 14 | return max - min 15 | } 16 | 17 | function average( positions ) { 18 | 19 | var average = _.reduce( positions, function( memo, position ) { 20 | 21 | memo[0] += position[0] / positions.length 22 | memo[1] += position[1] / positions.length 23 | memo[2] += position[2] / positions.length 24 | 25 | return memo 26 | 27 | }, [0,0,0]) 28 | 29 | average[0] = average[0] < 0.00001 ? 0 : average[0] 30 | average[1] = average[1] < 0.00001 ? 0 : average[1] 31 | average[2] = average[2] < 0.00001 ? 0 : average[2] 32 | 33 | return average 34 | } 35 | test("box", function(t) { 36 | 37 | 38 | t.test("- returns positions, uvs, cells, and normals", function(t) { 39 | 40 | t.plan(5) 41 | 42 | var box = Box() 43 | var keys = _.sortBy( _.keys(box), function( key ) { 44 | return key 45 | }) 46 | 47 | t.isEquivalent( keys, [ 'cells', 'normals', 'positions', 'uvs' ] ) 48 | t.equal( _.isArray( box.positions ), true ) 49 | t.equal( _.isArray( box.uvs ), true ) 50 | t.equal( _.isArray( box.cells ), true ) 51 | t.equal( _.isArray( box.normals ), true ) 52 | 53 | }) 54 | 55 | t.test("- default width 1", function(t) { 56 | 57 | t.plan(3) 58 | 59 | var box = Box() 60 | 61 | t.equal( boxSize( box.positions, 0 ), 1 ) 62 | t.equal( boxSize( box.positions, 1 ), 1 ) 63 | t.equal( boxSize( box.positions, 2 ), 1 ) 64 | }) 65 | 66 | t.test("- can set size", function(t) { 67 | 68 | t.plan(3) 69 | 70 | var box = Box({ 71 | size: [2,3,4] 72 | }) 73 | 74 | t.equal( boxSize( box.positions, 0 ), 2 ) 75 | t.equal( boxSize( box.positions, 1 ), 3 ) 76 | t.equal( boxSize( box.positions, 2 ), 4 ) 77 | }) 78 | 79 | t.test("- is about the origin", function(t) { 80 | 81 | t.plan(3) 82 | 83 | var boxA = Box({ 84 | size: [2,3,4] 85 | }) 86 | var boxB = Box() 87 | var boxC = Box({ 88 | size: [2,3,4] 89 | , segments: [2,3,4] 90 | }) 91 | 92 | var avgA = average( boxA.positions ) 93 | var avgB = average( boxB.positions ) 94 | var avgC = average( boxC.positions ) 95 | 96 | t.isEquivalent( avgA , [0,0,0] ) 97 | t.isEquivalent( avgB , [0,0,0] ) 98 | t.isEquivalent( avgC , [0,0,0] ) 99 | }) 100 | 101 | t.test("- can generate a box correctly", function( t ) { 102 | 103 | t.plan(3) 104 | 105 | var box1 = { 106 | positions : [[-0.5,-0.5,0.5],[0.5,-0.5,0.5],[-0.5,0.5,0.5],[0.5,0.5,0.5],[-0.5,0.5,-0.5],[0.5,0.5,-0.5],[-0.5,-0.5,-0.5],[0.5,-0.5,-0.5],[0.5,0.5,-0.5],[0.5,0.5,0.5],[0.5,-0.5,-0.5],[0.5,-0.5,0.5],[-0.5,-0.5,-0.5],[-0.5,-0.5,0.5],[-0.5,0.5,-0.5],[-0.5,0.5,0.5],[-0.5,0.5,0.5],[0.5,0.5,0.5],[-0.5,0.5,-0.5],[0.5,0.5,-0.5],[-0.5,-0.5,-0.5],[0.5,-0.5,-0.5],[-0.5,-0.5,0.5],[0.5,-0.5,0.5]], 107 | uvs : [[0,0],[1,0],[0,1],[1,1],[0,0],[1,0],[0,1],[1,1],[0,0],[1,0],[0,1],[1,1],[0,0],[1,0],[0,1],[1,1],[0,0],[1,0],[0,1],[1,1],[0,0],[1,0],[0,1],[1,1]], 108 | cells : [[0,1,3],[3,2,0],[4,5,7],[7,6,4],[8,9,11],[11,10,8],[12,13,15],[15,14,12],[16,17,19],[19,18,16],[20,21,23],[23,22,20]], 109 | normals : [[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0]] 110 | } 111 | 112 | var box2 = 113 | { 114 | positions : [[-1,-1,1],[0,-1,1],[1,-1,1],[-1,-0.33333333333333337,1],[0,-0.33333333333333337,1],[1,-0.33333333333333337,1],[-1,0.33333333333333326,1],[0,0.33333333333333326,1],[1,0.33333333333333326,1],[-1,1,1],[0,1,1],[1,1,1],[-1,1,-1],[0,1,-1],[1,1,-1],[-1,0.33333333333333337,-1],[0,0.33333333333333337,-1],[1,0.33333333333333337,-1],[-1,-0.33333333333333326,-1],[0,-0.33333333333333326,-1],[1,-0.33333333333333326,-1],[-1,-1,-1],[0,-1,-1],[1,-1,-1],[1,1,-1],[1,1,-0.5],[1,1,0],[1,1,0.5],[1,1,1],[1,0.33333333333333337,-1],[1,0.33333333333333337,-0.5],[1,0.33333333333333337,0],[1,0.33333333333333337,0.5],[1,0.33333333333333337,1],[1,-0.33333333333333326,-1],[1,-0.33333333333333326,-0.5],[1,-0.33333333333333326,0],[1,-0.33333333333333326,0.5],[1,-0.33333333333333326,1],[1,-1,-1],[1,-1,-0.5],[1,-1,0],[1,-1,0.5],[1,-1,1],[-1,-1,-1],[-1,-1,-0.5],[-1,-1,0],[-1,-1,0.5],[-1,-1,1],[-1,-0.33333333333333337,-1],[-1,-0.33333333333333337,-0.5],[-1,-0.33333333333333337,0],[-1,-0.33333333333333337,0.5],[-1,-0.33333333333333337,1],[-1,0.33333333333333326,-1],[-1,0.33333333333333326,-0.5],[-1,0.33333333333333326,0],[-1,0.33333333333333326,0.5],[-1,0.33333333333333326,1],[-1,1,-1],[-1,1,-0.5],[-1,1,0],[-1,1,0.5],[-1,1,1],[-1,1,1],[0,1,1],[1,1,1],[-1,1,0.5],[0,1,0.5],[1,1,0.5],[-1,1,0],[0,1,0],[1,1,0],[-1,1,-0.5],[0,1,-0.5],[1,1,-0.5],[-1,1,-1],[0,1,-1],[1,1,-1],[-1,-1,-1],[0,-1,-1],[1,-1,-1],[-1,-1,-0.5],[0,-1,-0.5],[1,-1,-0.5],[-1,-1,0],[0,-1,0],[1,-1,0],[-1,-1,0.5],[0,-1,0.5],[1,-1,0.5],[-1,-1,1],[0,-1,1],[1,-1,1]], 115 | uvs : [[0,0],[0.5,0],[1,0],[0,0.3333333333333333],[0.5,0.3333333333333333],[1,0.3333333333333333],[0,0.6666666666666666],[0.5,0.6666666666666666],[1,0.6666666666666666],[0,1],[0.5,1],[1,1],[0,0],[0.5,0],[1,0],[0,0.3333333333333333],[0.5,0.3333333333333333],[1,0.3333333333333333],[0,0.6666666666666666],[0.5,0.6666666666666666],[1,0.6666666666666666],[0,1],[0.5,1],[1,1],[0,0],[0.25,0],[0.5,0],[0.75,0],[1,0],[0,0.3333333333333333],[0.25,0.3333333333333333],[0.5,0.3333333333333333],[0.75,0.3333333333333333],[1,0.3333333333333333],[0,0.6666666666666666],[0.25,0.6666666666666666],[0.5,0.6666666666666666],[0.75,0.6666666666666666],[1,0.6666666666666666],[0,1],[0.25,1],[0.5,1],[0.75,1],[1,1],[0,0],[0.25,0],[0.5,0],[0.75,0],[1,0],[0,0.3333333333333333],[0.25,0.3333333333333333],[0.5,0.3333333333333333],[0.75,0.3333333333333333],[1,0.3333333333333333],[0,0.6666666666666666],[0.25,0.6666666666666666],[0.5,0.6666666666666666],[0.75,0.6666666666666666],[1,0.6666666666666666],[0,1],[0.25,1],[0.5,1],[0.75,1],[1,1],[0,0],[0.5,0],[1,0],[0,0.25],[0.5,0.25],[1,0.25],[0,0.5],[0.5,0.5],[1,0.5],[0,0.75],[0.5,0.75],[1,0.75],[0,1],[0.5,1],[1,1],[0,0],[0.5,0],[1,0],[0,0.25],[0.5,0.25],[1,0.25],[0,0.5],[0.5,0.5],[1,0.5],[0,0.75],[0.5,0.75],[1,0.75],[0,1],[0.5,1],[1,1]], 116 | cells : [[0,1,4],[4,3,0],[3,4,7],[7,6,3],[6,7,10],[10,9,6],[1,2,5],[5,4,1],[4,5,8],[8,7,4],[7,8,11],[11,10,7],[12,13,16],[16,15,12],[15,16,19],[19,18,15],[18,19,22],[22,21,18],[13,14,17],[17,16,13],[16,17,20],[20,19,16],[19,20,23],[23,22,19],[24,25,30],[30,29,24],[29,30,35],[35,34,29],[34,35,40],[40,39,34],[25,26,31],[31,30,25],[30,31,36],[36,35,30],[35,36,41],[41,40,35],[26,27,32],[32,31,26],[31,32,37],[37,36,31],[36,37,42],[42,41,36],[27,28,33],[33,32,27],[32,33,38],[38,37,32],[37,38,43],[43,42,37],[44,45,50],[50,49,44],[49,50,55],[55,54,49],[54,55,60],[60,59,54],[45,46,51],[51,50,45],[50,51,56],[56,55,50],[55,56,61],[61,60,55],[46,47,52],[52,51,46],[51,52,57],[57,56,51],[56,57,62],[62,61,56],[47,48,53],[53,52,47],[52,53,58],[58,57,52],[57,58,63],[63,62,57],[64,65,68],[68,67,64],[67,68,71],[71,70,67],[70,71,74],[74,73,70],[73,74,77],[77,76,73],[65,66,69],[69,68,65],[68,69,72],[72,71,68],[71,72,75],[75,74,71],[74,75,78],[78,77,74],[79,80,83],[83,82,79],[82,83,86],[86,85,82],[85,86,89],[89,88,85],[88,89,92],[92,91,88],[80,81,84],[84,83,80],[83,84,87],[87,86,83],[86,87,90],[90,89,86],[89,90,93],[93,92,89]], 117 | normals : [[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[0,0,-1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[-1,0,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0],[0,-1,0]] 118 | } 119 | 120 | var boxA = Box() 121 | var boxB = Box({ 122 | size: [2,2,2] 123 | , segments: [2,3,4] 124 | }) 125 | var boxC = Box({ 126 | size: 1 127 | , segments: 1 128 | }) 129 | 130 | 131 | t.isEquivalent( boxA, box1 ) 132 | t.isEquivalent( boxB, box2 ) 133 | t.isEquivalent( boxC, box1 ) 134 | }) 135 | }) --------------------------------------------------------------------------------