three心形方块折叠动画三维效果

代码语言:html

所属分类:表白

代码描述:three心形方块折叠动画三维效果

代码标签: 折叠 动画 三维 效果

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

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

<style>
@import url('https://fonts.googleapis.com/css2?family=Nova+Mono&display=swap');

canvas {
    display: grid; width: 100%; height: 100vh;
    position: fixed; top: 0; left: 0;
    cursor: -webkit-grab;
    cursor: grab;
}

a {
    display: block;
    color: black;
    padding: 5vmin;
    width: -webkit-min-content;
    width: -moz-min-content;
    width: min-content;
    font-family: 'nova mono', monospace;
    position: relative; z-index: 1;
}

a:after {
    display: block;
    content: "#2374C6, #C20F00, #FFDD22, #FFFFFF, #000000."
}

body {
    display: block;
    height: 100vh;
}
</style>

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

<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/gsap.3.3.1.js"></script>

<script type="module">
import * as $ from '//unpkg.com/three@0.118.3/build/three.module.js';
import { OrbitControls } from '//unpkg.com/three@0.118.3/examples/jsm/controls/OrbitControls.js';
import { EffectComposer } from '//unpkg.com/three@0.118.3/examples/jsm/postprocessing/EffectComposer';
import { RenderPass } from '//unpkg.com/three@0.118.3/examples/jsm/postprocessing/RenderPass';
import { UnrealBloomPass } from '//unpkg.com/three@0.118.3/examples/jsm/postprocessing/UnrealBloomPass';

// ----
// Boot
// ----

const renderer = new $.WebGLRenderer({ antialias: true });
const scene = new $.Scene();
const camera = new $.PerspectiveCamera(75, 2, 0.1, 100);
const controls = new OrbitControls(camera, renderer.domElement);
const composer = new EffectComposer(renderer);
const res = new $.Vector2();
window.addEventListener('resize', () => {
  const { clientWidth, clientHeight } = renderer.domElement;
  renderer.setPixelRatio(window.devicePixelRatio);
  renderer.setSize(clientWidth, clientHeight, false);
  camera.aspect = clientWidth / clientHeight;
  camera.updateProjectionMatrix();
  composer.setPixelRatio(window.devicePixelRatio);
  composer.setSize(clientWidth, clientHeight);
  renderer.getDrawingBufferSize(res);
});
document.body.prepend(renderer.domElement);
window.dispatchEvent(new Event('resize'));
renderer.setAnimationLoop(t => {
  composer.render();
  controls.update();
});

// ----
// Main
// ---- 

// #2374C6, #C20F00, #FFDD22, #FFFFFF, and #000000

const BLUEISH = '#2374C6';
const REDISH = '#C20F00';
const YELLOWISH = '#FFDD22';
const BLACK = '#000000';
const WHITE = '#FFFFFF';
const SIZE = 1;

scene.background = new $.Color(BLUEISH);
camera.position.set(0, 8, 0);

renderer.shadowMap.enabled = true;

const light = new $.DirectionalLight(WHITE, 1.5);
light.position.set(4, 4, -1);
light.castShadow = true;
light.shadow.camera.near = .1;
light.shadow.camera.far = 20;
light.shadow.mapSize.set(1024, 1024);
light.shadow.bias = -0.001;
scene.add(light);

//// Ground

const g = new $.BoxBufferGeometry(100, 0.001, 100, 100, 1, 100);
const mat = new $.ShadowMaterial({ color: BLACK });
const mesh = n.........完整代码请登录后点击上方下载按钮下载查看

网友评论0