From c54e7bfef1ee3a20f8a8cc116d684c16b4e0312e Mon Sep 17 00:00:00 2001 From: Codeboy-cn Date: Thu, 26 Sep 2024 16:12:57 +0800 Subject: [PATCH] chore: clean comments --- .../controller/CameraControllerBase.ts | 2 - src/core/Camera3D.ts | 22 +++---- src/math/MathUtil.ts | 1 - src/math/Matrix4.ts | 60 +++---------------- src/math/Plane3D.ts | 1 - src/math/Vector4.ts | 1 - 6 files changed, 19 insertions(+), 68 deletions(-) diff --git a/src/components/controller/CameraControllerBase.ts b/src/components/controller/CameraControllerBase.ts index 00201a89..1d7e0539 100644 --- a/src/components/controller/CameraControllerBase.ts +++ b/src/components/controller/CameraControllerBase.ts @@ -66,7 +66,6 @@ export class CameraControllerBase { * * Get moving speed * @returns number - * @version FlyEngine */ public get speed(): number { return this._speed; @@ -76,7 +75,6 @@ export class CameraControllerBase { * * Set moving speed * @returns number - * @version FlyEngine */ public set speed(val: number) { this._speed = val; diff --git a/src/core/Camera3D.ts b/src/core/Camera3D.ts index f575076e..a99f9db6 100644 --- a/src/core/Camera3D.ts +++ b/src/core/Camera3D.ts @@ -82,17 +82,17 @@ export class Camera3D extends ComponentBase { */ public frustum: Frustum; - public sh_bak: Float32Array = new Float32Array([ - 2.485296, 2.52417, 2.683965, 3.544894, - 0.2323964, 0.1813751, 0.08516902, -4.860471E-05, - -0.2744142, -0.04131086, 0.2248164, -0.005996059, - 0.1551732, 0.137717, 0.1002693, -0.0006728604, - 0.2209381, 0.2109673, 0.1770538, -1.395991E-05, - 0.3529238, 0.2824739, 0.1817433, -0.0005164869, - -0.1344275, -0.1289607, -0.1347626, 7.825881E-06, - 0.2125785, 0.1779549, 0.124602, 0.000503074, - -0.1039777, -0.09676537, -0.07681116, -0.0004372867, - ]); + // public sh_bak: Float32Array = new Float32Array([ + // 2.485296, 2.52417, 2.683965, 3.544894, + // 0.2323964, 0.1813751, 0.08516902, -4.860471E-05, + // -0.2744142, -0.04131086, 0.2248164, -0.005996059, + // 0.1551732, 0.137717, 0.1002693, -0.0006728604, + // 0.2209381, 0.2109673, 0.1770538, -1.395991E-05, + // 0.3529238, 0.2824739, 0.1817433, -0.0005164869, + // -0.1344275, -0.1289607, -0.1347626, 7.825881E-06, + // 0.2125785, 0.1779549, 0.124602, 0.000503074, + // -0.1039777, -0.09676537, -0.07681116, -0.0004372867, + // ]); public sh: Float32Array = new Float32Array(36); diff --git a/src/math/MathUtil.ts b/src/math/MathUtil.ts index e4c3ff9a..5994ef5c 100644 --- a/src/math/MathUtil.ts +++ b/src/math/MathUtil.ts @@ -227,7 +227,6 @@ export class MathUtil { * @param toDirection The transformed direction * @param target The calculated quaternion is null by default and the result is returned * @returns Quaternion The calculated quaternion returns a new instance created if target is null - * @version Orillusion3D 0.5.1 */ public static fromToRotation(fromDirection: Vector3, toDirection: Vector3, target: Quaternion = null): Quaternion { target ||= new Quaternion(); diff --git a/src/math/Matrix4.ts b/src/math/Matrix4.ts index 373db1eb..eb9d59a8 100644 --- a/src/math/Matrix4.ts +++ b/src/math/Matrix4.ts @@ -111,7 +111,6 @@ export class Matrix4 { /** * matrix raw data format FloatArray * @see {@link FloatArray} - * @version Orillusion3D 0.5.1 */ public rawData: FloatArray; @@ -121,8 +120,7 @@ export class Matrix4 { * alloc web runtime cpu memory totalCount * 4(float) * 4 * init matrix memory by totalCount * 4(float) * 4 * @param count every alloc matrix count - * @version Orillusion3D 0.5.1 - */ + */ public static allocMatrix(allocCount: number) { this.allocCount = allocCount; @@ -151,7 +149,6 @@ export class Matrix4 { * @param toDirection second direction * @param target ref matrix * @returns return new one matrix - * @version Orillusion3D 0.5.1 */ public static fromToRotation(fromDirection: Vector3, toDirection: Vector3, target?: Matrix4): Matrix4 { target ||= new Matrix4(); @@ -166,7 +163,6 @@ export class Matrix4 { * @param z z on the central axis * @param degrees rotation angle * @returns Matrix4 result - * @version Orillusion3D 0.5.1 */ public static getAxisRotation(x: number, y: number, z: number, degrees: number): Matrix4 { let m: Matrix4 = new Matrix4(); @@ -347,29 +343,27 @@ export class Matrix4 { * @param eye eye position * @param at target position * @param up normalize axis way - * @version Orillusion3D 0.5.1 */ public lookAt(eye: Vector3, at: Vector3, up: Vector3 = Vector3.Y_AXIS): void { let data = this.rawData; let zAxis: Vector3 = at.subtract(eye, Vector3.HELP_0); - if (zAxis.length < 0.0001) { + if (zAxis.length === 0) { zAxis.z = 1; } zAxis.normalize(); let xAxis: Vector3 = up.crossProduct(zAxis, Vector3.HELP_1); - - if (xAxis.length < 0.0001) { - if (Math.abs(up.z) > 0.9999) { + if (xAxis.length === 0) { + if (Math.abs(up.z) === 1) { zAxis.x += 0.0001; } else { zAxis.z -= 0.0001; } zAxis.normalize(); + xAxis = up.crossProduct(zAxis, Vector3.HELP_1) } - xAxis = up.crossProduct(zAxis, xAxis).normalize(); - - let yAxis = zAxis.crossProduct(xAxis, Vector3.HELP_2).normalize(); + xAxis.normalize(); + let yAxis = zAxis.crossProduct(xAxis, Vector3.HELP_2) data[0] = xAxis.x; data[1] = yAxis.x; @@ -389,7 +383,6 @@ export class Matrix4 { data[12] = -xAxis.dotProduct(eye); data[13] = -yAxis.dotProduct(eye); data[14] = -zAxis.dotProduct(eye); - data[15] = 1; } @@ -398,7 +391,6 @@ export class Matrix4 { /** * matrix multiply * @param mat4 multiply target - * @version Orillusion3D 0.5.1 */ public multiply(mat4: Matrix4): void { let a = this.rawData; @@ -526,7 +518,6 @@ export class Matrix4 { * @param v convert target * @param target ref one vector3 * @returns Vector3 - * @version Orillusion3D 0.5.1 */ public transformVector4(v: Vector3, target?: Vector3): Vector3 { let data: FloatArray = this.rawData; @@ -580,7 +571,6 @@ export class Matrix4 { * @param aspect aspect ratio * @param zn near plane * @param zf far plane - * @version Orillusion3D 0.5.1 */ public perspective(fov: number, aspect: number, zn: number, zf: number) { let data = this.rawData; @@ -640,7 +630,6 @@ export class Matrix4 { }; /** - * @version Orillusion3D 0.5.1 * set matrix orthogonal projection * @param w screen width * @param h screen height @@ -739,7 +728,6 @@ export class Matrix4 { * set matrix from two direction * @param fromDirection first direction * @param toDirection second direction - * @version Orillusion3D 0.5.1 */ public transformDir(fromDirection: Vector3, toDirection: Vector3): this { let data = this.rawData; @@ -862,7 +850,6 @@ export class Matrix4 { /** * multiply matrix a b * @param lhs target matrix - * @version Orillusion3D 0.5.1 */ public append(lhs: Matrix4): void { let data = this.rawData; @@ -908,7 +895,6 @@ export class Matrix4 { * matrix a add matrix b * @param lhs target matrix. * @returns Matrix4 result. - * @version Orillusion3D 0.5.1 */ public add(lhs: Matrix4): Matrix4 { let data = this.rawData; @@ -971,7 +957,6 @@ export class Matrix4 { * matrix a sub matrix b * @param lhs target matrix b. * @returns Matrix4 . - * @version Orillusion3D 0.5.1 */ public sub(lhs: Matrix4): Matrix4 { let data = this.rawData; @@ -1035,7 +1020,6 @@ export class Matrix4 { * Matrix times components. * @param v This matrix is going to be multiplied by this value * @returns Matrix4 Returns a multiplicative result matrix. - * @version Orillusion3D 0.5.1 */ public mult(v: number): Matrix4 { let data = this.rawData; @@ -1067,8 +1051,7 @@ export class Matrix4 { // * @param x Angle of rotation around the x axis. // * @param y Angle of rotation around the y axis. // * @param z Angle of rotation around the z axis. - // * @version Orillusion3D 0.5.1 - // */ + // // */ // public rotation(x: number, y: number, z: number) { // Quaternion.CALCULATION_QUATERNION.fromEulerAngles(x, y, z); // this.makeTransform( @@ -1093,7 +1076,6 @@ export class Matrix4 { * Create a matrix based on the axis and rotation Angle (the matrix created by rotating the degrees according to the axis) * @param degrees Angle of rotation. * @param axis Rotation Angle around axis axis. Axis needs to be specified as the orientation of an axis between x/y/z - * @version Orillusion3D 0.5.1 */ public createByRotation(degrees: number, axis: Vector3): this { let tmp: Matrix4 = Matrix4.helpMatrix; @@ -1170,7 +1152,6 @@ export class Matrix4 { * @param xScale x axis scaling * @param yScale y axis scaling * @param zScale z axis scaling - * @version Orillusion3D 0.5.1 */ public appendScale(xScale: number, yScale: number, zScale: number) { Matrix4.helpMatrix.createByScale(xScale, yScale, zScale); @@ -1182,7 +1163,6 @@ export class Matrix4 { * @param xScale x axis scaling * @param yScale y axis scaling * @param zScale z axis scaling - * @version Orillusion3D 0.5.1 */ public createByScale(xScale: number, yScale: number, zScale: number): void { let data = this.rawData; @@ -1209,7 +1189,6 @@ export class Matrix4 { * @param x x axis scaling * @param y y axis scaling * @param z z axis scaling - * @version Orillusion3D 0.5.1 */ public appendTranslation(x: number, y: number, z: number) { let data = this.rawData; @@ -1221,7 +1200,6 @@ export class Matrix4 { /** * Returns a clone of the current matrix * @returns Matrix4 The cloned matrix - * @version Orillusion3D 0.5.1 */ public clone(): Matrix4 { let ret: Matrix4 = new Matrix4(); @@ -1233,7 +1211,6 @@ export class Matrix4 { * Assigns a value to one row of the current matrix * @param row Row of copy * @param Vector3 Value of copy - * @version Orillusion3D 0.5.1 */ public copyRowFrom(row: number, Vector3: Vector3) { let data = this.rawData; @@ -1271,7 +1248,6 @@ export class Matrix4 { * One of the rows in the copy matrix stores the values in Vector3. * @param row Row of copy * @param Vector3 Copy the storage target - * @version Orillusion3D 0.5.1 */ public copyRowTo(row: number, Vector3: Vector3) { let data = this.rawData; @@ -1309,7 +1285,6 @@ export class Matrix4 { * Assigns the value of a matrix to the current matrix. * @param sourceMatrix3D source Matrix * @returns Returns the current matrix - * @version Orillusion3D 0.5.1 */ public copyFrom(sourceMatrix3D: Matrix4): Matrix4 { let data: FloatArray = this.rawData; @@ -1337,7 +1312,6 @@ export class Matrix4 { * @param vector The target array. * @param index copy from the index of the array. * @param transpose Whether to transpose the current matrix. - * @version Orillusion3D 0.5.1 */ public copyRawDataTo(vector: FloatArray, index: number = 0, transpose: boolean = false) { let data: FloatArray = this.rawData; @@ -1363,7 +1337,6 @@ export class Matrix4 { * Assigns a value to a column of the current matrix * @param col column * @param Vector3 Source of value - * @version Orillusion3D 0.5.1 */ public copyColFrom(col: number, Vector3: Vector3) { let data: FloatArray = this.rawData; @@ -1401,7 +1374,6 @@ export class Matrix4 { * Copy a column of the current matrix * @param col column * @param Vector3 Target of copy - * @version Orillusion3D 0.5.1 */ public copyColTo(col: number, Vector3: Vector3) { let data: FloatArray = this.rawData; @@ -1438,7 +1410,6 @@ export class Matrix4 { /** * Copy the current matrix * @param dest Target of copy - * @version Orillusion3D 0.5.1 */ public copyToMatrix3D(dest: Matrix4) { dest.rawData = this.rawData.slice(0); @@ -1462,7 +1433,6 @@ export class Matrix4 { * @see Orientation3D.EULER_ANGLES * @see Orientation3D.QUATERNION * @returns Vector3[3] pos rot scale - * @version Orillusion3D 0.5.1 */ public decompose(orientationStyle: string = 'eulerAngles', target?: Vector3[]): Vector3[] { let q: Quaternion = Quaternion.CALCULATION_QUATERNION; @@ -1657,7 +1627,6 @@ export class Matrix4 { * @param v Vector to transform * @param target The default is null and if the current argument is null then a new Vector3 will be returned * @returns Vector3 The transformed vector - * @version Orillusion3D 0.5.1 */ public deltaTransformVector(v: Vector3, target?: Vector3): Vector3 { target ||= new Vector3(); @@ -1676,7 +1645,6 @@ export class Matrix4 { /** * Unifies the current matrix - * @version Orillusion3D 0.5.1 */ public identity() { let data: FloatArray = this.rawData; @@ -1703,7 +1671,6 @@ export class Matrix4 { /** * Fill the current matrix * @param value The filled value - * @version Orillusion3D 0.5.1 */ public fill(value: number) { let data: FloatArray = this.rawData; @@ -1727,7 +1694,6 @@ export class Matrix4 { /** * Invert the current matrix - * @version Orillusion3D 0.5.1 */ public invers33() { /// Invert a 3x3 using cofactors. This is about 8 times faster than @@ -1764,7 +1730,6 @@ export class Matrix4 { /** * Invert the current matrix * @returns boolean Whether can invert it - * @version Orillusion3D 0.5.1 */ public invert(): boolean { let d = this.determinant; @@ -1836,7 +1801,6 @@ export class Matrix4 { * @param v Vector of transformation * @param target If the current argument is null then a new Vector3 will be returned * @returns Vector3 The transformed vector - * @version Orillusion3D 0.5.1 */ public transformVector(v: Vector3, target?: Vector3): Vector3 { let data: FloatArray = this.rawData; @@ -1856,7 +1820,6 @@ export class Matrix4 { /** * The current matrix transpose - * @version Orillusion3D 0.5.1 */ public transpose() { let data: FloatArray = this.rawData; @@ -1882,7 +1845,6 @@ export class Matrix4 { /** * Returns the matrix determinant * @returns number determinant - * @version Orillusion3D 0.5.1 */ public get determinant(): number { let data: FloatArray = this.rawData; @@ -1913,7 +1875,6 @@ export class Matrix4 { /** * Return translation * @returns Vector3 Position of translation - * @version Orillusion3D 0.5.1 */ public get position(): Vector3 { this._position.set(this.rawData[12], this.rawData[13], this.rawData[14]); @@ -1923,7 +1884,6 @@ export class Matrix4 { /** * Set Position of translation * @param value Position of translation - * @version Orillusion3D 0.5.1 */ public set position(value: Vector3) { let data: FloatArray = this.rawData; @@ -1936,7 +1896,6 @@ export class Matrix4 { * get Component of scale * * @returns Vector3 scale - * @version Orillusion3D 0.5.1 */ public get scale(): Vector3 { let data: FloatArray = this.rawData; @@ -1961,7 +1920,6 @@ export class Matrix4 { * Returns the value of the matrix as a string * * @returns string - * @version Orillusion3D 0.5.1 */ public toString(): string { let data = this.rawData; @@ -2007,7 +1965,6 @@ export class Matrix4 { * @param m0 Matrix 0 * @param m1 Matrix 1 * @param t Factor of interpolation 0.0 - 1.0 - * @version Orillusion3D 0.5.1 */ public lerp(m0: Matrix4, m1: Matrix4, t: number): void { ///t(m1 - m0) + m0 @@ -2036,7 +1993,6 @@ export class Matrix4 { /** * Get the maximum value of the matrix scaled on each axis - * @version Orillusion3D 0.5.1 4.0 */ public getMaxScaleOnAxis(): number { let te = this.rawData; diff --git a/src/math/Plane3D.ts b/src/math/Plane3D.ts index 5f8c532d..8f52c13a 100644 --- a/src/math/Plane3D.ts +++ b/src/math/Plane3D.ts @@ -8,7 +8,6 @@ import { PlaneClassification } from "./PlaneClassification"; * Plane3D 类 3D空间中的平面表示数据 * 由a,b,c,d4个分量组成 在三维空间中定义了一个平面 Ax + By + Cz + D = 0 * @includeExample geom/Plane3D.ts -* @version * @platform Web,Native */ export class Plane3D { diff --git a/src/math/Vector4.ts b/src/math/Vector4.ts index 4fc56e92..8ab26b4a 100644 --- a/src/math/Vector4.ts +++ b/src/math/Vector4.ts @@ -102,7 +102,6 @@ export class Vector4 { /** * A three-dimensional position or projection that can be used as * a perspective projection can also be a w in a quaternion - * @version Orillusion3D 0.5.1 */ public w: number = 1;