@xeokit/xeokit-sdk 2.0.0-beta.9 → 2.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.
@@ -74,11 +74,12 @@ class Group {
74
74
  * @private
75
75
  */
76
76
  class Item {
77
- constructor(id, getTitle, doAction, getEnabled) {
77
+ constructor(id, getTitle, doAction, getEnabled, getShown) {
78
78
  this.id = id;
79
79
  this.getTitle = getTitle;
80
80
  this.doAction = doAction;
81
81
  this.getEnabled = getEnabled;
82
+ this.getShown = getShown;
82
83
  this.itemElement = null;
83
84
  this.subMenu = null;
84
85
  this.enabled = true;
@@ -97,6 +98,7 @@ class Item {
97
98
  * * A pure JavaScript, lightweight context menu
98
99
  * * Dynamically configure menu items
99
100
  * * Dynamically enable or disable items
101
+ * * Dynamically show or hide items
100
102
  * * Supports cascading sub-menus
101
103
  * * Configure custom style with custom CSS (see examples above)
102
104
  *
@@ -110,16 +112,23 @@ class Item {
110
112
  * Each item has:
111
113
  *
112
114
  * * a ````title```` for the item,
113
- * * a ````doAction()```` callback to fire when the item's title is clicked, and
114
- * * an optional ````getEnabled()```` callback that indicates if the item should enabled in the menu or not.
115
+ * * a ````doAction()```` callback to fire when the item's title is clicked,
116
+ * * an optional ````getShown()```` callback that indicates if the item should shown in the menu or not, and
117
+ * * an optional ````getEnabled()```` callback that indicates if the item should be shown enabled in the menu or not.
115
118
  *
116
119
  * <br>
117
120
  *
118
- * The ````getEnabled()```` callbacks are invoked whenever the menu is shown. When an item's ````getEnabled()```` callback
119
- * returns ````true````, then the item is enabled and clickable. When it returns ````false````, then the item is disabled
120
- * and cannot be clicked. An item without a ````getEnabled()```` callback is always enabled and clickable.
121
+ * The ````getShown()```` and ````getEnabled()```` callbacks are invoked whenever the menu is shown.
121
122
  *
122
- * Note how the ````doAction()```` and ````getEnabled()```` callbacks accept a ````context````
123
+ * When an item's ````getShown()```` callback
124
+ * returns ````true````, then the item is shown. When it returns ````false````, then the item is hidden. An item without
125
+ * a ````getShown()```` callback is always shown.
126
+ *
127
+ * When an item's ````getEnabled()```` callback returns ````true````, then the item is enabled and clickable (as long as it's also shown). When it
128
+ * returns ````false````, then the item is disabled and cannot be clicked. An item without a ````getEnabled()````
129
+ * callback is always enabled and clickable.
130
+ *
131
+ * Note how the ````doAction()````, ````getShown()```` and ````getEnabled()```` callbacks accept a ````context````
123
132
  * object. That must be set on the ````ContextMenu```` before we're able to we show it. The context object can be anything. In this example,
124
133
  * we'll use the context object to provide the callbacks with the Entity that we right-clicked.
125
134
  *
@@ -341,6 +350,11 @@ class ContextMenu {
341
350
  this.hide();
342
351
  }
343
352
  });
353
+ document.addEventListener("touchstart", this._canvasTouchStartHandler = (event) => {
354
+ if (!event.target.classList.contains("xeokit-context-menu-item")) {
355
+ this.hide();
356
+ }
357
+ });
344
358
  }
345
359
 
346
360
  if (cfg.items) {
@@ -575,7 +589,11 @@ class ContextMenu {
575
589
  return true;
576
590
  });
577
591
 
578
- const item = new Item(itemId, getTitle, doAction, getEnabled);
592
+ const getShown = itemCfg.getShown || (() => {
593
+ return true;
594
+ });
595
+
596
+ const item = new Item(itemId, getTitle, doAction, getEnabled, getShown);
579
597
 
580
598
  item.parentMenu = menu;
581
599
 
@@ -809,6 +827,10 @@ class ContextMenu {
809
827
  if (!itemElement) {
810
828
  continue;
811
829
  }
830
+ const getShown = item.getShown;
831
+ if (!getShown || !getShown(this._context)) {
832
+ continue;
833
+ }
812
834
  const title = item.getTitle(this._context);
813
835
  if (item.subMenu) {
814
836
  itemElement.innerText = title;
@@ -832,6 +854,22 @@ class ContextMenu {
832
854
  if (!getEnabled) {
833
855
  continue;
834
856
  }
857
+ const getShown = item.getShown;
858
+ if (!getShown) {
859
+ continue;
860
+ }
861
+ const shown = getShown(this._context);
862
+ item.shown = shown;
863
+ if (!shown) {
864
+ itemElement.style.visibility = "hidden";
865
+ itemElement.style.height = "0";
866
+ itemElement.style.padding = "0";
867
+ continue;
868
+ } else {
869
+ itemElement.style.visibility = "visible";
870
+ itemElement.style.height = "auto";
871
+ itemElement.style.padding = null;
872
+ }
835
873
  const enabled = getEnabled(this._context);
836
874
  item.enabled = enabled;
837
875
  if (!enabled) {
@@ -8767,7 +8805,6 @@ const createRTCViewMat = (function () {
8767
8805
  *
8768
8806
  * Given a double-precision World-space position, returns a double-precision relative-to-center (RTC) center pos
8769
8807
  * and a single-precision offset fom that center.
8770
- *
8771
8808
  * @private
8772
8809
  * @param {Float64Array} worldPos The World-space position.
8773
8810
  * @param {Float64Array} rtcCenter Double-precision relative-to-center (RTC) center pos.
@@ -9056,12 +9093,12 @@ class Marker extends Component {
9056
9093
  this._entity = entity;
9057
9094
  if (this._entity) {
9058
9095
  if (this._entity instanceof PerformanceNode) {
9059
- this._onEntityModelDestroyed = this._entity.model.once("destroyed", () => { // PerformanceNode does not fire events, and cannot exist beyond its PerformanceModel
9096
+ this._onEntityModelDestroyed = this._entity.model.on("destroyed", () => { // PerformanceNode does not fire events, and cannot exist beyond its PerformanceModel
9060
9097
  this._entity = null; // Marker now may become visible, if it was synched to invisible Entity
9061
9098
  this._onEntityModelDestroyed = null;
9062
9099
  });
9063
9100
  } else {
9064
- this._onEntityDestroyed = this._entity.once("destroyed", () => {
9101
+ this._onEntityDestroyed = this._entity.on("destroyed", () => {
9065
9102
  this._entity = null;
9066
9103
  this._onEntityDestroyed = null;
9067
9104
  });
@@ -15849,6 +15886,7 @@ const Renderer = function (scene, options) {
15849
15886
  const tempMat4a = math.mat4();
15850
15887
  const tempMat4b = math.mat4();
15851
15888
 
15889
+ const randomVec3 = math.vec3();
15852
15890
  const up = math.vec3([0, 1, 0]);
15853
15891
  const _pickResult = new PickResult();
15854
15892
 
@@ -15859,6 +15897,7 @@ const Renderer = function (scene, options) {
15859
15897
  const worldRayOrigin = math.vec3();
15860
15898
  const worldRayDir = math.vec3();
15861
15899
  const worldSurfacePos = math.vec3();
15900
+ const worldSurfaceNormal = math.vec3();
15862
15901
 
15863
15902
  return function (params, pickResult = _pickResult) {
15864
15903
 
@@ -15899,7 +15938,7 @@ const Renderer = function (scene, options) {
15899
15938
  // Picking with arbitrary World-space ray
15900
15939
  // Align camera along ray and fire ray through center of canvas
15901
15940
 
15902
- const pickFrustumMatrix = math.frustumMat4(-1, 1, -1, 1, scene.camera.project.near, scene.camera.project.far, tempMat4a);
15941
+ const pickFrustumMatrix = math.frustumMat4(-1, 1, -1, 1, 0.01, scene.camera.project.far, tempMat4a);
15903
15942
 
15904
15943
  if (params.matrix) {
15905
15944
 
@@ -15913,6 +15952,13 @@ const Renderer = function (scene, options) {
15913
15952
 
15914
15953
  look = math.addVec3(worldRayOrigin, worldRayDir, tempVec3a);
15915
15954
 
15955
+ randomVec3[0] = Math.random();
15956
+ randomVec3[1] = Math.random();
15957
+ randomVec3[2] = Math.random();
15958
+
15959
+ math.normalizeVec3(randomVec3);
15960
+ math.cross3Vec3(worldRayDir, randomVec3, up);
15961
+
15916
15962
  pickViewMatrix = math.lookAtMat4v(worldRayOrigin, look, up, tempMat4b);
15917
15963
  pickProjMatrix = pickFrustumMatrix;
15918
15964
 
@@ -15950,14 +15996,18 @@ const Renderer = function (scene, options) {
15950
15996
  math.canvasPosToWorldRay(scene.canvas.canvas, pickViewMatrix, pickProjMatrix, canvasPos, worldRayOrigin, worldRayDir);
15951
15997
  }
15952
15998
 
15953
- if (pickable.precisionRayPickSurface(worldRayOrigin, worldRayDir, worldSurfacePos)) {
15999
+ if (pickable.precisionRayPickSurface(worldRayOrigin, worldRayDir, worldSurfacePos, worldSurfaceNormal)) {
15954
16000
 
15955
16001
  pickResult.worldPos = worldSurfacePos;
15956
16002
 
15957
16003
  if (params.pickSurfaceNormal !== false) {
15958
- gpuPickWorldNormal(pickable, canvasPos, pickViewMatrix, pickProjMatrix, pickResult);
16004
+ pickResult.worldNormal = worldSurfaceNormal;
15959
16005
  }
15960
16006
 
16007
+ // if (params.pickSurfaceNormal !== false) {
16008
+ // gpuPickWorldNormal(pickable, canvasPos, pickViewMatrix, pickProjMatrix, pickResult);
16009
+ // }
16010
+
15961
16011
  pickResult.pickSurfacePrecision = true;
15962
16012
  }
15963
16013
 
@@ -16017,8 +16067,6 @@ const Renderer = function (scene, options) {
16017
16067
  gl.disable(gl.BLEND);
16018
16068
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
16019
16069
 
16020
- let i;
16021
- let len;
16022
16070
  const includeEntityIds = params.includeEntityIds;
16023
16071
  const excludeEntityIds = params.excludeEntityIds;
16024
16072
 
@@ -16028,7 +16076,7 @@ const Renderer = function (scene, options) {
16028
16076
  const drawableInfo = drawableTypeInfo[type];
16029
16077
  const drawableList = drawableInfo.drawableList;
16030
16078
 
16031
- for (i = 0, len = drawableList.length; i < len; i++) {
16079
+ for (let i = 0, len = drawableList.length; i < len; i++) {
16032
16080
 
16033
16081
  const drawable = drawableList[i];
16034
16082
 
@@ -26063,8 +26111,10 @@ class Scene extends Component {
26063
26111
  }
26064
26112
 
26065
26113
  _deregisterModel(entity) {
26066
- delete this.models[entity.id];
26114
+ const modelId = entity.id;
26115
+ delete this.models[modelId];
26067
26116
  this._modelIds = null; // Lazy regenerate
26117
+ this.fire("modelUnloaded", modelId);
26068
26118
  }
26069
26119
 
26070
26120
  _registerObject(entity) {
@@ -27506,6 +27556,7 @@ class Scene extends Component {
27506
27556
  /**
27507
27557
  * @private
27508
27558
  */
27559
+
27509
27560
  const DrawShaderSource = function (mesh) {
27510
27561
  if (mesh._material._state.type === "LambertMaterial") {
27511
27562
  this.vertex = buildVertexLambert(mesh);
@@ -27594,7 +27645,13 @@ function buildVertexLambert(mesh) {
27594
27645
  }
27595
27646
  if (scene.logarithmicDepthBufferEnabled) {
27596
27647
  src.push("uniform float logDepthBufFC;");
27597
- src.push("varying float vFragDepth;");
27648
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27649
+ src.push("varying float vFragDepth;");
27650
+ }
27651
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
27652
+ src.push(" return (m[2][3] == - 1.0);");
27653
+ src.push("}");
27654
+ src.push("varying float isPerspective;");
27598
27655
  }
27599
27656
  if (clipping) {
27600
27657
  src.push("varying vec4 vWorldPosition;");
@@ -27728,7 +27785,6 @@ function buildVertexLambert(mesh) {
27728
27785
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
27729
27786
  }
27730
27787
  }
27731
- //src.push("vColor = vec4((reflectedColor * materialColor) + (lightAmbient.rgb * lightAmbient.a), 1.0) * colorize;");
27732
27788
  src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * materialColor.rgb) + materialEmissive.rgb + (reflectedColor * materialColor.rgb), materialColor.a) * colorize;"); // TODO: How to have ambient bright enough for canvas BG but not too bright for scene?
27733
27789
  if (clipping) {
27734
27790
  src.push("vWorldPosition = worldPosition;");
@@ -27738,7 +27794,13 @@ function buildVertexLambert(mesh) {
27738
27794
  }
27739
27795
  src.push("vec4 clipPos = projMatrix * viewPosition;");
27740
27796
  if (scene.logarithmicDepthBufferEnabled) {
27741
- src.push("vFragDepth = 1.0 + clipPos.w;");
27797
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27798
+ src.push("vFragDepth = 1.0 + clipPos.w;");
27799
+ } else {
27800
+ src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
27801
+ src.push("clipPos.z *= clipPos.w;");
27802
+ }
27803
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
27742
27804
  }
27743
27805
  src.push("gl_Position = clipPos;");
27744
27806
  src.push("}");
@@ -27764,7 +27826,8 @@ function buildFragmentLambert(mesh) {
27764
27826
  src.push("precision mediump float;");
27765
27827
  src.push("precision mediump int;");
27766
27828
  src.push("#endif");
27767
- if (scene.logarithmicDepthBufferEnabled) {
27829
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27830
+ src.push("varying float isPerspective;");
27768
27831
  src.push("uniform float logDepthBufFC;");
27769
27832
  src.push("varying float vFragDepth;");
27770
27833
  }
@@ -27804,8 +27867,8 @@ function buildFragmentLambert(mesh) {
27804
27867
  src.push("}");
27805
27868
 
27806
27869
  }
27807
- if (scene.logarithmicDepthBufferEnabled) {
27808
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
27870
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27871
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
27809
27872
  }
27810
27873
  if (gammaOutput) {
27811
27874
  src.push("gl_FragColor = linearToGamma(vColor, gammaFactor);");
@@ -27825,6 +27888,7 @@ function buildVertexDraw(mesh) {
27825
27888
  const lightsState = scene._lightsState;
27826
27889
  let light;
27827
27890
  const billboard = meshState.billboard;
27891
+ const background = meshState.background;
27828
27892
  const stationary = meshState.stationary;
27829
27893
  const texturing = hasTextures(mesh);
27830
27894
  const normals = hasNormals$1(mesh);
@@ -27853,7 +27917,13 @@ function buildVertexDraw(mesh) {
27853
27917
  }
27854
27918
  if (scene.logarithmicDepthBufferEnabled) {
27855
27919
  src.push("uniform float logDepthBufFC;");
27856
- src.push("varying float vFragDepth;");
27920
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27921
+ src.push("varying float vFragDepth;");
27922
+ }
27923
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
27924
+ src.push(" return (m[2][3] == - 1.0);");
27925
+ src.push("}");
27926
+ src.push("varying float isPerspective;");
27857
27927
  }
27858
27928
  if (lightsState.lightMaps.length > 0) {
27859
27929
  src.push("varying vec3 vWorldNormal;");
@@ -27950,6 +28020,8 @@ function buildVertexDraw(mesh) {
27950
28020
  src.push("mat4 modelMatrix2 = modelMatrix;");
27951
28021
  if (stationary) {
27952
28022
  src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");
28023
+ } else if (background) {
28024
+ src.push("viewMatrix2[3] = vec4(0.0, 0.0, 0.0 ,1.0);");
27953
28025
  }
27954
28026
  if (billboard === "spherical" || billboard === "cylindrical") {
27955
28027
  src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");
@@ -28020,7 +28092,16 @@ function buildVertexDraw(mesh) {
28020
28092
  src.push(" vViewPosition = viewPosition.xyz;");
28021
28093
  src.push("vec4 clipPos = projMatrix * viewPosition;");
28022
28094
  if (scene.logarithmicDepthBufferEnabled) {
28023
- src.push("vFragDepth = 1.0 + clipPos.w;");
28095
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
28096
+ src.push("vFragDepth = 1.0 + clipPos.w;");
28097
+ } else {
28098
+ src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
28099
+ src.push("clipPos.z *= clipPos.w;");
28100
+ }
28101
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
28102
+ }
28103
+ if (background) {
28104
+ src.push("clipPos.z = clipPos.w;");
28024
28105
  }
28025
28106
  src.push("gl_Position = clipPos;");
28026
28107
  if (receivesShadow) {
@@ -28074,7 +28155,8 @@ function buildFragmentDraw(mesh) {
28074
28155
  src.push("precision mediump int;");
28075
28156
  src.push("#endif");
28076
28157
 
28077
- if (scene.logarithmicDepthBufferEnabled) {
28158
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
28159
+ src.push("varying float isPerspective;");
28078
28160
  src.push("uniform float logDepthBufFC;");
28079
28161
  src.push("varying float vFragDepth;");
28080
28162
  }
@@ -29034,8 +29116,8 @@ function buildFragmentDraw(mesh) {
29034
29116
  src.push("gl_FragColor = linearToGamma(gl_FragColor, gammaFactor);");
29035
29117
  }
29036
29118
 
29037
- if (scene.logarithmicDepthBufferEnabled) {
29038
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
29119
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
29120
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
29039
29121
  }
29040
29122
 
29041
29123
  src.push("}");
@@ -29121,9 +29203,13 @@ DrawRenderer.prototype.drawMesh = function (frameCtx, mesh) {
29121
29203
  const geometryState = mesh._geometry._state;
29122
29204
  const camera = scene.camera;
29123
29205
  const rtcCenter = mesh.rtcCenter;
29206
+ const background = meshState.background;
29124
29207
 
29125
29208
  if (frameCtx.lastProgramId !== this._program.id) {
29126
29209
  frameCtx.lastProgramId = this._program.id;
29210
+ if (background) {
29211
+ gl.depthFunc(gl.LEQUAL);
29212
+ }
29127
29213
  this._bindProgram(frameCtx);
29128
29214
  }
29129
29215
 
@@ -29640,6 +29726,10 @@ DrawRenderer.prototype.drawMesh = function (frameCtx, mesh) {
29640
29726
  gl.drawArrays(gl.TRIANGLES, 0, geometryState.positions.numItems);
29641
29727
  frameCtx.drawArrays++;
29642
29728
  }
29729
+
29730
+ if (background) {
29731
+ gl.depthFunc(gl.LESS);
29732
+ }
29643
29733
  };
29644
29734
 
29645
29735
  DrawRenderer.prototype._allocate = function (mesh) {
@@ -30051,6 +30141,10 @@ function buildVertex$5(mesh) {
30051
30141
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30052
30142
  src.push("varying float vFragDepth;");
30053
30143
  }
30144
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
30145
+ src.push(" return (m[2][3] == - 1.0);");
30146
+ src.push("}");
30147
+ src.push("varying float isPerspective;");
30054
30148
  }
30055
30149
  if (clipping) {
30056
30150
  src.push("varying vec4 vWorldPosition;");
@@ -30190,6 +30284,7 @@ function buildVertex$5(mesh) {
30190
30284
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
30191
30285
  src.push("clipPos.z *= clipPos.w;");
30192
30286
  }
30287
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
30193
30288
  }
30194
30289
  src.push("gl_Position = clipPos;");
30195
30290
  src.push("}");
@@ -30227,6 +30322,7 @@ function buildFragment$5(mesh) {
30227
30322
  src.push("#endif");
30228
30323
 
30229
30324
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30325
+ src.push("varying float isPerspective;");
30230
30326
  src.push("uniform float logDepthBufFC;");
30231
30327
  src.push("varying float vFragDepth;");
30232
30328
  }
@@ -30267,7 +30363,7 @@ function buildFragment$5(mesh) {
30267
30363
  src.push("}");
30268
30364
  }
30269
30365
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30270
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
30366
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
30271
30367
  }
30272
30368
  if (gammaOutput) {
30273
30369
  src.push("gl_FragColor = linearToGamma(vColor, gammaFactor);");
@@ -30578,6 +30674,10 @@ function buildVertex$4(mesh) {
30578
30674
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30579
30675
  src.push("varying float vFragDepth;");
30580
30676
  }
30677
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
30678
+ src.push(" return (m[2][3] == - 1.0);");
30679
+ src.push("}");
30680
+ src.push("varying float isPerspective;");
30581
30681
  }
30582
30682
  if (clipping) {
30583
30683
  src.push("varying vec4 vWorldPosition;");
@@ -30634,6 +30734,7 @@ function buildVertex$4(mesh) {
30634
30734
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
30635
30735
  src.push("clipPos.z *= clipPos.w;");
30636
30736
  }
30737
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
30637
30738
  }
30638
30739
  src.push("gl_Position = clipPos;");
30639
30740
  src.push("}");
@@ -30660,6 +30761,7 @@ function buildFragment$4(mesh) {
30660
30761
  src.push("precision mediump int;");
30661
30762
  src.push("#endif");
30662
30763
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30764
+ src.push("varying float isPerspective;");
30663
30765
  src.push("uniform float logDepthBufFC;");
30664
30766
  src.push("varying float vFragDepth;");
30665
30767
  }
@@ -30692,7 +30794,7 @@ function buildFragment$4(mesh) {
30692
30794
  src.push("}");
30693
30795
  }
30694
30796
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30695
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
30797
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
30696
30798
  }
30697
30799
  if (gammaOutput) {
30698
30800
  src.push("gl_FragColor = linearToGamma(vColor, gammaFactor);");
@@ -30986,6 +31088,10 @@ function buildVertex$3(mesh) {
30986
31088
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30987
31089
  src.push("varying float vFragDepth;");
30988
31090
  }
31091
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
31092
+ src.push(" return (m[2][3] == - 1.0);");
31093
+ src.push("}");
31094
+ src.push("varying float isPerspective;");
30989
31095
  }
30990
31096
  if (billboard === "spherical" || billboard === "cylindrical") {
30991
31097
  src.push("void billboard(inout mat4 mat) {");
@@ -31031,6 +31137,7 @@ function buildVertex$3(mesh) {
31031
31137
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
31032
31138
  src.push("clipPos.z *= clipPos.w;");
31033
31139
  }
31140
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
31034
31141
  }
31035
31142
  src.push("gl_Position = clipPos;");
31036
31143
  src.push("}");
@@ -31054,6 +31161,7 @@ function buildFragment$3(mesh) {
31054
31161
  src.push("precision mediump int;");
31055
31162
  src.push("#endif");
31056
31163
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31164
+ src.push("varying float isPerspective;");
31057
31165
  src.push("uniform float logDepthBufFC;");
31058
31166
  src.push("varying float vFragDepth;");
31059
31167
  }
@@ -31080,7 +31188,7 @@ function buildFragment$3(mesh) {
31080
31188
  src.push("}");
31081
31189
  }
31082
31190
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31083
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
31191
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
31084
31192
  }
31085
31193
  src.push(" gl_FragColor = pickColor; ");
31086
31194
  src.push("}");
@@ -31327,6 +31435,10 @@ function buildVertex$2(mesh) {
31327
31435
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31328
31436
  src.push("varying float vFragDepth;");
31329
31437
  }
31438
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
31439
+ src.push(" return (m[2][3] == - 1.0);");
31440
+ src.push("}");
31441
+ src.push("varying float isPerspective;");
31330
31442
  }
31331
31443
  src.push("varying vec4 vColor;");
31332
31444
  if (quantizedGeometry) {
@@ -31352,6 +31464,7 @@ function buildVertex$2(mesh) {
31352
31464
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
31353
31465
  src.push("clipPos.z *= clipPos.w;");
31354
31466
  }
31467
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
31355
31468
  }
31356
31469
  src.push("gl_Position = clipPos;");
31357
31470
  src.push("}");
@@ -31376,6 +31489,7 @@ function buildFragment$2(mesh) {
31376
31489
  src.push("#endif");
31377
31490
  src.push("varying vec4 vColor;");
31378
31491
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31492
+ src.push("varying float isPerspective;");
31379
31493
  src.push("uniform float logDepthBufFC;");
31380
31494
  src.push("varying float vFragDepth;");
31381
31495
  }
@@ -31401,7 +31515,7 @@ function buildFragment$2(mesh) {
31401
31515
  src.push("}");
31402
31516
  }
31403
31517
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31404
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
31518
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
31405
31519
  }
31406
31520
  src.push(" gl_FragColor = vColor;");
31407
31521
  src.push("}");
@@ -31625,6 +31739,10 @@ function buildVertex$1(mesh) {
31625
31739
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31626
31740
  src.push("varying float vFragDepth;");
31627
31741
  }
31742
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
31743
+ src.push(" return (m[2][3] == - 1.0);");
31744
+ src.push("}");
31745
+ src.push("varying float isPerspective;");
31628
31746
  }
31629
31747
  if (billboard === "spherical" || billboard === "cylindrical") {
31630
31748
  src.push("void billboard(inout mat4 mat) {");
@@ -31670,6 +31788,7 @@ function buildVertex$1(mesh) {
31670
31788
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
31671
31789
  src.push("clipPos.z *= clipPos.w;");
31672
31790
  }
31791
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
31673
31792
  }
31674
31793
  src.push("gl_Position = clipPos;");
31675
31794
  src.push("}");
@@ -31698,6 +31817,7 @@ function buildFragment$1(mesh) {
31698
31817
  src.push("#endif");
31699
31818
 
31700
31819
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31820
+ src.push("varying float isPerspective;");
31701
31821
  src.push("uniform float logDepthBufFC;");
31702
31822
  src.push("varying float vFragDepth;");
31703
31823
  }
@@ -31729,7 +31849,7 @@ function buildFragment$1(mesh) {
31729
31849
  src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); ");
31730
31850
 
31731
31851
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31732
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
31852
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
31733
31853
  }
31734
31854
 
31735
31855
  src.push("}");
@@ -32629,6 +32749,7 @@ class Mesh extends Component {
32629
32749
  * @param {Number[]} [cfg.rotation=[0,0,0]] Local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
32630
32750
  * @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Local modelling transform matrix. Overrides the position, scale and rotation parameters.
32631
32751
  * @param {Number[]} [cfg.offset=[0,0,0]] World-space 3D translation offset. Translates the Mesh in World space, after modelling transforms.
32752
+ * @param {Boolean} [cfg.occluder=true] Indicates if the Mesh is able to occlude {@link Marker}s.
32632
32753
  * @param {Boolean} [cfg.visible=true] Indicates if the Mesh is initially visible.
32633
32754
  * @param {Boolean} [cfg.culled=false] Indicates if the Mesh is initially culled from view.
32634
32755
  * @param {Boolean} [cfg.pickable=true] Indicates if the Mesh is initially pickable.
@@ -32640,6 +32761,7 @@ class Mesh extends Component {
32640
32761
  * @param {Boolean} [cfg.highlighted=false] Indicates if the Mesh is initially highlighted.
32641
32762
  * @param {Boolean} [cfg.selected=false] Indicates if the Mesh is initially selected.
32642
32763
  * @param {Boolean} [cfg.edges=false] Indicates if the Mesh's edges are initially emphasized.
32764
+ * @param {Boolean} [cfg.background=false] Indicates if the Mesh should act as background, e.g., it can be used for a skybox.
32643
32765
  * @param {Number[]} [cfg.colorize=[1.0,1.0,1.0]] Mesh's initial RGB colorize color, multiplies by the rendered fragment colors.
32644
32766
  * @param {Number} [cfg.opacity=1.0] Mesh's initial opacity factor, multiplies by the rendered fragment alpha.
32645
32767
  * @param {String} [cfg.billboard="none"] Mesh's billboarding behaviour. Options are "none" for no billboarding, "spherical" to always directly face {@link Camera.eye}, rotating both vertically and horizontally, or "cylindrical" to face the {@link Camera#eye} while rotating only about its vertically axis (use that mode for things like trees on a landscape).
@@ -32671,6 +32793,7 @@ class Mesh extends Component {
32671
32793
  pickable: null,
32672
32794
  clippable: null,
32673
32795
  collidable: null,
32796
+ occluder: (cfg.occluder !== false),
32674
32797
  castsShadow: null,
32675
32798
  receivesShadow: null,
32676
32799
  xrayed: false,
@@ -32678,6 +32801,7 @@ class Mesh extends Component {
32678
32801
  selected: false,
32679
32802
  edges: false,
32680
32803
  stationary: !!cfg.stationary,
32804
+ background: !!cfg.background,
32681
32805
  billboard: this._checkBillboard(cfg.billboard),
32682
32806
  layer: null,
32683
32807
  colorize: null,
@@ -32841,11 +32965,13 @@ class Mesh extends Component {
32841
32965
  this._putPickRenderers();
32842
32966
  this._pickMeshRenderer = PickMeshRenderer.get(this);
32843
32967
  }
32844
- const occlusionHash = this._makeOcclusionHash();
32845
- if (this._state.occlusionHash !== occlusionHash) {
32846
- this._state.occlusionHash = occlusionHash;
32847
- this._putOcclusionRenderer();
32848
- this._occlusionRenderer = OcclusionRenderer.get(this);
32968
+ if (this._state.occluder) {
32969
+ const occlusionHash = this._makeOcclusionHash();
32970
+ if (this._state.occlusionHash !== occlusionHash) {
32971
+ this._state.occlusionHash = occlusionHash;
32972
+ this._putOcclusionRenderer();
32973
+ this._occlusionRenderer = OcclusionRenderer.get(this);
32974
+ }
32849
32975
  }
32850
32976
  }
32851
32977
 
@@ -34252,7 +34378,7 @@ class Mesh extends Component {
34252
34378
 
34253
34379
  /** @private */
34254
34380
  drawOcclusion(frameCtx) {
34255
- if (this._occlusionRenderer || (this._occlusionRenderer = OcclusionRenderer.get(this))) {
34381
+ if (this._state.occluder && this._occlusionRenderer || (this._occlusionRenderer = OcclusionRenderer.get(this))) {
34256
34382
  this._occlusionRenderer.drawMesh(frameCtx, this);
34257
34383
  }
34258
34384
  }
@@ -36935,8 +37061,8 @@ class AxisGizmoPlugin extends Plugin {
36935
37061
  pickable: false,
36936
37062
  collidable: false,
36937
37063
  visible: cfg.visible !== false,
36938
- position: [-5, 0, 0],
36939
- rotation: [0, 0, 90]
37064
+ position: [5, 0, 0],
37065
+ rotation: [0, 0, -90]
36940
37066
  }),
36941
37067
 
36942
37068
  new Mesh(axisGizmoScene, { // Shaft
@@ -36945,7 +37071,7 @@ class AxisGizmoPlugin extends Plugin {
36945
37071
  pickable: false,
36946
37072
  collidable: false,
36947
37073
  visible: cfg.visible !== false,
36948
- position: [-2, 0, 0],
37074
+ position: [2, 0, 0],
36949
37075
  rotation: [0, 0, 90]
36950
37076
  }),
36951
37077
 
@@ -36955,7 +37081,7 @@ class AxisGizmoPlugin extends Plugin {
36955
37081
  pickable: false,
36956
37082
  collidable: false,
36957
37083
  visible: cfg.visible !== false,
36958
- position: [-7, 0, 0],
37084
+ position: [7, 0, 0],
36959
37085
  billboard: "spherical"
36960
37086
  }),
36961
37087
 
@@ -39768,8 +39894,8 @@ class PerformanceMesh {
39768
39894
  }
39769
39895
 
39770
39896
  /** @private */
39771
- precisionRayPickSurface(worldRayOrigin, worldRayDir, worldSurfacePos) {
39772
- return this._layer.precisionRayPickSurface ? this._layer.precisionRayPickSurface(this._portionId, worldRayOrigin, worldRayDir, worldSurfacePos) : false;
39897
+ precisionRayPickSurface(worldRayOrigin, worldRayDir, worldSurfacePos, worldSurfaceNormal) {
39898
+ return this._layer.precisionRayPickSurface ? this._layer.precisionRayPickSurface(this._portionId, worldRayOrigin, worldRayDir, worldSurfacePos, worldSurfaceNormal) : false;
39773
39899
  }
39774
39900
 
39775
39901
  /** @private */
@@ -40187,6 +40313,10 @@ class TrianglesBatchingColorRenderer {
40187
40313
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40188
40314
  src.push("varying float vFragDepth;");
40189
40315
  }
40316
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
40317
+ src.push(" return (m[2][3] == - 1.0);");
40318
+ src.push("}");
40319
+ src.push("varying float isPerspective;");
40190
40320
  }
40191
40321
 
40192
40322
  src.push("uniform vec4 lightAmbient;");
@@ -40288,6 +40418,7 @@ class TrianglesBatchingColorRenderer {
40288
40418
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
40289
40419
  src.push("clipPos.z *= clipPos.w;");
40290
40420
  }
40421
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
40291
40422
  }
40292
40423
  if (clipping) {
40293
40424
  src.push("vWorldPosition = worldPosition;");
@@ -40318,6 +40449,7 @@ class TrianglesBatchingColorRenderer {
40318
40449
  src.push("#endif");
40319
40450
 
40320
40451
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40452
+ src.push("varying float isPerspective;");
40321
40453
  src.push("uniform float logDepthBufFC;");
40322
40454
  src.push("varying float vFragDepth;");
40323
40455
  }
@@ -40363,7 +40495,7 @@ class TrianglesBatchingColorRenderer {
40363
40495
  }
40364
40496
 
40365
40497
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40366
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
40498
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
40367
40499
  }
40368
40500
 
40369
40501
  if (this._withSAO) {
@@ -40638,7 +40770,6 @@ class TrianglesBatchingFlatColorRenderer {
40638
40770
  _buildVertexShader() {
40639
40771
  const scene = this._scene;
40640
40772
  const sectionPlanesState = scene._sectionPlanesState;
40641
- scene._lightsState;
40642
40773
  const clipping = sectionPlanesState.sectionPlanes.length > 0;
40643
40774
  const src = [];
40644
40775
 
@@ -40670,6 +40801,10 @@ class TrianglesBatchingFlatColorRenderer {
40670
40801
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40671
40802
  src.push("varying float vFragDepth;");
40672
40803
  }
40804
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
40805
+ src.push(" return (m[2][3] == - 1.0);");
40806
+ src.push("}");
40807
+ src.push("varying float isPerspective;");
40673
40808
  }
40674
40809
 
40675
40810
  if (clipping) {
@@ -40705,6 +40840,7 @@ class TrianglesBatchingFlatColorRenderer {
40705
40840
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
40706
40841
  src.push("clipPos.z *= clipPos.w;");
40707
40842
  }
40843
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
40708
40844
  }
40709
40845
  if (clipping) {
40710
40846
  src.push("vWorldPosition = worldPosition;");
@@ -40737,6 +40873,7 @@ class TrianglesBatchingFlatColorRenderer {
40737
40873
  src.push("#endif");
40738
40874
 
40739
40875
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40876
+ src.push("varying float isPerspective;");
40740
40877
  src.push("uniform float logDepthBufFC;");
40741
40878
  src.push("varying float vFragDepth;");
40742
40879
  }
@@ -40863,7 +41000,7 @@ class TrianglesBatchingFlatColorRenderer {
40863
41000
  }
40864
41001
 
40865
41002
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40866
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41003
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
40867
41004
  }
40868
41005
 
40869
41006
  src.push("}");
@@ -41093,6 +41230,10 @@ class TrianglesBatchingSilhouetteRenderer {
41093
41230
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41094
41231
  src.push("varying float vFragDepth;");
41095
41232
  }
41233
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
41234
+ src.push(" return (m[2][3] == - 1.0);");
41235
+ src.push("}");
41236
+ src.push("varying float isPerspective;");
41096
41237
  }
41097
41238
 
41098
41239
  if (clipping) {
@@ -41126,6 +41267,7 @@ class TrianglesBatchingSilhouetteRenderer {
41126
41267
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
41127
41268
  src.push("clipPos.z *= clipPos.w;");
41128
41269
  }
41270
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
41129
41271
  }
41130
41272
  src.push("gl_Position = clipPos;");
41131
41273
  src.push("}");
@@ -41152,6 +41294,7 @@ class TrianglesBatchingSilhouetteRenderer {
41152
41294
  src.push("precision mediump int;");
41153
41295
  src.push("#endif");
41154
41296
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41297
+ src.push("varying float isPerspective;");
41155
41298
  src.push("uniform float logDepthBufFC;");
41156
41299
  src.push("varying float vFragDepth;");
41157
41300
  }
@@ -41179,7 +41322,7 @@ class TrianglesBatchingSilhouetteRenderer {
41179
41322
  src.push("}");
41180
41323
  }
41181
41324
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41182
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41325
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
41183
41326
  }
41184
41327
  src.push("gl_FragColor = color;");
41185
41328
  src.push("}");
@@ -41405,6 +41548,10 @@ class TrianglesBatchingEdgesRenderer {
41405
41548
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41406
41549
  src.push("varying float vFragDepth;");
41407
41550
  }
41551
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
41552
+ src.push(" return (m[2][3] == - 1.0);");
41553
+ src.push("}");
41554
+ src.push("varying float isPerspective;");
41408
41555
  }
41409
41556
 
41410
41557
  if (clipping) {
@@ -41442,6 +41589,7 @@ class TrianglesBatchingEdgesRenderer {
41442
41589
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
41443
41590
  src.push("clipPos.z *= clipPos.w;");
41444
41591
  }
41592
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
41445
41593
  }
41446
41594
  src.push("gl_Position = clipPos;");
41447
41595
  src.push("vColor = vec4(color.r, color.g, color.b, color.a);");
@@ -41467,6 +41615,7 @@ class TrianglesBatchingEdgesRenderer {
41467
41615
  src.push("precision mediump int;");
41468
41616
  src.push("#endif");
41469
41617
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41618
+ src.push("varying float isPerspective;");
41470
41619
  src.push("uniform float logDepthBufFC;");
41471
41620
  src.push("varying float vFragDepth;");
41472
41621
  }
@@ -41494,7 +41643,7 @@ class TrianglesBatchingEdgesRenderer {
41494
41643
  src.push("}");
41495
41644
  }
41496
41645
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41497
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41646
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
41498
41647
  }
41499
41648
  src.push("gl_FragColor = vColor;");
41500
41649
  src.push("}");
@@ -41698,6 +41847,10 @@ class TrianglesBatchingEdgesColorRenderer {
41698
41847
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41699
41848
  src.push("varying float vFragDepth;");
41700
41849
  }
41850
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
41851
+ src.push(" return (m[2][3] == - 1.0);");
41852
+ src.push("}");
41853
+ src.push("varying float isPerspective;");
41701
41854
  }
41702
41855
 
41703
41856
  if (clipping) {
@@ -41735,6 +41888,7 @@ class TrianglesBatchingEdgesColorRenderer {
41735
41888
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
41736
41889
  src.push("clipPos.z *= clipPos.w;");
41737
41890
  }
41891
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
41738
41892
  }
41739
41893
  src.push("gl_Position = clipPos;");
41740
41894
  //src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
@@ -41761,6 +41915,7 @@ class TrianglesBatchingEdgesColorRenderer {
41761
41915
  src.push("precision mediump int;");
41762
41916
  src.push("#endif");
41763
41917
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41918
+ src.push("varying float isPerspective;");
41764
41919
  src.push("uniform float logDepthBufFC;");
41765
41920
  src.push("varying float vFragDepth;");
41766
41921
  }
@@ -41788,7 +41943,7 @@ class TrianglesBatchingEdgesColorRenderer {
41788
41943
  src.push("}");
41789
41944
  }
41790
41945
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41791
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41946
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
41792
41947
  }
41793
41948
  src.push("gl_FragColor = vColor;");
41794
41949
  src.push("}");
@@ -42000,6 +42155,10 @@ class TrianglesBatchingPickMeshRenderer {
42000
42155
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42001
42156
  src.push("varying float vFragDepth;");
42002
42157
  }
42158
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
42159
+ src.push(" return (m[2][3] == - 1.0);");
42160
+ src.push("}");
42161
+ src.push("varying float isPerspective;");
42003
42162
  }
42004
42163
 
42005
42164
  if (clipping) {
@@ -42036,6 +42195,7 @@ class TrianglesBatchingPickMeshRenderer {
42036
42195
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42037
42196
  src.push("clipPos.z *= clipPos.w;");
42038
42197
  }
42198
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42039
42199
  }
42040
42200
  src.push("gl_Position = clipPos;");
42041
42201
  src.push(" }");
@@ -42060,6 +42220,7 @@ class TrianglesBatchingPickMeshRenderer {
42060
42220
  src.push("precision mediump int;");
42061
42221
  src.push("#endif");
42062
42222
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42223
+ src.push("varying float isPerspective;");
42063
42224
  src.push("uniform float logDepthBufFC;");
42064
42225
  src.push("varying float vFragDepth;");
42065
42226
  }
@@ -42087,7 +42248,7 @@ class TrianglesBatchingPickMeshRenderer {
42087
42248
  src.push(" }");
42088
42249
  }
42089
42250
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42090
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
42251
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42091
42252
  }
42092
42253
  src.push(" gl_FragColor = vPickColor; ");
42093
42254
  src.push("}");
@@ -42299,6 +42460,10 @@ class TrianglesBatchingPickDepthRenderer {
42299
42460
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42300
42461
  src.push("varying float vFragDepth;");
42301
42462
  }
42463
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
42464
+ src.push(" return (m[2][3] == - 1.0);");
42465
+ src.push("}");
42466
+ src.push("varying float isPerspective;");
42302
42467
  }
42303
42468
 
42304
42469
  if (clipping) {
@@ -42332,6 +42497,7 @@ class TrianglesBatchingPickDepthRenderer {
42332
42497
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42333
42498
  src.push("clipPos.z *= clipPos.w;");
42334
42499
  }
42500
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42335
42501
  }
42336
42502
  src.push("gl_Position = clipPos;");
42337
42503
  src.push(" }");
@@ -42361,6 +42527,7 @@ class TrianglesBatchingPickDepthRenderer {
42361
42527
  src.push("#endif");
42362
42528
 
42363
42529
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42530
+ src.push("varying float isPerspective;");
42364
42531
  src.push("uniform float logDepthBufFC;");
42365
42532
  src.push("varying float vFragDepth;");
42366
42533
  }
@@ -42399,7 +42566,7 @@ class TrianglesBatchingPickDepthRenderer {
42399
42566
  src.push(" }");
42400
42567
  }
42401
42568
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42402
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
42569
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42403
42570
  }
42404
42571
  src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");
42405
42572
  src.push(" gl_FragColor = packDepth(zNormalizedDepth); "); // Must be linear depth
@@ -42605,6 +42772,10 @@ class TrianglesBatchingPickNormalsRenderer {
42605
42772
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42606
42773
  src.push("varying float vFragDepth;");
42607
42774
  }
42775
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
42776
+ src.push(" return (m[2][3] == - 1.0);");
42777
+ src.push("}");
42778
+ src.push("varying float isPerspective;");
42608
42779
  }
42609
42780
  src.push("vec3 octDecode(vec2 oct) {");
42610
42781
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -42643,6 +42814,7 @@ class TrianglesBatchingPickNormalsRenderer {
42643
42814
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42644
42815
  src.push("clipPos.z *= clipPos.w;");
42645
42816
  }
42817
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42646
42818
  }
42647
42819
  src.push("gl_Position = clipPos;");
42648
42820
  src.push(" }");
@@ -42667,6 +42839,7 @@ class TrianglesBatchingPickNormalsRenderer {
42667
42839
  src.push("precision mediump int;");
42668
42840
  src.push("#endif");
42669
42841
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42842
+ src.push("varying float isPerspective;");
42670
42843
  src.push("uniform float logDepthBufFC;");
42671
42844
  src.push("varying float vFragDepth;");
42672
42845
  }
@@ -42694,7 +42867,7 @@ class TrianglesBatchingPickNormalsRenderer {
42694
42867
  src.push(" }");
42695
42868
  }
42696
42869
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42697
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
42870
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42698
42871
  }
42699
42872
  src.push(" gl_FragColor = vec4((vWorldNormal * 0.5) + 0.5, 1.0);");
42700
42873
  src.push("}");
@@ -42896,6 +43069,10 @@ class TrianglesBatchingOcclusionRenderer {
42896
43069
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42897
43070
  src.push("varying float vFragDepth;");
42898
43071
  }
43072
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
43073
+ src.push(" return (m[2][3] == - 1.0);");
43074
+ src.push("}");
43075
+ src.push("varying float isPerspective;");
42899
43076
  }
42900
43077
  if (clipping) {
42901
43078
  src.push("varying vec4 vWorldPosition;");
@@ -42929,6 +43106,7 @@ class TrianglesBatchingOcclusionRenderer {
42929
43106
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42930
43107
  src.push("clipPos.z *= clipPos.w;");
42931
43108
  }
43109
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42932
43110
  }
42933
43111
  src.push("gl_Position = clipPos;");
42934
43112
  src.push(" }");
@@ -42953,6 +43131,7 @@ class TrianglesBatchingOcclusionRenderer {
42953
43131
  src.push("precision mediump int;");
42954
43132
  src.push("#endif");
42955
43133
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43134
+ src.push("varying float isPerspective;");
42956
43135
  src.push("uniform float logDepthBufFC;");
42957
43136
  src.push("varying float vFragDepth;");
42958
43137
  }
@@ -42979,7 +43158,7 @@ class TrianglesBatchingOcclusionRenderer {
42979
43158
  src.push(" }");
42980
43159
  }
42981
43160
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42982
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
43161
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42983
43162
  }
42984
43163
  src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); "); // Occluders are blue
42985
43164
  src.push("}");
@@ -43174,6 +43353,10 @@ class TrianglesBatchingDepthRenderer {
43174
43353
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43175
43354
  src.push("varying float vFragDepth;");
43176
43355
  }
43356
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
43357
+ src.push(" return (m[2][3] == - 1.0);");
43358
+ src.push("}");
43359
+ src.push("varying float isPerspective;");
43177
43360
  }
43178
43361
  if (clipping) {
43179
43362
  src.push("varying vec4 vWorldPosition;");
@@ -43205,6 +43388,7 @@ class TrianglesBatchingDepthRenderer {
43205
43388
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
43206
43389
  src.push("clipPos.z *= clipPos.w;");
43207
43390
  }
43391
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
43208
43392
  }
43209
43393
  src.push("gl_Position = clipPos;");
43210
43394
  src.push("vHighPrecisionZW = gl_Position.zw;");
@@ -43225,6 +43409,7 @@ class TrianglesBatchingDepthRenderer {
43225
43409
  src.push("precision highp float;");
43226
43410
  src.push("precision highp int;");
43227
43411
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43412
+ src.push("varying float isPerspective;");
43228
43413
  src.push("uniform float logDepthBufFC;");
43229
43414
  src.push("varying float vFragDepth;");
43230
43415
  }
@@ -43263,7 +43448,7 @@ class TrianglesBatchingDepthRenderer {
43263
43448
  src.push(" }");
43264
43449
  }
43265
43450
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43266
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
43451
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
43267
43452
  }
43268
43453
  src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");
43269
43454
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["WEBGL_depth_texture"]) {
@@ -43474,6 +43659,10 @@ class TrianglesBatchingNormalsRenderer {
43474
43659
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43475
43660
  src.push("varying float vFragDepth;");
43476
43661
  }
43662
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
43663
+ src.push(" return (m[2][3] == - 1.0);");
43664
+ src.push("}");
43665
+ src.push("varying float isPerspective;");
43477
43666
  }
43478
43667
  src.push("vec3 octDecode(vec2 oct) {");
43479
43668
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -43516,6 +43705,7 @@ class TrianglesBatchingNormalsRenderer {
43516
43705
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
43517
43706
  src.push("clipPos.z *= clipPos.w;");
43518
43707
  }
43708
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
43519
43709
  }
43520
43710
  src.push("gl_Position = clipPos;");
43521
43711
  src.push(" }");
@@ -43543,6 +43733,7 @@ class TrianglesBatchingNormalsRenderer {
43543
43733
  src.push("#endif");
43544
43734
 
43545
43735
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43736
+ src.push("varying float isPerspective;");
43546
43737
  src.push("uniform float logDepthBufFC;");
43547
43738
  src.push("varying float vFragDepth;");
43548
43739
  }
@@ -43574,7 +43765,7 @@ class TrianglesBatchingNormalsRenderer {
43574
43765
  src.push(" }");
43575
43766
  }
43576
43767
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43577
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
43768
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
43578
43769
  }
43579
43770
  src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");
43580
43771
  src.push("}");
@@ -44163,6 +44354,10 @@ class TrianglesBatchingColorQualityRenderer {
44163
44354
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44164
44355
  src.push("varying float vFragDepth;");
44165
44356
  }
44357
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
44358
+ src.push(" return (m[2][3] == - 1.0);");
44359
+ src.push("}");
44360
+ src.push("varying float isPerspective;");
44166
44361
  }
44167
44362
 
44168
44363
  src.push("vec3 octDecode(vec2 oct) {");
@@ -44210,6 +44405,7 @@ class TrianglesBatchingColorQualityRenderer {
44210
44405
 
44211
44406
  src.push("vec4 clipPos = projMatrix * viewPosition;");
44212
44407
  if (scene.logarithmicDepthBufferEnabled) {
44408
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
44213
44409
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44214
44410
  src.push("vFragDepth = 1.0 + clipPos.w;");
44215
44411
  } else {
@@ -44267,6 +44463,7 @@ class TrianglesBatchingColorQualityRenderer {
44267
44463
  src.push("#endif");
44268
44464
 
44269
44465
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44466
+ src.push("varying float isPerspective;");
44270
44467
  src.push("uniform float logDepthBufFC;");
44271
44468
  src.push("varying float vFragDepth;");
44272
44469
  }
@@ -44614,7 +44811,7 @@ class TrianglesBatchingColorQualityRenderer {
44614
44811
  src.push("gl_FragColor = fragColor;");
44615
44812
 
44616
44813
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44617
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
44814
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
44618
44815
  }
44619
44816
 
44620
44817
  src.push("}");
@@ -44811,6 +45008,10 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44811
45008
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44812
45009
  src.push("varying float vFragDepth;");
44813
45010
  }
45011
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
45012
+ src.push(" return (m[2][3] == - 1.0);");
45013
+ src.push("}");
45014
+ src.push("varying float isPerspective;");
44814
45015
  }
44815
45016
  src.push("varying vec4 vWorldPosition;");
44816
45017
  if (clipping) {
@@ -44839,6 +45040,7 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44839
45040
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
44840
45041
  src.push("clipPos.z *= clipPos.w;");
44841
45042
  }
45043
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
44842
45044
  }
44843
45045
  src.push("gl_Position = clipPos;");
44844
45046
  src.push(" }");
@@ -44864,6 +45066,7 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44864
45066
  src.push("precision mediump int;");
44865
45067
  src.push("#endif");
44866
45068
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
45069
+ src.push("varying float isPerspective;");
44867
45070
  src.push("uniform float logDepthBufFC;");
44868
45071
  src.push("varying float vFragDepth;");
44869
45072
  }
@@ -44890,7 +45093,7 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44890
45093
  src.push(" }");
44891
45094
  }
44892
45095
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44893
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
45096
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
44894
45097
  }
44895
45098
  src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");
44896
45099
  src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");
@@ -45425,6 +45628,7 @@ const tempVec3c$4 = math.vec3();
45425
45628
  const tempVec3d$2 = math.vec3();
45426
45629
  const tempVec3e$1 = math.vec3();
45427
45630
  const tempVec3f$1 = math.vec3();
45631
+ const tempVec3g$1 = math.vec3();
45428
45632
 
45429
45633
  /**
45430
45634
  * @private
@@ -46449,7 +46653,7 @@ class TrianglesBatchingLayer {
46449
46653
 
46450
46654
  //------------------------------------------------------------------------------------------------
46451
46655
 
46452
- precisionRayPickSurface(portionId, worldRayOrigin, worldRayDir, worldSurfacePos) {
46656
+ precisionRayPickSurface(portionId, worldRayOrigin, worldRayDir, worldSurfacePos, worldNormal) {
46453
46657
 
46454
46658
  if (!this.model.scene.pickSurfacePrecisionEnabled) {
46455
46659
  return false;
@@ -46484,9 +46688,13 @@ class TrianglesBatchingLayer {
46484
46688
  const b = tempVec3e$1;
46485
46689
  const c = tempVec3f$1;
46486
46690
 
46691
+ let gotIntersect = false;
46692
+ let closestDist = 0;
46693
+ const closestIntersectPos = tempVec3g$1;
46694
+
46487
46695
  for (let i = 0, len = indices.length; i < len; i += 3) {
46488
46696
 
46489
- const ia = indices[i + 0] * 3;
46697
+ const ia = indices[i] * 3;
46490
46698
  const ib = indices[i + 1] * 3;
46491
46699
  const ic = indices[i + 2] * 3;
46492
46700
 
@@ -46506,23 +46714,37 @@ class TrianglesBatchingLayer {
46506
46714
  math.decompressPosition(b, state.positionsDecodeMatrix);
46507
46715
  math.decompressPosition(c, state.positionsDecodeMatrix);
46508
46716
 
46509
- if (math.rayTriangleIntersect(rtcRayOrigin, rtcRayDir, a, b, c, worldSurfacePos)) {
46717
+ if (math.rayTriangleIntersect(rtcRayOrigin, rtcRayDir, a, b, c, closestIntersectPos)) {
46510
46718
 
46511
- math.transformPoint3(this.model.worldMatrix, worldSurfacePos, worldSurfacePos);
46719
+ math.transformPoint3(this.model.worldMatrix, closestIntersectPos, closestIntersectPos);
46512
46720
 
46513
46721
  if (offset) {
46514
- math.addVec3(worldSurfacePos, offset);
46722
+ math.addVec3(closestIntersectPos, offset);
46515
46723
  }
46516
46724
 
46517
46725
  if (rtcCenter) {
46518
- math.addVec3(worldSurfacePos, rtcCenter);
46726
+ math.addVec3(closestIntersectPos, rtcCenter);
46519
46727
  }
46520
46728
 
46521
- return true;
46729
+ const dist = Math.abs(math.lenVec3(math.subVec3(closestIntersectPos, worldRayOrigin, [])));
46730
+
46731
+ if (!gotIntersect || dist > closestDist) {
46732
+ closestDist = dist;
46733
+ worldSurfacePos.set(closestIntersectPos);
46734
+ if (worldNormal) { // Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
46735
+ math.triangleNormal(a, b, c, worldNormal);
46736
+ }
46737
+ gotIntersect = true;
46738
+ }
46522
46739
  }
46523
46740
  }
46524
46741
 
46525
- return false;
46742
+ if (gotIntersect && worldNormal) {
46743
+ math.transformVec3(this.model.worldNormalMatrix, worldNormal, worldNormal);
46744
+ math.normalizeVec3(worldNormal);
46745
+ }
46746
+
46747
+ return gotIntersect;
46526
46748
  }
46527
46749
 
46528
46750
  // ---------
@@ -46909,6 +47131,10 @@ class TrianglesInstancingColorRenderer {
46909
47131
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
46910
47132
  src.push("varying float vFragDepth;");
46911
47133
  }
47134
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
47135
+ src.push(" return (m[2][3] == - 1.0);");
47136
+ src.push("}");
47137
+ src.push("varying float isPerspective;");
46912
47138
  }
46913
47139
 
46914
47140
  src.push("uniform vec4 lightAmbient;");
@@ -47012,6 +47238,7 @@ class TrianglesInstancingColorRenderer {
47012
47238
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
47013
47239
  src.push("clipPos.z *= clipPos.w;");
47014
47240
  }
47241
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
47015
47242
  }
47016
47243
 
47017
47244
  if (clipping) {
@@ -47043,6 +47270,7 @@ class TrianglesInstancingColorRenderer {
47043
47270
  src.push("#endif");
47044
47271
  if (scene.logarithmicDepthBufferEnabled) {
47045
47272
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47273
+ src.push("varying float isPerspective;");
47046
47274
  src.push("uniform float logDepthBufFC;");
47047
47275
  src.push("varying float vFragDepth;");
47048
47276
  }
@@ -47089,7 +47317,7 @@ class TrianglesInstancingColorRenderer {
47089
47317
  }
47090
47318
 
47091
47319
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47092
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
47320
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
47093
47321
  }
47094
47322
 
47095
47323
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -47424,6 +47652,10 @@ class TrianglesInstancingFlatColorRenderer {
47424
47652
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47425
47653
  src.push("varying float vFragDepth;");
47426
47654
  }
47655
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
47656
+ src.push(" return (m[2][3] == - 1.0);");
47657
+ src.push("}");
47658
+ src.push("varying float isPerspective;");
47427
47659
  }
47428
47660
 
47429
47661
  if (clipping) {
@@ -47462,6 +47694,7 @@ class TrianglesInstancingFlatColorRenderer {
47462
47694
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
47463
47695
  src.push("clipPos.z *= clipPos.w;");
47464
47696
  }
47697
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
47465
47698
  }
47466
47699
 
47467
47700
  if (clipping) {
@@ -47497,6 +47730,7 @@ class TrianglesInstancingFlatColorRenderer {
47497
47730
  src.push("#endif");
47498
47731
  if (scene.logarithmicDepthBufferEnabled) {
47499
47732
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47733
+ src.push("varying float isPerspective;");
47500
47734
  src.push("uniform float logDepthBufFC;");
47501
47735
  src.push("varying float vFragDepth;");
47502
47736
  }
@@ -47623,7 +47857,7 @@ class TrianglesInstancingFlatColorRenderer {
47623
47857
  }
47624
47858
 
47625
47859
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47626
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
47860
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
47627
47861
  }
47628
47862
 
47629
47863
  src.push("}");
@@ -47881,6 +48115,10 @@ class TrianglesInstancingSilhouetteRenderer {
47881
48115
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47882
48116
  src.push("varying float vFragDepth;");
47883
48117
  }
48118
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
48119
+ src.push(" return (m[2][3] == - 1.0);");
48120
+ src.push("}");
48121
+ src.push("varying float isPerspective;");
47884
48122
  }
47885
48123
 
47886
48124
  src.push("uniform vec4 color;");
@@ -47919,6 +48157,7 @@ class TrianglesInstancingSilhouetteRenderer {
47919
48157
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
47920
48158
  src.push("clipPos.z *= clipPos.w;");
47921
48159
  }
48160
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
47922
48161
  }
47923
48162
  src.push("gl_Position = clipPos;");
47924
48163
  src.push("}");
@@ -47943,6 +48182,7 @@ class TrianglesInstancingSilhouetteRenderer {
47943
48182
  src.push("precision mediump int;");
47944
48183
  src.push("#endif");
47945
48184
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48185
+ src.push("varying float isPerspective;");
47946
48186
  src.push("uniform float logDepthBufFC;");
47947
48187
  src.push("varying float vFragDepth;");
47948
48188
  }
@@ -47970,7 +48210,7 @@ class TrianglesInstancingSilhouetteRenderer {
47970
48210
  src.push("}");
47971
48211
  }
47972
48212
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47973
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
48213
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
47974
48214
  }
47975
48215
  src.push("gl_FragColor = color;");
47976
48216
  src.push("}");
@@ -48231,6 +48471,10 @@ class TrianglesInstancingEdgesRenderer {
48231
48471
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48232
48472
  src.push("varying float vFragDepth;");
48233
48473
  }
48474
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
48475
+ src.push(" return (m[2][3] == - 1.0);");
48476
+ src.push("}");
48477
+ src.push("varying float isPerspective;");
48234
48478
  }
48235
48479
 
48236
48480
  if (clipping) {
@@ -48267,6 +48511,7 @@ class TrianglesInstancingEdgesRenderer {
48267
48511
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
48268
48512
  src.push("clipPos.z *= clipPos.w;");
48269
48513
  }
48514
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
48270
48515
  }
48271
48516
  src.push("gl_Position = clipPos;");
48272
48517
  src.push("vColor = vec4(color.r, color.g, color.b, color.a);");
@@ -48292,6 +48537,7 @@ class TrianglesInstancingEdgesRenderer {
48292
48537
  src.push("precision mediump int;");
48293
48538
  src.push("#endif");
48294
48539
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48540
+ src.push("varying float isPerspective;");
48295
48541
  src.push("uniform float logDepthBufFC;");
48296
48542
  src.push("varying float vFragDepth;");
48297
48543
  }
@@ -48319,7 +48565,7 @@ class TrianglesInstancingEdgesRenderer {
48319
48565
  src.push("}");
48320
48566
  }
48321
48567
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48322
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
48568
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
48323
48569
  }
48324
48570
  src.push("gl_FragColor = vColor;");
48325
48571
  src.push("}");
@@ -48561,6 +48807,10 @@ class TrianglesInstancingEdgesColorRenderer {
48561
48807
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48562
48808
  src.push("varying float vFragDepth;");
48563
48809
  }
48810
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
48811
+ src.push(" return (m[2][3] == - 1.0);");
48812
+ src.push("}");
48813
+ src.push("varying float isPerspective;");
48564
48814
  }
48565
48815
 
48566
48816
  if (clipping) {
@@ -48597,6 +48847,7 @@ class TrianglesInstancingEdgesColorRenderer {
48597
48847
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
48598
48848
  src.push("clipPos.z *= clipPos.w;");
48599
48849
  }
48850
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
48600
48851
  }
48601
48852
  src.push("gl_Position = clipPos;");
48602
48853
  // src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
@@ -48623,6 +48874,7 @@ class TrianglesInstancingEdgesColorRenderer {
48623
48874
  src.push("precision mediump int;");
48624
48875
  src.push("#endif");
48625
48876
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48877
+ src.push("varying float isPerspective;");
48626
48878
  src.push("uniform float logDepthBufFC;");
48627
48879
  src.push("varying float vFragDepth;");
48628
48880
  }
@@ -48650,7 +48902,7 @@ class TrianglesInstancingEdgesColorRenderer {
48650
48902
  src.push("}");
48651
48903
  }
48652
48904
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48653
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
48905
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
48654
48906
  }
48655
48907
  src.push("gl_FragColor = vColor;");
48656
48908
  src.push("}");
@@ -48903,6 +49155,10 @@ class TrianglesInstancingPickMeshRenderer {
48903
49155
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48904
49156
  src.push("varying float vFragDepth;");
48905
49157
  }
49158
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
49159
+ src.push(" return (m[2][3] == - 1.0);");
49160
+ src.push("}");
49161
+ src.push("varying float isPerspective;");
48906
49162
  }
48907
49163
 
48908
49164
  if (clipping) {
@@ -48942,6 +49198,7 @@ class TrianglesInstancingPickMeshRenderer {
48942
49198
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
48943
49199
  src.push("clipPos.z *= clipPos.w;");
48944
49200
  }
49201
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
48945
49202
  }
48946
49203
  src.push("gl_Position = clipPos;");
48947
49204
  src.push("}");
@@ -48966,6 +49223,7 @@ class TrianglesInstancingPickMeshRenderer {
48966
49223
  src.push("precision mediump int;");
48967
49224
  src.push("#endif");
48968
49225
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49226
+ src.push("varying float isPerspective;");
48969
49227
  src.push("uniform float logDepthBufFC;");
48970
49228
  src.push("varying float vFragDepth;");
48971
49229
  }
@@ -48993,7 +49251,7 @@ class TrianglesInstancingPickMeshRenderer {
48993
49251
  src.push("}");
48994
49252
  }
48995
49253
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48996
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
49254
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
48997
49255
  }
48998
49256
  src.push("gl_FragColor = vPickColor; ");
48999
49257
  src.push("}");
@@ -49242,6 +49500,10 @@ class TrianglesInstancingPickDepthRenderer {
49242
49500
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49243
49501
  src.push("varying float vFragDepth;");
49244
49502
  }
49503
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
49504
+ src.push(" return (m[2][3] == - 1.0);");
49505
+ src.push("}");
49506
+ src.push("varying float isPerspective;");
49245
49507
  }
49246
49508
 
49247
49509
  if (clipping) {
@@ -49279,6 +49541,7 @@ class TrianglesInstancingPickDepthRenderer {
49279
49541
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
49280
49542
  src.push("clipPos.z *= clipPos.w;");
49281
49543
  }
49544
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
49282
49545
  }
49283
49546
  src.push("gl_Position = clipPos;");
49284
49547
  src.push("}");
@@ -49306,6 +49569,7 @@ class TrianglesInstancingPickDepthRenderer {
49306
49569
  src.push("#endif");
49307
49570
 
49308
49571
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49572
+ src.push("varying float isPerspective;");
49309
49573
  src.push("uniform float logDepthBufFC;");
49310
49574
  src.push("varying float vFragDepth;");
49311
49575
  }
@@ -49344,7 +49608,7 @@ class TrianglesInstancingPickDepthRenderer {
49344
49608
  src.push("}");
49345
49609
  }
49346
49610
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49347
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
49611
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
49348
49612
  }
49349
49613
  src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");
49350
49614
  src.push(" gl_FragColor = packDepth(zNormalizedDepth); "); // Must be linear depth
@@ -49605,6 +49869,10 @@ class TrianglesInstancingPickNormalsRenderer {
49605
49869
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49606
49870
  src.push("varying float vFragDepth;");
49607
49871
  }
49872
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
49873
+ src.push(" return (m[2][3] == - 1.0);");
49874
+ src.push("}");
49875
+ src.push("varying float isPerspective;");
49608
49876
  }
49609
49877
  src.push("vec3 octDecode(vec2 oct) {");
49610
49878
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -49647,6 +49915,7 @@ class TrianglesInstancingPickNormalsRenderer {
49647
49915
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
49648
49916
  src.push("clipPos.z *= clipPos.w;");
49649
49917
  }
49918
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
49650
49919
  }
49651
49920
  src.push("gl_Position = clipPos;");
49652
49921
  src.push("}");
@@ -49674,6 +49943,7 @@ class TrianglesInstancingPickNormalsRenderer {
49674
49943
  src.push("#endif");
49675
49944
 
49676
49945
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49946
+ src.push("varying float isPerspective;");
49677
49947
  src.push("uniform float logDepthBufFC;");
49678
49948
  src.push("varying float vFragDepth;");
49679
49949
  }
@@ -49702,7 +49972,7 @@ class TrianglesInstancingPickNormalsRenderer {
49702
49972
  src.push("}");
49703
49973
  }
49704
49974
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49705
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
49975
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
49706
49976
  }
49707
49977
  src.push(" gl_FragColor = vec4((vWorldNormal * 0.5) + 0.5, 1.0);");
49708
49978
  src.push("}");
@@ -49944,6 +50214,10 @@ class TrianglesInstancingOcclusionRenderer {
49944
50214
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49945
50215
  src.push("varying float vFragDepth;");
49946
50216
  }
50217
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
50218
+ src.push(" return (m[2][3] == - 1.0);");
50219
+ src.push("}");
50220
+ src.push("varying float isPerspective;");
49947
50221
  }
49948
50222
  if (clipping) {
49949
50223
  src.push("varying vec4 vWorldPosition;");
@@ -49975,6 +50249,7 @@ class TrianglesInstancingOcclusionRenderer {
49975
50249
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
49976
50250
  src.push("clipPos.z *= clipPos.w;");
49977
50251
  }
50252
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
49978
50253
  }
49979
50254
  src.push("gl_Position = clipPos;");
49980
50255
  src.push("}");
@@ -49999,6 +50274,7 @@ class TrianglesInstancingOcclusionRenderer {
49999
50274
  src.push("precision mediump int;");
50000
50275
  src.push("#endif");
50001
50276
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50277
+ src.push("varying float isPerspective;");
50002
50278
  src.push("uniform float logDepthBufFC;");
50003
50279
  src.push("varying float vFragDepth;");
50004
50280
  }
@@ -50026,7 +50302,7 @@ class TrianglesInstancingOcclusionRenderer {
50026
50302
  }
50027
50303
  src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); "); // Occluders are blue
50028
50304
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50029
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
50305
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
50030
50306
  }
50031
50307
  src.push("}");
50032
50308
  return src;
@@ -50256,6 +50532,10 @@ class TrianglesInstancingDepthRenderer {
50256
50532
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50257
50533
  src.push("varying float vFragDepth;");
50258
50534
  }
50535
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
50536
+ src.push(" return (m[2][3] == - 1.0);");
50537
+ src.push("}");
50538
+ src.push("varying float isPerspective;");
50259
50539
  }
50260
50540
  if (clipping) {
50261
50541
  src.push("varying vec4 vWorldPosition;");
@@ -50290,6 +50570,7 @@ class TrianglesInstancingDepthRenderer {
50290
50570
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
50291
50571
  src.push("clipPos.z *= clipPos.w;");
50292
50572
  }
50573
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50293
50574
  }
50294
50575
  src.push("gl_Position = clipPos;");
50295
50576
  src.push("vHighPrecisionZW = gl_Position.zw;");
@@ -50313,6 +50594,7 @@ class TrianglesInstancingDepthRenderer {
50313
50594
  src.push("precision highp int;");
50314
50595
  if (scene.logarithmicDepthBufferEnabled) {
50315
50596
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50597
+ src.push("varying float isPerspective;");
50316
50598
  src.push("uniform float logDepthBufFC;");
50317
50599
  src.push("varying float vFragDepth;");
50318
50600
  }
@@ -50355,7 +50637,7 @@ class TrianglesInstancingDepthRenderer {
50355
50637
  src.push("}");
50356
50638
  }
50357
50639
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50358
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
50640
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
50359
50641
  }
50360
50642
  src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");
50361
50643
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["WEBGL_depth_texture"]) {
@@ -50611,6 +50893,10 @@ class TrianglesInstancingNormalsRenderer {
50611
50893
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50612
50894
  src.push("varying float vFragDepth;");
50613
50895
  }
50896
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
50897
+ src.push(" return (m[2][3] == - 1.0);");
50898
+ src.push("}");
50899
+ src.push("varying float isPerspective;");
50614
50900
  }
50615
50901
  src.push("vec3 octDecode(vec2 oct) {");
50616
50902
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -50654,6 +50940,7 @@ class TrianglesInstancingNormalsRenderer {
50654
50940
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
50655
50941
  src.push("clipPos.z *= clipPos.w;");
50656
50942
  }
50943
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50657
50944
  }
50658
50945
  src.push("gl_Position = clipPos;");
50659
50946
  src.push("}");
@@ -50678,6 +50965,7 @@ class TrianglesInstancingNormalsRenderer {
50678
50965
  src.push("precision mediump int;");
50679
50966
  src.push("#endif");
50680
50967
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50968
+ src.push("varying float isPerspective;");
50681
50969
  src.push("uniform float logDepthBufFC;");
50682
50970
  src.push("varying float vFragDepth;");
50683
50971
  }
@@ -50708,7 +50996,7 @@ class TrianglesInstancingNormalsRenderer {
50708
50996
  src.push("}");
50709
50997
  }
50710
50998
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50711
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
50999
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
50712
51000
  }
50713
51001
  src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");
50714
51002
  src.push("}");
@@ -51383,6 +51671,10 @@ class TrianglesInstancingColorQualityRenderer {
51383
51671
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
51384
51672
  src.push("varying float vFragDepth;");
51385
51673
  }
51674
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
51675
+ src.push(" return (m[2][3] == - 1.0);");
51676
+ src.push("}");
51677
+ src.push("varying float isPerspective;");
51386
51678
  }
51387
51679
 
51388
51680
  src.push("vec3 octDecode(vec2 oct) {");
@@ -51440,6 +51732,7 @@ class TrianglesInstancingColorQualityRenderer {
51440
51732
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
51441
51733
  src.push("clipPos.z *= clipPos.w;");
51442
51734
  }
51735
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51443
51736
  }
51444
51737
 
51445
51738
  if (clipping) {
@@ -51490,6 +51783,7 @@ class TrianglesInstancingColorQualityRenderer {
51490
51783
  src.push("#endif");
51491
51784
 
51492
51785
  if (scene.logarithmicDepthBufferEnabled) {
51786
+ src.push("varying float isPerspective;");
51493
51787
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
51494
51788
  src.push("uniform float logDepthBufFC;");
51495
51789
  src.push("varying float vFragDepth;");
@@ -51840,7 +52134,7 @@ class TrianglesInstancingColorQualityRenderer {
51840
52134
  src.push("gl_FragColor = fragColor;");
51841
52135
 
51842
52136
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
51843
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
52137
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
51844
52138
  }
51845
52139
 
51846
52140
  src.push("}");
@@ -52074,6 +52368,10 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52074
52368
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
52075
52369
  src.push("varying float vFragDepth;");
52076
52370
  }
52371
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
52372
+ src.push(" return (m[2][3] == - 1.0);");
52373
+ src.push("}");
52374
+ src.push("varying float isPerspective;");
52077
52375
  }
52078
52376
  if (clipping) {
52079
52377
  src.push("varying vec4 vFlags2;");
@@ -52102,6 +52400,7 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52102
52400
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
52103
52401
  src.push("clipPos.z *= clipPos.w;");
52104
52402
  }
52403
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
52105
52404
  }
52106
52405
  src.push("gl_Position = clipPos;");
52107
52406
  src.push("}");
@@ -52128,6 +52427,7 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52128
52427
  src.push("#endif");
52129
52428
 
52130
52429
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
52430
+ src.push("varying float isPerspective;");
52131
52431
  src.push("uniform float logDepthBufFC;");
52132
52432
  src.push("varying float vFragDepth;");
52133
52433
  }
@@ -52155,7 +52455,7 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52155
52455
  src.push("}");
52156
52456
  }
52157
52457
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
52158
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
52458
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
52159
52459
  }
52160
52460
  src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");
52161
52461
  src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");
@@ -52468,6 +52768,7 @@ const tempVec3c$3 = math.vec3();
52468
52768
  const tempVec3d$1 = math.vec3();
52469
52769
  const tempVec3e = math.vec3();
52470
52770
  const tempVec3f = math.vec3();
52771
+ const tempVec3g = math.vec3();
52471
52772
 
52472
52773
  /**
52473
52774
  * @private
@@ -52704,18 +53005,18 @@ class TrianglesInstancingLayer {
52704
53005
 
52705
53006
  // Note: order of inverse and transpose doesn't matter
52706
53007
 
52707
- let transposedMat = math.transposeMat4(meshMatrix, math.mat4()); // TODO: Use cached matrix
52708
- let normalMatrix = math.inverseMat4(transposedMat);
53008
+ let transposedMat = math.transposeMat4(meshMatrix, math.mat4()); // TODO: Use cached matrix
53009
+ let normalMatrix = math.inverseMat4(transposedMat);
52709
53010
 
52710
- this._modelNormalMatrixCol0.push(normalMatrix[0]);
52711
- this._modelNormalMatrixCol0.push(normalMatrix[4]);
52712
- this._modelNormalMatrixCol0.push(normalMatrix[8]);
52713
- this._modelNormalMatrixCol0.push(normalMatrix[12]);
53011
+ this._modelNormalMatrixCol0.push(normalMatrix[0]);
53012
+ this._modelNormalMatrixCol0.push(normalMatrix[4]);
53013
+ this._modelNormalMatrixCol0.push(normalMatrix[8]);
53014
+ this._modelNormalMatrixCol0.push(normalMatrix[12]);
52714
53015
 
52715
- this._modelNormalMatrixCol1.push(normalMatrix[1]);
52716
- this._modelNormalMatrixCol1.push(normalMatrix[5]);
52717
- this._modelNormalMatrixCol1.push(normalMatrix[9]);
52718
- this._modelNormalMatrixCol1.push(normalMatrix[13]);
53016
+ this._modelNormalMatrixCol1.push(normalMatrix[1]);
53017
+ this._modelNormalMatrixCol1.push(normalMatrix[5]);
53018
+ this._modelNormalMatrixCol1.push(normalMatrix[9]);
53019
+ this._modelNormalMatrixCol1.push(normalMatrix[13]);
52719
53020
 
52720
53021
  this._modelNormalMatrixCol2.push(normalMatrix[2]);
52721
53022
  this._modelNormalMatrixCol2.push(normalMatrix[6]);
@@ -52769,6 +53070,7 @@ class TrianglesInstancingLayer {
52769
53070
  if (this.model.scene.pickSurfacePrecisionEnabled) {
52770
53071
  portion.matrix = meshMatrix.slice();
52771
53072
  portion.inverseMatrix = null; // Lazy-computed in precisionRayPickSurface
53073
+ portion.normalMatrix = null; // Lazy-computed in precisionRayPickSurface
52772
53074
  }
52773
53075
 
52774
53076
  this._portions.push(portion);
@@ -53399,7 +53701,7 @@ class TrianglesInstancingLayer {
53399
53701
 
53400
53702
  //-----------------------------------------------------------------------------------------
53401
53703
 
53402
- precisionRayPickSurface(portionId, worldRayOrigin, worldRayDir, worldSurfacePos) {
53704
+ precisionRayPickSurface(portionId, worldRayOrigin, worldRayDir, worldSurfacePos, worldNormal) {
53403
53705
 
53404
53706
  if (!this.model.scene.pickSurfacePrecisionEnabled) {
53405
53707
  return false;
@@ -53417,6 +53719,10 @@ class TrianglesInstancingLayer {
53417
53719
  portion.inverseMatrix = math.inverseMat4(portion.matrix, math.mat4());
53418
53720
  }
53419
53721
 
53722
+ if (worldNormal && !portion.normalMatrix) {
53723
+ portion.normalMatrix = math.transposeMat4(portion.inverseMatrix, math.mat4());
53724
+ }
53725
+
53420
53726
  const quantizedPositions = state.quantizedPositions;
53421
53727
  const indices = state.indices;
53422
53728
  const rtcCenter = state.rtcCenter;
@@ -53440,6 +53746,10 @@ class TrianglesInstancingLayer {
53440
53746
  const b = tempVec3e;
53441
53747
  const c = tempVec3f;
53442
53748
 
53749
+ let gotIntersect = false;
53750
+ let closestDist = 0;
53751
+ const closestIntersectPos = tempVec3g;
53752
+
53443
53753
  for (let i = 0, len = indices.length; i < len; i += 3) {
53444
53754
 
53445
53755
  const ia = indices[i + 0] * 3;
@@ -53462,25 +53772,40 @@ class TrianglesInstancingLayer {
53462
53772
  math.decompressPosition(b, state.positionsDecodeMatrix);
53463
53773
  math.decompressPosition(c, state.positionsDecodeMatrix);
53464
53774
 
53465
- if (math.rayTriangleIntersect(rtcRayOrigin, rtcRayDir, a, b, c, worldSurfacePos)) {
53775
+ if (math.rayTriangleIntersect(rtcRayOrigin, rtcRayDir, a, b, c, closestIntersectPos)) {
53466
53776
 
53467
- math.transformPoint3(portion.matrix, worldSurfacePos, worldSurfacePos);
53777
+ math.transformPoint3(portion.matrix, closestIntersectPos, closestIntersectPos);
53468
53778
 
53469
- math.transformPoint3(this.model.worldMatrix, worldSurfacePos, worldSurfacePos);
53779
+ math.transformPoint3(this.model.worldMatrix, closestIntersectPos, closestIntersectPos);
53470
53780
 
53471
53781
  if (offset) {
53472
- math.addVec3(worldSurfacePos, offset);
53782
+ math.addVec3(closestIntersectPos, offset);
53473
53783
  }
53474
53784
 
53475
53785
  if (rtcCenter) {
53476
- math.addVec3(worldSurfacePos, rtcCenter);
53786
+ math.addVec3(closestIntersectPos, rtcCenter);
53477
53787
  }
53478
53788
 
53479
- return true;
53789
+ const dist = Math.abs(math.lenVec3(math.subVec3(closestIntersectPos, worldRayOrigin, [])));
53790
+
53791
+ if (!gotIntersect || dist > closestDist) {
53792
+ closestDist = dist;
53793
+ worldSurfacePos.set(closestIntersectPos);
53794
+ if (worldNormal) { // Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
53795
+ math.triangleNormal(a, b, c, worldNormal);
53796
+ }
53797
+ gotIntersect = true;
53798
+ }
53480
53799
  }
53481
53800
  }
53482
53801
 
53483
- return false;
53802
+ if (gotIntersect && worldNormal) {
53803
+ math.transformVec3(portion.normalMatrix, worldNormal, worldNormal);
53804
+ math.transformVec3(this.model.worldNormalMatrix, worldNormal, worldNormal);
53805
+ math.normalizeVec3(worldNormal);
53806
+ }
53807
+
53808
+ return gotIntersect;
53484
53809
  }
53485
53810
 
53486
53811
  destroy() {
@@ -69554,14 +69879,16 @@ var parseGLTF$1 = (function () {
69554
69879
  var geometry;
69555
69880
 
69556
69881
  for (var i = 0, len = primitivesInfo.length; i < len; i++) {
69557
-
69882
+ primitiveInfo = primitivesInfo[i];
69883
+ if (primitiveInfo.mode < 4 ) {
69884
+ continue;
69885
+ }
69558
69886
  geometryCfg = {
69559
69887
  primitive: "triangles",
69560
69888
  compressGeometry: true,
69561
69889
  edgeThreshold: ctx.edgeThreshold
69562
69890
  };
69563
69891
 
69564
- primitiveInfo = primitivesInfo[i];
69565
69892
  indicesIndex = primitiveInfo.indices;
69566
69893
 
69567
69894
  if (indicesIndex !== null && indicesIndex !== undefined) {
@@ -70245,11 +70572,14 @@ const parseGLTF = (function () {
70245
70572
  const meshIds = [];
70246
70573
 
70247
70574
  for (let i = 0; i < numPrimitives; i++) {
70575
+ const primitiveInfo = meshInfo.primitives[i];
70576
+ if (primitiveInfo.mode < 4 ) {
70577
+ continue;
70578
+ }
70248
70579
  const meshCfg = {
70249
70580
  id: performanceModel.id + "." + ctx.numObjects++,
70250
70581
  matrix: worldMatrix
70251
70582
  };
70252
- const primitiveInfo = meshInfo.primitives[i];
70253
70583
 
70254
70584
  const materialIndex = primitiveInfo.material;
70255
70585
  let materialInfo;
@@ -71424,6 +71754,7 @@ class NavCubePlugin extends Plugin {
71424
71754
  var lastX;
71425
71755
  var lastY;
71426
71756
 
71757
+
71427
71758
  self._navCubeCanvas.addEventListener("mouseenter", self._onMouseEnter = function (e) {
71428
71759
  over = true;
71429
71760
  });
@@ -71492,27 +71823,16 @@ class NavCubePlugin extends Plugin {
71492
71823
  self._repaint();
71493
71824
  lastAreaId = -1;
71494
71825
  }
71495
- var hit = navCubeScene.pick({
71496
- canvasPos: canvasPos,
71497
- pickSurface: true
71498
- });
71499
- if (hit) {
71500
- if (hit.uv) {
71501
- var areaId = self._cubeTextureCanvas.getArea(hit.uv);
71502
- if (areaId !== undefined) {
71503
- document.body.style.cursor = "pointer";
71504
- if (lastAreaId >= 0) {
71505
- self._cubeTextureCanvas.setAreaHighlighted(lastAreaId, false);
71506
- self._repaint();
71507
- lastAreaId = -1;
71508
- }
71509
- if (areaId >= 0) {
71510
- self._cubeTextureCanvas.setAreaHighlighted(areaId, true);
71511
- lastAreaId = areaId;
71512
- self._repaint();
71513
- }
71514
- }
71515
- }
71826
+ document.body.style.cursor = "pointer";
71827
+ if (lastAreaId >= 0) {
71828
+ self._cubeTextureCanvas.setAreaHighlighted(lastAreaId, false);
71829
+ self._repaint();
71830
+ lastAreaId = -1;
71831
+ }
71832
+ if (areaId >= 0) {
71833
+ self._cubeTextureCanvas.setAreaHighlighted(areaId, false);
71834
+ lastAreaId = -1;
71835
+ self._repaint();
71516
71836
  }
71517
71837
  });
71518
71838
  }
@@ -75014,6 +75334,7 @@ class Skybox extends Component {
75014
75334
  12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23
75015
75335
  ]
75016
75336
  }),
75337
+ background: true,
75017
75338
  scale: [2000, 2000, 2000], // Overridden when we initialize the 'size' property, below
75018
75339
  rotation: [0, -90, 0],
75019
75340
  material: new PhongMaterial(this, {
@@ -75024,6 +75345,8 @@ class Skybox extends Component {
75024
75345
  emissiveMap: new Texture(this, {
75025
75346
  src: cfg.src,
75026
75347
  flipY: true,
75348
+ wrapS: "clampToEdge",
75349
+ wrapT: "clampToEdge",
75027
75350
  encoding: cfg.encoding || "sRGB"
75028
75351
  }),
75029
75352
  backfaces: true // Show interior faces of our skybox geometry
@@ -78690,6 +79013,8 @@ class TreeViewPlugin extends Plugin {
78690
79013
  /**
78691
79014
  * Removes a model from this tree view.
78692
79015
  *
79016
+ * Does nothing if model not currently in tree view.
79017
+ *
78693
79018
  * @param {String} modelId ID of a model {@link Entity} in {@link Scene#models}.
78694
79019
  */
78695
79020
  removeModel(modelId) {
@@ -78698,7 +79023,6 @@ class TreeViewPlugin extends Plugin {
78698
79023
  }
78699
79024
  const modelTreeView = this._modelTreeViews[modelId];
78700
79025
  if (!modelTreeView) {
78701
- this.warn("Model not added: " + modelId);
78702
79026
  return;
78703
79027
  }
78704
79028
  modelTreeView.destroy();
@@ -98020,6 +98344,355 @@ class Fresnel extends Component {
98020
98344
  }
98021
98345
  }
98022
98346
 
98347
+ /**
98348
+ * A {@link Marker} with a billboarded and textured quad attached to it.
98349
+ *
98350
+ * * Extends {@link Marker}
98351
+ * * Keeps the quad oriented towards the viewpoint
98352
+ * * Auto-fits the quad to the texture
98353
+ * * Has a world-space position
98354
+ * * Can be configured to hide the quad whenever the position is occluded by some other object
98355
+ *
98356
+ * ## Usage
98357
+ *
98358
+ * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#markers_SpriteMarker)]
98359
+ *
98360
+ * ```` javascript
98361
+ * import {Viewer, SpriteMarker } from "../dist/xeokit-sdk.es.js";
98362
+ *
98363
+ * const viewer = new Viewer({
98364
+ * canvasId: "myCanvas",
98365
+ * transparent: true
98366
+ * });
98367
+ *
98368
+ * viewer.scene.camera.eye = [0, 0, 25];
98369
+ * viewer.scene.camera.look = [0, 0, 0];
98370
+ * viewer.scene.camera.up = [0, 1, 0];
98371
+ *
98372
+ * new SpriteMarker(viewer.scene, {
98373
+ * worldPos: [-10, 0, 0],
98374
+ * src: "../assets/textures/diffuse/uvGrid2_512x1024.jpg",
98375
+ * size: 5,
98376
+ * occludable: false
98377
+ * });
98378
+ *
98379
+ * new SpriteMarker(viewer.scene, {
98380
+ * worldPos: [+10, 0, 0],
98381
+ * src: "../assets/textures/diffuse/uvGrid2_1024x512.jpg",
98382
+ * size: 4,
98383
+ * occludable: false
98384
+ * });
98385
+ *````
98386
+ */
98387
+ class SpriteMarker extends Marker {
98388
+
98389
+ /**
98390
+ * @constructor
98391
+ * @param {Component} owner Owner component. When destroyed, the owner will destroy this SpriteMarker as well.
98392
+ * @param {*} [cfg] Configs
98393
+ * @param {String} [cfg.id] Optional ID for this SpriteMarker, unique among all components in the parent scene, generated automatically when omitted.
98394
+ * @param {Entity} [cfg.entity] Entity to associate this Marker with. When the SpriteMarker has an Entity, then {@link Marker#visible} will always be ````false```` if {@link Entity#visible} is false.
98395
+ * @param {Boolean} [cfg.occludable=false] Indicates whether or not this Marker is hidden (ie. {@link Marker#visible} is ````false```` whenever occluded by {@link Entity}s in the {@link Scene}.
98396
+ * @param {Number[]} [cfg.worldPos=[0,0,0]] World-space 3D Marker position.
98397
+ * @param {String} [cfg.src=null] Path to image file to load into this SpriteMarker. See the {@link SpriteMarker#src} property for more info.
98398
+ * @param {HTMLImageElement} [cfg.image=null] HTML Image object to load into this SpriteMarker. See the {@link SpriteMarker#image} property for more info.
98399
+ * @param {Boolean} [cfg.flipY=false] Flips this SpriteMarker's texture image along its vertical axis when true.
98400
+ * @param {String} [cfg.encoding="linear"] Texture encoding format. See the {@link Texture#encoding} property for more info.
98401
+ */
98402
+ constructor(owner, cfg = {}) {
98403
+
98404
+ super(owner, {
98405
+ entity: cfg.entity,
98406
+ occludable: cfg.occludable,
98407
+ worldPos: cfg.worldPos
98408
+ });
98409
+
98410
+ this._occluded = false;
98411
+ this._visible = true;
98412
+ this._src = null;
98413
+ this._image = null;
98414
+ this._pos = math.vec3();
98415
+ this._rtcCenter = math.vec3();
98416
+ this._rtcPos = math.vec3();
98417
+ this._dir = math.vec3();
98418
+ this._size = 1.0;
98419
+ this._imageSize = math.vec2();
98420
+
98421
+ this._texture = new Texture(this, {
98422
+ src: cfg.src
98423
+ });
98424
+
98425
+ this._geometry = new ReadableGeometry(this, {
98426
+ primitive: "triangles",
98427
+ positions: [3, 3, 0, -3, 3, 0, -3, -3, 0, 3, -3, 0],
98428
+ normals: [-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0],
98429
+ uv: [1, -1, 0, -1, 0, 0, 1, 0],
98430
+ indices: [0, 1, 2, 0, 2, 3] // Ensure these will be front-faces
98431
+ });
98432
+
98433
+ this._mesh = new Mesh(this, {
98434
+ geometry: this._geometry,
98435
+ material: new PhongMaterial(this, {
98436
+ ambient: [0.9, 0.3, 0.9],
98437
+ shininess: 30,
98438
+ diffuseMap: this._texture,
98439
+ backfaces: true
98440
+ }),
98441
+ scale: [1, 1, 1], // Note: by design, scale does not work with billboard
98442
+ position: cfg.worldPos,
98443
+ rotation: [90, 0, 0],
98444
+ billboard: "spherical",
98445
+ occluder: false // Don't occlude SpriteMarkers or Annotations
98446
+ });
98447
+
98448
+ this.visible = true;
98449
+ this.collidable = cfg.collidable;
98450
+ this.clippable = cfg.clippable;
98451
+ this.pickable = cfg.pickable;
98452
+ this.opacity = cfg.opacity;
98453
+ this.size = cfg.size;
98454
+
98455
+ if (cfg.image) {
98456
+ this.image = cfg.image;
98457
+ } else {
98458
+ this.src = cfg.src;
98459
+ }
98460
+ }
98461
+
98462
+ _setVisible(visible) { // Called by VisibilityTester and this._entity.on("destroyed"..)
98463
+ this._occluded = (!visible);
98464
+ this._mesh.visible = this._visible && (!this._occluded);
98465
+ super._setVisible(visible);
98466
+ }
98467
+
98468
+ /**
98469
+ * Sets if this ````SpriteMarker```` is visible or not.
98470
+ *
98471
+ * Default value is ````true````.
98472
+ *
98473
+ * @param {Boolean} visible Set ````true```` to make this ````SpriteMarker```` visible.
98474
+ */
98475
+ set visible(visible) {
98476
+ this._visible = (visible === null || visible === undefined) ? true : visible;
98477
+ this._mesh.visible = this._visible && (!this._occluded);
98478
+ }
98479
+
98480
+ /**
98481
+ * Gets if this ````SpriteMarker```` is visible or not.
98482
+ *
98483
+ * Default value is ````true````.
98484
+ *
98485
+ * @returns {Boolean} Returns ````true```` if visible.
98486
+ */
98487
+ get visible() {
98488
+ return this._visible;
98489
+ }
98490
+
98491
+ /**
98492
+ * Sets an ````HTMLImageElement```` to source the image from.
98493
+ *
98494
+ * Sets {@link Texture#src} null.
98495
+ *
98496
+ * @type {HTMLImageElement}
98497
+ */
98498
+ set image(image) {
98499
+ this._image = image;
98500
+ if (this._image) {
98501
+ this._imageSize[0] = this._image.width;
98502
+ this._imageSize[1] = this._image.height;
98503
+ this._updatePlaneSizeFromImage();
98504
+ this._src = null;
98505
+ this._texture.image = this._image;
98506
+ }
98507
+ }
98508
+
98509
+ /**
98510
+ * Gets the ````HTMLImageElement```` the ````SpriteMarker````'s image is sourced from, if set.
98511
+ *
98512
+ * Returns null if not set.
98513
+ *
98514
+ * @type {HTMLImageElement}
98515
+ */
98516
+ get image() {
98517
+ return this._image;
98518
+ }
98519
+
98520
+ /**
98521
+ * Sets an image file path that the ````SpriteMarker````'s image is sourced from.
98522
+ *
98523
+ * Accepted file types are PNG and JPEG.
98524
+ *
98525
+ * Sets {@link Texture#image} null.
98526
+ *
98527
+ * @type {String}
98528
+ */
98529
+ set src(src) {
98530
+ this._src = src;
98531
+ if (this._src) {
98532
+ this._image = null;
98533
+ const image = new Image();
98534
+ image.onload = () => {
98535
+ this._texture.image = image;
98536
+ this._imageSize[0] = image.width;
98537
+ this._imageSize[1] = image.height;
98538
+ this._updatePlaneSizeFromImage();
98539
+ };
98540
+ image.src = this._src;
98541
+ }
98542
+ }
98543
+
98544
+ /**
98545
+ * Gets the image file path that the ````SpriteMarker````'s image is sourced from, if set.
98546
+ *
98547
+ * Returns null if not set.
98548
+ *
98549
+ * @type {String}
98550
+ */
98551
+ get src() {
98552
+ return this._src;
98553
+ }
98554
+
98555
+ /**
98556
+ * Sets the World-space size of the longest edge of the ````SpriteMarker````.
98557
+ *
98558
+ * Note that ````SpriteMarker```` sets its aspect ratio to match its image. If we set a value of ````1000````, and
98559
+ * the image has size ````400x300````, then the ````SpriteMarker```` will then have size ````1000 x 750````.
98560
+ *
98561
+ * Default value is ````1.0````.
98562
+ *
98563
+ * @param {Number} size New World-space size of the ````SpriteMarker````.
98564
+ */
98565
+ set size(size) {
98566
+ this._size = (size === undefined || size === null) ? 1.0 : size;
98567
+ if (this._image) {
98568
+ this._updatePlaneSizeFromImage();
98569
+ }
98570
+ }
98571
+
98572
+ /**
98573
+ * Gets the World-space size of the longest edge of the ````SpriteMarker````.
98574
+ *
98575
+ * Returns {Number} World-space size of the ````SpriteMarker````.
98576
+ */
98577
+ get size() {
98578
+ return this._size;
98579
+ }
98580
+
98581
+ /**
98582
+ * Sets if this ````SpriteMarker```` is included in boundary calculations.
98583
+ *
98584
+ * Default is ````true````.
98585
+ *
98586
+ * @type {Boolean}
98587
+ */
98588
+ set collidable(value) {
98589
+ this._mesh.collidable = (value !== false);
98590
+ }
98591
+
98592
+ /**
98593
+ * Gets if this ````SpriteMarker```` is included in boundary calculations.
98594
+ *
98595
+ * Default is ````true````.
98596
+ *
98597
+ * @type {Boolean}
98598
+ */
98599
+ get collidable() {
98600
+ return this._mesh.collidable;
98601
+ }
98602
+
98603
+ /**
98604
+ * Sets if this ````SpriteMarker```` is clippable.
98605
+ *
98606
+ * Clipping is done by the {@link SectionPlane}s in {@link Scene#sectionPlanes}.
98607
+ *
98608
+ * Default is ````true````.
98609
+ *
98610
+ * @type {Boolean}
98611
+ */
98612
+ set clippable(value) {
98613
+ this._mesh.clippable = (value !== false);
98614
+ }
98615
+
98616
+ /**
98617
+ * Gets if this ````SpriteMarker```` is clippable.
98618
+ *
98619
+ * Clipping is done by the {@link SectionPlane}s in {@link Scene#sectionPlanes}.
98620
+ *
98621
+ * Default is ````true````.
98622
+ *
98623
+ * @type {Boolean}
98624
+ */
98625
+ get clippable() {
98626
+ return this._mesh.clippable;
98627
+ }
98628
+
98629
+ /**
98630
+ * Sets if this ````SpriteMarker```` is pickable.
98631
+ *
98632
+ * Default is ````true````.
98633
+ *
98634
+ * @type {Boolean}
98635
+ */
98636
+ set pickable(value) {
98637
+ this._mesh.pickable = (value !== false);
98638
+ }
98639
+
98640
+ /**
98641
+ * Gets if this ````SpriteMarker```` is pickable.
98642
+ *
98643
+ * Default is ````true````.
98644
+ *
98645
+ * @type {Boolean}
98646
+ */
98647
+ get pickable() {
98648
+ return this._mesh.pickable;
98649
+ }
98650
+
98651
+ /**
98652
+ * Sets the opacity factor for this ````SpriteMarker````.
98653
+ *
98654
+ * This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
98655
+ *
98656
+ * @type {Number}
98657
+ */
98658
+ set opacity(opacity) {
98659
+ this._mesh.opacity = opacity;
98660
+ }
98661
+
98662
+ /**
98663
+ * Gets this ````SpriteMarker````'s opacity factor.
98664
+ *
98665
+ * This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
98666
+ *
98667
+ * @type {Number}
98668
+ */
98669
+ get opacity() {
98670
+ return this._mesh.opacity;
98671
+ }
98672
+
98673
+ _updatePlaneSizeFromImage() {
98674
+ const halfSize = this._size * 0.5;
98675
+ const width = this._imageSize[0];
98676
+ const height = this._imageSize[1];
98677
+ const aspect = height / width;
98678
+ if (width > height) {
98679
+ this._geometry.positions = [
98680
+ halfSize, halfSize * aspect, 0,
98681
+ -halfSize, halfSize * aspect, 0,
98682
+ -halfSize, -halfSize * aspect, 0,
98683
+ halfSize, -halfSize * aspect, 0
98684
+ ];
98685
+ } else {
98686
+ this._geometry.positions = [
98687
+ halfSize / aspect, halfSize, 0,
98688
+ -halfSize / aspect, halfSize, 0,
98689
+ -halfSize / aspect, -halfSize, 0,
98690
+ halfSize / aspect, -halfSize, 0
98691
+ ];
98692
+ }
98693
+ }
98694
+ }
98695
+
98023
98696
  const color = math.vec3();
98024
98697
 
98025
98698
  /**
@@ -99708,6 +100381,7 @@ class MousePanRotateDollyHandler {
99708
100381
  const y = canvasPos[1];
99709
100382
  if (Math.abs(x - lastXDown) < 3 && Math.abs(y - lastYDown) < 3) {
99710
100383
  controllers.cameraControl.fire("rightClick", { // For context menus
100384
+ pagePos: [Math.round(e.pageX), Math.round(e.pageY)],
99711
100385
  canvasPos: canvasPos,
99712
100386
  event: e
99713
100387
  }, true);
@@ -99793,13 +100467,13 @@ const tempCameraTarget = {
99793
100467
  */
99794
100468
  class KeyboardAxisViewHandler {
99795
100469
 
99796
- constructor(scene, controllers, configs, states, updates) {
100470
+ constructor(scene, controllers, configs, states) {
99797
100471
 
99798
100472
  this._scene = scene;
99799
100473
  const cameraControl = controllers.cameraControl;
99800
100474
  const camera = scene.camera;
99801
100475
 
99802
- scene.input.on("keydown", this._documentKeyDownHandler = (e) => {
100476
+ this._onSceneKeyDown = scene.input.on("keydown", () => {
99803
100477
 
99804
100478
  if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
99805
100479
  return;
@@ -99891,7 +100565,7 @@ class KeyboardAxisViewHandler {
99891
100565
  }
99892
100566
 
99893
100567
  destroy() {
99894
- document.removeEventListener("keydown", this._documentKeyDownHandler);
100568
+ this._scene.input.off(this._onSceneKeyDown);
99895
100569
  }
99896
100570
  }
99897
100571
 
@@ -100265,22 +100939,19 @@ class KeyboardPanRotateDollyHandler {
100265
100939
 
100266
100940
  const canvas = scene.canvas.canvas;
100267
100941
 
100268
- controllers.pickController;
100269
-
100270
100942
  let mouseMovedSinceLastKeyboardDolly = true;
100271
100943
 
100272
- document.addEventListener("mousemove", this._documentMouseMoveHandler = () => {
100944
+ this._onSceneMouseMove = input.on("mousemove", () => {
100273
100945
  mouseMovedSinceLastKeyboardDolly = true;
100274
100946
  });
100275
100947
 
100276
- document.addEventListener("keydown", this._documentKeyDownHandler = (e) => {
100948
+ this._onSceneKeyDown = input.on("keydown", (keyCode) => {
100277
100949
  if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
100278
100950
  return;
100279
100951
  }
100280
100952
  if (!states.mouseover) {
100281
100953
  return;
100282
100954
  }
100283
- const keyCode = e.keyCode;
100284
100955
  keyDownMap[keyCode] = true;
100285
100956
 
100286
100957
  if (keyCode === input.KEY_SHIFT) {
@@ -100288,14 +100959,13 @@ class KeyboardPanRotateDollyHandler {
100288
100959
  }
100289
100960
  });
100290
100961
 
100291
- document.addEventListener("keyup", this._documentKeyUpHandler = (e) => {
100962
+ this._onSceneKeyUp = input.on("keyup", (keyCode) => {
100292
100963
  if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
100293
100964
  return;
100294
100965
  }
100295
100966
  if (!states.mouseover) {
100296
100967
  return;
100297
100968
  }
100298
- const keyCode = e.keyCode;
100299
100969
  keyDownMap[keyCode] = false;
100300
100970
 
100301
100971
  if (keyCode === input.KEY_SHIFT) {
@@ -100430,9 +101100,9 @@ class KeyboardPanRotateDollyHandler {
100430
101100
 
100431
101101
  this._scene.off(this._onTick);
100432
101102
 
100433
- document.removeEventListener("mousemove", this._documentMouseMoveHandler);
100434
- document.removeEventListener("keydown", this._documentKeyDownHandler);
100435
- document.removeEventListener("keyup", this._documentKeyUpHandler);
101103
+ this._scene.input.off(this._onSceneMouseMove);
101104
+ this._scene.input.off(this._onSceneKeyDown);
101105
+ this._scene.input.off(this._onSceneKeyUp);
100436
101106
  }
100437
101107
  }
100438
101108
 
@@ -100865,7 +101535,6 @@ class TouchPanRotateAndDollyHandler {
100865
101535
  return;
100866
101536
  }
100867
101537
 
100868
- event.stopPropagation();
100869
101538
  event.preventDefault();
100870
101539
 
100871
101540
  const touches = event.touches;
@@ -100965,7 +101634,12 @@ class TouchPanRotateAndDollyHandler {
100965
101634
 
100966
101635
  const xPanDelta = touch0Vec[0];
100967
101636
  const yPanDelta = touch0Vec[1];
100968
-
101637
+
101638
+ if (states.longTouchTimeout !== null && (Math.abs(xPanDelta) > configs.longTapRadius || Math.abs(yPanDelta) > configs.longTapRadius)) {
101639
+ clearTimeout(states.longTouchTimeout);
101640
+ states.longTouchTimeout = null;
101641
+ }
101642
+
100969
101643
  if (configs.planView) { // No rotating in plan-view mode
100970
101644
 
100971
101645
  const camera = scene.camera;
@@ -101075,7 +101749,6 @@ class TouchPickHandler {
101075
101749
  this._scene = scene;
101076
101750
 
101077
101751
  const pickController = controllers.pickController;
101078
- controllers.pivotController;
101079
101752
  const cameraControl = controllers.cameraControl;
101080
101753
 
101081
101754
  let touchStartTime;
@@ -101112,6 +101785,11 @@ class TouchPickHandler {
101112
101785
  return;
101113
101786
  }
101114
101787
 
101788
+ if (states.longTouchTimeout !== null) {
101789
+ clearTimeout(states.longTouchTimeout);
101790
+ states.longTouchTimeout = null;
101791
+ }
101792
+
101115
101793
  const touches = e.touches;
101116
101794
  const changedTouches = e.changedTouches;
101117
101795
 
@@ -101121,6 +101799,23 @@ class TouchPickHandler {
101121
101799
  tapStartTime = touchStartTime;
101122
101800
  tapStartPos[0] = touches[0].pageX;
101123
101801
  tapStartPos[1] = touches[0].pageY;
101802
+
101803
+ const rightClickClientX = touches[0].clientX;
101804
+ const rightClickClientY = touches[0].clientY;
101805
+
101806
+ const rightClickPageX = touches[0].pageX;
101807
+ const rightClickPageY = touches[0].pageY;
101808
+
101809
+ states.longTouchTimeout = setTimeout(() => {
101810
+ controllers.cameraControl.fire("rightClick", { // For context menus
101811
+ pagePos: [Math.round(rightClickPageX), Math.round(rightClickPageY)],
101812
+ canvasPos: [Math.round(rightClickClientX), Math.round(rightClickClientY)],
101813
+ event: e
101814
+ }, true);
101815
+
101816
+ states.longTouchTimeout = null;
101817
+ }, configs.longTapTimeout);
101818
+
101124
101819
  } else {
101125
101820
  tapStartTime = -1;
101126
101821
  }
@@ -101136,8 +101831,6 @@ class TouchPickHandler {
101136
101831
 
101137
101832
  activeTouches.length = touches.length;
101138
101833
 
101139
- e.stopPropagation();
101140
-
101141
101834
  }, {passive: true});
101142
101835
 
101143
101836
 
@@ -101151,12 +101844,12 @@ class TouchPickHandler {
101151
101844
  const touches = e.touches;
101152
101845
  const changedTouches = e.changedTouches;
101153
101846
 
101154
- cameraControl.hasSubs("picked");
101155
- cameraControl.hasSubs("pickedNothing");
101156
101847
  const pickedSurfaceSubs = cameraControl.hasSubs("pickedSurface");
101157
- cameraControl.hasSubs("doublePicked");
101158
- cameraControl.hasSubs("doublePickedSurface");
101159
- cameraControl.hasSubs("doublePickedNothing");
101848
+
101849
+ if (states.longTouchTimeout !== null) {
101850
+ clearTimeout(states.longTouchTimeout);
101851
+ states.longTouchTimeout = null;
101852
+ }
101160
101853
 
101161
101854
  // process tap
101162
101855
 
@@ -101240,8 +101933,8 @@ class TouchPickHandler {
101240
101933
 
101241
101934
  reset() {
101242
101935
  // TODO
101243
- // tapStartTime = -1;
101244
- // lastTapTime = -1;
101936
+ // tapStartTime = -1;
101937
+ // lastTapTime = -1;
101245
101938
 
101246
101939
  }
101247
101940
 
@@ -101859,9 +102552,8 @@ class CameraControl extends Component {
101859
102552
 
101860
102553
  // Private
101861
102554
 
101862
- tapInterval: 150, // Millisecs
101863
- doubleTapInterval: 325, // Millisecs
101864
- tapDistanceThreshold: 4, // Pixels
102555
+ longTapTimeout: 600, // Millisecs
102556
+ longTapRadius: 5, // Pixels
101865
102557
 
101866
102558
  // General
101867
102559
 
@@ -101914,7 +102606,8 @@ class CameraControl extends Component {
101914
102606
  activeTouches: [],
101915
102607
  tapStartPos: math.vec2(),
101916
102608
  tapStartTime: -1,
101917
- lastTapTime: -1
102609
+ lastTapTime: -1,
102610
+ longTouchTimeout: null
101918
102611
  };
101919
102612
 
101920
102613
  // Updates for CameraUpdater to process on next Scene "tick" event
@@ -103303,7 +103996,7 @@ class PropertySet {
103303
103996
  constructor(id, originalSystemId, name, type, properties) {
103304
103997
 
103305
103998
  /**
103306
- * Globally-unique ID.
103999
+ * Globally-unique ID for this PropertySet.
103307
104000
  *
103308
104001
  * PropertySet instances are registered by this ID in {@link MetaScene#propertySets} and {@link MetaModel#propertySets}.
103309
104002
  *
@@ -103347,7 +104040,7 @@ class PropertySet {
103347
104040
  if (properties) {
103348
104041
  for (let i = 0, len = properties.length; i < len; i++) {
103349
104042
  const property = properties[i];
103350
- this.properties.push(new Property(property.name, property.value, property.type, property.valueType, property.description));
104043
+ this.properties.push(new Property(property.name, property.value, property.type, property.valueType, property.description));
103351
104044
  }
103352
104045
  }
103353
104046
  }
@@ -104102,4 +104795,4 @@ class Viewer {
104102
104795
  }
104103
104796
  }
104104
104797
 
104105
- export { AmbientLight, AngleMeasurementsPlugin, AnnotationsPlugin, AxisGizmoPlugin, BCFViewpointsPlugin, CameraMemento, CameraPath, CameraPathAnimation, Component, ContextMenu, CubicBezierCurve, Curve, DirLight, DistanceMeasurementsPlugin, EdgeMaterial, EmphasisMaterial, FastNavPlugin, Fresnel, GLTFDefaultDataSource, GLTFLoaderPlugin, ImagePlane, LambertMaterial, LightMap, LocaleService, Map, Marker, Mesh, MetallicMaterial, ModelMemento, NavCubePlugin, Node, OBJLoaderPlugin, ObjectsMemento, Path, PerformanceModel, PhongMaterial, Plugin, PointLight, QuadraticBezierCurve, Queue, ReadableGeometry, ReflectionMap, STLDefaultDataSource, STLLoaderPlugin, SectionPlane, SectionPlanesPlugin, Skybox, SkyboxesPlugin, SpecularMaterial, SplineCurve, StoreyViewsPlugin, Texture, TreeViewPlugin, VBOGeometry, ViewCullPlugin, Viewer, XKTDefaultDataSource, XKTLoaderPlugin, XML3DLoaderPlugin, buildBoxGeometry, buildBoxLinesGeometry, buildCylinderGeometry, buildGridGeometry, buildPlaneGeometry, buildSphereGeometry, buildTorusGeometry, buildVectorTextGeometry, load3DSGeometry, loadOBJGeometry, math, utils };
104798
+ export { AmbientLight, AngleMeasurementsPlugin, AnnotationsPlugin, AxisGizmoPlugin, BCFViewpointsPlugin, CameraMemento, CameraPath, CameraPathAnimation, Component, ContextMenu, CubicBezierCurve, Curve, DirLight, DistanceMeasurementsPlugin, EdgeMaterial, EmphasisMaterial, FastNavPlugin, Fresnel, GLTFDefaultDataSource, GLTFLoaderPlugin, ImagePlane, LambertMaterial, LightMap, LocaleService, Map, Marker, Mesh, MetallicMaterial, ModelMemento, NavCubePlugin, Node, OBJLoaderPlugin, ObjectsMemento, Path, PerformanceModel, PhongMaterial, Plugin, PointLight, QuadraticBezierCurve, Queue, ReadableGeometry, ReflectionMap, STLDefaultDataSource, STLLoaderPlugin, SectionPlane, SectionPlanesPlugin, Skybox, SkyboxesPlugin, SpecularMaterial, SplineCurve, SpriteMarker, StoreyViewsPlugin, Texture, TreeViewPlugin, VBOGeometry, ViewCullPlugin, Viewer, XKTDefaultDataSource, XKTLoaderPlugin, XML3DLoaderPlugin, buildBoxGeometry, buildBoxLinesGeometry, buildCylinderGeometry, buildGridGeometry, buildPlaneGeometry, buildSphereGeometry, buildTorusGeometry, buildVectorTextGeometry, load3DSGeometry, loadOBJGeometry, math, utils };