Files
cocos4/playground/audio.html
T
Yun Hsiao Wu d7ee4b6aba builtin UBO pipe (#3931)
* shorter effect name

* audio adapt

* builtin UBO pipe

* modify global ubo in pipeline
2019-02-28 11:50:56 +08:00

81 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>audio</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="./camera.js"></script>
<script>
const $body = document.body;
const bcr = $body.getBoundingClientRect();
const canv = document.getElementById('canvas');
canv.width = bcr.width;
canv.height = bcr.height;
window.addEventListener('resize', () => {
const bcr = $body.getBoundingClientRect();
cc.director.root.resize(bcr.width, bcr.height);
});
const imgs = canv.getElementsByTagName('img');
function createTexture(idx) {
const textureAsset = new cc.Texture2D();
textureAsset.image = new cc.ImageAsset(imgs[idx]);
return textureAsset;
}
const geomList = ['box', 'sphere', 'cylinder', 'cone', 'torus', 'capsule'];
function onStart() {
const root = cc.director.root;
const scene = new cc.Scene();
const cameraNode = new cc.Node('Camera');
cameraNode.parent = scene;
cameraNode.setPosition(20, 0, 115);
cameraNode.setRotationFromEuler(0, 30, 0);
cameraNode.addComponent(cc.CameraComponent);
cameraNode.addComponent(FirstPersonCamera);
cc.AssetLibrary.init({
libraryPath: 'resources',
rawAssetsBase: 'resources',
rawAssets: {
assets: {
"bf43d245-3a77-4b55-bc7f-9a3bb09544d0": ["morceaux", "cc.AudioClip"],
"da0936bf-2873-4bc0-ab91-7aa11a6b7d23": ["nocturne", "cc.AudioClip"]
}
}
});
cc.loader.loadRes('nocturne', cc.AudioClip, (err, asset) => {
debugger
});
cc.director.runSceneImmediate(scene);
}
cc.game.run({ id: 'canvas' }, onStart);
</script>
</body>
</html>