-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
When the camera is set to orthographic rendering the cursor does not work as intended and does not hit the correct targets.
The code below is from my test implementation specifically for orthographic. This might be useful for the implementation.
private _applyTransformToDirection(): void {
this.object.transformVectorWorld(this._direction, this._direction);
this.object.getPositionWorld(this._origin);
const ndcX = (this._lastPointerPos[0] / window.innerWidth) * 2 - 1;
const ndcY = 1 - (this._lastPointerPos[1] / window.innerHeight) * 2;
const f = window.innerHeight / window.innerWidth;
const v = this._viewComponent.extent / 2;
const localPosition = vec3.fromValues(ndcX * v, ndcY * v * f, 50);
const rotationQuat = quat.create();
this.object.getRotationWorld(rotationQuat);
vec3.transformQuat(localPosition, localPosition, rotationQuat);
const playerPos = vec3.create();
this.player.getPositionWorld(playerPos);
vec3.add(localPosition, localPosition, playerPos);
vec3.set(this._origin, localPosition[0], localPosition[1] + 1, localPosition[2]);
}Metadata
Metadata
Assignees
Labels
No labels