浏览代码

Update parameter type. Simplify checks.

SntsDev 4 年之前
父节点
当前提交
b227e310fa

+ 8 - 4
docs/examples/en/utils/BufferGeometryUtils.html

@@ -74,14 +74,18 @@
 
 		</p>
 
-		<h3>[method:Object computeMorphedAttributes]( [param:Object3D object] )</h3>
+		<h3>[method:Object computeMorphedAttributes]( [param:Mesh | Line | Points object] )</h3>
 		<p>
-		object -- Instance of [page:Object3D Object3D].<br /><br />
+		object -- Instance of [page:Mesh Mesh] | [page:Line Line] | [page:Points Points].<br /><br />
 
 		Returns the current attributes (Position and Normal) of a morphed/skinned [page:Object3D Object3D] whose geometry is a 
-		[page:BufferGeometry BufferGeometry], together with the original ones: An Object with 4 properties: `positionAttribute`, `normalAttribute`, `morphedPositionAttribute` and `morphedNormalAttribute`.
+		[page:BufferGeometry BufferGeometry], together with the original ones: An Object with 4 properties: 
+		`positionAttribute`, `normalAttribute`, `morphedPositionAttribute` and `morphedNormalAttribute`.
 
-		Helpful for Raytracing or Decals (i.e. a [page:DecalGeometry DecalGeometry] applied to a morphed Object with a [page:BufferGeometry BufferGeometry] will use the original BufferGeometry, not the morphed/skinned one, generating an incorrect result. Using this function to create a shadow Object3D the DecalGeometry can be correctly generated).
+		Helpful for Raytracing or Decals (i.e. a [page:DecalGeometry DecalGeometry] applied to a morphed Object 
+		with a [page:BufferGeometry BufferGeometry] will use the original BufferGeometry, not the morphed/skinned one, 
+		generating an incorrect result. 
+		Using this function to create a shadow Object3D the DecalGeometry can be correctly generated).
 
 		</p>
 

+ 2 - 7
examples/js/utils/BufferGeometryUtils.js

@@ -623,17 +623,12 @@ THREE.BufferGeometryUtils = {
 	/**
 	 * Calculates the morphed attributes of a morphed/skinned BufferGeometry.
 	 * Helpful for Raytracing or Decals.
-	 * @param {Object3D} object
+	 * @param {Mesh | Line | Points} object An instance of Mesh, Line or Points.
 	 * @return {Object} An Object with original position/normal attributes and morphed ones.
 	 */
 	computeMorphedAttributes: function ( object ) {
 
-		if ( ! object ) {
-
-			console.error( 'Please provide an object' );
-			return null;
-
-		} else if ( ! object.geometry ) {
+		if ( ! object.geometry ) {
 
 			console.error( 'Please provide an object with a geometry' );
 			return null;

+ 2 - 2
examples/jsm/utils/BufferGeometryUtils.d.ts

@@ -1,4 +1,4 @@
-import { BufferAttribute, BufferGeometry, InterleavedBufferAttribute, TrianglesDrawModes, Object3D } from '../../../src/Three';
+import { BufferAttribute, BufferGeometry, InterleavedBufferAttribute, TrianglesDrawModes, Mesh, Line, Points } from '../../../src/Three';
 
 export namespace BufferGeometryUtils {
 	export function mergeBufferGeometries( geometries: BufferGeometry[], useGroups?: boolean ): BufferGeometry;
@@ -7,5 +7,5 @@ export namespace BufferGeometryUtils {
 	export function estimateBytesUsed( geometry: BufferGeometry ): number;
 	export function mergeVertices( geometry: BufferGeometry, tolerance?: number ): BufferGeometry;
 	export function toTrianglesDrawMode( geometry: BufferGeometry, drawMode: TrianglesDrawModes ): BufferGeometry;
-	export function computeMorphedAttributes( object: Object3D ): Object;
+	export function computeMorphedAttributes( object: Mesh | Line | Points ): Object;
 }

+ 2 - 7
examples/jsm/utils/BufferGeometryUtils.js

@@ -635,17 +635,12 @@ var BufferGeometryUtils = {
 	/**
 	 * Calculates the morphed attributes of a morphed/skinned BufferGeometry.
 	 * Helpful for Raytracing or Decals.
-	 * @param {Object3D} object
+	 * @param {Mesh | Line | Points} object An instance of Mesh, Line or Points.
 	 * @return {Object} An Object with original position/normal attributes and morphed ones.
 	 */
 	computeMorphedAttributes: function ( object ) {
 
-		if ( ! object ) {
-
-			console.warn( 'Please provide an object' );
-			return null;
-
-		} else if ( ! object.geometry ) {
+		if ( ! object.geometry ) {
 
 			console.warn( 'Please provide an object with a geometry' );
 			return null;