@xeokit/xeokit-sdk 2.4.0-alpha-101 → 2.4.0-alpha-104

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.
@@ -45983,7 +45983,10 @@ class Bitmap extends Component {
45983
45983
  this._rtcPos = math.vec3();
45984
45984
  this._imageSize = math.vec2();
45985
45985
 
45986
- this._texture = new Texture(this);
45986
+ this._texture = new Texture(this, {
45987
+ flipY: true
45988
+ });
45989
+
45987
45990
  this._image = new Image();
45988
45991
 
45989
45992
  if (this._type !== "jpg" && this._type !== "png") {
@@ -46356,6 +46359,116 @@ class Bitmap extends Component {
46356
46359
  }
46357
46360
  }
46358
46361
 
46362
+ const tempVec3a$v = math.vec3();
46363
+ const tempVec3b$q = math.vec3();
46364
+ const tempMat4a$h = math.mat4();
46365
+
46366
+ /**
46367
+ * @private
46368
+ */
46369
+ class FrustumPlane {
46370
+
46371
+ constructor() {
46372
+ this.normal = math.vec3();
46373
+ this.offset = 0;
46374
+ this.testVertex = math.vec3();
46375
+ }
46376
+
46377
+ set(nx, ny, nz, offset) {
46378
+ const s = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
46379
+ this.normal[0] = nx * s;
46380
+ this.normal[1] = ny * s;
46381
+ this.normal[2] = nz * s;
46382
+ this.offset = offset * s;
46383
+ this.testVertex[0] = (this.normal[0] >= 0.0) ? 1 : 0;
46384
+ this.testVertex[1] = (this.normal[1] >= 0.0) ? 1 : 0;
46385
+ this.testVertex[2] = (this.normal[2] >= 0.0) ? 1 : 0;
46386
+ }
46387
+ }
46388
+
46389
+ /**
46390
+ * @private
46391
+ */
46392
+ class Frustum {
46393
+ constructor() {
46394
+ this.planes = [
46395
+ new FrustumPlane(), new FrustumPlane(), new FrustumPlane(),
46396
+ new FrustumPlane(), new FrustumPlane(), new FrustumPlane()
46397
+ ];
46398
+ }
46399
+ }
46400
+
46401
+ Frustum.INSIDE = 0;
46402
+ Frustum.INTERSECT = 1;
46403
+ Frustum.OUTSIDE = 2;
46404
+
46405
+ /** @private */
46406
+ function setFrustum(frustum, viewMat, projMat) {
46407
+
46408
+ const m = math.mulMat4(projMat, viewMat, tempMat4a$h);
46409
+
46410
+ const m0 = m[0];
46411
+ const m1 = m[1];
46412
+ const m2 = m[2];
46413
+ const m3 = m[3];
46414
+ const m4 = m[4];
46415
+ const m5 = m[5];
46416
+ const m6 = m[6];
46417
+ const m7 = m[7];
46418
+ const m8 = m[8];
46419
+ const m9 = m[9];
46420
+ const m10 = m[10];
46421
+ const m11 = m[11];
46422
+ const m12 = m[12];
46423
+ const m13 = m[13];
46424
+ const m14 = m[14];
46425
+ const m15 = m[15];
46426
+
46427
+ frustum.planes[0].set(m3 - m0, m7 - m4, m11 - m8, m15 - m12);
46428
+ frustum.planes[1].set(m3 + m0, m7 + m4, m11 + m8, m15 + m12);
46429
+ frustum.planes[2].set(m3 - m1, m7 - m5, m11 - m9, m15 - m13);
46430
+ frustum.planes[3].set(m3 + m1, m7 + m5, m11 + m9, m15 + m13);
46431
+ frustum.planes[4].set(m3 - m2, m7 - m6, m11 - m10, m15 - m14);
46432
+ frustum.planes[5].set(m3 + m2, m7 + m6, m11 + m10, m15 + m14);
46433
+ }
46434
+
46435
+ /** @private */
46436
+ function frustumIntersectsAABB3(frustum, aabb) {
46437
+
46438
+ let ret = Frustum.INSIDE;
46439
+
46440
+ const min = tempVec3a$v;
46441
+ const max = tempVec3b$q;
46442
+
46443
+ min[0] = aabb[0];
46444
+ min[1] = aabb[1];
46445
+ min[2] = aabb[2];
46446
+ max[0] = aabb[3];
46447
+ max[1] = aabb[4];
46448
+ max[2] = aabb[5];
46449
+
46450
+ const bminmax = [min, max];
46451
+
46452
+ for (let i = 0; i < 6; ++i) {
46453
+ const plane = frustum.planes[i];
46454
+ if (((plane.normal[0] * bminmax[plane.testVertex[0]][0]) +
46455
+ (plane.normal[1] * bminmax[plane.testVertex[1]][1]) +
46456
+ (plane.normal[2] * bminmax[plane.testVertex[2]][2]) +
46457
+ (plane.offset)) < 0.0) {
46458
+ return Frustum.OUTSIDE;
46459
+ }
46460
+
46461
+ if (((plane.normal[0] * bminmax[1 - plane.testVertex[0]][0]) +
46462
+ (plane.normal[1] * bminmax[1 - plane.testVertex[1]][1]) +
46463
+ (plane.normal[2] * bminmax[1 - plane.testVertex[2]][2]) +
46464
+ (plane.offset)) < 0.0) {
46465
+ ret = Frustum.INTERSECT;
46466
+ }
46467
+ }
46468
+
46469
+ return ret;
46470
+ }
46471
+
46359
46472
  /**
46360
46473
  * A set of 3D line segments.
46361
46474
  *
@@ -46430,8 +46543,10 @@ class LineSet extends Component {
46430
46543
  super(owner, cfg);
46431
46544
 
46432
46545
  this._positions = cfg.positions || [];
46433
-
46434
- this._origin = math.vec3(cfg.origin || [0, 0, 0]);
46546
+ const rtcPositions = new Float32Array(this._positions.length);
46547
+ const rtcCenter = math.vec3();
46548
+ const cellSize = 100;
46549
+ const rtcNeeded = worldToRTCPositions(this._positions, new Float32Array(this._positions.length), rtcCenter, cellSize);
46435
46550
 
46436
46551
  if (cfg.indices) {
46437
46552
  this._indices = cfg.indices;
@@ -46449,9 +46564,9 @@ class LineSet extends Component {
46449
46564
  collidable: cfg.collidable,
46450
46565
  geometry: new VBOGeometry(this, {
46451
46566
  primitive: "lines",
46452
- positions: this._positions,
46567
+ positions: rtcNeeded ? rtcPositions : this._positions,
46453
46568
  indices: this._indices,
46454
- origin: cfg.origin
46569
+ origin: rtcNeeded ? rtcCenter : null
46455
46570
  }),
46456
46571
  material: new PhongMaterial(this, {
46457
46572
  diffuse: cfg.color || [0, 0, 0],
@@ -46514,8 +46629,8 @@ class LineSet extends Component {
46514
46629
  }
46515
46630
 
46516
46631
  const tempVec3$5 = math.vec3();
46517
- const tempVec3a$v = math.vec3();
46518
- const tempVec3b$q = math.vec3();
46632
+ const tempVec3a$u = math.vec3();
46633
+ const tempVec3b$p = math.vec3();
46519
46634
  const tempVec3c$m = math.vec3();
46520
46635
 
46521
46636
  /**
@@ -47195,8 +47310,8 @@ class BCFViewpointsPlugin extends Plugin {
47195
47310
  bcfViewpoint.bitmaps.forEach(function (e) {
47196
47311
  const bitmap_type = e.bitmap_type || "jpg"; // "jpg" | "png"
47197
47312
  const bitmap_data = e.bitmap_data; // base64
47198
- let location = xyzObjectToArray(e.location, tempVec3a$v);
47199
- let normal = xyzObjectToArray(e.normal, tempVec3b$q);
47313
+ let location = xyzObjectToArray(e.location, tempVec3a$u);
47314
+ let normal = xyzObjectToArray(e.normal, tempVec3b$p);
47200
47315
  let up = xyzObjectToArray(e.up, tempVec3c$m);
47201
47316
  let height = e.height || 1;
47202
47317
  if (!bitmap_type) {
@@ -50592,7 +50707,7 @@ class SplineCurve extends Curve {
50592
50707
  }
50593
50708
  }
50594
50709
 
50595
- const tempVec3a$u = math.vec3();
50710
+ const tempVec3a$t = math.vec3();
50596
50711
 
50597
50712
  /**
50598
50713
  * @desc Defines a sequence of frames along which a {@link CameraPathAnimation} can animate a {@link Camera}.
@@ -50724,9 +50839,9 @@ class CameraPath extends Component {
50724
50839
  t = t / (this._frames[this._frames.length - 1].t - this._frames[0].t);
50725
50840
  t = t < 0.0 ? 0.0 : (t > 1.0 ? 1.0 : t);
50726
50841
 
50727
- camera.eye = this._eyeCurve.getPoint(t, tempVec3a$u);
50728
- camera.look = this._lookCurve.getPoint(t, tempVec3a$u);
50729
- camera.up = this._upCurve.getPoint(t, tempVec3a$u);
50842
+ camera.eye = this._eyeCurve.getPoint(t, tempVec3a$t);
50843
+ camera.look = this._lookCurve.getPoint(t, tempVec3a$t);
50844
+ camera.up = this._upCurve.getPoint(t, tempVec3a$t);
50730
50845
  }
50731
50846
 
50732
50847
  /**
@@ -51765,7 +51880,7 @@ CameraPathAnimation.PLAYING = 2;
51765
51880
  CameraPathAnimation.PLAYING_TO = 3;
51766
51881
 
51767
51882
  const tempVec3$3 = math.vec3();
51768
- const tempVec3b$p = math.vec3();
51883
+ const tempVec3b$o = math.vec3();
51769
51884
  math.vec3();
51770
51885
  const zeroVec$2 = math.vec3([0, -1, 0]);
51771
51886
  const tempQuat = math.vec4([0, 0, 0, 1]);
@@ -52193,7 +52308,7 @@ class ImagePlane extends Component {
52193
52308
  const dist = -math.dotVec3(negDir, tempVec3$3);
52194
52309
 
52195
52310
  math.normalizeVec3(negDir);
52196
- math.mulVec3Scalar(negDir, dist, tempVec3b$p);
52311
+ math.mulVec3Scalar(negDir, dist, tempVec3b$o);
52197
52312
  math.vec3PairToQuaternion(zeroVec$2, dir, tempQuat);
52198
52313
 
52199
52314
  this._node.quaternion = tempQuat;
@@ -53359,116 +53474,6 @@ class SpriteMarker extends Marker {
53359
53474
  }
53360
53475
  }
53361
53476
 
53362
- const tempVec3a$t = math.vec3();
53363
- const tempVec3b$o = math.vec3();
53364
- const tempMat4a$h = math.mat4();
53365
-
53366
- /**
53367
- * @private
53368
- */
53369
- class FrustumPlane {
53370
-
53371
- constructor() {
53372
- this.normal = math.vec3();
53373
- this.offset = 0;
53374
- this.testVertex = math.vec3();
53375
- }
53376
-
53377
- set(nx, ny, nz, offset) {
53378
- const s = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
53379
- this.normal[0] = nx * s;
53380
- this.normal[1] = ny * s;
53381
- this.normal[2] = nz * s;
53382
- this.offset = offset * s;
53383
- this.testVertex[0] = (this.normal[0] >= 0.0) ? 1 : 0;
53384
- this.testVertex[1] = (this.normal[1] >= 0.0) ? 1 : 0;
53385
- this.testVertex[2] = (this.normal[2] >= 0.0) ? 1 : 0;
53386
- }
53387
- }
53388
-
53389
- /**
53390
- * @private
53391
- */
53392
- class Frustum {
53393
- constructor() {
53394
- this.planes = [
53395
- new FrustumPlane(), new FrustumPlane(), new FrustumPlane(),
53396
- new FrustumPlane(), new FrustumPlane(), new FrustumPlane()
53397
- ];
53398
- }
53399
- }
53400
-
53401
- Frustum.INSIDE = 0;
53402
- Frustum.INTERSECT = 1;
53403
- Frustum.OUTSIDE = 2;
53404
-
53405
- /** @private */
53406
- function setFrustum(frustum, viewMat, projMat) {
53407
-
53408
- const m = math.mulMat4(projMat, viewMat, tempMat4a$h);
53409
-
53410
- const m0 = m[0];
53411
- const m1 = m[1];
53412
- const m2 = m[2];
53413
- const m3 = m[3];
53414
- const m4 = m[4];
53415
- const m5 = m[5];
53416
- const m6 = m[6];
53417
- const m7 = m[7];
53418
- const m8 = m[8];
53419
- const m9 = m[9];
53420
- const m10 = m[10];
53421
- const m11 = m[11];
53422
- const m12 = m[12];
53423
- const m13 = m[13];
53424
- const m14 = m[14];
53425
- const m15 = m[15];
53426
-
53427
- frustum.planes[0].set(m3 - m0, m7 - m4, m11 - m8, m15 - m12);
53428
- frustum.planes[1].set(m3 + m0, m7 + m4, m11 + m8, m15 + m12);
53429
- frustum.planes[2].set(m3 - m1, m7 - m5, m11 - m9, m15 - m13);
53430
- frustum.planes[3].set(m3 + m1, m7 + m5, m11 + m9, m15 + m13);
53431
- frustum.planes[4].set(m3 - m2, m7 - m6, m11 - m10, m15 - m14);
53432
- frustum.planes[5].set(m3 + m2, m7 + m6, m11 + m10, m15 + m14);
53433
- }
53434
-
53435
- /** @private */
53436
- function frustumIntersectsAABB3(frustum, aabb) {
53437
-
53438
- let ret = Frustum.INSIDE;
53439
-
53440
- const min = tempVec3a$t;
53441
- const max = tempVec3b$o;
53442
-
53443
- min[0] = aabb[0];
53444
- min[1] = aabb[1];
53445
- min[2] = aabb[2];
53446
- max[0] = aabb[3];
53447
- max[1] = aabb[4];
53448
- max[2] = aabb[5];
53449
-
53450
- const bminmax = [min, max];
53451
-
53452
- for (let i = 0; i < 6; ++i) {
53453
- const plane = frustum.planes[i];
53454
- if (((plane.normal[0] * bminmax[plane.testVertex[0]][0]) +
53455
- (plane.normal[1] * bminmax[plane.testVertex[1]][1]) +
53456
- (plane.normal[2] * bminmax[plane.testVertex[2]][2]) +
53457
- (plane.offset)) < 0.0) {
53458
- return Frustum.OUTSIDE;
53459
- }
53460
-
53461
- if (((plane.normal[0] * bminmax[1 - plane.testVertex[0]][0]) +
53462
- (plane.normal[1] * bminmax[1 - plane.testVertex[1]][1]) +
53463
- (plane.normal[2] * bminmax[1 - plane.testVertex[2]][2]) +
53464
- (plane.offset)) < 0.0) {
53465
- ret = Frustum.INTERSECT;
53466
- }
53467
- }
53468
-
53469
- return ret;
53470
- }
53471
-
53472
53477
  /**
53473
53478
  * @desc Saves and restores the state of a {@link Scene}'s {@link Camera}.
53474
53479
  *
@@ -73271,9 +73276,9 @@ class TrianglesDataTextureColorRenderer {
73271
73276
 
73272
73277
  src.push("uniform int renderPass;");
73273
73278
 
73274
- if (scene.entityOffsetsEnabled) {
73275
- src.push("in vec3 offset;");
73276
- }
73279
+ // if (scene.entityOffsetsEnabled) {
73280
+ // src.push("in vec3 offset;");
73281
+ // }
73277
73282
 
73278
73283
  src.push("uniform mat4 sceneModelWorldMatrix;");
73279
73284
  src.push("uniform mat4 viewMatrix;");
@@ -74039,7 +74044,6 @@ const defaultColor = new Float32Array([0, 0, 0, 1]);
74039
74044
 
74040
74045
  const tempVec3a$i = math.vec3();
74041
74046
  const tempVec3b$e = math.vec3();
74042
- math.vec3();
74043
74047
  const tempVec3d$8 = math.vec3();
74044
74048
  const tempMat4a$9 = math.mat4();
74045
74049
 
@@ -74102,8 +74106,7 @@ class TrianglesDataTextureEdgesRenderer {
74102
74106
  if (gotOrigin || gotPosition) {
74103
74107
  const rtcOrigin = tempVec3a$i;
74104
74108
  if (gotOrigin) {
74105
- const rotatedOrigin = tempVec3b$e;
74106
- math.transformPoint3(rotationMatrix, origin, rotatedOrigin);
74109
+ const rotatedOrigin = math.transformPoint3(rotationMatrix, origin, tempVec3b$e);
74107
74110
  rtcOrigin[0] = rotatedOrigin[0];
74108
74111
  rtcOrigin[1] = rotatedOrigin[1];
74109
74112
  rtcOrigin[2] = rotatedOrigin[2];
@@ -74285,9 +74288,9 @@ class TrianglesDataTextureEdgesRenderer {
74285
74288
 
74286
74289
  src.push("uniform int renderPass;");
74287
74290
 
74288
- if (scene.entityOffsetsEnabled) {
74289
- src.push("in vec3 offset;");
74290
- }
74291
+ // if (scene.entityOffsetsEnabled) {
74292
+ // src.push("in vec3 offset;");
74293
+ // }
74291
74294
 
74292
74295
  src.push("uniform mat4 sceneModelWorldMatrix;");
74293
74296
  src.push("uniform mat4 viewMatrix;");
@@ -74372,7 +74375,7 @@ class TrianglesDataTextureEdgesRenderer {
74372
74375
  // get XYZ offset
74373
74376
  src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");
74374
74377
 
74375
- src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
74378
+ src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz + vec3(110.0,50.0, 10.0);");
74376
74379
 
74377
74380
  src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
74378
74381
 
@@ -74522,8 +74525,7 @@ class TrianglesDataTextureEdgesColorRenderer {
74522
74525
  if (gotOrigin || gotPosition) {
74523
74526
  const rtcOrigin = tempVec3a$h;
74524
74527
  if (gotOrigin) {
74525
- const rotatedOrigin = tempVec3b$d;
74526
- math.transformPoint3(rotationMatrix, origin, rotatedOrigin);
74528
+ const rotatedOrigin = math.transformPoint3(rotationMatrix, origin, tempVec3b$d);
74527
74529
  rtcOrigin[0] = rotatedOrigin[0];
74528
74530
  rtcOrigin[1] = rotatedOrigin[1];
74529
74531
  rtcOrigin[2] = rotatedOrigin[2];
@@ -74790,7 +74792,7 @@ class TrianglesDataTextureEdgesColorRenderer {
74790
74792
  // get XYZ offset
74791
74793
  src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");
74792
74794
 
74793
- // src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
74795
+ src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
74794
74796
 
74795
74797
  src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
74796
74798
 
@@ -82917,7 +82919,7 @@ class SceneModel extends Component {
82917
82919
  cfg.primitive = "triangles";
82918
82920
  }
82919
82921
  if (cfg.primitive !== "points" && cfg.primitive !== "lines" && cfg.primitive !== "triangles" && cfg.primitive !== "solid" && cfg.primitive !== "surface") {
82920
- this.error(`[createGeometry] Unsupported value for 'primitive': '${primitive}' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'.`);
82922
+ this.error(`[createGeometry] Unsupported value for 'primitive': '${cfg.primitive}' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'.`);
82921
82923
  return;
82922
82924
  }
82923
82925
  if (!cfg.positions && !cfg.positionsCompressed && !cfg.buckets) {
@@ -85867,12 +85869,13 @@ class MousePickHandler {
85867
85869
  }
85868
85870
 
85869
85871
  const hoverSubs = cameraControl.hasSubs("hover");
85872
+ const hoverEnterSubs = cameraControl.hasSubs("hoverEnter");
85870
85873
  const hoverOutSubs = cameraControl.hasSubs("hoverOut");
85871
85874
  const hoverOffSubs = cameraControl.hasSubs("hoverOff");
85872
85875
  const hoverSurfaceSubs = cameraControl.hasSubs("hoverSurface");
85873
85876
  const hoverSnapOrSurfaceSubs = cameraControl.hasSubs("hoverSnapOrSurface");
85874
85877
 
85875
- if (hoverSubs || hoverOutSubs || hoverOffSubs || hoverSurfaceSubs || hoverSnapOrSurfaceSubs) {
85878
+ if (hoverSubs || hoverEnterSubs || hoverOutSubs || hoverOffSubs || hoverSurfaceSubs || hoverSnapOrSurfaceSubs) {
85876
85879
 
85877
85880
  pickController.pickCursorPos = states.pointerCanvasPos;
85878
85881
  pickController.schedulePickEntity = true;