Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render Geometry with indices that are not a typed array #4419

Merged
merged 1 commit into from
Oct 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');