Skip to content

Commit

Permalink
Merged in ogre2json (pull request #165)
Browse files Browse the repository at this point in the history
Client-side Ogre material parser

Approved-by: Ian Chen <ichen@osrfoundation.org>
  • Loading branch information
chapulina committed May 26, 2018
2 parents d4c3a37 + cef5d39 commit bffbff6
Show file tree
Hide file tree
Showing 12 changed files with 17,972 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"THREE": true,
"ColladaLoader2": true,
"requestAnimationFrame": true,
"xml2json": true
"xml2json": true,
"_": true
},
"curly": true,
"eqeqeq": true,
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-jsdoc');

Expand Down
29 changes: 28 additions & 1 deletion examples/view_sdf_from_url.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ <h4>SDF model URL</h4>

var scene;
var sdfparser;
var ogre2json;
var resourcesInput;
var sdfInput;
var resourceList;
Expand All @@ -94,6 +95,8 @@ <h4>SDF model URL</h4>
sdfparser = new GZ3D.SdfParser(scene);
sdfparser.usingFilesUrls = true;

ogre2json = new GZ3D.Ogre2Json();

// Append to dom
var container = document.getElementById('container');
container.appendChild(scene.getDomElement());
Expand Down Expand Up @@ -147,7 +150,31 @@ <h4>SDF model URL</h4>
// Callback when Add URL is pressed
function addURL()
{
sdfparser.addUrl(resourcesInput.value);
var url = resourcesInput.value;

if (url.length === 0)
{
return;
}
else if (url.indexOf('.material') > 0)
{
ogre2json.LoadFromUrl(url)
.then((success) =>
{
if (!success)
{
alert('Failed to load material file.');
}
})
.catch((error) =>
{
alert('Failed to load material file: ' + error);
})
}
else
{
sdfparser.addUrl(url);
}

resourceList.innerHTML = resourceList.innerHTML + "<br>" + resourcesInput.value;
}
Expand Down
Loading

0 comments on commit bffbff6

Please sign in to comment.