Skip to content

Commit f69cee3

Browse files
author
Janine Liu
committed
Fix CHANGES.md merge conflict
2 parents 678ec80 + ef4293b commit f69cee3

40 files changed

+1604
-328
lines changed

Apps/Sandcastle/gallery/MSAA.html

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
9+
/>
10+
<meta name="description" content="Add MSAA to the scene." />
11+
<meta name="cesium-sandcastle-labels" content="Showcases" />
12+
<title>Cesium Demo</title>
13+
<script type="text/javascript" src="../Sandcastle-header.js"></script>
14+
<script
15+
type="text/javascript"
16+
src="../../../Build/CesiumUnminified/Cesium.js"
17+
nomodule
18+
></script>
19+
<script type="module" src="../load-cesium-es6.js"></script>
20+
</head>
21+
<body
22+
class="sandcastle-loading"
23+
data-sandcastle-bucket="bucket-requirejs.html"
24+
>
25+
<style>
26+
@import url(../templates/bucket.css);
27+
</style>
28+
<div id="cesiumContainer" class="fullSize"></div>
29+
<div id="loadingOverlay"><h1>Loading...</h1></div>
30+
<div id="toolbar"></div>
31+
<script id="cesium_sandcastle_script">
32+
function startup(Cesium) {
33+
"use strict";
34+
//Sandcastle_Begin
35+
const viewer = new Cesium.Viewer("cesiumContainer", {
36+
terrainProvider: Cesium.createWorldTerrain(),
37+
contextOptions: {
38+
requestWebgl2: true,
39+
},
40+
});
41+
42+
const scene = viewer.scene;
43+
if (!scene.msaaSupported) {
44+
window.alert("This browser does not support MSAA.");
45+
}
46+
47+
function createModel(url, height) {
48+
const position = Cesium.Cartesian3.fromDegrees(
49+
-123.0744619,
50+
44.0503706,
51+
height
52+
);
53+
const heading = Cesium.Math.toRadians(135);
54+
const pitch = 0;
55+
const roll = 0;
56+
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
57+
const orientation = Cesium.Transforms.headingPitchRollQuaternion(
58+
position,
59+
hpr
60+
);
61+
62+
const entity = viewer.entities.add({
63+
name: url,
64+
position: position,
65+
orientation: orientation,
66+
model: {
67+
uri: url,
68+
minimumPixelSize: 128,
69+
maximumScale: 20000,
70+
},
71+
});
72+
const target = Cesium.Cartesian3.fromDegrees(
73+
-123.0744619,
74+
44.0503706,
75+
height + 7.5
76+
);
77+
const offset = new Cesium.Cartesian3(50.0, -15.0, 0.0);
78+
viewer.scene.camera.lookAt(target, offset);
79+
}
80+
81+
const options = [
82+
{
83+
text: "Statue of Liberty",
84+
onselect: function () {
85+
viewer.entities.removeAll();
86+
scene.primitives.removeAll();
87+
scene.camera.setView({
88+
destination: new Cesium.Cartesian3(
89+
1331419.302230775,
90+
-4656681.5022043325,
91+
4136232.6465900405
92+
),
93+
orientation: new Cesium.HeadingPitchRoll(
94+
6.032455545102689,
95+
-0.056832496140112765,
96+
6.282360923090216
97+
),
98+
endTransform: Cesium.Matrix4.IDENTITY,
99+
});
100+
101+
scene.primitives.add(
102+
new Cesium.Cesium3DTileset({
103+
url: Cesium.IonResource.fromAssetId(75343),
104+
})
105+
);
106+
},
107+
},
108+
{
109+
text: "3D Tiles BIM",
110+
onselect: function () {
111+
viewer.entities.removeAll();
112+
scene.primitives.removeAll();
113+
const tileset = scene.primitives.add(
114+
new Cesium.Cesium3DTileset({
115+
url: Cesium.IonResource.fromAssetId(8564),
116+
})
117+
);
118+
viewer.camera.setView({
119+
destination: new Cesium.Cartesian3(
120+
1234138.7804841248,
121+
-5086063.633843134,
122+
3633284.606361642
123+
),
124+
orientation: {
125+
heading: 0.4304630387656614,
126+
pitch: -0.16969316864215878,
127+
roll: 6.283184816241989,
128+
},
129+
});
130+
},
131+
},
132+
{
133+
text: "Hot Air Balloon",
134+
onselect: function () {
135+
viewer.entities.removeAll();
136+
scene.primitives.removeAll();
137+
createModel(
138+
"../../SampleData/models/CesiumBalloon/CesiumBalloon.glb",
139+
1000.0
140+
);
141+
},
142+
},
143+
];
144+
145+
const samplingOptions = [
146+
{
147+
text: "MSAA off",
148+
onselect: function () {
149+
scene.msaaSamples = 1;
150+
},
151+
},
152+
{
153+
text: "MSAA 2x",
154+
onselect: function () {
155+
scene.msaaSamples = 2;
156+
},
157+
},
158+
{
159+
text: "MSAA 4x",
160+
onselect: function () {
161+
scene.msaaSamples = 4;
162+
},
163+
},
164+
{
165+
text: "MSAA 8x",
166+
onselect: function () {
167+
scene.msaaSamples = 8;
168+
},
169+
},
170+
];
171+
172+
Sandcastle.addToolbarMenu(options);
173+
Sandcastle.addToolbarMenu(samplingOptions);
174+
//Sandcastle_End
175+
Sandcastle.finishedLoading();
176+
}
177+
if (typeof Cesium !== "undefined") {
178+
window.startupCalled = true;
179+
startup(Cesium);
180+
}
181+
</script>
182+
</body>
183+
</html>

Apps/Sandcastle/gallery/MSAA.jpg

33.7 KB
Loading

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44

55
##### Additions :tada:
66

7+
- Added MSAA support for WebGL2. Enabled on viewer creation with the multisampling rate as the `msaaSamples` option and can be controlled through `Scene.msaaSamples`.
78
- glTF contents now use `ModelExperimental` by default. [#10055](https://github.com/CesiumGS/cesium/pull/10055)
89
- Added the ability to toggle back-face culling in `ModelExperimental`. [#10070](https://github.com/CesiumGS/cesium/pull/10070)
910
- Added `depthPlaneEllipsoidOffset` to Viewer and Scene constructors to address rendering artefacts below ellipsoid zero elevation. [#9200](https://github.com/CesiumGS/cesium/pull/9200)
1011
- Added support for `debugColorTiles` in `ModelExperimental`. [#10071](https://github.com/CesiumGS/cesium/pull/10071)
1112
- Added support for shadows in `ModelExperimental`. [#10077](https://github.com/CesiumGS/cesium/pull/10077)
13+
- Added `packArray` and `unpackArray` for matrix types. [#10118](https://github.com/CesiumGS/cesium/pull/10118)
1214

1315
##### Fixes :wrench:
1416

1517
- Fixed a bug where updating `ModelExperimental`'s model matrix would not update its bounding sphere. [#10078](https://github.com/CesiumGS/cesium/pull/10078)
1618
- Fixed feature ID texture artifacts on Safari. [#10111](https://github.com/CesiumGS/cesium/pull/10111)
19+
- Fixed a bug where a translucent shader applied to a `ModelExperimental` with opaque features was not being rendered. [#10110](https://github.com/CesiumGS/cesium/pull/10110)
1720

1821
### 1.90 - 2022-02-01
1922

Source/Core/Cartesian2.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,12 @@ Cartesian2.unpack = function (array, startingIndex, result) {
145145
};
146146

147147
/**
148-
* Flattens an array of Cartesian2s into and array of components.
149-
*
150-
* @param {Cartesian2[]} array The array of cartesians to pack.
151-
* @param {Number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 2 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.
152-
153-
* @returns {Number[]} The packed array.
154-
*/
148+
* Flattens an array of Cartesian2s into an array of components.
149+
*
150+
* @param {Cartesian2[]} array The array of cartesians to pack.
151+
* @param {Number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 2 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.
152+
* @returns {Number[]} The packed array.
153+
*/
155154
Cartesian2.packArray = function (array, result) {
156155
//>>includeStart('debug', pragmas.debug);
157156
Check.defined("array", array);
@@ -162,9 +161,11 @@ Cartesian2.packArray = function (array, result) {
162161
if (!defined(result)) {
163162
result = new Array(resultLength);
164163
} else if (!Array.isArray(result) && result.length !== resultLength) {
164+
//>>includeStart('debug', pragmas.debug);
165165
throw new DeveloperError(
166166
"If result is a typed array, it must have exactly array.length * 2 elements"
167167
);
168+
//>>includeEnd('debug');
168169
} else if (result.length !== resultLength) {
169170
result.length = resultLength;
170171
}
@@ -176,7 +177,7 @@ Cartesian2.packArray = function (array, result) {
176177
};
177178

178179
/**
179-
* Unpacks an array of cartesian components into and array of Cartesian2s.
180+
* Unpacks an array of cartesian components into an array of Cartesian2s.
180181
*
181182
* @param {Number[]} array The array of components to unpack.
182183
* @param {Cartesian2[]} [result] The array onto which to store the result.

Source/Core/Cartesian3.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ Cartesian3.packArray = function (array, result) {
189189
if (!defined(result)) {
190190
result = new Array(resultLength);
191191
} else if (!Array.isArray(result) && result.length !== resultLength) {
192+
//>>includeStart('debug', pragmas.debug);
192193
throw new DeveloperError(
193194
"If result is a typed array, it must have exactly array.length * 3 elements"
194195
);
196+
//>>includeEnd('debug');
195197
} else if (result.length !== resultLength) {
196198
result.length = resultLength;
197199
}

Source/Core/Cartesian4.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,12 @@ Cartesian4.unpack = function (array, startingIndex, result) {
173173
};
174174

175175
/**
176-
* Flattens an array of Cartesian4s into and array of components.
177-
*
178-
* @param {Cartesian4[]} array The array of cartesians to pack.
179-
* @param {Number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
180-
181-
* @returns {Number[]} The packed array.
182-
*/
176+
* Flattens an array of Cartesian4s into an array of components.
177+
*
178+
* @param {Cartesian4[]} array The array of cartesians to pack.
179+
* @param {Number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
180+
* @returns {Number[]} The packed array.
181+
*/
183182
Cartesian4.packArray = function (array, result) {
184183
//>>includeStart('debug', pragmas.debug);
185184
Check.defined("array", array);
@@ -190,9 +189,11 @@ Cartesian4.packArray = function (array, result) {
190189
if (!defined(result)) {
191190
result = new Array(resultLength);
192191
} else if (!Array.isArray(result) && result.length !== resultLength) {
192+
//>>includeStart('debug', pragmas.debug);
193193
throw new DeveloperError(
194194
"If result is a typed array, it must have exactly array.length * 4 elements"
195195
);
196+
//>>includeEnd('debug');
196197
} else if (result.length !== resultLength) {
197198
result.length = resultLength;
198199
}
@@ -204,7 +205,7 @@ Cartesian4.packArray = function (array, result) {
204205
};
205206

206207
/**
207-
* Unpacks an array of cartesian components into and array of Cartesian4s.
208+
* Unpacks an array of cartesian components into an array of Cartesian4s.
208209
*
209210
* @param {Number[]} array The array of components to unpack.
210211
* @param {Cartesian4[]} [result] The array onto which to store the result.

Source/Core/Matrix2.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Cartesian2 from "./Cartesian2.js";
22
import Check from "./Check.js";
33
import defaultValue from "./defaultValue.js";
44
import defined from "./defined.js";
5+
import DeveloperError from "./DeveloperError.js";
56

67
/**
78
* A 2x2 matrix, indexable as a column-major order array.
@@ -86,6 +87,69 @@ Matrix2.unpack = function (array, startingIndex, result) {
8687
return result;
8788
};
8889

90+
/**
91+
* Flattens an array of Matrix2s into an array of components. The components
92+
* are stored in column-major order.
93+
*
94+
* @param {Matrix2[]} array The array of matrices to pack.
95+
* @param {Number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
96+
* @returns {Number[]} The packed array.
97+
*/
98+
Matrix2.packArray = function (array, result) {
99+
//>>includeStart('debug', pragmas.debug);
100+
Check.defined("array", array);
101+
//>>includeEnd('debug');
102+
103+
const length = array.length;
104+
const resultLength = length * 4;
105+
if (!defined(result)) {
106+
result = new Array(resultLength);
107+
} else if (!Array.isArray(result) && result.length !== resultLength) {
108+
//>>includeStart('debug', pragmas.debug);
109+
throw new DeveloperError(
110+
"If result is a typed array, it must have exactly array.length * 4 elements"
111+
);
112+
//>>includeEnd('debug');
113+
} else if (result.length !== resultLength) {
114+
result.length = resultLength;
115+
}
116+
117+
for (let i = 0; i < length; ++i) {
118+
Matrix2.pack(array[i], result, i * 4);
119+
}
120+
return result;
121+
};
122+
123+
/**
124+
* Unpacks an array of column-major matrix components into an array of Matrix2s.
125+
*
126+
* @param {Number[]} array The array of components to unpack.
127+
* @param {Matrix2[]} [result] The array onto which to store the result.
128+
* @returns {Matrix2[]} The unpacked array.
129+
*/
130+
Matrix2.unpackArray = function (array, result) {
131+
//>>includeStart('debug', pragmas.debug);
132+
Check.defined("array", array);
133+
Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
134+
if (array.length % 4 !== 0) {
135+
throw new DeveloperError("array length must be a multiple of 4.");
136+
}
137+
//>>includeEnd('debug');
138+
139+
const length = array.length;
140+
if (!defined(result)) {
141+
result = new Array(length / 4);
142+
} else {
143+
result.length = length / 4;
144+
}
145+
146+
for (let i = 0; i < length; i += 4) {
147+
const index = i / 4;
148+
result[index] = Matrix2.unpack(array, i, result[index]);
149+
}
150+
return result;
151+
};
152+
89153
/**
90154
* Duplicates a Matrix2 instance.
91155
*

0 commit comments

Comments
 (0)