a3js 1.2.0 → 1.3.0

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.
package/dist/a3js.es.js CHANGED
@@ -538,30 +538,30 @@ var rn = {
538
538
  }
539
539
  configColliderDescs() {
540
540
  if (!this.objectA3) return;
541
- let e = this.completeOptions, t = [];
542
- this.objectA3.object3D.traverse((n) => {
543
- if (Jt(n)) {
544
- let r = fn(n.geometry), i = e.membership << 16 | e.filter;
545
- if (r) r.colliderDesc.setCollisionGroups(i), e.collisionDetection && r.colliderDesc.setActiveEvents(G.ActiveEvents.COLLISION_EVENTS), this.colliderDescs.push(r.colliderDesc), r.colliderDesc.setRestitution(e.restitution).setFriction(e.friction), t.push(r.volume);
541
+ let e = this.completeOptions, t = [], n = e.membership << 16 | e.filter, r = this.transform.scale;
542
+ this.objectA3.object3D.traverse((i) => {
543
+ if (Jt(i)) {
544
+ let a = fn(i.geometry, r);
545
+ if (a) a.colliderDesc.setCollisionGroups(n), e.collisionDetection && a.colliderDesc.setActiveEvents(G.ActiveEvents.COLLISION_EVENTS), this.colliderDescs.push(a.colliderDesc), a.colliderDesc.setRestitution(e.restitution).setFriction(e.friction), t.push(a.volume);
546
546
  else {
547
547
  let r, a;
548
548
  switch (e.meshCollider) {
549
549
  case "tri_mesh":
550
- r = ln(n), a = dn(n.geometry);
550
+ r = ln(i), a = dn(i.geometry);
551
551
  break;
552
552
  case "convex_hull":
553
- r = un(n), a = dn(n.geometry);
553
+ r = un(i), a = dn(i.geometry);
554
554
  break;
555
555
  }
556
- r && (r.setCollisionGroups(i), e.collisionDetection && r.setActiveEvents(G.ActiveEvents.COLLISION_EVENTS), r.setRestitution(e.restitution).setFriction(e.friction), this.colliderDescs.push(r), t.push(a));
556
+ r && (r.setCollisionGroups(n), e.collisionDetection && r.setActiveEvents(G.ActiveEvents.COLLISION_EVENTS), r.setRestitution(e.restitution).setFriction(e.friction), this.colliderDescs.push(r), t.push(a));
557
557
  }
558
558
  }
559
559
  });
560
- let n = t.reduce((e, t) => e + t, 0);
561
- for (let r = 0; r < this.colliderDescs.length; r++) this.colliderDescs[r].setRestitution(e.restitution), this.colliderDescs[r].setFriction(e.friction), this.colliderDescs[r].setMass(e.mass * (t[r] / n));
560
+ let i = t.reduce((e, t) => e + t, 0);
561
+ for (let n = 0; n < this.colliderDescs.length; n++) this.colliderDescs[n].setRestitution(e.restitution), this.colliderDescs[n].setFriction(e.friction), this.colliderDescs[n].setMass(e.mass * (t[n] / i));
562
562
  }
563
563
  init(e, t) {
564
- this.transform.set(e), this.objectA3 = t, this.colliderDescs = [], this.colliders = [], this.bodyDesc = this.makeBodyDesc(), this.configColliderDescs(), this.bodyDesc.setTranslation(e.loc.x, e.loc.y, e.loc.z), this.bodyDesc.setRotation(e.quat);
564
+ this.transform.set(e), this.objectA3 = t, this.colliderDescs = [], this.colliders = [], this.objectA3.object3D.scale.set(e.scale.x, e.scale.y, e.scale.z), this.bodyDesc = this.makeBodyDesc(), this.configColliderDescs(), this.bodyDesc.setTranslation(e.loc.x, e.loc.y, e.loc.z), this.bodyDesc.setRotation(e.quat);
565
565
  }
566
566
  addOneselfToPhysics(e) {
567
567
  this.bodyDesc && (this.body = e.world.createRigidBody(this.bodyDesc), this.colliderDescs.forEach((t) => {
@@ -719,42 +719,42 @@ function dn(t) {
719
719
  } else for (let e = 0; e < i.length; e += 9) o.set(i[e], i[e + 1], i[e + 2]), s.set(i[e + 3], i[e + 4], i[e + 5]), c.set(i[e + 6], i[e + 7], i[e + 8]), a += o.dot(s.clone().cross(c));
720
720
  return Math.abs(a) / 6;
721
721
  }
722
- function fn(e) {
722
+ function fn(e, t = new V(1, 1, 1)) {
723
723
  if (Yt(e)) {
724
- let t = e.parameters, n = typeof t?.width == "number" ? t.width / 2 : .5, r = typeof t?.height == "number" ? t.height / 2 : .5, i = typeof t?.depth == "number" ? t.depth / 2 : .5, a = .1;
724
+ let n = e.parameters, r = (typeof n?.width == "number" ? n.width / 2 : .5) * t.x, i = (typeof n?.height == "number" ? n.height / 2 : .5) * t.y, a = (typeof n?.depth == "number" ? n.depth / 2 : .5) * t.z, o = .1 * Math.cbrt(t.x * t.y * t.z);
725
725
  return {
726
- colliderDesc: G.ColliderDesc.roundCuboid(n - a, r - a, i - a, a),
727
- volume: 2 * n * 2 * r * 2 * i
726
+ colliderDesc: G.ColliderDesc.roundCuboid(r - o, i - o, a - o, o),
727
+ volume: 2 * r * 2 * i * 2 * a
728
728
  };
729
729
  } else if (Xt(e)) {
730
- let t = e.parameters, n = typeof t?.width == "number" ? t.width / 2 : .5, r = typeof t?.height == "number" ? t.height / 2 : .5, i = typeof t?.depth == "number" ? t.depth / 2 : .5;
730
+ let n = e.parameters, r = (typeof n?.width == "number" ? n.width / 2 : .5) * t.x, i = (typeof n?.height == "number" ? n.height / 2 : .5) * t.y, a = (typeof n?.depth == "number" ? n.depth / 2 : .5) * t.z;
731
731
  return {
732
- colliderDesc: G.ColliderDesc.cuboid(n, r, i),
733
- volume: 2 * n * 2 * r * 2 * i
732
+ colliderDesc: G.ColliderDesc.cuboid(r, i, a),
733
+ volume: 2 * r * 2 * i * 2 * a
734
734
  };
735
735
  } else if (Zt(e)) {
736
- let t = e.parameters, n = typeof t?.radius == "number" ? t.radius : 1;
736
+ let n = e.parameters, r = Math.cbrt(t.x * t.y * t.z), i = (typeof n?.radius == "number" ? n.radius : 1) * r;
737
737
  return {
738
- colliderDesc: G.ColliderDesc.ball(n),
739
- volume: 4 / 3 * Math.PI * n * n * n
738
+ colliderDesc: G.ColliderDesc.ball(i),
739
+ volume: 4 / 3 * Math.PI * i * i * i
740
740
  };
741
741
  } else if (Qt(e)) {
742
- let t = e.parameters, n = typeof t?.radius == "number" ? t.radius : 1;
742
+ let n = e.parameters, r = Math.cbrt(t.x * t.y * t.z), i = (typeof n?.radius == "number" ? n.radius : 1) * r;
743
743
  return {
744
- colliderDesc: G.ColliderDesc.ball(n),
745
- volume: 4 / 3 * Math.PI * n * n * n
744
+ colliderDesc: G.ColliderDesc.ball(i),
745
+ volume: 4 / 3 * Math.PI * i * i * i
746
746
  };
747
747
  } else if ($t(e)) {
748
- let t = e.parameters, n = typeof t?.radiusBottom == "number" ? t.radiusBottom : .5, r = typeof t?.height == "number" ? t.height : .5;
748
+ let n = e.parameters, r = Math.sqrt(t.x * t.z), i = (typeof n?.radiusBottom == "number" ? n.radiusBottom : .5) * r, a = (typeof n?.height == "number" ? n.height : .5) * t.y;
749
749
  return {
750
- colliderDesc: G.ColliderDesc.cylinder(r / 2, n),
751
- volume: Math.PI * n * n * r
750
+ colliderDesc: G.ColliderDesc.cylinder(a / 2, i),
751
+ volume: Math.PI * i * i * a
752
752
  };
753
753
  } else if (en(e)) {
754
- let t = e.parameters, n = typeof t?.radius == "number" ? t.radius : .5, r = typeof t?.height == "number" ? t.height : .5;
754
+ let n = e.parameters, r = Math.sqrt(t.x * t.z), i = (typeof n?.radius == "number" ? n.radius : .5) * r, a = (typeof n?.height == "number" ? n.height : .5) * t.y;
755
755
  return {
756
- colliderDesc: G.ColliderDesc.capsule(r / 2, n),
757
- volume: 4 / 3 * Math.PI * n * n * n + Math.PI * n * n * r
756
+ colliderDesc: G.ColliderDesc.capsule(a / 2, i),
757
+ volume: 4 / 3 * Math.PI * i * i * i + Math.PI * i * i * a
758
758
  };
759
759
  }
760
760
  return null;
@@ -12955,6 +12955,6 @@ var jo = {
12955
12955
  };
12956
12956
  customElements.define("ar-view-a3", Mo);
12957
12957
  //#endregion
12958
- export { Mo as ARView, Hr as Acerola3D, Mn as Action, Nn as ActionObject, Yr as AvatarPositionController, Zr as AvatarVelocityController, Kr as BaseController, Qr as BaseView, Ht as BillboardTransformer, mo as Box, Gr as Camera, Ka as Canvas, To as CarControl, Do as CarMotion, Eo as CarTransformer, Pr as ClipMotion, jt as DefaultTransformer, En as DynamicCharacterTransformer, Kt as FollowTransformer, Wa as GLTF, Co as GameCanvas, xo as Html3D, bo as ImagePlane, Cn as KinematicCharacterTransformer, q as ObjectA3, qr as OrbitController, H as Quat, on as RapierPhysicsEngine, sn as RapierPhysicsWorld, to as SampleObject, Wr as Scene, Wt as SmoothBillboardTransformer, Pt as SmoothTransformer, Lr as Sound, ho as Sphere, yo as StandardLights, Mt as StaticTransformer, fo as Text3D, $r as ThreeCamera, po as ThreeObject, W as Transform, Ao as VRView, V as Vec3, Xa as Window, Oo as XRCamera, hn as asyncSleep, an as collisionMap, xn as deepMerge, jo as defaultARViewOptions, Ga as defaultCanvasOptions, wo as defaultCarControlOptions, Tn as defaultDynamicCharacterTransformerOptions, Gt as defaultFollowTransformerOptions, So as defaultGameCanvasOptions, Sn as defaultKinematicCharacterTransformerOptions, eo as defaultSampleObjectOptions, An as defaultSetLightShadowOptions, Nt as defaultSmoothTransformerOptions, uo as defaultText3DOptions, ko as defaultVRViewOptions, Ya as defaultWindowOptions, Dt as eulerToQuaternion, Et as getLookAtQuaternion, lo as initFont, mn as initPhysics, Ir as initSound, Va as recreateGLTFLoader };
12958
+ export { Mo as ARView, Hr as Acerola3D, Mn as Action, Nn as ActionObject, Yr as AvatarPositionController, Zr as AvatarVelocityController, Kr as BaseController, Qr as BaseView, Ht as BillboardTransformer, mo as Box, Gr as Camera, Ka as Canvas, To as CarControl, Do as CarMotion, Eo as CarTransformer, Pr as ClipMotion, jt as DefaultTransformer, En as DynamicCharacterTransformer, Kt as FollowTransformer, Wa as GLTF, Co as GameCanvas, xo as Html3D, bo as ImagePlane, Cn as KinematicCharacterTransformer, q as ObjectA3, qr as OrbitController, H as Quat, on as RapierPhysicsEngine, sn as RapierPhysicsWorld, to as SampleObject, Wr as Scene, cn as SimplePhysicsTransformer, Wt as SmoothBillboardTransformer, Pt as SmoothTransformer, Lr as Sound, ho as Sphere, yo as StandardLights, Mt as StaticTransformer, fo as Text3D, $r as ThreeCamera, po as ThreeObject, W as Transform, Ao as VRView, V as Vec3, Xa as Window, Oo as XRCamera, hn as asyncSleep, an as collisionMap, xn as deepMerge, jo as defaultARViewOptions, Ga as defaultCanvasOptions, wo as defaultCarControlOptions, Tn as defaultDynamicCharacterTransformerOptions, Gt as defaultFollowTransformerOptions, So as defaultGameCanvasOptions, Sn as defaultKinematicCharacterTransformerOptions, eo as defaultSampleObjectOptions, An as defaultSetLightShadowOptions, rn as defaultSimplePhysicsOptions, Nt as defaultSmoothTransformerOptions, uo as defaultText3DOptions, ko as defaultVRViewOptions, Ya as defaultWindowOptions, Dt as eulerToQuat, Et as getLookAtQuat, lo as initFont, mn as initPhysics, Ir as initSound, At as quatToEuler, Ot as quatToMatrix, Va as recreateGLTFLoader };
12959
12959
 
12960
12960
  //# sourceMappingURL=a3js.es.js.map