Skip to content

Image distortion  #58

@dev1intellial

Description

@dev1intellial

I am drawing 3D shape using parallax library. I have use MeshLambertMaterial to draw this shape but image is not showing properly.

lvlkl

I have used antiliasing true but still problem is there. What are the possibilities cause for this type of issue?

I have used below code :

private Line getLine(Geometry geometry) {
if (line  == null) {
  line = new Line(geometry, getLineMaterial());      
  line.getRotation().set(-1.58, 0, -6.3);
  line.getScale().set(1);
  }
 return line;
}

private LineBasicMaterial getLineMaterial() {
if (lineMaterial == null) {
  lineMaterial = new LineBasicMaterial();
}
 return lineMaterial;
}

private Mesh getMesh(Geometry geometry) {
if (mesh == null) {
  mesh = new Mesh(geometry, getMeshMaterial());
  mesh.getRotation().set(-1.58, 0, -6.3); 
  mesh.getScale().set(1);
  }

return mesh;
}

private MeshLambertMaterial getMeshMaterial() {
if (meshMaterial == null) {
  meshMaterial = new MeshLambertMaterial();
  meshMaterial.setShading(Material.SHADING.FLAT);
  meshMaterial.materialNeedsSmoothNormals();
  meshMaterial.setReflectivity(50);
}

 return meshMaterial;
}

private Object3D getObject3D() {
if (object3D == null) {
  object3D = new Object3D();  
  object3D.getPosition().setY(48);
  if (topView) { 
    if (xAngle == 0 && yAngle == 0) {
      if (doAnimate) object3D.getRotation().set(-0.25, 0.26, 0);
      else object3D.getRotation().set(0.00, 0.0, 0);
    }
    else object3D.getRotation().set(xAngle, yAngle, 0);
  }
  else { 
    object3D.getRotation().set(0.321, 0.26, 0);
  }
}
  return object3D;
} 

long start = 0;

@Override
protected void onStart() {    
start = System.currentTimeMillis();
drawShape();
double camPositionX = 0;

if (yValue == 0) camPositionY = (45  + (elementPosition / 2));
else camPositionY = (45  + (elementPosition / 2)) - yValue;

if (xValue == 0) camPositionX = 0;
else if (xValue > 0) camPositionX = 110 + xValue;
else camPositionX = 0 + xValue;

getCamera().getPosition().set(camPositionX, camPositionY, camPositionZ);  
getScene().add(getHemisphereLight());
getScene().add(getDirectionalLightTop());
getScene().add(getDirectionalLightBottom());
}

@Override
protected void onUpdate(double duration) {
if (doAnimate) {
  double topX = 0.2 * 0.0321;
  double topY = 0.2 * 0.026;      

  if (getObject3D() != null) {
    if (topView) {
      if (getDoubleValue(getObject3D().getRotation().getX(), 2).equals("0.32")) {
        xTopRotation = true;
        doRender = true;
      }

      if (getDoubleValue(getObject3D().getRotation().getY(), 2).equals("0.26")) {
        yTopRotation = true;
      }

      if (!xTopRotation ) {
        if (!getDoubleValue(getObject3D().getRotation().getX(), 2).equals("0.32") ) {
          getObject3D().getRotation().addX( topX );
          topX += topX;
        }
      }

      if (!yTopRotation) {
        if (!getDoubleValue(getObject3D().getRotation().getY(), 2).equals("0.26")) {
          getObject3D().getRotation().addY(topY);
          topY += topY;
        }
      }
    }
    else {
      double bottomX = 0.2 * 0.0321;

      if (getDoubleValue(getObject3D().getRotation().getX(), 2).equals("-.25") ) {
        xBottomRotation = true;
        doRender = true;
      }

      if (!xBottomRotation) {    
        if (!getDoubleValue(getObject3D().getRotation().getX(), 2).equals("-.25") ) {
          getObject3D().getRotation().addX(-bottomX ); 
          bottomX += bottomX;
        }
      }
    }
  }    
}

if (!doRender && doAnimate) {
  getRenderer().clear();
  getRenderer().render(getScene(), getCamera());
}
else if (genRender == 0) {
  genRender ++;
  getRenderer().clear();
  getRenderer().render(getScene(), getCamera());
}
}   
}


   // For rendering panel Used below code : 
    renderingPanel = new RenderingPanel();
    renderingPanel.setSize(370+"px", 236+"px");
    renderingPanel.setBackground(0x000000);
    renderingPanel.addCanvas3dErrorHandler(this);
    renderingPanel.addSceneLoadingHandler(this);
    renderingPanel.setAnimatedScene(new ThreeDImage(getCanvasPanel().getElement(), "4", "1.55", "18", "18", "Green", "White", "Green", "White", "AnyLF", topView, 0, 0, 0.321, 0.26, "No", "No"));

   //getCanvasPanel().clear();
   getCanvasPanel().add(getImagePanel());
   getCanvasPanel().add(renderingPanel);
   RootPanel.get("image").add(getMainPanel());

The main issue is that when Object position is (0, 0, 0) but when position is changing then image is not rotating correctly. Means image is going to distorted when object is rotating. Tha main issue coming form onStart() , onUpdate() and getObject3D() method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions