@rings-webgpu/core 1.0.16 → 1.0.18

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.
@@ -35500,8 +35500,8 @@ class GLTFSubParserConverter {
35500
35500
  baseColorFactor[3]
35501
35501
  )
35502
35502
  );
35503
- physicMaterial.setUniformFloat("roughness", roughnessFactor);
35504
- physicMaterial.setUniformFloat("metallic", metallicFactor);
35503
+ physicMaterial.setUniformFloat("roughness", roughnessFactor ?? 1);
35504
+ physicMaterial.setUniformFloat("metallic", metallicFactor ?? 0);
35505
35505
  physicMaterial.setUniformFloat("ao", 1);
35506
35506
  physicMaterial.doubleSide = doubleSided;
35507
35507
  if (baseColorTexture) {
@@ -35512,6 +35512,11 @@ class GLTFSubParserConverter {
35512
35512
  }
35513
35513
  if (metallicRoughnessTexture) {
35514
35514
  physicMaterial.setTexture("maskMap", metallicRoughnessTexture);
35515
+ physicMaterial.shader.setDefine("USE_ROUGHNESS_G", true);
35516
+ physicMaterial.shader.setDefine("USE_METALLIC_B", true);
35517
+ } else {
35518
+ physicMaterial.shader.setDefine("USE_ROUGHNESS_G", false);
35519
+ physicMaterial.shader.setDefine("USE_METALLIC_B", false);
35515
35520
  }
35516
35521
  if (emissiveTexture) {
35517
35522
  physicMaterial.setTexture("emissiveMap", emissiveTexture);
@@ -35561,7 +35566,8 @@ class GLTFSubParserConverter {
35561
35566
  numComponents: 1
35562
35567
  };
35563
35568
  }
35564
- if (!attribArrays[`normal`]) {
35569
+ let needsNormalComputation = !attribArrays[`normal`];
35570
+ if (needsNormalComputation) {
35565
35571
  let normal = [];
35566
35572
  let count = attribArrays["position"].data.length / 3;
35567
35573
  for (let i2 = 0; i2 < count; i2++) {
@@ -35590,6 +35596,9 @@ class GLTFSubParserConverter {
35590
35596
  nodeInfo.skin
35591
35597
  );
35592
35598
  this.gltf.resources[meshName2] = geometry;
35599
+ if (needsNormalComputation && attribArrays[`indices`]?.data && attribArrays[`indices`].data.length > 0) {
35600
+ geometry.computeNormals();
35601
+ }
35593
35602
  let skeletonNode = this.gltf.nodes[nodeInfo.skin.skeleton];
35594
35603
  if (skeletonNode.dnode && skeletonNode.dnode["nodeObj"]) {
35595
35604
  this.convertSkeletonAnim(node, nodeInfo.skin);
@@ -35606,6 +35615,9 @@ class GLTFSubParserConverter {
35606
35615
  primitive
35607
35616
  );
35608
35617
  this.gltf.resources[meshName2] = geometry;
35618
+ if (needsNormalComputation && attribArrays[`indices`]?.data && attribArrays[`indices`].data.length > 0) {
35619
+ geometry.computeNormals();
35620
+ }
35609
35621
  if (geometry.hasAttribute(VertexAttributeName.joints0)) {
35610
35622
  geometry.vertexAttributeMap.delete(VertexAttributeName.joints0);
35611
35623
  }
@@ -38959,7 +38971,9 @@ class B3DMParser extends ParserBase {
38959
38971
  static format = ParserFormat.BIN;
38960
38972
  async parseBuffer(buffer) {
38961
38973
  let loader = new B3DMLoader();
38962
- loader.adjustmentTransform = this.userData;
38974
+ if (this.userData) {
38975
+ loader.adjustmentTransform = this.userData;
38976
+ }
38963
38977
  this.data = await loader.parse(buffer);
38964
38978
  }
38965
38979
  verification() {
@@ -41043,7 +41057,7 @@ class PostProcessingComponent extends ComponentBase {
41043
41057
  }
41044
41058
  }
41045
41059
 
41046
- const version = "1.0.16";
41060
+ const version = "1.0.18";
41047
41061
 
41048
41062
  class Engine3D {
41049
41063
  /**
@@ -62046,15 +62060,25 @@ class TilesRenderer {
62046
62060
  }
62047
62061
  }
62048
62062
  if (!parentTile) {
62049
- transform.rawData[12] -= boundCenter.x;
62050
- transform.rawData[13] -= boundCenter.y;
62051
- transform.rawData[14] -= boundCenter.z;
62052
- }
62053
- const worldTransform = transform.clone();
62063
+ const tmpMat = new Matrix4();
62064
+ tmpMat.copyFrom(transform);
62065
+ tmpMat.rawData[12] = 0;
62066
+ tmpMat.rawData[13] = 0;
62067
+ tmpMat.rawData[14] = 0;
62068
+ const position = new Vector3();
62069
+ position.copyFrom(boundCenter);
62070
+ position.applyMatrix4(tmpMat);
62071
+ transform.rawData[12] = -position.x;
62072
+ transform.rawData[13] = -position.y;
62073
+ transform.rawData[14] = -position.z;
62074
+ }
62075
+ const worldTransform = new Matrix4();
62076
+ worldTransform.copyFrom(transform);
62054
62077
  if (parentTile && parentTile.cached.worldTransform) {
62055
62078
  worldTransform.multiplyMatrices(parentTile.cached.worldTransform, transform);
62056
62079
  }
62057
- const transformInverse = worldTransform.clone();
62080
+ const transformInverse = new Matrix4();
62081
+ transformInverse.copyFrom(worldTransform);
62058
62082
  transformInverse.invert();
62059
62083
  tileObj.cached.transfrom = transform;
62060
62084
  tileObj.cached.worldTransform = worldTransform;
@@ -62162,16 +62186,14 @@ class TilesRenderer {
62162
62186
  const adjustmentTransform = this._upRotationMatrix;
62163
62187
  switch (extension.toLowerCase()) {
62164
62188
  case "b3dm":
62165
- scene = await Engine3D.res.loadB3DM(
62166
- fullUrl,
62167
- {
62168
- onProgress: (e) => {
62169
- },
62170
- onComplete: (e) => {
62171
- }
62189
+ const loader = new FileLoader();
62190
+ const parser = await loader.load(fullUrl, B3DMParser, {
62191
+ onProgress: (e) => {
62172
62192
  },
62173
- adjustmentTransform
62174
- );
62193
+ onComplete: (e) => {
62194
+ }
62195
+ }, adjustmentTransform);
62196
+ scene = parser.data;
62175
62197
  break;
62176
62198
  case "i3dm":
62177
62199
  scene = await Engine3D.res.loadI3DM(
@@ -62367,7 +62389,8 @@ class TilesRenderer {
62367
62389
  break;
62368
62390
  }
62369
62391
  this._upRotationMatrix = adjustmentTransform;
62370
- const invertMatrix = adjustmentTransform.clone();
62392
+ const invertMatrix = new Matrix4();
62393
+ invertMatrix.copyFrom(adjustmentTransform);
62371
62394
  invertMatrix.invert();
62372
62395
  this._applyLocalTransform(this.group.transform, invertMatrix);
62373
62396
  }
@@ -62574,6 +62597,7 @@ class TilesRenderer {
62574
62597
  this.frameCount = 0;
62575
62598
  this.isLoading = false;
62576
62599
  this.resetCacheStats();
62600
+ this.group.destroy();
62577
62601
  }
62578
62602
  /**
62579
62603
  * Rings-specific: Add camera