提交 a5dc13b1 编写于 作者: S sunag

update code style all sea3d examples

上级 67e1da95
......@@ -157,12 +157,11 @@
scene.add( bvhSkeletonHelper );
scene.add( boneContainer );
// play animation
bvhMixer = new THREE.AnimationMixer( bvhSkeletonHelper );
// get offsets when it is in T-Pose
options.offsets = THREE.SkeletonUtils.getSkeletonOffsets( player, bvhSkeletonHelper, options );
// play animation
bvhMixer = new THREE.AnimationMixer( bvhSkeletonHelper );
bvhMixer.clipAction( result.clip ).setEffectiveWeight( 1.0 ).play();
} );
......
......@@ -59,11 +59,11 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
console.log("Visit https://github.com/sunag/sea3d to all codes and builds under development.");
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
var container, stats;
var camera, scene, renderer, composer, controls;
var camera, scene, renderer, composer;
var loader;
......@@ -77,30 +77,30 @@
loader = new THREE.SEA3D( {
autoPlay : false, // Auto play animations
container : scene // Container to add models
autoPlay: false, // Auto play animations
container: scene // Container to add models
} );
loader.onComplete = function( e ) {
loader.onComplete = function ( e ) {
// play all animations
for(var i = 0; i < loader.meshes.length; i++) {
for ( var i = 0; i < loader.meshes.length; i ++ ) {
if (loader.meshes[i].animator)
loader.meshes[i].animator.play( "root" );
if ( loader.meshes[ i ].animator )
loader.meshes[ i ].animator.play( "root" );
}
// Get the first camera from SEA3D Studio
// use loader.get... to get others objects
var cam = loader.cameras[0];
var cam = loader.cameras[ 0 ];
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
controls = new THREE.OrbitControls( camera );
new THREE.OrbitControls( camera );
animate();
......
......@@ -56,11 +56,11 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
console.log("Visit https://github.com/sunag/sea3d to all codes and builds under development.");
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
var container, stats;
var camera, scene, renderer, composer, controls, demoAt = -1;
var camera, scene, renderer, composer, demoAt = - 1;
var loader;
......@@ -74,25 +74,25 @@
loader = new THREE.SEA3D( {
autoPlay : false, // Manual play animations
container : scene // Container to add models
autoPlay: false, // Manual play animations
container: scene // Container to add models
} );
loader.onComplete = function( e ) {
loader.onComplete = function ( e ) {
// Get the first camera from 3ds Max
// use loader.get... to get others objects
var cam = loader.cameras[0];
var cam = loader.cameras[ 0 ];
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
controls = new THREE.OrbitControls( camera );
new THREE.OrbitControls( camera );
// events
window.addEventListener('click', onMouseClick, false);
window.addEventListener( 'click', onMouseClick, false );
animate();
......@@ -104,14 +104,14 @@
// Animation Functions
//
function playAll(id, crossfade, offset) {
function playAll( id, crossfade, offset ) {
// play all animations
for(var i = 0; i < loader.meshes.length; i++) {
for ( var i = 0; i < loader.meshes.length; i ++ ) {
if (loader.meshes[i].animator)
loader.meshes[i].animator.play(id, crossfade, offset);
if ( loader.meshes[ i ].animator )
loader.meshes[ i ].animator.play( id, crossfade, offset );
}
......@@ -119,10 +119,10 @@
function setTimeScale( timeScale ) {
for(var i = 0; i < loader.meshes.length; i++) {
for ( var i = 0; i < loader.meshes.length; i ++ ) {
if (loader.meshes[i].animator)
loader.meshes[i].animator.setTimeScale( timeScale );
if ( loader.meshes[ i ].animator )
loader.meshes[ i ].animator.setTimeScale( timeScale );
}
......@@ -130,10 +130,10 @@
function stopAll() {
for(var i = 0; i < loader.meshes.length; i++) {
for ( var i = 0; i < loader.meshes.length; i ++ ) {
if (loader.meshes[i].animator)
loader.meshes[i].animator.stop();
if ( loader.meshes[ i ].animator )
loader.meshes[ i ].animator.stop();
}
......@@ -201,9 +201,9 @@
//
function description(msg) {
function description( msg ) {
document.getElementById('description').innerHTML = (demoAt + 1) + " - " + msg;
document.getElementById( 'description' ).innerHTML = ( demoAt + 1 ) + " - " + msg;
}
......@@ -211,62 +211,64 @@
// 0 at 3 demos
switch( demoAt = ++demoAt % 4 ) {
switch ( demoAt = ++ demoAt % 4 ) {
// play all animation to sequence "crash#1"
// play all animation to sequence "crash#1"
case 0:
playAll("crash#1", .5);
setTimeScale(1);
playAll( "crash#1", .5 );
setTimeScale( 1 );
description("crash#1 - crossfade 0.5 seconds");
description( "crash#1 - crossfade 0.5 seconds" );
break;
// play all animation to sequence "crash#2"
// play all animation to sequence "crash#2"
case 1:
playAll("crash#2", .5);
playAll( "crash#2", .5 );
description("crash#2 - crossfade 0.5 seconds");
description( "crash#2 - crossfade 0.5 seconds" );
break;
// play animation in single object
// play animation in single object
case 2:
stopAll();
var fracture99 = loader.getMesh("Object099");
var fracture99 = loader.getMesh( "Object099" );
//fracture99.animator.setTimeScale( 1 );
//fracture99.animator.playing
//fracture99.animator.currentAnimation
//fracture99.animator.previousAnimation
fracture99.animator.play("crash#2", .5, 0);
fracture99.animator.play( "crash#2", .5, 0 );
//fracture99.animator.stop();
//fracture99.animator.pause();
//fracture99.animator.resume();
description("crash#2 in single object - crossfade 0.5 seconds");
description( "crash#2 in single object - crossfade 0.5 seconds" );
break;
// set time scale
// set time scale
case 3:
playAll("crash#2", .5);
setTimeScale(.1);
playAll( "crash#2", .5 );
setTimeScale( .1 );
description("time scale / 10 - crossfade 0.5 seconds");
description( "time scale / 10 - crossfade 0.5 seconds" );
break;
}
}
//
......
......@@ -56,11 +56,11 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
console.log("Visit https://github.com/sunag/sea3d to all codes and builds under development.");
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
var container, stats;
var camera, scene, renderer, composer, controls, teapot;
var camera, scene, renderer, composer, teapot;
var loader;
......@@ -74,26 +74,26 @@
loader = new THREE.SEA3D( {
autoPlay : true, // Auto play animations
scripts : false, // Disable embed scripts
container : scene // Container to add models
autoPlay: true, // Auto play animations
scripts: false, // Disable embed scripts
container: scene // Container to add models
} );
loader.onComplete = function( e ) {
loader.onComplete = function ( e ) {
// Get the first camera from SEA3D Studio
// use loader.get... to get others objects
var cam = loader.cameras[0];
var cam = loader.cameras[ 0 ];
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
controls = new THREE.OrbitControls( camera );
new THREE.OrbitControls( camera );
// get mesh
teapot = loader.getMesh("Teapot01");
teapot = loader.getMesh( "Teapot01" );
// events
......@@ -161,8 +161,8 @@
// change morph weight: 0 at 1
// names from modifier Morph of 3ds Max
teapot.setWeight("OldTeapot", mouseX / window.innerWidth);
teapot.setWeight("Sphere", mouseY / window.innerHeight);
teapot.setWeight( "OldTeapot", mouseX / window.innerWidth );
teapot.setWeight( "Sphere", mouseY / window.innerHeight );
}
......
......@@ -58,11 +58,11 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
console.log("Visit https://github.com/sunag/sea3d to all codes and builds under development.");
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
var container, stats;
var camera, scene, renderer, composer, controls, player, hat;
var camera, scene, renderer, composer, player, hat;
var loader;
......@@ -76,26 +76,26 @@
loader = new THREE.SEA3D( {
autoPlay : true, // Auto play animations
container : scene, // Container to add models
multiplier : .6 // Light multiplier
autoPlay: true, // Auto play animations
container: scene, // Container to add models
multiplier: .6 // Light multiplier
} );
loader.onComplete = function( e ) {
loader.onComplete = function ( e ) {
// Get the first camera from SEA3D Studio
// use loader.get... to get others objects
var cam = loader.cameras[0];
var cam = loader.cameras[ 0 ];
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
controls = new THREE.OrbitControls( camera );
// get meshes
player = loader.getMesh("Player");
hat = loader.getMesh("Hat");
player = loader.getMesh( "Player" );
hat = loader.getMesh( "Hat" );
// on animation complete example
......@@ -103,9 +103,9 @@
// or
player.animation['pass#1'].addEventListener(THREE.SEA3D.Animation.COMPLETE, function(e) {
player.animation[ 'pass#1' ].addEventListener( THREE.SEA3D.Animation.COMPLETE, function ( e ) {
console.log("Animation completed!", e);
console.log( "Animation completed!", e );
} );
......@@ -124,34 +124,34 @@
function updatePlayerCountDescription( count ) {
document.getElementById("playercount").innerText = "Numbers of players " + count + " | Middle click to clone";
document.getElementById( "playercount" ).innerText = "Numbers of players " + count + " | Middle click to clone";
}
var cloneAsset = function() {
var cloneAsset = function () {
var count = 2, size = 25;
return function() {
return function () {
updatePlayerCountDescription( count );
var PHI = Math.PI * 2 * (Math.sqrt(5) + 1) / 2; // golden ratio
var angle = PHI * count++;
var PHI = Math.PI * 2 * ( Math.sqrt( 5 ) + 1 ) / 2; // golden ratio
var angle = PHI * count ++;
var container = new THREE.Object3D();
container.position.z = ( size * count ) * Math.cos( angle );
container.position.x = ( size * count ) * Math.sin( angle );
scene.add( container );
var domain = loader.clone( {
autoPlay : true,
container : container,
lights : false
});
}
var domain = loader.clone( {
autoPlay: true,
container: container,
lights: false
} );
};
}();
......@@ -205,10 +205,10 @@
function onRightClick( e ) {
// play character animation
if (player.currentAnimation.name == "idle")
player.play("run", .5);// play "pass#1" to caller .onComplete animation example
if ( player.currentAnimation.name == "idle" )
player.play( "run", .5 );// play "pass#1" to caller .onComplete animation example
else
player.play("idle", .5);
player.play( "idle", .5 );
e.preventDefault();
......@@ -216,11 +216,11 @@
function onMouseClick( e ) {
if (e.button === 0) {
if ( e.button === 0 ) {
hat.visible = !hat.visible;
hat.visible = ! hat.visible;
} else if (e.button === 1) {
} else if ( e.button === 1 ) {
cloneAsset();
......
......@@ -103,7 +103,7 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
console.log("Visit https://github.com/sunag/sea3d to all codes and builds under development.");
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
var container, raycaster, stats;
......@@ -126,12 +126,12 @@
loader = new THREE.SEA3D( {
autoPlay : true, // Auto play animations
container : scene // Container to add models
autoPlay: true, // Auto play animations
container: scene // Container to add models
} );
loader.onComplete = function( e ) {
loader.onComplete = function ( e ) {
audioListener = loader.audioListener;
......@@ -144,19 +144,19 @@
// sound asset 1
lightOutside = loader.getLight("Light1");
lightOutside = loader.getLight( "Light1" );
var soundOutside = loader.getSound3D("Point001");
var soundOutside = loader.getSound3D( "Point001" );
soundOutsideAnalyser = new THREE.AudioAnalyser( soundOutside, 32 );
// sound asset 2 + area
lightArea = loader.getLight("Light2");
lightArea = loader.getLight( "Light2" );
soundArea = loader.getSound3D("Point002");
soundArea = loader.getSound3D( "Point002" );
soundAreaAnalyser = new THREE.AudioAnalyser( soundArea, 512 );
collisionArea = loader.getMesh("Torus003");
collisionArea = loader.getMesh( "Torus003" );
animate();
......@@ -394,18 +394,18 @@
function updateSoundFilter() {
// difference position between sound and listener
var difPos = new THREE.Vector3().setFromMatrixPosition( soundArea.matrixWorld ).sub(audioPos);
var difPos = new THREE.Vector3().setFromMatrixPosition( soundArea.matrixWorld ).sub( audioPos );
var length = difPos.length();
// pick a vector from camera to sound
raycaster.set( audioPos, difPos.normalize() );
// intersecting sound1
if ( length > 50 && raycaster.intersectObjects( [collisionArea] ).length ) {
if ( length > 50 && raycaster.intersectObjects( [ collisionArea ] ).length ) {
if ( soundArea.getFilters()[0] !== soundFilter ) soundArea.setFilters( [ soundFilter ] );
if ( soundArea.getFilters()[ 0 ] !== soundFilter ) soundArea.setFilters( [ soundFilter ] );
} else if ( soundArea.getFilters()[0] === soundFilter ) {
} else if ( soundArea.getFilters()[ 0 ] === soundFilter ) {
soundArea.setFilters( [] );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册