hi. I want to check the camera can see the point. and I caculate the worldviewProject like which is the Vertex shader has.
the code:
// worldViewProjectionMatrix = world * view * projection
// worldViewProjectionMatrix * vector
var viewport = camera.viewport.toGlobal(engine);
var cw = viewport.width;
var ch = viewport.height;
var cx = viewport.x;
var cy = viewport.y;
var viewportMatrix = BABYLON.Vector3._viewportMatrixCache ? BABYLON.Vector3._viewportMatrixCache : (BABYLON.Vector3._viewportMatrixCache = new BABYLON.Matrix());
BABYLON.Matrix.FromValuesToRef(cw / 2.0, 0, 0, 0, 0, -ch / 2.0, 0, 0, 0, 0, 1, 0, cx + cw / 2.0, ch / 2.0 + cy, 0, 1, viewportMatrix);
var matrix = BABYLON.Vector3._matrixCache ? BABYLON.Vector3._matrixCache : (BABYLON.Vector3._matrixCache = new BABYLON.Matrix());
BABYLON.Matrix.Identity().multiplyToRef( viewportMatrix , matrix);
matrix.multiplyToRef(camera.getProjectionMatrix(), matrix);
var p2 = BABYLON.Vector3.TransformCoordinates(vector, matrix)
//BABYLON.Vector3.Project(vector, world, transform, viewport)
var p = BABYLON.Vector3.Project(vector,
BABYLON.Matrix.Identity(),
scene.getTransformMatrix(), //scene.getTransformMatrix(),
camera.viewport.toGlobal(engine));
console.log(p);
console.log(p2);
// p and p2 xy not like
help.