Three.js App.Player Examples
An example of the App.Player class. It is the three.js class which play the scene you edit in the three.js editor. Here are 4 examples that you can play.
by jetienne
HTML
<script src="http://threejs.org/build/three.min.js"></script>
<script src="http://threejs.org/editor/js/libs/app.js"></script>
<body>
<div id="info">three.js standalone player - able to play examples app from <a href='http://threejs.org/editor'>three.js editor</a>
<br/>examples : <a href='javascript:void(0)' onClick='load("http://threejs.org/editor/examples/arkanoid.app.json")'>arkanoid</a> - <a href='javascript:void(0)' onClick='load("http://threejs.org/editor/examples/camera.app.json")'>camera</a> - <a href='javascript:void(0)' onClick='load("http://threejs.org/editor/examples/particles.app.json")'>particles</a> - <a href='javascript:void(0)' onClick='load("http://threejs.org/editor/examples/pong.app.json")'>pong</a>
</div>
</body>
CSS
body {
background:#777;
padding:0;
margin:0;
font-weight: bold;
overflow:hidden;
}
#info {
position: absolute;
top: 0px;
width: 100%;
color: #ffffff;
padding: 5px;
font-family:Monospace;
font-size:13px;
text-align:center;
z-index:1000;
}
a {
color: #ffffff;
}
JavaScript
var appPlayer = new APP.Player();
var isRunning = false
var appUrl = location.hash.substr(1) || 'http://threejs.org/editor/examples/arkanoid.app.json'
load(appUrl)
function load(appUrl) {
console.log('load', appUrl)
var loader = new THREE.XHRLoader();
loader.load(appUrl, function (text) {
if (isRunning) {
appPlayer.stop();
document.body.removeChild(appPlayer.dom)
isRunning = false
}
var json = JSON.parse(text);
json.project = {
vr: false
}
appPlayer.load(json)
appPlayer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(appPlayer.dom)
appPlayer.play();
isRunning = true
});
location.hash = appUrl
}
// export load globally
window.load = load