多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > web前端 > htmlcss > three.js 源碼注釋(六十七)objects/PointCloud.js

three.js 源碼注釋(六十七)objects/PointCloud.js

來源:程序員人生   發布時間:2015-03-07 12:51:28 閱讀次數:4213次

俺也是剛開始學,好多地兒肯定不對還請見諒.

以下代碼是THREE.JS 源碼文件中objects/PointCloud.js文件的注釋.

更多更新在 : https://github.com/omni360/three.js.sourcecode


/** * @author alteredq / http://alteredqualia.com/ */ /* ///PointCloud點云對象,在場景中方便的改變大量的點精靈對象大小,位置等屬性. */ ///PointCloud///Geometry對象點云對象里的點集合///PointCloudMaterial對象(點云材質對象)///返回Mesh對象THREE.PointCloud = function ( geometry, material ) { THREE.Object3D.call( this ); //調用Object3D對象的call方法,將本來屬于Object3D的方法交給當前對象PointCloud來使用. this.geometry = geometry !== undefined ? geometry : new THREE.Geometry(); // //將參數geometry賦值給mesh對象的geometry屬性 this.material = material !== undefined ? material : new THREE.PointCloudMaterial( { color: Math.random() * 0xffffff } ); //將參數material賦值給PointCloud對象的material屬性,如果沒有傳遞material參數,將創建隨機色彩材質,賦值給當前PointCloud對象 this.sortParticles = false; //設置是不是排序粒子?? //TODO:sortParticles屬性沒有弄明白,有時間回來處理. }; /************************************************* ****下面是PointCloud對象的方法屬性定義,繼承自Object3D **************************************************/ THREE.PointCloud.prototype = Object.create( THREE.Object3D.prototype ); /* ///raycast方法用來取得當前對象與射線(參數raycaster)的交點.raycaster.intersectObject會調用這個方法。主要是用來進行碰撞檢測, /// 在選擇場景中的對象時常常會用到,判斷當前鼠標是不是與對象重適用來選擇對象. /// NOTE:raycast方法中參數intersects參數用來存儲交點的集合,格式以下 /// intersects.push( { /// /// distance: distance, /// point: intersectionPoint, /// indices: [ a, b, c ], /// face: null, /// faceIndex: null, /// object: this /// /// } ); /// *////raycast///射線對象///交點的屬性集合///交點的屬性集合THREE.PointCloud.prototype.raycast = ( function () { var inverseMatrix = new THREE.Matrix4(); //聲明1個4x4矩陣,用來放置逆矩陣 var ray = new THREE.Ray(); //聲明全局射線對象 return function ( raycaster, intersects ) { var object = this; var geometry = object.geometry; var threshold = raycaster.params.PointCloud.threshold; inverseMatrix.getInverse( this.matrixWorld ); ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix ); if ( geometry.boundingBox !== null ) { if ( ray.isIntersectionBox( geometry.boundingBox ) === false ) { return; } } var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); var position = new THREE.Vector3(); //檢查射線與點云元素是不是碰撞的具體實現. var testPoint = function ( point, index ) { var rayPointDistance = ray.distanceToPoint( point ); if ( rayPointDistance < localThreshold ) { var intersectPoint = ray.closestPointToPoint( point ); intersectPoint.applyMatrix4( object.matrixWorld ); var distance = raycaster.ray.origin.distanceTo( intersectPoint ); intersects.push( { distance: distance, distanceToRay: rayPointDistance, point: intersectPoint.clone(), index: index, face: null, object: object } ); } }; //如果geometry對象是BufferGeometry對象 if ( geometry instanceof THREE.BufferGeometry ) { var attributes = geometry.attributes; var positions = attributes.position.array; //下面對3種數據格式的pointCloud對象的元素進行檢測. if ( attributes.index !== undefined ) { var indices = attributes.index.array; var offsets = geometry.offsets; if ( offsets.length === 0 ) { var offset = { start: 0, count: indices.length, index: 0 }; offsets = [ offset ]; } for ( var oi = 0, ol = offsets.length; oi < ol; ++oi ) { var start = offsets[ oi ].start; var count = offsets[ oi ].count; var index = offsets[ oi ].index; for ( var i = start, il = start + count; i < il; i ++ ) { var a = index + indices[ i ]; position.set( positions[ a * 3 ], positions[ a * 3 + 1 ], positions[ a * 3 + 2 ] ); testPoint( position, a ); } } } else { var pointCount = positions.length / 3; for ( var i = 0; i < pointCount; i ++ ) { position.set( positions[ 3 * i ], positions[ 3 * i + 1 ], positions[ 3 * i + 2 ] ); testPoint( position, i ); } } } else { var vertices = this.geometry.vertices; for ( var i = 0; i < vertices.length; i ++ ) { testPoint( vertices[ i ], i ); } } }; }() ); /*clone方法 ///clone方法克隆1個PointCloud點云對象. */ ///clone///接收克隆的Object3D對象///返回PointCloud對象.THREE.PointCloud.prototype.clone = function ( object ) { if ( object === undefined ) object = new THREE.PointCloud( this.geometry, this.material ); object.sortParticles = this.sortParticles; THREE.Object3D.prototype.clone.call( this, object ); //繼承Object3D的clone方法 return object; //返回克隆的PointCloud對象 }; // Backwards compatibility 向后兼容,粒子系統唄點云對象替換.用法和THREE.PointCloud對象1樣. THREE.ParticleSystem = function ( geometry, material ) { console.warn( 'THREE.ParticleSystem has been renamed to THREE.PointCloud.' ); return new THREE.PointCloud( geometry, material ); };


商域無疆 (http://blog.csdn.net/omni360/)

本文遵守“署名-非商業用處-保持1致”創作公用協議

轉載請保存此句:商域無疆 -  本博客專注于 敏捷開發及移動和物聯裝備研究:數據可視化、GOLANG、Html5、WEBGL、THREE.JS否則,出自本博客的文章謝絕轉載或再轉載,謝謝合作。


以下代碼是THREE.JS 源碼文件中objects/PointCloud.js文件的注釋.

更多更新在 : https://github.com/omni360/three.js.sourcecode

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 亚洲一级片免费 | 精品视频在线观看免费 | 印度videos又粗又大 | 好吊妞国产欧美日韩视频 | 欧美a一片xxxx片 | 亚洲第一免费视频 | 一级做a爰全过程免费视频毛片 | 日本乱码一卡二卡三卡永久 | 青青草国产免费国产是公开 | 正在播放国产一区 | 性xxxx黑人与亚洲 | 一本久到久久亚洲综合 | 国产亚洲精品午夜高清影院 | 国产精品免费福利 | 中文字幕26页| 性短视频在线观看免费不卡流畅 | 欧美激情性xxxxx | 乱人伦视频69 | 2020国产精品久久久久 | 久久亚洲在线 | 日韩亚洲天堂 | 精品三级国产一区二区三区四区 | 亚洲精品美女国产一区 | 精品久久久久久国产91 | 老牛影视在线一区二观看 | 亚洲精品嫩草研究院久久 | 欧美一区二 | 亚州1区2区3区4区产品乱码2021 | 亚洲www色| 欧美成人天天综合在线视色 | 91免费影视 | 欧美性色综合网 | 精品一区二区三区自拍图片区 | 香蕉成人啪国产精品视频综合网 | 亚洲大片免费观看 | 最近免费中文字幕完整7 | 手机看片日韩日韩韩 | 免费乱码中文字幕网站 | 中文字幕免费在线看 | 亚洲国产网 | 国产欧美一区二区三区在线看 |