Преглед на файлове

Helpers: Replaced onBeforeRender usage with updateMatrixWorld. See #11638

Mr.doob преди 8 години
родител
ревизия
e62a722efd
променени са 3 файла, в които са добавени 12 реда и са изтрити 13 реда
  1. 4 3
      src/helpers/Box3Helper.js
  2. 3 6
      src/helpers/PlaneHelper.js
  3. 5 4
      src/helpers/SkeletonHelper.js

+ 4 - 3
src/helpers/Box3Helper.js

@@ -7,6 +7,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial';
 import { BufferAttribute } from '../core/BufferAttribute';
 import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
+import { Object3D } from '../core/Object3D';
 
 function Box3Helper( box, hex ) {
 
@@ -30,14 +31,12 @@ function Box3Helper( box, hex ) {
 
 	this.geometry.computeBoundingSphere();
 
-	this.onBeforeRender();
-
 }
 
 Box3Helper.prototype = Object.create( LineSegments.prototype );
 Box3Helper.prototype.constructor = Box3Helper;
 
-Box3Helper.prototype.onBeforeRender = function () {
+Box3Helper.prototype.updateMatrixWorld = function ( force ) {
 
 	var box = this.box;
 
@@ -49,6 +48,8 @@ Box3Helper.prototype.onBeforeRender = function () {
 
 	this.scale.multiplyScalar( 0.5 );
 
+	Object3D.prototype.updateMatrixWorld.call( this, force );
+
 };
 
 export { Box3Helper };

+ 3 - 6
src/helpers/PlaneHelper.js

@@ -8,6 +8,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial';
 import { MeshBasicMaterial } from '../materials/MeshBasicMaterial';
 import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
+import { Object3D } from '../core/Object3D';
 
 function PlaneHelper( plane, size, hex ) {
 
@@ -37,16 +38,12 @@ function PlaneHelper( plane, size, hex ) {
 
 	this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false } ) ) );
 
-	//
-
-	this.onBeforeRender();
-
 }
 
 PlaneHelper.prototype = Object.create( Line.prototype );
 PlaneHelper.prototype.constructor = PlaneHelper;
 
-PlaneHelper.prototype.onBeforeRender = function () {
+PlaneHelper.prototype.updateMatrixWorld = function ( force ) {
 
 	var scale = - this.plane.constant;
 
@@ -56,7 +53,7 @@ PlaneHelper.prototype.onBeforeRender = function () {
 
 	this.lookAt( this.plane.normal );
 
-	this.updateMatrixWorld();
+	Object3D.prototype.updateMatrixWorld.call( this, force );
 
 };
 

+ 5 - 4
src/helpers/SkeletonHelper.js

@@ -14,6 +14,7 @@ import { Color } from '../math/Color';
 import { Vector3 } from '../math/Vector3';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Float32BufferAttribute } from '../core/BufferAttribute';
+import { Object3D } from '../core/Object3D';
 
 function getBoneList( object ) {
 
@@ -75,21 +76,19 @@ function SkeletonHelper( object ) {
 	this.matrix = object.matrixWorld;
 	this.matrixAutoUpdate = false;
 
-	this.onBeforeRender();
-
 }
 
 SkeletonHelper.prototype = Object.create( LineSegments.prototype );
 SkeletonHelper.prototype.constructor = SkeletonHelper;
 
-SkeletonHelper.prototype.onBeforeRender = function () {
+SkeletonHelper.prototype.updateMatrixWorld = function () {
 
 	var vector = new Vector3();
 
 	var boneMatrix = new Matrix4();
 	var matrixWorldInv = new Matrix4();
 
-	return function onBeforeRender() {
+	return function updateMatrixWorld( force ) {
 
 		var bones = this.bones;
 
@@ -120,6 +119,8 @@ SkeletonHelper.prototype.onBeforeRender = function () {
 
 		geometry.getAttribute( 'position' ).needsUpdate = true;
 
+		Object3D.prototype.updateMatrixWorld.call( this, force );
+
 	};
 
 }();