-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Splat shader #12364
base: main
Are you sure you want to change the base?
Splat shader #12364
Changes from all commits
0103673
ea53962
60022f4
ba77e31
8d67853
9aaf292
8c3aea4
7a3f472
4f9c886
b235c09
df28196
bdf4eb5
7a4c864
c6b8d25
a03abdd
7d5b09a
0620dca
fe340a4
e352ca2
3e74c74
d5f4069
13dfa78
31e8d13
947d9e0
9862eeb
0069114
427d490
fcfc3df
f4657c6
2270dae
fb180f6
43c08cf
2b1e72a
52b3d61
f207786
18d75d2
ddceea8
d2441cf
3c7bae6
6061b17
b2f5aa2
361312b
1991389
baf322d
bf4ab9d
de96ac6
276a410
fb0559b
6874e72
2ed9de4
62116b5
f0237a7
c858f03
7142df3
eb1db94
811338a
ce0976f
635659e
edca8a8
a327c88
b0bde10
ef2ec34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/node_modules | ||
/ThirdParty | ||
/Tools/** | ||
temp_wasm/* | ||
|
||
LICENSE.md |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,108 @@ | ||||||||||||||||||||||||||
<!doctype html> | ||||||||||||||||||||||||||
<html lang="en"> | ||||||||||||||||||||||||||
<head> | ||||||||||||||||||||||||||
<meta charset="utf-8" /> | ||||||||||||||||||||||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||||||||||||||||||||||||||
<meta | ||||||||||||||||||||||||||
name="viewport" | ||||||||||||||||||||||||||
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" | ||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||
<meta | ||||||||||||||||||||||||||
name="description" | ||||||||||||||||||||||||||
content="Use Viewer to start building new applications or easily embed Cesium into existing applications." | ||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||
<meta name="cesium-sandcastle-labels" content="Showcases, 3D Tiles" /> | ||||||||||||||||||||||||||
<title>Cesium Demo</title> | ||||||||||||||||||||||||||
<script type="text/javascript" src="../Sandcastle-header.js"></script> | ||||||||||||||||||||||||||
<script type="module" src="../load-cesium-es6.js"></script> | ||||||||||||||||||||||||||
</head> | ||||||||||||||||||||||||||
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> | ||||||||||||||||||||||||||
<style> | ||||||||||||||||||||||||||
@import url(../templates/bucket.css); | ||||||||||||||||||||||||||
</style> | ||||||||||||||||||||||||||
<div id="cesiumContainer" class="fullSize"></div> | ||||||||||||||||||||||||||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||||||||||||||||||||||||||
<div id="toolbar"></div> | ||||||||||||||||||||||||||
<script id="cesium_sandcastle_script"> | ||||||||||||||||||||||||||
window.startup = async function (Cesium) { | ||||||||||||||||||||||||||
"use strict"; | ||||||||||||||||||||||||||
//Sandcastle_Begin | ||||||||||||||||||||||||||
Cesium.Ion.defaultAccessToken = | ||||||||||||||||||||||||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2MWEyNWI4NS02ZWVmLTQyZTEtOTRjZi02NjljOWNhOWViNGEiLCJpZCI6MTQwNTg1LCJpYXQiOjE3MzYzNjg4OTR9.rIAEC387JLBYOPt3w1fliKTWZgTGCQYJlG8o5HJsTwY"; | ||||||||||||||||||||||||||
const viewer = new Cesium.Viewer("cesiumContainer"); | ||||||||||||||||||||||||||
viewer.scene.debugShowFramesPerSecond = true; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const ORBIT_RANGE_FACTOR = 3; | ||||||||||||||||||||||||||
const ORBIT_PITCH_DIVIDEND = 8; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
let cellTowerTileset; | ||||||||||||||||||||||||||
Cesium.Cesium3DTileset.fromIonAssetId(2917325, { | ||||||||||||||||||||||||||
maximumScreenSpaceError: 1, | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is |
||||||||||||||||||||||||||
}).then((tileset) => { | ||||||||||||||||||||||||||
cellTowerTileset = tileset; | ||||||||||||||||||||||||||
viewer.scene.primitives.add(cellTowerTileset); | ||||||||||||||||||||||||||
setupCamera(); | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
Comment on lines
+39
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Going forward, we prefer async/await syntax over promise chains:
Suggested change
To make eslint happy, you may also need to move the call to |
||||||||||||||||||||||||||
let startTime; | ||||||||||||||||||||||||||
let isRunning = false; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
function setupCamera() { | ||||||||||||||||||||||||||
const boundingSphere = cellTowerTileset.boundingSphere; | ||||||||||||||||||||||||||
const heading = 0; | ||||||||||||||||||||||||||
const range = boundingSphere.radius * ORBIT_RANGE_FACTOR; | ||||||||||||||||||||||||||
const pitch = -Math.PI / ORBIT_PITCH_DIVIDEND; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
viewer.camera.lookAt( | ||||||||||||||||||||||||||
boundingSphere.center, | ||||||||||||||||||||||||||
new Cesium.HeadingPitchRange(heading, pitch, range), | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
function startCameraOrbit() { | ||||||||||||||||||||||||||
if (!setupCamera()) { | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would this return false? |
||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
startTime = performance.now(); | ||||||||||||||||||||||||||
isRunning = true; | ||||||||||||||||||||||||||
requestAnimationFrame(cameraOrbitTickCallback); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
function cameraOrbitTickCallback(timestamp) { | ||||||||||||||||||||||||||
if (!isRunning) { | ||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const boundingSphere = cellTowerTileset.boundingSphere; | ||||||||||||||||||||||||||
const elapsedSeconds = (timestamp - startTime) / 1000; | ||||||||||||||||||||||||||
const heading = (elapsedSeconds / 15) * Math.PI * 2; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const range = boundingSphere.radius * ORBIT_RANGE_FACTOR; | ||||||||||||||||||||||||||
const pitch = -Math.PI / ORBIT_PITCH_DIVIDEND; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
viewer.camera.lookAt( | ||||||||||||||||||||||||||
boundingSphere.center, | ||||||||||||||||||||||||||
new Cesium.HeadingPitchRange(heading, pitch, range), | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
requestAnimationFrame(cameraOrbitTickCallback); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Sandcastle.addToolbarButton("Start Orbit", startCameraOrbit); | ||||||||||||||||||||||||||
Sandcastle.addToolbarButton("Stop Orbit", () => { | ||||||||||||||||||||||||||
isRunning = false; | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
//Sandcastle_End | ||||||||||||||||||||||||||
Sandcastle.finishedLoading(); | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
if (typeof Cesium !== "undefined") { | ||||||||||||||||||||||||||
window.startupCalled = true; | ||||||||||||||||||||||||||
window.startup(Cesium).catch((error) => { | ||||||||||||||||||||||||||
"use strict"; | ||||||||||||||||||||||||||
console.error(error); | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||
</body> | ||||||||||||||||||||||||||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,6 +373,11 @@ export async function prepare() { | |
"Tools/jsdoc/cesium_template/static/styles/prism.css", | ||
); | ||
|
||
copyFileSync( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nit-picky, but can we move this line up with the other source code dependencies up around line 351? It will help it not get lost among the other dev processes like building documentation. |
||
"node_modules/@cesium/wasm-splats/wasm_splats_bg.wasm", | ||
"packages/engine/Source/ThirdParty/wasm_splats_bg.wasm", | ||
); | ||
|
||
// Copy jasmine runner files into Specs | ||
const files = await globby([ | ||
"node_modules/jasmine-core/lib/jasmine-core", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,8 @@ | |
], | ||
"dependencies": { | ||
"@cesium/engine": "^13.1.0", | ||
"@cesium/widgets": "^10.1.0" | ||
"@cesium/widgets": "^10.1.0", | ||
"@cesium/wasm-splats": "file:./temp_wasm/pkg" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The root dependencies here should only include the packages in this repo. The |
||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.41.1", | ||
|
@@ -159,4 +160,4 @@ | |
"packages/engine", | ||
"packages/widgets" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ function Context(canvas, options) { | |
} = defaultValue(options, {}); | ||
|
||
// Override select WebGL defaults | ||
webglOptions.alpha = defaultValue(webglOptions.alpha, false); // WebGL default is true | ||
webglOptions.alpha = defaultValue(webglOptions.alpha, true); // WebGL default is true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain a bit why this was changed? It look like a fundamental change which could cause unintended effects on the rest of the codebase. |
||
webglOptions.stencil = defaultValue(webglOptions.stencil, true); // WebGL default is false | ||
webglOptions.powerPreference = defaultValue( | ||
webglOptions.powerPreference, | ||
|
@@ -1308,6 +1308,7 @@ function beginDraw( | |
bindFramebuffer(context, framebuffer); | ||
applyRenderState(context, renderState, passState, false); | ||
shaderProgram._bind(); | ||
|
||
context._maxFrameTextureUnitIndex = Math.max( | ||
context._maxFrameTextureUnitIndex, | ||
shaderProgram.maximumTextureUnitIndex, | ||
|
@@ -1382,6 +1383,7 @@ function continueDraw(context, drawCommand, shaderProgram, uniformMap) { | |
} else { | ||
count = va.numberOfVertices; | ||
} | ||
|
||
if (instanceCount === 0) { | ||
context._gl.drawArrays(primitiveType, offset, count); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,9 +340,17 @@ function loadBufferSource(texture, source) { | |
pixelDatatype, | ||
width, | ||
); | ||
|
||
let glErr; | ||
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment); | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); | ||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); | ||
glErr = gl.getError(); | ||
if (glErr !== 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and below: Opt to throw a |
||
console.log( | ||
`pixelStorei err ${glErr}, format ${pixelFormat} internalFormat ${internalFormat}`, | ||
); | ||
} | ||
|
||
let { arrayBufferView } = source; | ||
if (flipY) { | ||
|
@@ -365,6 +373,12 @@ function loadBufferSource(texture, source) { | |
PixelDatatype.toWebGLConstant(pixelDatatype, context), | ||
arrayBufferView, | ||
); | ||
glErr = gl.getError(); | ||
if (glErr !== 0) { | ||
console.log( | ||
`texImage2D err ${glErr}, format ${pixelFormat} internalFormat ${internalFormat}`, | ||
); | ||
} | ||
|
||
if (defined(source.mipLevels)) { | ||
let mipWidth = width; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import RuntimeError from "../Core/RuntimeError.js"; | |
import Buffer from "./Buffer.js"; | ||
import BufferUsage from "./BufferUsage.js"; | ||
import ContextLimits from "./ContextLimits.js"; | ||
import AttributeType from "../Scene/AttributeType.js"; | ||
|
||
function addAttribute(attributes, attribute, index, context) { | ||
const hasVertexBuffer = defined(attribute.vertexBuffer); | ||
|
@@ -648,6 +649,7 @@ VertexArray.fromGeometry = function (options) { | |
componentDatatype = ComponentDatatype.FLOAT; | ||
} | ||
|
||
let attrProps = {}; | ||
vertexBuffer = undefined; | ||
if (defined(attribute.values)) { | ||
vertexBuffer = Buffer.createVertexBuffer({ | ||
|
@@ -658,16 +660,48 @@ VertexArray.fromGeometry = function (options) { | |
), | ||
usage: bufferUsage, | ||
}); | ||
|
||
attrProps = { | ||
index: attributeLocations[name], | ||
vertexBuffer: vertexBuffer, | ||
value: attribute.value, | ||
componentDatatype: componentDatatype, | ||
componentsPerAttribute: attribute.componentsPerAttribute, | ||
normalize: attribute.normalize, | ||
}; | ||
} | ||
|
||
//if we already have a typedArray lets use it | ||
if (defined(attribute.typedArray)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change does seem to make sense, but we should confirm this doesn't affect any downstream processes with glTF loading and the like. I'm not sure off the top of my head if there are special cases where we tweak the contents of the typed array based on certain conditions. |
||
vertexBuffer = Buffer.createVertexBuffer({ | ||
context: context, | ||
typedArray: attribute.typedArray, | ||
usage: bufferUsage, | ||
}); | ||
|
||
attrProps = { | ||
index: attributeLocations[name], | ||
vertexBuffer: vertexBuffer, | ||
value: undefined, | ||
componentDatatype: componentDatatype, | ||
componentsPerAttribute: AttributeType.getNumberOfComponents( | ||
attribute.type, | ||
), | ||
normalize: attribute.normalized, | ||
instanceDivisor: attribute.instanceDivisor, | ||
}; | ||
} | ||
|
||
vaAttributes.push({ | ||
index: attributeLocations[name], | ||
vertexBuffer: vertexBuffer, | ||
value: attribute.value, | ||
componentDatatype: componentDatatype, | ||
componentsPerAttribute: attribute.componentsPerAttribute, | ||
normalize: attribute.normalize, | ||
}); | ||
vaAttributes.push(attrProps); | ||
|
||
// vaAttributes.push({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this if it's no longer needed. |
||
// index: attributeLocations[name], | ||
// vertexBuffer: vertexBuffer, | ||
// value: attribute.value, | ||
// componentDatatype: componentDatatype, | ||
// componentsPerAttribute: attribute.componentsPerAttribute, | ||
// normalize: attribute.normalize, | ||
// }); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description should be updated to a summary of the example. Any key words here will also be helpful, as they will help this example show up when a user searches.
Something along the lines of "Load a gaussian splat dataset of a cell tower as a 3D tileset." would be great.