前端量子纠缠 效果炸裂 multipleWindow3dScene

这篇具有很好参考价值的文章主要介绍了前端量子纠缠 效果炸裂 multipleWindow3dScene。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

我 | 在这里

🕵️ 读书 | 长沙 ⭐软件工程 ⭐ 本科
🏠 工作 | 广州 ⭐ Java 全栈开发(软件工程师)
🎃 爱好 | 研究技术、旅游、阅读、运动、喜欢流行歌曲
✈️已经旅游的地点 | 新疆-乌鲁木齐、新疆-吐鲁番、广东-广州、广东-佛山、湖南-长沙、湖南-张家界、山西、上海、郑州等。老家河南嘞
🏷️ 标签 | 男 自律狂人 目标明确 责任心强
✈️公众号 | 热爱技术的小郑 。文章底部有个人公众号二维码。回复 Java全套视频教程前端全套视频教程 即可获取 300G+ 教程资料及项目实战案例
🚀 邮箱 | 2977429967@qq.com
✈️ GitHub传送门 开源项目 + 实战Demo
 
为何而写?
🍍 好记性不如烂笔头,记录学习的相关知识 、项目 BUG 解决
🍇 复盘总结,加深记忆,方便自己查看
🍑 分享知识,咱就是这么乐于助人、专注填坑20年、哈哈哈哈
 
目标描述
🏆 没有伞的孩子、只能用力奔跑。向着架构师的方向努力、做一个有始有终的人。

视频效果

量子纠缠

源码地址

改项目目前已达到 9.9k stars
项目地址:https://github.com/bgstaal/multipleWindow3dScene

前端量子纠缠 效果炸裂 multipleWindow3dScene,Github 优秀项目,前端,3d

运行

1、Vscode安装 Live Server这个插件

前端量子纠缠 效果炸裂 multipleWindow3dScene,Github 优秀项目,前端,3d

2、点击Go live 就可以看到运行效果了
前端量子纠缠 效果炸裂 multipleWindow3dScene,Github 优秀项目,前端,3d
前端量子纠缠 效果炸裂 multipleWindow3dScene,Github 优秀项目,前端,3d文章来源地址https://www.toymoban.com/news/detail-756743.html

部分源码

import WindowManager from './WindowManager.js'



const t = THREE;
let camera, scene, renderer, world;
let near, far;
let pixR = window.devicePixelRatio ? window.devicePixelRatio : 1;
let cubes = [];
let sceneOffsetTarget = {x: 0, y: 0};
let sceneOffset = {x: 0, y: 0};

let today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
today.setMilliseconds(0);
today = today.getTime();

let internalTime = getTime();
let windowManager;
let initialized = false;

// get time in seconds since beginning of the day (so that all windows use the same time)
function getTime ()
{
	return (new Date().getTime() - today) / 1000.0;
}


if (new URLSearchParams(window.location.search).get("clear"))
{
	localStorage.clear();
}
else
{	
	// this code is essential to circumvent that some browsers preload the content of some pages before you actually hit the url
	document.addEventListener("visibilitychange", () => 
	{
		if (document.visibilityState != 'hidden' && !initialized)
		{
			init();
		}
	});

	window.onload = () => {
		if (document.visibilityState != 'hidden')
		{
			init();
		}
	};

	function init ()
	{
		initialized = true;

		// add a short timeout because window.offsetX reports wrong values before a short period 
		setTimeout(() => {
			setupScene();
			setupWindowManager();
			resize();
			updateWindowShape(false);
			render();
			window.addEventListener('resize', resize);
		}, 500)	
	}

	function setupScene ()
	{
		camera = new t.OrthographicCamera(0, 0, window.innerWidth, window.innerHeight, -10000, 10000);
		
		camera.position.z = 2.5;
		near = camera.position.z - .5;
		far = camera.position.z + 0.5;

		scene = new t.Scene();
		scene.background = new t.Color(0.0);
		scene.add( camera );

		renderer = new t.WebGLRenderer({antialias: true, depthBuffer: true});
		renderer.setPixelRatio(pixR);
	    
	  	world = new t.Object3D();
		scene.add(world);

		renderer.domElement.setAttribute("id", "scene");
		document.body.appendChild( renderer.domElement );
	}

	function setupWindowManager ()
	{
		windowManager = new WindowManager();
		windowManager.setWinShapeChangeCallback(updateWindowShape);
		windowManager.setWinChangeCallback(windowsUpdated);

		// here you can add your custom metadata to each windows instance
		let metaData = {foo: "bar"};

		// this will init the windowmanager and add this window to the centralised pool of windows
		windowManager.init(metaData);

		// call update windows initially (it will later be called by the win change callback)
		windowsUpdated();
	}

	function windowsUpdated ()
	{
		updateNumberOfCubes();
	}

	function updateNumberOfCubes ()
	{
		let wins = windowManager.getWindows();

		// remove all cubes
		cubes.forEach((c) => {
			world.remove(c);
		})

		cubes = [];

		// add new cubes based on the current window setup
		for (let i = 0; i < wins.length; i++)
		{
			let win = wins[i];

			let c = new t.Color();
			c.setHSL(i * .1, 1.0, .5);

			let s = 100 + i * 50;
			let cube = new t.Mesh(new t.BoxGeometry(s, s, s), new t.MeshBasicMaterial({color: c , wireframe: true}));
			cube.position.x = win.shape.x + (win.shape.w * .5);
			cube.position.y = win.shape.y + (win.shape.h * .5);

			world.add(cube);
			cubes.push(cube);
		}
	}

	function updateWindowShape (easing = true)
	{
		// storing the actual offset in a proxy that we update against in the render function
		sceneOffsetTarget = {x: -window.screenX, y: -window.screenY};
		if (!easing) sceneOffset = sceneOffsetTarget;
	}


	function render ()
	{
		let t = getTime();

		windowManager.update();


		// calculate the new position based on the delta between current offset and new offset times a falloff value (to create the nice smoothing effect)
		let falloff = .05;
		sceneOffset.x = sceneOffset.x + ((sceneOffsetTarget.x - sceneOffset.x) * falloff);
		sceneOffset.y = sceneOffset.y + ((sceneOffsetTarget.y - sceneOffset.y) * falloff);

		// set the world position to the offset
		world.position.x = sceneOffset.x;
		world.position.y = sceneOffset.y;

		let wins = windowManager.getWindows();


		// loop through all our cubes and update their positions based on current window positions
		for (let i = 0; i < cubes.length; i++)
		{
			let cube = cubes[i];
			let win = wins[i];
			let _t = t;// + i * .2;

			let posTarget = {x: win.shape.x + (win.shape.w * .5), y: win.shape.y + (win.shape.h * .5)}

			cube.position.x = cube.position.x + (posTarget.x - cube.position.x) * falloff;
			cube.position.y = cube.position.y + (posTarget.y - cube.position.y) * falloff;
			cube.rotation.x = _t * .5;
			cube.rotation.y = _t * .3;
		};

		renderer.render(scene, camera);
		requestAnimationFrame(render);
	}


	// resize the renderer to fit the window size
	function resize ()
	{
		let width = window.innerWidth;
		let height = window.innerHeight
		
		camera = new t.OrthographicCamera(0, width, 0, height, -10000, 10000);
		camera.updateProjectionMatrix();
		renderer.setSize( width, height );
	}
}

到了这里,关于前端量子纠缠 效果炸裂 multipleWindow3dScene的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 使用增强版 singleflight 合并事件推送,效果炸裂!

    hello,大家好啊,我是小楼。 最近在工作中对 Go 的 singleflight 包做了下增强,解决了一个性能问题,这里记录下,希望对你也有所帮助。 singleflight 直接翻译为”单(次)飞(行)“,它是对同一种请求的抑制,保证同一时刻相同的请求只有一个在执行,且在它执行期间的相

    2024年02月05日
    浏览(23)
  • 5个效果炸裂的AI绘画网站,快来收藏

    在绘图创作的过程中,AI绘图网站以其强大的算法和智能生成功能,为设计师提供了丰富的创意灵感和精致的图片内容。本文从市面上众多的AI绘画网站中精选了5个好用的与大家一起分享,让设计师在创作过程中能释放创意,探索无限可能。 即时AI灵感是一个国产的AI绘画网站

    2024年02月15日
    浏览(39)
  • 【Midjourney实操】逼真到颤抖!保姆级教程教生成效果炸裂的图片

    最近,许多由Midjourney V5创作的画作在网络上引起了热议,许多人惊呼:人类画师, 插画师, 设计师统统活不下去了! 比如下面这张中国情侣的画作: 因为前段时间这个很火, 我跟着同样的prompt画出了一对中国情侣,画风超级震撼,简直就是碾压人类画师。 有人不相信这是

    2024年02月09日
    浏览(67)
  • Vue.js2+Cesium1.103.0 十一、Three.js 炸裂效果

    Demo ThreeModelBoom.vue index.vue

    2024年02月11日
    浏览(29)
  • 前端瀑布流效果

    先看效果

    2024年02月09日
    浏览(24)
  • 【前端基础】垂直居中效果

    在网页设计中,要实现垂直居中效果,可以尝试以下几种常见的方法: Flexbox 布局 : 使用 Flexbox 布局是实现垂直居中效果的一种简单方法。以下是一个基本示例: Grid 布局 : 你也可以使用 CSS Grid 布局来实现垂直居中效果,类似于 Flexbox,但它更适合复杂的布局。 绝对定位

    2024年02月09日
    浏览(25)
  • 前端放大镜效果实现

    放大图片的需求,一般是在原有的渲染之上,额外添加一个放大框,当鼠标在原图上移动,放大框内就以当前的鼠标为中心,局部放大一定范围,在淘宝商城中是常有的实现。下面将用两种实现。 1、使用 div + img 标签,原理是放大框中有一个图片,这个图片是放大后的,放大

    2024年02月08日
    浏览(28)
  • 前端页面--视觉差效果

    2024年02月14日
    浏览(23)
  • 前端效果 登入界面

    效果展示: 代码:

    2024年01月21日
    浏览(23)
  • 前端常用js、css效果

    效果 主要整理了几个常用的,方便平时做项目的时候参考 文本横向滚动 文本无限滚动 无缝轮播 无缝滚动 盒子上下滚动 樱花飘落效果 参考代码 文本横向滚动 文本无限滚动 无缝轮播 无缝滚动 盒子上下移动 樱花飘落 添加插件sakura.js就可以了,不用什么代码

    2024年02月02日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包