Merge branch 'master' into feature/kml_renderable

This commit is contained in:
Jakub Balhar 2016-04-04 13:29:18 +02:00
commit 7aa6538cfa
39 changed files with 677 additions and 621 deletions

79
apps/Collada.html Normal file
View File

@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!--NOTE: Most Web World Wind examples use jquery, Bootstrap and requirejs but those technologies are NOT-->
<!--required by Web World Wind. See SimplestExample.html for an example of using Web World Wind without them.-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script data-main="Collada/Collada"
src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.17/require.min.js"></script>
<style>
.my-slider {
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="jumbotron hidden-xs">
<h1 style="text-align:center">World Wind Collada Example</h1>
</div>
<div class="row">
<div class="col-sm-3">
<h4>Projection</h4>
<ul class="nav nav-pills">
<li class="dropdown" id="projectionDropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="projectionDropdownTitle">3D
<span class="caret"></span></a></li>
</ul>
<br>
<h4>Models</h4>
<br>
<div class="dropdown" id="collada-models">
<button class="btn btn-default dropdown-toggle" type="button" id="modelDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span id="button-value">Select a model</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="modelDropdownMenu" id="model-list">
</ul>
</div>
<br>
<div style="background-color: #ededed; padding: 20px;">
<p id="scale">Scale: <span id="scaleSpan"></span></p>
<div id="sliderScale" class="my-slider"></div>
<p>Rotate X: <span id="spanRotateX">0</span></p>
<div id="sliderRotateX" class="my-slider"></div>
<p>Rotate Y: <span id="spanRotateY">0</span></p>
<div id="sliderRotateY" class="my-slider"></div>
<p>Rotate Z: <span id="spanRotateZ">0</span></p>
<div id="sliderRotateZ" class="my-slider"></div>
</div>
</div>
<div class="col-sm-9" id="globe">
<canvas id="canvasOne" width="1000" height="1000" style="width: 100%; height: auto">
Your browser does not support HTML5 Canvas.
</canvas>
</div>
</div>
</div>
</body>
</html>

214
apps/Collada/Collada.js Normal file
View File

@ -0,0 +1,214 @@
/*
* Copyright (C) 2014 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration. All Rights Reserved.
*/
/*
* Copyright (C) 2014 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration. All Rights Reserved.
*/
require(['../../src/WorldWind', '../util/ProjectionMenu'], function (ww, ProjectionMenu) {
"use strict";
var modelsCombo = document.getElementById('model-list');
var modelSelectorButton = document.getElementById('button-value');
var sliderScale = $("#sliderScale");
var sliderRotateX = $("#sliderRotateX");
var sliderRotateY = $("#sliderRotateY");
var sliderRotateZ = $("#sliderRotateZ");
var spanScale = $('#scaleSpan');
var spanRotateX = $("#spanRotateX");
var spanRotateY = $("#spanRotateY");
var spanRotateZ = $("#spanRotateZ");
sliderScale.slider({
min: 0,
max: 5000,
value: 10,
slide: function (event, ui) {
if (modelScene) {
spanScale.html(ui.value);
modelScene.scale = ui.value;
wwd.redraw();
}
}
});
sliderRotateX.slider({
min: 0,
max: 360,
value: 0,
slide: function (event, ui) {
if (modelScene) {
spanRotateX.html(ui.value);
modelScene.xRotation = ui.value;
wwd.redraw();
}
}
});
sliderRotateY.slider({
min: 0,
max: 360,
value: 0,
slide: function (event, ui) {
if (modelScene) {
spanRotateY.html(ui.value);
modelScene.yRotation = ui.value;
wwd.redraw();
}
}
});
sliderRotateZ.slider({
min: 0,
max: 360,
value: 0,
slide: function (event, ui) {
if (modelScene) {
spanRotateZ.html(ui.value);
modelScene.zRotation = ui.value;
wwd.redraw();
}
}
});
WorldWind.Logger.setLoggingLevel(WorldWind.Logger.LEVEL_WARNING);
var wwd = new WorldWind.WorldWindow("canvasOne");
new ProjectionMenu(wwd);
var layers = [
{layer: new WorldWind.BMNGLayer(), enabled: true},
{layer: new WorldWind.BMNGLandsatLayer(), enabled: false},
{layer: new WorldWind.BingAerialLayer(null), enabled: false},
{layer: new WorldWind.BingAerialWithLabelsLayer(null), enabled: false},
{layer: new WorldWind.BingRoadsLayer(null), enabled: false},
{layer: new WorldWind.OpenStreetMapImageLayer(null), enabled: false},
{layer: new WorldWind.CompassLayer(), enabled: true, hide: true},
{layer: new WorldWind.CoordinatesDisplayLayer(wwd), enabled: true, hide: true},
{layer: new WorldWind.ViewControlsLayer(wwd), enabled: true, hide: true}
];
for (var l = 0; l < layers.length; l++) {
layers[l].layer.enabled = layers[l].enabled;
layers[l].layer.hide = layers[l].hide;
wwd.addLayer(layers[l].layer);
}
var modelLayer = new WorldWind.RenderableLayer("model");
wwd.addLayer(modelLayer);
var position = new WorldWind.Position(45, -100, 1000e3);
var colladaLoader = new WorldWind.ColladaLoader(position);
var modelScene;
var colladaModels = [
{
displayName: 'box',
fileName: 'box.dae',
path: 'box',
initialScale: 500000,
maxScale: 1000000,
useTexturePaths: true
},
{
displayName: 'duck',
fileName: 'duck.dae',
path: 'duck',
initialScale: 5000,
maxScale: 10000,
useTexturePaths: true
},
{
displayName: 'cylinderEngine',
fileName: '2_cylinder_engine.dae',
path: '2_cylinder_engine',
initialScale: 5000,
maxScale: 10000,
useTexturePaths: true
},
{
displayName: 'reciprocatingSaw',
fileName: 'Reciprocating_Saw.dae',
path: 'Reciprocating_Saw',
initialScale: 5000,
maxScale: 10000,
useTexturePaths: true
},
{
displayName: 'gearbox',
fileName: 'gearbox_assy.dae',
path: 'gearbox_assy',
initialScale: 10000,
maxScale: 20000,
useTexturePaths: true
},
{
displayName: 'buggy',
fileName: 'buggy.dae',
path: 'buggy',
initialScale: 5000,
maxScale: 10000,
useTexturePaths: true
},
{
displayName: 'kmlBuilding',
fileName: 'CU Macky.dae',
path: 'kmlBuilding',
initialScale: 500,
maxScale: 1000,
useTexturePaths: false
},
];
createCombo();
function createCombo() {
for (var i = 0; i < colladaModels.length; i++) {
var li = document.createElement('li');
var a = document.createElement('a');
a.href = "#";
a.text = colladaModels[i].displayName;
a.onclick = selectModel;
li.appendChild(a);
modelsCombo.appendChild(li);
}
}
function selectModel(event) {
modelSelectorButton.innerHTML = this.text;
var pos = colladaModels.map(function (model) {
return model.displayName;
}).indexOf(this.text);
var model = colladaModels[pos];
colladaLoader.init({dirPath: './Collada/collada_models/' + model.path + '/'});
colladaLoader.load(model.fileName, function (scene) {
console.log('scene', scene);
if (scene) {
scene.scale = model.initialScale;
scene.altitudeMode = WorldWind.ABSOLUTE;
scene.useTexturePaths = model.useTexturePaths;
modelLayer.removeAllRenderables();
modelLayer.addRenderable(scene);
modelScene = scene;
sliderScale.slider("option", "max", model.maxScale);
sliderScale.slider("option", "value", model.initialScale);
spanScale.html(model.initialScale);
}
});
}
});

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -3,19 +3,15 @@
<head>
<!--NOTE: Most Web World Wind examples use jquery, Bootstrap and requirejs but those technologies are NOT-->
<!--required by Web World Wind. See SimplestExample.html for an example of using Web World Wind without them.-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script data-main="Collada" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.17/require.min.js"></script>
<style>
.my-slider {
margin-bottom: 10px;
}
</style>
</head>
<body>
@ -26,58 +22,7 @@
<div class="row">
<div class="col-sm-3">
<h4>Projection</h4>
<div class="dropdown" id="projectionDropdown">
</div>
<br>
<h4 style="display: none">Layers</h4>
<div class="list-group" id="layerList" style="display: none">
</div>
<br>
<h4 style="display: none">Destination</h4>
<div class="input-group" id="searchBox" style="display: none">
<input type="text" class="form-control" placeholder="GoTo" id="searchText"/>
<span class="input-group-btn">
<button id="searchButton" class="btn btn-primary" type="button">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
<br>
<h4>Models</h4>
<br>
<div class="dropdown" id="collada-models">
<button class="btn btn-default dropdown-toggle" type="button" id="modelDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span id="button-value">Select a model</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="modelDropdownMenu" id="model-list">
</ul>
</div>
<br>
<div style="background-color: #ededed; padding: 20px;">
<p id="scale">Scale: <span id="scaleSpan"></span></p>
<div id="sliderScale" class="my-slider"></div>
<p>Rotate X: <span id="spanRotateX">0</span></p>
<div id="sliderRotateX" class="my-slider"></div>
<p>Rotate Y: <span id="spanRotateY">0</span></p>
<div id="sliderRotateY" class="my-slider"></div>
<p>Rotate Z: <span id="spanRotateZ">0</span></p>
<div id="sliderRotateZ" class="my-slider"></div>
</div>
<div class="dropdown" id="projectionDropdown"></div>
</div>
<div class="col-sm-9" id="globe">
<canvas id="canvasOne" width="1000" height="1000" style="width: 100%; height: auto">

View File

@ -6,69 +6,6 @@
require(['../src/WorldWind', './LayerManager'], function (ww, LayerManager) {
"use strict";
var modelsCombo = document.getElementById('model-list');
var modelSelectorButton = document.getElementById('button-value');
var sliderScale = $("#sliderScale");
var sliderRotateX = $("#sliderRotateX");
var sliderRotateY = $("#sliderRotateY");
var sliderRotateZ = $("#sliderRotateZ");
var spanScale = $('#scaleSpan');
var spanRotateX = $("#spanRotateX");
var spanRotateY = $("#spanRotateY");
var spanRotateZ = $("#spanRotateZ");
sliderScale.slider({
min: 0,
max: 5000,
value: 10,
slide: function (event, ui) {
if (modelScene) {
spanScale.html(ui.value);
modelScene.scale = ui.value;
wwd.redraw();
}
}
});
sliderRotateX.slider({
min: 0,
max: 360,
value: 0,
slide: function (event, ui) {
if (modelScene) {
spanRotateX.html(ui.value);
modelScene.xRotation = ui.value;
wwd.redraw();
}
}
});
sliderRotateY.slider({
min: 0,
max: 360,
value: 0,
slide: function (event, ui) {
if (modelScene) {
spanRotateY.html(ui.value);
modelScene.yRotation = ui.value;
wwd.redraw();
}
}
});
sliderRotateZ.slider({
min: 0,
max: 360,
value: 0,
slide: function (event, ui) {
if (modelScene) {
spanRotateZ.html(ui.value);
modelScene.zRotation = ui.value;
wwd.redraw();
}
}
});
WorldWind.Logger.setLoggingLevel(WorldWind.Logger.LEVEL_WARNING);
var wwd = new WorldWind.WorldWindow("canvasOne");
@ -95,116 +32,12 @@ require(['../src/WorldWind', './LayerManager'], function (ww, LayerManager) {
var position = new WorldWind.Position(45, -100, 1000e3);
var colladaLoader = new WorldWind.ColladaLoader(position);
colladaLoader.init({dirPath: './collada_models/duck/'});
colladaLoader.load('duck.dae', function (scene) {
scene.scale = 5000;
modelLayer.addRenderable(scene);
});
var modelScene;
var colladaModels = [
{
displayName: 'box',
fileName: 'box.dae',
path: 'box',
initialScale: 500000,
maxScale: 1000000,
localTransform: true
},
{
displayName: 'boxWithoutIndices',
fileName: 'boxWithoutIndices.dae',
path: 'boxWithoutIndices',
initialScale: 500000,
maxScale: 1000000,
localTransform: true
},
{
displayName: 'duck',
fileName: 'duck.dae',
path: 'duck',
initialScale: 5000,
maxScale: 10000,
localTransform: true
},
{
displayName: 'cylinderEngine',
fileName: '2_cylinder_engine.dae',
path: '2_cylinder_engine',
initialScale: 5000,
maxScale: 10000,
localTransform: true
},
{
displayName: 'reciprocatingSaw',
fileName: 'Reciprocating_Saw.dae',
path: 'Reciprocating_Saw',
initialScale: 5000,
maxScale: 10000,
localTransform: true
},
{
displayName: 'gearbox',
fileName: 'gearbox_assy.dae',
path: 'gearbox_assy',
initialScale: 10000,
maxScale: 20000,
localTransform: true
},
{
displayName: 'buggy',
fileName: 'buggy.dae',
path: 'buggy',
initialScale: 5000,
maxScale: 10000,
localTransform: true
},
{
displayName: 'kmlBuilding',
fileName: 'CU Macky.dae',
path: 'kmlBuilding',
initialScale: 500,
maxScale: 1000,
localTransform: true
},
];
createCombo();
function createCombo() {
for (var i = 0; i < colladaModels.length; i++) {
var li = document.createElement('li');
var a = document.createElement('a');
a.href = "#";
a.text = colladaModels[i].displayName;
a.onclick = selectModel;
li.appendChild(a);
modelsCombo.appendChild(li);
}
}
function selectModel(event) {
modelSelectorButton.innerHTML = this.text;
var pos = colladaModels.map(function (model) {
return model.displayName;
}).indexOf(this.text);
var model = colladaModels[pos];
colladaLoader.init({filePath: './collada_models/' + model.path + '/'});
colladaLoader.load(model.fileName, function (scene) {
scene.scale = model.initialScale;
scene.localTransforms = model.localTransform;
scene.altitudeMode = WorldWind.ABSOLUTE;
modelLayer.removeAllRenderables();
modelLayer.addRenderable(scene);
modelScene = scene;
sliderScale.slider("option", "max", model.maxScale);
sliderScale.slider("option", "value", model.initialScale);
spanScale.html(model.initialScale);
});
}
new LayerManager(wwd);
});

View File

@ -1,313 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<authoring_tool>modo 701 [Build 64278], Microsoft Windows 7 Service Pack 1 (6.1.7601 Service Pack 1)</authoring_tool>
<comments>Plug-in: [Build 64278]; Use Absolute Path: No; Merge Reference Items: No; Save Hidden Items: No; Save Cameras: No; Save Lights: Yes; Save Locators: Yes; Save Triangles as Triangles: Yes; Order Vertex Maps Alphabetically: Yes; Bake Matrices: No; Save Vertex Normals: Yes; Save UV Texture Coordinates: Yes; Save Vertex Colors: No; Save Vertex Weights: No; Save Animation: Yes; Sample Animation: No; Sample Animation Start: 0; Sample Animation End: 120; Save modo Profile: No; Save Maya Profile: No; Save 3ds Max Profile: No; Formatted Arrays: No;</comments>
<source_data>file:///C:/Users/bcoker/Desktop/DAE%20Test/anim-test-boxes.lxo</source_data>
</contributor>
<created>2013-10-31T20:53:56Z</created>
<modified>2013-10-31T20:53:56Z</modified>
<up_axis>Y_UP</up_axis>
</asset>
<library_animations>
<animation id="Geometry-mesh020_rotation022X.ANGLE">
<source id="Geometry-mesh020_rotation022X.ANGLE-input">
<float_array id="Geometry-mesh020_rotation022X.ANGLE-input-array" count="2">1.25 2.5</float_array>
<technique_common>
<accessor count="2" source="#Geometry-mesh020_rotation022X.ANGLE-input-array" stride="1">
<param name="TIME" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_rotation022X.ANGLE-output">
<float_array id="Geometry-mesh020_rotation022X.ANGLE-output-array" count="2">0 180</float_array>
<technique_common>
<accessor count="2" source="#Geometry-mesh020_rotation022X.ANGLE-output-array" stride="1">
<param name="ANGLE" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_rotation022X.ANGLE-intangents">
<float_array id="Geometry-mesh020_rotation022X.ANGLE-intangents-array" count="4">0.833333 0 2.08333 180</float_array>
<technique_common>
<accessor count="2" source="#Geometry-mesh020_rotation022X.ANGLE-intangents-array" stride="2">
<param name="X" type="float" />
<param name="Y" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_rotation022X.ANGLE-outtangents">
<float_array id="Geometry-mesh020_rotation022X.ANGLE-outtangents-array" count="4">1.66667 0 2.91667 180</float_array>
<technique_common>
<accessor count="2" source="#Geometry-mesh020_rotation022X.ANGLE-outtangents-array" stride="2">
<param name="X" type="float" />
<param name="Y" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_rotation022X.ANGLE-interpolations">
<Name_array id="Geometry-mesh020_rotation022X.ANGLE-interpolations-array" count="2">BEZIER BEZIER</Name_array>
<technique_common>
<accessor count="2" source="#Geometry-mesh020_rotation022X.ANGLE-interpolations-array" stride="1">
<param name="INTERPOLATION" type="Name" />
</accessor>
</technique_common>
</source>
<sampler id="Geometry-mesh020_rotation022X.ANGLE-sampler">
<input semantic="INPUT" source="#Geometry-mesh020_rotation022X.ANGLE-input" />
<input semantic="OUTPUT" source="#Geometry-mesh020_rotation022X.ANGLE-output" />
<input semantic="INTERPOLATION" source="#Geometry-mesh020_rotation022X.ANGLE-interpolations" />
<input semantic="IN_TANGENT" source="#Geometry-mesh020_rotation022X.ANGLE-intangents" />
<input semantic="OUT_TANGENT" source="#Geometry-mesh020_rotation022X.ANGLE-outtangents" />
</sampler>
<channel source="#Geometry-mesh020_rotation022X.ANGLE-sampler" target="Geometry-mesh020Node/rotation022X.ANGLE" />
</animation>
<animation id="Geometry-mesh020_translation021.Y">
<source id="Geometry-mesh020_translation021.Y-input">
<float_array id="Geometry-mesh020_translation021.Y-input-array" count="4">0 1.25 2.5 3.70833</float_array>
<technique_common>
<accessor count="4" source="#Geometry-mesh020_translation021.Y-input-array" stride="1">
<param name="TIME" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_translation021.Y-output">
<float_array id="Geometry-mesh020_translation021.Y-output-array" count="4">0 2.52 2.52 0</float_array>
<technique_common>
<accessor count="4" source="#Geometry-mesh020_translation021.Y-output-array" stride="1">
<param name="Y" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_translation021.Y-intangents">
<float_array id="Geometry-mesh020_translation021.Y-intangents-array" count="8">-0.416667 0 0.833333 2.52 2.08333 2.52 3.30556 0</float_array>
<technique_common>
<accessor count="4" source="#Geometry-mesh020_translation021.Y-intangents-array" stride="2">
<param name="X" type="float" />
<param name="Y" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_translation021.Y-outtangents">
<float_array id="Geometry-mesh020_translation021.Y-outtangents-array" count="8">0.416667 0 1.66667 2.52 2.91667 2.52 4.11111 0</float_array>
<technique_common>
<accessor count="4" source="#Geometry-mesh020_translation021.Y-outtangents-array" stride="2">
<param name="X" type="float" />
<param name="Y" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020_translation021.Y-interpolations">
<Name_array id="Geometry-mesh020_translation021.Y-interpolations-array" count="4">BEZIER BEZIER BEZIER BEZIER</Name_array>
<technique_common>
<accessor count="4" source="#Geometry-mesh020_translation021.Y-interpolations-array" stride="1">
<param name="INTERPOLATION" type="Name" />
</accessor>
</technique_common>
</source>
<sampler id="Geometry-mesh020_translation021.Y-sampler">
<input semantic="INPUT" source="#Geometry-mesh020_translation021.Y-input" />
<input semantic="OUTPUT" source="#Geometry-mesh020_translation021.Y-output" />
<input semantic="INTERPOLATION" source="#Geometry-mesh020_translation021.Y-interpolations" />
<input semantic="IN_TANGENT" source="#Geometry-mesh020_translation021.Y-intangents" />
<input semantic="OUT_TANGENT" source="#Geometry-mesh020_translation021.Y-outtangents" />
</sampler>
<channel source="#Geometry-mesh020_translation021.Y-sampler" target="Geometry-mesh020Node/translation021.Y" />
</animation>
</library_animations>
<library_materials>
<material id="Material-inner" name="inner">
<instance_effect url="#Effect-inner" />
</material>
<material id="Material-outer" name="outer">
<instance_effect url="#Effect-outer" />
</material>
</library_materials>
<library_effects>
<effect id="Effect-inner" name="inner">
<profile_COMMON>
<technique sid="common">
<phong>
<diffuse>
<color sid="diffuse_effect_rgb">0.8 0.415942 0.795292 1</color>
</diffuse>
<specular>
<color sid="specular_effect_rgb">0.2 0.2 0.2 1</color>
</specular>
<shininess>
<float sid="specular_effect_rgb">256</float>
</shininess>
</phong>
</technique>
</profile_COMMON>
</effect>
<effect id="Effect-outer" name="outer">
<profile_COMMON>
<technique sid="common">
<phong>
<diffuse>
<color sid="diffuse_effect_rgb">0.301604 0.533542 0.8 1</color>
</diffuse>
<specular>
<color sid="specular_effect_rgb">0.2 0.2 0.2 1</color>
</specular>
<shininess>
<float sid="specular_effect_rgb">256</float>
</shininess>
</phong>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_geometries>
<geometry id="Geometry-mesh019" name="outer_box">
<mesh>
<source id="Geometry-mesh019-positions" name="positions">
<float_array id="Geometry-mesh019-positions-array" count="192">-0.497 -0.497 -0.5 -0.494879 -0.5 -0.497879 -0.497879 -0.5 -0.494879 -0.5 -0.497 -0.497 0.5 -0.497 -0.497 0.497879 -0.5 -0.494879 0.494879 -0.5 -0.497879 0.497 -0.497 -0.5 0.497 -0.497 0.5 0.494879 -0.5 0.497879 0.497879 -0.5 0.494879 0.5 -0.497 0.497 -0.5 -0.497 0.497 -0.497879 -0.5 0.494879 -0.494879 -0.5 0.497879 -0.497 -0.497 0.5 -0.5 0.497 -0.497 -0.497879 0.5 -0.494879 -0.494879 0.5 -0.497879 -0.497 0.497 -0.5 0.494879 0.5 -0.497879 0.497879 0.5 -0.494879 0.5 0.497 -0.497 0.497 0.497 -0.5 0.497879 0.5 0.494879 0.494879 0.5 0.497879 0.497 0.497 0.5 0.5 0.497 0.497 -0.494879 0.5 0.497879 -0.497879 0.5 0.494879 -0.5 0.497 0.497 -0.497 0.497 0.5 -0.347852 -0.5 -0.351772 -0.346 -0.497 -0.349 -0.349 -0.497 -0.346 -0.351772 -0.5 -0.347852 0.351772 -0.5 -0.347852 0.349 -0.497 -0.346 0.346 -0.497 -0.349 0.347852 -0.5 -0.351772 0.347852 -0.5 0.351772 0.346 -0.497 0.349 0.349 -0.497 0.346 0.351772 -0.5 0.347852 -0.351772 -0.5 0.347852 -0.349 -0.497 0.346 -0.346 -0.497 0.349 -0.347852 -0.5 0.351772 -0.351772 0.5 -0.347852 -0.349 0.497 -0.346 -0.346 0.497 -0.349 -0.347852 0.5 -0.351772 0.347852 0.5 -0.351772 0.346 0.497 -0.349 0.349 0.497 -0.346 0.351772 0.5 -0.347852 0.351772 0.5 0.347852 0.349 0.497 0.346 0.346 0.497 0.349 0.347852 0.5 0.351772 -0.347852 0.5 0.351772 -0.346 0.497 0.349 -0.349 0.497 0.346 -0.351772 0.5 0.347852</float_array>
<technique_common>
<accessor count="64" source="#Geometry-mesh019-positions-array" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh019-normals" name="normals">
<float_array id="Geometry-mesh019-normals-array" count="126">0 -0.6786 -0.734508 0 -1 -0 0.707107 0 0.707107 -0.734508 -0.6786 -0 0.734508 -0.6786 0 0 -0.577353 0.816495 0 -0.6786 0.734508 0 0.6786 -0.734508 -0.816495 -0.577353 -0 0.816495 -0.577353 0 -0.734508 0.6786 0 0.734508 0.6786 0 0 -0.577353 -0.816495 0.707107 0 -0.707107 0 0.577353 0.816495 -0 0.6786 0.734508 -0.707107 0 -0.707107 0.816495 0.577353 -0 -0.816495 0.577353 0 -0.707107 0 0.707107 0 0.577353 -0.816495 -0.499998 -0.707109 -0.499998 0.499998 -0.707109 -0.499998 0.499998 -0.707109 0.499998 -0.499998 -0.707109 0.499998 -0.499998 0.707109 -0.499998 0.499998 0.707109 -0.499998 0.499998 0.707109 0.499998 -0.499998 0.707109 0.499998 0.478075 -0.73681 0.478075 -0.478075 -0.73681 0.478075 -0.478075 -0.73681 -0.478075 0.478075 -0.73681 -0.478075 0.478075 0.73681 0.478075 -0.478075 0.73681 0.478075 -0.478075 0.73681 -0.478075 0.478075 0.73681 -0.478075 1 0 0 -0 0 1 -1 0 0 -0 -0 -1 0 1 0</float_array>
<technique_common>
<accessor count="42" source="#Geometry-mesh019-normals-array" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh019-Texture" name="Texture">
<float_array id="Geometry-mesh019-Texture-array" count="188">0.344638 0.240525 0.405362 0.240525 0.407013 0.240691 0.342987 0.240691 0.342643 0.0934546 0.251326 0.00232583 0.252076 0.00132583 0.342987 0.0926427 0.344375 0.90257 0.344375 0.0974302 0.344638 0.0968087 0.344638 0.903191 0.405625 0.239903 0.405625 0.0974302 0.407357 0.0934546 0.407357 0.239879 0.342643 0.239879 0.344375 0.239903 0.49925 0.334333 0.25075 0.334333 0.252076 0.332007 0.497924 0.332007 0.405362 0.0968087 0.407013 0.0926427 0.405362 0.759475 0.344638 0.759475 0.342987 0.759309 0.407013 0.759309 0.248674 0.331008 0.248674 0.00232583 0.251326 0.331008 0.501326 0.00232583 0.501326 0.331008 0.498674 0.331008 0.498674 0.00232583 0.405625 0.90257 0.405625 0.760097 0.407357 0.760121 0.407357 0.906545 0.344375 0.760097 0.342643 0.906545 0.342643 0.760121 0.252076 -0.00132583 0.497924 -0.00132583 0.497924 0.00132583 0.497924 0.667992 0.252076 0.667992 0.25075 0.665667 0.49925 0.665667 0.405362 0.903191 0.407013 0.907357 0.342987 0.907357 0.74925 0.667667 0.50075 0.667667 0.50075 0.665667 0.74925 0.665667 0.24925 0.667667 0.00075 0.667667 0.00075 0.665667 0.24925 0.665667 0.99925 0.667667 0.75075 0.667667 0.75075 0.665667 0.99925 0.665667 0.24923 0.000132068 0.249868 0.000769766 0.25077 -0.000132068 0.250132 -0.000769766 0.500132 0.000769766 0.50077 0.000132068 0.499868 -0.000769766 0.49923 -0.000132068 0.50075 0.334333 0.24925 0.334333 1.00013 0.665897 1.00077 0.666535 0.999868 0.667436 0.99923 0.666799 0.749868 0.665897 0.75077 0.666799 0.750132 0.667436 0.74923 0.666535 0.498674 0.668993 0.251326 0.668993 0.498674 0.997674 0.497924 0.998674 0.251326 0.997674 0.252076 0.998674 0.00075 0.334333 0.75075 0.334333 0.99925 0.334333 0.74925 0.334333 -0.00075 0.665667 -0.00075 0.334333</float_array>
<technique_common>
<accessor count="94" source="#Geometry-mesh019-Texture-array" stride="2">
<param name="S" type="float" />
<param name="T" type="float" />
</accessor>
</technique_common>
</source>
<vertices id="Geometry-mesh019-vertices">
<input semantic="POSITION" source="#Geometry-mesh019-positions" />
</vertices>
<polylist count="64" material="Material-outer">
<input semantic="VERTEX" source="#Geometry-mesh019-vertices" offset="0" />
<input semantic="NORMAL" source="#Geometry-mesh019-normals" offset="1" />
<input semantic="TEXCOORD" source="#Geometry-mesh019-Texture" offset="2" set="0" />
<vcount>4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4</vcount>
<p>46 0 0 41 0 1 40 0 2 47 0 3 35 1 4 2 1 5 1 1 6 32 1 7 49 2 8 34 2 9 33 2 10 50 2 11 42 3 12 37 3 13 36 3 14 43 3 15 44 4 16 35 4 4 34 4 9 45 4 17 8 5 18 15 5 19 14 5 20 9 5 21 38 6 22 33 6 10 32 6 7 39 6 23 58 7 24 61 7 25 60 7 26 59 7 27 12 8 28 3 8 29 2 8 5 13 8 30 4 9 31 11 9 32 10 9 33 5 9 34 47 1 3 14 1 20 13 1 30 44 1 16 54 10 35 57 10 36 56 10 37 55 10 38 62 11 39 49 11 8 48 11 40 63 11 41 0 12 42 7 12 43 6 12 44 1 12 6 61 13 25 46 13 0 45 13 17 62 13 39 25 14 45 28 14 46 31 14 47 26 14 48 43 1 15 10 1 33 9 1 21 40 1 2 50 15 11 53 15 49 52 15 50 51 15 51 41 16 1 58 16 24 57 16 36 42 16 12 21 17 52 24 17 53 27 17 54 22 17 55 29 18 56 17 18 57 16 18 58 30 18 59 39 1 23 6 1 44 5 1 34 36 1 14 37 19 13 54 19 35 53 19 49 38 19 22 18 20 60 20 20 61 23 20 62 19 20 63 0 21 64 1 21 65 2 21 66 3 21 67 4 22 68 5 22 69 6 22 70 7 22 71 8 23 18 9 23 21 10 23 33 11 23 72 12 24 73 13 24 30 14 24 20 15 24 19 16 25 74 17 25 75 18 25 76 19 25 77 20 26 78 21 26 79 22 26 80 23 26 81 24 27 82 25 27 45 26 27 48 27 27 54 28 28 46 29 28 83 30 28 59 31 28 47 32 29 7 33 29 10 34 29 9 35 29 4 36 30 14 37 30 13 38 30 22 39 30 23 40 31 2 41 31 1 42 31 12 43 31 15 44 32 16 45 32 17 46 32 0 47 32 3 48 33 40 49 33 8 50 33 11 51 33 51 52 34 50 53 34 49 54 34 35 55 34 38 56 35 37 57 35 36 58 35 24 59 35 27 60 36 26 61 36 25 62 36 39 63 36 41 14 1 20 47 1 3 40 1 2 9 1 21 2 1 5 35 1 4 44 1 16 13 1 30 6 1 44 39 1 23 32 1 7 1 1 6 10 1 33 43 1 15 36 1 14 5 1 34 62 37 39 45 37 17 34 37 9 49 37 8 50 38 11 33 38 10 38 38 22 53 38 49 54 39 35 37 39 13 42 39 12 57 39 36 58 40 24 41 40 1 46 40 0 61 40 25 21 41 84 20 41 85 52 41 50 55 41 38 17 41 86 29 41 83 63 41 41 48 41 40 24 41 82 21 41 84 55 41 38 56 41 37 18 41 87 17 41 86 48 41 40 51 41 51 25 41 45 24 41 82 56 41 37 59 41 27 20 41 85 18 41 87 51 41 51 52 41 50 28 41 46 25 41 45 59 41 27 60 41 26 29 41 83 28 41 46 60 41 26 63 41 41 30 39 59 16 39 58 3 39 88 12 39 73 19 40 63 23 40 62 7 40 89 0 40 90 31 19 47 30 19 59 12 19 73 15 19 19 22 37 55 27 37 54 11 37 72 4 37 91 26 38 48 31 38 47 15 38 19 8 38 18 16 16 58 19 16 92 0 16 93 3 16 88 27 2 54 26 2 48 8 2 18 11 2 72 23 13 62 22 13 55 4 13 91 7 13 89</p>
</polylist>
</mesh>
</geometry>
<geometry id="Geometry-mesh020" name="inner_box">
<mesh>
<source id="Geometry-mesh020-positions" name="positions">
<float_array id="Geometry-mesh020-positions-array" count="72">-0.33204 -0.497 -0.33504 -0.33204 -0.5 -0.33204 -0.33504 -0.497 -0.33204 0.33504 -0.497 -0.33204 0.33204 -0.5 -0.33204 0.33204 -0.497 -0.33504 0.33204 -0.497 0.33504 0.33204 -0.5 0.33204 0.33504 -0.497 0.33204 -0.33204 -0.5 0.33204 -0.33204 -0.497 0.33504 -0.33504 -0.497 0.33204 -0.33204 0.5 -0.33204 -0.33204 0.497 -0.33504 -0.33504 0.497 -0.33204 0.33204 0.5 -0.33204 0.33504 0.497 -0.33204 0.33204 0.497 -0.33504 0.33204 0.5 0.33204 0.33204 0.497 0.33504 0.33504 0.497 0.33204 -0.33504 0.497 0.33204 -0.33204 0.497 0.33504 -0.33204 0.5 0.33204</float_array>
<technique_common>
<accessor count="24" source="#Geometry-mesh020-positions-array" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020-normals" name="normals">
<float_array id="Geometry-mesh020-normals-array" count="78">0 -0.707107 0.707107 -0.707107 -0 -0.707107 0.707107 -0.707107 0 -0.707107 -0.707107 -0 -0 -0.707107 -0.707107 -0 0.707107 0.707107 0.707107 0.707107 0 -0.707107 0.707107 0 -0.707107 0 0.707107 0 0.707107 -0.707107 0.707107 0 0.707107 0.707107 0 -0.707107 -0.57735 -0.57735 -0.57735 0.57735 -0.57735 -0.57735 0.57735 -0.57735 0.57735 -0.57735 -0.57735 0.57735 -0.57735 0.57735 -0.57735 0.57735 0.57735 -0.57735 0.57735 0.57735 0.57735 -0.57735 0.57735 0.57735 -1 0 0 0 0 -1 1 -0 0 0 0 1 0 1 0 0 -1 0</float_array>
<technique_common>
<accessor count="26" source="#Geometry-mesh020-normals-array" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<source id="Geometry-mesh020-Texture" name="Texture">
<float_array id="Geometry-mesh020-Texture-array" count="48">0.344393 0.238915 0.405607 0.238915 0.405607 0.239063 0.344393 0.239063 0.344393 0.905463 0.344393 0.0945372 0.344375 0.0945804 0.344375 0.90542 0.405607 0.0944181 0.405625 0.0945804 0.405625 0.23902 0.344375 0.23902 0.344393 0.0944182 0.405607 0.0945372 0.344393 0.760937 0.405607 0.760937 0.405607 0.761085 0.344393 0.761085 0.405625 0.76098 0.405625 0.90542 0.405607 0.905582 0.344393 0.905582 0.344375 0.76098 0.405607 0.905463</float_array>
<technique_common>
<accessor count="24" source="#Geometry-mesh020-Texture-array" stride="2">
<param name="S" type="float" />
<param name="T" type="float" />
</accessor>
</technique_common>
</source>
<vertices id="Geometry-mesh020-vertices">
<input semantic="POSITION" source="#Geometry-mesh020-positions" />
</vertices>
<polylist count="26" material="Material-inner">
<input semantic="VERTEX" source="#Geometry-mesh020-vertices" offset="0" />
<input semantic="NORMAL" source="#Geometry-mesh020-normals" offset="1" />
<input semantic="TEXCOORD" source="#Geometry-mesh020-Texture" offset="2" set="0" />
<vcount>4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 4 4 4 4 4 4</vcount>
<p>9 0 0 7 0 1 6 0 2 10 0 3 13 1 4 0 1 5 2 1 6 14 1 7 7 2 1 4 2 8 3 2 9 8 2 10 11 3 11 2 3 6 1 3 12 9 3 0 4 4 8 1 4 12 0 4 5 5 4 13 22 5 14 19 5 15 18 5 16 23 5 17 20 6 18 16 6 19 15 6 20 18 6 16 23 7 17 12 7 21 14 7 7 21 7 22 21 8 22 11 8 11 10 8 3 22 8 14 17 9 23 13 9 4 12 9 21 15 9 20 19 10 15 6 10 2 8 10 10 20 10 18 16 11 19 3 11 9 5 11 13 17 11 23 0 12 5 1 12 12 2 12 6 3 13 9 4 13 8 5 13 13 6 14 2 7 14 1 8 14 10 9 15 0 10 15 3 11 15 11 12 16 21 13 16 4 14 16 7 15 17 20 16 17 19 17 17 23 18 18 16 19 18 15 20 18 18 21 19 22 22 19 14 23 19 17 2 20 6 11 20 11 21 20 22 14 20 7 5 21 13 0 21 5 13 21 4 17 21 23 8 22 10 3 22 9 16 22 19 20 22 18 10 23 3 6 23 2 19 23 15 22 23 14 12 24 21 23 24 17 18 24 16 15 24 20 4 25 8 7 25 1 9 25 0 1 25 12</p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_lights>
<light id="Light-polyRender005" name="Render">
<technique_common>
<ambient>
<color sid="ambient_light_rgb">0 0 0</color>
</ambient>
</technique_common>
</light>
<light id="Light-sunLight011" name="Directional_Light">
<technique_common>
<directional>
<color sid="directional_light_rgb">1 1 1</color>
</directional>
</technique_common>
</light>
</library_lights>
<library_visual_scenes>
<visual_scene id="DefaultScene">
<node id="polyRender005" name="Render" type="NODE">
<instance_light url="#Light-polyRender005" />
</node>
<node id="Geometry-mesh019Node" name="outer_box" type="NODE">
<instance_geometry url="#Geometry-mesh019">
<bind_material>
<technique_common>
<instance_material symbol="Material-outer" target="#Material-outer" />
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Geometry-mesh020Node" name="inner_box" type="NODE">
<translate sid="translation021">0 0 0</translate>
<rotate sid="rotation022Y">0 1 0 0</rotate>
<rotate sid="rotation022X">1 0 0 0</rotate>
<rotate sid="rotation022Z">0 0 1 0</rotate>
<instance_geometry url="#Geometry-mesh020">
<bind_material>
<technique_common>
<instance_material symbol="Material-inner" target="#Material-inner" />
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Camera-camera002Node" name="Camera" type="NODE">
<translate sid="translation003">0 0.75 4</translate>
<rotate sid="rotation004Y">0 1 0 0</rotate>
<rotate sid="rotation004X">1 0 0 -5</rotate>
<rotate sid="rotation004Z">0 0 1 0</rotate>
<instance_camera url="#Camera-camera002" />
</node>
<node id="Light-sunLight011Node" name="Directional_Light" type="NODE">
<translate sid="translation013">-2 2 2</translate>
<rotate sid="rotation014Y">0 1 0 -45</rotate>
<rotate sid="rotation014X">1 0 0 -30</rotate>
<rotate sid="rotation014Z">0 0 1 0</rotate>
<instance_light url="#Light-sunLight011" />
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#DefaultScene" />
</scene>
</COLLADA>

View File

@ -199,16 +199,17 @@ define([
* @param {WebGLRenderingContext} gl The current WebGL context.
* @param {String|ImageSource} imageSource The image source, either a {@link ImageSource} or a String
* giving the URL of the image.
* @param {GL.enum} wrapMode Optional. Specifies the wrap mode of the texture. Defaults to gl.CLAMP_TO_EDGE
* @returns {Texture} The {@link Texture} created for the image if the specified image source is an
* {@link ImageSource}, otherwise null.
*/
GpuResourceCache.prototype.retrieveTexture = function (gl, imageSource) {
GpuResourceCache.prototype.retrieveTexture = function (gl, imageSource, wrapMode) {
if (!imageSource) {
return null;
}
if (imageSource instanceof ImageSource) {
var t = new Texture(gl, imageSource.image);
var t = new Texture(gl, imageSource.image, wrapMode);
this.putResource(imageSource.key, t, t.size);
return t;
}
@ -223,7 +224,7 @@ define([
image.onload = function () {
Logger.log(Logger.LEVEL_INFO, "Image retrieval succeeded: " + imageSource);
var texture = new Texture(gl, image);
var texture = new Texture(gl, image, wrapMode);
cache.putResource(imageSource, texture, texture.size);

View File

@ -37,7 +37,7 @@ define([
* @param {Position} position The model's geographic position.
* @param {Object} config Configuration options for the loader.
* <ul>
* <li>filePath - the path to the collada file</li>
* <li>dirPath - the path to the directory where the collada file is located</li>
* </ul>
*/
var ColladaLoader = function (position, config) {
@ -49,7 +49,7 @@ define([
this.position = position;
this.filePath = '/';
this.dirPath = '/';
this.init(config);
};
@ -58,17 +58,17 @@ define([
* Initialization of the ColladaLoader
* @param {Object} config Configuration options for the loader.
* <ul>
* <li>filePath - the path to the collada file</li>
* <li>dirPath - the path to the directory where the collada file is located</li>
* </ul>
*/
ColladaLoader.prototype.init = function (config) {
if (config) {
this.filePath = config.filePath || '/';
this.dirPath = config.dirPath || '/';
}
this.scene = {
type: "SceneTree",
filePath: this.filePath,
dirPath: this.dirPath,
images: {},
metadata: {},
materials: {},
@ -88,7 +88,7 @@ define([
ColladaLoader.prototype.load = function (url, cb) {
if (url.indexOf("://") === -1) {
url = this.filePath + url;
url = this.dirPath + url;
}
ColladaUtils.fetchFile(url, function (data) {

View File

@ -56,7 +56,7 @@ define([
this._materials = {};
this._images = {};
this._upAxis = '';
this._filePath = '';
this._dirPath = '';
// Documented in defineProperties below.
this._xRotation = 0;
@ -72,6 +72,13 @@ define([
// Documented in defineProperties below.
this._localTransforms = true;
// Documented in defineProperties below.
this._useTexturePaths = true;
// Documented in defineProperties below.
this._nodesToHide = [];
this._hideNodes = false;
this.setSceneData(sceneData);
// Documented in defineProperties below.
@ -83,6 +90,10 @@ define([
// Documented in defineProperties below.
this._normalMatrix = Matrix.fromIdentity();
this._texCoordMatrix = Matrix.fromIdentity().setToUnitYFlip();
this._activeTexture = null;
};
ColladaScene.prototype = Object.create(Renderable.prototype);
@ -175,16 +186,16 @@ define([
},
/**
* The path to the collada file.
* The path to the directory of the collada file.
* @memberof ColladaScene.prototype
* @type {String}
*/
filePath: {
dirPath: {
get: function () {
return this._filePath;
return this._dirPath;
},
set: function (value) {
this._filePath = value;
this._dirPath = value;
}
},
@ -307,7 +318,9 @@ define([
},
/**
* Force the use of the nodes transformation info
* Force the use of the nodes transformation info. Some 3d software may break the transformations when
* importing/exporting models to collada format. Set to false to ignore the the nodes transformation.
* Only use this option if the model does not render properly.
* @memberof ColladaScene.prototype
* @default true
* @type {Boolean}
@ -319,6 +332,51 @@ define([
set: function (value) {
this._localTransforms = value;
}
},
/**
* Force the use of the texture path specified in the collada file. Set to false to ignore the paths of the
* textures in the collada file and instead get the textures from the same dir as the collada file.
* @memberof ColladaScene.prototype
* @default true
* @type {Boolean}
*/
useTexturePaths: {
get: function () {
return this._useTexturePaths;
},
set: function (value) {
this._useTexturePaths = value;
}
},
/**
* An array of node id's to not render.
* @memberof ColladaScene.prototype
* @type {String[]}
*/
nodesToHide: {
get: function () {
return this._nodesToHide;
},
set: function (value) {
this._nodesToHide = value;
}
},
/**
* Set to true to force the renderer to not draw the nodes passed to the nodesToHide list.
* @memberof ColladaScene.prototype
* @default false
* @type {Boolean}
*/
hideNodes: {
get: function () {
return this._hideNodes;
},
set: function (value) {
this._hideNodes = value;
}
}
});
@ -331,7 +389,7 @@ define([
this.materials = sceneData.materials;
this.images = sceneData.images;
this.upAxis = sceneData.metadata.up_axis;
this.filePath = sceneData.filePath;
this.dirPath = sceneData.dirPath;
}
};
@ -340,6 +398,10 @@ define([
var orderedScene;
if (!this.enabled) {
return;
}
if (this.lastFrameTime !== dc.timestamp) {
orderedScene = this.makeOrderedRenderable(dc);
}
@ -422,29 +484,34 @@ define([
// Internal. Intentionally not documented.
ColladaScene.prototype.traverseNodeTree = function (dc, node) {
if (node.mesh) {
var meshKey = node.mesh;
var buffers = this.meshes[meshKey].buffers;
var renderNode = this.mustRenderNode(node.id);
for (var i = 0, bufLen = buffers.length; i < bufLen; i++) {
if (renderNode) {
var materialBuf = buffers[i].material;
if (node.mesh) {
var meshKey = node.mesh;
var buffers = this.meshes[meshKey].buffers;
for (var j = 0; j < node.materials.length; j++) {
if (materialBuf === node.materials[j].symbol) {
var materialKey = node.materials[j].id;
break;
for (var i = 0, bufLen = buffers.length; i < bufLen; i++) {
var materialBuf = buffers[i].material;
for (var j = 0; j < node.materials.length; j++) {
if (materialBuf === node.materials[j].symbol) {
var materialKey = node.materials[j].id;
break;
}
}
var material = this.materials[materialKey];
this.draw(dc, buffers[i], material, node.worldMatrix, node.normalMatrix);
}
var material = this.materials[materialKey];
this.draw(dc, buffers[i], material, node.worldMatrix, node.normalMatrix);
}
}
for (var k = 0; k < node.children.length; k++) {
this.traverseNodeTree(dc, node.children[k]);
for (var k = 0; k < node.children.length; k++) {
this.traverseNodeTree(dc, node.children[k]);
}
}
};
@ -462,7 +529,7 @@ define([
this.applyColor(dc, material);
var hasTexture = (material && material.textures != null && buffers.uvs && buffers.uvs.length);
var hasTexture = (material && material.textures != null && buffers.uvs && buffers.uvs.length > 0);
if (hasTexture) {
this.applyTexture(dc, buffers, material);
}
@ -472,7 +539,7 @@ define([
this.applyLighting(dc, buffers);
}
this.applyMatrix(dc, hasLighting, nodeWorldMatrix, nodeNormalMatrix);
this.applyMatrix(dc, hasLighting, hasTexture , nodeWorldMatrix, nodeNormalMatrix);
this.applyIndices(dc, buffers);
@ -550,7 +617,8 @@ define([
var textureBound, vboId,
gl = dc.currentGlContext,
program = dc.currentProgram;
program = dc.currentProgram,
wrapMode;
if (material.textures.diffuse) {
var imageKey = material.textures.diffuse.mapId;
@ -559,14 +627,15 @@ define([
imageKey = material.textures.reflective.mapId;
}
var image = this.images[imageKey].filename || this.images[imageKey].path;
var image = this.useTexturePaths ? this.images[imageKey].path : this.images[imageKey].filename;
buffers.activeTexture = dc.gpuResourceCache.resourceForKey(this.filePath + image + "");
if (!buffers.activeTexture) {
buffers.activeTexture = dc.gpuResourceCache.retrieveTexture(gl, this.filePath + image + "");
this._activeTexture = dc.gpuResourceCache.resourceForKey(this.dirPath + image + "");
if (!this._activeTexture) {
wrapMode = buffers.isClamp ? gl.CLAMP_TO_EDGE : gl.REPEAT;
this._activeTexture = dc.gpuResourceCache.retrieveTexture(gl, this.dirPath + image + "", wrapMode);
}
textureBound = this._activeTexture && this._activeTexture.bind(dc);
textureBound = buffers.activeTexture && buffers.activeTexture.bind(dc);
if (textureBound) {
if (!buffers.texCoordsVboCacheKey) {
buffers.texCoordsVboCacheKey = dc.gpuResourceCache.generateCacheKey();
@ -586,16 +655,6 @@ define([
buffers.refreshTexCoordBuffer = false;
}
if (buffers.isClamp) {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
}
else {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
}
program.loadTextureEnabled(gl, true);
gl.enableVertexAttribArray(program.vertexTexCoordLocation);
gl.vertexAttribPointer(program.vertexTexCoordLocation, 2, gl.FLOAT, false, 0, 0);
@ -635,7 +694,7 @@ define([
};
// Internal. Intentionally not documented.
ColladaScene.prototype.applyMatrix = function (dc, hasLighting, nodeWorldMatrix, nodeNormalMatrix) {
ColladaScene.prototype.applyMatrix = function (dc, hasLighting, hasTexture, nodeWorldMatrix, nodeNormalMatrix) {
var mvpMatrix = Matrix.fromIdentity();
@ -662,6 +721,11 @@ define([
dc.currentProgram.loadModelviewInverse(dc.currentGlContext, normalMatrix);
}
if (hasTexture && this._activeTexture){
dc.currentProgram.loadTextureMatrix(dc.currentGlContext, this._texCoordMatrix);
this._activeTexture = null;
}
dc.currentProgram.loadModelviewProjection(dc.currentGlContext, mvpMatrix);
};
@ -715,31 +779,17 @@ define([
dc.bindProgram(null);
};
// Internal. Intentionally not documented.
ColladaScene.prototype.computeRotationMatrix = function () {
this.rotationMatrix = Matrix.fromIdentity();
this.rotationMatrix.multiplyByRotation(1, 0, 0, this.xRotation);
this.rotationMatrix.multiplyByRotation(0, 1, 0, this.yRotation);
this.rotationMatrix.multiplyByRotation(0, 0, 1, this.zRotation);
};
// Internal. Intentionally not documented.
ColladaScene.prototype.computeTransformationMatrix = function (globe) {
this.transformationMatrix = Matrix.fromIdentity();
//this.computeRotationMatrix();
this.transformationMatrix.multiplyByLocalCoordinateTransform(this.placePoint, globe);
this.transformationMatrix.multiplyByRotation(1, 0, 0, this.xRotation);
this.transformationMatrix.multiplyByRotation(0, 1, 0, this.yRotation);
this.transformationMatrix.multiplyByRotation(0, 0, 1, this.zRotation);
//this.transformationMatrix.multiplyMatrix(this.rotationMatrix);
this.transformationMatrix.multiplyByScale(this.scale, this.scale, this.scale);
this.computeNormalMatrix();
@ -760,6 +810,16 @@ define([
this.normalMatrix.multiplyByRotation(0, 0, -1, rotAngles[2]);
};
// Internal. Intentionally not documented.
ColladaScene.prototype.mustRenderNode = function (nodeId) {
var draw = true;
if (this.hideNodes) {
var pos = this.nodesToHide.indexOf(nodeId);
draw = (pos === -1);
}
return draw;
};
return ColladaScene;
});

View File

@ -23,9 +23,11 @@ define([
* @classdesc Represents a WebGL texture. Applications typically do not interact with this class.
* @param {WebGLRenderingContext} gl The current WebGL rendering context.
* @param {Image} image The texture's image.
* @param {GL.enum} wrapMode Optional. Specifies the wrap mode of the texture. Defaults to gl.CLAMP_TO_EDGE
* @throws {ArgumentError} If the specified WebGL context or image is null or undefined.
*/
var Texture = function (gl, image) {
var Texture = function (gl, image, wrapMode) {
if (!gl) {
throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "Texture", "constructor",
"missingGlContext"));
@ -36,30 +38,39 @@ define([
"missingImage"));
}
if (!wrapMode) {
wrapMode = gl.CLAMP_TO_EDGE;
}
var textureId = gl.createTexture(),
isPowerOfTwo = (WWMath.isPowerOfTwo(image.width) && WWMath.isPowerOfTwo(image.height));
this.originalImageWidth = image.width;
this.originalImageHeight = image.height;
if (wrapMode === gl.REPEAT && !isPowerOfTwo) {
image = this.resizeImage(image);
isPowerOfTwo = true;
}
this.imageWidth = image.width;
this.imageHeight = image.height;
this.size = image.width * image.height * 4;
this.originalImageWidth = this.imageWidth;
this.originalImageHeight = this.imageHeight;
gl.bindTexture(gl.TEXTURE_2D, textureId);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER,
isPowerOfTwo ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER,
gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S,
gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T,
gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapMode);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapMode);
// Setup 4x anisotropic texture filtering when this feature is available.
// https://www.khronos.org/registry/webgl/extensions/EXT_texture_filter_anisotropic
var ext = (
gl.getExtension("EXT_texture_filter_anisotropic") ||
gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"));
gl.getExtension("EXT_texture_filter_anisotropic") ||
gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"));
if (ext) {
gl.texParameteri(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, 4);
}
@ -101,5 +112,19 @@ define([
return true;
};
/**
* Resizes an image to a power of two.
* @param {Image} image The image to resize.
*/
Texture.prototype.resizeImage = function (image) {
var canvas = document.createElement("canvas");
canvas.width = WWMath.powerOfTwoFloor(image.width);
canvas.height = WWMath.powerOfTwoFloor(image.height);
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
return canvas;
};
return Texture;
});

View File

@ -411,6 +411,10 @@ define([
// Internal function. Intentionally not documented.
SurfaceShape.prototype.render = function(dc) {
if (!this.enabled) {
return;
}
this.layer = dc.currentLayer;
this.prepareBoundaries(dc);

View File

@ -60,7 +60,7 @@ define([
if (typeof Math.cbrt == 'function') {
return Math.cbrt(x);
} else {
return Math.pow(x, 1/3);
return Math.pow(x, 1 / 3);
}
},
@ -769,6 +769,16 @@ define([
WWMath.clamp(latRadians * Angle.RADIANS_TO_DEGREES, -90, 90),
WWMath.clamp(lonRadians * Angle.RADIANS_TO_DEGREES, -180, 180)
];
},
/**
* Returns the value that is the nearest power of 2 less than or equal to the given value.
* @param {Number} value the reference value. The power of 2 returned is less than or equal to this value.
* @returns {Number} the value that is the nearest power of 2 less than or equal to the reference value
*/
powerOfTwoFloor: function (value) {
var power = Math.floor(Math.log(value) / Math.log(2));
return Math.pow(2, power);
}
};