openfl / away3d

An open source, real-time 3D engine for OpenFL
Apache License 2.0
206 stars 34 forks source link

View3D project bug in shareContext #32

Open tsmithf opened 5 years ago

tsmithf commented 5 years ago

As per this post on the Away3D forum...

Away3D Forum Post

Can this please get implemented in the openfl Away3D code, as project returns incorrect results when using shareContext otherwise.

peteshand commented 5 years ago

Based on that post it doesn't sound like the away3d source code was changed.. they're simply suggesting to set the viewport x and y:

v.x = (v.x + 1.0) _width / 2.0 (stage3DProxy.width / _width); v.y = (v.y + 1.0) _height / 2.0 (stage3DProxy.height / _height);

tsmithf commented 5 years ago

I believe it may be referring to an amendment to the project function in containers\View3D.hx...

public function project(point3d:Vector3D):Vector3D { var v:Vector3D = _camera.project(point3d);

    if (!shareContext){
        v.x = (v.x + 1.0)*_globalWidth/2.0;
        v.y = (v.y + 1.0)*_globalHeight/2.0;
    }else{
        v.x = (v.x + 1.0) * _width / 2.0 * (stage3DProxy.width / _width);
        v.y = (v.y + 1.0) * _height / 2.0 * (stage3DProxy.height / _height);
    }
    return v;
}