diff --git a/components/layout/README.md b/components/layout/README.md index 49c53c68..915f2497 100644 --- a/components/layout/README.md +++ b/components/layout/README.md @@ -48,6 +48,7 @@ We move then entire group around while maintaining the layout: | plane | Which plane direction for 2D layout. Can be `xy`, `yz`, or `xz` (for type `box`, `circle`, `line`) | `xy` | | radius | Radius in meters (for type `circle`, `cube`, `dodecahedron`, `pyramid`. | 1 | | reverse | Whether to reverse direction of layout. | false | +| angle | For type `circle`, set this to position items `angle` degrees apart | false | ### Usage diff --git a/components/layout/dist/aframe-layout-component.js b/components/layout/dist/aframe-layout-component.js index 70e2d03e..f7b56c6f 100644 --- a/components/layout/dist/aframe-layout-component.js +++ b/components/layout/dist/aframe-layout-component.js @@ -56,7 +56,9 @@ radius: {default: 1, min: 0, if: {type: ['circle', 'cube', 'dodecahedron', 'pyramid']}}, reverse: {default: false}, type: {default: 'line', oneOf: ['box', 'circle', 'cube', 'dodecahedron', 'line', - 'pyramid']} + 'pyramid']}, + fill: {default: true, if: {type: ['circle']}}, + angle: {type: 'number', default: false, min:0, max: 360, if: {type: ['circle']}} }, /** @@ -187,7 +189,14 @@ var positions = []; for (var i = 0; i < numChildren; i++) { - var rad = i * (2 * Math.PI) / numChildren; + var rad; + + if (isNaN(data.angle)) { + rad = i * (2 * Math.PI) / numChildren; + } else { + rad = i * data.angle * 0.01745329252; // angle to radian + } + var position = [ startPosition.x, startPosition.y, diff --git a/components/layout/dist/aframe-layout-component.min.js b/components/layout/dist/aframe-layout-component.min.js index d46d765b..e7fac041 100644 --- a/components/layout/dist/aframe-layout-component.min.js +++ b/components/layout/dist/aframe-layout-component.min.js @@ -1 +1 @@ -!function(e){function i(n){if(t[n])return t[n].exports;var r=t[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,i),r.loaded=!0,r.exports}var t={};return i.m=e,i.c=t,i.p="",i(0)}([function(e,i){function t(e,i,t){for(var n,r=[],a=Math.ceil(i/e.columns),o=0;o + + Circle Layout Angle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/layout/examples/circle-angle/preview.png b/components/layout/examples/circle-angle/preview.png new file mode 100644 index 00000000..2c0c3226 Binary files /dev/null and b/components/layout/examples/circle-angle/preview.png differ diff --git a/components/layout/index.html b/components/layout/index.html index f8ddd816..b9c87aca 100644 --- a/components/layout/index.html +++ b/components/layout/index.html @@ -88,8 +88,14 @@

Circle Layout - Planes

  • Circle Layout

    -

    Circular layout of boxes

    +

    Circular layout of boxes, fills circle (default)

  • + +
  • + +

    Circle Layout - Angle

    +

    Circular layout of boxes with supplied angle

    +
  • diff --git a/components/layout/index.js b/components/layout/index.js index fb1ace39..a5b928d1 100644 --- a/components/layout/index.js +++ b/components/layout/index.js @@ -10,7 +10,9 @@ AFRAME.registerComponent('layout', { radius: {default: 1, min: 0, if: {type: ['circle', 'cube', 'dodecahedron', 'pyramid']}}, reverse: {default: false}, type: {default: 'line', oneOf: ['box', 'circle', 'cube', 'dodecahedron', 'line', - 'pyramid']} + 'pyramid']}, + fill: {default: true, if: {type: ['circle']}}, + angle: {type: 'number', default: false, min:0, max: 360, if: {type: ['circle']}} }, /** @@ -141,7 +143,14 @@ function getCirclePositions (data, numChildren, startPosition) { var positions = []; for (var i = 0; i < numChildren; i++) { - var rad = i * (2 * Math.PI) / numChildren; + var rad; + + if (isNaN(data.angle)) { + rad = i * (2 * Math.PI) / numChildren; + } else { + rad = i * data.angle * 0.01745329252; // angle to radian + } + var position = [ startPosition.x, startPosition.y,