Skip to content

Commit

Permalink
Merge pull request Gaia3D#586 from Gaia3D/feature/nativeProjects_19
Browse files Browse the repository at this point in the history
Feature/native projects 19
  • Loading branch information
sdson authored Apr 19, 2018
2 parents c65540f + a7754f8 commit 8f8a292
Show file tree
Hide file tree
Showing 15 changed files with 1,018 additions and 531 deletions.
1 change: 1 addition & 0 deletions sample/cesium.html
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ <h3>View Mode</h3>
<script type="text/javascript" src="../src/mago3d/f4d/ReaderWriter.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/Arc.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/AxisXYZ.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/BoxAux.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/BoundingRectangle.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/Circle.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/HalfEdge.js"></script>
Expand Down
1 change: 1 addition & 0 deletions sample/worldwind.html
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ <h3>View Mode</h3>
<script type="text/javascript" src="../src/mago3d/f4d/ReaderWriter.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/Arc.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/AxisXYZ.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/BoxAux.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/BoundingRectangle.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/Circle.js"></script>
<script type="text/javascript" src="../src/mago3d/geometry/HalfEdge.js"></script>
Expand Down
183 changes: 87 additions & 96 deletions src/mago3d/core/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,125 +11,116 @@ var Box = function()
throw new Error(Messages.CONSTRUCT_ERROR);
}

// vertex indices of the box.***
// 3----------2 7----------6
// | | | |
// | bottom | | top |
// | | | |
// 0----------1 4----------5

this.triPolyhedron = new TriPolyhedron();
this.vbo_vicks_container = new VBOVertexIdxCacheKeysContainer();
this.vBOVertexIdxCacheKey = this.vbo_vicks_container.newVBOVertexIdxCacheKey();
this.vbo_vicks_containerEdges;
this.centerPoint;
this.width;
this.length;
this.height;

};

/**
* axis aligned bounding box
* @param xLength
* @param yLength
* @param zLength
* box
*/
Box.prototype.getVboKeysContainer = function()
{
return this.vbo_vicks_container;
};

/**
* axis aligned bounding box
* @param xLength
* @param yLength
* @param zLength
* box
*/
Box.prototype.makeAABB = function(xLength, yLength, zLength)
Box.prototype.makeMesh = function(width, length, height)
{
// this makes a box centered on the center of the box.***
var minX = -xLength/2.0;
var minY = -yLength/2.0;
var minZ = -zLength/2.0;

var maxX = xLength/2.0;
var maxY = yLength/2.0;
var maxZ = zLength/2.0;

// make 8 vertices and 6 triSurfaces.***
var vertexList = this.triPolyhedron.vertexList;

// Bottom.****
var vertex = vertexList.newVertex(); // 0.***
vertex.setPosition(minX, minY, minZ);

vertex = vertexList.newVertex(); // 1.***
vertex.setPosition(maxX, minY, minZ);

vertex = vertexList.newVertex(); // 2.***
vertex.setPosition(maxX, maxY, minZ);

vertex = vertexList.newVertex(); // 3.***
vertex.setPosition(minX, maxY, minZ);

// Top.***
vertex = vertexList.newVertex(); // 4.***
vertex.setPosition(minX, minY, maxZ);

vertex = vertexList.newVertex(); // 5.***
vertex.setPosition(maxX, minY, maxZ);

vertex = vertexList.newVertex(); // 6.***
vertex.setPosition(maxX, maxY, maxZ);

vertex = vertexList.newVertex(); // 7.***
vertex.setPosition(minX, maxY, maxZ);

// check dimensions of the box.***
if(width !== undefined)
this.width = width;

// now, create triSurfaces and triangles.***
var triSurface;
var triangle;
// Bottom surface.***
triSurface = this.triPolyhedron.newTriSurface();
triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(0), vertexList.getVertex(2), vertexList.getVertex(1));
if(length !== undefined)
this.length = length;

triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(0), vertexList.getVertex(3), vertexList.getVertex(2));
if(height !== undefined)
this.height = height;

// Top surface.***
triSurface = this.triPolyhedron.newTriSurface();
triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(4), vertexList.getVertex(5), vertexList.getVertex(6));
if(this.width === undefined)
this.width = 1;

triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(4), vertexList.getVertex(6), vertexList.getVertex(7));
if(this.length === undefined)
this.length = 1;

// Front surface.***
triSurface = this.triPolyhedron.newTriSurface();
triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(0), vertexList.getVertex(1), vertexList.getVertex(5));
if(this.height === undefined)
this.height = 1;

triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(0), vertexList.getVertex(5), vertexList.getVertex(4));
if(this.centerPoint === undefined)
this.centerPoint = new Point3D(0,0,0);

// Right surface.***
triSurface = this.triPolyhedron.newTriSurface();
triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(1), vertexList.getVertex(2), vertexList.getVertex(6));
if(this.vbo_vicks_container === undefined)
this.vbo_vicks_container = new VBOVertexIdxCacheKeysContainer();

triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(1), vertexList.getVertex(6), vertexList.getVertex(5));
if(this.vbo_vicks_containerEdges === undefined)
this.vbo_vicks_containerEdges = new VBOVertexIdxCacheKeysContainer();

// Rear surface.***
triSurface = this.triPolyhedron.newTriSurface();
triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(2), vertexList.getVertex(3), vertexList.getVertex(7));
// Create a parametric mesh.***
var pMesh = new ParametricMesh();

// Create a Profile2d.***
pMesh.profile = new Profile();
var profileAux = pMesh.profile;

triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(2), vertexList.getVertex(7), vertexList.getVertex(6));
// Create a outer ring in the Profile2d.***
var outerRing = profileAux.newOuterRing();
var rect = outerRing.newElement("RECTANGLE");
rect.setCenterPosition(this.centerPoint.x, this.centerPoint.y);
rect.setDimensions(this.width, this.length);

// Left surface.***
triSurface = this.triPolyhedron.newTriSurface();
triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(3), vertexList.getVertex(0), vertexList.getVertex(4));
// Extrude the Profile.***
var extrudeSegmentsCount = 1;
var extrusionVector = undefined;
pMesh.extrude(profileAux, this.height, extrudeSegmentsCount, extrusionVector);

triangle = triSurface.newTriangle();
triangle.setVertices(vertexList.getVertex(3), vertexList.getVertex(4), vertexList.getVertex(7));
var bIncludeBottomCap = true;
var bIncludeTopCap = true;
var mesh = pMesh.getSurfaceIndependentMesh(undefined, bIncludeBottomCap, bIncludeTopCap);

};
// translate the box bcos center the origen to the center of the box.***
mesh.translate(0,0,-this.height/2);

return mesh;
};




































74 changes: 72 additions & 2 deletions src/mago3d/core/FBO.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ var FBO = function(gl, width, height)
}

this.gl = gl;
this.width = width;
this.height = height;
this.width = new Int32Array(1);
this.height = new Int32Array(1);
this.width[0] = width;
this.height[0] = height;
this.fbo = gl.createFramebuffer();
this.depthBuffer = gl.createRenderbuffer();
this.colorBuffer = gl.createTexture();
Expand Down Expand Up @@ -59,4 +61,72 @@ FBO.prototype.unbind = function()
{
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
};

/**
* 어떤 일을 하고 있습니까?
*/
FBO.prototype.deleteObjects = function(gl)
{
if(this.depthBuffer)
gl.deleteRenderbuffer(this.depthBuffer);
this.depthBuffer = undefined;

if(this.colorBuffer)
gl.deleteTexture(this.colorBuffer);
this.colorBuffer = undefined;

if(this.fbo)
gl.deleteFramebuffer(this.fbo);
this.fbo = undefined;


};

















































Loading

0 comments on commit 8f8a292

Please sign in to comment.