Skip to content

Commit

Permalink
Merge pull request #4419 from AnalyticalGraphicsInc/non-typed-array-p…
Browse files Browse the repository at this point in the history
…rimitive

Render Geometry with indices that are not a typed array
  • Loading branch information
pjcozzi authored Oct 15, 2016
2 parents 86a7685 + a18cf16 commit 0f859ec
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/Scene/Primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,11 @@ define([
var indices;
if (defined(geometry.indices)) {
var sourceValues = geometry.indices;
indices = new sourceValues.constructor(sourceValues);
if (isArray(sourceValues)) {
indices = sourceValues.slice(0);
} else {
indices = new sourceValues.constructor(sourceValues);
}
}

return new Geometry({
Expand Down
49 changes: 49 additions & 0 deletions Specs/Scene/GeometryRenderingSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,55 @@ defineSuite([
pickGeometry(instance);
});
}, 'WebGL');

describe('with native arrays as attributes and indices', function() {
var instance;
beforeAll(function() {
instance = new GeometryInstance({
geometry : new Geometry({
attributes : {
position : new GeometryAttribute({
componentDatatype : ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : [
1000000.0, 0.0, 0.0,
1000000.0, 1000000.0, 0.0,
1000000.0, 0.0, 1000000.0,
1000000.0, 1000000.0, 1000000.0
]
})
},
indices : [0, 1, 2, 2, 1, 3],
primitiveType : PrimitiveType.TRIANGLES
}),
modelMatrix : Matrix4.multiplyByTranslation(Transforms.eastNorthUpToFixedFrame(
Cartesian3.fromDegrees(0,0)), new Cartesian3(0.0, 0.0, 10000.0), new Matrix4()),
id : 'customWithIndices',
attributes : {
color : new ColorGeometryInstanceAttribute(1.0, 1.0, 1.0, 1.0)
}
});
geometry = instance.geometry;
geometry.boundingSphere = BoundingSphere.fromVertices(instance.geometry.attributes.position.values);
geometry.boundingSphereWC = BoundingSphere.transform(geometry.boundingSphere, instance.modelMatrix);
});

it('3D', function() {
render3D(instance);
});

it('Columbus view', function() {
renderCV(instance);
});

it('2D', function() {
render2D(instance);
});

it('pick', function() {
pickGeometry(instance);
});
}, 'WebGL');
});

}, 'WebGL');

0 comments on commit 0f859ec

Please sign in to comment.