Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body { margin: 0; overflow: hidden; }
JavaScript
class Stage { constructor() { this.renderParam = { clearColor: 0x666666, width: window.innerWidth, height: window.innerHeight }; this.cameraParam = { left: -1, right: 1, top: 1, bottom: 1, near: 0, far: -1 }; this.scene = null; this.camera = null; this.renderer = null; this.geometry = null; this.material = null; this.mesh = null; this.isInitialized = false; } init() { this._setScene(); this._setRender(); this._setCamera(); this.isInitialized = true; } _setScene() { this.scene = new THREE.Scene(); } _setRender() { this.renderer = new THREE.WebGLRenderer({ canvas: document.getElementById("webgl-canvas") }); this.renderer.setPixelRatio(window.devicePixelRatio); this.renderer.setClearColor(new THREE.Color(this.renderParam.clearColor)); this.renderer.setSize(this.renderParam.width, this.renderParam.height); } _setCamera() { if (!this.isInitialized) { this.camera = new THREE.OrthographicCamera( this.cameraParam.left, this.cameraParam.right, this.cameraParam.top, this.cameraParam.bottom, this.cameraParam.near, this.cameraParam.far ); } const windowWidth = window.innerWidth; const windowHeight = window.innerHeight; this.camera.aspect = windowWidth / windowHeight; this.camera.updateProjectionMatrix(); this.renderer.setSize(windowWidth, windowHeight); } _render() { this.renderer.render(this.scene, this.camera); } onResize() { this._setCamera(); } onRaf() { this._render(); } } class Mesh { constructor(stage) { this.geometryParm = {}; this.materialParam = { useWireframe: false }; this.uniforms = { resolution: { type: "v2", value: [ window.innerWidth, window.innerHeight ] }, time: { type: "f", value: 0.0 }, xScale: { type: "f", value: 1.0 }, yScale: { type: "f", value: 0.5 }, distortion: { type: "f", value: 0.050 } }; this.stage = stage; this.mesh = null; this.windowWidth = 0; this.windowHeight = 0; this.windowWidthHalf = 0; this.windowHeightHalf = 0; this.xScale = 1.0; this.yScale = 0.5; this.distortion = 0.050; } init() { this._setMesh(); this._setGui(); } _setMesh() { const position = [ -1.0, -1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, 1.0, 0.0 ]; const positions = new THREE.BufferAttribute(new Float32Array(position), 3); const geometry = new THREE.BufferGeometry(); geometry.setAttribute("position", positions); const material = new THREE.RawShaderMaterial({ vertexShader: document.getElementById("js-vertex-shader").textContent, fragmentShader: document.getElementById("js-fragment-shader").textContent, uniforms: this.uniforms, side: THREE.DoubleSide }); this.mesh = new THREE.Mesh(geometry, material); this.stage.scene.add(this.mesh); } _render() { this.uniforms.time.value += 0.01; } _setGui() { const parameter = { xScale: this.xScale, yScale: this.yScale, distortion: this.distortion } const gui = new dat.GUI(); gui.add(parameter, "xScale", 0.00, 5.00, 0.01).onChange((value) => { this.mesh.material.uniforms.xScale.value = value; }); gui.add(parameter, "yScale", 0.00, 1.00, 0.01).onChange((value) => { this.mesh.material.uniforms.yScale.value = value; }); gui.add(parameter, "distortion", 0.001, 0.100, 0.001).onChange((value) => { this.mesh.material.uniforms.distortion.value = value; }); } onRaf() { this._render(); } } (() => { const stage = new Stage(); stage.init(); const mesh = new Mesh(stage); mesh.init(); window.addEventListener("resize", () => { stage.onResize(); }); const _raf = () => { window.requestAnimationFrame(() => { stage.onRaf(); mesh.onRaf(); _raf(); }); }; _raf(); })();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>GLSL 光带-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号