Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body { margin: 0; padding: 0; overflow: hidden; }
JavaScript
var boxSz = 500; var t; var seekers = []; function setup() { createCanvas(windowWidth, windowHeight, WEBGL); t = new Target(); for (var i = 0; i < 12; i++) { seekers[i] = new Seeker(); } } function draw() { background(100); translate(0, 0, -boxSz); rotateY(frameCount * 0.002); t.update(); t.display(); for (var i = 0; i < seekers.length; i++) { seekers[i].update(); seekers[i].seek(createVector(t.pos.x, t.pos.y, t.pos.z)); seekers[i].display(); //seekers[i].seek(createVector(mouseX, mouseY)); } drawBox(); } function Seeker() { this.pos = createVector(random(-boxSz * 2, boxSz * 2), random(-boxSz, boxSz * 2), random(boxSz * 2, boxSz * 4)); this.vel = createVector(random(-2, 2), random(-2, 2), random(-2, 2)); this.acc = createVector(0, 0), 0; this.sz = 10; this.maxSpeed = random(1, 5); this.maxForce = random(0.03, 0.1); this.trail = []; this.trailMax = int(random(10, 30)); this.display = function() { this.colorTint = 200; for (var i = 0; i < this.trail.length; i++) { var pos = this.trail[i]; push(); translate(pos.x, pos.y, pos.z); this.sz = map(i, 0, this.trailMax, 1, 8); this.colorTint = map(i, 0, this.trailMax, 100, 200); basicMaterial(this.colorTint); sphere(this.sz, 4); pop(); } push(); translate(this.pos.x, this.pos.y, this.pos.z); basicMaterial(255); sphere(10, 8); pop(); } this.update = function() { this.vel.add(this.acc); this.pos.add(this.vel); this.acc.mult(0); if (this.trail.length > this.trailMax) { this.trail.splice(0, 1); } if (frameCount % 10 == 0) { var v = createVector(this.pos.x, this.pos.y, this.pos.z); this.trail.push(v); } } this.applyForce = function(force) { this.acc.add(force); } this.seek = function(target) { var desired = p5.Vector.sub(target, this.pos); desired.setMag(this.maxSpeed); var steering = p5.Vector.sub(desired, this.vel); steering.limit(this.maxForce); this.applyForce(steering); } } function Target() { this.pos = createVector(random(-boxSz, boxSz), random(-boxSz, boxSz), random(-boxSz, boxSz)); this.newPos = createVector(0, 0); this.display = function() { //fill(255, 0, 0); push(); translate(this.pos.x, this.pos.y, this.pos.z); basicMaterial(255, 0, 0); box(5); pop(); if (frameCount % 200 === 0) { this.moveTarget(); } } this.update = function() { this.pos.x = lerp(this.pos.x, this.newPos.x, 0, 1); this.pos.y = lerp(this.pos.y, this.newPos.y, 0, 1); } this.moveTarget = function() { this.pos = createVector(random(-boxSz, boxSz), random(-boxSz, boxSz), random(-boxSz, boxSz)); } } function drawBox() { // DRAW OUTLINE BOX stroke(120); //front line(-boxSz, -boxSz, boxSz, boxSz, -boxSz, boxSz); line(-boxSz, boxSz, boxSz, boxSz, boxSz, boxSz); line(-boxSz, -boxSz, boxSz, -boxSz, boxSz, boxSz); line(boxSz, -boxSz, boxSz, boxSz, boxSz, boxSz); //back line(-boxSz, -boxSz, -boxSz, boxSz, -boxSz, -boxSz); line(-boxSz, boxSz, -boxSz, boxSz, boxSz, -boxSz); line(-boxSz, -boxSz, -boxSz, -boxSz, boxSz, -boxSz); line(boxSz, -boxSz, -boxSz, boxSz, boxSz, -boxSz); //left top line(-boxSz, -boxSz, boxSz, -boxSz, -boxSz, -boxSz); //left bottom line(-boxSz, boxSz, -boxSz, -boxSz, boxSz, boxSz); //right top line(boxSz, -boxSz, boxSz, boxSz, -boxSz, -boxSz); // // right bottom line(boxSz, boxSz, -boxSz, boxSz, boxSz, boxSz); }
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>3D Seek-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号