/**
* @en Transform a world space position to screen space rendered by the camera
* @zh 将一个世界空间位置转换到相机渲染后的屏幕空间
* @param out the resulting vector
* @param worldPos the world position to be transformed
* @returns the resulting vector
*/
public worldToScreen(out: Vec3, worldPos: Vec3 | Readonly): Vec3 {
const ySign = this._device.capabilities.clipSpaceSignY;
const preTransform = preTransforms[this._curTransform];
Vec3.transformMat4(out, worldPos, this._matViewProj);
const { x, y } = out;
out.x = x * preTransform[0] + y * preTransform[2] * ySign;
out.y = x * preTransform[1] + y * preTransform[3] * ySign;
const width = this.width;
const height = this.height;
const cx = this._orientedViewport.x * width;
const cy = this._orientedViewport.y * height;
const cw = this._orientedViewport.width * width;
const ch = this._orientedViewport.height * height;
out.x = cx + (out.x + 1) * 0.5 * cw;
out.y = cy + (out.y + 1) * 0.5 * ch;
out.z = out.z * 0.5 + 0.5;
return out;
}
这个方法对于3d场景的正交相机获得结果不对呢