Skip to content

Commit

Permalink
Set program correctly for other primitive with the same program
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Mar 30, 2020
1 parent 41dab42 commit 8ca78f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/moveTechniquesToExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ function moveTechniquesToExtension(gltf) {
});

if (!defined(seenPrograms[techniqueLegacy.program])) {
seenPrograms[techniqueLegacy.program] = true;

const programLegacy = gltf.programs[techniqueLegacy.program];

const program = {
Expand All @@ -86,6 +84,9 @@ function moveTechniquesToExtension(gltf) {
program.vertexShader = addToArray(extension.shaders, vs, true);

technique.program = addToArray(extension.programs, program);
seenPrograms[techniqueLegacy.program] = technique.program;
} else {
technique.program = seenPrograms[techniqueLegacy.program];
}

// Store the index of the new technique to reference instead.
Expand Down
3 changes: 2 additions & 1 deletion specs/lib/moveTechniquesToExtensionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const moveTechniquesToExtension = require('../../lib/moveTechniquesToExtension')

const WebGLConstants = Cesium.WebGLConstants;
describe('moveTechniquesToExtension', () => {
it('moves techniques, shaders, and programs to extension', () => {
fit('moves techniques, shaders, and programs to extension', () => {
const gltf = {
programs: {
program_0: {
Expand Down Expand Up @@ -192,6 +192,7 @@ describe('moveTechniquesToExtension', () => {
expect(program2.fragmentShader).not.toBe(program.fragmentShader);

const technique3 = techniques.techniques[2];
expect(technique3.program).toBe(0);
expect(technique3.uniforms.u_diffuse.type).toBe(WebGLConstants.FLOAT_VEC4);
expect(gltf.materials[1].extensions.KHR_techniques_webgl.values.u_diffuse).toEqual([0.2, 0.2, 0.2, 1.0]);
});
Expand Down

0 comments on commit 8ca78f7

Please sign in to comment.