[b86468]: / v3 / js / libs / three / utils / SceneUtils.js

Download this file

39 lines (22 with data), 646 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @author alteredq / http://alteredqualia.com/
*/
THREE.SceneUtils = {
createMultiMaterialObject: function ( geometry, materials ) {
var group = new THREE.Group();
for ( var i = 0, l = materials.length; i < l; i ++ ) {
group.add( new THREE.Mesh( geometry, materials[ i ] ) );
}
return group;
},
detach: function ( child, parent, scene ) {
child.applyMatrix( parent.matrixWorld );
parent.remove( child );
scene.add( child );
},
attach: function ( child, scene, parent ) {
child.applyMatrix( new THREE.Matrix4().getInverse( parent.matrixWorld ) );
scene.remove( child );
parent.add( child );
}
};