three打造一个三维蝴蝶状带阴影效果
代码语言:html
所属分类:三维
代码描述:three打造一个三维蝴蝶状带阴影效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> canvas { width: 100%; height: 100vh; display: block; cursor: -webkit-grab; cursor: grab; } a { display: block; padding: 5vmin; position: fixed; top: 0; left: 0; } </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.120.0/build/three.module.js'; import { OrbitControls } from '//unpkg.com/three@0.120.0/examples/jsm/controls/OrbitControls.js'; // ---- // Boot // ---- const renderer = new $.WebGLRenderer({ antialias: true }); const scene = new $.Scene(); const camera = new $.PerspectiveCamera(100, 2, .01, 100); const controls = new OrbitControls(camera, renderer.domElement); window.addEventListener('resize', () => { const { clientWidth, clientHeight } = renderer.domElement; renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(clientWidth, clientHeight, false); camera.aspect = clientWidth / clientHeight; camera.updateProjectionMatrix(); }); document.body.prepend(renderer.domElement); window.dispatchEvent(new Event('resize')); renderer.setAnimationLoop(t => { renderer.render(scene, camera); controls.update(); }); // +----- // Canvas // -----+ const canvas = document.createElement('canvas'); canvas.width = 256; canvas.height = 256; const ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.ellipse(canvas.width / 2, 0, canvas.width / 4, canvas.height / 4, 0, 0, Math.PI * 2); ctx.strokeStyle = '#53d9d1'; ctx.lineWidth = 32.........完整代码请登录后点击上方下载按钮下载查看
网友评论0