@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.
@@ -45987,7 +45987,10 @@ class Bitmap extends Component {
45987
45987
  this._rtcPos = math.vec3();
45988
45988
  this._imageSize = math.vec2();
45989
45989
 
45990
- this._texture = new Texture(this);
45990
+ this._texture = new Texture(this, {
45991
+ flipY: true
45992
+ });
45993
+
45991
45994
  this._image = new Image();
45992
45995
 
45993
45996
  if (this._type !== "jpg" && this._type !== "png") {
@@ -46360,6 +46363,116 @@ class Bitmap extends Component {
46360
46363
  }
46361
46364
  }
46362
46365
 
46366
+ const tempVec3a$v = math.vec3();
46367
+ const tempVec3b$q = math.vec3();
46368
+ const tempMat4a$h = math.mat4();
46369
+
46370
+ /**
46371
+ * @private
46372
+ */
46373
+ class FrustumPlane {
46374
+
46375
+ constructor() {
46376
+ this.normal = math.vec3();
46377
+ this.offset = 0;
46378
+ this.testVertex = math.vec3();
46379
+ }
46380
+
46381
+ set(nx, ny, nz, offset) {
46382
+ const s = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
46383
+ this.normal[0] = nx * s;
46384
+ this.normal[1] = ny * s;
46385
+ this.normal[2] = nz * s;
46386
+ this.offset = offset * s;
46387
+ this.testVertex[0] = (this.normal[0] >= 0.0) ? 1 : 0;
46388
+ this.testVertex[1] = (this.normal[1] >= 0.0) ? 1 : 0;
46389
+ this.testVertex[2] = (this.normal[2] >= 0.0) ? 1 : 0;
46390
+ }
46391
+ }
46392
+
46393
+ /**
46394
+ * @private
46395
+ */
46396
+ class Frustum {
46397
+ constructor() {
46398
+ this.planes = [
46399
+ new FrustumPlane(), new FrustumPlane(), new FrustumPlane(),
46400
+ new FrustumPlane(), new FrustumPlane(), new FrustumPlane()
46401
+ ];
46402
+ }
46403
+ }
46404
+
46405
+ Frustum.INSIDE = 0;
46406
+ Frustum.INTERSECT = 1;
46407
+ Frustum.OUTSIDE = 2;
46408
+
46409
+ /** @private */
46410
+ function setFrustum(frustum, viewMat, projMat) {
46411
+
46412
+ const m = math.mulMat4(projMat, viewMat, tempMat4a$h);
46413
+
46414
+ const m0 = m[0];
46415
+ const m1 = m[1];
46416
+ const m2 = m[2];
46417
+ const m3 = m[3];
46418
+ const m4 = m[4];
46419
+ const m5 = m[5];
46420
+ const m6 = m[6];
46421
+ const m7 = m[7];
46422
+ const m8 = m[8];
46423
+ const m9 = m[9];
46424
+ const m10 = m[10];
46425
+ const m11 = m[11];
46426
+ const m12 = m[12];
46427
+ const m13 = m[13];
46428
+ const m14 = m[14];
46429
+ const m15 = m[15];
46430
+
46431
+ frustum.planes[0].set(m3 - m0, m7 - m4, m11 - m8, m15 - m12);
46432
+ frustum.planes[1].set(m3 + m0, m7 + m4, m11 + m8, m15 + m12);
46433
+ frustum.planes[2].set(m3 - m1, m7 - m5, m11 - m9, m15 - m13);
46434
+ frustum.planes[3].set(m3 + m1, m7 + m5, m11 + m9, m15 + m13);
46435
+ frustum.planes[4].set(m3 - m2, m7 - m6, m11 - m10, m15 - m14);
46436
+ frustum.planes[5].set(m3 + m2, m7 + m6, m11 + m10, m15 + m14);
46437
+ }
46438
+
46439
+ /** @private */
46440
+ function frustumIntersectsAABB3(frustum, aabb) {
46441
+
46442
+ let ret = Frustum.INSIDE;
46443
+
46444
+ const min = tempVec3a$v;
46445
+ const max = tempVec3b$q;
46446
+
46447
+ min[0] = aabb[0];
46448
+ min[1] = aabb[1];
46449
+ min[2] = aabb[2];
46450
+ max[0] = aabb[3];
46451
+ max[1] = aabb[4];
46452
+ max[2] = aabb[5];
46453
+
46454
+ const bminmax = [min, max];
46455
+
46456
+ for (let i = 0; i < 6; ++i) {
46457
+ const plane = frustum.planes[i];
46458
+ if (((plane.normal[0] * bminmax[plane.testVertex[0]][0]) +
46459
+ (plane.normal[1] * bminmax[plane.testVertex[1]][1]) +
46460
+ (plane.normal[2] * bminmax[plane.testVertex[2]][2]) +
46461
+ (plane.offset)) < 0.0) {
46462
+ return Frustum.OUTSIDE;
46463
+ }
46464
+
46465
+ if (((plane.normal[0] * bminmax[1 - plane.testVertex[0]][0]) +
46466
+ (plane.normal[1] * bminmax[1 - plane.testVertex[1]][1]) +
46467
+ (plane.normal[2] * bminmax[1 - plane.testVertex[2]][2]) +
46468
+ (plane.offset)) < 0.0) {
46469
+ ret = Frustum.INTERSECT;
46470
+ }
46471
+ }
46472
+
46473
+ return ret;
46474
+ }
46475
+
46363
46476
  /**
46364
46477
  * A set of 3D line segments.
46365
46478
  *
@@ -46434,8 +46547,10 @@ class LineSet extends Component {
46434
46547
  super(owner, cfg);
46435
46548
 
46436
46549
  this._positions = cfg.positions || [];
46437
-
46438
- this._origin = math.vec3(cfg.origin || [0, 0, 0]);
46550
+ const rtcPositions = new Float32Array(this._positions.length);
46551
+ const rtcCenter = math.vec3();
46552
+ const cellSize = 100;
46553
+ const rtcNeeded = worldToRTCPositions(this._positions, new Float32Array(this._positions.length), rtcCenter, cellSize);
46439
46554
 
46440
46555
  if (cfg.indices) {
46441
46556
  this._indices = cfg.indices;
@@ -46453,9 +46568,9 @@ class LineSet extends Component {
46453
46568
  collidable: cfg.collidable,
46454
46569
  geometry: new VBOGeometry(this, {
46455
46570
  primitive: "lines",
46456
- positions: this._positions,
46571
+ positions: rtcNeeded ? rtcPositions : this._positions,
46457
46572
  indices: this._indices,
46458
- origin: cfg.origin
46573
+ origin: rtcNeeded ? rtcCenter : null
46459
46574
  }),
46460
46575
  material: new PhongMaterial(this, {
46461
46576
  diffuse: cfg.color || [0, 0, 0],
@@ -46518,8 +46633,8 @@ class LineSet extends Component {
46518
46633
  }
46519
46634
 
46520
46635
  const tempVec3$5 = math.vec3();
46521
- const tempVec3a$v = math.vec3();
46522
- const tempVec3b$q = math.vec3();
46636
+ const tempVec3a$u = math.vec3();
46637
+ const tempVec3b$p = math.vec3();
46523
46638
  const tempVec3c$m = math.vec3();
46524
46639
 
46525
46640
  /**
@@ -47199,8 +47314,8 @@ class BCFViewpointsPlugin extends Plugin {
47199
47314
  bcfViewpoint.bitmaps.forEach(function (e) {
47200
47315
  const bitmap_type = e.bitmap_type || "jpg"; // "jpg" | "png"
47201
47316
  const bitmap_data = e.bitmap_data; // base64
47202
- let location = xyzObjectToArray(e.location, tempVec3a$v);
47203
- let normal = xyzObjectToArray(e.normal, tempVec3b$q);
47317
+ let location = xyzObjectToArray(e.location, tempVec3a$u);
47318
+ let normal = xyzObjectToArray(e.normal, tempVec3b$p);
47204
47319
  let up = xyzObjectToArray(e.up, tempVec3c$m);
47205
47320
  let height = e.height || 1;
47206
47321
  if (!bitmap_type) {
@@ -50596,7 +50711,7 @@ class SplineCurve extends Curve {
50596
50711
  }
50597
50712
  }
50598
50713
 
50599
- const tempVec3a$u = math.vec3();
50714
+ const tempVec3a$t = math.vec3();
50600
50715
 
50601
50716
  /**
50602
50717
  * @desc Defines a sequence of frames along which a {@link CameraPathAnimation} can animate a {@link Camera}.
@@ -50728,9 +50843,9 @@ class CameraPath extends Component {
50728
50843
  t = t / (this._frames[this._frames.length - 1].t - this._frames[0].t);
50729
50844
  t = t < 0.0 ? 0.0 : (t > 1.0 ? 1.0 : t);
50730
50845
 
50731
- camera.eye = this._eyeCurve.getPoint(t, tempVec3a$u);
50732
- camera.look = this._lookCurve.getPoint(t, tempVec3a$u);
50733
- camera.up = this._upCurve.getPoint(t, tempVec3a$u);
50846
+ camera.eye = this._eyeCurve.getPoint(t, tempVec3a$t);
50847
+ camera.look = this._lookCurve.getPoint(t, tempVec3a$t);
50848
+ camera.up = this._upCurve.getPoint(t, tempVec3a$t);
50734
50849
  }
50735
50850
 
50736
50851
  /**
@@ -51769,7 +51884,7 @@ CameraPathAnimation.PLAYING = 2;
51769
51884
  CameraPathAnimation.PLAYING_TO = 3;
51770
51885
 
51771
51886
  const tempVec3$3 = math.vec3();
51772
- const tempVec3b$p = math.vec3();
51887
+ const tempVec3b$o = math.vec3();
51773
51888
  math.vec3();
51774
51889
  const zeroVec$2 = math.vec3([0, -1, 0]);
51775
51890
  const tempQuat = math.vec4([0, 0, 0, 1]);
@@ -52197,7 +52312,7 @@ class ImagePlane extends Component {
52197
52312
  const dist = -math.dotVec3(negDir, tempVec3$3);
52198
52313
 
52199
52314
  math.normalizeVec3(negDir);
52200
- math.mulVec3Scalar(negDir, dist, tempVec3b$p);
52315
+ math.mulVec3Scalar(negDir, dist, tempVec3b$o);
52201
52316
  math.vec3PairToQuaternion(zeroVec$2, dir, tempQuat);
52202
52317
 
52203
52318
  this._node.quaternion = tempQuat;
@@ -53363,116 +53478,6 @@ class SpriteMarker extends Marker {
53363
53478
  }
53364
53479
  }
53365
53480
 
53366
- const tempVec3a$t = math.vec3();
53367
- const tempVec3b$o = math.vec3();
53368
- const tempMat4a$h = math.mat4();
53369
-
53370
- /**
53371
- * @private
53372
- */
53373
- class FrustumPlane {
53374
-
53375
- constructor() {
53376
- this.normal = math.vec3();
53377
- this.offset = 0;
53378
- this.testVertex = math.vec3();
53379
- }
53380
-
53381
- set(nx, ny, nz, offset) {
53382
- const s = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
53383
- this.normal[0] = nx * s;
53384
- this.normal[1] = ny * s;
53385
- this.normal[2] = nz * s;
53386
- this.offset = offset * s;
53387
- this.testVertex[0] = (this.normal[0] >= 0.0) ? 1 : 0;
53388
- this.testVertex[1] = (this.normal[1] >= 0.0) ? 1 : 0;
53389
- this.testVertex[2] = (this.normal[2] >= 0.0) ? 1 : 0;
53390
- }
53391
- }
53392
-
53393
- /**
53394
- * @private
53395
- */
53396
- class Frustum {
53397
- constructor() {
53398
- this.planes = [
53399
- new FrustumPlane(), new FrustumPlane(), new FrustumPlane(),
53400
- new FrustumPlane(), new FrustumPlane(), new FrustumPlane()
53401
- ];
53402
- }
53403
- }
53404
-
53405
- Frustum.INSIDE = 0;
53406
- Frustum.INTERSECT = 1;
53407
- Frustum.OUTSIDE = 2;
53408
-
53409
- /** @private */
53410
- function setFrustum(frustum, viewMat, projMat) {
53411
-
53412
- const m = math.mulMat4(projMat, viewMat, tempMat4a$h);
53413
-
53414
- const m0 = m[0];
53415
- const m1 = m[1];
53416
- const m2 = m[2];
53417
- const m3 = m[3];
53418
- const m4 = m[4];
53419
- const m5 = m[5];
53420
- const m6 = m[6];
53421
- const m7 = m[7];
53422
- const m8 = m[8];
53423
- const m9 = m[9];
53424
- const m10 = m[10];
53425
- const m11 = m[11];
53426
- const m12 = m[12];
53427
- const m13 = m[13];
53428
- const m14 = m[14];
53429
- const m15 = m[15];
53430
-
53431
- frustum.planes[0].set(m3 - m0, m7 - m4, m11 - m8, m15 - m12);
53432
- frustum.planes[1].set(m3 + m0, m7 + m4, m11 + m8, m15 + m12);
53433
- frustum.planes[2].set(m3 - m1, m7 - m5, m11 - m9, m15 - m13);
53434
- frustum.planes[3].set(m3 + m1, m7 + m5, m11 + m9, m15 + m13);
53435
- frustum.planes[4].set(m3 - m2, m7 - m6, m11 - m10, m15 - m14);
53436
- frustum.planes[5].set(m3 + m2, m7 + m6, m11 + m10, m15 + m14);
53437
- }
53438
-
53439
- /** @private */
53440
- function frustumIntersectsAABB3(frustum, aabb) {
53441
-
53442
- let ret = Frustum.INSIDE;
53443
-
53444
- const min = tempVec3a$t;
53445
- const max = tempVec3b$o;
53446
-
53447
- min[0] = aabb[0];
53448
- min[1] = aabb[1];
53449
- min[2] = aabb[2];
53450
- max[0] = aabb[3];
53451
- max[1] = aabb[4];
53452
- max[2] = aabb[5];
53453
-
53454
- const bminmax = [min, max];
53455
-
53456
- for (let i = 0; i < 6; ++i) {
53457
- const plane = frustum.planes[i];
53458
- if (((plane.normal[0] * bminmax[plane.testVertex[0]][0]) +
53459
- (plane.normal[1] * bminmax[plane.testVertex[1]][1]) +
53460
- (plane.normal[2] * bminmax[plane.testVertex[2]][2]) +
53461
- (plane.offset)) < 0.0) {
53462
- return Frustum.OUTSIDE;
53463
- }
53464
-
53465
- if (((plane.normal[0] * bminmax[1 - plane.testVertex[0]][0]) +
53466
- (plane.normal[1] * bminmax[1 - plane.testVertex[1]][1]) +
53467
- (plane.normal[2] * bminmax[1 - plane.testVertex[2]][2]) +
53468
- (plane.offset)) < 0.0) {
53469
- ret = Frustum.INTERSECT;
53470
- }
53471
- }
53472
-
53473
- return ret;
53474
- }
53475
-
53476
53481
  /**
53477
53482
  * @desc Saves and restores the state of a {@link Scene}'s {@link Camera}.
53478
53483
  *
@@ -73275,9 +73280,9 @@ class TrianglesDataTextureColorRenderer {
73275
73280
 
73276
73281
  src.push("uniform int renderPass;");
73277
73282
 
73278
- if (scene.entityOffsetsEnabled) {
73279
- src.push("in vec3 offset;");
73280
- }
73283
+ // if (scene.entityOffsetsEnabled) {
73284
+ // src.push("in vec3 offset;");
73285
+ // }
73281
73286
 
73282
73287
  src.push("uniform mat4 sceneModelWorldMatrix;");
73283
73288
  src.push("uniform mat4 viewMatrix;");
@@ -74043,7 +74048,6 @@ const defaultColor = new Float32Array([0, 0, 0, 1]);
74043
74048
 
74044
74049
  const tempVec3a$i = math.vec3();
74045
74050
  const tempVec3b$e = math.vec3();
74046
- math.vec3();
74047
74051
  const tempVec3d$8 = math.vec3();
74048
74052
  const tempMat4a$9 = math.mat4();
74049
74053
 
@@ -74106,8 +74110,7 @@ class TrianglesDataTextureEdgesRenderer {
74106
74110
  if (gotOrigin || gotPosition) {
74107
74111
  const rtcOrigin = tempVec3a$i;
74108
74112
  if (gotOrigin) {
74109
- const rotatedOrigin = tempVec3b$e;
74110
- math.transformPoint3(rotationMatrix, origin, rotatedOrigin);
74113
+ const rotatedOrigin = math.transformPoint3(rotationMatrix, origin, tempVec3b$e);
74111
74114
  rtcOrigin[0] = rotatedOrigin[0];
74112
74115
  rtcOrigin[1] = rotatedOrigin[1];
74113
74116
  rtcOrigin[2] = rotatedOrigin[2];
@@ -74289,9 +74292,9 @@ class TrianglesDataTextureEdgesRenderer {
74289
74292
 
74290
74293
  src.push("uniform int renderPass;");
74291
74294
 
74292
- if (scene.entityOffsetsEnabled) {
74293
- src.push("in vec3 offset;");
74294
- }
74295
+ // if (scene.entityOffsetsEnabled) {
74296
+ // src.push("in vec3 offset;");
74297
+ // }
74295
74298
 
74296
74299
  src.push("uniform mat4 sceneModelWorldMatrix;");
74297
74300
  src.push("uniform mat4 viewMatrix;");
@@ -74376,7 +74379,7 @@ class TrianglesDataTextureEdgesRenderer {
74376
74379
  // get XYZ offset
74377
74380
  src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");
74378
74381
 
74379
- src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
74382
+ src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz + vec3(110.0,50.0, 10.0);");
74380
74383
 
74381
74384
  src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
74382
74385
 
@@ -74526,8 +74529,7 @@ class TrianglesDataTextureEdgesColorRenderer {
74526
74529
  if (gotOrigin || gotPosition) {
74527
74530
  const rtcOrigin = tempVec3a$h;
74528
74531
  if (gotOrigin) {
74529
- const rotatedOrigin = tempVec3b$d;
74530
- math.transformPoint3(rotationMatrix, origin, rotatedOrigin);
74532
+ const rotatedOrigin = math.transformPoint3(rotationMatrix, origin, tempVec3b$d);
74531
74533
  rtcOrigin[0] = rotatedOrigin[0];
74532
74534
  rtcOrigin[1] = rotatedOrigin[1];
74533
74535
  rtcOrigin[2] = rotatedOrigin[2];
@@ -74794,7 +74796,7 @@ class TrianglesDataTextureEdgesColorRenderer {
74794
74796
  // get XYZ offset
74795
74797
  src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");
74796
74798
 
74797
- // src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
74799
+ src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
74798
74800
 
74799
74801
  src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
74800
74802
 
@@ -82921,7 +82923,7 @@ class SceneModel extends Component {
82921
82923
  cfg.primitive = "triangles";
82922
82924
  }
82923
82925
  if (cfg.primitive !== "points" && cfg.primitive !== "lines" && cfg.primitive !== "triangles" && cfg.primitive !== "solid" && cfg.primitive !== "surface") {
82924
- this.error(`[createGeometry] Unsupported value for 'primitive': '${primitive}' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'.`);
82926
+ this.error(`[createGeometry] Unsupported value for 'primitive': '${cfg.primitive}' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'.`);
82925
82927
  return;
82926
82928
  }
82927
82929
  if (!cfg.positions && !cfg.positionsCompressed && !cfg.buckets) {
@@ -85871,12 +85873,13 @@ class MousePickHandler {
85871
85873
  }
85872
85874
 
85873
85875
  const hoverSubs = cameraControl.hasSubs("hover");
85876
+ const hoverEnterSubs = cameraControl.hasSubs("hoverEnter");
85874
85877
  const hoverOutSubs = cameraControl.hasSubs("hoverOut");
85875
85878
  const hoverOffSubs = cameraControl.hasSubs("hoverOff");
85876
85879
  const hoverSurfaceSubs = cameraControl.hasSubs("hoverSurface");
85877
85880
  const hoverSnapOrSurfaceSubs = cameraControl.hasSubs("hoverSnapOrSurface");
85878
85881
 
85879
- if (hoverSubs || hoverOutSubs || hoverOffSubs || hoverSurfaceSubs || hoverSnapOrSurfaceSubs) {
85882
+ if (hoverSubs || hoverEnterSubs || hoverOutSubs || hoverOffSubs || hoverSurfaceSubs || hoverSnapOrSurfaceSubs) {
85880
85883
 
85881
85884
  pickController.pickCursorPos = states.pointerCanvasPos;
85882
85885
  pickController.schedulePickEntity = true;