Skip to content

Instantly share code, notes, and snippets.

@JScott
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JScott/06157326c997500a91b8 to your computer and use it in GitHub Desktop.
Save JScott/06157326c997500a91b8 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<script>
var api_url = "http://direct.dev.mvml.net:6865/";
var post = new XMLHttpRequest();
post.open("POST", url, true);
post.setRequestHeader("Content-Type", "text/mvml");
post.onreadystatechange = function() {
if(post.readyState == 4 && post.status == 200) {
document.write(post.responseText);
document.close();
}
}
window.onload = function() {
post.send(document.getElementsByTagName("mvml")[0].innerHTML);
}
</script>
</head>
<mvml>
---
title: JavaScript test
player:
move_speed: 15
turn_speed: 1.5
min_jump_speed: 0
max_jump_speed: 20
start: (0,0,30)
gravity: 30
scene:
- primitive: sphere
position: (5, 0, 0)
- primitive: box
position: (0, 0, -20)
scale: (30,10,1)
color: 0x00ff00
- primitive: box
position: (-5, 1, 0)
scale: (2,2,4)
rotation: (0,-30,0)
color: 0x00ffff
physics: off
- primitive: plane
position: (0,-2, 0)
scale: (200,200,1)
rotation: (-90,0,0)
color: green
</mvml>
</html>
These files show example pages that use the hosted MVML API with HTML5 and JS.
Just copy these files onto your page and let the API handle the rest.
You can either edit the MVML in-line or as a separate file.
<!DOCTYPE html>
<html lang="en">
<head>
<script>
var mvml_file_url = "http://dev.mvml.net/mvml/spec.mvml";
var api_url = "http://direct.dev.mvml.net:6865/";
var get = new XMLHttpRequest();
get.open("GET", mvml_file_url, true);
var post = new XMLHttpRequest();
post.open("POST", api_url, true);
post.setRequestHeader("Content-Type", "text/mvml");
post.onreadystatechange = function() {
if(post.readyState == 4 && post.status == 200) {
document.write(post.responseText);
document.close();
}
}
get.onreadystatechange = function() {
if(get.readyState == 4 && get.status == 200) {
post.send(get.responseText);
}
}
window.onload = function() {
get.send();
}
</script>
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment