Skip to content

Commit

Permalink
Updated Vector3 to last release
Browse files Browse the repository at this point in the history
  • Loading branch information
agargaro committed Mar 10, 2024
1 parent f59ab26 commit f45c0a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/patch/Matrix4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Object3D } from "three";
/** @internal Override compose method because is called for every rendered object and can be performance critical after Vector3 patch. */
export function applyMatrix4Patch(parent: Object3D): void {
parent.matrix.compose = function (position: any, quaternion: any, scale: any) {

const te = this.elements;

const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
Expand Down Expand Up @@ -35,6 +34,5 @@ export function applyMatrix4Patch(parent: Object3D): void {
te[15] = 1;

return this;

};
}
14 changes: 7 additions & 7 deletions src/patch/Vector3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function patchVector(vec3: Vector3Ext): void {
Object.setPrototypeOf(vec3, Vector3Ext.prototype);
}

/** Updated to r158 */
/** @LASTREV 162 Vector3 */
class Vector3Ext {
public distanceToManhattan: (v: Vector3) => number; //remove when fix deprecated d.ts
public lengthManhattan: () => number; //remove when fix deprecated d.ts
Expand Down Expand Up @@ -561,12 +561,12 @@ class Vector3Ext {
}

randomDirection() {
const u = (Math.random() - 0.5) * 2;
const t = Math.random() * Math.PI * 2;
const f = Math.sqrt(1 - u ** 2);
this._x = f * Math.cos(t);
this._y = f * Math.sin(t);
this._z = u;
const theta = Math.random() * Math.PI * 2;
const u = Math.random() * 2 - 1;
const c = Math.sqrt(1 - u * u);
this.x = c * Math.cos(theta);
this.y = u;
this.z = c * Math.sin(theta);
this._onChangeCallback();
return this;
}
Expand Down

0 comments on commit f45c0a0

Please sign in to comment.