gsap实现三维碎片化动画效果

代码语言:html

所属分类:三维

代码描述:gsap实现三维碎片化动画效果

代码标签: 碎片 动画 效果

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

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

<style>
canvas {
    width: 100%;
    height: 100vh;
    display: block;
    background: #000;
}

a {
    position: fixed;
    left: 0;
    top: 0;
    padding: 5vmin;
    color: #eee;
}
</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.117.1/build/three.module.js'
import { OrbitControls } from '//unpkg.com/three@0.117.1/examples/jsm/controls/OrbitControls.js'
import { EffectComposer } from '//unpkg.com/three@0.117.1/examples/jsm/postprocessing/EffectComposer.js'
import { RenderPass } from '//unpkg.com/three@0.117.1/examples/jsm/postprocessing/RenderPass.js'
import { UnrealBloomPass } from '//unpkg.com/three@0.117.1/examples/jsm/postprocessing/UnrealBloomPass.js'

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

const renderer = new $.WebGLRenderer({ antialias: false });
const scene = new $.Scene();
const camera = new $.PerspectiveCamera(75, 2, .1, 1000);
const controls = new OrbitControls(camera, renderer.domElement);
const composer = new EffectComposer(renderer);
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);
});
document.body.prepend(renderer.domElement);
window.dispatchEvent(new Event('resize'));
renderer.setAnimationLoop(t => {
    composer.render();
    controls.update();
});

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

scene.background = new $.Color('black');
scene.fog = new $.Fog(scene.background, 1, 8);
camera.position.set(0, 0, 5);

const light0 = new $.DirectionalLight('cyan', 2);
scene.add(light0);

const light1 = new $.PointLight('magenta', 5, 5, 1);
scene.add(light1);

//// Make Non Indexed Geometry

let geom;
{
    const geom_ = new $.TorusKnotBufferGeometry(2, .5, 100, 50, 2, 3);
    geom = geom_.toNonIndexed();
    geom_.dispose();
}

//// Compute Morph Attrib - Position

const positions0 = new Float32Array(geom.attributes.pos.........完整代码请登录后点击上方下载按钮下载查看

网友评论0