代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<body>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Object.values%2CPromise"></script>
<script src="../build/v3d.js"></script>
<script src="./js/controls/OrbitControls.js"></script>
<script src="./js/loaders/GLTFLoader.js"></script>
<script src="./js/loaders/RGBELoader.js"></script>
<script>
var camera, scene, renderer;
var controls;
init();
animate();
function init() {
renderer = new v3d.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputEncoding = v3d.sRGBEncoding;
renderer.toneMapping = v3d.ACESFilmicToneMapping;
document.body.appendChild(renderer.domElement);
scene = new v3d.Scene();
camera = new v3d.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 20);
camera.position.set(1.5, 0.2, 1.5);
controls = new v3d.OrbitControls(camera, document.body);
controls.autoRotate = true;
controls.autoRotateSpeed = - 1.0;
var pmremGenerator = new v3d.PMREMGenerator(renderer);
pmremGenerator.compileEquirectangularShader();
new v3d.RGBELoader()
.setDataType(v3d.UnsignedByteType)
.load('./textures/equirectangular/venice_sunset_1k.hdr', function(texture) {
var envMap = pmremGenerator.fromEquirectangular(texture).texture;
scene.background = envMap;
scene.environment = envMap;
});
var url = './models/gltf/BoomBox/glTF-Binary/BoomBox.glb';
var loader = new v3d.GLTFLoader();
loader.load(url, function(gltf) {
var model = gltf.scene;
model.rotation.y = Math.PI;
model.scale.setScalar(50);
scene.add(model);
});
window.addEventListener('resize', onWindowResize, false);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
//
function animate() {
renderer.setAnimationLoop(animate);
controls.update();
renderer.render(scene, camera);
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。