Skip to content

Commit 110e57f

Browse files
committed
feat: moved environmentMapOptions to Entity
1 parent 3e617cd commit 110e57f

File tree

10 files changed

+12
-39
lines changed

10 files changed

+12
-39
lines changed

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"unregisters",
9696
"unrenderable",
9797
"voxel",
98+
"VVLH",
9899
"WEBG",
99100
"xdescribe"
100101
]

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
##### Fixes :wrench:
88

9-
- Added `enableEnvironmentMap` to `ModelGraphics` constructor options to allow long distance `Entity` movements without performance drop. [#12358](https://github.com/CesiumGS/cesium/pull/12358)
9+
- Added `environmentMapOptions` to `Entity`'s constructor options with EnvironmentMap disabled by default to allow long distance `Entity` jumps without performance drop. If EnvironmentMap needs to be enabled, ensure to provide a `maximumPositionEpsilon` threshold value large enough with your entity movements use case. [#12358](https://github.com/CesiumGS/cesium/pull/12358)
1010

1111
### 1.124 - 2024-12-02
1212

packages/engine/Source/DataSources/Cesium3DTilesetVisualizer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ async function createTileset(resource, tilesetHash, entity, primitives) {
243243
};
244244

245245
try {
246-
const tileset = await Cesium3DTileset.fromUrl(resource);
246+
const tileset = await Cesium3DTileset.fromUrl(resource, {
247+
environmentMapOptions: entity._environmentMapOptions,
248+
});
247249
tileset.id = entity;
248250
primitives.add(tileset);
249251

packages/engine/Source/DataSources/Entity.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function createPropertyTypeDescriptor(name, Type) {
9898
* @property {PolylineVolumeGraphics | PolylineVolumeGraphics.ConstructorOptions} [polylineVolume] A polylineVolume to associate with this entity.
9999
* @property {RectangleGraphics | RectangleGraphics.ConstructorOptions} [rectangle] A rectangle to associate with this entity.
100100
* @property {WallGraphics | WallGraphics.ConstructorOptions} [wall] A wall to associate with this entity.
101+
* @property {DynamicEnvironmentMapManager.ConstructorOptions} [environmentMapOptions={enabled: false}] The properties for managing dynamic environment maps on this entity.
101102
*/
102103

103104
/**
@@ -122,6 +123,9 @@ function Entity(options) {
122123
this._availability = undefined;
123124
this._id = id;
124125
this._definitionChanged = new Event();
126+
this._environmentMapOptions = defaultValue(options.environmentMapOptions, {
127+
enabled: false,
128+
});
125129
this._name = options.name;
126130
this._show = defaultValue(options.show, true);
127131
this._trackingReferenceFrame = defaultValue(

packages/engine/Source/DataSources/ModelGraphics.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function createArticulationStagePropertyBag(value) {
4646
* @property {PropertyBag | Object<string, number>} [articulations] An object, where keys are composed of an articulation name, a single space, and a stage name, and the values are numeric properties.
4747
* @property {Property | ClippingPlaneCollection} [clippingPlanes] A property specifying the {@link ClippingPlaneCollection} used to selectively disable rendering the model.
4848
* @property {Property | CustomShader} [customShader] A property specifying the {@link CustomShader} to apply to this model.
49-
* @property {Property | boolean} [enableEnvironmentMap=true] A boolean Property specifying if the model has {@link DynamicEnvironmentMapManager} enabled.
5049
*/
5150

5251
/**
@@ -114,8 +113,6 @@ function ModelGraphics(options) {
114113
this._clippingPlanesSubscription = undefined;
115114
this._customShader = undefined;
116115
this._customShaderSubscription = undefined;
117-
this._enableEnvironmentMap = undefined;
118-
this._enableEnvironmentMapSubscription = undefined;
119116

120117
this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
121118
}
@@ -336,14 +333,6 @@ Object.defineProperties(ModelGraphics.prototype, {
336333
* @type {Property|undefined}
337334
*/
338335
customShader: createPropertyDescriptor("customShader"),
339-
340-
/**
341-
* Gets or sets the boolean Property specifying if the model has {@link DynamicEnvironmentMapManager} enabled.
342-
* @memberof ModelGraphics.prototype
343-
* @type {Property|undefined}
344-
* @default true
345-
*/
346-
enableEnvironmentMap: createPropertyDescriptor("enableEnvironmentMap"),
347336
});
348337

349338
/**
@@ -378,7 +367,6 @@ ModelGraphics.prototype.clone = function (result) {
378367
result.articulations = this.articulations;
379368
result.clippingPlanes = this.clippingPlanes;
380369
result.customShader = this.customShader;
381-
result.enableEnvironmentMap = this.enableEnvironmentMap;
382370
return result;
383371
};
384372

@@ -453,10 +441,6 @@ ModelGraphics.prototype.merge = function (source) {
453441
source.clippingPlanes,
454442
);
455443
this.customShader = defaultValue(this.customShader, source.customShader);
456-
this.enableEnvironmentMap = defaultValue(
457-
this.enableEnvironmentMap,
458-
source.enableEnvironmentMap,
459-
);
460444

461445
const sourceNodeTransformations = source.nodeTransformations;
462446
if (defined(sourceNodeTransformations)) {

packages/engine/Source/DataSources/ModelVisualizer.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const defaultColor = Color.WHITE;
3535
const defaultColorBlendMode = ColorBlendMode.HIGHLIGHT;
3636
const defaultColorBlendAmount = 0.5;
3737
const defaultImageBasedLightingFactor = new Cartesian2(1.0, 1.0);
38-
const defaultEnableEnvironmentMap = true;
3938

4039
const modelMatrixScratch = new Matrix4();
4140
const nodeMatrixScratch = new Matrix4();
@@ -86,6 +85,7 @@ async function createModelPrimitive(
8685
url: resource,
8786
incrementallyLoadTextures: incrementallyLoadTextures,
8887
scene: visualizer._scene,
88+
environmentMapOptions: entity._environmentMapOptions,
8989
});
9090

9191
if (visualizer.isDestroyed() || !defined(modelHash[entity.id])) {
@@ -290,12 +290,6 @@ ModelVisualizer.prototype.update = function (time) {
290290
time,
291291
);
292292

293-
model.environmentMapManager.enabled = Property.getValueOrDefault(
294-
modelGraphics._enableEnvironmentMap,
295-
time,
296-
defaultEnableEnvironmentMap,
297-
);
298-
299293
// It's possible for getBoundingSphere to run before
300294
// model becomes ready and these properties are updated
301295
modelHash[entity.id].modelUpdated = true;

packages/engine/Source/Scene/Cesium3DTileset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ import DynamicEnvironmentMapManager from "./DynamicEnvironmentMapManager.js";
105105
* @property {object} [pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
106106
* @property {Cartesian3} [lightColor] The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
107107
* @property {ImageBasedLighting} [imageBasedLighting] The properties for managing image-based lighting for this tileset.
108-
* @param {DynamicEnvironmentMapManager.ConstructorOptions} [options.environmentMapOptions] The properties for managing dynamic environment maps on this model.
108+
* @property {DynamicEnvironmentMapManager.ConstructorOptions} [environmentMapOptions] The properties for managing dynamic environment maps on this tileset.
109109
* @property {boolean} [backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
110110
* @property {boolean} [enableShowOutline=true] Whether to enable outlines for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set to false to avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor options are ignored.
111111
* @property {boolean} [showOutline=true] Whether to display the outline for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. When true, outlines are displayed. When false, outlines are not displayed.

packages/engine/Specs/DataSources/Cesium3DTilesetVisualizerSpec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ describe(
133133
visualizer.update(time);
134134
expect(primitive.show).toEqual(true);
135135
expect(primitive.maximumScreenSpaceError).toEqual(24.0);
136+
expect(primitive.environmentMapManager.enabled).toEqual(false);
136137
});
137138

138139
it("A Cesium3DTilesetGraphics with a Resource causes a primitive to be created.", async function () {

packages/engine/Specs/DataSources/ModelGraphicsSpec.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe("DataSources/ModelGraphics", function () {
4949
articulations: {
5050
"articulation1 stage1": 45,
5151
},
52-
enableEnvironmentMap: false,
5352
};
5453

5554
const model = new ModelGraphics(options);
@@ -105,9 +104,6 @@ describe("DataSources/ModelGraphics", function () {
105104
expect(model.lightColor.getValue()).toEqual(options.lightColor);
106105
expect(model.runAnimations.getValue()).toEqual(options.runAnimations);
107106
expect(model.clampAnimations.getValue()).toEqual(options.clampAnimations);
108-
expect(model.enableEnvironmentMap.getValue()).toEqual(
109-
options.enableEnvironmentMap,
110-
);
111107

112108
let actualNodeTransformations = model.nodeTransformations.getValue(
113109
new JulianDate(),
@@ -176,7 +172,6 @@ describe("DataSources/ModelGraphics", function () {
176172
"a1 s1": 10,
177173
"a2 s2": 20,
178174
};
179-
source.enableEnvironmentMap = new ConstantProperty(true);
180175

181176
const target = new ModelGraphics();
182177
target.merge(source);
@@ -209,7 +204,6 @@ describe("DataSources/ModelGraphics", function () {
209204
expect(target.clampAnimations).toBe(source.clampAnimations);
210205
expect(target.nodeTransformations).toEqual(source.nodeTransformations);
211206
expect(target.articulations).toEqual(source.articulations);
212-
expect(target.enableEnvironmentMap).toBe(source.enableEnvironmentMap);
213207
});
214208

215209
it("merge does not assign assigned properties", function () {
@@ -247,7 +241,6 @@ describe("DataSources/ModelGraphics", function () {
247241
"a1 s1": 10,
248242
"a2 s2": 20,
249243
};
250-
source.enableEnvironmentMap = new ConstantProperty(true);
251244

252245
const uri = new ConstantProperty("");
253246
const show = new ConstantProperty(true);
@@ -282,7 +275,6 @@ describe("DataSources/ModelGraphics", function () {
282275
"a1 s1": 10,
283276
"a2 s2": 20,
284277
});
285-
const enableEnvironmentMap = new ConstantProperty(true);
286278

287279
const target = new ModelGraphics();
288280
target.uri = uri;
@@ -307,7 +299,6 @@ describe("DataSources/ModelGraphics", function () {
307299
target.clampAnimations = clampAnimations;
308300
target.nodeTransformations = nodeTransformations;
309301
target.articulations = articulations;
310-
target.enableEnvironmentMap = enableEnvironmentMap;
311302

312303
target.merge(source);
313304

@@ -333,7 +324,6 @@ describe("DataSources/ModelGraphics", function () {
333324
expect(target.clampAnimations).toBe(clampAnimations);
334325
expect(target.nodeTransformations).toBe(nodeTransformations);
335326
expect(target.articulations).toBe(articulations);
336-
expect(target.enableEnvironmentMap).toBe(enableEnvironmentMap);
337327
});
338328

339329
it("clone works", function () {
@@ -372,7 +362,6 @@ describe("DataSources/ModelGraphics", function () {
372362
"a1 s1": 10,
373363
"a2 s2": 20,
374364
};
375-
source.enableEnvironmentMap = new ConstantProperty(true);
376365

377366
const result = source.clone();
378367
expect(result.uri).toBe(source.uri);
@@ -403,7 +392,6 @@ describe("DataSources/ModelGraphics", function () {
403392
expect(result.clampAnimations).toBe(source.clampAnimations);
404393
expect(result.nodeTransformations).toEqual(source.nodeTransformations);
405394
expect(result.articulations).toEqual(source.articulations);
406-
expect(result.enableEnvironmentMap).toEqual(source.enableEnvironmentMap);
407395
});
408396

409397
it("merge throws if source undefined", function () {

packages/engine/Specs/DataSources/ModelVisualizerSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ describe(
146146
new Cartesian2(0.5, 0.5),
147147
);
148148
model.lightColor = new ConstantProperty(new Color(1.0, 1.0, 0.0, 1.0));
149-
model.enableEnvironmentMap = new ConstantProperty(false);
150149

151150
const testObject = entityCollection.getOrCreateEntity("test");
152151
testObject.position = new ConstantPositionProperty(

0 commit comments

Comments
 (0)