Skip to content

Commit e02c825

Browse files
author
hpinkos
committed
remove ClippingPlaneCollection.clone
1 parent a4775a0 commit e02c825

File tree

4 files changed

+23
-111
lines changed

4 files changed

+23
-111
lines changed

Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html

+14-19
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE -->
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
77
<meta name="description" content="User-defined clipping planes applied to a batched 3D Tileset, point cloud, and model.">
88
<meta name="cesium-sandcastle-labels" content="Showcases, 3D Tiles">
99
<title>Cesium Demo</title>
1010
<script type="text/javascript" src="../Sandcastle-header.js"></script>
1111
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
1212
<script type="text/javascript">
13-
require.config({
14-
baseUrl : '../../../Source',
15-
waitSeconds : 60
16-
});
13+
if(typeof require === 'function') {
14+
require.config({
15+
baseUrl : '../../../Source',
16+
waitSeconds : 120
17+
});
18+
}
1719
</script>
1820
</head>
1921
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
@@ -45,7 +47,6 @@
4547
function startup(Cesium) {
4648
'use strict';
4749
//Sandcastle_Begin
48-
4950
// Add a clipping plane, a plane geometry to show the representation of the
5051
// plane, and control the magnitude of the plane distance with the mouse.
5152

@@ -154,19 +155,13 @@
154155

155156
var modelEntityClippingPlanes;
156157
function loadModel(url) {
157-
var clippingPlanes = [
158-
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 0.0, -1.0), -100.0)
159-
];
160-
161-
modelEntityClippingPlanes = new Cesium.ClippingPlaneCollection({
162-
planes : clippingPlanes,
158+
var clippingPlanes = new Cesium.ClippingPlaneCollection({
159+
planes : [
160+
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 0.0, -1.0), -100.0)
161+
],
163162
edgeWidth : viewModel.edgeStylingEnabled ? 1.0 : 0.0
164163
});
165164

166-
function updateClippingPlanes() {
167-
return modelEntityClippingPlanes;
168-
}
169-
170165
var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 100.0);
171166
var heading = Cesium.Math.toRadians(135.0);
172167
var pitch = 0.0;
@@ -181,14 +176,14 @@
181176
uri : url,
182177
scale : 8,
183178
minimumPixelSize : 100.0,
184-
clippingPlanes : new Cesium.CallbackProperty(updateClippingPlanes, false)
179+
clippingPlanes : clippingPlanes
185180
}
186181
});
187182

188183
viewer.trackedEntity = entity;
189184

190185
for (var i = 0; i < clippingPlanes.length; ++i) {
191-
var plane = clippingPlanes[i];
186+
var plane = clippingPlanes.get(i);
192187
var planeEntity = viewer.entities.add({
193188
position : position,
194189
plane : {
@@ -262,7 +257,7 @@
262257
}
263258

264259
//Sandcastle_End
265-
Sandcastle.finishedLoading();
260+
Sandcastle.finishedLoading();
266261
}
267262
if (typeof Cesium !== 'undefined') {
268263
startup(Cesium);

CHANGES.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Change Log
22
==========
33

4+
### 1.49 - 2018-09-03
5+
6+
##### Breaking Changes :mega:
7+
* Removed `ClippingPlaneCollection.clone`
8+
9+
##### Fixes :wrench:
10+
* Fixed bug that caused a new `ClippingPlaneCollection` to be created every frame when used with a model entity [#6872](https://github.com/AnalyticalGraphicsInc/cesium/pull/6872)
11+
412
### 1.48 - 2018-08-01
513

614
##### Additions :tada:
@@ -16,7 +24,7 @@ Change Log
1624
* Support for the 3D Tiles pre-version 1.0 Batch Table Hierarchy is deprecated to reflect updates to the [3D Tiles spec](https://github.com/AnalyticalGraphicsInc/3d-tiles/pull/301). Use the [`3DTILES_batch_table_hierarchy`](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/1.0/extensions/3DTILES_batch_table_hierarchy) extension instead. Support for the deprecated batch table hierarchy will remain for backwards compatibility. [#6780](https://github.com/AnalyticalGraphicsInc/cesium/pull/6780)
1725
* `PostProcessStageLibrary.createLensFlarStage` is deprecated due to misspelling and will be removed in Cesium 1.49. Use `PostProcessStageLibrary.createLensFlareStage` instead.
1826

19-
#### Fixes :wrench:
27+
##### Fixes :wrench:
2028
* Fixed a bug where 3D Tilesets using the `region` bounding volume don't get transformed when the tileset's `modelMatrix` changes. [#6755](https://github.com/AnalyticalGraphicsInc/cesium/pull/6755)
2129
* Fixed a bug that caused eye dome lighting for point clouds to fail in Safari on macOS and Edge on Windows by removing the dependency on floating point color textures. [#6792](https://github.com/AnalyticalGraphicsInc/cesium/issues/6792)
2230
* Fixed a bug that caused polylines on terrain to render incorrectly in 2D and Columbus View with a `WebMercatorProjection`. [#6809](https://github.com/AnalyticalGraphicsInc/cesium/issues/6809)

Source/Scene/ClippingPlaneCollection.js

-41
Original file line numberDiff line numberDiff line change
@@ -546,47 +546,6 @@ define([
546546
this._dirtyIndex = -1;
547547
};
548548

549-
/**
550-
* Duplicates this ClippingPlaneCollection instance.
551-
*
552-
* @param {ClippingPlaneCollection} [result] The object onto which to store the result.
553-
* @returns {ClippingPlaneCollection} The modified result parameter or a new ClippingPlaneCollection instance if one was not provided.
554-
*/
555-
ClippingPlaneCollection.prototype.clone = function(result) {
556-
if (!defined(result)) {
557-
result = new ClippingPlaneCollection();
558-
}
559-
560-
var length = this.length;
561-
var i;
562-
if (result.length !== length) {
563-
var planes = result._planes;
564-
var index = planes.length;
565-
566-
planes.length = length;
567-
for (i = index; i < length; ++i) {
568-
result._planes[i] = new ClippingPlane(Cartesian3.UNIT_X, 0.0);
569-
}
570-
}
571-
572-
for (i = 0; i < length; ++i) {
573-
var resultPlane = result._planes[i];
574-
resultPlane.index = i;
575-
resultPlane.onChangeCallback = function(index) {
576-
setIndexDirty(result, index);
577-
};
578-
ClippingPlane.clone(this._planes[i], resultPlane);
579-
}
580-
581-
result.enabled = this.enabled;
582-
Matrix4.clone(this.modelMatrix, result.modelMatrix);
583-
result.unionClippingRegions = this.unionClippingRegions;
584-
Color.clone(this.edgeColor, result.edgeColor);
585-
result.edgeWidth = this.edgeWidth;
586-
587-
return result;
588-
};
589-
590549
var scratchMatrix = new Matrix4();
591550
var scratchPlane = new Plane(Cartesian3.UNIT_X, 0.0);
592551
/**

Specs/Scene/ClippingPlaneCollectionSpec.js

-50
Original file line numberDiff line numberDiff line change
@@ -576,56 +576,6 @@ defineSuite([
576576
}).toThrowDeveloperError();
577577
});
578578

579-
it('clone without a result parameter returns new copy', function() {
580-
clippingPlanes = new ClippingPlaneCollection({
581-
planes : planes,
582-
enabled : false,
583-
edgeColor : Color.RED,
584-
modelMatrix : transform
585-
});
586-
587-
var result = clippingPlanes.clone();
588-
expect(result).not.toBe(clippingPlanes);
589-
expect(Cartesian3.equals(result._planes[0].normal, planes[0].normal)).toBe(true);
590-
expect(result._planes[0].distance).toEqual(planes[0].distance);
591-
expect(Cartesian3.equals(result._planes[1].normal, planes[1].normal)).toBe(true);
592-
expect(result._planes[1].distance).toEqual(planes[1].distance);
593-
expect(result.enabled).toEqual(false);
594-
expect(result.modelMatrix).toEqual(transform);
595-
expect(result.edgeColor).toEqual(Color.RED);
596-
expect(result.edgeWidth).toEqual(0.0);
597-
expect(result.unionClippingRegions).toEqual(false);
598-
expect(result._testIntersection).not.toBeUndefined();
599-
});
600-
601-
it('clone stores copy in result parameter', function() {
602-
clippingPlanes = new ClippingPlaneCollection({
603-
planes : planes,
604-
enabled : false,
605-
edgeColor : Color.RED,
606-
modelMatrix : transform
607-
});
608-
var result = new ClippingPlaneCollection();
609-
var copy = clippingPlanes.clone(result);
610-
expect(copy).toBe(result);
611-
expect(result._planes).not.toBe(planes);
612-
expect(Cartesian3.equals(result._planes[0].normal, planes[0].normal)).toBe(true);
613-
expect(result._planes[0].distance).toEqual(planes[0].distance);
614-
expect(Cartesian3.equals(result._planes[1].normal, planes[1].normal)).toBe(true);
615-
expect(result._planes[1].distance).toEqual(planes[1].distance);
616-
expect(result.enabled).toEqual(false);
617-
expect(result.modelMatrix).toEqual(transform);
618-
expect(result.edgeColor).toEqual(Color.RED);
619-
expect(result.edgeWidth).toEqual(0.0);
620-
expect(result.unionClippingRegions).toEqual(false);
621-
expect(result._testIntersection).not.toBeUndefined();
622-
623-
// Only allocate a new array if needed
624-
var previousPlanes = result._planes;
625-
clippingPlanes.clone(result);
626-
expect(result._planes).toBe(previousPlanes);
627-
});
628-
629579
it('setting unionClippingRegions updates testIntersection function', function() {
630580
clippingPlanes = new ClippingPlaneCollection();
631581
var originalIntersectFunction = clippingPlanes._testIntersection;

0 commit comments

Comments
 (0)