当前位置: 首页 > news >正文

手机网站开发+图库类怎样在手机上建设网站

手机网站开发+图库类,怎样在手机上建设网站,外国ps素材网站,太仓网站建设太仓介绍 场景选点后,灯光移动了,但是开启辅助器时,辅助器是不会跟随移动的,总是移动到上一次选中的位置!官网上没有相应的解释,此时就需要查看源码,再根据源码编写功能代码啦!主要是聚光…
介绍
  • 场景选点后,灯光移动了,但是开启辅助器时,辅助器是不会跟随移动的,总是移动到上一次选中的位置!官网上没有相应的解释,此时就需要查看源码,再根据源码编写功能代码啦!
  • 主要是聚光灯平行光以及环境光的灯光辅助器不能跟随变动!
  • 每次修改灯光相关参数时,记得helper.update()
详情

SpotLightHelper 源码如下:
- 通过设置断点,更新灯光时,调用灯光update方法,此时 line49 仍然会保留上一次的位置,所以此时需要重新改写一下灯光辅助器骨架的位置 this.cone.lookAt(position)
- position 为 Vector3 类型;

/*** @author alteredq / http://alteredqualia.com/* @author mrdoob / http://mrdoob.com/* @author WestLangley / http://github.com/WestLangley*/1. import { Vector3 } from '../math/Vector3.js';
2. import { Object3D } from '../core/Object3D.js';
3. import { LineSegments } from '../objects/LineSegments.js';
4. import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
5. import { Float32BufferAttribute } from '../core/BufferAttribute.js';
6. import { BufferGeometry } from '../core/BufferGeometry.js';
7. var _vector = new Vector3();
8. function SpotLightHelper( light, color ) {
9. 		Object3D.call( this );
10. 	this.light = light;
11. 	this.light.updateMatrixWorld();
12. 	this.matrix = light.matrixWorld;
13. 	this.matrixAutoUpdate = false;
14. 	this.color = color;
15. 	var geometry = new BufferGeometry();
16. 	var positions = [
17. 		0, 0, 0, 	0, 0, 1,
18. 		0, 0, 0, 	1, 0, 1,
19. 		0, 0, 0,	- 1, 0, 1,
20. 		0, 0, 0, 	0, 1, 1,
21. 		0, 0, 0, 	0, - 1, 1
22. 	];
23. 	for ( var i = 0, j = 1, l = 32; i < l; i ++, j ++ ) {
24. 		var p1 = ( i / l ) * Math.PI * 2;
25. 		var p2 = ( j / l ) * Math.PI * 2;
26. 		positions.push(
27. 			Math.cos( p1 ), Math.sin( p1 ), 1,
28. 			Math.cos( p2 ), Math.sin( p2 ), 1
29. 		);
30. 	}
31. 	geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
32. 	var material = new LineBasicMaterial( { fog: false } );
33. 	this.cone = new LineSegments( geometry, material );
34. 	this.add( this.cone );
35. 	this.update();
36. }
37. SpotLightHelper.prototype = Object.create( Object3D.prototype );
38. SpotLightHelper.prototype.constructor = SpotLightHelper; 
39. SpotLightHelper.prototype.dispose = function () {
40. 	this.cone.geometry.dispose();
41. 	this.cone.material.dispose();
42. };
43. SpotLightHelper.prototype.update = function () {
44. 	this.light.updateMatrixWorld();
45. 	var coneLength = this.light.distance ? this.light.distance : 1000;
46. 	var coneWidth = coneLength * Math.tan( this.light.angle );
47. 	this.cone.scale.set( coneWidth, coneWidth, coneLength );
48. 	_vector.setFromMatrixPosition( this.light.target.matrixWorld );
49. 	this.cone.lookAt( _vector ); // 重要点
50. 	if ( this.color !== undefined ) {
51. 		this.cone.material.color.set( this.color );
52.		} else {
53. 		this.cone.material.color.copy( this.light.color );
54. 	}
55. };
56. export { SpotLightHelper };

DirectionalLightHelper 源码如下:
- 通过设置断点,更新灯光时,调用灯光update方法,此时 灯光辅助器 会停留上一次的位置,所以此时需要重新改写一下灯光辅助器骨架的位置 line 13、 line 44-47、 line55-56,都需要重新调用或设置;

 light.updateMatrixWorld();let targetPosition = light.target.position;let lightPosoition = light.position;let subPosition = new THREE.Vector3();subPosition.subVectors(targetPosition, lightPosoition); // 获取灯光与位置之间的差helper.lightPlane.lookAt(targetPosition);helper.targetLine.lookAt(targetPosition);helper.targetLine.scale.z = subPosition.length();
/*** @author alteredq / http://alteredqualia.com/* @author mrdoob / http://mrdoob.com/* @author WestLangley / http://github.com/WestLangley*/
1. import { Vector3 } from '../math/Vector3.js';
2. import { Object3D } from '../core/Object3D.js';
3. import { Line } from '../objects/Line.js';
4. import { Float32BufferAttribute } from '../core/BufferAttribute.js';
5. import { BufferGeometry } from '../core/BufferGeometry.js';
6. import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
7. var _v1 = new Vector3();
8. var _v2 = new Vector3();
9. var _v3 = new Vector3();
10. function DirectionalLightHelper( light, size, color ) {
11.		Object3D.call( this );
12.		this.light = light;
13.		this.light.updateMatrixWorld(); // 重要点
14.		this.matrix = light.matrixWorld;
15.		this.matrixAutoUpdate = false;
16.		this.color = color;
17.		if ( size === undefined ) size = 1;
18.		var geometry = new BufferGeometry();
19.		geometry.addAttribute( 'position', new Float32BufferAttribute( [
20.			- size, size, 0,
21.			size, size, 0,
22.			size, - size, 0,
23.			- size, - size, 0,
24.			- size, size, 0
25.		], 3 ) );
26.		var material = new LineBasicMaterial( { fog: false } );
27.		this.lightPlane = new Line( geometry, material );
28.		this.add( this.lightPlane );
29.		geometry = new BufferGeometry();
30.		geometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
31.		this.targetLine = new Line( geometry, material );
32.		this.add( this.targetLine );
33.		this.update();
34.	}
35.	DirectionalLightHelper.prototype = Object.create( Object3D.prototype );
36.	DirectionalLightHelper.prototype.constructor = DirectionalLightHelper;
37.	DirectionalLightHelper.prototype.dispose = function () {
38.		this.lightPlane.geometry.dispose();
39.		this.lightPlane.material.dispose();
40.		this.targetLine.geometry.dispose();
41.		this.targetLine.material.dispose();
42.	};
43.	DirectionalLightHelper.prototype.update = function () {
44.		_v1.setFromMatrixPosition( this.light.matrixWorld ); // 重要点
45.		_v2.setFromMatrixPosition( this.light.target.matrixWorld ); // 重要点
46.		_v3.subVectors( _v2, _v1 ); // 重要点
47.		this.lightPlane.lookAt( _v2 ); // 重要点
48.		if ( this.color !== undefined ) {
49.			this.lightPlane.material.color.set( this.color );
50.			this.targetLine.material.color.set( this.color );
51.		} else {
52.			this.lightPlane.material.color.copy( this.light.color );
53.			this.targetLine.material.color.copy( this.light.color );
54.		}
55.		this.targetLine.lookAt( _v2 ); // 重要点
56.		this.targetLine.scale.z = _v3.length(); // 重要点
57.	};
58. export { DirectionalLightHelper };

DirectionalLightHelper 源码如下:
- 通过设置断点,更新灯光时,调用灯光update方法,此时 灯光辅助器 会停留上一次的位置,所以此时需要重新改写一下灯光辅助器骨架的位置 line 15-16、 line 49 需要重新调用或设置;

light.updateMatrixWorld();
helper.matrix = light.matrixWorld;
let subPosition = new THREE.Vector3();
helper.children[0].lookAt(subPosition.setFromMatrixPosition(light.matrixWorld).negate());
/*** @author alteredq / http://alteredqualia.com/* @author mrdoob / http://mrdoob.com/* @author Mugen87 / https://github.com/Mugen87*/
1. import { Vector3 } from '../math/Vector3.js';
2. import { Color } from '../math/Color.js';
3. import { Object3D } from '../core/Object3D.js';
4. import { Mesh } from '../objects/Mesh.js';
5. import { VertexColors } from '../constants.js';
6.	import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
7.	import { OctahedronBufferGeometry } from '../geometries/OctahedronGeometry.js';
8.	import { BufferAttribute } from '../core/BufferAttribute.js';
9.	var _vector = new Vector3();
10.	var _color1 = new Color();
11.	var _color2 = new Color();
12.	function HemisphereLightHelper( light, size, color ) {
13.		Object3D.call( this );
14.		this.light = light;
15.		this.light.updateMatrixWorld(); // 重要点
16.		this.matrix = light.matrixWorld; // 重要点
17.		this.matrixAutoUpdate = false;
18.		this.color = color;
19.		var geometry = new OctahedronBufferGeometry( size );
20.		geometry.rotateY( Math.PI * 0.5 );
21.		this.material = new MeshBasicMaterial( { wireframe: true, fog: false } );
22.		if ( this.color === undefined ) this.material.vertexColors = VertexColors;
23.		var position = geometry.getAttribute( 'position' );
24.		var colors = new Float32Array( position.count * 3 );
25.		geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) );
26.		this.add( new Mesh( geometry, this.material ) );
27.		this.update();
28.	}
29.	HemisphereLightHelper.prototype = Object.create( Object3D.prototype );
30.	HemisphereLightHelper.prototype.constructor = HemisphereLightHelper;
31.	HemisphereLightHelper.prototype.dispose = function () {
32.		this.children[ 0 ].geometry.dispose();
33.		this.children[ 0 ].material.dispose();
34.	};
35.	HemisphereLightHelper.prototype.update = function () {
36.		var mesh = this.children[ 0 ];
37.		if ( this.color !== undefined ) {
38.			this.material.color.set( this.color );
39.		} else {
40.			var colors = mesh.geometry.getAttribute( 'color' );
41.			_color1.copy( this.light.color );
42.			_color2.copy( this.light.groundColor );
43.			for ( var i = 0, l = colors.count; i < l; i ++ ) {
44.				var color = ( i < ( l / 2 ) ) ? _color1 : _color2;
45.				colors.setXYZ( i, color.r, color.g, color.b );
46.			}
47.			colors.needsUpdate = true;
48.		}
49.		mesh.lookAt( _vector.setFromMatrixPosition( this.light.matrixWorld ).negate() ); // 重要点
50.	};
51.	export { HemisphereLightHelper };
http://www.dtcms.com/a/414538.html

相关文章:

  • MySQL三层架构:从连接管理到数据存储
  • 嵌入式硬件——IMX6ULL时钟配置
  • 【用androidx.camera拍摄景深合成照片】
  • linux安装google chrome 谷歌浏览器
  • 从零起步学习Redis || 第二章:Cache Aside Pattern(旁路缓存模式)以及优化策略
  • 两性做受技巧视频网站喊别人做的网站不肯给代码
  • ESP32-S3入门第八天:往期知识回顾与实战练习
  • Claude Code 实战指南(三):AI辅助开发工作流 Spec Workflow MCP教程
  • 红帽认证含金量怎么样?适合哪些人?
  • 宣传的网站开发需要多少钱步骤的英文
  • 选择一款拖拽式界面的vscode扩展程序制作Python界面
  • Android开发-屏幕变更事件
  • 十大咨询公司排行榜aso优化师主要是干嘛的
  • LeetCode第1346题 - 检查整数及其两倍数是否存在
  • 【Leetcode hot 100】207.课程表
  • 搜索引擎高级搜索技巧
  • 2.3 物理层设备 (答案见原书 P48)
  • 华为OBS obsutil使用
  • 租购同权七年之痒:政策善意如何变现?
  • 【Linux操作系统】基础开发工具
  • 老年ai模拟恋爱抖音快手微信小程序看广告流量主开源
  • 知名的网站制作公司需要多少钱企业宣传网站模板下载
  • 深圳横岗做网站的网站品牌形象设计怎么做
  • 社区网站推广方案百度百家号注册
  • 编程竞赛高频考点
  • Linux 程序使用 STDOUT 打印日志导致程序“假死”?一次线上 Bug 的深度排查与解决
  • (一)routeros命令笔记:开局篇
  • 网站推广模式一份完整的项目计划书
  • 基于STM32设计的智能安全头盔_299
  • ​VR应急安全学习机,提升应对自然灾害时自救互救的应急技能