webgl实现宇宙黑洞鼠标跟随交互动画效果代码

代码语言:html

所属分类:动画

代码描述:webgl实现宇宙黑洞鼠标跟随交互动画效果代码

代码标签: webgl 宇宙 黑洞 交互 动画

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

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <style>
        html, body {
          position: absolute;
          top: 0px;
          left: 0px;
          right: 0px;
          bottom: 0px;
          padding: 0px;
          cursor: none;
          margin: 0px;
          overflow: hidden;
          display: flex;
          height: 100%;
          width: 100%;
          background-color: #000;
        }
        
        canvas {
          margin: auto auto;
        }
    </style>

</head>

<body>
   <script id="2d-fragment-shader" type="x-shader/x-fragment">// <![CDATA[

// Look below at line 23 for realism.

#ifdef GL_ES
precision mediump float;
#endif

#define PI 3.14159265359

uniform sampler2D u_image;
varying vec2 v_texCoord;

uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_mass;
uniform float u_time;
uniform float u_clickedTime;

vec2 rotate(vec2 mt, vec2 st, float angle){
	float cos = cos((angle + u_clickedTime) * PI); // try replacing * 1.0 with * PI
	float sin = sin(angle * 0.0); // try removing the * 0.0
	
	// Uncomment these two lin.........完整代码请登录后点击上方下载按钮下载查看

网友评论0