Commit aa3b7061 authored by 刘子逸's avatar 刘子逸

魔方初始化

parents
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./js/WebGL/three.min.js"></script>
<title>魔方小玩具</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
#webgl-canvas {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<div id="webgl-canvas"></div>
</body>
<script>
const canvas = document.querySelector("#webgl-canvas");
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, canvas.offsetWidth / canvas.offsetHeight, 0.5, 1000);
camera.position.set(100, 100, 200);
camera.lookAt(new THREE.Vector3(0, 0, 0));
const renderer = new THREE.WebGLRenderer({
antialias: true
});
renderer.setSize(canvas.offsetWidth, canvas.offsetHeight);
renderer.setClearColor(0xEEEEEE);
canvas.appendChild(renderer.domElement);
const light = new THREE.AmbientLight(0xFFFFFF, 1);
scene.add(light);
const posList = createPosList();
const boxGeo = new THREE.BoxGeometry(20, 20, 20);
const boxMat = new THREE.MeshStandardMaterial({
vertexColors: THREE.FaceColors
});
renderAll();
function renderAll() {
renderer.render(scene, camera);
requestAnimationFrame(renderAll)
}
</script>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment