three打造一个3d月球

代码语言:html

所属分类:三维

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">


    <style>
        body {
            margin: 0;
        }

        canvas {
            width: 100%;
            height: 100%;
            vertical-align: bottom;
        }

    </style>

</head>
<body translate="no">
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.js"></script>

    <script src='//repo.bfw.wiki/bfwrepo/js/OrbitControls.js'></script>
    <script>
        var textureURL = "//repo.bfw.wiki/bfwrepo/image/62e6326f89c55.png";
        var displacementURL = "//repo.bfw.wiki/bfwrepo/image/62e63251d2a61.png";
        var worldURL = "";

        var scene = new THREE.Scene();

        var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

        var renderer = new THREE.WebGLRenderer();

        var controls = new THREE.OrbitControls(camera, renderer.domElement);
        controls.enablePan = false;


        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        var geometry = new THREE.SphereGeometry(2, 60, 60);

        var textureLoader = new THREE.TextureLoader();
        var texture = textureLoader.load(textureURL);
        var displacementMap = textureLoader.load(displacementURL);
        var worldTexture = textureLoader.load(worldURL);

        var material = new THREE.MeshPhongMaterial(
            {
                color: 0xffffff,
                map: texture,
                displacementMap: displacementMap,
                displacement.........完整代码请登录后点击上方下载按钮下载查看

网友评论0