From 1d61d35164375a6d0ceb86f64cd679cd958c8b0f Mon Sep 17 00:00:00 2001 From: ssatguru Date: Fri, 26 Jul 2024 17:32:39 -0500 Subject: [PATCH] better fall detection using pick ray, latest babylonjs --- package-lock.json | 252 ++++++++++++------------------------- package.json | 8 +- src/CharacterController.ts | 33 ++++- 3 files changed, 117 insertions(+), 176 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d30cd2..819e378 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "babylonjs-charactercontroller", - "version": "0.4.4-alpha.7", + "version": "0.4.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "babylonjs-charactercontroller", - "version": "0.4.4-alpha.7", + "version": "0.4.5", "license": "Apache-2.0", "devDependencies": { - "babylonjs": "7.0.0", - "babylonjs-inspector": "^7.0.0", - "babylonjs-loaders": "^7.0.0", + "babylonjs": "7.17.2", + "babylonjs-inspector": "^7.17.2", + "babylonjs-loaders": "^7.17.2", "terser-webpack-plugin": "^5.3.6", "ts-loader": "^9.4.2", "typescript": "^4.9.4", @@ -609,122 +609,80 @@ "dev": true }, "node_modules/babylonjs": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.0.0.tgz", - "integrity": "sha512-tK4qHeuw/Ea161BSwQo4Ni1jE/sr/C2wkuoEEqwv+AdQvnZaATr2QBorj9CtBBY1YssoZRXa+2nNTt2Y8dKApw==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.17.2.tgz", + "integrity": "sha512-3hS/EDtNRzcRVfLsw/bQ7djQ54xoLda6kTPXchmnMasOmQaRodj2fCsJjw4TQxFaw3f2zEfVl8DMieYyZADbOw==", "dev": true, "hasInstallScript": true }, "node_modules/babylonjs-gltf2interface": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.16.0.tgz", - "integrity": "sha512-yo77NZjnNTQkCWMcZDUT8xw0fwh5cjLgsUpoo5ncghut+oAV2YV3FUCXf3BDAsU2yWePtgt8idehWN/dNm2kjA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.17.2.tgz", + "integrity": "sha512-+lrTi1+jVVaNAF8vrUXXY23GAA2jCP3rQnfvDIhIwbZ4Aa2SFmU3jyj4w1nAn3nENP95vg30pR2QK9THoOaq9Q==", "dev": true }, "node_modules/babylonjs-gui": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.16.0.tgz", - "integrity": "sha512-qcVZiQia3B1q/IkQOzAAHO6GpU81uYPb19RMZLyonaa0v1cT31I3xCm6Yswkh1yu7dhLx/FrnjSZPc7xAdCb7g==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.17.2.tgz", + "integrity": "sha512-ZnG+BTJlJX7RSVgr3+u3uj94+YLQncys24Exs8wh5lRbNfWzMZmUgF+lFJQ27JNW4Buj/n47Q7a3p9BR5h7KZQ==", "dev": true, "dependencies": { - "babylonjs": "^7.16.0" + "babylonjs": "^7.17.2" } }, "node_modules/babylonjs-gui-editor": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-gui-editor/-/babylonjs-gui-editor-7.16.0.tgz", - "integrity": "sha512-DAGlTNLOY+hTwc7TOvKWmQ2cQZdwt92YZQ33dBprtpZ8d2l9TqRYqhuK2t7Jzgzg+44ijvp+t0DAcDIfoJVDmA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-gui-editor/-/babylonjs-gui-editor-7.17.2.tgz", + "integrity": "sha512-pG/fw6WS0oGm6aI8JhQGiaUzF1BNMTO8v/ABMlwbVPN1rLxbDsulTfmJ2FsyqFPwfPOBz2O3sg9EkU47Fsif/Q==", "dev": true, "dependencies": { - "babylonjs": "^7.16.0", - "babylonjs-gui": "^7.16.0" + "babylonjs": "^7.17.2", + "babylonjs-gui": "^7.17.2" } }, - "node_modules/babylonjs-gui-editor/node_modules/babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true, - "hasInstallScript": true - }, - "node_modules/babylonjs-gui/node_modules/babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true, - "hasInstallScript": true - }, "node_modules/babylonjs-inspector": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-inspector/-/babylonjs-inspector-7.16.0.tgz", - "integrity": "sha512-dFiPwZ/hgB5YS/f1fiAtcpWgSx9Z+IF9jo++3Kz8uEA4uwEK3awKaifBqlOsl6P/xwN7X2NL+V2HMafPmv9jTw==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-inspector/-/babylonjs-inspector-7.17.2.tgz", + "integrity": "sha512-FpU9ahpMKYdqE8IZpRigOTc0HfxITFeDI+PqR6SmuTOPy7wPdIhw7WKov8vyIatXQqPm5ZjgsYK0Hv7+AnjVmw==", "dev": true, "dependencies": { - "babylonjs": "^7.16.0", - "babylonjs-gui": "^7.16.0", - "babylonjs-gui-editor": "^7.16.0", - "babylonjs-loaders": "^7.16.0", - "babylonjs-materials": "^7.16.0", - "babylonjs-serializers": "^7.16.0" + "babylonjs": "^7.17.2", + "babylonjs-gui": "^7.17.2", + "babylonjs-gui-editor": "^7.17.2", + "babylonjs-loaders": "^7.17.2", + "babylonjs-materials": "^7.17.2", + "babylonjs-serializers": "^7.17.2" } }, - "node_modules/babylonjs-inspector/node_modules/babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true, - "hasInstallScript": true - }, "node_modules/babylonjs-loaders": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.16.0.tgz", - "integrity": "sha512-fNC2R1BYWd2Lhg3hrvw5KrDnDTdk/xwd/fwUzfPcn6HhMK5qV5H7nREZVjBW35QdxWlMRRy+YPDTZCv9Caa5Iw==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.17.2.tgz", + "integrity": "sha512-NeK02A1R1zUp1cqGQEEnfrHQoRE4L5z3iMLD/NeFAmTvelP01ELxf/1eysmBk//wX+zEonV2J4BPepoy2aLXQA==", "dev": true, "dependencies": { - "babylonjs": "^7.16.0", - "babylonjs-gltf2interface": "^7.16.0" + "babylonjs": "^7.17.2", + "babylonjs-gltf2interface": "^7.17.2" } }, - "node_modules/babylonjs-loaders/node_modules/babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true, - "hasInstallScript": true - }, "node_modules/babylonjs-materials": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.16.0.tgz", - "integrity": "sha512-VJx8eI2JIk1z5FMQW2pajt1AUN5Fw3zSrA+z+m2b7ePH4epKwbvyjEDvNIArngnQa2DZcHJX9PdQfqvV11o5aA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.17.2.tgz", + "integrity": "sha512-sAA2EwvGQQdau97uGl7DJgcz8Ly17UvtPg0g2bKmpkZwwB9mnSTOw5DiBfvLB6tpYhZlaBKCblqi7lCqKjKpJQ==", "dev": true, "dependencies": { - "babylonjs": "^7.16.0" + "babylonjs": "^7.17.2" } }, - "node_modules/babylonjs-materials/node_modules/babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true, - "hasInstallScript": true - }, "node_modules/babylonjs-serializers": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-serializers/-/babylonjs-serializers-7.16.0.tgz", - "integrity": "sha512-mMA5m2c1/MQvgEuU8HlikIEkBIpd81/E3ddvc2MczASCc3o+jybBJT6h+GUR7H/i+pSWiDU2ByT0u+jKnnxbFA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-serializers/-/babylonjs-serializers-7.17.2.tgz", + "integrity": "sha512-7cVhCwwNFvlyTYe5Ps3tQGo/oVuZkRqWeJ9PTCHbmDAtYCk5keg33R7Oq7PBAM5IYsl69TDscv71dsh7oQRNWw==", "dev": true, "dependencies": { - "babylonjs": "^7.16.0", - "babylonjs-gltf2interface": "^7.16.0" + "babylonjs": "^7.17.2", + "babylonjs-gltf2interface": "^7.17.2" } }, - "node_modules/babylonjs-serializers/node_modules/babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true, - "hasInstallScript": true - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -4168,125 +4126,77 @@ "dev": true }, "babylonjs": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.0.0.tgz", - "integrity": "sha512-tK4qHeuw/Ea161BSwQo4Ni1jE/sr/C2wkuoEEqwv+AdQvnZaATr2QBorj9CtBBY1YssoZRXa+2nNTt2Y8dKApw==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.17.2.tgz", + "integrity": "sha512-3hS/EDtNRzcRVfLsw/bQ7djQ54xoLda6kTPXchmnMasOmQaRodj2fCsJjw4TQxFaw3f2zEfVl8DMieYyZADbOw==", "dev": true }, "babylonjs-gltf2interface": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.16.0.tgz", - "integrity": "sha512-yo77NZjnNTQkCWMcZDUT8xw0fwh5cjLgsUpoo5ncghut+oAV2YV3FUCXf3BDAsU2yWePtgt8idehWN/dNm2kjA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.17.2.tgz", + "integrity": "sha512-+lrTi1+jVVaNAF8vrUXXY23GAA2jCP3rQnfvDIhIwbZ4Aa2SFmU3jyj4w1nAn3nENP95vg30pR2QK9THoOaq9Q==", "dev": true }, "babylonjs-gui": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.16.0.tgz", - "integrity": "sha512-qcVZiQia3B1q/IkQOzAAHO6GpU81uYPb19RMZLyonaa0v1cT31I3xCm6Yswkh1yu7dhLx/FrnjSZPc7xAdCb7g==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.17.2.tgz", + "integrity": "sha512-ZnG+BTJlJX7RSVgr3+u3uj94+YLQncys24Exs8wh5lRbNfWzMZmUgF+lFJQ27JNW4Buj/n47Q7a3p9BR5h7KZQ==", "dev": true, "requires": { - "babylonjs": "^7.16.0" - }, - "dependencies": { - "babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true - } + "babylonjs": "^7.17.2" } }, "babylonjs-gui-editor": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-gui-editor/-/babylonjs-gui-editor-7.16.0.tgz", - "integrity": "sha512-DAGlTNLOY+hTwc7TOvKWmQ2cQZdwt92YZQ33dBprtpZ8d2l9TqRYqhuK2t7Jzgzg+44ijvp+t0DAcDIfoJVDmA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-gui-editor/-/babylonjs-gui-editor-7.17.2.tgz", + "integrity": "sha512-pG/fw6WS0oGm6aI8JhQGiaUzF1BNMTO8v/ABMlwbVPN1rLxbDsulTfmJ2FsyqFPwfPOBz2O3sg9EkU47Fsif/Q==", "dev": true, "requires": { - "babylonjs": "^7.16.0", - "babylonjs-gui": "^7.16.0" - }, - "dependencies": { - "babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true - } + "babylonjs": "^7.17.2", + "babylonjs-gui": "^7.17.2" } }, "babylonjs-inspector": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-inspector/-/babylonjs-inspector-7.16.0.tgz", - "integrity": "sha512-dFiPwZ/hgB5YS/f1fiAtcpWgSx9Z+IF9jo++3Kz8uEA4uwEK3awKaifBqlOsl6P/xwN7X2NL+V2HMafPmv9jTw==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-inspector/-/babylonjs-inspector-7.17.2.tgz", + "integrity": "sha512-FpU9ahpMKYdqE8IZpRigOTc0HfxITFeDI+PqR6SmuTOPy7wPdIhw7WKov8vyIatXQqPm5ZjgsYK0Hv7+AnjVmw==", "dev": true, "requires": { - "babylonjs": "^7.16.0", - "babylonjs-gui": "^7.16.0", - "babylonjs-gui-editor": "^7.16.0", - "babylonjs-loaders": "^7.16.0", - "babylonjs-materials": "^7.16.0", - "babylonjs-serializers": "^7.16.0" - }, - "dependencies": { - "babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true - } + "babylonjs": "^7.17.2", + "babylonjs-gui": "^7.17.2", + "babylonjs-gui-editor": "^7.17.2", + "babylonjs-loaders": "^7.17.2", + "babylonjs-materials": "^7.17.2", + "babylonjs-serializers": "^7.17.2" } }, "babylonjs-loaders": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.16.0.tgz", - "integrity": "sha512-fNC2R1BYWd2Lhg3hrvw5KrDnDTdk/xwd/fwUzfPcn6HhMK5qV5H7nREZVjBW35QdxWlMRRy+YPDTZCv9Caa5Iw==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.17.2.tgz", + "integrity": "sha512-NeK02A1R1zUp1cqGQEEnfrHQoRE4L5z3iMLD/NeFAmTvelP01ELxf/1eysmBk//wX+zEonV2J4BPepoy2aLXQA==", "dev": true, "requires": { - "babylonjs": "^7.16.0", - "babylonjs-gltf2interface": "^7.16.0" - }, - "dependencies": { - "babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true - } + "babylonjs": "^7.17.2", + "babylonjs-gltf2interface": "^7.17.2" } }, "babylonjs-materials": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.16.0.tgz", - "integrity": "sha512-VJx8eI2JIk1z5FMQW2pajt1AUN5Fw3zSrA+z+m2b7ePH4epKwbvyjEDvNIArngnQa2DZcHJX9PdQfqvV11o5aA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.17.2.tgz", + "integrity": "sha512-sAA2EwvGQQdau97uGl7DJgcz8Ly17UvtPg0g2bKmpkZwwB9mnSTOw5DiBfvLB6tpYhZlaBKCblqi7lCqKjKpJQ==", "dev": true, "requires": { - "babylonjs": "^7.16.0" - }, - "dependencies": { - "babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true - } + "babylonjs": "^7.17.2" } }, "babylonjs-serializers": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs-serializers/-/babylonjs-serializers-7.16.0.tgz", - "integrity": "sha512-mMA5m2c1/MQvgEuU8HlikIEkBIpd81/E3ddvc2MczASCc3o+jybBJT6h+GUR7H/i+pSWiDU2ByT0u+jKnnxbFA==", + "version": "7.17.2", + "resolved": "https://registry.npmjs.org/babylonjs-serializers/-/babylonjs-serializers-7.17.2.tgz", + "integrity": "sha512-7cVhCwwNFvlyTYe5Ps3tQGo/oVuZkRqWeJ9PTCHbmDAtYCk5keg33R7Oq7PBAM5IYsl69TDscv71dsh7oQRNWw==", "dev": true, "requires": { - "babylonjs": "^7.16.0", - "babylonjs-gltf2interface": "^7.16.0" - }, - "dependencies": { - "babylonjs": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.16.0.tgz", - "integrity": "sha512-6OtvuDHcNUtcLIuA6enjZBay3DCsF04WrvTScua9cP1zPqHpn4pWlEjjYSnL3JXIcR8/Qtktj+R+IIy/oSL5Rw==", - "dev": true - } + "babylonjs": "^7.17.2", + "babylonjs-gltf2interface": "^7.17.2" } }, "balanced-match": { diff --git a/package.json b/package.json index 7b9df6e..8cc298b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "babylonjs-charactercontroller", - "version": "0.4.4", + "version": "0.4.5", "description": "A CharacterController for BabylonJS", "repository": { "type": "git", @@ -16,9 +16,9 @@ "main": "dist/CharacterController.js", "types": "dist/CharacterController.d.ts", "devDependencies": { - "babylonjs": "7.0.0", - "babylonjs-inspector": "^7.0.0", - "babylonjs-loaders": "^7.0.0", + "babylonjs": "7.17.2", + "babylonjs-inspector": "^7.17.2", + "babylonjs-loaders": "^7.17.2", "terser-webpack-plugin": "^5.3.6", "ts-loader": "^9.4.2", "typescript": "^4.9.4", diff --git a/src/CharacterController.ts b/src/CharacterController.ts index 9df09ff..7a8098b 100644 --- a/src/CharacterController.ts +++ b/src/CharacterController.ts @@ -57,6 +57,7 @@ export class CharacterController { //should we go into first person view when camera is near avatar (radius is lowerradius limit) private _noFirstPerson: boolean = false; + private _down: Vector3 = Vector3.DownReadOnly; public setSlopeLimit(minSlopeLimit: number, maxSlopeLimit: number) { @@ -1065,7 +1066,11 @@ export class CharacterController { //AV could be running down a slope which mean freefall,run,frefall run ... //to remove anim flicker, check if AV has been falling down continously for last few consecutive frames //before changing to free fall animation - if (this._fallFrameCount > this._fallFrameCountMin) { + // if (this._fallFrameCount > this._fallFrameCountMin) { + // actdata = this._actionMap.fall; + // } + + if (!this._isNearGround()) { actdata = this._actionMap.fall; } } @@ -1077,6 +1082,32 @@ export class CharacterController { return actdata; } + //check if any collidable mesh is just below the avatar's ellipsoid + private _isNearGround(): boolean { + //start the ray from the bottom of avatar's ellipsod + //ellipsoid center = avatar position + ellipsoid offset + //ellipsoid bottom = ellipsoid center - ellipsoid height + this._avatar.position.addToRef(this._avatar.ellipsoidOffset, this._ray.origin); + this._ray.origin.y = this._ray.origin.y - this._avatar.ellipsoid.y; + //from the bottom of ellipsoid go down 1/4 the ellipsoid height to check for any mesh + this._ray.length = this._avatar.ellipsoid.y / 2; + //direction is towards the bottom + this._ray.direction = this._down; + + //TODO + //handle case were pick is with a child of avatar, avatar atatchment. etc + //check if any collidable mesh is there just below the avatar's ellipsoid + const pis: PickingInfo[] = this._scene.multiPickWithRay(this._ray, (mesh) => { + if (mesh == this._avatar) return false; + if (mesh.checkCollisions) return true + else return false; + }); + + if (pis.length > 0) return true; + else return false; + + } + /** * rotate avatar with respect to camera direction. */