diff --git a/docs/api/en/constants/DrawModes.html b/docs/api/en/constants/DrawModes.html deleted file mode 100644 index 1f08943792dc0171e6a3466a7a7a9ecdd715c231..0000000000000000000000000000000000000000 --- a/docs/api/en/constants/DrawModes.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - -

Draw Mode Constants

- -

- These are valid values for [page:Mesh.drawMode], and control how the list of vertices is interpeted once sent to the GPU. -

- -

Draw Modes

- - - THREE.TrianglesDrawMode - -

- This is the default, and results in every three consecutive vertices (v0, v1, v2), (v3, v4, v5), ... - being interpreted as a separate triangle.
- If the number of vertices is not a multiple of 3, excess vertices are ignored. -

- - - THREE.TriangleStripDrawMode - -

- This will result in a series of triangles connected in a strip, given by (v0, v1, v2), (v2, v1, v3), (v2, v3, v4), ... - so that every subsequent triangle shares two vertices with the previous triangle. -

- - - THREE.TriangleFanDrawMode - -

- This will result in a series of triangles each sharing the first vertex (like a fan), - given by (v0, v1, v2), (v0, v2, v3), (v0, v3, v4), ...

- - Note: As of [link:https://en.wikipedia.org/wiki/DirectX#DirectX_10 DirectX10], this mode is not supported. As Chrome and Firefox - render WebGL using [link:https://en.wikipedia.org/wiki/ANGLE_(software) ANGLE] on Windows, - internally this mode will be converted to a supported mode, which will likely lead to lowered - performance on those browsers. -

- - -

Usage

- - - var geometry = new THREE.BufferGeometry(); - - var vertices = []; - - vertices.push( -10, 10, 0 ); - vertices.push( -10, -10, 0 ); - vertices.push( 10, -10, 0 ); - - // ... - - geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); - - var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); - - var mesh = new THREE.Mesh( geometry, material ); - mesh.setDrawMode( THREE.TrianglesDrawMode ); //default - - scene.add( mesh ); - - -

Source

- -

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

- - diff --git a/docs/api/en/objects/Mesh.html b/docs/api/en/objects/Mesh.html index 209961b325a737288d7598bab8a1bcd56373b137..ecc429169f996cec101b144c6be0f31d4d842a2e 100644 --- a/docs/api/en/objects/Mesh.html +++ b/docs/api/en/objects/Mesh.html @@ -41,18 +41,6 @@

Properties

See the base [page:Object3D] class for common properties.

-

[property:Integer drawMode]

-

- Determines how the mesh triangles are constructed from the vertices. - See the draw mode [page:DrawModes constants] for all possible values. - Default is [page:DrawModes TrianglesDrawMode]. -

-

- A sensible usage of this property is only possible when [page:Mesh.geometry] is of type [page:BufferGeometry BufferGeometry] - since the engine always assumes *THREE.TrianglesDrawMode* for [page:Geometry Geometry]. -

- -

[property:Boolean isMesh]

Used to check whether this or derived classes are meshes. Default is *true*.

@@ -90,9 +78,6 @@

Methods

See the base [page:Object3D] class for common methods.

-

[method:null setDrawMode]( [param:Integer value] )

-

Set the value of [page:.drawMode drawMode].

-

[method:Mesh clone]()

Returns a clone of this [name] object and its descendants.

diff --git a/docs/api/zh/constants/DrawModes.html b/docs/api/zh/constants/DrawModes.html deleted file mode 100644 index bdccbb29dd239e1f604372200d17ac4825713e3b..0000000000000000000000000000000000000000 --- a/docs/api/zh/constants/DrawModes.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - -

绘图模式常量(Draw Mode Constants)

- -

- 这些是[page:Mesh.drawMode]的有效值,控制着顶点列表一旦被发送到GPU中将如何被解释。 -

- - -

绘图模式

- - - THREE.TrianglesDrawMode - -

- 这是默认值,这将使得每三个连续顶点(v0, v1, v2),(v3, v4, v5),……被解释为一个单独的三角形。 -
- 如果顶点的数量不是3的倍数,那么将会忽略多余的顶点。 -

- - - THREE.TriangleStripDrawMode - -

- 这将使得一系列的三角形(由(v0, v1, v2),(v2, v1, v3),(v2, v3, v4),……给定)一个一个地连在一起,每一个连续的三角形将和前一个三角形共享两个顶点。 -

- - - THREE.TriangleFanDrawMode - -

-这将会使得一个序列中的每一个三角形(由(v0, v1, v2),(v0, v2, v3),(v0, v3, v4),……给定)共享它们的第一个顶点(就像风扇一样)。

- - 注意:截至[link:https://en.wikipedia.org/wiki/DirectX#DirectX_10 DirectX10]这个模式还没有被支持。 - 由于Chorme和Firefox在Windows上是使用[link:https://en.wikipedia.org/wiki/ANGLE_(software) ANGLE]来渲染WebGL的,所以这种模式将会在内部转换为受支持的模式, - 但可能会导致这些浏览器在性能上降低一些。 -

- - -

用法

- - - var geometry = new THREE.BufferGeometry(); - - var vertices = []; - - vertices.push( -10, 10, 0 ); - vertices.push( -10, -10, 0 ); - vertices.push( 10, -10, 0 ); - - // ... - - geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); - - var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); - - var mesh = new THREE.Mesh( geometry, material ); - mesh.setDrawMode( THREE.TrianglesDrawMode ); //default - - scene.add( mesh ); - - - - -

源代码

- -

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

- - diff --git a/docs/api/zh/objects/Mesh.html b/docs/api/zh/objects/Mesh.html index 4cf6edb0b3f6a7b9e8bb7ab645b4bbee31640dc7..50d85dafbfe6260eaa99142062df37577e3899b6 100644 --- a/docs/api/zh/objects/Mesh.html +++ b/docs/api/zh/objects/Mesh.html @@ -40,17 +40,6 @@

属性

共有属性请参见其基类[page:Object3D]。

-

[property:Integer drawMode]

-

- 决定了网格中的三角形将如何从顶点来构造。 - 请参阅draw mode [page:DrawModes constants](绘图模式常量)来查看其所有可能的值。 - 其默认值是[page:DrawModes TrianglesDrawMode]。 -

-

- A sensible usage of this property is only possible when [page:Mesh.geometry] is of type [page:BufferGeometry BufferGeometry] - since the engine always assumes *THREE.TrianglesDrawMode* for [page:Geometry Geometry]. -

-

[property:Boolean isMesh]

用于检查这个类或者其派生类是否为网格,默认值为*true*。

@@ -85,9 +74,6 @@

方法

共有方法请参见其基类[page:Object3D]。

-

[method:null setDrawMode]( [param:Integer value] )

-

设置[page:.drawMode drawMode]的值。

-

[method:Mesh clone]()

返回这个[name]对象及其子级的克隆。

diff --git a/docs/list.js b/docs/list.js index d86b77069e859b5374893fabe2c73b11d965d6c1..313919b6bbecd2f1ea28be25df6b1d7902460eba 100644 --- a/docs/list.js +++ b/docs/list.js @@ -76,7 +76,6 @@ var list = { "Animation": "api/en/constants/Animation", "Core": "api/en/constants/Core", "CustomBlendingEquation": "api/en/constants/CustomBlendingEquations", - "DrawModes": "api/en/constants/DrawModes", "Materials": "api/en/constants/Materials", "Renderer": "api/en/constants/Renderer", "Textures": "api/en/constants/Textures" @@ -520,7 +519,6 @@ var list = { "Animation": "api/zh/constants/Animation", "Core": "api/zh/constants/Core", "CustomBlendingEquation": "api/zh/constants/CustomBlendingEquations", - "DrawModes": "api/zh/constants/DrawModes", "Materials": "api/zh/constants/Materials", "Renderer": "api/zh/constants/Renderer", "Textures": "api/zh/constants/Textures" diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index 15a41d7e078e04cdfce70a243da71bea0c799377..82371d555c7c1e1a6b5d0dfb19408d8d7aa21079 100644 --- a/examples/js/exporters/GLTFExporter.js +++ b/examples/js/exporters/GLTFExporter.js @@ -1175,20 +1175,7 @@ THREE.GLTFExporter.prototype = { } - if ( mesh.drawMode === THREE.TriangleFanDrawMode ) { - - console.warn( 'GLTFExporter: TriangleFanDrawMode and wireframe incompatible.' ); - mode = WEBGL_CONSTANTS.TRIANGLE_FAN; - - } else if ( mesh.drawMode === THREE.TriangleStripDrawMode ) { - - mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINE_STRIP : WEBGL_CONSTANTS.TRIANGLE_STRIP; - - } else { - - mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES; - - } + mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES; } diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index 466bc87f289c649c9f1a8a330bdb1176052eb11d..ec8c15a7c77c94691d052b801a62c04caee90ade 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -2524,13 +2524,9 @@ THREE.GLTFLoader = ( function () { } - if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) { + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { - mesh.drawMode = THREE.TriangleStripDrawMode; - - } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { - - mesh.drawMode = THREE.TriangleFanDrawMode; + console.warn( 'THREE.GLTFLoader: The draw modes triangle strip and fan are not supported anymore.' ); } diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index 08939fe092d3f28116a34a1bfad25469499d8ac3..41d20ee5a5ccca7afe4b994b2fc14a4bf48989e1 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -23,8 +23,6 @@ import { RGBAFormat, RepeatWrapping, Scene, - TriangleFanDrawMode, - TriangleStripDrawMode, Vector3 } from "../../../build/three.module.js"; @@ -1199,20 +1197,7 @@ GLTFExporter.prototype = { } - if ( mesh.drawMode === TriangleFanDrawMode ) { - - console.warn( 'GLTFExporter: TriangleFanDrawMode and wireframe incompatible.' ); - mode = WEBGL_CONSTANTS.TRIANGLE_FAN; - - } else if ( mesh.drawMode === TriangleStripDrawMode ) { - - mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINE_STRIP : WEBGL_CONSTANTS.TRIANGLE_STRIP; - - } else { - - mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES; - - } + mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES; } diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 2defafc10a40b8d05d33498798bce047d6b579ab..0acbfce63dcb85e784b3535470af07a0aeaa0f10 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -63,8 +63,6 @@ import { Sphere, SpotLight, TextureLoader, - TriangleFanDrawMode, - TriangleStripDrawMode, UniformsUtils, Vector2, Vector3, @@ -2591,13 +2589,9 @@ var GLTFLoader = ( function () { } - if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) { + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { - mesh.drawMode = TriangleStripDrawMode; - - } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { - - mesh.drawMode = TriangleFanDrawMode; + console.warn( 'THREE.GLTFLoader: The draw modes triangle strip and fan are not supported anymore.' ); } diff --git a/examples/misc_exporter_gltf.html b/examples/misc_exporter_gltf.html index 2b834d14eb907f9083be611493ce417130aa3ece..7b5bfe663ad8bd24fc4ccee804e8d88904cd9393 100644 --- a/examples/misc_exporter_gltf.html +++ b/examples/misc_exporter_gltf.html @@ -293,39 +293,6 @@ object2.position.set( 0, 0, 400 ); group2.add( object2 ); - // --------------------------------------------------------------------- - // Triangle Strip - // --------------------------------------------------------------------- - var geometry = new THREE.BufferGeometry(); - var positions = new Float32Array( [ - 0, 0, 0, - 0, 80, 0, - 80, 0, 0, - 80, 80, 0, - 80, 0, 80, - 80, 80, 80, - ] ); - - var colors = new Float32Array( [ - 1, 0, 0, - 1, 0, 0, - 1, 1, 0, - 1, 1, 0, - 0, 0, 1, - 0, 0, 1, - ] ); - - geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); - geometry.setAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) ); - object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { side: THREE.DoubleSide, vertexColors: THREE.VertexColors } ) ); - object.position.set( 140, - 40, - 250 ); - object.setDrawMode( THREE.TriangleStripDrawMode ); - object.name = 'Custom buffered'; - object.userData = { data: 'customdata', list: [ 1, 2, 3, 4 ] }; - - scene1.add( object ); - - // --------------------------------------------------------------------- // THREE.Line Strip // --------------------------------------------------------------------- @@ -404,7 +371,7 @@ object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { side: THREE.DoubleSide, vertexColors: THREE.VertexColors } ) ); object.name = 'Custom buffered truncated'; - object.position.set( 340, - 40, - 200 ); + object.position.set( 140, - 40, - 200 ); scene1.add( object ); diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index 89311e062a9f9b5f714d43be6bbe6022c293dc5a..9146cf7c7b185ed465b5420bf6e0a8ce7787e5d0 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -8,7 +8,8 @@ import { PerspectiveCamera } from './cameras/PerspectiveCamera.js'; import { FlatShading, StaticDrawUsage, - DynamicDrawUsage + DynamicDrawUsage, + TrianglesDrawMode } from './constants.js'; import { Float64BufferAttribute, @@ -70,6 +71,7 @@ import { Triangle } from './math/Triangle.js'; import { Vector2 } from './math/Vector2.js'; import { Vector3 } from './math/Vector3.js'; import { Vector4 } from './math/Vector4.js'; +import { Mesh } from './objects/Mesh.js'; import { LineSegments } from './objects/LineSegments.js'; import { LOD } from './objects/LOD.js'; import { Points } from './objects/Points.js'; @@ -988,6 +990,34 @@ Object.defineProperties( Object3D.prototype, { } ); +Object.assign( Mesh.prototype, { + + setDrawMode: function () { + + console.error( 'THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' ); + + }, + +} ); + +Object.defineProperties( Mesh.prototype, { + + drawMode: { + get: function () { + + console.error( 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.' ); + return TrianglesDrawMode; + + }, + set: function () { + + console.error( 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' ); + + } + } + +} ); + Object.defineProperties( LOD.prototype, { objects: { diff --git a/src/core/Object3D.js b/src/core/Object3D.js index b1f8e12dee0935ebef5bce46fe45ed262d9305f4..1d46893ee34ab975078810826399e4973a8f70b4 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -6,7 +6,6 @@ import { Euler } from '../math/Euler.js'; import { Layers } from './Layers.js'; import { Matrix3 } from '../math/Matrix3.js'; import { _Math } from '../math/Math.js'; -import { TrianglesDrawMode } from '../constants.js'; var _object3DId = 0; @@ -681,8 +680,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), // object specific properties - if ( this.isMesh && this.drawMode !== TrianglesDrawMode ) object.drawMode = this.drawMode; - if ( this.isInstancedMesh ) { object.type = 'InstancedMesh'; diff --git a/src/loaders/ObjectLoader.js b/src/loaders/ObjectLoader.js index ca61e6e61cfb0d786139caaed62fe5f9750c72e5..741a681bd069457419f0aca87e951a70c5049ce6 100644 --- a/src/loaders/ObjectLoader.js +++ b/src/loaders/ObjectLoader.js @@ -948,8 +948,6 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), { if ( data.userData !== undefined ) object.userData = data.userData; if ( data.layers !== undefined ) object.layers.mask = data.layers; - if ( data.drawMode !== undefined ) object.setDrawMode( data.drawMode ); - if ( data.children !== undefined ) { var children = data.children; diff --git a/src/objects/Mesh.d.ts b/src/objects/Mesh.d.ts index 3a8b6176ffdfa1865f328f1dbc2f5ea93f749b31..94596b88f20d1623314bb5faf26ea2ce530b472d 100644 --- a/src/objects/Mesh.d.ts +++ b/src/objects/Mesh.d.ts @@ -4,7 +4,6 @@ import { Raycaster } from './../core/Raycaster'; import { Object3D } from './../core/Object3D'; import { BufferGeometry } from '../core/BufferGeometry'; import { Intersection } from '../core/Raycaster'; -import { TrianglesDrawModes } from '../constants'; export class Mesh extends Object3D { @@ -15,13 +14,11 @@ export class Mesh extends Object3D { geometry: Geometry | BufferGeometry; material: Material | Material[]; - drawMode: TrianglesDrawModes; morphTargetInfluences?: number[]; morphTargetDictionary?: { [key: string]: number }; isMesh: true; type: string; - setDrawMode( drawMode: TrianglesDrawModes ): void; updateMorphTargets(): void; raycast( raycaster: Raycaster, intersects: Intersection[] ): void; diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index d13515d8529361ee3c7eaf8bfbb49c8a96a868ef..1d2b1f221569593450f2b153981bd3bee1a6257c 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -6,7 +6,7 @@ import { Matrix4 } from '../math/Matrix4.js'; import { Object3D } from '../core/Object3D.js'; import { Triangle } from '../math/Triangle.js'; import { Face3 } from '../core/Face3.js'; -import { DoubleSide, BackSide, TrianglesDrawMode } from '../constants.js'; +import { DoubleSide, BackSide } from '../constants.js'; import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; @@ -49,8 +49,6 @@ function Mesh( geometry, material ) { this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); this.material = material !== undefined ? material : new MeshBasicMaterial( { color: Math.random() * 0xffffff } ); - this.drawMode = TrianglesDrawMode; - this.updateMorphTargets(); } @@ -61,18 +59,10 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { isMesh: true, - setDrawMode: function ( value ) { - - this.drawMode = value; - - }, - copy: function ( source ) { Object3D.prototype.copy.call( this, source ); - this.drawMode = source.drawMode; - if ( source.morphTargetInfluences !== undefined ) { this.morphTargetInfluences = source.morphTargetInfluences.slice(); @@ -165,15 +155,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { } - // check unsupported draw modes - - if ( this.drawMode !== TrianglesDrawMode ) { - - console.warn( 'THREE.Mesh: TriangleStripDrawMode and TriangleFanDrawMode are not supported by .raycast().' ); - return; - - } - var intersection; if ( geometry.isBufferGeometry ) { diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 92db099a200f1a94ea507094acd2adb2662d0e1f..39aaf25a2850662dcc91785fd96106f6eef29a82 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -3,9 +3,6 @@ import { HalfFloatType, FloatType, UnsignedByteType, - TriangleFanDrawMode, - TriangleStripDrawMode, - TrianglesDrawMode, LinearToneMapping, BackSide } from '../constants.js'; @@ -821,21 +818,7 @@ function WebGLRenderer( parameters ) { } else { - switch ( object.drawMode ) { - - case TrianglesDrawMode: - renderer.setMode( _gl.TRIANGLES ); - break; - - case TriangleStripDrawMode: - renderer.setMode( _gl.TRIANGLE_STRIP ); - break; - - case TriangleFanDrawMode: - renderer.setMode( _gl.TRIANGLE_FAN ); - break; - - } + renderer.setMode( _gl.TRIANGLES ); } diff --git a/src/renderers/webgl/WebGLInfo.js b/src/renderers/webgl/WebGLInfo.js index de30b40a48f0a7b8bc8424bc44a01107f8e8c9b1..52a52406cebf322d70857d3398963cfdcc0700f7 100644 --- a/src/renderers/webgl/WebGLInfo.js +++ b/src/renderers/webgl/WebGLInfo.js @@ -29,11 +29,6 @@ function WebGLInfo( gl ) { render.triangles += instanceCount * ( count / 3 ); break; - case gl.TRIANGLE_STRIP: - case gl.TRIANGLE_FAN: - render.triangles += instanceCount * ( count - 2 ); - break; - case gl.LINES: render.lines += instanceCount * ( count / 2 ); break; diff --git a/test/unit/src/objects/Mesh.tests.js b/test/unit/src/objects/Mesh.tests.js index 39c2826abb95aa170406d0ae78e3333cbd0614d9..aeb9043281472f00c690fd1d681adba1050e90d7 100644 --- a/test/unit/src/objects/Mesh.tests.js +++ b/test/unit/src/objects/Mesh.tests.js @@ -28,11 +28,6 @@ export default QUnit.module( 'Objects', () => { assert.ok( false, "everything's gonna be alright" ); - } ); - QUnit.todo( "setDrawMode", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - } ); QUnit.todo( "copy", ( assert ) => {