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/170/three.webgpu.js",
      "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/170/jsm/"
    }
  }
</script>
  
      <script type="module">
import * as THREE from "three";
import { texture, Fn, assign, uniform, color } from "three";
import { float, vec2, vec3, vec4 } from "three";
import { mx_fractal_noise_float, mx_fractal_noise_vec3, mx_noise_float, mx_noise_vec3, mx_cell_noise_float,
        screenUV, screenSize } from "three";
import { add, sub, mul, div, abs, sign,
        min, max, mix, 
        smoothstep, step, floor, fract, normalize, length } from "three";
import { time, hash } from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";

console.clear();

// load fonts
await (async function () {
  async function loadFont(fontface) {
    await fontface.load();
    document.fonts.add(fontface);
  }
  let fonts = [
    new FontFace(
      "Goldman",
      "url(https://fonts.gstatic.com/s/goldman/v19/pe0rMIWbN4JFplR2FI5XEtCaBg.woff2) format('woff2')"
    )
  ];
  for (let font in fonts) {
    await loadFont(fonts[font]);
  }
})();

let tex = (() => {
  let c = document.createElement("canvas");
  let ctx = c.getContext("2d");
  c.width = c.height = 1024;
  let u = (val) => c.height * 0.01 * val;

  ctx.translate(u(50), u(50));
  ctx.textAlign = "center";
  ctx.textBaseline = "middle";
  ctx.fillStyle = "rgba(255, 255, 255, 1)";
  
  ctx.font = `${u(18)}px .........完整代码请登录后点击上方下载按钮下载查看

网友评论0