From 7a86f938b389754af14b6001a5f7679b660c946b Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Wed, 3 Jan 2018 10:58:40 +0100 Subject: [PATCH 1/2] SceneUtils: Moved to examples --- .../extras => examples/utils}/SceneUtils.html | 2 +- docs/list.js | 5 ++- editor/js/libs/tern-threejs/threejs.js | 18 ---------- .../js/utils}/SceneUtils.js | 15 +++------ src/Three.Legacy.js | 24 ++++++++++++++ src/Three.js | 1 - test/three.source.unit.js | 1 - test/unit/src/extras/SceneUtils.tests.js | 33 ------------------- 8 files changed, 33 insertions(+), 66 deletions(-) rename docs/{api/extras => examples/utils}/SceneUtils.html (94%) rename {src/extras => examples/js/utils}/SceneUtils.js (57%) delete mode 100644 test/unit/src/extras/SceneUtils.tests.js diff --git a/docs/api/extras/SceneUtils.html b/docs/examples/utils/SceneUtils.html similarity index 94% rename from docs/api/extras/SceneUtils.html rename to docs/examples/utils/SceneUtils.html index 8bd05c465f2260..96739bb9da232e 100644 --- a/docs/api/extras/SceneUtils.html +++ b/docs/examples/utils/SceneUtils.html @@ -48,6 +48,6 @@

[method:null detach]( [page:Object3D child], [page:Object3D parent], [page:O

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/SceneUtils.js examples/js/utils/SceneUtils.js] diff --git a/docs/list.js b/docs/list.js index 7c1f1ed376e2e6..0d9d9fb798033d 100644 --- a/docs/list.js +++ b/docs/list.js @@ -105,7 +105,6 @@ var list = { "Extras": { "Earcut": "api/extras/Earcut", - "SceneUtils": "api/extras/SceneUtils", "ShapeUtils": "api/extras/ShapeUtils" }, @@ -381,6 +380,10 @@ var list = { "Renderers": { "CanvasRenderer": "examples/renderers/CanvasRenderer" + }, + + "Utils": { + "SceneUtils": "examples/utils/SceneUtils", } }, diff --git a/editor/js/libs/tern-threejs/threejs.js b/editor/js/libs/tern-threejs/threejs.js index 675f2dd5c169fc..044d4411e034cc 100644 --- a/editor/js/libs/tern-threejs/threejs.js +++ b/editor/js/libs/tern-threejs/threejs.js @@ -805,24 +805,6 @@ "prototype": {}, "!doc": "Contains handy functions geometry manipulations." }, - "SceneUtils": { - "!url": "http://threejs.org/docs/#Reference/extras/SceneUtils", - "prototype": { - "createMultiMaterialObject": { - "!type": "fn(geometry: +THREE.Geometry, materials: []) -> +THREE.Object3D", - "!doc": "Creates an new Object3D an new mesh for each material defined in materials. Beware that this is not the same as MultiMaterial which defines multiple material for 1 mesh.
\n\t\tThis is mostly useful for object that need a material and a wireframe implementation." - }, - "attach": { - "!type": "fn(child: +THREE.Object3D, scene: +THREE.Object3D, parent: +THREE.Object3D)", - "!doc": "Attaches the object to the parent without the moving the object in the worldspace." - }, - "detach": { - "!type": "fn(child: +THREE.Object3D, parent: +THREE.Object3D, scene: +THREE.Object3D)", - "!doc": "Detaches the object from the parent and adds it back to the scene without moving in worldspace." - } - }, - "!doc": "A class containing useful utility functions for scene manipulation." - }, "Curve": { "!url": "http://threejs.org/docs/#Reference/extras/core/Curve", "prototype": { diff --git a/src/extras/SceneUtils.js b/examples/js/utils/SceneUtils.js similarity index 57% rename from src/extras/SceneUtils.js rename to examples/js/utils/SceneUtils.js index b2e10d78128674..faaed8a9791c30 100644 --- a/src/extras/SceneUtils.js +++ b/examples/js/utils/SceneUtils.js @@ -1,20 +1,16 @@ -import { Matrix4 } from '../math/Matrix4.js'; -import { Mesh } from '../objects/Mesh.js'; -import { Group } from '../objects/Group.js'; - /** * @author alteredq / http://alteredqualia.com/ */ -var SceneUtils = { +THREE.SceneUtils = { createMultiMaterialObject: function ( geometry, materials ) { - var group = new Group(); + var group = new THREE.Group(); for ( var i = 0, l = materials.length; i < l; i ++ ) { - group.add( new Mesh( geometry, materials[ i ] ) ); + group.add( new THREE.Mesh( geometry, materials[ i ] ) ); } @@ -32,7 +28,7 @@ var SceneUtils = { attach: function ( child, scene, parent ) { - child.applyMatrix( new Matrix4().getInverse( parent.matrixWorld ) ); + child.applyMatrix( new THREE.Matrix4().getInverse( parent.matrixWorld ) ); scene.remove( child ); parent.add( child ); @@ -40,6 +36,3 @@ var SceneUtils = { } }; - - -export { SceneUtils }; diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index bf3dca7d939a81..c45413e4d33fa8 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -1722,3 +1722,27 @@ export function CanvasRenderer() { this.setSize = function () {}; } + +// + +export var SceneUtils = { + + createMultiMaterialObject: function ( /* geometry, materials */ ) { + + console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + + }, + + detach: function ( /* child, parent, scene */ ) { + + console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + + }, + + attach: function ( /* child, scene, parent */ ) { + + console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + + } + +}; diff --git a/src/Three.js b/src/Three.js index 601e7d05b855f6..72b50d27d82b8e 100644 --- a/src/Three.js +++ b/src/Three.js @@ -147,7 +147,6 @@ export { Font } from './extras/core/Font.js'; export { CurvePath } from './extras/core/CurvePath.js'; export { Curve } from './extras/core/Curve.js'; export { ShapeUtils } from './extras/ShapeUtils.js'; -export { SceneUtils } from './extras/SceneUtils.js'; export { WebGLUtils } from './renderers/webgl/WebGLUtils.js'; export * from './constants.js'; export * from './Three.Legacy.js'; diff --git a/test/three.source.unit.js b/test/three.source.unit.js index 2c58a5eaf1d977..ab0fee9ba58407 100644 --- a/test/three.source.unit.js +++ b/test/three.source.unit.js @@ -64,7 +64,6 @@ import './unit/src/core/Uniform.tests'; //src/extras -import './unit/src/extras/SceneUtils.tests'; import './unit/src/extras/ShapeUtils.tests'; //src/extras/core diff --git a/test/unit/src/extras/SceneUtils.tests.js b/test/unit/src/extras/SceneUtils.tests.js deleted file mode 100644 index 64789451415740..00000000000000 --- a/test/unit/src/extras/SceneUtils.tests.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @author TristanVALCKE / https://github.com/Itee - */ -/* global QUnit */ - -import { SceneUtils } from '../../../../src/extras/SceneUtils'; - -export default QUnit.module( 'Extras', () => { - - QUnit.module( 'SceneUtils', () => { - - // PUBLIC STUFF - QUnit.todo( "createMultiMaterialObject", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "detach", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "attach", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - } ); - -} ); From 24c969d0d71d62acd42773c669a76bb77768773c Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Wed, 3 Jan 2018 11:02:07 +0100 Subject: [PATCH 2/2] Docs: Remove unnecessary comma --- docs/list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/list.js b/docs/list.js index 0d9d9fb798033d..5657c5bb599dc3 100644 --- a/docs/list.js +++ b/docs/list.js @@ -383,7 +383,7 @@ var list = { }, "Utils": { - "SceneUtils": "examples/utils/SceneUtils", + "SceneUtils": "examples/utils/SceneUtils" } },