Commit f6f2fc61 authored by nduca@chromium.org's avatar nduca@chromium.org

[cc] Add gl-matrix to cc-frame-viewer 3rd party

R=vmpstr

Review URL: https://codereview.chromium.org/12250012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182017 0039d316-1c4b-4281-b951-d872f2087c98
parent d6545d50
source :gemcutter
# core ruby
gem 'rake'
# https://github.com/pivotal/jasmine-gem
gem 'jasmine'
# https://github.com/sstephenson/sprockets
gem 'sprockets'
# https://github.com/lautis/uglifier
gem 'uglifier'
# for jasmine:ci task
gem 'json'
# https://github.com/wycats/thor - for release debug
gem 'thor'
GEM
remote: http://rubygems.org/
specs:
childprocess (0.3.7)
ffi (~> 1.0, >= 1.0.6)
diff-lcs (1.1.3)
execjs (1.4.0)
multi_json (~> 1.0)
ffi (1.3.1)
hike (1.2.1)
jasmine (1.2.1)
jasmine-core (>= 1.2.0)
rack (~> 1.0)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
jasmine-core (1.2.0)
json (1.7.4)
multi_json (1.5.0)
rack (1.4.1)
rake (0.9.2.2)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.2)
rubyzip (0.9.9)
selenium-webdriver (2.29.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
sprockets (2.4.5)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
websocket (1.0.7)
PLATFORMS
ruby
DEPENDENCIES
jasmine
json
rake
sprockets
thor
uglifier
Copyright (c) 2013 Brandon Jones, Colin MacKenzie IV
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
\ No newline at end of file
Name: gl-matrix
Short Name: gl-matrix
URL: https://github.com/toji/gl-matrix
Version: 0
Revision: fb436a8f6b82d200d0069790635810778712dd44
Date: Mon Feb 4 16:54:37 2013 -0500
License: BSD
License File: NOT_SHIPPED
Security Critical: no
Description:
Matrix math in javascript
Local Modifications:
None.
glMatrix
=======================
Javascript has evolved into a language capable of handling realtime 3D graphics,
via WebGL, and computationally intensive tasks such as physics simulations.
These types of applications demand high performance vector and matrix math,
which is something that Javascript doesn't provide by default.
glMatrix to the rescue!
glMatrix is designed to perform vector and matrix operations stupidly fast! By
hand-tuning each function for maximum performance and encouraging efficient
usage patterns through API conventions, glMatrix will help you get the most out
of your browsers Javascript engine.
Learn More
----------------------
For documentation, news, tutorials, and more visit the [glMatrix Homepage](http://glmatrix.net/)
\ No newline at end of file
begin
require 'bundler/setup'
rescue LoadError
puts "Couldn't find Bundler!"
puts
puts "Please run:"
puts " gem install bundler"
puts
puts "...and then try again."
puts
exit
end
# dependencies
require 'json'
require 'rspec/core/rake_task'
require 'uglifier'
# helper module
require File.expand_path('./tasks/support/gl-matrix', File.dirname(__FILE__))
include GLMatrix
Dir[base_path.join './tasks/**/*.rake'].each do |f|
load f
end
Running the test suite
=======================
The unit tests are built upon the following tools:
* Jasmine -- the underlying test suite which executes the test and reports feedback
* node.js -- used for testing at the command line, via the `jasmine-node` package
* selenium -- used for automated in-browser testing via Ruby
If Ruby is installed, you can set up with:
gem install bundler
bundle install
...and then test with:
rake
Hint: also look at
rake --tasks
If Ruby is not installed, you must test with `jasmine-node` directly:
NODE_PATH=$NODE_PATH:. \
node_modules/jasmine-node/bin/jasmine-node \
spec/helpers/node_helper.js
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<div align="center">{+new Link().toFile("index.html").withText("Class Index")+}
| {+new Link().toFile("files.html").withText("File Index")+}</div>
<hr />
<h2>Classes</h2>
<ul class="classList">
<for each="thisClass" in="data">
<li>{!
if (thisClass.alias != "_global_") {
output += new Link().toClass(thisClass.alias);
}
!}</li>
</for>
</ul>
<hr />
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset={+IO.encoding+}" />
{! Link.base = ""; /* all generated links will be relative to this */ !}
<title>glMatrix - File Index</title>
<meta name="generator" content="JsDoc Toolkit" />
<style type="text/css">
{+include("static/default.css")+}
</style>
</head>
<body>
{+include("static/header.html")+}
<div class="wrapper">
<header id="index">
{+publish.classesIndex+}
</header>
<section id="content">
<h1 class="classTitle">File Index</h1>
<for each="item" in="data">
<div>
<h2>{+new Link().toSrc(item.alias).withText(item.name)+}</h2>
<if test="item.desc">{+resolveLinks(item.desc)+}</if>
<dl>
<if test="item.author">
<dt class="heading">Author:</dt>
<dd>{+item.author+}</dd>
</if>
<if test="item.version">
<dt class="heading">Version:</dt>
<dd>{+item.version+}</dd>
</if>
{! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !}
<if test="locations.length">
<dt class="heading">Location:</dt>
<for each="location" in="locations">
<dd><a href="{+location+}">{+location+}</a></dd>
</for>
</if>
</dl>
</div>
<hr />
</for>
</section>
<footer>
<small>
<if test="JSDOC.opt.D.copyright">&copy;{+JSDOC.opt.D.copyright+}<br /></if>
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> {+JSDOC.VERSION+} on {+new Date()+}
<br/><br/>
Theme based on Github Pages template by <a href="https://github.com/orderedlist">orderedlist</a>
</small>
</footer>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset={+IO.encoding+}" />
<title>glMatrix - Index</title>
<meta name="generator" content="JsDoc Toolkit" />
<style type="text/css">
{+include("static/default.css")+}
</style>
</head>
<body>
{+include("static/header.html")+}
<div class="wrapper">
<header id="index">
{+publish.classesIndex+}
</header>
<section id="content">
<h1 class="classTitle">Class Index</h1>
<for each="thisClass" in="data">
<if test="thisClass.alias != '_global_'">
<div>
<h2>{+(new Link().toSymbol(thisClass.alias))+}</h2>
{+resolveLinks(summarize(thisClass.classDesc))+}
</div>
<hr />
</if>
</for>
</section>
<footer>
<small>
<if test="JSDOC.opt.D.copyright">&copy;{+JSDOC.opt.D.copyright+}<br /></if>
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> {+JSDOC.VERSION+} on {+new Date()+}
<br/><br/>
Theme based on Github Pages template by <a href="https://github.com/orderedlist">orderedlist</a>
</small>
</footer>
</div>
</body>
</html>
\ No newline at end of file
/** Called automatically by JsDoc Toolkit. */
function publish(symbolSet) {
publish.conf = { // trailing slash expected for dirs
ext: ".html",
outDir: JSDOC.opt.d || SYS.pwd+"../out/jsdoc/",
templatesDir: JSDOC.opt.t || SYS.pwd+"../jsdoc-template/",
symbolsDir: "symbols/",
srcDir: "symbols/src/"
};
// is source output is suppressed, just display the links to the source file
if (JSDOC.opt.s && defined(Link) && Link.prototype._makeSrcLink) {
Link.prototype._makeSrcLink = function(srcFilePath) {
return "&lt;"+srcFilePath+"&gt;";
}
}
// create the folders and subfolders to hold the output
IO.mkPath((publish.conf.outDir+"symbols/src").split("/"));
// used to allow Link to check the details of things being linked to
Link.symbolSet = symbolSet;
// create the required templates
try {
var classTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"class.tmpl");
var classesTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allclasses.tmpl");
}
catch(e) {
print("Couldn't create the required templates: "+e);
quit();
}
// some ustility filters
function hasNoParent($) {return ($.memberOf == "")}
function isaFile($) {return ($.is("FILE"))}
function isaClass($) {return ($.is("CONSTRUCTOR") || $.isNamespace)}
// get an array version of the symbolset, useful for filtering
var symbols = symbolSet.toArray();
// create the hilited source code files
var files = JSDOC.opt.srcFiles;
for (var i = 0, l = files.length; i < l; i++) {
var file = files[i];
var srcDir = publish.conf.outDir + "symbols/src/";
makeSrcFile(file, srcDir);
}
// get a list of all the classes in the symbolset
var classes = symbols.filter(isaClass).sort(makeSortby("alias"));
// create a filemap in which outfiles must be to be named uniquely, ignoring case
if (JSDOC.opt.u) {
var filemapCounts = {};
Link.filemap = {};
for (var i = 0, l = classes.length; i < l; i++) {
var lcAlias = classes[i].alias.toLowerCase();
if (!filemapCounts[lcAlias]) filemapCounts[lcAlias] = 1;
else filemapCounts[lcAlias]++;
Link.filemap[classes[i].alias] =
(filemapCounts[lcAlias] > 1)?
lcAlias+"_"+filemapCounts[lcAlias] : lcAlias;
}
}
// create a class index, displayed in the left-hand column of every class page
Link.base = "../";
publish.classesIndex = classesTemplate.process(classes); // kept in memory
// create each of the class pages
for (var i = 0, l = classes.length; i < l; i++) {
var symbol = classes[i];
symbol.events = symbol.getEvents(); // 1 order matters
symbol.methods = symbol.getMethods(); // 2
Link.currentSymbol= symbol;
var output = "";
output = classTemplate.process(symbol);
IO.saveFile(publish.conf.outDir+"symbols/", ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias) + publish.conf.ext, output);
}
// regenerate the index with different relative links, used in the index pages
Link.base = "";
publish.classesIndex = classesTemplate.process(classes);
// create the class index page
try {
var classesindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"index.tmpl");
}
catch(e) { print(e.message); quit(); }
var classesIndex = classesindexTemplate.process(classes);
IO.saveFile(publish.conf.outDir, "index"+publish.conf.ext, classesIndex);
classesindexTemplate = classesIndex = classes = null;
// create the file index page
try {
var fileindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allfiles.tmpl");
}
catch(e) { print(e.message); quit(); }
var documentedFiles = symbols.filter(isaFile); // files that have file-level docs
var allFiles = []; // not all files have file-level docs, but we need to list every one
for (var i = 0; i < files.length; i++) {
allFiles.push(new JSDOC.Symbol(files[i], [], "FILE", new JSDOC.DocComment("/** */")));
}
for (var i = 0; i < documentedFiles.length; i++) {
var offset = files.indexOf(documentedFiles[i].alias);
allFiles[offset] = documentedFiles[i];
}
allFiles = allFiles.sort(makeSortby("name"));
// output the file index page
var filesIndex = fileindexTemplate.process(allFiles);
IO.saveFile(publish.conf.outDir, "files"+publish.conf.ext, filesIndex);
fileindexTemplate = filesIndex = files = null;
}
/** Just the first sentence (up to a full stop). Should not break on dotted variable names. */
function summarize(desc) {
if (typeof desc != "undefined")
return desc.match(/([\w\W]+?\.)[^a-z0-9_$]/i)? RegExp.$1 : desc;
}
/** Make a symbol sorter by some attribute. */
function makeSortby(attribute) {
return function(a, b) {
if (a[attribute] != undefined && b[attribute] != undefined) {
a = a[attribute].toLowerCase();
b = b[attribute].toLowerCase();
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
}
}
/** Pull in the contents of an external file at the given path. */
function include(path) {
var path = publish.conf.templatesDir+path;
return IO.readFile(path);
}
/** Turn a raw source file into a code-hilited page in the docs. */
function makeSrcFile(path, srcDir, name) {
if (JSDOC.opt.s) return;
if (!name) {
name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_");
name = name.replace(/\:/g, "_");
}
var src = {path: path, name:name, charset: IO.encoding, hilited: ""};
if (defined(JSDOC.PluginManager)) {
JSDOC.PluginManager.run("onPublishSrc", src);
}
if (src.hilited) {
IO.saveFile(srcDir, name+publish.conf.ext, src.hilited);
}
}
/** Build output for displaying function parameters. */
function makeSignature(params) {
if (!params) return "()";
var signature = "("
+
params.filter(
function($) {
return $.name.indexOf(".") == -1; // don't show config params in signature
}
).map(
function($) {
return $.name;
}
).join(", ")
+
")";
return signature;
}
/** Find symbol {@link ...} strings in text and turn into html links */
function resolveLinks(str, from) {
str = str.replace(/\{@link ([^} ]+) ?\}/gi,
function(match, symbolName) {
return new Link().toSymbol(symbolName);
}
);
return str;
}
/* default.css */
/*
body
{
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
width: 800px;
}
.header
{
clear: both;
background-color: #ccc;
padding: 8px;
}
h1
{
font-size: 150%;
font-weight: bold;
padding: 0;
margin: 1em 0 0 .3em;
}
hr
{
border: none 0;
border-top: 1px solid #7F8FB1;
height: 1px;
}
pre.code
{
display: block;
padding: 8px;
border: 1px dashed #ccc;
}
#index
{
margin-top: 24px;
float: left;
width: 160px;
position: absolute;
left: 8px;
background-color: #F3F3F3;
padding: 8px;
}
#content
{
margin-left: 190px;
width: 600px;
}
.classList
{
list-style-type: none;
padding: 0;
margin: 0 0 0 8px;
font-family: arial, sans-serif;
font-size: 1em;
overflow: auto;
}
.classList li
{
padding: 0;
margin: 0 0 8px 0;
}
.summaryTable { width: 100%; }
h1.classTitle
{
font-size:170%;
line-height:130%;
}
h2 { font-size: 110%; }
caption, div.sectionTitle
{
background-color: #7F8FB1;
color: #fff;
font-size:130%;
text-align: left;
padding: 2px 6px 2px 6px;
border: 1px #7F8FB1 solid;
}
div.sectionTitle { margin-bottom: 8px; }
.summaryTable thead { display: none; }
.summaryTable td
{
vertical-align: top;
padding: 4px;
border-bottom: 1px #7F8FB1 solid;
border-right: 1px #7F8FB1 solid;
border-left: 1px #7F8FB1 solid;
}
.summaryTable td.attributes
{
border-left: 1px #7F8FB1 solid;
width: 140px;
text-align: right;
}
td.attributes, .fixedFont
{
line-height: 15px;
color: #002EBE;
font-family: "Courier New",Courier,monospace;
font-size: 13px;
}
.summaryTable td.nameDescription
{
text-align: left;
font-size: 13px;
line-height: 15px;
}
.summaryTable td.nameDescription, .description
{
line-height: 15px;
padding: 4px;
padding-left: 4px;
}
.summaryTable { margin-bottom: 8px; }
ul.inheritsList
{
list-style: square;
margin-left: 20px;
padding-left: 0;
}
.detailList {
margin-left: 20px;
line-height: 15px;
}
.detailList dt { margin-left: 20px; }
.detailList .heading
{
font-weight: bold;
padding-bottom: 6px;
margin-left: 0;
}
.light, td.attributes, .light a:link, .light a:visited
{
color: #777;
font-style: italic;
}
.fineprint
{
text-align: right;
font-size: 10px;
}
*/
/* Copied from styles.css generated by Github Pages */
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
body {
padding:50px;
font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
color:#777;
font-weight:300;
}
h1, h2, h3, h4, h5, h6 {
color:#222;
margin:0 0 20px;
}
p, ul, ol, table, pre, dl {
margin:0 0 20px;
}
h1, h2, h3 {
line-height:1.1;
}
h1 {
font-size:28px;
}
h2 {
color:#393939;
}
h3, h4, h5, h6 {
color:#494949;
}
a {
color:#39c;
font-weight:400;
text-decoration:none;
}
a small {
font-size:11px;
color:#777;
margin-top:-0.6em;
display:block;
}
.wrapper {
width:860px;
margin:0 auto;
}
blockquote {
border-left:1px solid #e5e5e5;
margin:0;
padding:0 0 0 20px;
font-style:italic;
}
code, pre {
font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
color:#333;
font-size:12px;
}
pre {
padding:8px 15px;
background: #f8f8f8;
border-radius:5px;
border:1px solid #e5e5e5;
overflow-x: auto;
}
table {
width:100%;
border-collapse:collapse;
}
th, td {
text-align:left;
padding:5px 10px;
border-bottom:1px solid #e5e5e5;
}
dt {
color:#444;
font-weight:700;
}
th {
color:#444;
}
img {
max-width:100%;
}
header {
width:270px;
float:left;
position:fixed;
}
header ul {
list-style:none;
padding:0;
/*background: #eee;
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
border-radius:5px;
border:1px solid #d2d2d2;
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;*/
width:270px;
}
header li {
width:89px;
/*float:left;
border-right:1px solid #d2d2d2;
height:40px;*/
}
header ul a {
line-height:1;
font-size:11px;
color:#999;
display:block;
text-align:center;
padding-top:6px;
/*height:40px;*/
}
strong {
color:#222;
font-weight:700;
}
/*header ul li + li {
width:88px;
border-left:1px solid #fff;
}
header ul li + li + li {
border-right:none;
width:89px;
}*/
header ul a strong {
font-size:14px;
display:block;
color:#222;
}
section {
width:500px;
float:right;
padding-bottom:50px;
}
small {
font-size:11px;
}
hr {
border:0;
background:#e5e5e5;
height:1px;
margin:0 0 20px;
}
footer {
width:270px;
float:left;
position:fixed;
bottom:50px;
}
@media print, screen and (max-width: 960px) {
div.wrapper {
width:auto;
margin:0;
}
header, section, footer {
float:none;
position:static;
width:auto;
}
header {
/*padding-right:320px;*/
padding: 0;
}
section {
border:1px solid #e5e5e5;
border-width:1px 0;
padding:20px 0;
margin:0 0 20px;
}
header a small {
display:inline;
}
header ul {
position:static;
height:40px;
width: auto;
}
header ul li {
float: left;
}
}
@media print, screen and (max-width: 720px) {
body {
word-wrap:break-word;
}
header {
padding:0;
}
header ul, header p.view {
position:static;
}
pre, code {
word-wrap:normal;
}
}
@media print, screen and (max-width: 480px) {
body {
padding:15px;
}
/*header ul {
display:none;
}*/
}
@media print {
body {
padding:0.4in;
font-size:12pt;
color:#444;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>glMatrix Documentation</title>
</head>
<frameset cols="20%,80%">
<frame src="allclasses-frame.html" name="packageFrame" />
<frame src="splash.html" name="classFrame" />
<noframes>
<body>
<p>
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
</p>
</body>
</noframes>
</frameset>
</html>
\ No newline at end of file
<symbol alias="{+data.alias+}">
<name>{+data.name+}</name>
<memberOf>{+data.memberOf+}</memberOf>
<isStatic>{+data.isStatic+}</isStatic>
<isa>{+data.isa+}</isa>
<desc>{+data.desc+}</desc>
<classDesc>{+data.classDesc+}</classDesc>
<methods><for each="method" in="data.methods">
<method>
<name>{+method.name+}</name>
<memberOf>{+method.memberOf+}</memberOf>
<isStatic>{+method.isStatic+}</isStatic>
<desc>{+method.desc+}</desc>
<params><for each="param" in="method.params">
<param>
<type>{+param.type+}</type>
<name>{+param.name+}</name>
<desc>{+param.desc+}</desc>
<defaultValue>{+param.defaultValue+}</defaultValue>
</param></for>
</params>
</method></for>
</methods>
<properties><for each="property" in="data.properties">
<property>
<name>{+property.name+}</name>
<memberOf>{+property.memberOf+}</memberOf>
<isStatic>{+property.isStatic+}</isStatic>
<desc>{+property.desc+}</desc>
<type>{+property.type+}</type>
</property></for>
</properties>
</symbol>
{
"name": "gl-matrix",
"description": "Javascript Matrix and Vector library for High Performance WebGL apps",
"version": "2.1.0",
"main": "dist/gl-matrix.js",
"homepage": "http://glmatrix.net",
"bugs": {
"url": "https://github.com/toji/gl-matrix/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/toji/gl-matrix.git"
},
"contributors": [
{
"name": "Brandon Jones",
"email": "tojiro@gmail.com"
},
{
"name": "Colin MacKenzie IV",
"email": "sinisterchipmunk@gmail.com"
}
],
"license": "BSD"
}
/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
describe("mat2", function() {
var out, matA, matB, identity, result;
beforeEach(function() {
matA = [1, 2,
3, 4];
matB = [5, 6,
7, 8];
out = [0, 0,
0, 0];
identity = [1, 0,
0, 1];
});
describe("create", function() {
beforeEach(function() { result = mat2.create(); });
it("should return a 4 element array initialized to a 2x2 identity matrix", function() { expect(result).toBeEqualish(identity); });
});
describe("clone", function() {
beforeEach(function() { result = mat2.clone(matA); });
it("should return a 4 element array initialized to the values in matA", function() { expect(result).toBeEqualish(matA); });
});
describe("copy", function() {
beforeEach(function() { result = mat2.copy(out, matA); });
it("should place values into out", function() { expect(out).toBeEqualish(matA); });
it("should return out", function() { expect(result).toBe(out); });
});
describe("identity", function() {
beforeEach(function() { result = mat2.identity(out); });
it("should place values into out", function() { expect(result).toBeEqualish(identity); });
it("should return out", function() { expect(result).toBe(out); });
});
describe("transpose", function() {
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2.transpose(out, matA); });
it("should place values into out", function() { expect(out).toBeEqualish([1, 3, 2, 4]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2.transpose(matA, matA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([1, 3, 2, 4]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("invert", function() {
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2.invert(out, matA); });
it("should place values into out", function() { expect(out).toBeEqualish([-2, 1, 1.5, -0.5]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2.invert(matA, matA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([-2, 1, 1.5, -0.5]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("adjoint", function() {
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2.adjoint(out, matA); });
it("should place values into out", function() { expect(out).toBeEqualish([4, -2, -3, 1]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2.adjoint(matA, matA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([4, -2, -3, 1]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("determinant", function() {
beforeEach(function() { result = mat2.determinant(matA); });
it("should return the determinant", function() { expect(result).toEqual(-2); });
});
describe("multiply", function() {
it("should have an alias called 'mul'", function() { expect(mat2.mul).toEqual(mat2.multiply); });
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2.multiply(out, matA, matB); });
it("should place values into out", function() { expect(out).toBeEqualish([19, 22, 43, 50]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
it("should not modify matB", function() { expect(matB).toBeEqualish([5, 6, 7, 8]); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2.multiply(matA, matA, matB); });
it("should place values into matA", function() { expect(matA).toBeEqualish([19, 22, 43, 50]); });
it("should return matA", function() { expect(result).toBe(matA); });
it("should not modify matB", function() { expect(matB).toBeEqualish([5, 6, 7, 8]); });
});
describe("when matB is the output matrix", function() {
beforeEach(function() { result = mat2.multiply(matB, matA, matB); });
it("should place values into matB", function() { expect(matB).toBeEqualish([19, 22, 43, 50]); });
it("should return matB", function() { expect(result).toBe(matB); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
});
});
describe("rotate", function() {
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2.rotate(out, matA, Math.PI * 0.5); });
it("should place values into out", function() { expect(out).toBeEqualish([2, -1, 4, -3]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2.rotate(matA, matA, Math.PI * 0.5); });
it("should place values into matA", function() { expect(matA).toBeEqualish([2, -1, 4, -3]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("scale", function() {
var vecA;
beforeEach(function() { vecA = [2, 3]; });
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2.scale(out, matA, vecA); });
it("should place values into out", function() { expect(out).toBeEqualish([2, 6, 6, 12]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4]); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2.scale(matA, matA, vecA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([2, 6, 6, 12]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("str", function() {
beforeEach(function() { result = mat2.str(matA); });
it("should return a string representation of the matrix", function() { expect(result).toEqual("mat2(1, 2, 3, 4)"); });
});
});
\ No newline at end of file
/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
describe("mat2d", function() {
var out, matA, matB, identity, result;
beforeEach(function() {
matA = [1, 2,
3, 4,
5, 6];
oldA = [1, 2,
3, 4,
5, 6];
matB = [7, 8,
9, 10,
11, 12];
oldB = [7, 8,
9, 10,
11, 12];
out = [0, 0,
0, 0,
0, 0];
identity = [1, 0,
0, 1,
0, 0];
});
describe("create", function() {
beforeEach(function() { result = mat2d.create(); });
it("should return a 6 element array initialized to a 2x3 identity matrix", function() { expect(result).toBeEqualish(identity); });
});
describe("clone", function() {
beforeEach(function() { result = mat2d.clone(matA); });
it("should return a 6 element array initialized to the values in matA", function() { expect(result).toBeEqualish(matA); });
});
describe("copy", function() {
beforeEach(function() { result = mat2d.copy(out, matA); });
it("should place values into out", function() { expect(out).toBeEqualish(matA); });
it("should return out", function() { expect(result).toBe(out); });
});
describe("identity", function() {
beforeEach(function() { result = mat2d.identity(out); });
it("should place values into out", function() { expect(result).toBeEqualish(identity); });
it("should return out", function() { expect(result).toBe(out); });
});
describe("invert", function() {
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2d.invert(out, matA); });
it("should place values into out", function() { expect(out).toBeEqualish([ -2, 1, 1.5, -0.5, 1, -2 ]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish(oldA); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2d.invert(matA, matA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([ -2, 1, 1.5, -0.5, 1, -2 ]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("determinant", function() {
beforeEach(function() { result = mat2d.determinant(matA); });
it("should return the determinant", function() { expect(result).toEqual(-2); });
});
describe("multiply", function() {
it("should have an alias called 'mul'", function() { expect(mat2d.mul).toEqual(mat2d.multiply); });
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2d.multiply(out, matA, matB); });
it("should place values into out", function() { expect(out).toBeEqualish([25, 28, 57, 64, 100, 112]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish(oldA); });
it("should not modify matB", function() { expect(matB).toBeEqualish(oldB); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2d.multiply(matA, matA, matB); });
it("should place values into matA", function() { expect(matA).toBeEqualish([25, 28, 57, 64, 100, 112]); });
it("should return matA", function() { expect(result).toBe(matA); });
it("should not modify matB", function() { expect(matB).toBeEqualish(oldB); });
});
describe("when matB is the output matrix", function() {
beforeEach(function() { result = mat2d.multiply(matB, matA, matB); });
it("should place values into matB", function() { expect(matB).toBeEqualish([25, 28, 57, 64, 100, 112]); });
it("should return matB", function() { expect(result).toBe(matB); });
it("should not modify matA", function() { expect(matA).toBeEqualish(oldA); });
});
});
describe("rotate", function() {
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2d.rotate(out, matA, Math.PI * 0.5); });
it("should place values into out", function() { expect(out).toBeEqualish([2, -1, 4, -3, 6, -5]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish(oldA); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2d.rotate(matA, matA, Math.PI * 0.5); });
it("should place values into matA", function() { expect(matA).toBeEqualish([2, -1, 4, -3, 6, -5]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("scale", function() {
var vecA;
beforeEach(function() { vecA = [2, 3]; });
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2d.scale(out, matA, vecA); });
it("should place values into out", function() { expect(out).toBeEqualish([2, 6, 6, 12, 10, 18]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish(oldA); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2d.scale(matA, matA, vecA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([2, 6, 6, 12, 10, 18]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("translate", function() {
var vecA;
beforeEach(function() { vecA = [2, 3]; });
describe("with a separate output matrix", function() {
beforeEach(function() { result = mat2d.translate(out, matA, vecA); });
it("should place values into out", function() { expect(out).toBeEqualish([1, 2, 3, 4, 7, 9]); });
it("should return out", function() { expect(result).toBe(out); });
it("should not modify matA", function() { expect(matA).toBeEqualish(oldA); });
});
describe("when matA is the output matrix", function() {
beforeEach(function() { result = mat2d.translate(matA, matA, vecA); });
it("should place values into matA", function() { expect(matA).toBeEqualish([1, 2, 3, 4, 7, 9]); });
it("should return matA", function() { expect(result).toBe(matA); });
});
});
describe("str", function() {
beforeEach(function() { result = mat2d.str(matA); });
it("should return a string representation of the matrix", function() { expect(result).toEqual("mat2d(1, 2, 3, 4, 5, 6)"); });
});
});
\ No newline at end of file
if (typeof(exports) !== 'undefined') {
var glm = require("../../dist/gl-matrix");
for (var ns in glm) {
global[ns] = glm[ns];
}
}
var HELPER_MATCHERS = (function() {
var EPSILON = 0.00001;
return {
/*
Returns true if `actual` has the same length as `expected`, and
if each element of both arrays is within 0.000001 of each other.
This is a way to check for "equal enough" conditions, as a way
of working around floating point imprecision.
*/
toBeEqualish: function(expected) {
if (typeof(this.actual) == 'number')
return Math.abs(this.actual - expected) < EPSILON;
if (this.actual.length != expected.length) return false;
for (var i = 0; i < this.actual.length; i++) {
if (isNaN(this.actual[i]) !== isNaN(expected[i]))
return false;
if (Math.abs(this.actual[i] - expected[i]) >= EPSILON)
return false;
}
return true;
}
};
})();
beforeEach(function() {
this.addMatchers(HELPER_MATCHERS);
});
if (typeof(global) != 'undefined')
global.HELPER_MATCHERS = HELPER_MATCHERS;
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
# - dist/**/*.js
#
src_files:
- dist/gl-matrix.js
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
# - css/style.css
# - stylesheets/*.css
#
stylesheets:
# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
#
spec_files:
# src_dir
#
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:
# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir: spec
//= require 'gl-matrix/common.js'
//= require 'gl-matrix/vec2.js'
//= require 'gl-matrix/vec3.js'
//= require 'gl-matrix/vec4.js'
//= require 'gl-matrix/mat2.js'
//= require 'gl-matrix/mat2d.js'
//= require 'gl-matrix/mat3.js'
//= require 'gl-matrix/mat4.js'
//= require 'gl-matrix/quat.js'
/**
* @fileoverview gl-matrix - High performance matrix and vector operations
* @author Brandon Jones
* @author Colin MacKenzie IV
* @version 2.1.0
*/
/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
(function() {
"use strict";
var shim = {};
if (typeof(exports) === 'undefined') {
if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
shim.exports = {};
define(function() {
return shim.exports;
});
} else {
// gl-matrix lives in a browser, define its namespaces in global
shim.exports = window;
}
}
else {
// gl-matrix lives in commonjs, define its namespaces in exports
shim.exports = exports;
}
(function(exports) {
<%= GLMatrix.sprockets['gl-matrix-manifest.js'] %>
})(shim.exports);
})();
/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
if(!GLMAT_EPSILON) {
var GLMAT_EPSILON = 0.000001;
}
if(!GLMAT_ARRAY_TYPE) {
var GLMAT_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
}
/**
* @class Common utilities
* @name glMatrix
*/
var glMatrix = {};
/**
* Sets the type of array used when creating new vectors and matricies
*
* @param {Type} type Array type, such as Float32Array or Array
*/
glMatrix.setMatrixArrayType = function(type) {
GLMAT_ARRAY_TYPE = type;
}
if(typeof(exports) !== 'undefined') {
exports.glMatrix = glMatrix;
}
\ No newline at end of file
/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/**
* @class 2x2 Matrix
* @name mat2
*/
var mat2 = {};
/**
* Creates a new identity mat2
*
* @returns {mat2} a new 2x2 matrix
*/
mat2.create = function() {
var out = new GLMAT_ARRAY_TYPE(4);
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 1;
return out;
};
/**
* Creates a new mat2 initialized with values from an existing matrix
*
* @param {mat2} a matrix to clone
* @returns {mat2} a new 2x2 matrix
*/
mat2.clone = function(a) {
var out = new GLMAT_ARRAY_TYPE(4);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
return out;
};
/**
* Copy the values from one mat2 to another
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
mat2.copy = function(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
return out;
};
/**
* Set a mat2 to the identity matrix
*
* @param {mat2} out the receiving matrix
* @returns {mat2} out
*/
mat2.identity = function(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 1;
return out;
};
/**
* Transpose the values of a mat2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
mat2.transpose = function(out, a) {
// If we are transposing ourselves we can skip a few steps but have to cache some values
if (out === a) {
var a1 = a[1];
out[1] = a[2];
out[2] = a1;
} else {
out[0] = a[0];
out[1] = a[2];
out[2] = a[1];
out[3] = a[3];
}
return out;
};
/**
* Inverts a mat2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
mat2.invert = function(out, a) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
// Calculate the determinant
det = a0 * a3 - a2 * a1;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = a3 * det;
out[1] = -a1 * det;
out[2] = -a2 * det;
out[3] = a0 * det;
return out;
};
/**
* Calculates the adjugate of a mat2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
mat2.adjoint = function(out, a) {
// Caching this value is nessecary if out == a
var a0 = a[0];
out[0] = a[3];
out[1] = -a[1];
out[2] = -a[2];
out[3] = a0;
return out;
};
/**
* Calculates the determinant of a mat2
*
* @param {mat2} a the source matrix
* @returns {Number} determinant of a
*/
mat2.determinant = function (a) {
return a[0] * a[3] - a[2] * a[1];
};
/**
* Multiplies two mat2's
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the first operand
* @param {mat2} b the second operand
* @returns {mat2} out
*/
mat2.multiply = function (out, a, b) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
out[0] = a0 * b0 + a1 * b2;
out[1] = a0 * b1 + a1 * b3;
out[2] = a2 * b0 + a3 * b2;
out[3] = a2 * b1 + a3 * b3;
return out;
};
/**
* Alias for {@link mat2.multiply}
* @function
*/
mat2.mul = mat2.multiply;
/**
* Rotates a mat2 by the given angle
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2} out
*/
mat2.rotate = function (out, a, rad) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
s = Math.sin(rad),
c = Math.cos(rad);
out[0] = a0 * c + a1 * s;
out[1] = a0 * -s + a1 * c;
out[2] = a2 * c + a3 * s;
out[3] = a2 * -s + a3 * c;
return out;
};
/**
* Scales the mat2 by the dimensions in the given vec2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the matrix to rotate
* @param {vec2} v the vec2 to scale the matrix by
* @returns {mat2} out
**/
mat2.scale = function(out, a, v) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
v0 = v[0], v1 = v[1];
out[0] = a0 * v0;
out[1] = a1 * v1;
out[2] = a2 * v0;
out[3] = a3 * v1;
return out;
};
/**
* Returns a string representation of a mat2
*
* @param {mat2} mat matrix to represent as a string
* @returns {String} string representation of the matrix
*/
mat2.str = function (a) {
return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
};
if(typeof(exports) !== 'undefined') {
exports.mat2 = mat2;
}
desc "compile & minify sources into a single file"
task :build => ['build:compile', 'build:minify']
namespace :build do
task :compile do
compile
end
end
namespace :build do
task :minify do
minify
end
end
desc "tag and release gl-matrix v#{GLMatrix::VERSION}"
task :release do
require 'thor'
Bundler.ui = Bundler::UI::Shell.new(Thor::Shell::Basic.new)
Bundler.ui.debug! if ENV['DEBUG']
# Sanity check: rebuild files just in case dev forgot to.
# If so, files will change and release will abort since changes
# were not checked in.
Rake::Task['build'].invoke
release do
# Put other release-related stuff here, such as publishing docs;
# if anything fails, gl-matrix will be untagged and not pushed.
#
# Example:
#
# Rake::Task['doc:publish'].invoke
#
end
end
$:.unshift File.expand_path('.', File.dirname(__FILE__))
require 'sprockets'
require 'jasmine'
class Jasmine::Config
def simple_config_file
File.expand_path GLMatrix.base_path.join('spec/jasmine.yml')
end
end
class Rack::Jasmine::Runner
alias_method :jasmine_call, :call
def call(env)
GLMatrix.compile
jasmine_call env
end
end
module GLMatrix
autoload :ReleaseHelper, 'gl-matrix/release_helper'
autoload :Version, 'gl-matrix/version'
autoload :VERSION, 'gl-matrix/version'
module_function
def release(&block)
GLMatrix::ReleaseHelper.release &block
end
def sprockets
env = Sprockets::Environment.new base_path
env.append_path base_path.join('src')
env
end
def base_path
Pathname.new File.expand_path('../..', File.dirname(__FILE__))
end
# Compiles the source file to the dest file. If a block
# is given, the source file is yielded and replaced with
# the result. Returns the destination as a Pathname.
def compile(source = 'gl-matrix.js', dest = 'dist/gl-matrix.js')
dest = base_path.join dest
js = sprockets[source]
js = yield js if block_given?
File.open dest, "w" do |f|
f.puts js
end
puts "compiled #{source} to #{dest.relative_path_from base_path}"
dest
end
def minify(source = 'gl-matrix.js', dest = 'dist/gl-matrix-min.js')
dest = compile source, dest do |js|
Uglifier.compile js
end
puts "minified #{source} to #{dest.relative_path_from base_path}"
end
end
# Pretty much everything here was ripped from Bundler.
# https://github.com/carlhuda/bundler/blob/master/lib/bundler/gem_helper.rb
module GLMatrix::ReleaseHelper
module_function
def release
guard_clean
guard_already_tagged
tag_version {
yield if block_given?
git_push
}
end
def base
GLMatrix.base_path.to_s
end
def git_push
perform_git_push
perform_git_push ' --tags'
Bundler.ui.confirm "Pushed git commits and tags"
end
def perform_git_push(options = '')
cmd = "git push #{options}"
out, code = sh_with_code(cmd)
raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0
end
def guard_already_tagged
if sh('git tag').split(/\n/).include?(version_tag)
raise("This tag has already been committed to the repo.")
end
end
def guard_clean
clean? or raise("There are files that need to be committed first.")
end
def clean?
sh_with_code("git diff --exit-code")[1] == 0
end
def tag_version
sh "git tag -a -m \"Version #{version}\" #{version_tag}"
Bundler.ui.confirm "Tagged #{version_tag}"
yield if block_given?
rescue
Bundler.ui.error "Untagged #{version_tag} due to error"
sh_with_code "git tag -d #{version_tag}"
raise
end
def version
GLMatrix::VERSION
end
def version_tag
"v#{version}"
end
def name
"gl-matrix"
end
def sh(cmd, &block)
out, code = sh_with_code(cmd, &block)
code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
end
def sh_with_code(cmd, &block)
cmd << " 2>&1"
outbuf = ''
Bundler.ui.debug(cmd)
Dir.chdir(base) {
outbuf = `#{cmd}`
if $? == 0
block.call(outbuf) if block
end
}
[outbuf, $?]
end
end
module GLMatrix
module Version
MAJOR, MINOR, PATCH, REL = *File.read(base_path.join 'VERSION').split(".")
STRING = [MAJOR, MINOR, PATCH, REL].compact.join '.'
end
VERSION = Version::STRING
end
namespace :test do
desc "Run continuous integration tests"
RSpec::Core::RakeTask.new('ci' => :build) do |t|
t.rspec_opts = ["--colour", "--format", ENV['JASMINE_SPEC_FORMAT'] || "progress"]
t.verbose = true
t.rspec_opts += ["-r #{base_path.join('tasks/support/gl-matrix')}"]
t.pattern = [Jasmine.runner_filepath]
end
end
namespace :test do
desc "Run specs via server"
task :jasmine do
port = ENV['JASMINE_PORT'] || 8888
puts "your tests are here:"
puts " http://localhost:#{port}/"
Jasmine::Server.new(port).start
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment