Ver Fonte

Mesh: Remove drawMode.

Mugen87 há 5 anos atrás
pai
commit
f56d4c2889

+ 0 - 79
docs/api/en/constants/DrawModes.html

@@ -1,79 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8" />
-		<base href="../../../" />
-		<script src="list.js"></script>
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-		<h1>Draw Mode Constants</h1>
-
-		<p class="desc">
-			These are valid values for [page:Mesh.drawMode], and control how the list of vertices is interpeted once sent to the GPU.
-		</p>
-
-		<h2>Draw Modes</h2>
-
-		<code>
-			THREE.TrianglesDrawMode
-		</code>
-		<p>
-			This is the default, and results in every three consecutive vertices (v0, v1, v2), (v3, v4, v5), ...
-			being interpreted as a separate triangle. <br />
-			If the number of vertices is not a multiple of 3, excess vertices are ignored.
-		</p>
-
-		<code>
-			THREE.TriangleStripDrawMode
-		</code>
-		<p>
-			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.
-		</p>
-
-		<code>
-			THREE.TriangleFanDrawMode
-		</code>
-		<p>
-			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), ... <br /><br />
-
-			<em>Note:</em> 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.
-		</p>
-
-
-		<h2>Usage</h2>
-
-		<code>
-		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 );
-		</code>
-
-		<h2>Source</h2>
-
-		<p>
-			[link:https://github.com/mrdoob/three.js/blob/master/src/constants.js src/constants.js]
-		</p>
-	</body>
-</html>

+ 0 - 15
docs/api/en/objects/Mesh.html

@@ -41,18 +41,6 @@
 		<h2>Properties</h2>
 		<p>See the base [page:Object3D] class for common properties.</p>
 
-		<h3>[property:Integer drawMode]</h3>
-		<p>
-			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].
-		</p>
-		<p>
-			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].
-		</p>
-
-
 		<h3>[property:Boolean isMesh]</h3>
 		<p>
 			Used to check whether this or derived classes are meshes. Default is *true*.<br /><br />
@@ -90,9 +78,6 @@
 		<h2>Methods</h2>
 		<p>See the base [page:Object3D] class for common methods.</p>
 
-		<h3>[method:null setDrawMode]( [param:Integer value] )</h3>
-		<p>Set the value of [page:.drawMode drawMode].</p>
-
 		<h3>[method:Mesh clone]()</h3>
 		<p>Returns a clone of this [name] object and its descendants.</p>
 

+ 0 - 79
docs/api/zh/constants/DrawModes.html

@@ -1,79 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8" />
-		<base href="../../../" />
-		<script src="list.js"></script>
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-		<h1>绘图模式常量(Draw Mode Constants)</h1>
-
-		<p class="desc">
-			这些是[page:Mesh.drawMode]的有效值,控制着顶点列表一旦被发送到GPU中将如何被解释。
-		</p>
-
-
-		<h2>绘图模式</h2>
-
-		<code>
-			THREE.TrianglesDrawMode
-		</code>
-		<p>
-			这是默认值,这将使得每三个连续顶点(v0, v1, v2),(v3, v4, v5),……被解释为一个单独的三角形。
-			<br />
-			如果顶点的数量不是3的倍数,那么将会忽略多余的顶点。
-		</p>
-
-		<code>
-			THREE.TriangleStripDrawMode
-		</code>
-		<p>
-			这将使得一系列的三角形(由(v0, v1, v2),(v2, v1, v3),(v2, v3, v4),……给定)一个一个地连在一起,每一个连续的三角形将和前一个三角形共享两个顶点。
-		</p>
-
-		<code>
-			THREE.TriangleFanDrawMode
-		</code>
-		<p>
-这将会使得一个序列中的每一个三角形(由(v0, v1, v2),(v0, v2, v3),(v0, v3, v4),……给定)共享它们的第一个顶点(就像风扇一样)。<br /><br />
-
-			<em>注意:</em>截至[link:https://en.wikipedia.org/wiki/DirectX#DirectX_10 DirectX10]这个模式还没有被支持。
-			由于Chorme和Firefox在Windows上是使用[link:https://en.wikipedia.org/wiki/ANGLE_(software) ANGLE]来渲染WebGL的,所以这种模式将会在内部转换为受支持的模式,
-			但可能会导致这些浏览器在性能上降低一些。
-		</p>
-
-
-		<h2>用法</h2>
-
-		<code>
-		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 );
-		</code>
-
-
-
-		<h2>源代码</h2>
-
-		<p>
-			[link:https://github.com/mrdoob/three.js/blob/master/src/constants.js src/constants.js]
-		</p>
-	</body>
-</html>

+ 0 - 14
docs/api/zh/objects/Mesh.html

@@ -40,17 +40,6 @@
 		<h2>属性</h2>
 		<p>共有属性请参见其基类[page:Object3D]。</p>
 
-		<h3>[property:Integer drawMode]</h3>
-		<p>
-			决定了网格中的三角形将如何从顶点来构造。
-			请参阅draw mode [page:DrawModes constants](绘图模式常量)来查看其所有可能的值。
-			其默认值是[page:DrawModes TrianglesDrawMode]。
-		</p>
-		<p>
-			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].
-		</p>
-
 		<h3>[property:Boolean isMesh]</h3>
 		<p>
 			用于检查这个类或者其派生类是否为网格,默认值为*true*。<br /><br />
@@ -85,9 +74,6 @@
 		<h2>方法</h2>
 		<p>共有方法请参见其基类[page:Object3D]。</p>
 
-		<h3>[method:null setDrawMode]( [param:Integer value] )</h3>
-		<p>设置[page:.drawMode drawMode]的值。</p>
-
 		<h3>[method:Mesh clone]()</h3>
 		<p>返回这个[name]对象及其子级的克隆。</p>
 

+ 0 - 2
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"

+ 1 - 14
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;
 
 			}
 

+ 2 - 6
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.' );
 
 						}
 

+ 1 - 16
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;
 
 			}
 

+ 2 - 8
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.' );
 
 						}
 

+ 1 - 34
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 );
 

+ 31 - 1
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: {

+ 0 - 3
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';

+ 0 - 2
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;

+ 0 - 3
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;
 

+ 1 - 20
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 ) {

+ 1 - 18
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 );
 
 			}
 

+ 0 - 5
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;

+ 0 - 5
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 ) => {