three实现三维海滩沙滩许多遮阳伞效果代码

代码语言:html

所属分类:三维

代码描述:three实现三维海滩沙滩许多遮阳伞效果代码

代码标签: three 三维 海滩 沙滩 许多 遮阳伞

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
<style>
body{
  overflow: hidden;
  margin: 0;
}
</style>


  
  
</head>

<body translate="no">
  <script type="importmap">
  {
    "imports": {
      "three": "//repo.bfw.wiki/bfwrepo/js/module/three/build/169/three.webgpu.js",
      "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/169/jsm/"
    }
  }
</script>
  
      <script type="module">
import * as THREE from "three";
import {uv, vec2, vec3, fract, attribute, select, color, length, smoothstep, add, mix, positionGeometry} from "three";
import {OrbitControls} from "three/addons/controls/OrbitControls.js";
import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";

console.clear();

let scene = new THREE.Scene();
scene.background = new THREE.Color("skyblue");
let camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 1, 1000);
camera.position.set(0, 0.3, 1).setLength(10);
let renderer = new THREE.WebGPURenderer({antialias: true});
renderer.setPixelRatio( devicePixelRatio );
renderer.setSize( innerWidth, innerHeight );
document.body.appendChild(renderer.domElement);

window.addEventListener("resize", event => {
  camera.aspect = innerWidth / innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(innerWidth, innerHeight);
})

let controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;

let light = new THREE.DirectionalLight(0xffffff, Math.PI);
light.position.setScalar(1);
scene.add(light, new THREE.AmbientLight(0xffffff, Math.PI * 0.5));

let circle = 100;

let sand = new THREE.Mesh(
  new THREE.CircleGeometry(circle + 50, 32).rotateX(-Math.PI * 0.5),
  new THREE.MeshLambertNodeM.........完整代码请登录后点击上方下载按钮下载查看

网友评论0