当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Geometry.merge方法代码示例

本文整理汇总了TypeScript中THREE.Geometry.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Geometry.merge方法的具体用法?TypeScript Geometry.merge怎么用?TypeScript Geometry.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THREE.Geometry的用法示例。


在下文中一共展示了Geometry.merge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: initClouds

function initClouds() {

	container = document.getElementById('cd-main-overlay')!;

	// Bg gradient

	const canvas = document.createElement('canvas');
	canvas.width = 32;
	canvas.height = window.innerHeight;

	const context = canvas.getContext('2d')!;

	const gradient = context.createLinearGradient(0, 0, 0, canvas.height);
	gradient.addColorStop(0, '#1e4877');
	gradient.addColorStop(0.5, '#4584b4');

	context.fillStyle = gradient;
	context.fillRect(0, 0, canvas.width, canvas.height);

	container.style.background = `url("${canvas.toDataURL('image/png')}")`;

	//

	camera = new PerspectiveCamera(30, window.innerWidth / window.innerHeight, 1, 3000);
	camera.position.z = 3000;

	scene = new Scene();

	geometry = new Geometry();

	const texture = new TextureLoader().load('/images/cloud10.png', animateClouds);

	const fog = new Fog(0x4584b4, -100, 3000);

	const vs = document.getElementById('vs');
	const fs = document.getElementById('fs');
	const vertexShader = vs!.textContent!;
	const fragmentShader = fs!.textContent!;

	material = new ShaderMaterial({
		depthTest: false,
		depthWrite: false,
		fragmentShader,
		transparent: true,
		uniforms: {
			fogColor: {
				type: 'c',
				value: fog.color,
			},
			fogFar: {
				type: 'f',
				value: fog.far,
			},
			fogNear: {
				type: 'f',
				value: fog.near,
			},
			map: {
				type: 't',
				value: texture,
			},
		},
		vertexShader,
	});

	const plane = new Mesh(new PlaneGeometry(64, 64));

	for (let i = 0; i < 8000; i++) {

		plane.position.x = Math.random() * 1000 - 500;
		plane.position.y = -Math.random() * Math.random() * 200 - 15;
		plane.position.z = i;
		plane.rotation.z = Math.random() * Math.PI;
		plane.scale.x = plane.scale.y = Math.random() * Math.random() * 1.5 + 0.5;

		plane.updateMatrix();
		geometry.merge(plane.geometry as Geometry, plane.matrix);
	}

	mesh = new Mesh(geometry, material);
	scene.add(mesh);

	mesh = new Mesh(geometry, material);
	mesh.position.z = -8000;
	scene.add(mesh);

	renderer = new WebGLRenderer({
		alpha: true,
		antialias: false,
	});
	renderer.setSize(window.innerWidth, window.innerHeight);
	container.append(renderer.domElement);

	document.addEventListener('mousemove', onDocumentMouseMoveClouds, false);
	window.addEventListener('resize', onWindowResizeClouds, false);
}
开发者ID:csrdelft,项目名称:csrdelft.nl,代码行数:96,代码来源:fxclouds.ts


注:本文中的THREE.Geometry.merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。