@threenative/physics 0.3.22 → 0.3.23

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/index.js CHANGED
@@ -1342,6 +1342,32 @@ function createNativePhysicsSimulation(raw, version) {
1342
1342
  position: finiteQueryVector(hit.position, "query hit position")
1343
1343
  };
1344
1344
  };
1345
+ const rayOutputHit = () => {
1346
+ const bodyId3 = rayOutput[0];
1347
+ const distance = rayOutput[7];
1348
+ if (bodyId3 === void 0 || !Number.isSafeInteger(bodyId3) || bodyId3 < 0 || distance === void 0)
1349
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output is malformed");
1350
+ const body = bodyHandle(bodyId3);
1351
+ const px = rayOutput[1];
1352
+ const py = rayOutput[2];
1353
+ const pz = rayOutput[3];
1354
+ if (!Number.isFinite(px) || !Number.isFinite(py) || !Number.isFinite(pz))
1355
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: query hit position contains a non-finite vector");
1356
+ if (!Number.isFinite(distance) || distance < 0)
1357
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output distance is invalid");
1358
+ const nx = rayOutput[4];
1359
+ const ny = rayOutput[5];
1360
+ const nz = rayOutput[6];
1361
+ if (!Number.isFinite(nx) || !Number.isFinite(ny) || !Number.isFinite(nz))
1362
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output normal contains a non-finite vector");
1363
+ return {
1364
+ body,
1365
+ entity: body.entity,
1366
+ position: { x: px, y: py, z: pz },
1367
+ distance,
1368
+ normal: { x: nx, y: ny, z: nz }
1369
+ };
1370
+ };
1345
1371
  const refreshBodyTransforms = () => {
1346
1372
  if (!bodyTransformsDirty) return;
1347
1373
  const required = Math.max(1, bodyIds.size) * PHYSICS_TRANSFORM_STRIDE;
@@ -1619,24 +1645,7 @@ function createNativePhysicsSimulation(raw, version) {
1619
1645
  if (hit === 0) return void 0;
1620
1646
  if (hit !== 1)
1621
1647
  throw new Error("TN_NATIVE_PHYSICS_INVALID: ray query returned an invalid status");
1622
- const bodyId3 = rayOutput[0];
1623
- const position = {
1624
- x: rayOutput[1],
1625
- y: rayOutput[2],
1626
- z: rayOutput[3]
1627
- };
1628
- const normal = {
1629
- x: rayOutput[4],
1630
- y: rayOutput[5],
1631
- z: rayOutput[6]
1632
- };
1633
- const distance = rayOutput[7];
1634
- if (bodyId3 === void 0 || !Number.isSafeInteger(bodyId3) || bodyId3 < 0 || distance === void 0)
1635
- throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output is malformed");
1636
- const base2 = nativeHit({ bodyId: bodyId3, position });
1637
- if (!Number.isFinite(distance) || distance < 0)
1638
- throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output distance is invalid");
1639
- return { ...base2, distance, normal: finiteQueryVector(normal, "ray output normal") };
1648
+ return rayOutputHit();
1640
1649
  }
1641
1650
  if (hit === void 0 || hit === null) return void 0;
1642
1651
  if (!Number.isFinite(hit.distance) || hit.distance < 0)
@@ -462,6 +462,32 @@ function createNativePhysicsSimulation(raw, version) {
462
462
  position: finiteQueryVector(hit.position, "query hit position")
463
463
  };
464
464
  };
465
+ const rayOutputHit = () => {
466
+ const bodyId2 = rayOutput[0];
467
+ const distance = rayOutput[7];
468
+ if (bodyId2 === void 0 || !Number.isSafeInteger(bodyId2) || bodyId2 < 0 || distance === void 0)
469
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output is malformed");
470
+ const body = bodyHandle(bodyId2);
471
+ const px = rayOutput[1];
472
+ const py = rayOutput[2];
473
+ const pz = rayOutput[3];
474
+ if (!Number.isFinite(px) || !Number.isFinite(py) || !Number.isFinite(pz))
475
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: query hit position contains a non-finite vector");
476
+ if (!Number.isFinite(distance) || distance < 0)
477
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output distance is invalid");
478
+ const nx = rayOutput[4];
479
+ const ny = rayOutput[5];
480
+ const nz = rayOutput[6];
481
+ if (!Number.isFinite(nx) || !Number.isFinite(ny) || !Number.isFinite(nz))
482
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output normal contains a non-finite vector");
483
+ return {
484
+ body,
485
+ entity: body.entity,
486
+ position: { x: px, y: py, z: pz },
487
+ distance,
488
+ normal: { x: nx, y: ny, z: nz }
489
+ };
490
+ };
465
491
  const refreshBodyTransforms = () => {
466
492
  if (!bodyTransformsDirty) return;
467
493
  const required = Math.max(1, bodyIds.size) * PHYSICS_TRANSFORM_STRIDE;
@@ -739,24 +765,7 @@ function createNativePhysicsSimulation(raw, version) {
739
765
  if (hit === 0) return void 0;
740
766
  if (hit !== 1)
741
767
  throw new Error("TN_NATIVE_PHYSICS_INVALID: ray query returned an invalid status");
742
- const bodyId2 = rayOutput[0];
743
- const position = {
744
- x: rayOutput[1],
745
- y: rayOutput[2],
746
- z: rayOutput[3]
747
- };
748
- const normal = {
749
- x: rayOutput[4],
750
- y: rayOutput[5],
751
- z: rayOutput[6]
752
- };
753
- const distance = rayOutput[7];
754
- if (bodyId2 === void 0 || !Number.isSafeInteger(bodyId2) || bodyId2 < 0 || distance === void 0)
755
- throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output is malformed");
756
- const base2 = nativeHit({ bodyId: bodyId2, position });
757
- if (!Number.isFinite(distance) || distance < 0)
758
- throw new Error("TN_NATIVE_PHYSICS_INVALID: ray output distance is invalid");
759
- return { ...base2, distance, normal: finiteQueryVector(normal, "ray output normal") };
768
+ return rayOutputHit();
760
769
  }
761
770
  if (hit === void 0 || hit === null) return void 0;
762
771
  if (!Number.isFinite(hit.distance) || hit.distance < 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/physics",
3
- "version": "0.3.22",
3
+ "version": "0.3.23",
4
4
  "license": "MIT",
5
5
  "description": "Thin Rapier physics bindings for ThreeNative games.",
6
6
  "keywords": [
@@ -56,7 +56,7 @@
56
56
  "recast-navigation": "0.43.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@threenative/core": ">=0.3.22 <0.4.0",
59
+ "@threenative/core": ">=0.3.23 <0.4.0",
60
60
  "three": ">=0.187.0 <0.188.0"
61
61
  },
62
62
  "devDependencies": {
@@ -66,7 +66,7 @@
66
66
  "tsup": "8.5.1",
67
67
  "typescript": "npm:@typescript/typescript6@6.0.2",
68
68
  "@typescript/native": "npm:typescript@7.0.2",
69
- "@threenative/core": "0.3.22"
69
+ "@threenative/core": "0.3.23"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsup --config tsup.config.ts && publint",