如何在Three.js中声明另一个对象的BufferGeometry?

时间:2019-02-21 13:32:11

标签: javascript three.js

我正在使用Three.js生成随机行,如in this fiddle所示。但是,我想知道是否可以访问另一个对象的缓冲区几何(在我的情况下为THREE.PerspectiveCamera),以便在该几何内部创建线(视图视锥)。我通过调用此命令发现了这一点:

var helperGeometry = camera_RT_Helper.geometry;
console.log(helperGeometry)

它将返回:

enter image description here

我用于分配BUFFER GEOMETRY的内容:

var myBufferGeometry = new THREE.BufferGeometry(); //Create geometry
myBufferGeometry.addAttribute( 'position', new THREE.BufferAttribute( vertices_Per_Point, 3 ) );

//Set Drawcalls (when drawing should start & end)
drawCount = 2; // draw the first 2 points, only
myBufferGeometry.setDrawRange( 0, drawCount );

//Create material with color and linewidth
var material = new THREE.LineBasicMaterial( { color: 0xff0000, linewidth: 2 } );

//Create ray according to camera's geometry and material
ray = new THREE.Line( myBufferGeometry,  material );

scene_Main.add(ray);

结果:

RESULTS IMAGE

我想做什么:

我正在尝试演示RayTracing。主要目标是从 startPoint (相机几何图形的近平面)到 endPoint (相机几何图形的远平面)拍摄N条光线。我尝试将 var myBufferGeometry 替换为相机的BufferGeometry var helperGeometry ,但是这里显示的很奇怪。

ISSUE IMAGE

以上内容可以实现吗?

0 个答案:

没有答案