/usr/share/javascript/three/examples/js/UCSCharacter.js is in libjs-three 80+dfsg2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | THREE.UCSCharacter = function() {
var scope = this;
var mesh;
this.scale = 1;
this.root = new THREE.Object3D();
this.numSkins;
this.numMorphs;
this.skins = [];
this.materials = [];
this.morphs = [];
this.mixer = new THREE.AnimationMixer( this.root );
this.onLoadComplete = function () {};
this.loadCounter = 0;
this.loadParts = function ( config ) {
this.numSkins = config.skins.length;
this.numMorphs = config.morphs.length;
// Character geometry + number of skins
this.loadCounter = 1 + config.skins.length;
// SKINS
this.skins = loadTextures( config.baseUrl + "skins/", config.skins );
this.materials = createMaterials( this.skins );
// MORPHS
this.morphs = config.morphs;
// CHARACTER
var loader = new THREE.JSONLoader();
console.log( config.baseUrl + config.character );
loader.load( config.baseUrl + config.character, function( geometry ) {
geometry.computeBoundingBox();
geometry.computeVertexNormals();
mesh = new THREE.SkinnedMesh( geometry, new THREE.MultiMaterial() );
mesh.name = config.character;
scope.root.add( mesh );
var bb = geometry.boundingBox;
scope.root.scale.set( config.s, config.s, config.s );
scope.root.position.set( config.x, config.y - bb.min.y * config.s, config.z );
mesh.castShadow = true;
mesh.receiveShadow = true;
scope.mixer.clipAction( geometry.animations[0], mesh ).play();
scope.setSkin( 0 );
scope.checkLoadComplete();
} );
};
this.setSkin = function( index ) {
if ( mesh && scope.materials ) {
mesh.material = scope.materials[ index ];
}
};
this.updateMorphs = function( influences ) {
if ( mesh ) {
for ( var i = 0; i < scope.numMorphs; i ++ ) {
mesh.morphTargetInfluences[ i ] = influences[ scope.morphs[ i ] ] / 100;
}
}
};
function loadTextures( baseUrl, textureUrls ) {
var textureLoader = new THREE.TextureLoader();
var textures = [];
for ( var i = 0; i < textureUrls.length; i ++ ) {
textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], scope.checkLoadComplete );
textures[ i ].mapping = THREE.UVMapping;
textures[ i ].name = textureUrls[ i ];
}
return textures;
}
function createMaterials( skins ) {
var materials = [];
for ( var i = 0; i < skins.length; i ++ ) {
materials[ i ] = new THREE.MeshLambertMaterial( {
color: 0xeeeeee,
specular: 10.0,
map: skins[ i ],
skinning: true,
morphTargets: true
} );
}
return materials;
}
this.checkLoadComplete = function () {
scope.loadCounter -= 1;
if ( scope.loadCounter === 0 ) {
scope.onLoadComplete();
}
}
};
|