瀏覽代碼

Scene: Remove dispose().

Mugen87 5 年之前
父節點
當前提交
3a56aedf68

+ 0 - 5
docs/api/en/scenes/Scene.html

@@ -52,11 +52,6 @@
 
 		<h2>Methods</h2>
 
-		<h3>[method:null dispose]()</h3>
-		<p>
-		Clears scene related data internally cached by [page:WebGLRenderer].
-		</p>
-
 		<h3>[method:Object toJSON]( [param:Object meta] )</h3>
 		<p>
 		meta -- object containing metadata such as textures or images for the scene.<br />

+ 0 - 5
docs/api/zh/scenes/Scene.html

@@ -55,11 +55,6 @@
 
 		<h2>方法</h2>
 
-		<h3>[method:null dispose]()</h3>
-		<p>
-			清除[page:WebGLRenderer]内部所缓存的场景相关的数据。
-		</p>
-
 		<h3>[method:JSON toJSON]</h3>
 		<p>
 			meta -- 包含有元数据的对象,例如场景中的的纹理或图片。

+ 0 - 7
docs/manual/en/introduction/How-to-dispose-of-objects.html

@@ -53,13 +53,6 @@
 		for realizing custom rendering destinations. These objects are only deallocated by executing [page:WebGLRenderTarget.dispose]().
 	</p>
 
-	<h2>Scenes</h2>
-
-	<p>
-		The renderer maintains for scenes special data structures for sorting and rendering. If for some reasons a scene object becomes obsolete in an application,
-		call [page:Scene.dispose]() in order to free these resources.
-	</p>
-
 	<h2>Miscellaneous</h2>
 
 	<p>

+ 0 - 7
docs/manual/zh/introduction/How-to-dispose-of-objects.html

@@ -53,13 +53,6 @@
 		这些对象仅能通过执行[page:WebGLRenderTarget.dispose]()来解除分配。
 	</p>
 
-	<h2>Scenes</h2>
-
-	<p>
-		The renderer maintains for scenes special data structures for sorting and rendering. If for some reasons a scene object becomes obsolete in an application,
-		call [page:Scene.dispose]() in order to free these resources.
-	</p>
-
 	<h2>杂项</h2>
 
 	<p>

+ 13 - 0
src/Three.Legacy.js

@@ -88,6 +88,7 @@ import { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js';
 import { ImageUtils } from './extras/ImageUtils.js';
 import { Shape } from './extras/core/Shape.js';
 import { CubeCamera } from './cameras/CubeCamera.js';
+import { Scene } from './scenes/Scene.js';
 
 export { BoxGeometry as CubeGeometry };
 export { MathUtils as Math };
@@ -1467,6 +1468,18 @@ Object.assign( ExtrudeBufferGeometry.prototype, {
 
 //
 
+Object.assign( Scene.prototype, {
+
+	dispose: function () {
+
+		console.error( 'THREE.Scene: .dispose() has been removed.' );
+
+	}
+
+} );
+
+//
+
 Object.defineProperties( Uniform.prototype, {
 
 	dynamic: {

+ 0 - 12
src/renderers/webgl/WebGLRenderLists.js

@@ -174,16 +174,6 @@ function WebGLRenderLists( properties ) {
 
 	let lists = new WeakMap();
 
-	function onSceneDispose( event ) {
-
-		const scene = event.target;
-
-		scene.removeEventListener( 'dispose', onSceneDispose );
-
-		lists.delete( scene );
-
-	}
-
 	function get( scene, camera ) {
 
 		const cameras = lists.get( scene );
@@ -195,8 +185,6 @@ function WebGLRenderLists( properties ) {
 			lists.set( scene, new WeakMap() );
 			lists.get( scene ).set( camera, list );
 
-			scene.addEventListener( 'dispose', onSceneDispose );
-
 		} else {
 
 			list = cameras.get( camera );

+ 0 - 12
src/renderers/webgl/WebGLRenderStates.js

@@ -54,16 +54,6 @@ function WebGLRenderStates() {
 
 	let renderStates = new WeakMap();
 
-	function onSceneDispose( event ) {
-
-		const scene = event.target;
-
-		scene.removeEventListener( 'dispose', onSceneDispose );
-
-		renderStates.delete( scene );
-
-	}
-
 	function get( scene, camera ) {
 
 		let renderState;
@@ -74,8 +64,6 @@ function WebGLRenderStates() {
 			renderStates.set( scene, new WeakMap() );
 			renderStates.get( scene ).set( camera, renderState );
 
-			scene.addEventListener( 'dispose', onSceneDispose );
-
 		} else {
 
 			if ( renderStates.get( scene ).has( camera ) === false ) {

+ 0 - 6
src/scenes/Scene.js

@@ -55,12 +55,6 @@ Scene.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		return data;
 
-	},
-
-	dispose: function () {
-
-		this.dispatchEvent( { type: 'dispose' } );
-
 	}
 
 } );

+ 0 - 17
test/unit/src/renderers/webgl/WebGLRenderLists.tests.js

@@ -34,23 +34,6 @@ export default QUnit.module( 'Renderers', () => {
 
 			} );
 
-			QUnit.test( "dispose", ( assert ) => {
-
-				var properties = new WebGLProperties();
-				var renderLists = new WebGLRenderLists( properties );
-				var scene = new Scene();
-				var camera = new Camera();
-
-				var list1 = renderLists.get( scene, camera );
-
-				scene.dispose();
-
-				var list2 = renderLists.get( scene, camera );
-
-				assert.ok( list1 !== list2, "New list should be different after disposing of the scene." );
-
-			} );
-
 		} );