Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body, .container, canvas { margin: 0; padding: 0; width: 100%; height: 100%; } canvas { display: block; background: black; }
JavaScript
class Scene { constructor(options) { this.$el = options.el; this.time = 0; this.bindAll(); this.init(); } bindAll() { this.render = this.render.bind(this); this.resize = this.resize.bind(this); } init() { this.textureLoader = new THREE.TextureLoader(); this.camera = new THREE.PerspectiveCamera(40, window.innerWidth / window.innerHeight, 1, 2000); this.camera.position.z = 350; this.camera.position.y = 200; this.camera.lookAt(new THREE.Vector3(0, 0, 0)); this.scene = new THREE.Scene(); this.renderer = new THREE.WebGLRenderer({ alpha: true }); this.renderer.setPixelRatio(window.devicePixelRatio); this.renderer.setSize(window.innerWidth, window.innerHeight); this.$el.appendChild(this.renderer.domElement); this.createParticles(); this.bindEvents(); this.resize(); this.render(); } createParticles() { const plane = new THREE.PlaneBufferGeometry(500, 250, 250, 125); const textureLoader = new THREE.TextureLoader(); textureLoader.crossOrigin = ''; const material = new THREE.ShaderMaterial({ uniforms: { time: { value: 1.0 }, texture: { value: textureLoader.load("https://s3-us-west-2.amazonaws.com/s.cdpn.io/1081752/spark1.png") }, resolution: { value: new THREE.Vector2() } }, vertexShader: document.getElementById('vertex-shader').textContent, fragmentShader: document.getElementById('fragment-shader').textContent, blending: THREE.AdditiveBlending, depthTest: false, transparent: true }); console.log(material.uniforms.texture); //const material = new THREE.PointsMaterial( { size: 1 } ); this.particles = new THREE.Points(plane, material); this.particles.rotation.x = this.degToRad(-90); this.scene.add(this.particles); } bindEvents() { // window.addEventListener('mousemove', this.mousemove); window.addEventListener('resize', this.resize); } resize() { const w = window.innerWidth; const h = window.innerHeight; this.renderer.setSize(w, h); this.camera.aspect = w / h; this.camera.updateProjectionMatrix(); } moveParticles() { this.particles.material.uniforms.time.value = this.time; // this.particles.material.needsUpdate = true; } // Animations render() { requestAnimationFrame(this.render); this.time += .01; this.moveParticles(); this.renderer.render(this.scene, this.camera); } // Utils degToRad(angle) { return angle * Math.PI / 180; }} const scene = new Scene({ el: document.querySelector('.container') });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>three.js粒子波浪动画-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号