@xeokit/xeokit-sdk 2.4.2-beta-23 → 2.4.2-beta-26

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.
@@ -27996,8 +27996,6 @@ class Scene extends Component {
27996
27996
 
27997
27997
  this._aabbDirty = true;
27998
27998
 
27999
- this._numCachedSectionPlanes = cfg.numCachedSectionPlanes || 0;
28000
-
28001
27999
  /**
28002
28000
  * The {@link Viewer} this Scene belongs to.
28003
28001
  * @type {Viewer}
@@ -28260,14 +28258,14 @@ class Scene extends Component {
28260
28258
  alphaDepthMask: alphaDepthMask
28261
28259
  });
28262
28260
 
28263
- const numCachedSectionPlanes = this._numCachedSectionPlanes;
28264
-
28265
28261
  this._sectionPlanesState = new (function () {
28266
28262
 
28267
28263
  this.sectionPlanes = [];
28268
28264
 
28269
28265
  this.clippingCaps = false;
28270
28266
 
28267
+ this._numCachedSectionPlanes = 0;
28268
+
28271
28269
  let hash = null;
28272
28270
 
28273
28271
  this.getHash = function () {
@@ -28304,12 +28302,23 @@ class Scene extends Component {
28304
28302
  }
28305
28303
  };
28306
28304
 
28305
+ this.setNumCachedSectionPlanes = function(numCachedSectionPlanes) {
28306
+ this._numCachedSectionPlanes = numCachedSectionPlanes;
28307
+ hash = null;
28308
+ };
28309
+
28310
+ this.getNumCachedSectionPlanes = function() {
28311
+ return this._numCachedSectionPlanes;
28312
+ };
28313
+
28307
28314
  this.getNumAllocatedSectionPlanes = function () {
28308
28315
  const num = this.sectionPlanes.length;
28309
- return (num > numCachedSectionPlanes) ? num : numCachedSectionPlanes;
28316
+ return (num > this._numCachedSectionPlanes) ? num : this._numCachedSectionPlanes;
28310
28317
  };
28311
28318
  })();
28312
28319
 
28320
+ this._sectionPlanesState.setNumCachedSectionPlanes(cfg.numCachedSectionPlanes || 0);
28321
+
28313
28322
  this._lightsState = new (function () {
28314
28323
 
28315
28324
  const DEFAULT_AMBIENT = math.vec4([0, 0, 0, 0]);
@@ -28854,8 +28863,12 @@ class Scene extends Component {
28854
28863
  * Default is ````0````.
28855
28864
  */
28856
28865
  set numCachedSectionPlanes(numCachedSectionPlanes) {
28857
- this._numCachedSectionPlanes = numCachedSectionPlanes;
28858
- this._recompile();
28866
+ numCachedSectionPlanes = numCachedSectionPlanes || 0;
28867
+ if (this._sectionPlanesState.getNumCachedSectionPlanes() !== numCachedSectionPlanes) {
28868
+ this._sectionPlanesState.setNumCachedSectionPlanes(numCachedSectionPlanes);
28869
+ this._needRecompile = true;
28870
+ this.glRedraw();
28871
+ }
28859
28872
  }
28860
28873
 
28861
28874
  /**
@@ -28872,7 +28885,7 @@ class Scene extends Component {
28872
28885
  * @returns {number} The number of {@link SectionPlane}s for which this Scene pre-caches resources.
28873
28886
  */
28874
28887
  get numCachedSectionPlanes() {
28875
- return this._numCachedSectionPlanes;
28888
+ return this._sectionPlanesState.getNumCachedSectionPlanes();
28876
28889
  }
28877
28890
 
28878
28891
  /**
@@ -27992,8 +27992,6 @@ class Scene extends Component {
27992
27992
 
27993
27993
  this._aabbDirty = true;
27994
27994
 
27995
- this._numCachedSectionPlanes = cfg.numCachedSectionPlanes || 0;
27996
-
27997
27995
  /**
27998
27996
  * The {@link Viewer} this Scene belongs to.
27999
27997
  * @type {Viewer}
@@ -28256,14 +28254,14 @@ class Scene extends Component {
28256
28254
  alphaDepthMask: alphaDepthMask
28257
28255
  });
28258
28256
 
28259
- const numCachedSectionPlanes = this._numCachedSectionPlanes;
28260
-
28261
28257
  this._sectionPlanesState = new (function () {
28262
28258
 
28263
28259
  this.sectionPlanes = [];
28264
28260
 
28265
28261
  this.clippingCaps = false;
28266
28262
 
28263
+ this._numCachedSectionPlanes = 0;
28264
+
28267
28265
  let hash = null;
28268
28266
 
28269
28267
  this.getHash = function () {
@@ -28300,12 +28298,23 @@ class Scene extends Component {
28300
28298
  }
28301
28299
  };
28302
28300
 
28301
+ this.setNumCachedSectionPlanes = function(numCachedSectionPlanes) {
28302
+ this._numCachedSectionPlanes = numCachedSectionPlanes;
28303
+ hash = null;
28304
+ };
28305
+
28306
+ this.getNumCachedSectionPlanes = function() {
28307
+ return this._numCachedSectionPlanes;
28308
+ };
28309
+
28303
28310
  this.getNumAllocatedSectionPlanes = function () {
28304
28311
  const num = this.sectionPlanes.length;
28305
- return (num > numCachedSectionPlanes) ? num : numCachedSectionPlanes;
28312
+ return (num > this._numCachedSectionPlanes) ? num : this._numCachedSectionPlanes;
28306
28313
  };
28307
28314
  })();
28308
28315
 
28316
+ this._sectionPlanesState.setNumCachedSectionPlanes(cfg.numCachedSectionPlanes || 0);
28317
+
28309
28318
  this._lightsState = new (function () {
28310
28319
 
28311
28320
  const DEFAULT_AMBIENT = math.vec4([0, 0, 0, 0]);
@@ -28850,8 +28859,12 @@ class Scene extends Component {
28850
28859
  * Default is ````0````.
28851
28860
  */
28852
28861
  set numCachedSectionPlanes(numCachedSectionPlanes) {
28853
- this._numCachedSectionPlanes = numCachedSectionPlanes;
28854
- this._recompile();
28862
+ numCachedSectionPlanes = numCachedSectionPlanes || 0;
28863
+ if (this._sectionPlanesState.getNumCachedSectionPlanes() !== numCachedSectionPlanes) {
28864
+ this._sectionPlanesState.setNumCachedSectionPlanes(numCachedSectionPlanes);
28865
+ this._needRecompile = true;
28866
+ this.glRedraw();
28867
+ }
28855
28868
  }
28856
28869
 
28857
28870
  /**
@@ -28868,7 +28881,7 @@ class Scene extends Component {
28868
28881
  * @returns {number} The number of {@link SectionPlane}s for which this Scene pre-caches resources.
28869
28882
  */
28870
28883
  get numCachedSectionPlanes() {
28871
- return this._numCachedSectionPlanes;
28884
+ return this._sectionPlanesState.getNumCachedSectionPlanes();
28872
28885
  }
28873
28886
 
28874
28887
  /**
@@ -8822,7 +8822,7 @@ function getEntityIDMap(scene,entityIds){var map={};var entityId;var entity;for(
8822
8822
  * @throws {String} Throws an exception when both canvasId or canvasElement are missing or they aren't pointing to a valid HTMLCanvasElement.
8823
8823
  */function Scene(viewer){var _this52;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Scene);_this52=_super33.call(this,null,cfg);var canvas=cfg.canvasElement||document.getElementById(cfg.canvasId);if(!(canvas instanceof HTMLCanvasElement)){throw"Mandatory config expected: valid canvasId or canvasElement";}/**
8824
8824
  * @type {{[key: string]: {wrapperFunc: Function, tickSubId: string}}}
8825
- */_this52._tickifiedFunctions={};var transparent=!!cfg.transparent;var alphaDepthMask=!!cfg.alphaDepthMask;_this52._aabbDirty=true;_this52._numCachedSectionPlanes=cfg.numCachedSectionPlanes||0;/**
8825
+ */_this52._tickifiedFunctions={};var transparent=!!cfg.transparent;var alphaDepthMask=!!cfg.alphaDepthMask;_this52._aabbDirty=true;/**
8826
8826
  * The {@link Viewer} this Scene belongs to.
8827
8827
  * @type {Viewer}
8828
8828
  */_this52.viewer=viewer;/** Decremented each frame, triggers occlusion test for occludable {@link Marker}s when zero.
@@ -8970,7 +8970,7 @@ _this52._needRecompile=false;/**
8970
8970
  *
8971
8971
  * @type {Canvas}
8972
8972
  */_this52.canvas=new Canvas(_assertThisInitialized(_this52),{dontClear:true,// Never destroy this component with Scene#clear();
8973
- canvas:canvas,spinnerElementId:cfg.spinnerElementId,transparent:transparent,webgl2:cfg.webgl2!==false,contextAttr:cfg.contextAttr||{},backgroundColor:cfg.backgroundColor,backgroundColorFromAmbientLight:cfg.backgroundColorFromAmbientLight,premultipliedAlpha:cfg.premultipliedAlpha});_this52.canvas.on("boundary",function(){_this52.glRedraw();});_this52.canvas.on("webglContextFailed",function(){alert("xeokit failed to find WebGL!");});_this52._renderer=new Renderer$1(_assertThisInitialized(_this52),{transparent:transparent,alphaDepthMask:alphaDepthMask});var numCachedSectionPlanes=_this52._numCachedSectionPlanes;_this52._sectionPlanesState=new function(){this.sectionPlanes=[];this.clippingCaps=false;var hash=null;this.getHash=function(){if(hash){return hash;}var numAllocatedSectionPlanes=this.getNumAllocatedSectionPlanes();this.sectionPlanes;if(numAllocatedSectionPlanes===0){return this.hash=";";}var hashParts=[];for(var _i80=0,len=numAllocatedSectionPlanes;_i80<len;_i80++){hashParts.push("cp");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addSectionPlane=function(sectionPlane){this.sectionPlanes.push(sectionPlane);hash=null;};this.removeSectionPlane=function(sectionPlane){for(var _i81=0,len=this.sectionPlanes.length;_i81<len;_i81++){if(this.sectionPlanes[_i81].id===sectionPlane.id){this.sectionPlanes.splice(_i81,1);hash=null;return;}}};this.getNumAllocatedSectionPlanes=function(){var num=this.sectionPlanes.length;return num>numCachedSectionPlanes?num:numCachedSectionPlanes;};}();_this52._lightsState=new function(){var DEFAULT_AMBIENT=math.vec4([0,0,0,0]);var ambientColorIntensity=math.vec4();this.lights=[];this.reflectionMaps=[];this.lightMaps=[];var hash=null;var ambientLight=null;this.getHash=function(){if(hash){return hash;}var hashParts=[];var lights=this.lights;var light;for(var _i82=0,len=lights.length;_i82<len;_i82++){light=lights[_i82];hashParts.push("/");hashParts.push(light.type);hashParts.push(light.space==="world"?"w":"v");if(light.castsShadow){hashParts.push("sh");}}if(this.lightMaps.length>0){hashParts.push("/lm");}if(this.reflectionMaps.length>0){hashParts.push("/rm");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addLight=function(state){this.lights.push(state);ambientLight=null;hash=null;};this.removeLight=function(state){for(var _i83=0,len=this.lights.length;_i83<len;_i83++){var light=this.lights[_i83];if(light.id===state.id){this.lights.splice(_i83,1);if(ambientLight&&ambientLight.id===state.id){ambientLight=null;}hash=null;return;}}};this.addReflectionMap=function(state){this.reflectionMaps.push(state);hash=null;};this.removeReflectionMap=function(state){for(var _i84=0,len=this.reflectionMaps.length;_i84<len;_i84++){if(this.reflectionMaps[_i84].id===state.id){this.reflectionMaps.splice(_i84,1);hash=null;return;}}};this.addLightMap=function(state){this.lightMaps.push(state);hash=null;};this.removeLightMap=function(state){for(var _i85=0,len=this.lightMaps.length;_i85<len;_i85++){if(this.lightMaps[_i85].id===state.id){this.lightMaps.splice(_i85,1);hash=null;return;}}};this.getAmbientColorAndIntensity=function(){if(!ambientLight){for(var _i86=0,len=this.lights.length;_i86<len;_i86++){var light=this.lights[_i86];if(light.type==="ambient"){ambientLight=light;break;}}}if(ambientLight){var _color2=ambientLight.color;var intensity=ambientLight.intensity;ambientColorIntensity[0]=_color2[0];ambientColorIntensity[1]=_color2[1];ambientColorIntensity[2]=_color2[2];ambientColorIntensity[3]=intensity;return ambientColorIntensity;}else{return DEFAULT_AMBIENT;}};}();/**
8973
+ canvas:canvas,spinnerElementId:cfg.spinnerElementId,transparent:transparent,webgl2:cfg.webgl2!==false,contextAttr:cfg.contextAttr||{},backgroundColor:cfg.backgroundColor,backgroundColorFromAmbientLight:cfg.backgroundColorFromAmbientLight,premultipliedAlpha:cfg.premultipliedAlpha});_this52.canvas.on("boundary",function(){_this52.glRedraw();});_this52.canvas.on("webglContextFailed",function(){alert("xeokit failed to find WebGL!");});_this52._renderer=new Renderer$1(_assertThisInitialized(_this52),{transparent:transparent,alphaDepthMask:alphaDepthMask});_this52._sectionPlanesState=new function(){this.sectionPlanes=[];this.clippingCaps=false;this._numCachedSectionPlanes=0;var hash=null;this.getHash=function(){if(hash){return hash;}var numAllocatedSectionPlanes=this.getNumAllocatedSectionPlanes();this.sectionPlanes;if(numAllocatedSectionPlanes===0){return this.hash=";";}var hashParts=[];for(var _i80=0,len=numAllocatedSectionPlanes;_i80<len;_i80++){hashParts.push("cp");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addSectionPlane=function(sectionPlane){this.sectionPlanes.push(sectionPlane);hash=null;};this.removeSectionPlane=function(sectionPlane){for(var _i81=0,len=this.sectionPlanes.length;_i81<len;_i81++){if(this.sectionPlanes[_i81].id===sectionPlane.id){this.sectionPlanes.splice(_i81,1);hash=null;return;}}};this.setNumCachedSectionPlanes=function(numCachedSectionPlanes){this._numCachedSectionPlanes=numCachedSectionPlanes;hash=null;};this.getNumCachedSectionPlanes=function(){return this._numCachedSectionPlanes;};this.getNumAllocatedSectionPlanes=function(){var num=this.sectionPlanes.length;return num>this._numCachedSectionPlanes?num:this._numCachedSectionPlanes;};}();_this52._sectionPlanesState.setNumCachedSectionPlanes(cfg.numCachedSectionPlanes||0);_this52._lightsState=new function(){var DEFAULT_AMBIENT=math.vec4([0,0,0,0]);var ambientColorIntensity=math.vec4();this.lights=[];this.reflectionMaps=[];this.lightMaps=[];var hash=null;var ambientLight=null;this.getHash=function(){if(hash){return hash;}var hashParts=[];var lights=this.lights;var light;for(var _i82=0,len=lights.length;_i82<len;_i82++){light=lights[_i82];hashParts.push("/");hashParts.push(light.type);hashParts.push(light.space==="world"?"w":"v");if(light.castsShadow){hashParts.push("sh");}}if(this.lightMaps.length>0){hashParts.push("/lm");}if(this.reflectionMaps.length>0){hashParts.push("/rm");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addLight=function(state){this.lights.push(state);ambientLight=null;hash=null;};this.removeLight=function(state){for(var _i83=0,len=this.lights.length;_i83<len;_i83++){var light=this.lights[_i83];if(light.id===state.id){this.lights.splice(_i83,1);if(ambientLight&&ambientLight.id===state.id){ambientLight=null;}hash=null;return;}}};this.addReflectionMap=function(state){this.reflectionMaps.push(state);hash=null;};this.removeReflectionMap=function(state){for(var _i84=0,len=this.reflectionMaps.length;_i84<len;_i84++){if(this.reflectionMaps[_i84].id===state.id){this.reflectionMaps.splice(_i84,1);hash=null;return;}}};this.addLightMap=function(state){this.lightMaps.push(state);hash=null;};this.removeLightMap=function(state){for(var _i85=0,len=this.lightMaps.length;_i85<len;_i85++){if(this.lightMaps[_i85].id===state.id){this.lightMaps.splice(_i85,1);hash=null;return;}}};this.getAmbientColorAndIntensity=function(){if(!ambientLight){for(var _i86=0,len=this.lights.length;_i86<len;_i86++){var light=this.lights[_i86];if(light.type==="ambient"){ambientLight=light;break;}}}if(ambientLight){var _color2=ambientLight.color;var intensity=ambientLight.intensity;ambientColorIntensity[0]=_color2[0];ambientColorIntensity[1]=_color2[1];ambientColorIntensity[2]=_color2[2];ambientColorIntensity[3]=intensity;return ambientColorIntensity;}else{return DEFAULT_AMBIENT;}};}();/**
8974
8974
  * Publishes input events that occur on this Scene's canvas.
8975
8975
  *
8976
8976
  * @property input
@@ -9065,11 +9065,11 @@ this.canvas.spinner.processes--;}/**
9065
9065
  * Default is ````0````.
9066
9066
  *
9067
9067
  * @returns {number} The number of {@link SectionPlane}s for which this Scene pre-caches resources.
9068
- */function get(){return this._numCachedSectionPlanes;}/**
9068
+ */function get(){return this._sectionPlanesState.getNumCachedSectionPlanes();}/**
9069
9069
  * Sets whether physically-based rendering is enabled.
9070
9070
  *
9071
9071
  * Default is ````false````.
9072
- */,set:function set(numCachedSectionPlanes){this._numCachedSectionPlanes=numCachedSectionPlanes;this._recompile();}},{key:"pbrEnabled",get:/**
9072
+ */,set:function set(numCachedSectionPlanes){numCachedSectionPlanes=numCachedSectionPlanes||0;if(this._sectionPlanesState.getNumCachedSectionPlanes()!==numCachedSectionPlanes){this._sectionPlanesState.setNumCachedSectionPlanes(numCachedSectionPlanes);this._needRecompile=true;this.glRedraw();}}},{key:"pbrEnabled",get:/**
9073
9073
  * Gets whether physically-based rendering is enabled.
9074
9074
  *
9075
9075
  * Default is ````false````.