Forráskód Böngészése

Object3D: Setting parent to null by default. See #6987.

Mr.doob 10 éve
szülő
commit
764d3c08bf

+ 1 - 1
editor/js/Editor.js

@@ -189,7 +189,7 @@ Editor.prototype = {
 
 	removeObject: function ( object ) {
 
-		if ( object.parent === undefined ) return; // avoid deleting the camera or scene
+		if ( object.parent === null ) return; // avoid deleting the camera or scene
 
 		var scope = this;
 

+ 1 - 1
editor/js/Menubar.Edit.js

@@ -53,7 +53,7 @@ Menubar.Edit = function ( editor ) {
 
 		var object = editor.selected;
 
-		if ( object.parent === undefined ) return; // avoid cloning the camera or scene
+		if ( object.parent === null ) return; // avoid cloning the camera or scene
 
 		object = object.clone();
 

+ 2 - 2
editor/js/Sidebar.Object3D.js

@@ -342,7 +342,7 @@ Sidebar.Object3D = function ( editor ) {
 
 		if ( object !== null ) {
 
-			if ( object.parent !== undefined ) {
+			if ( object.parent !== null ) {
 
 				var newParentId = parseInt( objectParent.getValue() );
 
@@ -535,7 +535,7 @@ Sidebar.Object3D = function ( editor ) {
 		objectUUID.setValue( object.uuid );
 		objectName.setValue( object.name );
 
-		if ( object.parent !== undefined ) {
+		if ( object.parent !== null ) {
 
 			objectParent.setValue( object.parent.id );
 

+ 1 - 1
editor/js/libs/app.js

@@ -101,7 +101,7 @@ var APP = {
 
 			if ( vr === true ) {
 
-				if ( camera.parent === undefined ) {
+				if ( camera.parent === null ) {
 
 					// camera needs to be in the scene so camera2 matrix updates
 

+ 1 - 1
examples/js/Gyroscope.js

@@ -29,7 +29,7 @@ THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
 
 		if ( this.matrixWorldNeedsUpdate || force ) {
 
-			if ( this.parent ) {
+			if ( this.parent !== null ) {
 
 				this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
 

+ 4 - 4
examples/js/Mirror.js

@@ -37,7 +37,7 @@ THREE.ShaderLib[ 'mirror' ] = {
 		"float blendOverlay(float base, float blend) {",
 			"return( base < 0.5 ? ( 2.0 * base * blend ) : (1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );",
 		"}",
-		
+
 		"void main() {",
 
 			"vec4 color = texture2DProj(mirrorSampler, mirrorCoord);",
@@ -76,7 +76,7 @@ THREE.Mirror = function ( renderer, camera, options ) {
 	this.rotationMatrix = new THREE.Matrix4();
 	this.lookAtPosition = new THREE.Vector3( 0, 0, - 1 );
 	this.clipPlane = new THREE.Vector4();
-	
+
 	// For debug only, show the normal and plane of the mirror
 	var debugMode = options.debugMode !== undefined ? options.debugMode : false;
 
@@ -257,7 +257,7 @@ THREE.Mirror.prototype.render = function () {
 	// Render the mirrored view of the current scene into the target texture
 	var scene = this;
 
-	while ( scene.parent !== undefined ) {
+	while ( scene.parent !== null ) {
 
 		scene = scene.parent;
 
@@ -286,7 +286,7 @@ THREE.Mirror.prototype.renderTemp = function () {
 	// Render the mirrored view of the current scene into the target texture
 	var scene = this;
 
-	while ( scene.parent !== undefined ) {
+	while ( scene.parent !== null ) {
 
 		scene = scene.parent;
 

+ 1 - 1
examples/js/effects/AnaglyphEffect.js

@@ -105,7 +105,7 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
 
 		scene.updateMatrixWorld();
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		var hasCameraChanged = ( _aspect !== camera.aspect ) || ( _near !== camera.near ) || ( _far !== camera.far ) || ( _fov !== camera.fov );
 

+ 1 - 1
examples/js/effects/ParallaxBarrierEffect.js

@@ -104,7 +104,7 @@ THREE.ParallaxBarrierEffect = function ( renderer ) {
 
 		scene.updateMatrixWorld();
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		var hasCameraChanged = ( _aspect !== camera.aspect ) || ( _near !== camera.near ) || ( _far !== camera.far ) || ( _fov !== camera.fov );
 

+ 2 - 2
examples/js/effects/StereoEffect.js

@@ -78,8 +78,8 @@ THREE.StereoEffect = function ( renderer ) {
 
 		scene.updateMatrixWorld();
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
-	
+		if ( camera.parent === null ) camera.updateMatrixWorld();
+
 		camera.matrixWorld.decompose( _position, _quaternion, _scale );
 
 		// Effective fov of the camera

+ 1 - 1
examples/js/effects/VREffect.js

@@ -133,7 +133,7 @@ THREE.VREffect = function ( renderer, onError ) {
 			renderer.enableScissorTest( true );
 			renderer.clear();
 
-			if ( camera.parent === undefined ) camera.updateMatrixWorld();
+			if ( camera.parent === null ) camera.updateMatrixWorld();
 
 			cameraL.projectionMatrix = fovToProjection( eyeFOVL, true, camera.near, camera.far );
 			cameraR.projectionMatrix = fovToProjection( eyeFOVR, true, camera.near, camera.far );

+ 1 - 1
examples/js/renderers/CSS2DRenderer.js

@@ -90,7 +90,7 @@ THREE.CSS2DRenderer = function () {
 
 		scene.updateMatrixWorld();
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 

+ 1 - 1
examples/js/renderers/CSS3DRenderer.js

@@ -227,7 +227,7 @@ THREE.CSS3DRenderer = function () {
 
 		scene.updateMatrixWorld();
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 

+ 1 - 1
examples/js/renderers/CSS3DStereoRenderer.js

@@ -254,7 +254,7 @@ THREE.CSS3DStereoRenderer = function () {
 
 		scene.updateMatrixWorld();
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		camera.matrixWorld.decompose( _position, _quaternion, _scale );
 

+ 1 - 1
examples/js/renderers/Projector.js

@@ -325,7 +325,7 @@ THREE.Projector = function () {
 		_renderData.elements.length = 0;
 
 		if ( scene.autoUpdate === true ) scene.updateMatrixWorld();
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		_viewMatrix.copy( camera.matrixWorldInverse.getInverse( camera.matrixWorld ) );
 		_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );

+ 1 - 1
examples/js/renderers/RaytracingRenderer.js

@@ -493,7 +493,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 		// update camera matrices
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 		cameraPosition.setFromMatrixPosition( camera.matrixWorld );

+ 1 - 1
src/cameras/CubeCamera.js

@@ -47,7 +47,7 @@ THREE.CubeCamera = function ( near, far, cubeResolution ) {
 
 	this.updateCubeMap = function ( renderer, scene ) {
 
-		if ( this.parent === undefined ) this.updateMatrixWorld();
+		if ( this.parent === null ) this.updateMatrixWorld();
 
 		var renderTarget = this.renderTarget;
 		var generateMipmaps = renderTarget.generateMipmaps;

+ 5 - 5
src/core/Object3D.js

@@ -15,7 +15,7 @@ THREE.Object3D = function () {
 	this.name = '';
 	this.type = 'Object3D';
 
-	this.parent = undefined;
+	this.parent = null;
 	this.children = [];
 
 	this.up = THREE.Object3D.DefaultUp.clone();
@@ -331,7 +331,7 @@ THREE.Object3D.prototype = {
 
 		if ( object instanceof THREE.Object3D ) {
 
-			if ( object.parent !== undefined ) {
+			if ( object.parent !== null ) {
 
 				object.parent.remove( object );
 
@@ -368,7 +368,7 @@ THREE.Object3D.prototype = {
 
 		if ( index !== - 1 ) {
 
-			object.parent = undefined;
+			object.parent = null;
 
 			object.dispatchEvent( { type: 'removed' } );
 
@@ -534,7 +534,7 @@ THREE.Object3D.prototype = {
 
 		var parent = this.parent;
 
-		if ( parent !== undefined ) {
+		if ( parent !== null ) {
 
 			callback( parent );
 
@@ -558,7 +558,7 @@ THREE.Object3D.prototype = {
 
 		if ( this.matrixWorldNeedsUpdate === true || force === true ) {
 
-			if ( this.parent === undefined ) {
+			if ( this.parent === null ) {
 
 				this.matrixWorld.copy( this.matrix );
 

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -1533,7 +1533,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		// update camera matrices and frustum
 
-		if ( camera.parent === undefined ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );