Skip to content

Commit

Permalink
1.4.0 | getRandomColor() takes an array, bug fixes (#309)
Browse files Browse the repository at this point in the history
- Update viewer camera to not give errors in console
- getRandomColor() can take an array and choose a random color from the array.
- Reference page doesn't have uncaught error from no editor.
- Reference page tab titles hide on small screens.
- Nested groups are supported.
  • Loading branch information
jasondkiesling authored Jul 1, 2019
1 parent b8d968c commit ed84433
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 47 deletions.
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ The Engaging Computing Group develops new technologies to enable learners—yout
## Status
[![CircleCI](https://circleci.com/gh/engaging-computing/MYR.svg?style=shield)](https://circleci.com/gh/engaging-computing/MYR)

## Change Log - 1.2.6 -> 1.3.0
- Implemented relative cursor modification functions (increasePosition, increaseXPos, increaseYPos, increaseZPos).
- Implemented a welcome screen to give new users information during their first visit.
- Project view has been updated to be a tabbed modal.
- Projects with the same name are now sorted by timestamp.
- Reference drawer new tab and close buttons moved to corner.
- Reference drawer has a title added.
- There are no labels on the reference on a small screen to make it easier to read.
- The MYR brand will direct to create a new scene.
- "Too many errors" won't appear in the editor for long scenes.
- Settings modal is a tabbed modal.
## Change Log - 1.3.0 -> 1.4.0
- Update viewer camera to not give errors in console
- `getRandomColor()` can take an array and choose a random color from the array.
- Reference page doesn't have uncaught error from no editor.
- Reference page tab titles hide on small screens.
- Nested groups are supported.

## Acknowledgments
MYR uses [Aframe](https://aframe.io), a fantastic open source project, to render objects and effects in the three dimensional space.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "myr",
"version": "1.3.0",
"version": "1.4.0",
"private": false,
"engines": {
"node": "10.13.0"
Expand Down Expand Up @@ -61,4 +61,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}
25 changes: 21 additions & 4 deletions src/components/reference/ReferencePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TableHead,
TableRow,
TableCell,
Hidden,
} from "@material-ui/core";

import "../../css/ReferencePage.css";
Expand Down Expand Up @@ -80,19 +81,35 @@ export default class Reference extends React.Component {
onChange={this.handleChange} >
<Tab
icon={<Icon className="material-icons geometry">category</Icon>}
label="GEOMETRY"
label={
<Hidden xsDown>
<div>GEOMETRY</div>
</Hidden>
}
value='a' />
<Tab
icon={<Icon className="material-icons color-change">bubble_chart</Icon>}
label="TRANSFORMATIONS"
label={
<Hidden xsDown>
<div>TRANSFORMATIONS</div>
</Hidden>
}
value='b' />
<Tab
icon={<Icon className="material-icons animation-ref">zoom_out_map</Icon>} //swap_horiz control_camera category
label="ANIMATIONS"
label={
<Hidden xsDown>
<div>ANIMATIONS</div>
</Hidden>
}
value='c' />
<Tab
icon={<Icon className="material-icons geometry">widgets</Icon>}
label="GROUPS"
label={
<Hidden xsDown>
<div>GROUPS</div>
</Hidden>
}
value='d' />
</Tabs>
{<div style={{ margin: 5 }}>
Expand Down
16 changes: 8 additions & 8 deletions src/components/structural/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ class View extends Component {
checkpointCam = () => {
return (
<a-entity id="rig" movement-controls="controls: checkpoint" checkpoint-controls="mode: animate">
<a-entity camera
<a-camera
position={this.props.sceneConfig.settings.cameraPosition}
look-controls="pointerLockEnabled: true"
>
<a-entity cursor
<a-cursor
position="0 0 -1"
geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03;"
material="color: #CCC; shader: flat;" />
</a-entity>
</a-camera>
</a-entity>
);
}
Expand All @@ -143,15 +143,15 @@ class View extends Component {
return (
<a-entity id="rig"
debug={true}
movement-controls={this.props.sceneConfig.settings.canFly ? "fly:true" : "fly:false"}
position={this.props.sceneConfig.settings.cameraPosition} >
<a-entity camera
movement-controls={this.props.sceneConfig.settings.canFly ? "fly:true" : "fly:false"} >
<a-camera
position={this.props.sceneConfig.settings.cameraPosition}
look-controls="pointerLockEnabled: true">
<a-entity cursor
<a-cursor
position="0 0 -1"
geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03;"
material="color: #CCC; shader: flat;" />
</a-entity>
</a-camera>
</a-entity>
);
}
Expand Down
26 changes: 14 additions & 12 deletions src/components/structural/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,21 @@ class Header extends Component {
document.addEventListener("keydown", this.handleKeyDown.bind(this));

// Warn the issue before refreshing the page
try {
let editor = window.ace.edit("ace-editor");
editor.getSession().on("change", () => {
let text = editor.getSession().getValue();
if (this.props.text !== text) {
this.setState({ editorChange: true });
} else {
this.setState({ editorChange: false });
}
if (this.props.layoutType !== layoutTypes.REFERENCE) {
try {
let editor = window.ace.edit("ace-editor");
editor.getSession().on("change", () => {
let text = editor.getSession().getValue();
if (this.props.text !== text) {
this.setState({ editorChange: true });
} else {
this.setState({ editorChange: false });
}

});
} catch (err) {
console.error(err);
});
} catch (err) {
console.error(err);
}
}
window.addEventListener("beforeunload", (event) => {
if (this.state.editorChange) {
Expand Down
7 changes: 7 additions & 0 deletions src/myr/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ class Group {
}

add = (id) => {
if (id instanceof Group) {
this.els.push(this.myr.transfer(id.id));
}
this.els.push(this.myr.transfer(id));

}

remove = (id) => {
if (id instanceof Group) {
id = id.id;
}
let index = this.getIndex(id);
let el = this.els[index];
delete this.els[index];
Expand Down
22 changes: 14 additions & 8 deletions src/myr/Myr.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,20 @@ class Myr {
this.color = color;
}

getRandomColor = () => {
let color, i, letters;
letters = "0123456789ABCDEF";
color = "#";
i = 0;
while (i < 6) {
color += letters[Math.floor(Math.random() * 16)];
i++;
getRandomColor = (colors = null) => {
let color;
if (Array.isArray(colors) && colors.length !== 0) {
color = colors[Math.floor(Math.random() * colors.length)];
}
else {
let i, letters;
letters = "0123456789ABCDEF";
color = "#";
i = 0;
while (i < 6) {
color += letters[Math.floor(Math.random() * 16)];
i++;
}
}
this.color = color;
return color;
Expand Down
4 changes: 2 additions & 2 deletions src/myr/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ let transformations = [
example: "setColor"
},
{
name: <span>getRandomColor()</span>,
description: <span>Changes the color of the cursor to a random color, and returns the color. Default: 'red'</span>,
name: <span>getRandomColor(<span className="array">array</span>)</span>,
description: <span>Changes the color of the cursor to either a completely random color or a random color from an array of colors if an array is provided, then returns that color. Default: 'red'</span>,
example: "getRandomColor"
},
{
Expand Down
7 changes: 7 additions & 0 deletions src/tests/Myr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ describe("Updates to Myr's Model", () => {
expect(color).not.toBeUndefined();
expect(colorRegEx.test(color)).toBeTruthy();
});

it("pick Random Color out of a list of colors", () => {
let colors = ["blue","green","red","hotpink","FF00FF","rgb(100,33,93)"];
let color = myr.getRandomColor(colors);
expect(color).not.toBeUndefined();
expect(colors.includes(color)).toBeTruthy();
});
});

describe("Component Renders", () => {
Expand Down

0 comments on commit ed84433

Please sign in to comment.