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

Make Cesium's shaders editable with the SpectorJS shader editor #8608

Merged
merged 5 commits into from
Mar 27, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix eslint problems.
  • Loading branch information
kring committed Feb 12, 2020
commit e5d3fd31f1dd6609bc4d9e2deee52754e85ed54f
8 changes: 4 additions & 4 deletions Source/Renderer/ShaderProgram.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import createUniformArray from './createUniformArray.js';
var fragmentShaderText = options.fragmentShaderText;

if (window.spector) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we don't do a good job of it everywhere, in general this should be typeof spector !== 'undefined' instead using window, since window doesn't exist in all contexts (workers/node/etc..) it's a more robust check for a global spector variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

// The #line statements common Cesium shaders interfere with the ability of the
// The #line statements common in Cesium shaders interfere with the ability of the
// SpectorJS to show errors on the correct line. So remove them when SpectorJS
// is active.
vertexShaderText = vertexShaderText.replace(/^#line/mg, '//#line');
@@ -448,7 +448,7 @@ import createUniformArray from './createUniformArray.js';
}

function reinitialize(shader) {
const oldProgram = shader._program;
var oldProgram = shader._program;

var gl = shader._gl;
var program = createAndLinkProgram(gl, shader, shader._debugShaders);
@@ -484,7 +484,7 @@ import createUniformArray from './createUniformArray.js';

// SpectorJS likes to replace `!=` with `! =` for unknown reasons,
// and that causes glsl compile failures. So fix that up.
const regex = / ! = /g;
var regex = / ! = /g;
shader._vertexShaderText = vertexSourceCode.replace(regex, ' != ');
shader._fragmentShaderText = fragmentSourceCode.replace(regex, ' != ');

@@ -497,7 +497,7 @@ import createUniformArray from './createUniformArray.js';

// Only pass on the WebGL error:
var errorMatcher = /(?:Compile|Link) error: ([^]*)/;
const match = errorMatcher.exec(e.message);
var match = errorMatcher.exec(e.message);
if (match) {
onError(match[1]);
} else {