使用three.js

时间:2017-03-19 03:05:48

标签: javascript three.js

如何绘制凹面镜和入射光线以及反射光线。 我做了以下但导致非常烦人的结果。 我用ellipseCurve画镜子。

var curve = new THREE.EllipseCurve(
0,  0,            // ax, aY
10, 10,           // xRadius, yRadius
0,  2 * Math.PI,  // aStartAngle, aEndAngle
false,            // aClockwise
0                 // aRotation
);
var path = new THREE.Path( curve.getPoints( 50 ) ); 
var geometry = path.createPointsGeometry( 50 );
var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
// Create the final object to add to the scene
var ellipse = new THREE.Line( geometry, material );
scene.add(ellipse);

用于通过更改源点和目标点来绘制对象和入射光线以及反射光线

var sourcePos= new THREE.Vector3(ObjectPositionX,ObjectPositionY,0);
var targetPos = new THREE.Vector3(FocusPointX,FocusPointY,0);
var direction = new THREE.Vector3().sub(targetPos, sourcePos);
var rayParallel = new THREE.ArrowHelper(direction.clone().normalize(), sourcePos, direction.length(), 0x00ff00);
scene.add(rayParallel);

我的结果的屏幕截图是 Image Formed by concave mirror

建议任何其他方法来解决这个问题也是值得赞赏的。

0 个答案:

没有答案