@cesium/engine 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +95 -76
- package/README.md +9 -9
- package/Source/Core/Ion.js +1 -1
- package/Source/Renderer/Context.js +213 -178
- package/Source/Scene/I3SDataProvider.js +2 -1
- package/Source/Scene/I3SFeature.js +1 -1
- package/Source/Scene/I3SLayer.js +64 -2
- package/Source/Scene/I3SNode.js +50 -6
- package/Source/Scene/Model/Model.js +36 -3
- package/Source/Scene/Scene.js +3 -50
- package/Source/Shaders/Builtin/CzmBuiltins.js +15 -15
- package/Source/ThirdParty/Workers/draco_decoder_nodejs.js +100 -101
- package/Source/ThirdParty/Workers/pako_deflate.min.js +2 -2
- package/Source/ThirdParty/Workers/pako_inflate.min.js +2 -2
- package/Source/ThirdParty/Workers/z-worker-pako.js +0 -0
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/Source/Widget/CesiumWidget.js +1 -1
- package/index.d.ts +2402 -2334
- package/index.js +1085 -1085
- package/package.json +4 -1
- package/Build/ThirdParty/Workers/basis_transcoder.js +0 -2233
- package/Build/ThirdParty/Workers/draco_decoder_nodejs.js +0 -1872
- package/Build/ThirdParty/Workers/package.json +0 -1
- package/Build/ThirdParty/Workers/pako_deflate.min.js +0 -589
- package/Build/ThirdParty/Workers/pako_inflate.min.js +0 -798
- package/Build/ThirdParty/Workers/z-worker-pako.js +0 -503
- package/Build/ThirdParty/basis_transcoder.wasm +0 -0
- package/Build/ThirdParty/draco_decoder.wasm +0 -0
- package/Build/ThirdParty/google-earth-dbroot-parser.js +0 -8019
- package/Build/Widget/CesiumWidget.css +0 -120
- package/Build/Widget/lighter.css +0 -13
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Check from "../Core/Check.js";
|
|
2
|
-
import clone from "../Core/clone.js";
|
|
3
2
|
import Color from "../Core/Color.js";
|
|
4
3
|
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
5
4
|
import createGuid from "../Core/createGuid.js";
|
|
@@ -31,183 +30,43 @@ import TextureCache from "./TextureCache.js";
|
|
|
31
30
|
import UniformState from "./UniformState.js";
|
|
32
31
|
import VertexArray from "./VertexArray.js";
|
|
33
32
|
|
|
34
|
-
function errorToString(gl, error) {
|
|
35
|
-
let message = "WebGL Error: ";
|
|
36
|
-
switch (error) {
|
|
37
|
-
case gl.INVALID_ENUM:
|
|
38
|
-
message += "INVALID_ENUM";
|
|
39
|
-
break;
|
|
40
|
-
case gl.INVALID_VALUE:
|
|
41
|
-
message += "INVALID_VALUE";
|
|
42
|
-
break;
|
|
43
|
-
case gl.INVALID_OPERATION:
|
|
44
|
-
message += "INVALID_OPERATION";
|
|
45
|
-
break;
|
|
46
|
-
case gl.OUT_OF_MEMORY:
|
|
47
|
-
message += "OUT_OF_MEMORY";
|
|
48
|
-
break;
|
|
49
|
-
case gl.CONTEXT_LOST_WEBGL:
|
|
50
|
-
message += "CONTEXT_LOST_WEBGL lost";
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
message += `Unknown (${error})`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return message;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function createErrorMessage(gl, glFunc, glFuncArguments, error) {
|
|
60
|
-
let message = `${errorToString(gl, error)}: ${glFunc.name}(`;
|
|
61
|
-
|
|
62
|
-
for (let i = 0; i < glFuncArguments.length; ++i) {
|
|
63
|
-
if (i !== 0) {
|
|
64
|
-
message += ", ";
|
|
65
|
-
}
|
|
66
|
-
message += glFuncArguments[i];
|
|
67
|
-
}
|
|
68
|
-
message += ");";
|
|
69
|
-
|
|
70
|
-
return message;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function throwOnError(gl, glFunc, glFuncArguments) {
|
|
74
|
-
const error = gl.getError();
|
|
75
|
-
if (error !== gl.NO_ERROR) {
|
|
76
|
-
throw new RuntimeError(
|
|
77
|
-
createErrorMessage(gl, glFunc, glFuncArguments, error)
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function makeGetterSetter(gl, propertyName, logFunction) {
|
|
83
|
-
return {
|
|
84
|
-
get: function () {
|
|
85
|
-
const value = gl[propertyName];
|
|
86
|
-
logFunction(gl, `get: ${propertyName}`, value);
|
|
87
|
-
return gl[propertyName];
|
|
88
|
-
},
|
|
89
|
-
set: function (value) {
|
|
90
|
-
gl[propertyName] = value;
|
|
91
|
-
logFunction(gl, `set: ${propertyName}`, value);
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function wrapGL(gl, logFunction) {
|
|
97
|
-
if (!defined(logFunction)) {
|
|
98
|
-
return gl;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function wrapFunction(property) {
|
|
102
|
-
return function () {
|
|
103
|
-
const result = property.apply(gl, arguments);
|
|
104
|
-
logFunction(gl, property, arguments);
|
|
105
|
-
return result;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const glWrapper = {};
|
|
110
|
-
|
|
111
|
-
// JavaScript linters normally demand that a for..in loop must directly contain an if,
|
|
112
|
-
// but in our loop below, we actually intend to iterate all properties, including
|
|
113
|
-
// those in the prototype.
|
|
114
|
-
/*eslint-disable guard-for-in*/
|
|
115
|
-
for (const propertyName in gl) {
|
|
116
|
-
const property = gl[propertyName];
|
|
117
|
-
|
|
118
|
-
// wrap any functions we encounter, otherwise just copy the property to the wrapper.
|
|
119
|
-
if (property instanceof Function) {
|
|
120
|
-
glWrapper[propertyName] = wrapFunction(property);
|
|
121
|
-
} else {
|
|
122
|
-
Object.defineProperty(
|
|
123
|
-
glWrapper,
|
|
124
|
-
propertyName,
|
|
125
|
-
makeGetterSetter(gl, propertyName, logFunction)
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/*eslint-enable guard-for-in*/
|
|
130
|
-
|
|
131
|
-
return glWrapper;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function getExtension(gl, names) {
|
|
135
|
-
const length = names.length;
|
|
136
|
-
for (let i = 0; i < length; ++i) {
|
|
137
|
-
const extension = gl.getExtension(names[i]);
|
|
138
|
-
if (extension) {
|
|
139
|
-
return extension;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
33
|
/**
|
|
147
34
|
* @private
|
|
148
35
|
* @constructor
|
|
36
|
+
*
|
|
37
|
+
* @param {HTMLCanvasElement} canvas The canvas element to which the context will be associated
|
|
38
|
+
* @param {ContextOptions} [options] Options to control WebGL settings for the context
|
|
149
39
|
*/
|
|
150
40
|
function Context(canvas, options) {
|
|
151
|
-
// this check must use typeof, not defined, because defined doesn't work with undeclared variables.
|
|
152
|
-
if (typeof WebGLRenderingContext === "undefined") {
|
|
153
|
-
throw new RuntimeError(
|
|
154
|
-
"The browser does not support WebGL. Visit http://get.webgl.org."
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
41
|
//>>includeStart('debug', pragmas.debug);
|
|
159
42
|
Check.defined("canvas", canvas);
|
|
160
43
|
//>>includeEnd('debug');
|
|
161
44
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
options.allowTextureFilterAnisotropic,
|
|
169
|
-
true
|
|
170
|
-
);
|
|
171
|
-
const webglOptions = defaultValue(options.webgl, {});
|
|
45
|
+
const {
|
|
46
|
+
getWebGLStub,
|
|
47
|
+
requestWebgl2 = false,
|
|
48
|
+
webgl: webglOptions = {},
|
|
49
|
+
allowTextureFilterAnisotropic = true,
|
|
50
|
+
} = defaultValue(options, {});
|
|
172
51
|
|
|
173
52
|
// Override select WebGL defaults
|
|
174
53
|
webglOptions.alpha = defaultValue(webglOptions.alpha, false); // WebGL default is true
|
|
175
54
|
webglOptions.stencil = defaultValue(webglOptions.stencil, true); // WebGL default is false
|
|
55
|
+
webglOptions.powerPreference = defaultValue(
|
|
56
|
+
webglOptions.powerPreference,
|
|
57
|
+
"high-performance"
|
|
58
|
+
); // WebGL default is "default"
|
|
176
59
|
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (!defined(getWebGLStub)) {
|
|
186
|
-
if (requestWebgl2) {
|
|
187
|
-
glContext =
|
|
188
|
-
canvas.getContext("webgl2", webglOptions) ||
|
|
189
|
-
canvas.getContext("experimental-webgl2", webglOptions) ||
|
|
190
|
-
undefined;
|
|
191
|
-
if (defined(glContext)) {
|
|
192
|
-
webgl2 = true;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (!defined(glContext)) {
|
|
196
|
-
glContext =
|
|
197
|
-
canvas.getContext("webgl", webglOptions) ||
|
|
198
|
-
canvas.getContext("experimental-webgl", webglOptions) ||
|
|
199
|
-
undefined;
|
|
200
|
-
}
|
|
201
|
-
if (!defined(glContext)) {
|
|
202
|
-
throw new RuntimeError(
|
|
203
|
-
"The browser supports WebGL, but initialization failed."
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
// Use WebGL stub when requested for unit tests
|
|
208
|
-
glContext = getWebGLStub(canvas, webglOptions);
|
|
209
|
-
}
|
|
60
|
+
const glContext = defined(getWebGLStub)
|
|
61
|
+
? getWebGLStub(canvas, webglOptions)
|
|
62
|
+
: getWebGLContext(canvas, webglOptions, requestWebgl2);
|
|
63
|
+
|
|
64
|
+
// Get context type. instanceof will throw if WebGL2 is not supported
|
|
65
|
+
const webgl2 =
|
|
66
|
+
typeof WebGL2RenderingContext !== "undefined" &&
|
|
67
|
+
glContext instanceof WebGL2RenderingContext;
|
|
210
68
|
|
|
69
|
+
this._canvas = canvas;
|
|
211
70
|
this._originalGLContext = glContext;
|
|
212
71
|
this._gl = glContext;
|
|
213
72
|
this._webgl2 = webgl2;
|
|
@@ -335,7 +194,7 @@ function Context(canvas, options) {
|
|
|
335
194
|
this._bc7
|
|
336
195
|
);
|
|
337
196
|
|
|
338
|
-
const textureFilterAnisotropic =
|
|
197
|
+
const textureFilterAnisotropic = allowTextureFilterAnisotropic
|
|
339
198
|
? getExtension(gl, [
|
|
340
199
|
"EXT_texture_filter_anisotropic",
|
|
341
200
|
"WEBKIT_EXT_texture_filter_anisotropic",
|
|
@@ -502,21 +361,16 @@ function Context(canvas, options) {
|
|
|
502
361
|
this._nextPickColor = new Uint32Array(1);
|
|
503
362
|
|
|
504
363
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* alpha : false,
|
|
509
|
-
* depth : true,
|
|
510
|
-
* stencil : false,
|
|
511
|
-
* antialias : true,
|
|
512
|
-
* premultipliedAlpha : true,
|
|
513
|
-
* preserveDrawingBuffer : false,
|
|
514
|
-
* failIfMajorPerformanceCaveat : true
|
|
515
|
-
* },
|
|
516
|
-
* allowTextureFilterAnisotropic : true
|
|
517
|
-
* }
|
|
364
|
+
* The options used to construct this context
|
|
365
|
+
*
|
|
366
|
+
* @type {ContextOptions}
|
|
518
367
|
*/
|
|
519
|
-
this.options =
|
|
368
|
+
this.options = {
|
|
369
|
+
getWebGLStub: getWebGLStub,
|
|
370
|
+
requestWebgl2: requestWebgl2,
|
|
371
|
+
webgl: webglOptions,
|
|
372
|
+
allowTextureFilterAnisotropic: allowTextureFilterAnisotropic,
|
|
373
|
+
};
|
|
520
374
|
|
|
521
375
|
/**
|
|
522
376
|
* A cache of objects tied to this context. Just before the Context is destroyed,
|
|
@@ -532,6 +386,187 @@ function Context(canvas, options) {
|
|
|
532
386
|
RenderState.apply(gl, rs, ps);
|
|
533
387
|
}
|
|
534
388
|
|
|
389
|
+
/**
|
|
390
|
+
* @typedef {Object} ContextOptions
|
|
391
|
+
*
|
|
392
|
+
* Options to control the setting up of a WebGL Context.
|
|
393
|
+
* <p>
|
|
394
|
+
* <code>allowTextureFilterAnisotropic</code> defaults to true, which enables
|
|
395
|
+
* anisotropic texture filtering when the WebGL extension is supported.
|
|
396
|
+
* Setting this to false will improve performance, but hurt visual quality,
|
|
397
|
+
* especially for horizon views.
|
|
398
|
+
* </p>
|
|
399
|
+
*
|
|
400
|
+
* @property {Boolean} [requestWebGl2 = false] If true and the browser supports it, use a WebGL 2 rendering context
|
|
401
|
+
* @property {Boolean} [allowTextureFilterAnisotropic=true] If true, use anisotropic filtering during texture sampling
|
|
402
|
+
* @property {WebGLOptions} [webgl] WebGL options to be passed on to canvas.getContext
|
|
403
|
+
* @property {Function} [getWebGLStub] A function to create a WebGL stub for testing
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @private
|
|
408
|
+
* @param {HTMLCanvasElement} canvas The canvas element to which the context will be associated
|
|
409
|
+
* @param {WebGLOptions} webglOptions WebGL options to be passed on to HTMLCanvasElement.getContext()
|
|
410
|
+
* @param {Boolean} requestWebgl2 Whether to request a WebGL2RenderingContext
|
|
411
|
+
* @returns {WebGLRenderingContext|WebGL2RenderingContext}
|
|
412
|
+
*/
|
|
413
|
+
function getWebGLContext(canvas, webglOptions, requestWebgl2) {
|
|
414
|
+
if (typeof WebGLRenderingContext === "undefined") {
|
|
415
|
+
throw new RuntimeError(
|
|
416
|
+
"The browser does not support WebGL. Visit http://get.webgl.org."
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
requestWebgl2 =
|
|
421
|
+
requestWebgl2 && typeof WebGL2RenderingContext !== "undefined";
|
|
422
|
+
const contextType = requestWebgl2 ? "webgl2" : "webgl";
|
|
423
|
+
const glContext = canvas.getContext(contextType, webglOptions);
|
|
424
|
+
|
|
425
|
+
if (!defined(glContext)) {
|
|
426
|
+
throw new RuntimeError(
|
|
427
|
+
"The browser supports WebGL, but initialization failed."
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return glContext;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @typedef {Object} WebGLOptions
|
|
436
|
+
*
|
|
437
|
+
* WebGL options to be passed on to HTMLCanvasElement.getContext().
|
|
438
|
+
* See {@link https://registry.khronos.org/webgl/specs/latest/1.0/#5.2|WebGLContextAttributes}
|
|
439
|
+
* but note the modified defaults for 'alpha', 'stencil', and 'powerPreference'
|
|
440
|
+
*
|
|
441
|
+
* <p>
|
|
442
|
+
* <code>alpha</code> defaults to false, which can improve performance
|
|
443
|
+
* compared to the standard WebGL default of true. If an application needs
|
|
444
|
+
* to composite Cesium above other HTML elements using alpha-blending, set
|
|
445
|
+
* <code>alpha</code> to true.
|
|
446
|
+
* </p>
|
|
447
|
+
*
|
|
448
|
+
* @property {Boolean} [alpha=false]
|
|
449
|
+
* @property {Boolean} [depth=true]
|
|
450
|
+
* @property {Boolean} [stencil=false]
|
|
451
|
+
* @property {Boolean} [antialias=true]
|
|
452
|
+
* @property {Boolean} [premultipliedAlpha=true]
|
|
453
|
+
* @property {Boolean} [preserveDrawingBuffer=false]
|
|
454
|
+
* @property {("default"|"low-power"|"high-performance")} [powerPreference="high-performance"]
|
|
455
|
+
* @property {Boolean} [failIfMajorPerformanceCaveat=false]
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
function errorToString(gl, error) {
|
|
459
|
+
let message = "WebGL Error: ";
|
|
460
|
+
switch (error) {
|
|
461
|
+
case gl.INVALID_ENUM:
|
|
462
|
+
message += "INVALID_ENUM";
|
|
463
|
+
break;
|
|
464
|
+
case gl.INVALID_VALUE:
|
|
465
|
+
message += "INVALID_VALUE";
|
|
466
|
+
break;
|
|
467
|
+
case gl.INVALID_OPERATION:
|
|
468
|
+
message += "INVALID_OPERATION";
|
|
469
|
+
break;
|
|
470
|
+
case gl.OUT_OF_MEMORY:
|
|
471
|
+
message += "OUT_OF_MEMORY";
|
|
472
|
+
break;
|
|
473
|
+
case gl.CONTEXT_LOST_WEBGL:
|
|
474
|
+
message += "CONTEXT_LOST_WEBGL lost";
|
|
475
|
+
break;
|
|
476
|
+
default:
|
|
477
|
+
message += `Unknown (${error})`;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return message;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function createErrorMessage(gl, glFunc, glFuncArguments, error) {
|
|
484
|
+
let message = `${errorToString(gl, error)}: ${glFunc.name}(`;
|
|
485
|
+
|
|
486
|
+
for (let i = 0; i < glFuncArguments.length; ++i) {
|
|
487
|
+
if (i !== 0) {
|
|
488
|
+
message += ", ";
|
|
489
|
+
}
|
|
490
|
+
message += glFuncArguments[i];
|
|
491
|
+
}
|
|
492
|
+
message += ");";
|
|
493
|
+
|
|
494
|
+
return message;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function throwOnError(gl, glFunc, glFuncArguments) {
|
|
498
|
+
const error = gl.getError();
|
|
499
|
+
if (error !== gl.NO_ERROR) {
|
|
500
|
+
throw new RuntimeError(
|
|
501
|
+
createErrorMessage(gl, glFunc, glFuncArguments, error)
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function makeGetterSetter(gl, propertyName, logFunction) {
|
|
507
|
+
return {
|
|
508
|
+
get: function () {
|
|
509
|
+
const value = gl[propertyName];
|
|
510
|
+
logFunction(gl, `get: ${propertyName}`, value);
|
|
511
|
+
return gl[propertyName];
|
|
512
|
+
},
|
|
513
|
+
set: function (value) {
|
|
514
|
+
gl[propertyName] = value;
|
|
515
|
+
logFunction(gl, `set: ${propertyName}`, value);
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function wrapGL(gl, logFunction) {
|
|
521
|
+
if (!defined(logFunction)) {
|
|
522
|
+
return gl;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function wrapFunction(property) {
|
|
526
|
+
return function () {
|
|
527
|
+
const result = property.apply(gl, arguments);
|
|
528
|
+
logFunction(gl, property, arguments);
|
|
529
|
+
return result;
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const glWrapper = {};
|
|
534
|
+
|
|
535
|
+
// JavaScript linters normally demand that a for..in loop must directly contain an if,
|
|
536
|
+
// but in our loop below, we actually intend to iterate all properties, including
|
|
537
|
+
// those in the prototype.
|
|
538
|
+
/*eslint-disable guard-for-in*/
|
|
539
|
+
for (const propertyName in gl) {
|
|
540
|
+
const property = gl[propertyName];
|
|
541
|
+
|
|
542
|
+
// wrap any functions we encounter, otherwise just copy the property to the wrapper.
|
|
543
|
+
if (property instanceof Function) {
|
|
544
|
+
glWrapper[propertyName] = wrapFunction(property);
|
|
545
|
+
} else {
|
|
546
|
+
Object.defineProperty(
|
|
547
|
+
glWrapper,
|
|
548
|
+
propertyName,
|
|
549
|
+
makeGetterSetter(gl, propertyName, logFunction)
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/*eslint-enable guard-for-in*/
|
|
554
|
+
|
|
555
|
+
return glWrapper;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function getExtension(gl, names) {
|
|
559
|
+
const length = names.length;
|
|
560
|
+
for (let i = 0; i < length; ++i) {
|
|
561
|
+
const extension = gl.getExtension(names[i]);
|
|
562
|
+
if (extension) {
|
|
563
|
+
return extension;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
|
|
535
570
|
const defaultFramebufferMarker = {};
|
|
536
571
|
|
|
537
572
|
Object.defineProperties(Context.prototype, {
|
|
@@ -626,7 +626,8 @@ I3SDataProvider.prototype._loadGeoidData = function () {
|
|
|
626
626
|
console.log(
|
|
627
627
|
"No Geoid Terrain service provided - no geoid conversion will be performed."
|
|
628
628
|
);
|
|
629
|
-
|
|
629
|
+
this._geoidDataIsReadyPromise = Promise.resolve();
|
|
630
|
+
return this._geoidDataIsReadyPromise;
|
|
630
631
|
}
|
|
631
632
|
|
|
632
633
|
this._geoidDataIsReadyPromise = geoidTerrainProvider.readyPromise.then(
|
|
@@ -49,7 +49,7 @@ Object.defineProperties(I3SFeature.prototype, {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Loads the content.
|
|
52
|
-
* @returns {Promise
|
|
52
|
+
* @returns {Promise} A promise that is resolved when the data of the I3S feature is loaded
|
|
53
53
|
* @private
|
|
54
54
|
*/
|
|
55
55
|
I3SFeature.prototype.load = function () {
|
package/Source/Scene/I3SLayer.js
CHANGED
|
@@ -35,6 +35,11 @@ function I3SLayer(dataProvider, layerData, index) {
|
|
|
35
35
|
.concat(`${layerData.href}`);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
this._version = layerData.store.version;
|
|
39
|
+
const splitVersion = this._version.split(".");
|
|
40
|
+
this._majorVersion = parseInt(splitVersion[0]);
|
|
41
|
+
this._minorVersion = splitVersion.length > 1 ? parseInt(splitVersion[1]) : 0;
|
|
42
|
+
|
|
38
43
|
this._resource = new Resource({ url: tilesetUrl });
|
|
39
44
|
this._resource.setQueryParameters(
|
|
40
45
|
this._dataProvider.resource.queryParameters
|
|
@@ -98,11 +103,68 @@ Object.defineProperties(I3SLayer.prototype, {
|
|
|
98
103
|
return this._data;
|
|
99
104
|
},
|
|
100
105
|
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The version string of the loaded I3S dataset
|
|
109
|
+
* @memberof I3SLayer.prototype
|
|
110
|
+
* @type {String}
|
|
111
|
+
* @readonly
|
|
112
|
+
*/
|
|
113
|
+
version: {
|
|
114
|
+
get: function () {
|
|
115
|
+
return this._version;
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The major version number of the loaded I3S dataset
|
|
121
|
+
* @memberof I3SLayer.prototype
|
|
122
|
+
* @type {Number}
|
|
123
|
+
* @readonly
|
|
124
|
+
*/
|
|
125
|
+
majorVersion: {
|
|
126
|
+
get: function () {
|
|
127
|
+
return this._majorVersion;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The minor version number of the loaded I3S dataset
|
|
133
|
+
* @memberof I3SLayer.prototype
|
|
134
|
+
* @type {Number}
|
|
135
|
+
* @readonly
|
|
136
|
+
*/
|
|
137
|
+
minorVersion: {
|
|
138
|
+
get: function () {
|
|
139
|
+
return this._minorVersion;
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* When <code>true</code>, when the loaded I3S version is 1.6 or older
|
|
145
|
+
* @memberof I3SLayer.prototype
|
|
146
|
+
* @type {Boolean}
|
|
147
|
+
* @readonly
|
|
148
|
+
*/
|
|
149
|
+
legacyVersion16: {
|
|
150
|
+
get: function () {
|
|
151
|
+
if (!defined(this.version)) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
if (
|
|
155
|
+
this.majorVersion < 1 ||
|
|
156
|
+
(this.majorVersion === 1 && this.minorVersion <= 6)
|
|
157
|
+
) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
},
|
|
162
|
+
},
|
|
101
163
|
});
|
|
102
164
|
|
|
103
165
|
/**
|
|
104
166
|
* Loads the content, including the root node definition and its children
|
|
105
|
-
* @returns {Promise
|
|
167
|
+
* @returns {Promise} A promise that is resolved when the layer data is loaded
|
|
106
168
|
* @private
|
|
107
169
|
*/
|
|
108
170
|
I3SLayer.prototype.load = function () {
|
|
@@ -121,7 +183,7 @@ I3SLayer.prototype.load = function () {
|
|
|
121
183
|
return that._tileset.readyPromise.then(function () {
|
|
122
184
|
that._rootNode._tile = that._tileset._root;
|
|
123
185
|
that._tileset._root._i3sNode = that._rootNode;
|
|
124
|
-
if (that.
|
|
186
|
+
if (that.legacyVersion16) {
|
|
125
187
|
return that._rootNode._loadChildren();
|
|
126
188
|
}
|
|
127
189
|
});
|
package/Source/Scene/I3SNode.js
CHANGED
|
@@ -240,6 +240,52 @@ I3SNode.prototype.loadFields = function () {
|
|
|
240
240
|
return Promise.all(promises);
|
|
241
241
|
};
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Returns the fields for a given picked position
|
|
245
|
+
* @param {Cartesian3} pickedPosition The picked position
|
|
246
|
+
* @returns {Object} Object containing field names and their values
|
|
247
|
+
*/
|
|
248
|
+
I3SNode.prototype.getFieldsForPickedPosition = function (pickedPosition) {
|
|
249
|
+
const geometry = this.geometryData[0];
|
|
250
|
+
if (!defined(geometry.customAttributes.featureIndex)) {
|
|
251
|
+
return {};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const location = geometry.getClosestPointIndexOnTriangle(
|
|
255
|
+
pickedPosition.x,
|
|
256
|
+
pickedPosition.y,
|
|
257
|
+
pickedPosition.z
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
if (
|
|
261
|
+
location.index === -1 ||
|
|
262
|
+
location.index > geometry.customAttributes.featureIndex.length
|
|
263
|
+
) {
|
|
264
|
+
return {};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const featureIndex = geometry.customAttributes.featureIndex[location.index];
|
|
268
|
+
return this.getFieldsForFeature(featureIndex);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Returns the fields for a given feature
|
|
273
|
+
* @param {Number} featureIndex Index of the feature whose attributes we want to get
|
|
274
|
+
* @returns {Object} Object containing field names and their values
|
|
275
|
+
*/
|
|
276
|
+
I3SNode.prototype.getFieldsForFeature = function (featureIndex) {
|
|
277
|
+
const featureFields = {};
|
|
278
|
+
for (const fieldName in this.fields) {
|
|
279
|
+
if (this.fields.hasOwnProperty(fieldName)) {
|
|
280
|
+
const field = this.fields[fieldName];
|
|
281
|
+
if (featureIndex >= 0 && featureIndex < field.values.length) {
|
|
282
|
+
featureFields[field.name] = field.values[featureIndex];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return featureFields;
|
|
287
|
+
};
|
|
288
|
+
|
|
243
289
|
/**
|
|
244
290
|
* @private
|
|
245
291
|
*/
|
|
@@ -336,11 +382,6 @@ I3SNode.prototype._loadFeatureData = function () {
|
|
|
336
382
|
this._featureData.push(newFeatureData);
|
|
337
383
|
featurePromises.push(newFeatureData.load());
|
|
338
384
|
}
|
|
339
|
-
} else if (defined(this._data.mesh) && defined(this._data.mesh.attribute)) {
|
|
340
|
-
const featureURI = `./features/0`;
|
|
341
|
-
const newFeatureData = new I3SFeature(this, featureURI);
|
|
342
|
-
this._featureData.push(newFeatureData);
|
|
343
|
-
featurePromises.push(newFeatureData.load());
|
|
344
385
|
}
|
|
345
386
|
|
|
346
387
|
return Promise.all(featurePromises);
|
|
@@ -661,7 +702,10 @@ I3SNode.prototype._createContentURL = function () {
|
|
|
661
702
|
};
|
|
662
703
|
|
|
663
704
|
// Load the geometry data
|
|
664
|
-
const dataPromises = [this.
|
|
705
|
+
const dataPromises = [this._loadGeometryData()];
|
|
706
|
+
if (this._dataProvider.legacyVersion16) {
|
|
707
|
+
dataPromises.push(this._loadFeatureData());
|
|
708
|
+
}
|
|
665
709
|
|
|
666
710
|
const that = this;
|
|
667
711
|
return Promise.all(dataPromises).then(function () {
|
|
@@ -49,22 +49,55 @@ import StyleCommandsNeeded from "./StyleCommandsNeeded.js";
|
|
|
49
49
|
* {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/AGI_articulations/README.md|AGI_articulations}
|
|
50
50
|
* </li>
|
|
51
51
|
* <li>
|
|
52
|
+
* {@link https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline}
|
|
53
|
+
* </li>
|
|
54
|
+
* <li>
|
|
55
|
+
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/1.0/Vendor/CESIUM_RTC/README.md|CESIUM_RTC}
|
|
56
|
+
* </li>
|
|
57
|
+
* <li>
|
|
58
|
+
* {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_instance_features|EXT_instance_features}
|
|
59
|
+
* </li>
|
|
60
|
+
* <li>
|
|
61
|
+
* {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features|EXT_mesh_features}
|
|
62
|
+
* </li>
|
|
63
|
+
* <li>
|
|
64
|
+
* {@link https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing|EXT_mesh_gpu_instancing}
|
|
65
|
+
* </li>
|
|
66
|
+
* <li>
|
|
67
|
+
* {@link https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_meshopt_compression|EXT_meshopt_compression}
|
|
68
|
+
* </li>
|
|
69
|
+
* <li>
|
|
70
|
+
* {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata|EXT_structural_metadata}
|
|
71
|
+
* </li>
|
|
72
|
+
* <li>
|
|
73
|
+
* {@link https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_texture_webp|EXT_texture_webp}
|
|
74
|
+
* </li>
|
|
75
|
+
* <li>
|
|
52
76
|
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md|KHR_draco_mesh_compression}
|
|
53
77
|
* </li>
|
|
54
78
|
* <li>
|
|
55
|
-
* {@link https://github.com/KhronosGroup/glTF/
|
|
79
|
+
* {@link https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_techniques_webgl/README.md|KHR_techniques_webgl}
|
|
80
|
+
* </li>
|
|
81
|
+
* <li>
|
|
82
|
+
* {@link https://github.com/KhronosGroup/glTF/blob/main/extensions/1.0/Khronos/KHR_materials_common/README.md|KHR_materials_common}
|
|
83
|
+
* </li>
|
|
84
|
+
* <li>
|
|
85
|
+
* {@link https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness|KHR_materials_pbrSpecularGlossiness}
|
|
56
86
|
* </li>
|
|
57
87
|
* <li>
|
|
58
88
|
* {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit/README.md|KHR_materials_unlit}
|
|
59
89
|
* </li>
|
|
60
90
|
* <li>
|
|
61
|
-
* {@link https://github.com/KhronosGroup/glTF/
|
|
91
|
+
* {@link https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_mesh_quantization|KHR_mesh_quantization}
|
|
62
92
|
* </li>
|
|
63
93
|
* <li>
|
|
64
94
|
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_basisu|KHR_texture_basisu}
|
|
65
95
|
* </li>
|
|
66
96
|
* <li>
|
|
67
|
-
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/
|
|
97
|
+
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md|KHR_texture_transform}
|
|
98
|
+
* </li>
|
|
99
|
+
* <li>
|
|
100
|
+
* {@link https://github.com/KhronosGroup/glTF/blob/main/extensions/1.0/Vendor/WEB3D_quantized_attributes/README.md|WEB3D_quantized_attributes}
|
|
68
101
|
* </li>
|
|
69
102
|
* </ul>
|
|
70
103
|
* </p>
|