@rings-webgpu/core 1.0.22 → 1.0.24

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.
@@ -37085,6 +37085,7 @@ else if (typeof exports === 'object')
37085
37085
  }
37086
37086
  }
37087
37087
  }
37088
+ const promiseList = [];
37088
37089
  for (const key in this.matLibs) {
37089
37090
  const mat2 = this.matLibs[key];
37090
37091
  if (mat2.textures && mat2.textures.length > 0) {
@@ -37092,10 +37093,16 @@ else if (typeof exports === 'object')
37092
37093
  const texUrl = StringUtil.normalizePath(
37093
37094
  this.baseUrl + mat2.textures[i]
37094
37095
  );
37095
- await Engine3D.res.loadTexture(texUrl);
37096
+ promiseList.push(Engine3D.res.loadTexture(texUrl).catch(
37097
+ (error) => {
37098
+ console.error(`Failed to load texture: ${texUrl}`, error);
37099
+ return null;
37100
+ }
37101
+ ));
37096
37102
  }
37097
37103
  }
37098
37104
  }
37105
+ await Promise.all(promiseList);
37099
37106
  sourceData = null;
37100
37107
  return true;
37101
37108
  }
@@ -40960,7 +40967,12 @@ else if (typeof exports === 'object')
40960
40967
  }
40961
40968
  let texture = new BitmapTexture2D();
40962
40969
  texture.flipY = flipY;
40963
- await texture.load(url, loaderFunctions);
40970
+ try {
40971
+ await texture.load(url, loaderFunctions);
40972
+ } catch (error) {
40973
+ console.error(`Failed to load texture: ${url}`, error);
40974
+ return null;
40975
+ }
40964
40976
  this._texturePool.set(url, texture);
40965
40977
  return texture;
40966
40978
  }
@@ -41260,7 +41272,7 @@ else if (typeof exports === 'object')
41260
41272
  }
41261
41273
  }
41262
41274
 
41263
- const version = "1.0.21";
41275
+ const version = "1.0.23";
41264
41276
 
41265
41277
  class Engine3D {
41266
41278
  /**
@@ -61589,6 +61601,9 @@ fn frag(){
61589
61601
  _type;
61590
61602
  _data;
61591
61603
  _box;
61604
+ get box() {
61605
+ return this._box;
61606
+ }
61592
61607
  _sphere;
61593
61608
  _matrix;
61594
61609
  constructor(data) {
@@ -62268,17 +62283,33 @@ fn frag(){
62268
62283
  }
62269
62284
  }
62270
62285
  if (!parentTile) {
62271
- const tmpMat = new Matrix4();
62272
- tmpMat.copyFrom(transform);
62273
- tmpMat.rawData[12] = 0;
62274
- tmpMat.rawData[13] = 0;
62275
- tmpMat.rawData[14] = 0;
62286
+ transform.copyFrom(this._upRotationMatrix);
62276
62287
  const position = new Vector3();
62277
62288
  position.copyFrom(boundCenter);
62278
- position.applyMatrix4(tmpMat);
62289
+ position.applyMatrix4(transform);
62290
+ const box = tileObj.cached.boundingVolume.box;
62291
+ const boundCorners = [
62292
+ new Vector3(box.min.x, box.min.y, box.min.z),
62293
+ new Vector3(box.max.x, box.min.y, box.min.z),
62294
+ new Vector3(box.min.x, box.max.y, box.min.z),
62295
+ new Vector3(box.max.x, box.max.y, box.min.z),
62296
+ new Vector3(box.min.x, box.min.y, box.max.z),
62297
+ new Vector3(box.max.x, box.min.y, box.max.z),
62298
+ new Vector3(box.min.x, box.max.y, box.max.z),
62299
+ new Vector3(box.max.x, box.max.y, box.max.z)
62300
+ ];
62301
+ for (const corner of boundCorners) {
62302
+ corner.applyMatrix4(transform);
62303
+ }
62304
+ const newBox = new BoundingBox();
62305
+ boundCorners.forEach((corner) => {
62306
+ newBox.expandByPoint(corner);
62307
+ });
62279
62308
  transform.rawData[12] = -position.x;
62280
62309
  transform.rawData[13] = -position.y;
62281
62310
  transform.rawData[14] = -position.z;
62311
+ const min = newBox.min;
62312
+ transform.rawData[13] -= min.y;
62282
62313
  }
62283
62314
  const worldTransform = new Matrix4();
62284
62315
  worldTransform.copyFrom(transform);
@@ -62391,7 +62422,6 @@ fn frag(){
62391
62422
  const extension = getUrlExtension(uri);
62392
62423
  const fullUrl = url;
62393
62424
  let scene = null;
62394
- const adjustmentTransform = this._upRotationMatrix;
62395
62425
  switch (extension.toLowerCase()) {
62396
62426
  case "b3dm":
62397
62427
  const loader = new FileLoader();
@@ -62400,7 +62430,7 @@ fn frag(){
62400
62430
  },
62401
62431
  onComplete: (e) => {
62402
62432
  }
62403
- }, adjustmentTransform);
62433
+ });
62404
62434
  scene = parser.data;
62405
62435
  break;
62406
62436
  case "i3dm":
@@ -62411,8 +62441,7 @@ fn frag(){
62411
62441
  },
62412
62442
  onComplete: (e) => {
62413
62443
  }
62414
- },
62415
- adjustmentTransform
62444
+ }
62416
62445
  );
62417
62446
  break;
62418
62447
  case "glb":
@@ -62586,10 +62615,10 @@ fn frag(){
62586
62615
  adjustmentTransform.makeRotationAxis(Vector3.Y_AXIS, -Math.PI / 2);
62587
62616
  break;
62588
62617
  case "y":
62589
- adjustmentTransform.makeRotationAxis(Vector3.X_AXIS, Math.PI / 2);
62618
+ adjustmentTransform.identity();
62590
62619
  break;
62591
62620
  case "z":
62592
- adjustmentTransform.identity();
62621
+ adjustmentTransform.makeRotationAxis(Vector3.X_AXIS, -Math.PI / 2);
62593
62622
  break;
62594
62623
  default:
62595
62624
  console.warn(`Unknown gltfUpAxis: ${gltfUpAxis}, using default`);
@@ -62597,10 +62626,6 @@ fn frag(){
62597
62626
  break;
62598
62627
  }
62599
62628
  this._upRotationMatrix = adjustmentTransform;
62600
- const invertMatrix = new Matrix4();
62601
- invertMatrix.copyFrom(adjustmentTransform);
62602
- invertMatrix.invert();
62603
- this._applyLocalTransform(this.group.transform, invertMatrix);
62604
62629
  }
62605
62630
  /**
62606
62631
  * Apply local transform matrix to Transform
@@ -10,6 +10,7 @@ export declare class BoundingVolume {
10
10
  private _type;
11
11
  private _data;
12
12
  private _box?;
13
+ get box(): BoundingBox;
13
14
  private _sphere?;
14
15
  private _matrix?;
15
16
  constructor(data: BoundingVolumeData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rings-webgpu/core",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Rings webgpu Engine",
5
5
  "main": "index.js",
6
6
  "exports": {