three打造森林绿光走光动画效果
代码语言:html
所属分类:动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/three-min.js"></script>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script>
'use strict';
var _class, _temp, _class2, _temp2, _class3, _temp3;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var BackgroundMaterial = (_temp = _class = function (_THREE$RawShaderMater) {
_inherits(BackgroundMaterial, _THREE$RawShaderMater);
function BackgroundMaterial() {
_classCallCheck(this, BackgroundMaterial);
var _this = _possibleConstructorReturn(this, _THREE$RawShaderMater.call(this, BackgroundMaterial.shader));
_this.resize = function () {
_this.uniforms.resolution.value.set(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio);
};
_this.loop = function (timestamp) {
requestAnimationFrame(_this.loop);
_this.uniforms.globalTime.value = timestamp / 1000;
};
addEventListener('resize', _this.resize);
requestAnimationFrame(_this.loop);
return _this;
}
return BackgroundMaterial;
}(THREE.RawShaderMaterial), _class.shader = {
vertexShader: '\n attribute vec3 position;\n\n uniform mat4 projectionMatrix;\n uniform mat4 modelViewMatrix;\n\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n }\n ',
fragmentSh.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0