webgl照片粒子化动画效果代码
代码语言:html
所属分类:动画
代码描述:webgl照片粒子化动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; background-color: black; } .loading { color: white; } .canvas-container { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; font-family: sans-serif; background-color: black; } canvas { max-height: 100vh; max-width: 100vw; } .toggle-help-link { position: absolute; bottom: 10px; right: 10px; font-size: 12px; text-decoration: none; color: lightgrey; } .status { position: absolute; bottom: 10px; left: 10px; font-size: 12px; color: lightgrey; } .help-container { position: fixed; left: 0; top: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; background-color: rgba(0, 0, 0, 0.4); color: white; backdrop-filter: blur(3px); } .help-container .help { width: 90%; max-width: 500px; } .help li { margin-bottom: 1em; } .help a { color: inherit; } </style> </head> <body > <!-- this pen was built and maintained in https://github.com/callumacrae/sketchbook/blob/master/src/views/ParticlePhotoWebgl.vue --> <p class="loading">loading…</p> <div class="canvas-container" style="display: none"> <canvas ref="canvas" @click="status = status === 'playing' ? 'paused' : 'playing'" @dragenter.prevent @dragleave.prevent @dragover.prevent @drop.prevent="handleDrop" ></canvas> <GlobalEvents target="window" @resize="setSize" /> <div class="help-container" v-show="showHelp || showIosWarning"> <div class="help" v-show="showIosWarning"> <h2 style="color: red">WARNING</h2> <p> Due to a bug in how iOS handles webgl instancing, this animation performs incredibly poorly on iOS—to the point where it doesn't really work at all. On my phone, it runs at 0.0075 fps and makes my phone heat up to the temperature of the sun. </p> <p> I'd recommend trying this on desktop (it also just looks better), but if you really want to see what happens on iOS, you can <a href @click.prevent=" showIosWarning = false; status = 'playing'; " > proceed anyway</a >. </p> </div> <div class="help" v-show="showHelp"> <h2>Instructions</h2> <p> This experiment visualises images as collections of animated coloured particles. </p> <p> In addition to providing a few images (selectable on the configuration in the top right of the screen), it also allows you to upload your own by dragging and dropping them .........完整代码请登录后点击上方下载按钮下载查看
网友评论0