@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.
@@ -35507,8 +35507,8 @@ else if (typeof exports === 'object')
35507
35507
  baseColorFactor[3]
35508
35508
  )
35509
35509
  );
35510
- physicMaterial.setUniformFloat("roughness", roughnessFactor);
35511
- physicMaterial.setUniformFloat("metallic", metallicFactor);
35510
+ physicMaterial.setUniformFloat("roughness", roughnessFactor ?? 1);
35511
+ physicMaterial.setUniformFloat("metallic", metallicFactor ?? 0);
35512
35512
  physicMaterial.setUniformFloat("ao", 1);
35513
35513
  physicMaterial.doubleSide = doubleSided;
35514
35514
  if (baseColorTexture) {
@@ -35519,6 +35519,11 @@ else if (typeof exports === 'object')
35519
35519
  }
35520
35520
  if (metallicRoughnessTexture) {
35521
35521
  physicMaterial.setTexture("maskMap", metallicRoughnessTexture);
35522
+ physicMaterial.shader.setDefine("USE_ROUGHNESS_G", true);
35523
+ physicMaterial.shader.setDefine("USE_METALLIC_B", true);
35524
+ } else {
35525
+ physicMaterial.shader.setDefine("USE_ROUGHNESS_G", false);
35526
+ physicMaterial.shader.setDefine("USE_METALLIC_B", false);
35522
35527
  }
35523
35528
  if (emissiveTexture) {
35524
35529
  physicMaterial.setTexture("emissiveMap", emissiveTexture);
@@ -35568,7 +35573,8 @@ else if (typeof exports === 'object')
35568
35573
  numComponents: 1
35569
35574
  };
35570
35575
  }
35571
- if (!attribArrays[`normal`]) {
35576
+ let needsNormalComputation = !attribArrays[`normal`];
35577
+ if (needsNormalComputation) {
35572
35578
  let normal = [];
35573
35579
  let count = attribArrays["position"].data.length / 3;
35574
35580
  for (let i2 = 0; i2 < count; i2++) {
@@ -35597,6 +35603,9 @@ else if (typeof exports === 'object')
35597
35603
  nodeInfo.skin
35598
35604
  );
35599
35605
  this.gltf.resources[meshName2] = geometry;
35606
+ if (needsNormalComputation && attribArrays[`indices`]?.data && attribArrays[`indices`].data.length > 0) {
35607
+ geometry.computeNormals();
35608
+ }
35600
35609
  let skeletonNode = this.gltf.nodes[nodeInfo.skin.skeleton];
35601
35610
  if (skeletonNode.dnode && skeletonNode.dnode["nodeObj"]) {
35602
35611
  this.convertSkeletonAnim(node, nodeInfo.skin);
@@ -35613,6 +35622,9 @@ else if (typeof exports === 'object')
35613
35622
  primitive
35614
35623
  );
35615
35624
  this.gltf.resources[meshName2] = geometry;
35625
+ if (needsNormalComputation && attribArrays[`indices`]?.data && attribArrays[`indices`].data.length > 0) {
35626
+ geometry.computeNormals();
35627
+ }
35616
35628
  if (geometry.hasAttribute(VertexAttributeName.joints0)) {
35617
35629
  geometry.vertexAttributeMap.delete(VertexAttributeName.joints0);
35618
35630
  }
@@ -38966,7 +38978,9 @@ else if (typeof exports === 'object')
38966
38978
  static format = ParserFormat.BIN;
38967
38979
  async parseBuffer(buffer) {
38968
38980
  let loader = new B3DMLoader();
38969
- loader.adjustmentTransform = this.userData;
38981
+ if (this.userData) {
38982
+ loader.adjustmentTransform = this.userData;
38983
+ }
38970
38984
  this.data = await loader.parse(buffer);
38971
38985
  }
38972
38986
  verification() {
@@ -41050,7 +41064,7 @@ else if (typeof exports === 'object')
41050
41064
  }
41051
41065
  }
41052
41066
 
41053
- const version = "1.0.16";
41067
+ const version = "1.0.18";
41054
41068
 
41055
41069
  class Engine3D {
41056
41070
  /**
@@ -62053,15 +62067,25 @@ fn frag(){
62053
62067
  }
62054
62068
  }
62055
62069
  if (!parentTile) {
62056
- transform.rawData[12] -= boundCenter.x;
62057
- transform.rawData[13] -= boundCenter.y;
62058
- transform.rawData[14] -= boundCenter.z;
62059
- }
62060
- const worldTransform = transform.clone();
62070
+ const tmpMat = new Matrix4();
62071
+ tmpMat.copyFrom(transform);
62072
+ tmpMat.rawData[12] = 0;
62073
+ tmpMat.rawData[13] = 0;
62074
+ tmpMat.rawData[14] = 0;
62075
+ const position = new Vector3();
62076
+ position.copyFrom(boundCenter);
62077
+ position.applyMatrix4(tmpMat);
62078
+ transform.rawData[12] = -position.x;
62079
+ transform.rawData[13] = -position.y;
62080
+ transform.rawData[14] = -position.z;
62081
+ }
62082
+ const worldTransform = new Matrix4();
62083
+ worldTransform.copyFrom(transform);
62061
62084
  if (parentTile && parentTile.cached.worldTransform) {
62062
62085
  worldTransform.multiplyMatrices(parentTile.cached.worldTransform, transform);
62063
62086
  }
62064
- const transformInverse = worldTransform.clone();
62087
+ const transformInverse = new Matrix4();
62088
+ transformInverse.copyFrom(worldTransform);
62065
62089
  transformInverse.invert();
62066
62090
  tileObj.cached.transfrom = transform;
62067
62091
  tileObj.cached.worldTransform = worldTransform;
@@ -62169,16 +62193,14 @@ fn frag(){
62169
62193
  const adjustmentTransform = this._upRotationMatrix;
62170
62194
  switch (extension.toLowerCase()) {
62171
62195
  case "b3dm":
62172
- scene = await Engine3D.res.loadB3DM(
62173
- fullUrl,
62174
- {
62175
- onProgress: (e) => {
62176
- },
62177
- onComplete: (e) => {
62178
- }
62196
+ const loader = new FileLoader();
62197
+ const parser = await loader.load(fullUrl, B3DMParser, {
62198
+ onProgress: (e) => {
62179
62199
  },
62180
- adjustmentTransform
62181
- );
62200
+ onComplete: (e) => {
62201
+ }
62202
+ }, adjustmentTransform);
62203
+ scene = parser.data;
62182
62204
  break;
62183
62205
  case "i3dm":
62184
62206
  scene = await Engine3D.res.loadI3DM(
@@ -62374,7 +62396,8 @@ fn frag(){
62374
62396
  break;
62375
62397
  }
62376
62398
  this._upRotationMatrix = adjustmentTransform;
62377
- const invertMatrix = adjustmentTransform.clone();
62399
+ const invertMatrix = new Matrix4();
62400
+ invertMatrix.copyFrom(adjustmentTransform);
62378
62401
  invertMatrix.invert();
62379
62402
  this._applyLocalTransform(this.group.transform, invertMatrix);
62380
62403
  }
@@ -62581,6 +62604,7 @@ fn frag(){
62581
62604
  this.frameCount = 0;
62582
62605
  this.isLoading = false;
62583
62606
  this.resetCacheStats();
62607
+ this.group.destroy();
62584
62608
  }
62585
62609
  /**
62586
62610
  * Rings-specific: Add camera
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rings-webgpu/core",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Rings webgpu Engine",
5
5
  "main": "index.js",
6
6
  "exports": {