Files
cocos4/playground/savePrimitivesAsWavefrontOBJ.html
T
Yun Hsiao Wu 6cffc59376 fix primitives (#3613)
* fix primitives

* defines & view clear color
2018-12-11 10:43:07 +08:00

54 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>spec-scroll-view</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #333;
margin: 0px;
overflow: hidden;
}
.fit {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body class="fit">
<canvas id="canvas" tabindex="-1" class="fit"></canvas>
<script src="../bin/cocos-3d.dev.js"></script>
<!-- <script src="./loadScene.js"></script> -->
<script>
function write(name) {
let text = cc.primitives.toWavefrontOBJ(cc.primitives[name](), 100);
let blob = new Blob([text], { type: 'text/plain' });
let anchor = document.createElement('a');
anchor.download = `${name}.obj`;
anchor.href = (window.webkitURL || window.URL).createObjectURL(blob);
anchor.dataset.downloadurl = ['text/plain', anchor.download, anchor.href].join(':');
anchor.click();
}
function onStart() {
// write('box');
// write('sphere');
// write('cylinder');
write('cone');
// write('capsule');
// write('torus');
// write('plane');
// write('quad');
}
cc.game.run({id:'canvas'}, onStart);
</script>
</body>
</html>