Why cant I do this:
Raycast.prototype.doRayCast = function (screenPosition) {
// Initialise the ray and work out the direction of the ray from the a screen position
this.cameraEntity.camera.screenToWorld(screenPosition.x, screenPosition.y, this.cameraEntity.camera.farClip, this.ray.direction);
this.ray.origin.copy(this.cameraEntity.getPosition());
this.ray.direction.sub(this.ray.origin).normalize();
var result = this.aabbShape.intersectsRay(this.ray, this.hitPosition);
if (result) {
// this.hitMarkerEntity.setPosition(this.hitPosition);
console.log("result"+ result);
var from = this.entity.camera.screenToWorld(screenPosition.x, screenPosition.y, this.entity.camera.nearClip);
var to = this.entity.camera.screenToWorld(screenPosition.x, screenPosition.y, this.entity.camera.farClip);
console.log("gregr: "+from + " :: "+to);
//this.app.systems.rigidbody.raycastFirst(from, to, function (result2) {
var point = new pc.Vec3(); var normal = new pc.Vec3();
var result2 = this.RaycastResult(this.resEntity, point, normal);//this.aabbShape.intersectsRay(this.ray, this.hitPosition);
console.log("Entity picked is: " + this.resEntity.entity.name);
// });
}
};
By the way, the documentation here: https://developer.playcanvas.com/en/api/pc.RaycastResult.html
- is poorly written/structured. No actual method/how-to-use code is displayed.