merge conflicts resolved
commit
875873d85a
|
@ -0,0 +1,2 @@
|
||||||
|
build/
|
||||||
|
node_modules/
|
File diff suppressed because one or more lines are too long
|
@ -1,213 +0,0 @@
|
||||||
body, html {
|
|
||||||
margin:0; padding: 0;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
font-family: Helvetica Neue, Helvetica, Arial;
|
|
||||||
font-size: 14px;
|
|
||||||
color:#333;
|
|
||||||
}
|
|
||||||
.small { font-size: 12px; }
|
|
||||||
*, *:after, *:before {
|
|
||||||
-webkit-box-sizing:border-box;
|
|
||||||
-moz-box-sizing:border-box;
|
|
||||||
box-sizing:border-box;
|
|
||||||
}
|
|
||||||
h1 { font-size: 20px; margin: 0;}
|
|
||||||
h2 { font-size: 14px; }
|
|
||||||
pre {
|
|
||||||
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
-moz-tab-size: 2;
|
|
||||||
-o-tab-size: 2;
|
|
||||||
tab-size: 2;
|
|
||||||
}
|
|
||||||
a { color:#0074D9; text-decoration:none; }
|
|
||||||
a:hover { text-decoration:underline; }
|
|
||||||
.strong { font-weight: bold; }
|
|
||||||
.space-top1 { padding: 10px 0 0 0; }
|
|
||||||
.pad2y { padding: 20px 0; }
|
|
||||||
.pad1y { padding: 10px 0; }
|
|
||||||
.pad2x { padding: 0 20px; }
|
|
||||||
.pad2 { padding: 20px; }
|
|
||||||
.pad1 { padding: 10px; }
|
|
||||||
.space-left2 { padding-left:55px; }
|
|
||||||
.space-right2 { padding-right:20px; }
|
|
||||||
.center { text-align:center; }
|
|
||||||
.clearfix { display:block; }
|
|
||||||
.clearfix:after {
|
|
||||||
content:'';
|
|
||||||
display:block;
|
|
||||||
height:0;
|
|
||||||
clear:both;
|
|
||||||
visibility:hidden;
|
|
||||||
}
|
|
||||||
.fl { float: left; }
|
|
||||||
@media only screen and (max-width:640px) {
|
|
||||||
.col3 { width:100%; max-width:100%; }
|
|
||||||
.hide-mobile { display:none!important; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.quiet {
|
|
||||||
color: #7f7f7f;
|
|
||||||
color: rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
.quiet a { opacity: 0.7; }
|
|
||||||
|
|
||||||
.fraction {
|
|
||||||
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
||||||
font-size: 10px;
|
|
||||||
color: #555;
|
|
||||||
background: #E8E8E8;
|
|
||||||
padding: 4px 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.path a:link, div.path a:visited { color: #333; }
|
|
||||||
table.coverage {
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin: 10px 0 0 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.coverage td {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
table.coverage td.line-count {
|
|
||||||
text-align: right;
|
|
||||||
padding: 0 5px 0 20px;
|
|
||||||
}
|
|
||||||
table.coverage td.line-coverage {
|
|
||||||
text-align: right;
|
|
||||||
padding-right: 10px;
|
|
||||||
min-width:20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.coverage td span.cline-any {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 0 5px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.missing-if-branch {
|
|
||||||
display: inline-block;
|
|
||||||
margin-right: 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
position: relative;
|
|
||||||
padding: 0 4px;
|
|
||||||
background: #333;
|
|
||||||
color: yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
.skip-if-branch {
|
|
||||||
display: none;
|
|
||||||
margin-right: 10px;
|
|
||||||
position: relative;
|
|
||||||
padding: 0 4px;
|
|
||||||
background: #ccc;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
||||||
color: inherit !important;
|
|
||||||
}
|
|
||||||
.coverage-summary {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
||||||
.keyline-all { border: 1px solid #ddd; }
|
|
||||||
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
||||||
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
||||||
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
||||||
.coverage-summary td:last-child { border-right: none; }
|
|
||||||
.coverage-summary th {
|
|
||||||
text-align: left;
|
|
||||||
font-weight: normal;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.coverage-summary th.file { border-right: none !important; }
|
|
||||||
.coverage-summary th.pct { }
|
|
||||||
.coverage-summary th.pic,
|
|
||||||
.coverage-summary th.abs,
|
|
||||||
.coverage-summary td.pct,
|
|
||||||
.coverage-summary td.abs { text-align: right; }
|
|
||||||
.coverage-summary td.file { white-space: nowrap; }
|
|
||||||
.coverage-summary td.pic { min-width: 120px !important; }
|
|
||||||
.coverage-summary tfoot td { }
|
|
||||||
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
height: 10px;
|
|
||||||
width: 7px;
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 0.5em;
|
|
||||||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
||||||
}
|
|
||||||
.coverage-summary .sorted .sorter {
|
|
||||||
background-position: 0 -20px;
|
|
||||||
}
|
|
||||||
.coverage-summary .sorted-desc .sorter {
|
|
||||||
background-position: 0 -10px;
|
|
||||||
}
|
|
||||||
.status-line { height: 10px; }
|
|
||||||
/* dark red */
|
|
||||||
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
||||||
.low .chart { border:1px solid #C21F39 }
|
|
||||||
/* medium red */
|
|
||||||
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
||||||
/* light red */
|
|
||||||
.low, .cline-no { background:#FCE1E5 }
|
|
||||||
/* light green */
|
|
||||||
.high, .cline-yes { background:rgb(230,245,208) }
|
|
||||||
/* medium green */
|
|
||||||
.cstat-yes { background:rgb(161,215,106) }
|
|
||||||
/* dark green */
|
|
||||||
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
||||||
.high .chart { border:1px solid rgb(77,146,33) }
|
|
||||||
/* dark yellow (gold) */
|
|
||||||
.medium .chart { border:1px solid #f9cd0b; }
|
|
||||||
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
|
||||||
/* light yellow */
|
|
||||||
.medium { background: #fff4c2; }
|
|
||||||
/* light gray */
|
|
||||||
span.cline-neutral { background: #eaeaea; }
|
|
||||||
|
|
||||||
.cbranch-no { background: yellow !important; color: #111; }
|
|
||||||
|
|
||||||
.cstat-skip { background: #ddd; color: #111; }
|
|
||||||
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
||||||
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
||||||
|
|
||||||
|
|
||||||
.cover-fill, .cover-empty {
|
|
||||||
display:inline-block;
|
|
||||||
height: 12px;
|
|
||||||
}
|
|
||||||
.chart {
|
|
||||||
line-height: 0;
|
|
||||||
}
|
|
||||||
.cover-empty {
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
.cover-full {
|
|
||||||
border-right: none !important;
|
|
||||||
}
|
|
||||||
pre.prettyprint {
|
|
||||||
border: none !important;
|
|
||||||
padding: 0 !important;
|
|
||||||
margin: 0 !important;
|
|
||||||
}
|
|
||||||
.com { color: #999 !important; }
|
|
||||||
.ignore-none { color: #999; font-weight: normal; }
|
|
||||||
|
|
||||||
.wrapper {
|
|
||||||
min-height: 100%;
|
|
||||||
height: auto !important;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0 auto -48px;
|
|
||||||
}
|
|
||||||
.footer, .push {
|
|
||||||
height: 48px;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,93 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Code coverage report for build/</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="stylesheet" href="../prettify.css" />
|
|
||||||
<link rel="stylesheet" href="../base.css" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style type='text/css'>
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
background-image: url(../sort-arrow-sprite.png);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='wrapper'>
|
|
||||||
<div class='pad1'>
|
|
||||||
<h1>
|
|
||||||
<a href="../index.html">all files</a> build/
|
|
||||||
</h1>
|
|
||||||
<div class='clearfix'>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">17.41% </span>
|
|
||||||
<span class="quiet">Statements</span>
|
|
||||||
<span class='fraction'>361/2074</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">4.94% </span>
|
|
||||||
<span class="quiet">Branches</span>
|
|
||||||
<span class='fraction'>40/810</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">8.44% </span>
|
|
||||||
<span class="quiet">Functions</span>
|
|
||||||
<span class='fraction'>13/154</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">17.41% </span>
|
|
||||||
<span class="quiet">Lines</span>
|
|
||||||
<span class='fraction'>361/2074</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='status-line low'></div>
|
|
||||||
<div class="pad1">
|
|
||||||
<table class="coverage-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
||||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
||||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
||||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
||||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
||||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
||||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody><tr>
|
|
||||||
<td class="file low" data-value="game-lib.js"><a href="game-lib.js.html">game-lib.js</a></td>
|
|
||||||
<td data-value="17.41" class="pic low"><div class="chart"><div class="cover-fill" style="width: 17%;"></div><div class="cover-empty" style="width:83%;"></div></div></td>
|
|
||||||
<td data-value="17.41" class="pct low">17.41%</td>
|
|
||||||
<td data-value="2074" class="abs low">361/2074</td>
|
|
||||||
<td data-value="4.94" class="pct low">4.94%</td>
|
|
||||||
<td data-value="810" class="abs low">40/810</td>
|
|
||||||
<td data-value="8.44" class="pct low">8.44%</td>
|
|
||||||
<td data-value="154" class="abs low">13/154</td>
|
|
||||||
<td data-value="17.41" class="pct low">17.41%</td>
|
|
||||||
<td data-value="2074" class="abs low">361/2074</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div><div class='push'></div><!-- for sticky footer -->
|
|
||||||
</div><!-- /wrapper -->
|
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
|
||||||
Code coverage
|
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:03:55 GMT+0200 (CEST)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="../prettify.js"></script>
|
|
||||||
<script>
|
|
||||||
window.onload = function () {
|
|
||||||
if (typeof prettyPrint === 'function') {
|
|
||||||
prettyPrint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script src="../sorter.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,93 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Code coverage report for All files</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="stylesheet" href="prettify.css" />
|
|
||||||
<link rel="stylesheet" href="base.css" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style type='text/css'>
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
background-image: url(sort-arrow-sprite.png);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='wrapper'>
|
|
||||||
<div class='pad1'>
|
|
||||||
<h1>
|
|
||||||
/
|
|
||||||
</h1>
|
|
||||||
<div class='clearfix'>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">17.41% </span>
|
|
||||||
<span class="quiet">Statements</span>
|
|
||||||
<span class='fraction'>361/2074</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">4.94% </span>
|
|
||||||
<span class="quiet">Branches</span>
|
|
||||||
<span class='fraction'>40/810</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">8.44% </span>
|
|
||||||
<span class="quiet">Functions</span>
|
|
||||||
<span class='fraction'>13/154</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">17.41% </span>
|
|
||||||
<span class="quiet">Lines</span>
|
|
||||||
<span class='fraction'>361/2074</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='status-line low'></div>
|
|
||||||
<div class="pad1">
|
|
||||||
<table class="coverage-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
||||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
||||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
||||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
||||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
||||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
||||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody><tr>
|
|
||||||
<td class="file low" data-value="build/"><a href="build/index.html">build/</a></td>
|
|
||||||
<td data-value="17.41" class="pic low"><div class="chart"><div class="cover-fill" style="width: 17%;"></div><div class="cover-empty" style="width:83%;"></div></div></td>
|
|
||||||
<td data-value="17.41" class="pct low">17.41%</td>
|
|
||||||
<td data-value="2074" class="abs low">361/2074</td>
|
|
||||||
<td data-value="4.94" class="pct low">4.94%</td>
|
|
||||||
<td data-value="810" class="abs low">40/810</td>
|
|
||||||
<td data-value="8.44" class="pct low">8.44%</td>
|
|
||||||
<td data-value="154" class="abs low">13/154</td>
|
|
||||||
<td data-value="17.41" class="pct low">17.41%</td>
|
|
||||||
<td data-value="2074" class="abs low">361/2074</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div><div class='push'></div><!-- for sticky footer -->
|
|
||||||
</div><!-- /wrapper -->
|
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
|
||||||
Code coverage
|
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:03:55 GMT+0200 (CEST)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="prettify.js"></script>
|
|
||||||
<script>
|
|
||||||
window.onload = function () {
|
|
||||||
if (typeof prettyPrint === 'function') {
|
|
||||||
prettyPrint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script src="sorter.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1 +0,0 @@
|
||||||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 209 B |
|
@ -1,158 +0,0 @@
|
||||||
var addSorting = (function () {
|
|
||||||
"use strict";
|
|
||||||
var cols,
|
|
||||||
currentSort = {
|
|
||||||
index: 0,
|
|
||||||
desc: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// returns the summary table element
|
|
||||||
function getTable() { return document.querySelector('.coverage-summary'); }
|
|
||||||
// returns the thead element of the summary table
|
|
||||||
function getTableHeader() { return getTable().querySelector('thead tr'); }
|
|
||||||
// returns the tbody element of the summary table
|
|
||||||
function getTableBody() { return getTable().querySelector('tbody'); }
|
|
||||||
// returns the th element for nth column
|
|
||||||
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
|
|
||||||
|
|
||||||
// loads all columns
|
|
||||||
function loadColumns() {
|
|
||||||
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
||||||
colNode,
|
|
||||||
cols = [],
|
|
||||||
col,
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 0; i < colNodes.length; i += 1) {
|
|
||||||
colNode = colNodes[i];
|
|
||||||
col = {
|
|
||||||
key: colNode.getAttribute('data-col'),
|
|
||||||
sortable: !colNode.getAttribute('data-nosort'),
|
|
||||||
type: colNode.getAttribute('data-type') || 'string'
|
|
||||||
};
|
|
||||||
cols.push(col);
|
|
||||||
if (col.sortable) {
|
|
||||||
col.defaultDescSort = col.type === 'number';
|
|
||||||
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cols;
|
|
||||||
}
|
|
||||||
// attaches a data attribute to every tr element with an object
|
|
||||||
// of data values keyed by column name
|
|
||||||
function loadRowData(tableRow) {
|
|
||||||
var tableCols = tableRow.querySelectorAll('td'),
|
|
||||||
colNode,
|
|
||||||
col,
|
|
||||||
data = {},
|
|
||||||
i,
|
|
||||||
val;
|
|
||||||
for (i = 0; i < tableCols.length; i += 1) {
|
|
||||||
colNode = tableCols[i];
|
|
||||||
col = cols[i];
|
|
||||||
val = colNode.getAttribute('data-value');
|
|
||||||
if (col.type === 'number') {
|
|
||||||
val = Number(val);
|
|
||||||
}
|
|
||||||
data[col.key] = val;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
// loads all row data
|
|
||||||
function loadData() {
|
|
||||||
var rows = getTableBody().querySelectorAll('tr'),
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 0; i < rows.length; i += 1) {
|
|
||||||
rows[i].data = loadRowData(rows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// sorts the table using the data for the ith column
|
|
||||||
function sortByIndex(index, desc) {
|
|
||||||
var key = cols[index].key,
|
|
||||||
sorter = function (a, b) {
|
|
||||||
a = a.data[key];
|
|
||||||
b = b.data[key];
|
|
||||||
return a < b ? -1 : a > b ? 1 : 0;
|
|
||||||
},
|
|
||||||
finalSorter = sorter,
|
|
||||||
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
||||||
rowNodes = tableBody.querySelectorAll('tr'),
|
|
||||||
rows = [],
|
|
||||||
i;
|
|
||||||
|
|
||||||
if (desc) {
|
|
||||||
finalSorter = function (a, b) {
|
|
||||||
return -1 * sorter(a, b);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < rowNodes.length; i += 1) {
|
|
||||||
rows.push(rowNodes[i]);
|
|
||||||
tableBody.removeChild(rowNodes[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.sort(finalSorter);
|
|
||||||
|
|
||||||
for (i = 0; i < rows.length; i += 1) {
|
|
||||||
tableBody.appendChild(rows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// removes sort indicators for current column being sorted
|
|
||||||
function removeSortIndicators() {
|
|
||||||
var col = getNthColumn(currentSort.index),
|
|
||||||
cls = col.className;
|
|
||||||
|
|
||||||
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
||||||
col.className = cls;
|
|
||||||
}
|
|
||||||
// adds sort indicators for current column being sorted
|
|
||||||
function addSortIndicators() {
|
|
||||||
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
|
|
||||||
}
|
|
||||||
// adds event listeners for all sorter widgets
|
|
||||||
function enableUI() {
|
|
||||||
var i,
|
|
||||||
el,
|
|
||||||
ithSorter = function ithSorter(i) {
|
|
||||||
var col = cols[i];
|
|
||||||
|
|
||||||
return function () {
|
|
||||||
var desc = col.defaultDescSort;
|
|
||||||
|
|
||||||
if (currentSort.index === i) {
|
|
||||||
desc = !currentSort.desc;
|
|
||||||
}
|
|
||||||
sortByIndex(i, desc);
|
|
||||||
removeSortIndicators();
|
|
||||||
currentSort.index = i;
|
|
||||||
currentSort.desc = desc;
|
|
||||||
addSortIndicators();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
for (i =0 ; i < cols.length; i += 1) {
|
|
||||||
if (cols[i].sortable) {
|
|
||||||
// add the click event handler on the th so users
|
|
||||||
// dont have to click on those tiny arrows
|
|
||||||
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
||||||
if (el.addEventListener) {
|
|
||||||
el.addEventListener('click', ithSorter(i));
|
|
||||||
} else {
|
|
||||||
el.attachEvent('onclick', ithSorter(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// adds sorting functionality to the UI
|
|
||||||
return function () {
|
|
||||||
if (!getTable()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cols = loadColumns();
|
|
||||||
loadData(cols);
|
|
||||||
addSortIndicators();
|
|
||||||
enableUI();
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
window.addEventListener('load', addSorting);
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
6047
build/game-lib.js
6047
build/game-lib.js
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,9 @@
|
||||||
|
ApiLib = function() {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiLib.Scene = function(
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
|
};
|
|
@ -407,7 +407,22 @@ GameLib.D3.Material = function(
|
||||||
envMapIntensity = 1.0;
|
envMapIntensity = 1.0;
|
||||||
}
|
}
|
||||||
this.envMapIntensity = envMapIntensity;
|
this.envMapIntensity = envMapIntensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns a copy of the loaded texture map to the instance material
|
||||||
|
* @param instanceMaterial
|
||||||
|
* @param instanceMapId
|
||||||
|
* @returns {Function}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.ImageLoadedCallback = function(
|
||||||
|
instanceMaterial,
|
||||||
|
instanceMapId
|
||||||
|
) {
|
||||||
|
return function(texture) {
|
||||||
|
instanceMaterial[instanceMapId] = texture.clone();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -508,24 +523,194 @@ GameLib.D3.Material.TYPE_MULTI_MATERIAL= "MultiMaterial";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance Material from a GameLib.D3.Material
|
* Creates an instance Material from a GameLib.D3.Material
|
||||||
* @param gameLibMaterial GameLib.D3.Material
|
* @param apiMaterial GameLib.D3.Material
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param uploadUrl String
|
* @param gameLibScene GameLib.D3.Scene
|
||||||
* @param progressCallback
|
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material.createInstanceMaterial = function(
|
GameLib.D3.Material.CreateInstanceMaterial = function(
|
||||||
gameLibMaterial,
|
apiMaterial,
|
||||||
graphics,
|
graphics,
|
||||||
uploadUrl,
|
gameLibScene
|
||||||
progressCallback
|
|
||||||
) {
|
) {
|
||||||
|
var maps = apiMaterial.maps;
|
||||||
|
|
||||||
var defer = Q.defer();
|
var gameLibTextures = [];
|
||||||
|
|
||||||
|
for (var map in maps) {
|
||||||
|
if (maps.hasOwnProperty(map)) {
|
||||||
|
if (maps[map]) {
|
||||||
|
var instanceMapId = null;
|
||||||
|
|
||||||
|
if (map == 'alpha') {
|
||||||
|
instanceMapId = 'alhpaMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'ao') {
|
||||||
|
instanceMapId = 'aoMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'bump') {
|
||||||
|
instanceMapId = 'bumpMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'displacement') {
|
||||||
|
instanceMapId = 'displacementMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'emissive') {
|
||||||
|
instanceMapId = 'emissiveMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'environment') {
|
||||||
|
instanceMapId = 'envMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'light') {
|
||||||
|
instanceMapId = 'lightMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'specular') {
|
||||||
|
instanceMapId = 'specularMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'diffuse') {
|
||||||
|
instanceMapId = 'map';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'roughness') {
|
||||||
|
instanceMapId = 'roughnessMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == 'metalness') {
|
||||||
|
instanceMapId = 'metalnessMap';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instanceMapId == null) {
|
||||||
|
console.warn("unsupported map type : " + map);
|
||||||
|
}
|
||||||
|
|
||||||
|
var apiTexture = maps[map];
|
||||||
|
|
||||||
|
var apiImage = apiTexture.image;
|
||||||
|
|
||||||
|
var gameLibTexture = new GameLib.D3.Texture(
|
||||||
|
apiTexture.id,
|
||||||
|
apiTexture.name,
|
||||||
|
new GameLib.D3.Image(
|
||||||
|
apiImage.id,
|
||||||
|
apiImage.textureLink,
|
||||||
|
apiImage.filename,
|
||||||
|
apiImage.size,
|
||||||
|
apiImage.contentType
|
||||||
|
),
|
||||||
|
apiTexture.wrapS,
|
||||||
|
apiTexture.wrapT,
|
||||||
|
new GameLib.D3.Vector2(
|
||||||
|
apiTexture.repeat.x,
|
||||||
|
apiTexture.repeat.y
|
||||||
|
),
|
||||||
|
apiTexture.data,
|
||||||
|
apiTexture.format,
|
||||||
|
apiTexture.mapping,
|
||||||
|
apiTexture.magFilter,
|
||||||
|
apiTexture.minFilter,
|
||||||
|
apiTexture.textureType,
|
||||||
|
apiTexture.anisotropy,
|
||||||
|
new GameLib.D3.Vector2(
|
||||||
|
apiTexture.offset.x,
|
||||||
|
apiTexture.offset.y
|
||||||
|
),
|
||||||
|
apiTexture.generateMipmaps,
|
||||||
|
apiTexture.flipY,
|
||||||
|
apiTexture.mipmaps,
|
||||||
|
apiTexture.unpackAlignment,
|
||||||
|
apiTexture.premultiplyAlpha,
|
||||||
|
apiTexture.encoding,
|
||||||
|
instanceMapId
|
||||||
|
);
|
||||||
|
|
||||||
|
gameLibTextures.push(gameLibTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var gameLibMaterial = new GameLib.D3.Material(
|
||||||
|
apiMaterial.id,
|
||||||
|
apiMaterial.name,
|
||||||
|
apiMaterial.materialType,
|
||||||
|
apiMaterial.opacity,
|
||||||
|
apiMaterial.side,
|
||||||
|
apiMaterial.transparent,
|
||||||
|
gameLibTextures,
|
||||||
|
new GameLib.D3.Color(
|
||||||
|
apiMaterial.specular.r,
|
||||||
|
apiMaterial.specular.g,
|
||||||
|
apiMaterial.specular.b,
|
||||||
|
apiMaterial.specular.a
|
||||||
|
),
|
||||||
|
apiMaterial.lightMapIntensity,
|
||||||
|
apiMaterial.aoMapIntensity,
|
||||||
|
new GameLib.D3.Color(
|
||||||
|
apiMaterial.color.r,
|
||||||
|
apiMaterial.color.g,
|
||||||
|
apiMaterial.color.b,
|
||||||
|
apiMaterial.color.a
|
||||||
|
),
|
||||||
|
new GameLib.D3.Color(
|
||||||
|
apiMaterial.emissive.r,
|
||||||
|
apiMaterial.emissive.g,
|
||||||
|
apiMaterial.emissive.b,
|
||||||
|
apiMaterial.emissive.a
|
||||||
|
),
|
||||||
|
apiMaterial.emissiveIntensity,
|
||||||
|
apiMaterial.combine,
|
||||||
|
apiMaterial.shininess,
|
||||||
|
apiMaterial.reflectivity,
|
||||||
|
apiMaterial.refractionRatio,
|
||||||
|
apiMaterial.fog,
|
||||||
|
apiMaterial.wireframe,
|
||||||
|
apiMaterial.wireframeLineWidth,
|
||||||
|
apiMaterial.wireframeLineCap,
|
||||||
|
apiMaterial.wireframeLineJoin,
|
||||||
|
apiMaterial.vertexColors,
|
||||||
|
apiMaterial.skinning,
|
||||||
|
apiMaterial.morphTargets,
|
||||||
|
apiMaterial.morphNormals,
|
||||||
|
apiMaterial.lineWidth,
|
||||||
|
apiMaterial.lineCap,
|
||||||
|
apiMaterial.lineJoin,
|
||||||
|
apiMaterial.dashSize,
|
||||||
|
apiMaterial.gapWidth,
|
||||||
|
apiMaterial.blending,
|
||||||
|
apiMaterial.blendSrc,
|
||||||
|
apiMaterial.blendDst,
|
||||||
|
apiMaterial.blendEquation,
|
||||||
|
apiMaterial.depthTest,
|
||||||
|
apiMaterial.depthFunc,
|
||||||
|
apiMaterial.depthWrite,
|
||||||
|
apiMaterial.polygonOffset,
|
||||||
|
apiMaterial.polygonOffsetFactor,
|
||||||
|
apiMaterial.polygonOffsetUnits,
|
||||||
|
apiMaterial.alphaTest,
|
||||||
|
apiMaterial.clippingPlanes,
|
||||||
|
apiMaterial.clipShadows,
|
||||||
|
apiMaterial.visible,
|
||||||
|
apiMaterial.overdraw,
|
||||||
|
apiMaterial.shading,
|
||||||
|
apiMaterial.bumpScale,
|
||||||
|
apiMaterial.normalScale,
|
||||||
|
apiMaterial.displacementScale,
|
||||||
|
apiMaterial.displacementBias,
|
||||||
|
apiMaterial.roughness,
|
||||||
|
apiMaterial.metalness,
|
||||||
|
apiMaterial.pointSize,
|
||||||
|
apiMaterial.pointSizeAttenuation,
|
||||||
|
apiMaterial.spriteRotation,
|
||||||
|
apiMaterial.envMapIntensity
|
||||||
|
);
|
||||||
|
|
||||||
var instanceMaterial = null;
|
var instanceMaterial = null;
|
||||||
|
|
||||||
var blenderMaps = [];
|
|
||||||
|
|
||||||
if (gameLibMaterial.materialType == GameLib.D3.Material.TYPE_MESH_STANDARD) {
|
if (gameLibMaterial.materialType == GameLib.D3.Material.TYPE_MESH_STANDARD) {
|
||||||
|
|
||||||
instanceMaterial = new graphics.instance.MeshStandardMaterial({
|
instanceMaterial = new graphics.instance.MeshStandardMaterial({
|
||||||
|
@ -579,19 +764,6 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
||||||
morphNormals: gameLibMaterial.morphNormals
|
morphNormals: gameLibMaterial.morphNormals
|
||||||
});
|
});
|
||||||
|
|
||||||
blenderMaps.push(
|
|
||||||
'diffuse',
|
|
||||||
'light',
|
|
||||||
'ao',
|
|
||||||
'emissive',
|
|
||||||
'bump',
|
|
||||||
'normal',
|
|
||||||
'displacement',
|
|
||||||
'roughness',
|
|
||||||
'metalness',
|
|
||||||
'alpha',
|
|
||||||
'environment'
|
|
||||||
);
|
|
||||||
} else if (gameLibMaterial.materialType == GameLib.D3.Material.TYPE_MESH_PHONG) {
|
} else if (gameLibMaterial.materialType == GameLib.D3.Material.TYPE_MESH_PHONG) {
|
||||||
|
|
||||||
instanceMaterial = new graphics.instance.MeshPhongMaterial({
|
instanceMaterial = new graphics.instance.MeshPhongMaterial({
|
||||||
|
@ -650,45 +822,24 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
||||||
morphNormals: gameLibMaterial.morphNormals
|
morphNormals: gameLibMaterial.morphNormals
|
||||||
});
|
});
|
||||||
|
|
||||||
blenderMaps.push(
|
|
||||||
'diffuse',
|
|
||||||
'light',
|
|
||||||
'ao',
|
|
||||||
'emissive',
|
|
||||||
'bump',
|
|
||||||
'normal',
|
|
||||||
'displacement',
|
|
||||||
'specular',
|
|
||||||
'alpha',
|
|
||||||
'environment'
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("material type is not implemented yet: " + gameLibMaterial.materialType + " - material indexes could be screwed up");
|
console.log("material type is not implemented yet: " + apiMaterial.materialType + " - material indexes could be screwed up");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blenderMaps.length > 0) {
|
/**
|
||||||
var textureMaps = GameLib.D3.Texture.loadMaps(
|
* Here we need to notify the scene of all the textures which need to be created once image loading for the
|
||||||
gameLibMaterial,
|
* textures are complete. (this download process will be started at a later stage)
|
||||||
blenderMaps,
|
* The Notification objects take care of applying the loaded instance texture(s) to the instance material
|
||||||
instanceMaterial,
|
* once it is loaded
|
||||||
graphics,
|
*/
|
||||||
uploadUrl,
|
for (var t = 0; t < gameLibTextures.length; t++) {
|
||||||
progressCallback
|
gameLibScene.notify(
|
||||||
);
|
new GameLib.D3.Texture.Notification(
|
||||||
Q.all(textureMaps).then(
|
gameLibTextures[t],
|
||||||
function(){
|
instanceMaterial
|
||||||
defer.resolve(instanceMaterial);
|
)
|
||||||
}
|
|
||||||
).catch(
|
|
||||||
function(error){
|
|
||||||
console.log(error);
|
|
||||||
defer.reject(error);
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
defer.resolve(instanceMaterial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return defer.promise;
|
return instanceMaterial;
|
||||||
};
|
};
|
|
@ -124,7 +124,7 @@ GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
||||||
* @param graphics
|
* @param graphics
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.createInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
GameLib.D3.Mesh.CreateInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||||
|
|
||||||
var threeMesh = null;
|
var threeMesh = null;
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,27 @@
|
||||||
/**
|
/**
|
||||||
* Scenes are objects putting meshes into 'world space'
|
* Scenes are objects putting meshes into 'world space'
|
||||||
* @param id
|
* @param id Mongo.ObjectId
|
||||||
* @param path String
|
* @param path String
|
||||||
* @param name String
|
* @param name String
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param meshes GameLib.D3.Mesh[]
|
* @param meshes GameLib.D3.Mesh[]
|
||||||
* @param quaternion
|
* @param quaternion GameLib.D3.Vector4
|
||||||
* @param position
|
* @param position GameLib.D3.Vector3
|
||||||
* @param rotation
|
* @param rotation GameLib.D3.Vector3
|
||||||
* @param scale
|
* @param scale GameLib.D3.Vector3
|
||||||
* @param parentSceneId
|
* @param parentSceneId String
|
||||||
* @param lights
|
* @param lights GameLib.D3.Light[]
|
||||||
* @param worlds
|
* @param worlds GameLib.D3.World[]
|
||||||
* @param entities
|
* @param entities GameLib.D3.Entity[]
|
||||||
|
* @param progressCallback
|
||||||
|
* @param uploadUrl String
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene = function(
|
GameLib.D3.Scene = function(
|
||||||
id,
|
id,
|
||||||
path,
|
path,
|
||||||
name,
|
name,
|
||||||
|
graphics,
|
||||||
meshes,
|
meshes,
|
||||||
quaternion,
|
quaternion,
|
||||||
position,
|
position,
|
||||||
|
@ -26,12 +30,23 @@ GameLib.D3.Scene = function(
|
||||||
parentSceneId,
|
parentSceneId,
|
||||||
lights,
|
lights,
|
||||||
worlds,
|
worlds,
|
||||||
entities
|
entities,
|
||||||
|
progressCallback,
|
||||||
|
uploadUrl
|
||||||
) {
|
) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sceneId = GameLib.D3.Tools.RandomId();
|
this.sceneId = GameLib.D3.Tools.RandomId();
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
if (graphics) {
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
this.textureLoader = new this.graphics.instance.TextureLoader();
|
||||||
|
this.textureLoader.crossOrigin = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (this.name.trim() == "") {
|
if (this.name.trim() == "") {
|
||||||
this.name = 'unnamed';
|
this.name = 'unnamed';
|
||||||
}
|
}
|
||||||
|
@ -91,6 +106,142 @@ GameLib.D3.Scene = function(
|
||||||
|
|
||||||
// assoc array
|
// assoc array
|
||||||
this.componentIdToComponent = {};
|
this.componentIdToComponent = {};
|
||||||
|
|
||||||
|
this.uploadUrl = uploadUrl;
|
||||||
|
|
||||||
|
this.progressCallback = progressCallback;
|
||||||
|
|
||||||
|
this.urls = [];
|
||||||
|
this.notifications = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notification objects manage the links between image filenames, instance texture
|
||||||
|
* map IDs, and instance materials.
|
||||||
|
* @param notification GameLib.D3.Texture.Notificatio
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Scene.prototype.notify = function(
|
||||||
|
notification
|
||||||
|
) {
|
||||||
|
var url = this.uploadUrl + '/' + notification.gameLibTexture.image.filename;
|
||||||
|
|
||||||
|
if (this.urls.indexOf(url) == -1) {
|
||||||
|
this.urls.push(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.notifications.push(notification);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Promises to loads a texture
|
||||||
|
* @param url
|
||||||
|
* @returns {promise.promise|jQuery.promise|*|promise|Promise}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Scene.prototype.loadTexture = function(url) {
|
||||||
|
|
||||||
|
var defer = Q.defer();
|
||||||
|
|
||||||
|
this.textureLoader.load(
|
||||||
|
url,
|
||||||
|
function onLoad(textureInstance){
|
||||||
|
defer.resolve(textureInstance);
|
||||||
|
},
|
||||||
|
function onProgress(xhr){
|
||||||
|
if (this.progressCallback) {
|
||||||
|
this.progressCallback(Math.round(xhr.loaded / xhr.total * 100))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function onError() {
|
||||||
|
defer.resolve(null);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return defer.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a Image Loading Process - when all are done - executes all calbacks registered
|
||||||
|
* on materials listening for an image load to complete
|
||||||
|
* @param urls
|
||||||
|
* @param onLoadedCallback
|
||||||
|
* @returns {jQuery.promise|promise.promise|*|Promise|promise}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Scene.prototype.loadTextures = function(urls, onLoadedCallback) {
|
||||||
|
|
||||||
|
var texturesToLoad = [];
|
||||||
|
|
||||||
|
for (var u = 0; u < urls.length; u++) {
|
||||||
|
texturesToLoad.push(this.loadTexture(urls[u]));
|
||||||
|
}
|
||||||
|
|
||||||
|
Q.all(texturesToLoad).then(
|
||||||
|
|
||||||
|
function onFulfilled(textureInstances) {
|
||||||
|
|
||||||
|
var loadedTexturesInstances = [];
|
||||||
|
|
||||||
|
for (var t = 0; t < textureInstances.length; t++) {
|
||||||
|
|
||||||
|
var instanceTexture = textureInstances[t];
|
||||||
|
|
||||||
|
if (!instanceTexture) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var n = 0; n < this.notifications.length; n++) {
|
||||||
|
|
||||||
|
var notification = this.notifications[n];
|
||||||
|
|
||||||
|
var gameLibTexture = notification.gameLibTexture;
|
||||||
|
|
||||||
|
var instanceMaterial = notification.instanceMaterial;
|
||||||
|
|
||||||
|
var instanceMapId = gameLibTexture.instanceMapId;
|
||||||
|
|
||||||
|
var filename = gameLibTexture.image.filename;
|
||||||
|
|
||||||
|
if (instanceTexture.image.src.match(new RegExp(filename + '$'))) {
|
||||||
|
instanceMaterial[instanceMapId] = new this.graphics.instance.Texture(
|
||||||
|
instanceTexture.image,
|
||||||
|
gameLibTexture.mapping,
|
||||||
|
gameLibTexture.wrapS,
|
||||||
|
gameLibTexture.wrapT,
|
||||||
|
gameLibTexture.magFilter,
|
||||||
|
gameLibTexture.minFilter,
|
||||||
|
gameLibTexture.format,
|
||||||
|
gameLibTexture.textureType,
|
||||||
|
gameLibTexture.anisotropy
|
||||||
|
);
|
||||||
|
|
||||||
|
instanceMaterial[instanceMapId].name = gameLibTexture.name;
|
||||||
|
instanceMaterial[instanceMapId].flipY = gameLibTexture.flipY;
|
||||||
|
instanceMaterial[instanceMapId].encoding = gameLibTexture.encoding;
|
||||||
|
instanceMaterial[instanceMapId].flipY = gameLibTexture.flipY;
|
||||||
|
instanceMaterial[instanceMapId].offset.x = gameLibTexture.offset.x;
|
||||||
|
instanceMaterial[instanceMapId].offset.y = gameLibTexture.offset.y;
|
||||||
|
instanceMaterial[instanceMapId].mipmaps = gameLibTexture.mipmaps;
|
||||||
|
instanceMaterial[instanceMapId].unpackAlignment = gameLibTexture.unpackAlignment;
|
||||||
|
instanceMaterial[instanceMapId].premultiplyAlpha = gameLibTexture.premultiplyAlpha;
|
||||||
|
instanceMaterial[instanceMapId].needsUpdate = true;
|
||||||
|
instanceMaterial.needsUpdate = true;
|
||||||
|
|
||||||
|
loadedTexturesInstances.push(instanceMaterial[instanceMapId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadedCallback(loadedTexturesInstances);
|
||||||
|
|
||||||
|
}.bind(this),
|
||||||
|
function onRejected(message){
|
||||||
|
console.log('Promise failed : ' + message);
|
||||||
|
},
|
||||||
|
function onProgress(){
|
||||||
|
console.log('progress');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +288,7 @@ GameLib.D3.Scene.LoadSceneFromApi = function(
|
||||||
|
|
||||||
var scene = response.scene[0];
|
var scene = response.scene[0];
|
||||||
|
|
||||||
var physics3ds = [];
|
var entities = [];
|
||||||
|
|
||||||
if (scene.worlds && scene.worlds.length > 0) {
|
if (scene.worlds && scene.worlds.length > 0) {
|
||||||
console.warn('Implement physics worlds code here');
|
console.warn('Implement physics worlds code here');
|
||||||
|
@ -146,61 +297,64 @@ GameLib.D3.Scene.LoadSceneFromApi = function(
|
||||||
|
|
||||||
var lights3d = [];
|
var lights3d = [];
|
||||||
|
|
||||||
for (var l = 0; l < scene.lights.length; l++) {
|
if (scene.lights && scene.lights.length > 0) {
|
||||||
|
for (var l = 0; l < scene.lights.length; l++) {
|
||||||
|
|
||||||
var light = scene.lights[l];
|
var light = scene.lights[l];
|
||||||
|
|
||||||
var light3d = new GameLib.D3.Light(
|
var light3d = new GameLib.D3.Light(
|
||||||
light.id,
|
light.id,
|
||||||
light.lightType,
|
light.lightType,
|
||||||
light.name,
|
light.name,
|
||||||
new GameLib.D3.Color(
|
new GameLib.D3.Color(
|
||||||
light.color.r,
|
light.color.r,
|
||||||
light.color.g,
|
light.color.g,
|
||||||
light.color.b,
|
light.color.b,
|
||||||
light.color.a
|
light.color.a
|
||||||
),
|
),
|
||||||
light.intensity,
|
light.intensity,
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.Vector3(
|
||||||
light.position.x,
|
light.position.x,
|
||||||
light.position.y,
|
light.position.y,
|
||||||
light.position.z
|
light.position.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.Vector3(
|
||||||
light.targetPosition.x,
|
light.targetPosition.x,
|
||||||
light.targetPosition.y,
|
light.targetPosition.y,
|
||||||
light.targetPosition.z
|
light.targetPosition.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector4(
|
new GameLib.D3.Vector4(
|
||||||
light.quaternion.x,
|
light.quaternion.x,
|
||||||
light.quaternion.y,
|
light.quaternion.y,
|
||||||
light.quaternion.z,
|
light.quaternion.z,
|
||||||
light.quaternion.w
|
light.quaternion.w
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.Vector3(
|
||||||
light.rotation.x,
|
light.rotation.x,
|
||||||
light.rotation.y,
|
light.rotation.y,
|
||||||
light.rotation.z
|
light.rotation.z
|
||||||
),
|
),
|
||||||
new GameLib.D3.Vector3(
|
new GameLib.D3.Vector3(
|
||||||
light.scale.x,
|
light.scale.x,
|
||||||
light.scale.y,
|
light.scale.y,
|
||||||
light.scale.z
|
light.scale.z
|
||||||
),
|
),
|
||||||
light.distance,
|
light.distance,
|
||||||
light.decay,
|
light.decay,
|
||||||
light.power,
|
light.power,
|
||||||
light.angle,
|
light.angle,
|
||||||
light.penumbra
|
light.penumbra
|
||||||
);
|
);
|
||||||
|
|
||||||
lights3d.push(light3d);
|
lights3d.push(light3d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene3d = new GameLib.D3.Scene(
|
var scene3d = new GameLib.D3.Scene(
|
||||||
scene._id || scene.id,
|
scene._id || scene.id,
|
||||||
scene.path,
|
scene.path,
|
||||||
scene.name,
|
scene.name,
|
||||||
|
graphics,
|
||||||
scene.meshes,
|
scene.meshes,
|
||||||
new GameLib.D3.Vector4(
|
new GameLib.D3.Vector4(
|
||||||
scene.quaternion.x,
|
scene.quaternion.x,
|
||||||
|
@ -225,16 +379,17 @@ GameLib.D3.Scene.LoadSceneFromApi = function(
|
||||||
),
|
),
|
||||||
scene.parentSceneId,
|
scene.parentSceneId,
|
||||||
lights3d,
|
lights3d,
|
||||||
physics3ds
|
entities,
|
||||||
|
uploadUrl,
|
||||||
|
progressCallback,
|
||||||
|
uploadUrl
|
||||||
);
|
);
|
||||||
|
|
||||||
GameLib.D3.Scene.LoadScene(
|
GameLib.D3.Scene.LoadScene(
|
||||||
scene3d,
|
scene3d,
|
||||||
onLoaded,
|
onLoaded,
|
||||||
false,
|
false,
|
||||||
graphics,
|
graphics
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,23 +404,24 @@ GameLib.D3.Scene.LoadSceneFromApi = function(
|
||||||
* @param onLoaded callback when all meshes have loaded
|
* @param onLoaded callback when all meshes have loaded
|
||||||
* @param computeNormals set to true to compute new face and vertex normals during load
|
* @param computeNormals set to true to compute new face and vertex normals during load
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param uploadUrl
|
|
||||||
* @param progressCallback
|
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.LoadScene = function(
|
GameLib.D3.Scene.LoadScene = function(
|
||||||
gameLibScene,
|
gameLibScene,
|
||||||
onLoaded,
|
onLoaded,
|
||||||
computeNormals,
|
computeNormals,
|
||||||
graphics,
|
graphics
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
console.log("loading scene " + gameLibScene.name);
|
console.log("loading scene " + gameLibScene.name);
|
||||||
|
|
||||||
|
if (typeof onLoaded == 'undefined') {
|
||||||
|
console.warn('No on loaded callback has been specified');
|
||||||
|
throw new Error('No on loaded callback has been specified');
|
||||||
|
}
|
||||||
|
|
||||||
graphics.isNotThreeThrow();
|
graphics.isNotThreeThrow();
|
||||||
|
|
||||||
var meshQ = [];
|
var instanceMeshes = [];
|
||||||
|
|
||||||
for (var m = 0; m < gameLibScene.meshes.length; m++) {
|
for (var m = 0; m < gameLibScene.meshes.length; m++) {
|
||||||
|
|
||||||
|
@ -402,250 +558,158 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
geometry.computeVertexNormals();
|
geometry.computeVertexNormals();
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceMaterialLoaders = [];
|
var instanceMaterial = GameLib.D3.Material.CreateInstanceMaterial(
|
||||||
|
materials[0],
|
||||||
|
graphics,
|
||||||
|
gameLibScene
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
var instanceMesh = GameLib.D3.Mesh.CreateInstanceMesh(
|
||||||
* Setup materials
|
mesh,
|
||||||
*/
|
geometry,
|
||||||
for (var mi = 0; mi < materials.length; mi++) {
|
instanceMaterial,
|
||||||
instanceMaterialLoaders.push(
|
graphics
|
||||||
GameLib.D3.Material.createInstanceMaterial(
|
);
|
||||||
materials[mi],
|
|
||||||
graphics,
|
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = Q.all(instanceMaterialLoaders).then(
|
instanceMesh.name = mesh.name;
|
||||||
function(mesh, geometry) {
|
|
||||||
return function(materials) {
|
|
||||||
|
|
||||||
console.log("loaded material : " + materials[0].name);
|
instanceMesh.position.x = mesh.position.x;
|
||||||
|
instanceMesh.position.y = mesh.position.y;
|
||||||
|
instanceMesh.position.z = mesh.position.z;
|
||||||
|
|
||||||
/**
|
instanceMesh.rotation.x = mesh.rotation.x;
|
||||||
* We don't support MultiMaterial atm - it doesn't work with raycasting
|
instanceMesh.rotation.y = mesh.rotation.y;
|
||||||
*/
|
instanceMesh.rotation.z = mesh.rotation.z;
|
||||||
var material = materials[0];
|
|
||||||
|
|
||||||
var threeMesh = GameLib.D3.Mesh.createInstanceMesh(
|
instanceMesh.scale.x = mesh.scale.x;
|
||||||
mesh,
|
instanceMesh.scale.y = mesh.scale.y;
|
||||||
geometry,
|
instanceMesh.scale.z = mesh.scale.z;
|
||||||
material,
|
|
||||||
graphics
|
|
||||||
);
|
|
||||||
threeMesh.name = mesh.name;
|
|
||||||
|
|
||||||
threeMesh.position.x = mesh.position.x;
|
instanceMesh.quaternion.x = mesh.quaternion.x;
|
||||||
threeMesh.position.y = mesh.position.y;
|
instanceMesh.quaternion.y = mesh.quaternion.y;
|
||||||
threeMesh.position.z = mesh.position.z;
|
instanceMesh.quaternion.z = mesh.quaternion.z;
|
||||||
|
instanceMesh.quaternion.w = mesh.quaternion.w;
|
||||||
|
|
||||||
threeMesh.rotation.x = mesh.rotation.x;
|
instanceMeshes.push(instanceMesh);
|
||||||
threeMesh.rotation.y = mesh.rotation.y;
|
|
||||||
threeMesh.rotation.z = mesh.rotation.z;
|
|
||||||
|
|
||||||
threeMesh.scale.x = mesh.scale.x;
|
|
||||||
threeMesh.scale.y = mesh.scale.y;
|
|
||||||
threeMesh.scale.z = mesh.scale.z;
|
|
||||||
|
|
||||||
threeMesh.quaternion.x = mesh.quaternion.x;
|
|
||||||
threeMesh.quaternion.y = mesh.quaternion.y;
|
|
||||||
threeMesh.quaternion.z = mesh.quaternion.z;
|
|
||||||
threeMesh.quaternion.w = mesh.quaternion.w;
|
|
||||||
|
|
||||||
return threeMesh;
|
|
||||||
};
|
|
||||||
}(mesh, geometry)
|
|
||||||
).catch(function(error){
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
meshQ.push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q.all(meshQ).then(
|
console.log("created all meshes");
|
||||||
function(instanceMeshes){
|
|
||||||
console.log("all meshes have loaded");
|
|
||||||
if (typeof onLoaded != 'undefined') {
|
|
||||||
|
|
||||||
var instanceLights = [];
|
var instanceLights = [];
|
||||||
|
|
||||||
for (var sli = 0; sli < gameLibScene.lights.length; sli++) {
|
if (gameLibScene.lights && gameLibScene.lights.length > 0) {
|
||||||
|
|
||||||
var gameLibLight = gameLibScene.lights[sli];
|
for (var glsl = 0; glsl < gameLibScene.lights.length; glsl++) {
|
||||||
|
|
||||||
var light = null;
|
var gameLibLight = gameLibScene.lights[glsl];
|
||||||
|
|
||||||
if (gameLibLight.lightType == 'AmbientLight') {
|
var light = null;
|
||||||
light = new graphics.instance.AmbientLight(gameLibLight.color, gameLibLight.intensity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gameLibLight.lightType == 'DirectionalLight') {
|
if (gameLibLight.lightType == 'AmbientLight') {
|
||||||
light = new graphics.instance.DirectionalLight(gameLibLight.color, gameLibLight.intensity);
|
light = new graphics.instance.AmbientLight(gameLibLight.color, gameLibLight.intensity);
|
||||||
}
|
|
||||||
|
|
||||||
if (gameLibLight.lightType == 'PointLight') {
|
|
||||||
light = new graphics.instance.PointLight(gameLibLight.color, gameLibLight.intensity);
|
|
||||||
light.distance = gameLibLight.distance;
|
|
||||||
light.decay = gameLibLight.decay;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gameLibLight.lightType == 'SpotLight') {
|
|
||||||
light = new graphics.instance.SpotLight(gameLibLight.color, gameLibLight.intensity);
|
|
||||||
light.distance = gameLibLight.distance;
|
|
||||||
light.angle = gameLibLight.angle;
|
|
||||||
light.penumbra = gameLibLight.penumbra;
|
|
||||||
light.decay = gameLibLight.decay;
|
|
||||||
}
|
|
||||||
|
|
||||||
light.position.x = gameLibLight.position.x;
|
|
||||||
light.position.y = gameLibLight.position.y;
|
|
||||||
light.position.z = gameLibLight.position.z;
|
|
||||||
|
|
||||||
light.rotation.x = gameLibLight.rotation.x;
|
|
||||||
light.rotation.y = gameLibLight.rotation.y;
|
|
||||||
light.rotation.z = gameLibLight.rotation.z;
|
|
||||||
|
|
||||||
if (light == null) {
|
|
||||||
console.warn('Does not support lights of type :' + gameLibLight.lightType + ', not imported');
|
|
||||||
} else {
|
|
||||||
light.name = gameLibLight.name;
|
|
||||||
instanceLights.push(light);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceScene = new graphics.instance.Scene();
|
if (gameLibLight.lightType == 'DirectionalLight') {
|
||||||
|
light = new graphics.instance.DirectionalLight(gameLibLight.color, gameLibLight.intensity);
|
||||||
instanceScene.name = gameLibScene.name;
|
|
||||||
|
|
||||||
instanceScene.position.x = gameLibScene.position.x;
|
|
||||||
instanceScene.position.y = gameLibScene.position.y;
|
|
||||||
instanceScene.position.z = gameLibScene.position.z;
|
|
||||||
|
|
||||||
instanceScene.rotation.x = gameLibScene.rotation.x;
|
|
||||||
instanceScene.rotation.y = gameLibScene.rotation.y;
|
|
||||||
instanceScene.rotation.z = gameLibScene.rotation.z;
|
|
||||||
|
|
||||||
instanceScene.scale.x = gameLibScene.scale.x;
|
|
||||||
instanceScene.scale.y = gameLibScene.scale.y;
|
|
||||||
instanceScene.scale.z = gameLibScene.scale.z;
|
|
||||||
|
|
||||||
instanceScene.quaternion.x = gameLibScene.quaternion.x;
|
|
||||||
instanceScene.quaternion.y = gameLibScene.quaternion.y;
|
|
||||||
instanceScene.quaternion.z = gameLibScene.quaternion.z;
|
|
||||||
instanceScene.quaternion.w = gameLibScene.quaternion.w;
|
|
||||||
|
|
||||||
for (var m = 0; m < instanceMeshes.length; m++) {
|
|
||||||
instanceScene.add(instanceMeshes[m]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var l = 0; l < instanceLights.length; l++) {
|
if (gameLibLight.lightType == 'PointLight') {
|
||||||
instanceScene.add(instanceLights[l]);
|
light = new graphics.instance.PointLight(gameLibLight.color, gameLibLight.intensity);
|
||||||
|
light.distance = gameLibLight.distance;
|
||||||
|
light.decay = gameLibLight.decay;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoaded(
|
if (gameLibLight.lightType == 'SpotLight') {
|
||||||
gameLibScene,
|
light = new graphics.instance.SpotLight(gameLibLight.color, gameLibLight.intensity);
|
||||||
{
|
light.distance = gameLibLight.distance;
|
||||||
scene: instanceScene,
|
light.angle = gameLibLight.angle;
|
||||||
lights: instanceLights,
|
light.penumbra = gameLibLight.penumbra;
|
||||||
meshes: instanceMeshes
|
light.decay = gameLibLight.decay;
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
}).catch(
|
|
||||||
function(error){
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
light.position.x = gameLibLight.position.x;
|
||||||
|
light.position.y = gameLibLight.position.y;
|
||||||
|
light.position.z = gameLibLight.position.z;
|
||||||
|
|
||||||
// - - - - - - - - - - - - - RUNTIME FUNCTIONS - - - - - - - - - - - - - - - - -
|
light.rotation.x = gameLibLight.rotation.x;
|
||||||
|
light.rotation.y = gameLibLight.rotation.y;
|
||||||
|
light.rotation.z = gameLibLight.rotation.z;
|
||||||
|
|
||||||
|
if (light == null) {
|
||||||
/**
|
console.warn('Does not support lights of type :' + gameLibLight.lightType + ', not imported');
|
||||||
* Updates the scene
|
} else {
|
||||||
* @param deltaTime
|
light.name = gameLibLight.name;
|
||||||
*/
|
instanceLights.push(light);
|
||||||
GameLib.D3.Scene.prototype.update = function(
|
}
|
||||||
deltaTime
|
|
||||||
) {
|
|
||||||
for(var e in this.entities) {
|
|
||||||
this.entities[e].update(deltaTime);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the scene
|
|
||||||
* @param deltaTime
|
|
||||||
*/
|
|
||||||
GameLib.D3.Scene.prototype.lateUpdate = function(
|
|
||||||
deltaTime
|
|
||||||
) {
|
|
||||||
for(var e in this.entities) {
|
|
||||||
this.entities[e].lateUpdate(deltaTime);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* renders the scene
|
|
||||||
* @param deltaTime
|
|
||||||
* @param renderer
|
|
||||||
* @param camera
|
|
||||||
*/
|
|
||||||
GameLib.D3.Scene.prototype.render = function(
|
|
||||||
deltaTime,
|
|
||||||
renderer,
|
|
||||||
camera
|
|
||||||
) {
|
|
||||||
renderer.render(this.threeScene, camera);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an entity to the scene.
|
|
||||||
* This method also links the entity and it's components,
|
|
||||||
* if they are defined inside the componentIds array.
|
|
||||||
* The setParentEntity and onSetParentEntity methods are being called here.
|
|
||||||
* @param entity GameLib.D3.Entity
|
|
||||||
*/
|
|
||||||
GameLib.D3.Scene.prototype.registerEntity = function(
|
|
||||||
entity
|
|
||||||
) {
|
|
||||||
this.entities.push(entity);
|
|
||||||
entity.register(this);
|
|
||||||
|
|
||||||
// link components to entity
|
|
||||||
for(var c in entity.componentIds) {
|
|
||||||
var componentId = entity.componentIds[c];
|
|
||||||
|
|
||||||
var component = this.componentIdToComponent[componentId];
|
|
||||||
if(component) {
|
|
||||||
component.setParentEntity(this, entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
var instanceScene = new graphics.instance.Scene();
|
||||||
* Registers a component to the scene.
|
|
||||||
* This method also calls the onRegistered-method on the component
|
instanceScene.name = gameLibScene.name;
|
||||||
* @param component GameLib.D3.ComponentInterface
|
|
||||||
*/
|
instanceScene.position.x = gameLibScene.position.x;
|
||||||
GameLib.D3.Scene.prototype.registerComponent = function(
|
instanceScene.position.y = gameLibScene.position.y;
|
||||||
component
|
instanceScene.position.z = gameLibScene.position.z;
|
||||||
) {
|
|
||||||
this.componentIdToComponent[component.componentId] = component;
|
instanceScene.rotation.x = gameLibScene.rotation.x;
|
||||||
if(component.onRegistered && typeof component.onRegistered == 'function') {
|
instanceScene.rotation.y = gameLibScene.rotation.y;
|
||||||
component.onRegistered(this);
|
instanceScene.rotation.z = gameLibScene.rotation.z;
|
||||||
|
|
||||||
|
instanceScene.scale.x = gameLibScene.scale.x;
|
||||||
|
instanceScene.scale.y = gameLibScene.scale.y;
|
||||||
|
instanceScene.scale.z = gameLibScene.scale.z;
|
||||||
|
|
||||||
|
instanceScene.quaternion.x = gameLibScene.quaternion.x;
|
||||||
|
instanceScene.quaternion.y = gameLibScene.quaternion.y;
|
||||||
|
instanceScene.quaternion.z = gameLibScene.quaternion.z;
|
||||||
|
instanceScene.quaternion.w = gameLibScene.quaternion.w;
|
||||||
|
|
||||||
|
for (var im = 0; im < instanceMeshes.length; im++) {
|
||||||
|
instanceScene.add(instanceMeshes[im]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var l = 0; l < instanceLights.length; l++) {
|
||||||
|
instanceScene.add(instanceLights[l]);
|
||||||
|
}
|
||||||
|
|
||||||
|
gameLibScene.loadTextures(gameLibScene.urls, function(loadedTextures) {
|
||||||
|
|
||||||
|
console.log('Found image data and applied it to ' + loadedTextures.length + ' textures');
|
||||||
|
|
||||||
|
onLoaded(
|
||||||
|
gameLibScene,
|
||||||
|
{
|
||||||
|
scene: instanceScene,
|
||||||
|
lights: instanceLights,
|
||||||
|
meshes: instanceMeshes
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
GameLib.D3.Scene.FromAPIScene = function(
|
||||||
* Registers a light to the scene
|
apiScene,
|
||||||
* @param light THREE.Light
|
graphics,
|
||||||
*/
|
progressCallback,
|
||||||
GameLib.D3.Scene.prototype.registerLight = function(
|
uploadUrl
|
||||||
light
|
|
||||||
) {
|
) {
|
||||||
this.threeScene.add(light);
|
return new GameLib.D3.Scene(
|
||||||
};
|
apiScene.id,
|
||||||
|
apiScene.path,
|
||||||
|
apiScene.name,
|
||||||
|
graphics,
|
||||||
|
apiScene.meshes,
|
||||||
|
apiScene.quaternion,
|
||||||
|
apiScene.position,
|
||||||
|
apiScene.rotation,
|
||||||
|
apiScene.scale,
|
||||||
|
apiScene.parentSceneId,
|
||||||
|
apiScene.lights,
|
||||||
|
apiScene.worlds,
|
||||||
|
apiScene.entities,
|
||||||
|
progressCallback,
|
||||||
|
uploadUrl
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* @param unpackAlignment
|
* @param unpackAlignment
|
||||||
* @param premultiplyAlpha
|
* @param premultiplyAlpha
|
||||||
* @param encoding
|
* @param encoding
|
||||||
|
* @param instanceMapId
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture = function(
|
GameLib.D3.Texture = function(
|
||||||
|
@ -42,7 +43,8 @@ GameLib.D3.Texture = function(
|
||||||
mipmaps,
|
mipmaps,
|
||||||
unpackAlignment,
|
unpackAlignment,
|
||||||
premultiplyAlpha,
|
premultiplyAlpha,
|
||||||
encoding
|
encoding,
|
||||||
|
instanceMapId
|
||||||
) {
|
) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -132,6 +134,8 @@ GameLib.D3.Texture = function(
|
||||||
encoding = GameLib.D3.Texture.TYPE_LINEAR_ENCODING;
|
encoding = GameLib.D3.Texture.TYPE_LINEAR_ENCODING;
|
||||||
}
|
}
|
||||||
this.encoding = encoding;
|
this.encoding = encoding;
|
||||||
|
|
||||||
|
this.instanceMapId = instanceMapId;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,195 +208,18 @@ GameLib.D3.Texture.TYPE_RGBM16_ENCODING = 3005;
|
||||||
GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defers loading of an image and resolves once image is loaded
|
* A Notification object stores an association between a gameLibTexture and a instance material map.
|
||||||
* @param gameLibTexture GameLib.D3.Texture
|
|
||||||
* @param instanceMaterial
|
* @param instanceMaterial
|
||||||
* @param instanceMaterialMapType
|
* @param gameLibTexture
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @constructor
|
||||||
* @param uploadUrl String
|
|
||||||
* @param progressCallback
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.loadMap = function(
|
GameLib.D3.Texture.Notification = function(
|
||||||
gameLibTexture,
|
gameLibTexture,
|
||||||
instanceMaterial,
|
instanceMaterial
|
||||||
instanceMaterialMapType,
|
|
||||||
graphics,
|
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
) {
|
) {
|
||||||
|
this.gameLibTexture = gameLibTexture;
|
||||||
var defer = Q.defer();
|
this.instanceMaterial = instanceMaterial;
|
||||||
|
|
||||||
var imagePath = null;
|
|
||||||
|
|
||||||
var textureLoader = new graphics.instance.TextureLoader();
|
|
||||||
|
|
||||||
if (gameLibTexture && gameLibTexture.image && gameLibTexture.image.filename) {
|
|
||||||
/**
|
|
||||||
* Else, load from upload source
|
|
||||||
*/
|
|
||||||
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imagePath) {
|
|
||||||
|
|
||||||
textureLoader.crossOrigin = '';
|
|
||||||
|
|
||||||
textureLoader.load(
|
|
||||||
imagePath,
|
|
||||||
function(texture) {
|
|
||||||
/**
|
|
||||||
* onLoad
|
|
||||||
*/
|
|
||||||
instanceMaterial[instanceMaterialMapType] = texture;
|
|
||||||
instanceMaterial[instanceMaterialMapType].name = gameLibTexture.name;
|
|
||||||
instanceMaterial[instanceMaterialMapType].anisotropy = gameLibTexture.anisotropy;
|
|
||||||
instanceMaterial[instanceMaterialMapType].encoding = gameLibTexture.encoding;
|
|
||||||
instanceMaterial[instanceMaterialMapType].flipY = gameLibTexture.flipY;
|
|
||||||
/**
|
|
||||||
* We don't restore the format since this changing from OS to OS and breaks the implementation sometimes
|
|
||||||
*/
|
|
||||||
instanceMaterial[instanceMaterialMapType].generateMipmaps = gameLibTexture.generateMipmaps;
|
|
||||||
instanceMaterial[instanceMaterialMapType].magFilter = gameLibTexture.magFilter;
|
|
||||||
instanceMaterial[instanceMaterialMapType].minFilter = gameLibTexture.minFilter;
|
|
||||||
instanceMaterial[instanceMaterialMapType].mapping = gameLibTexture.mapping;
|
|
||||||
instanceMaterial[instanceMaterialMapType].mipmaps = gameLibTexture.mipmaps;
|
|
||||||
instanceMaterial[instanceMaterialMapType].offset = new graphics.instance.Vector2(
|
|
||||||
gameLibTexture.offset.x,
|
|
||||||
gameLibTexture.offset.y
|
|
||||||
);
|
|
||||||
instanceMaterial[instanceMaterialMapType].premultiplyAlpha = gameLibTexture.premultiplyAlpha;
|
|
||||||
instanceMaterial[instanceMaterialMapType].textureType = gameLibTexture.textureType;
|
|
||||||
instanceMaterial[instanceMaterialMapType].wrapS = gameLibTexture.wrapS;
|
|
||||||
instanceMaterial[instanceMaterialMapType].wrapT = gameLibTexture.wrapT;
|
|
||||||
instanceMaterial[instanceMaterialMapType].unpackAlignment = gameLibTexture.unpackAlignment;
|
|
||||||
instanceMaterial.needsUpdate = true;
|
|
||||||
defer.resolve(true);
|
|
||||||
},
|
|
||||||
function(xhr) {
|
|
||||||
/**
|
|
||||||
* onProgress
|
|
||||||
*/
|
|
||||||
if (progressCallback) {
|
|
||||||
progressCallback(Math.round(xhr.loaded / xhr.total * 100));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
/**
|
|
||||||
* onError
|
|
||||||
*/
|
|
||||||
console.log("an error occurred while trying to load the image : " + imagePath);
|
|
||||||
defer.resolve(null);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
defer.resolve(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return defer.promise;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of image loading Promises
|
|
||||||
* @param gameLibMaterial
|
|
||||||
* @param blenderMaps
|
|
||||||
* @param instanceMaterial
|
|
||||||
* @param graphics GameLib.D3.Graphics
|
|
||||||
* @param uploadUrl String
|
|
||||||
* @param progressCallback
|
|
||||||
* @returns Q[]
|
|
||||||
*/
|
|
||||||
GameLib.D3.Texture.loadMaps = function(
|
|
||||||
gameLibMaterial,
|
|
||||||
blenderMaps,
|
|
||||||
instanceMaterial,
|
|
||||||
graphics,
|
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
) {
|
|
||||||
|
|
||||||
var textureMaps = [];
|
|
||||||
|
|
||||||
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
|
||||||
|
|
||||||
var map = blenderMaps[ti];
|
|
||||||
|
|
||||||
if (gameLibMaterial.maps.hasOwnProperty(map)) {
|
|
||||||
|
|
||||||
var blenderTexture = gameLibMaterial.maps[map];
|
|
||||||
|
|
||||||
if (
|
|
||||||
blenderTexture &&
|
|
||||||
blenderTexture.image &&
|
|
||||||
blenderTexture.image.filename
|
|
||||||
) {
|
|
||||||
|
|
||||||
var instanceMap = null;
|
|
||||||
|
|
||||||
if (map == 'alpha') {
|
|
||||||
instanceMap = 'alhpaMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'ao') {
|
|
||||||
instanceMap = 'aoMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'bump') {
|
|
||||||
instanceMap = 'bumpMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'displacement') {
|
|
||||||
instanceMap = 'displacementMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'emissive') {
|
|
||||||
instanceMap = 'emissiveMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'environment') {
|
|
||||||
instanceMap = 'envMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'light') {
|
|
||||||
instanceMap = 'lightMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'specular') {
|
|
||||||
instanceMap = 'specularMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'diffuse') {
|
|
||||||
instanceMap = 'map';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'roughness') {
|
|
||||||
instanceMap = 'roughnessMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map == 'metalness') {
|
|
||||||
instanceMap = 'metalnessMap';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instanceMap == null) {
|
|
||||||
console.warn("unsupported map type : " + map);
|
|
||||||
}
|
|
||||||
|
|
||||||
textureMaps.push(
|
|
||||||
GameLib.D3.Texture.loadMap(
|
|
||||||
gameLibMaterial.maps[map],
|
|
||||||
instanceMaterial,
|
|
||||||
instanceMap,
|
|
||||||
graphics,
|
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return textureMaps;
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue