mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 06:44:56 +08:00
96 lines
2.3 KiB
HTML
96 lines
2.3 KiB
HTML
<html>
|
|
<script src="../../build/spine-webgl.js"></script>
|
|
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
|
<style>
|
|
/* Dead Simple Grid (c) 2015 Vladimir Agafonkin */
|
|
|
|
.row .row { margin: 0 -1.5em; }
|
|
.col { padding: 0 1.5em; }
|
|
|
|
.row:after {
|
|
content: "";
|
|
clear: both;
|
|
display: table;
|
|
}
|
|
|
|
@media only screen { .col {
|
|
float: left;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
}}
|
|
|
|
@media only screen and (min-width: 30em) {
|
|
.content { width: 50%; height: 100%; padding: 0 }
|
|
.sidebar { width: 50%; height: 100%; padding: 0 }
|
|
}
|
|
body {
|
|
margin: 0;
|
|
}
|
|
iframe {
|
|
width: 100%;
|
|
height: 100%;
|
|
border:none;
|
|
}
|
|
.panel {
|
|
width: 100%;
|
|
height: 50%;
|
|
}
|
|
.buttons {
|
|
position: absolute;
|
|
top: 5; left: 5;
|
|
}
|
|
</style>
|
|
<body>
|
|
<div class="buttons">
|
|
<button id="playButton">Run</button>
|
|
<button id="stopButton">Stop</button>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col content">
|
|
<iframe id="iframe"></iframe>
|
|
</div>
|
|
<div class="col sidebar">
|
|
<div id="codeJs" class="panel"></div>
|
|
<div id="codeHtml" class="panel"></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
|
|
<script id="initialJs" type="text/plain">
|
|
var canvas = document.getElementById("canvas");
|
|
var config = { alpha: false };
|
|
var context = new spine.webgl.ManagedWebGLRenderingContext(canvas, config);
|
|
var gl = context.gl;
|
|
|
|
function render() {
|
|
gl.clearColor(0.2, 0.2, 0.2, 1);
|
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
|
|
requestAnimationFrame(render);
|
|
}
|
|
|
|
requestAnimationFrame(render);
|
|
</script>
|
|
|
|
<script src="js/ace.js" type="text/javascript" charset="utf-8"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
var editorJs = ace.edit("codeJs");
|
|
editorJs.setTheme("ace/theme/monokai");
|
|
editorJs.getSession().setMode("ace/mode/javascript");
|
|
editorJs.setValue(document.getElementById("initialJs").innerHTML);
|
|
|
|
var editorHtml = ace.edit("codeHtml");
|
|
editorHtml.setTheme("ace/theme/monokai");
|
|
editorHtml.getSession().setMode("ace/mode/html");
|
|
editorHtml.setValue('<script src="../../build/spine-webgl.js"><\/script>\n<canvas id="canvas" style="width: 100%; height: 98vh;"></canvas>');
|
|
|
|
$("#playButton").click(function() {
|
|
var iframe = document.getElementById("iframe");
|
|
var source = "<html><body>" + editorHtml.getValue() + "<script>" + editorJs.getValue() + "<\/script></body></html>";
|
|
iframe.srcdoc = source;
|
|
});
|
|
});
|
|
</script>
|
|
</html> |