three打造日出草坪小草摆动三维效果

代码语言:html

所属分类:三维

代码描述:three打造日出草坪小草摆动三维效果,可以360拖动

代码标签: 草坪 小草 摆动 三维 效果

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

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

    <style>
        body {
            background-color: #fff;
            margin: 0;
            overflow: hidden;
        }
        .label {
            position: absolute;
            top: 0;
            left: 0;
            padding: 5px 15px;
            color: #fff;
            font-size: 13px;
            background-color: rgba(0, 0, 0, .15);
        }
        .instructions {
            position: absolute;
            bottom: 0%;
            left: 0;
            padding: 5px 15px;
            color: #fff;
            font-size: 13px;
            background-color: rgba(0, 0, 0, .15);
        }
        canvas {
            display: block;
        }
    </style>

</head>
<body translate="no">

    <canvas id="canvas"></canvas>


    <div class="label">
       Logo
    </div>
    <div class="instructions">
        WASD/ARROW KEYS TO MOVE, MOUSE TO LOOK
    </div>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.109.js"></script>
    <script src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Stats-16.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script>

    <script>
      

        var canvas = document.getElementById("canvas");

        const mobile = (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)
        );

        //Variables for blade mesh
        var joints = 4;
        var bladeWidth = 0.12;
        var bladeHeight = 1;

        //Patch side length
        var width = 120;
        //Number of vertices on ground plane side
        var resolution = 32;
        //Distance between two ground plane vertices
        var delta = width/resolution;
        //Radius of the sphere onto which the ground plane is bended
        var radius = 120;
        //User movement speed
        var speed = 1.5;

        //The global coordinates
        //The geometry never leaves a box of width*width around (0, 0)
        //But we track where in space the camera would be globally
        var pos = new THREE.Vector2(0, 0);

        //Number of blades
        var instances = 40000;
        if (mobile) {
            instances = 7000;
            width = 50;
        }

        //Sun
        //Height over horizon in range [0, PI/2.0]
        var elevation = 0.3;
        //Rotation around Y axis in range [0, 2*PI]
        var azimuth = 2.0;

        //Lighting variables for grass
        var ambientStrength = 0.6;
        var translucencyStrength = 1.4;
        var specularStrength = 0.5;
        var diffuseStrength = 2.2;
        var shininess = 256;
        var sunColour = new THREE.Vector3(1.0, 1.0, 1.0);
        var specularColour = new THREE.Vector3(1.0, 1.0, 1.0);

        //Camera rotate
        v.........完整代码请登录后点击上方下载按钮下载查看

网友评论0