未验证 提交 83b394eb 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #14785 from Mugen87/dev2

Examples: Removed unused variables
...@@ -30,10 +30,6 @@ ...@@ -30,10 +30,6 @@
windowHalfX = window.innerWidth / 2, windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2, windowHalfY = window.innerHeight / 2,
SEPARATION = 200,
AMOUNTX = 10,
AMOUNTY = 10,
camera, scene, renderer; camera, scene, renderer;
init(); init();
...@@ -41,10 +37,7 @@ ...@@ -41,10 +37,7 @@
function init() { function init() {
var container, separation = 100, amountX = 50, amountY = 50, var container = document.createElement('div');
particles, particle;
container = document.createElement('div');
document.body.appendChild(container); document.body.appendChild(container);
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 ); camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
...@@ -77,7 +70,7 @@ ...@@ -77,7 +70,7 @@
for ( var i = 0; i < 100; i ++ ) { for ( var i = 0; i < 100; i ++ ) {
particle = new THREE.Sprite( material ); var particle = new THREE.Sprite( material );
particle.position.x = Math.random() * 2 - 1; particle.position.x = Math.random() * 2 - 1;
particle.position.y = Math.random() * 2 - 1; particle.position.y = Math.random() * 2 - 1;
particle.position.z = Math.random() * 2 - 1; particle.position.z = Math.random() * 2 - 1;
......
...@@ -46,8 +46,7 @@ ...@@ -46,8 +46,7 @@
<script> <script>
var camera, scene, renderer, var camera, scene, renderer, mesh;
loader, mesh;
init(); init();
animate(); animate();
...@@ -61,7 +60,7 @@ ...@@ -61,7 +60,7 @@
scene = new THREE.Scene(); scene = new THREE.Scene();
loader = new THREE.BufferGeometryLoader(); var loader = new THREE.BufferGeometryLoader();
loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) { loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) {
mesh = new THREE.Mesh( geometry, new THREE.MeshNormalMaterial( { overdraw: 0.5 } ) ); mesh = new THREE.Mesh( geometry, new THREE.MeshNormalMaterial( { overdraw: 0.5 } ) );
...@@ -100,8 +99,6 @@ ...@@ -100,8 +99,6 @@
function render() { function render() {
var time = Date.now() * 0.0005;
if ( mesh ) { if ( mesh ) {
mesh.rotation.x -= 0.005; mesh.rotation.x -= 0.005;
......
...@@ -105,8 +105,6 @@ ...@@ -105,8 +105,6 @@
function render() { function render() {
var time = Date.now() * 0.0005;
if ( mesh ) mesh.rotation.y -= 0.01; if ( mesh ) mesh.rotation.y -= 0.01;
renderer.render( scene, camera ); renderer.render( scene, camera );
......
...@@ -42,7 +42,7 @@ THREE.MD2Character = function () { ...@@ -42,7 +42,7 @@ THREE.MD2Character = function () {
var loader = new THREE.MD2Loader(); var loader = new THREE.MD2Loader();
loader.load( config.baseUrl + config.body, function( geo ) { loader.load( config.baseUrl + config.body, function ( geo ) {
geo.computeBoundingBox(); geo.computeBoundingBox();
scope.root.position.y = - scope.scale * geo.boundingBox.min.y; scope.root.position.y = - scope.scale * geo.boundingBox.min.y;
...@@ -55,7 +55,7 @@ THREE.MD2Character = function () { ...@@ -55,7 +55,7 @@ THREE.MD2Character = function () {
scope.meshBody = mesh; scope.meshBody = mesh;
scope.meshBody.clipOffset = 0; scope.meshBody.clipOffset = 0;
scope.activeAnimationClipName = mesh.geometry.animations[0].name; scope.activeAnimationClipName = mesh.geometry.animations[ 0 ].name;
scope.mixer = new THREE.AnimationMixer( mesh ); scope.mixer = new THREE.AnimationMixer( mesh );
...@@ -67,7 +67,7 @@ THREE.MD2Character = function () { ...@@ -67,7 +67,7 @@ THREE.MD2Character = function () {
var generateCallback = function ( index, name ) { var generateCallback = function ( index, name ) {
return function( geo ) { return function ( geo ) {
var mesh = createPart( geo, scope.skinsWeapon[ index ] ); var mesh = createPart( geo, scope.skinsWeapon[ index ] );
mesh.scale.set( scope.scale, scope.scale, scope.scale ); mesh.scale.set( scope.scale, scope.scale, scope.scale );
...@@ -82,7 +82,7 @@ THREE.MD2Character = function () { ...@@ -82,7 +82,7 @@ THREE.MD2Character = function () {
checkLoadingComplete(); checkLoadingComplete();
} };
}; };
...@@ -96,11 +96,14 @@ THREE.MD2Character = function () { ...@@ -96,11 +96,14 @@ THREE.MD2Character = function () {
this.setPlaybackRate = function ( rate ) { this.setPlaybackRate = function ( rate ) {
if( rate !== 0 ) { if ( rate !== 0 ) {
this.mixer.timeScale = 1 / rate; this.mixer.timeScale = 1 / rate;
}
else { } else {
this.mixer.timeScale = 0; this.mixer.timeScale = 0;
} }
}; };
...@@ -121,7 +124,7 @@ THREE.MD2Character = function () { ...@@ -121,7 +124,7 @@ THREE.MD2Character = function () {
}; };
this.setSkin = function( index ) { this.setSkin = function ( index ) {
if ( this.meshBody && this.meshBody.material.wireframe === false ) { if ( this.meshBody && this.meshBody.material.wireframe === false ) {
...@@ -152,13 +155,16 @@ THREE.MD2Character = function () { ...@@ -152,13 +155,16 @@ THREE.MD2Character = function () {
if ( this.meshBody ) { if ( this.meshBody ) {
if( this.meshBody.activeAction ) { if ( this.meshBody.activeAction ) {
this.meshBody.activeAction.stop(); this.meshBody.activeAction.stop();
this.meshBody.activeAction = null; this.meshBody.activeAction = null;
} }
var action = this.mixer.clipAction( clipName, this.meshBody ); var action = this.mixer.clipAction( clipName, this.meshBody );
if( action ) {
if ( action ) {
this.meshBody.activeAction = action.play(); this.meshBody.activeAction = action.play();
...@@ -172,35 +178,34 @@ THREE.MD2Character = function () { ...@@ -172,35 +178,34 @@ THREE.MD2Character = function () {
}; };
this.syncWeaponAnimation = function() { this.syncWeaponAnimation = function () {
var clipName = scope.activeClipName; var clipName = scope.activeClipName;
if ( scope.meshWeapon ) { if ( scope.meshWeapon ) {
if( this.meshWeapon.activeAction ) { if ( this.meshWeapon.activeAction ) {
this.meshWeapon.activeAction.stop(); this.meshWeapon.activeAction.stop();
this.meshWeapon.activeAction = null; this.meshWeapon.activeAction = null;
}
var geometry = this.meshWeapon.geometry, }
animations = geometry.animations;
var action = this.mixer.clipAction( clipName, this.meshWeapon ); var action = this.mixer.clipAction( clipName, this.meshWeapon );
if( action ) {
this.meshWeapon.activeAction = if ( action ) {
action.syncWith( this.meshBody.activeAction ).play();
this.meshWeapon.activeAction = action.syncWith( this.meshBody.activeAction ).play();
} }
} }
} };
this.update = function ( delta ) { this.update = function ( delta ) {
if( this.mixer ) this.mixer.update( delta ); if ( this.mixer ) this.mixer.update( delta );
}; };
......
...@@ -104,11 +104,9 @@ ...@@ -104,11 +104,9 @@
// lights // lights
var light, materials;
scene.add( new THREE.AmbientLight( 0x666666 ) ); scene.add( new THREE.AmbientLight( 0x666666 ) );
light = new THREE.DirectionalLight( 0xdfebff, 1 ); var light = new THREE.DirectionalLight( 0xdfebff, 1 );
light.position.set( 50, 200, 100 ); light.position.set( 50, 200, 100 );
light.position.multiplyScalar( 1.3 ); light.position.multiplyScalar( 1.3 );
......
...@@ -181,19 +181,9 @@ ...@@ -181,19 +181,9 @@
function createScene( geometry, materials, x, y, z, s ) { function createScene( geometry, materials, x, y, z, s ) {
//ensureLoop( geometry.animation );
geometry.computeBoundingBox(); geometry.computeBoundingBox();
var bb = geometry.boundingBox; var bb = geometry.boundingBox;
var path = "textures/cube/Park2/";
var format = '.jpg';
var urls = [
path + 'posx' + format, path + 'negx' + format,
path + 'posy' + format, path + 'negy' + format,
path + 'posz' + format, path + 'negz' + format
];
for ( var i = 0; i < materials.length; i ++ ) { for ( var i = 0; i < materials.length; i ++ ) {
var m = materials[ i ]; var m = materials[ i ];
...@@ -201,17 +191,8 @@ ...@@ -201,17 +191,8 @@
m.morphTargets = true; m.morphTargets = true;
m.specular.setHSL( 0, 0, 0.1 ); m.specular.setHSL( 0, 0, 0.1 );
m.color.setHSL( 0.6, 0, 0.6 ); m.color.setHSL( 0.6, 0, 0.6 );
//m.map = map;
//m.envMap = envMap;
//m.bumpMap = bumpMap;
//m.bumpScale = 2;
//m.combine = THREE.MixOperation;
//m.reflectivity = 0.75;
} }
mesh = new THREE.SkinnedMesh( geometry, materials ); mesh = new THREE.SkinnedMesh( geometry, materials );
......
...@@ -193,8 +193,6 @@ ...@@ -193,8 +193,6 @@
emissive: 0x000000 emissive: 0x000000
}; };
var meshes = [];
var geometry = new THREE.SphereBufferGeometry(0.5, 24, 12); var geometry = new THREE.SphereBufferGeometry(0.5, 24, 12);
for (var i = 0; i < labeldata.length; i++) { for (var i = 0; i < labeldata.length; i++) {
......
...@@ -152,8 +152,7 @@ ...@@ -152,8 +152,7 @@
function generateTexture( data, width, height ) { function generateTexture( data, width, height ) {
var canvas, canvasScaled, context, image, imageData, var canvas, canvasScaled, context, image, imageData, vector3, sun, shade;
level, diff, vector3, sun, shade;
vector3 = new THREE.Vector3( 0, 0, 0 ); vector3 = new THREE.Vector3( 0, 0, 0 );
......
...@@ -155,8 +155,7 @@ ...@@ -155,8 +155,7 @@
function generateTexture( data, width, height ) { function generateTexture( data, width, height ) {
var canvas, canvasScaled, context, image, imageData, var canvas, canvasScaled, context, image, imageData, vector3, sun, shade;
level, diff, vector3, sun, shade;
vector3 = new THREE.Vector3( 0, 0, 0 ); vector3 = new THREE.Vector3( 0, 0, 0 );
......
...@@ -168,8 +168,7 @@ ...@@ -168,8 +168,7 @@
// bake lighting into texture // bake lighting into texture
var canvas, canvasScaled, context, image, imageData, var canvas, canvasScaled, context, image, imageData, vector3, sun, shade;
level, diff, vector3, sun, shade;
vector3 = new THREE.Vector3( 0, 0, 0 ); vector3 = new THREE.Vector3( 0, 0, 0 );
......
...@@ -290,7 +290,6 @@ ...@@ -290,7 +290,6 @@
hemiLight.intensity = hemiLuminousIrradiances[ params.hemiIrradiance ]; hemiLight.intensity = hemiLuminousIrradiances[ params.hemiIrradiance ];
var time = Date.now() * 0.0005; var time = Date.now() * 0.0005;
var delta = clock.getDelta();
bulbLight.position.y = Math.cos( time ) * 0.75 + 1.25; bulbLight.position.y = Math.cos( time ) * 0.75 + 1.25;
......
...@@ -60,15 +60,15 @@ ...@@ -60,15 +60,15 @@
}; };
var texture = new THREE.Texture();
var material = new THREE.MeshBasicMaterial( { color: 'red' } );
var onProgress = function ( xhr ) { var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) { if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100; var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round(percentComplete, 2) + '% downloaded' ); console.log( Math.round(percentComplete, 2) + '% downloaded' );
} }
}; };
var onError = function ( xhr ) { var onError = function ( xhr ) {
......
...@@ -103,10 +103,7 @@ ...@@ -103,10 +103,7 @@
var loader = new THREE.NRRDLoader(); var loader = new THREE.NRRDLoader();
loader.load( "models/nrrd/I.nrrd", function ( volume ) { loader.load( "models/nrrd/I.nrrd", function ( volume ) {
var geometry, var geometry,
canvas,
canvasMap,
material, material,
plane,
sliceZ, sliceZ,
sliceY, sliceY,
sliceX; sliceX;
...@@ -122,18 +119,14 @@ ...@@ -122,18 +119,14 @@
scene.add( cube ); scene.add( cube );
//z plane //z plane
var indexZ = 0;
sliceZ = volume.extractSlice('z',Math.floor(volume.RASDimensions[2]/4)); sliceZ = volume.extractSlice('z',Math.floor(volume.RASDimensions[2]/4));
scene.add( sliceZ.mesh ); scene.add( sliceZ.mesh );
//y plane //y plane
var indexY = 0;
sliceY = volume.extractSlice('y',Math.floor(volume.RASDimensions[1]/2)); sliceY = volume.extractSlice('y',Math.floor(volume.RASDimensions[1]/2));
scene.add( sliceY.mesh ); scene.add( sliceY.mesh );
//x plane //x plane
var indexX = 0;
sliceX = volume.extractSlice('x',Math.floor(volume.RASDimensions[0]/2)); sliceX = volume.extractSlice('x',Math.floor(volume.RASDimensions[0]/2));
scene.add( sliceX.mesh ); scene.add( sliceX.mesh );
......
...@@ -158,8 +158,6 @@ ...@@ -158,8 +158,6 @@
var effectColor = new THREE.ShaderPass( THREE.ColorCorrectionShader ); var effectColor = new THREE.ShaderPass( THREE.ColorCorrectionShader );
effectFXAA = new THREE.ShaderPass( THREE.FXAAShader ); effectFXAA = new THREE.ShaderPass( THREE.FXAAShader );
var canvas = renderer.context.canvas;
effectFXAA.uniforms[ 'resolution' ].value.set( 1 / window.innerWidth, 1 / window.innerHeight ); effectFXAA.uniforms[ 'resolution' ].value.set( 1 / window.innerWidth, 1 / window.innerHeight );
effectBleach.uniforms[ 'opacity' ].value = 0.4; effectBleach.uniforms[ 'opacity' ].value = 0.4;
......
...@@ -260,8 +260,6 @@ ...@@ -260,8 +260,6 @@
renderer.toneMappingExposure = params.exposure; renderer.toneMappingExposure = params.exposure;
var timer = Date.now() * 0.00025;
camera.lookAt( scene.position ); camera.lookAt( scene.position );
if( params.autoRotate ) { if( params.autoRotate ) {
......
...@@ -76,10 +76,6 @@ ...@@ -76,10 +76,6 @@
imgTexture.anisotropy = 16; imgTexture.anisotropy = 16;
imgTexture = null; imgTexture = null;
var shininess = 50, specular = 0x333333;
var materials = [];
var cubeWidth = 400; var cubeWidth = 400;
var numberOfSphersPerSide = 5; var numberOfSphersPerSide = 5;
var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5; var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
......
...@@ -76,10 +76,6 @@ ...@@ -76,10 +76,6 @@
imgTexture.anisotropy = 16; imgTexture.anisotropy = 16;
imgTexture = null; imgTexture = null;
var shininess = 50, specular = 0x333333;
var materials = [];
var cubeWidth = 400; var cubeWidth = 400;
var numberOfSphersPerSide = 5; var numberOfSphersPerSide = 5;
var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5; var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
......
...@@ -76,10 +76,7 @@ ...@@ -76,10 +76,7 @@
imgTexture.anisotropy = 16; imgTexture.anisotropy = 16;
imgTexture = null; imgTexture = null;
var shininess = 50, specular = 0x333333, bumpScale = 1; var bumpScale = 1;
var materials = [];
var cubeWidth = 400; var cubeWidth = 400;
var numberOfSphersPerSide = 5; var numberOfSphersPerSide = 5;
var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5; var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
......
...@@ -101,10 +101,7 @@ ...@@ -101,10 +101,7 @@
hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget; hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
var shininess = 50, specular = 0x333333, bumpScale = 1; var bumpScale = 1;
var materials = [];
var cubeWidth = 400; var cubeWidth = 400;
var numberOfSphersPerSide = 5; var numberOfSphersPerSide = 5;
var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5; var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
......
...@@ -78,10 +78,7 @@ ...@@ -78,10 +78,7 @@
imgTexture.anisotropy = 16; imgTexture.anisotropy = 16;
imgTexture = null; imgTexture = null;
var shininess = 50, specular = 0x333333, bumpScale = 1; var bumpScale = 1;
var materials = [];
var cubeWidth = 400; var cubeWidth = 400;
var numberOfSphersPerSide = 5; var numberOfSphersPerSide = 5;
var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5; var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
......
...@@ -204,7 +204,7 @@ ...@@ -204,7 +204,7 @@
var geometry = new THREE.Geometry().fromBufferGeometry( bufGeometry ); var geometry = new THREE.Geometry().fromBufferGeometry( bufGeometry );
// Merge the vertices so the triangle soup is converted to indexed triangles // Merge the vertices so the triangle soup is converted to indexed triangles
var vertsDiff = geometry.mergeVertices(); geometry.mergeVertices();
// Convert again to BufferGeometry, indexed // Convert again to BufferGeometry, indexed
var indexedBufferGeom = createIndexedBufferGeometryFromGeometry( geometry ); var indexedBufferGeom = createIndexedBufferGeometryFromGeometry( geometry );
......
...@@ -183,7 +183,6 @@ ...@@ -183,7 +183,6 @@
var width = window.innerWidth || 1; var width = window.innerWidth || 1;
var height = window.innerHeight || 1; var height = window.innerHeight || 1;
var devicePixelRatio = window.devicePixelRatio || 1;
camera.aspect = width / height; camera.aspect = width / height;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
......
...@@ -119,7 +119,6 @@ ...@@ -119,7 +119,6 @@
var vA = new THREE.Vector2(); var vA = new THREE.Vector2();
var vB = new THREE.Vector2(); var vB = new THREE.Vector2();
var vDot = new THREE.Vector2();
function processShape( path, reverse ) { function processShape( path, reverse ) {
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
for ( var i = 0; i !== ANIMATION_GROUPS; ++ i ) { for ( var i = 0; i !== ANIMATION_GROUPS; ++ i ) {
var group = new THREE.AnimationObjectGroup(); var group = new THREE.AnimationObjectGroup();
animGroups.push( new THREE.AnimationObjectGroup() ); animGroups.push( group );
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
var textureLoader = new THREE.TextureLoader(); var textureLoader = new THREE.TextureLoader();
var mapA = textureLoader.load( "textures/sprite0.png", createHUDSprites ); textureLoader.load( "textures/sprite0.png", createHUDSprites );
var mapB = textureLoader.load( "textures/sprite1.png" ); var mapB = textureLoader.load( "textures/sprite1.png" );
mapC = textureLoader.load( "textures/sprite2.png" ); mapC = textureLoader.load( "textures/sprite2.png" );
......
...@@ -265,8 +265,6 @@ ...@@ -265,8 +265,6 @@
renderer.toneMappingExposure = params.exposure; renderer.toneMappingExposure = params.exposure;
renderer.toneMappingWhitePoint = params.whitePoint; renderer.toneMappingWhitePoint = params.whitePoint;
var timer = Date.now() * 0.00025;
camera.lookAt( scene.position ); camera.lookAt( scene.position );
for ( var i = 0, l = group.children.length; i < l; i ++ ) { for ( var i = 0, l = group.children.length; i < l; i ++ ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册