From 2638efa42707542ae996bd8e0fe330450c7271fd Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Thu, 28 Jan 2021 15:40:33 +0100 Subject: [PATCH] Face3: Remove from core. --- docs/api/en/core/Face3.html | 100 ------------------------- docs/api/en/core/Raycaster.html | 2 +- docs/api/zh/core/Face3.html | 96 ------------------------ docs/api/zh/core/Raycaster.html | 2 +- docs/list.json | 2 - examples/jsm/deprecated/Geometry.d.ts | 101 +++++++++++++++++++++++++- examples/jsm/deprecated/Geometry.js | 54 +++++++++++++- src/Three.Legacy.js | 8 -- src/Three.d.ts | 1 - src/Three.js | 1 - src/core/Face3.d.ts | 100 ------------------------- src/core/Face3.js | 58 --------------- test/unit/src/core/Face3.tests.js | 86 ---------------------- test/unit/three.source.unit.js | 1 - 14 files changed, 152 insertions(+), 460 deletions(-) delete mode 100644 docs/api/en/core/Face3.html delete mode 100644 docs/api/zh/core/Face3.html delete mode 100644 src/core/Face3.d.ts delete mode 100644 src/core/Face3.js delete mode 100644 test/unit/src/core/Face3.tests.js diff --git a/docs/api/en/core/Face3.html b/docs/api/en/core/Face3.html deleted file mode 100644 index f788b426254b3b..00000000000000 --- a/docs/api/en/core/Face3.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - -

[name]

- -

- Triangular face used in deprecated geometry. These are created automatically for all - standard geometry types, however if you are building a custom geometry you will have to - create them manually. -

- -

Constructor

- -

[name]( [param:Integer a], [param:Integer b], [param:Integer c], [param:Vector3 normal], [param:Color color], [param:Integer materialIndex] )

-

- a — Vertex A index.
- b — Vertex B index.
- c — Vertex C index.

- - normal — (optional) Face normal ([page:Vector3 Vector3]) or array of vertex normals. - If a single vector is passed in, this sets [page:.normal], otherwise if an array of three - vectors is passed in this sets [page:.vertexNormals]

- - color — (optional) Face [page:Color color] or array of vertex [page:Color colors]. - If a single vector is passed in, this sets [page:.color], otherwise if an array of three - vectors is passed in this sets [page:.vertexColors]

- - materialIndex — (optional) which index of an array of materials to associate - with the face. -

- -

Properties

- -

[property:Integer a]

-

- Vertex A index. -

- -

[property:Integer b]

-

- Vertex B index. -

- -

[property:Integer c]

-

- Vertex C index. -

- -

[property:Vector3 normal]

-

- Face normal - vector showing the direction of the Face3. If calculated automatically, - this is the normalized cross product of two edges of the - triangle. Default is *(0, 0, 0)*. -

- -

[property:Color color]

-

- Face color - for this to be used a material's [page:Material.vertexColors vertexColors] property - must be set to *true*. -

- -

[property:Array vertexNormals]

-

- Array of 3 [page:Vector3 vertex normals]. -

- -

[property:Array vertexColors]

-

- Array of 3 vertex colors - for these to be used a material's [page:Material.vertexColors vertexColors] property - must be set to *true*. -

- - -

[property:Integer materialIndex]

-

- Material index (points to an index in the associated array of materials). Default is *0*. -

- -

Methods

- -

[method:Face3 clone]()

-

Creates a new clone of the Face3 object.

- -

[method:Face3 copy]( [param:Face3 face3] )

-

Copy the parameters of another Face3 into this.

- - -

Source

- -

- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] -

- - diff --git a/docs/api/en/core/Raycaster.html b/docs/api/en/core/Raycaster.html index 81c88bb42767e9..381e394eeefa4e 100644 --- a/docs/api/en/core/Raycaster.html +++ b/docs/api/en/core/Raycaster.html @@ -172,7 +172,7 @@

[method:Array intersectObject]( [param:Object3D object], [param:Boolean recu

[page:Float distance] – distance between the origin of the ray and the intersection
[page:Vector3 point] – point of intersection, in world coordinates
- [page:Face3 face] – intersected face
+ [page:Object face] – intersected face
[page:Integer faceIndex] – index of the intersected face
[page:Object3D object] – the intersected object
[page:Vector2 uv] - U,V coordinates at point of intersection
diff --git a/docs/api/zh/core/Face3.html b/docs/api/zh/core/Face3.html deleted file mode 100644 index b2ceefa8bb2737..00000000000000 --- a/docs/api/zh/core/Face3.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - -

[name]

- -

- 在 deprecated geometry 中被使用到的三角形面。这些三角形面会为所有标准几何体自动创建。 - 然而,如果你正在构建一个自定义几何体,你需要手动创建这些三角形面。 -

- -

构造函数

- -

[name]( [param:Integer a], [param:Integer b], [param:Integer c], [param:Vector3 normal], [param:Color color], [param:Integer materialIndex] )

-

- a — 顶点 A 的索引。
- b — 顶点 B 的索引。
- c — 顶点 C 的索引。

- - normal — (可选) 面的法向量 ([page:Vector3 Vector3]) 或顶点法向量队列。 - 如果参数传入单一矢量,则用该量设置面的法向量 [page:.normal],如果传入的是包含三个矢量的队列, - 则用该量设置 [page:.vertexNormals]

- - color — (可选) 面的颜色值 [page:Color color] 或顶点颜色值的队列。 - 如果参数传入单一矢量,则用该量设置 [page:.color],如果传入的是包含三个矢量的队列, - 则用该量设置 [page:.vertexColors]

- - materialIndex — (可选) 材质队列中与该面对应的材质的索引。 -

- -

属性

- -

[property:Integer a]

-

- 顶点 A 的索引。 -

- -

[property:Integer b]

-

- 顶点 B 的索引。 -

- -

[property:Integer c]

-

- 顶点 C 的索引。 -

- -

[property:Vector3 normal]

-

- 面的法向量 - 矢量展示 Face3 的方向。如果该量是通过调用自动计算的, - 该值等于归一化的两条边的差积。默认值是 *(0, 0, 0)*。 -

- -

[property:Color color]

-

- 面的颜色值 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为 - *true*。 -

- -

[property:Array vertexNormals]

-

- 包含三个 [page:Vector3 vertex normals] 的队列。 -

- -

[property:Array vertexColors]

-

- 包含 3 个顶点颜色值的队列 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为 - *true*。 -

- -

[property:Integer materialIndex]

-

- 材质队列中与该面相关的材质的索引。默认值为 *0*。 -

- -

方法

- -

[method:Face3 clone]()

-

克隆该 Face3 对象。

- -

[method:Face3 copy]( [param:Face3 face3] )

-

将参数指定的 Face3 对象的数据拷贝到当前对象。

- - -

源代码

- -

- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] -

- - diff --git a/docs/api/zh/core/Raycaster.html b/docs/api/zh/core/Raycaster.html index bdbdd3df267c8b..63fb11444e090e 100644 --- a/docs/api/zh/core/Raycaster.html +++ b/docs/api/zh/core/Raycaster.html @@ -175,7 +175,7 @@

[method:Array intersectObject]( [param:Object3D object], [param:Boolean recu

[page:Float distance] —— 射线投射原点和相交部分之间的距离。
[page:Vector3 point] —— 相交部分的点(世界坐标)
- [page:Face3 face] —— 相交的面
+ [page:Object face] —— 相交的面
[page:Integer faceIndex] —— 相交的面的索引
[page:Object3D object] —— 相交的物体
[page:Vector2 uv] —— 相交部分的点的UV坐标。
diff --git a/docs/list.json b/docs/list.json index f43e8b566fbfb0..24074a1df5fb81 100644 --- a/docs/list.json +++ b/docs/list.json @@ -87,7 +87,6 @@ "BufferGeometry": "api/en/core/BufferGeometry", "Clock": "api/en/core/Clock", "EventDispatcher": "api/en/core/EventDispatcher", - "Face3": "api/en/core/Face3", "GLBufferAttribute": "api/en/core/GLBufferAttribute", "InstancedBufferAttribute": "api/en/core/InstancedBufferAttribute", "InstancedBufferGeometry": "api/en/core/InstancedBufferGeometry", @@ -599,7 +598,6 @@ "BufferGeometry": "api/zh/core/BufferGeometry", "Clock": "api/zh/core/Clock", "EventDispatcher": "api/zh/core/EventDispatcher", - "Face3": "api/zh/core/Face3", "GLBufferAttribute": "api/zh/core/GLBufferAttribute", "InstancedBufferAttribute": "api/zh/core/InstancedBufferAttribute", "InstancedBufferGeometry": "api/zh/core/InstancedBufferGeometry", diff --git a/examples/jsm/deprecated/Geometry.d.ts b/examples/jsm/deprecated/Geometry.d.ts index 61a500f708bc08..cb44bc5f8467e7 100644 --- a/examples/jsm/deprecated/Geometry.d.ts +++ b/examples/jsm/deprecated/Geometry.d.ts @@ -1,7 +1,6 @@ import { Vector3, Color, - Face3, Vector2, Vector4, Box3, @@ -17,7 +16,7 @@ import { } from '../../../src/Three'; /** - * @deprecated Use {@link Face3} instead. + * @deprecated Use Face3 instead. */ export interface MorphTarget { @@ -37,8 +36,6 @@ export interface MorphNormals { /** * Base class for geometries - * - * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js|src/core/Geometry.js} */ export class Geometry extends EventDispatcher { @@ -279,3 +276,99 @@ export class Geometry extends EventDispatcher { animations: AnimationClip[]; } + +/** + * Triangle face. + */ +export class Face3 { + + /** + * @param a Vertex A index. + * @param b Vertex B index. + * @param c Vertex C index. + * @param normal Face normal or array of vertex normals. + * @param color Face color or array of vertex colors. + * @param materialIndex Material index. + */ + constructor( + a: number, + b: number, + c: number, + normal?: Vector3, + color?: Color, + materialIndex?: number + ); + constructor( + a: number, + b: number, + c: number, + normal?: Vector3, + vertexColors?: Color[], + materialIndex?: number + ); + constructor( + a: number, + b: number, + c: number, + vertexNormals?: Vector3[], + color?: Color, + materialIndex?: number + ); + constructor( + a: number, + b: number, + c: number, + vertexNormals?: Vector3[], + vertexColors?: Color[], + materialIndex?: number + ); + + /** + * Vertex A index. + */ + a: number; + + /** + * Vertex B index. + */ + b: number; + + /** + * Vertex C index. + */ + c: number; + + /** + * Face normal. + * @default new THREE.Vector3() + */ + normal: Vector3; + + /** + * Array of 3 vertex normals. + * @default [] + */ + vertexNormals: Vector3[]; + + /** + * Face color. + * @default new THREE.Color() + */ + color: Color; + + /** + * Array of 3 vertex colors. + * @default [] + */ + vertexColors: Color[]; + + /** + * Material index (points to {@link Mesh.material}). + * @default 0 + */ + materialIndex: number; + + clone(): Face3; + copy( source: Face3 ): this; + +} diff --git a/examples/jsm/deprecated/Geometry.js b/examples/jsm/deprecated/Geometry.js index 491653006f75f2..5ee3346a3c148f 100644 --- a/examples/jsm/deprecated/Geometry.js +++ b/examples/jsm/deprecated/Geometry.js @@ -4,7 +4,6 @@ import { BufferGeometry, Color, EventDispatcher, - Face3, Float32BufferAttribute, Matrix3, Matrix4, @@ -1814,4 +1813,57 @@ class DirectGeometry { } +class Face3 { + + constructor( a, b, c, normal, color, materialIndex = 0 ) { + + this.a = a; + this.b = b; + this.c = c; + + this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3(); + this.vertexNormals = Array.isArray( normal ) ? normal : []; + + this.color = ( color && color.isColor ) ? color : new Color(); + this.vertexColors = Array.isArray( color ) ? color : []; + + this.materialIndex = materialIndex; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.a = source.a; + this.b = source.b; + this.c = source.c; + + this.normal.copy( source.normal ); + this.color.copy( source.color ); + + this.materialIndex = source.materialIndex; + + for ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) { + + this.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); + + } + + for ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) { + + this.vertexColors[ i ] = source.vertexColors[ i ].clone(); + + } + + return this; + + } + +} + export { Geometry }; diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index 2d9b6a39ae91e6..5e959fde4a8dad 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -24,7 +24,6 @@ import { import { BufferGeometry } from './core/BufferGeometry.js'; import { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js'; import { InterleavedBuffer } from './core/InterleavedBuffer.js'; -import { Face3 } from './core/Face3.js'; import { Object3D } from './core/Object3D.js'; import { Uniform } from './core/Uniform.js'; import { Raycaster } from './core/Raycaster.js'; @@ -87,13 +86,6 @@ import { Scene } from './scenes/Scene.js'; export { MathUtils as Math }; -export function Face4( a, b, c, d, normal, color, materialIndex ) { - - console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ); - return new Face3( a, b, c, normal, color, materialIndex ); - -} - export const LineStrip = 0; export const LinePieces = 1; export const NoColors = 0; diff --git a/src/Three.d.ts b/src/Three.d.ts index 8a86af5defda87..762d911e274498 100644 --- a/src/Three.d.ts +++ b/src/Three.d.ts @@ -98,7 +98,6 @@ export * from './core/InstancedInterleavedBuffer'; export * from './core/InterleavedBuffer'; export * from './core/InstancedBufferAttribute'; export * from './core/BufferAttribute'; -export * from './core/Face3'; export * from './core/Object3D'; export * from './core/Raycaster'; export * from './core/Layers'; diff --git a/src/Three.js b/src/Three.js index 9cfe9682851d2a..7e3bb3e8b29baa 100644 --- a/src/Three.js +++ b/src/Three.js @@ -95,7 +95,6 @@ export { InterleavedBuffer } from './core/InterleavedBuffer.js'; export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js'; export { GLBufferAttribute } from './core/GLBufferAttribute.js'; export * from './core/BufferAttribute.js'; -export { Face3 } from './core/Face3.js'; export { Object3D } from './core/Object3D.js'; export { Raycaster } from './core/Raycaster.js'; export { Layers } from './core/Layers.js'; diff --git a/src/core/Face3.d.ts b/src/core/Face3.d.ts deleted file mode 100644 index 8c8955a58d0652..00000000000000 --- a/src/core/Face3.d.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { Vector3 } from './../math/Vector3'; -import { Color } from './../math/Color'; - -/** - * Triangle face. - * - * @source https://github.com/mrdoob/three.js/blob/master/src/core/Face3.js - */ -export class Face3 { - - /** - * @param a Vertex A index. - * @param b Vertex B index. - * @param c Vertex C index. - * @param normal Face normal or array of vertex normals. - * @param color Face color or array of vertex colors. - * @param materialIndex Material index. - */ - constructor( - a: number, - b: number, - c: number, - normal?: Vector3, - color?: Color, - materialIndex?: number - ); - constructor( - a: number, - b: number, - c: number, - normal?: Vector3, - vertexColors?: Color[], - materialIndex?: number - ); - constructor( - a: number, - b: number, - c: number, - vertexNormals?: Vector3[], - color?: Color, - materialIndex?: number - ); - constructor( - a: number, - b: number, - c: number, - vertexNormals?: Vector3[], - vertexColors?: Color[], - materialIndex?: number - ); - - /** - * Vertex A index. - */ - a: number; - - /** - * Vertex B index. - */ - b: number; - - /** - * Vertex C index. - */ - c: number; - - /** - * Face normal. - * @default new THREE.Vector3() - */ - normal: Vector3; - - /** - * Array of 3 vertex normals. - * @default [] - */ - vertexNormals: Vector3[]; - - /** - * Face color. - * @default new THREE.Color() - */ - color: Color; - - /** - * Array of 3 vertex colors. - * @default [] - */ - vertexColors: Color[]; - - /** - * Material index (points to {@link Mesh.material}). - * @default 0 - */ - materialIndex: number; - - clone(): Face3; - copy( source: Face3 ): this; - -} diff --git a/src/core/Face3.js b/src/core/Face3.js deleted file mode 100644 index 8f67bc51baeb6d..00000000000000 --- a/src/core/Face3.js +++ /dev/null @@ -1,58 +0,0 @@ -import { Color } from '../math/Color.js'; -import { Vector3 } from '../math/Vector3.js'; - -class Face3 { - - constructor( a, b, c, normal, color, materialIndex = 0 ) { - - this.a = a; - this.b = b; - this.c = c; - - this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3(); - this.vertexNormals = Array.isArray( normal ) ? normal : []; - - this.color = ( color && color.isColor ) ? color : new Color(); - this.vertexColors = Array.isArray( color ) ? color : []; - - this.materialIndex = materialIndex; - - } - - clone() { - - return new this.constructor().copy( this ); - - } - - copy( source ) { - - this.a = source.a; - this.b = source.b; - this.c = source.c; - - this.normal.copy( source.normal ); - this.color.copy( source.color ); - - this.materialIndex = source.materialIndex; - - for ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) { - - this.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); - - } - - for ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) { - - this.vertexColors[ i ] = source.vertexColors[ i ].clone(); - - } - - return this; - - } - -} - - -export { Face3 }; diff --git a/test/unit/src/core/Face3.tests.js b/test/unit/src/core/Face3.tests.js deleted file mode 100644 index 1a37e8baace7f8..00000000000000 --- a/test/unit/src/core/Face3.tests.js +++ /dev/null @@ -1,86 +0,0 @@ -/* global QUnit */ - -import { Face3 } from '../../../../src/core/Face3'; -import { Color } from '../../../../src/math/Color'; -import { Vector3 } from '../../../../src/math/Vector3'; - -export default QUnit.module( 'Core', () => { - - QUnit.module( 'Face3', () => { - - // INSTANCING - QUnit.todo( "Instancing", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - // PUBLIC STUFF - QUnit.test( "copy", ( assert ) => { - - var instance = new Face3( 0, 1, 2, new Vector3( 0, 1, 0 ), new Color( 0.25, 0.5, 0.75 ), 2 ); - var copiedInstance = new Face3().copy( instance ); - - checkCopy( copiedInstance, assert ); - checkVertexAndColors( copiedInstance, assert ); - - } ); - - QUnit.test( "copy (more)", ( assert ) => { - - var instance = new Face3( 0, 1, 2, - [ new Vector3( 0, 1, 0 ), new Vector3( 1, 0, 1 ) ], - [ new Color( 0.25, 0.5, 0.75 ), new Color( 1, 0, 0.4 ) ], - 2 ); - var copiedInstance = new Face3().copy( instance ); - - checkCopy( copiedInstance, assert ); - checkVertexAndColorArrays( copiedInstance, assert ); - - } ); - - QUnit.test( "clone", ( assert ) => { - - var instance = new Face3( 0, 1, 2, new Vector3( 0, 1, 0 ), new Color( 0.25, 0.5, 0.75 ), 2 ); - var copiedInstance = instance.clone(); - - checkCopy( copiedInstance, assert ); - checkVertexAndColors( copiedInstance, assert ); - - } ); - - function checkCopy( copiedInstance, assert ) { - - assert.ok( copiedInstance instanceof Face3, "copy created the correct type" ); - assert.ok( - copiedInstance.a === 0 && - copiedInstance.b === 1 && - copiedInstance.c === 2 && - copiedInstance.materialIndex === 2 - , "properties where copied" ); - - } - - function checkVertexAndColors( copiedInstance, assert ) { - - assert.ok( - copiedInstance.normal.x === 0 && copiedInstance.normal.y === 1 && copiedInstance.normal.z === 0 && - copiedInstance.color.r === 0.25 && copiedInstance.color.g === 0.5 && copiedInstance.color.b === 0.75 - , "properties where copied" ); - - } - - function checkVertexAndColorArrays( copiedInstance, assert ) { - - assert.ok( - copiedInstance.vertexNormals[ 0 ].x === 0 && copiedInstance.vertexNormals[ 0 ].y === 1 && copiedInstance.vertexNormals[ 0 ].z === 0 && - copiedInstance.vertexNormals[ 1 ].x === 1 && copiedInstance.vertexNormals[ 1 ].y === 0 && copiedInstance.vertexNormals[ 1 ].z === 1 && - copiedInstance.vertexColors[ 0 ].r === 0.25 && copiedInstance.vertexColors[ 0 ].g === 0.5 && copiedInstance.vertexColors[ 0 ].b === 0.75 && - copiedInstance.vertexColors[ 1 ].r === 1 && copiedInstance.vertexColors[ 1 ].g === 0 && copiedInstance.vertexColors[ 1 ].b === 0.4 - , "properties where copied" ); - - } - - } ); - -} ); diff --git a/test/unit/three.source.unit.js b/test/unit/three.source.unit.js index 430d74271efecb..9077b1418833f8 100644 --- a/test/unit/three.source.unit.js +++ b/test/unit/three.source.unit.js @@ -48,7 +48,6 @@ import './src/core/BufferAttribute.tests'; import './src/core/BufferGeometry.tests'; import './src/core/Clock.tests'; import './src/core/EventDispatcher.tests'; -import './src/core/Face3.tests'; import './src/core/InstancedBufferAttribute.tests'; import './src/core/InstancedBufferGeometry.tests'; import './src/core/InstancedInterleavedBuffer.tests';