提交 0b76ce4b 编写于 作者: M Mugen87

Global: Improve code style

上级 b22db83f
......@@ -53,7 +53,7 @@ Menubar.Examples = function ( editor ) {
} );
options.add( option );
} )( i )
} )( i );
}
......
......@@ -517,7 +517,7 @@ Sidebar.Material = function ( editor ) {
if ( currentMaterialSlot !== previousSelectedSlot ) refreshUI( true );
var material = editor.getObjectMaterial( currentObject, currentMaterialSlot )
var material = editor.getObjectMaterial( currentObject, currentMaterialSlot );
var textureWarning = false;
var objectHasUvs = false;
......
......@@ -40,7 +40,7 @@ var Toolbar = function ( editor ) {
} );
buttons.add( scale );
var local = new UI.THREE.Boolean( false, 'local' )
var local = new UI.THREE.Boolean( false, 'local' );
local.onChange( function () {
signals.spaceChanged.dispatch( this.getValue() === true ? 'local' : 'world' );
......
......@@ -76,7 +76,7 @@
Bird.prototype = Object.create( THREE.Geometry.prototype );
Bird.prototype.constructor = Bird;
// Based on https://www.openprocessing.org/sketch/6910
var Boid = function () {
......@@ -351,7 +351,7 @@
return posSum;
}
};
}
......
THREE.UCSCharacter = function() {
THREE.UCSCharacter = function () {
var scope = this;
......@@ -39,7 +39,7 @@ THREE.UCSCharacter = function() {
// CHARACTER
var loader = new THREE.JSONLoader();
console.log( config.baseUrl + config.character );
loader.load( config.baseUrl + config.character, function( geometry ) {
loader.load( config.baseUrl + config.character, function ( geometry ) {
geometry.computeBoundingBox();
geometry.computeVertexNormals();
......@@ -55,7 +55,7 @@ THREE.UCSCharacter = function() {
mesh.castShadow = true;
mesh.receiveShadow = true;
scope.mixer.clipAction( geometry.animations[0], mesh ).play();
scope.mixer.clipAction( geometry.animations[ 0 ], mesh ).play();
scope.setSkin( 0 );
......@@ -65,7 +65,7 @@ THREE.UCSCharacter = function() {
};
this.setSkin = function( index ) {
this.setSkin = function ( index ) {
if ( mesh && scope.materials ) {
......@@ -75,7 +75,7 @@ THREE.UCSCharacter = function() {
};
this.updateMorphs = function( influences ) {
this.updateMorphs = function ( influences ) {
if ( mesh ) {
......@@ -136,6 +136,6 @@ THREE.UCSCharacter = function() {
}
}
};
};
......@@ -374,7 +374,7 @@ THREE.Volume.prototype = {
matrix : planeMatrix,
planeWidth : planeWidth,
planeHeight : planeHeight
}
};
},
......
......@@ -7,7 +7,7 @@
* @param {string} [axis='z'] For now only 'x', 'y' or 'z' but later it will change to a normal vector
* @see THREE.Volume
*/
THREE.VolumeSlice = function( volume, index, axis ) {
THREE.VolumeSlice = function ( volume, index, axis ) {
var slice = this;
/**
......@@ -19,12 +19,12 @@ THREE.VolumeSlice = function( volume, index, axis ) {
*/
index = index || 0;
Object.defineProperty( this, 'index', {
get : function() {
get: function () {
return index;
},
set : function( value ) {
set: function ( value ) {
index = value;
slice.geometryNeedsUpdate = true;
......@@ -57,7 +57,7 @@ THREE.VolumeSlice = function( volume, index, axis ) {
var canvasMap = new THREE.Texture( this.canvas );
canvasMap.minFilter = THREE.LinearFilter;
canvasMap.wrapS = canvasMap.wrapT = THREE.ClampToEdgeWrapping;
var material = new THREE.MeshBasicMaterial( { map: canvasMap, side: THREE.DoubleSide, transparent : true } );
var material = new THREE.MeshBasicMaterial( { map: canvasMap, side: THREE.DoubleSide, transparent: true } );
/**
* @member {THREE.Mesh} mesh The mesh ready to get used in the scene
*/
......@@ -89,13 +89,13 @@ THREE.VolumeSlice = function( volume, index, axis ) {
THREE.VolumeSlice.prototype = {
constructor : THREE.VolumeSlice,
constructor: THREE.VolumeSlice,
/**
* @member {Function} repaint Refresh the texture and the geometry if geometryNeedsUpdate is set to true
* @memberof THREE.VolumeSlice
*/
repaint : function() {
repaint: function () {
if ( this.geometryNeedsUpdate ) {
......@@ -104,13 +104,11 @@ THREE.VolumeSlice.prototype = {
}
var iLength = this.iLength,
jLength = this.jLength,
sliceAccess = this.sliceAccess,
volume = this.volume,
axis = this.axis,
index = this.index,
canvas = this.canvasBuffer,
ctx = this.ctxBuffer;
jLength = this.jLength,
sliceAccess = this.sliceAccess,
volume = this.volume,
canvas = this.canvasBuffer,
ctx = this.ctxBuffer;
// get the imageData and pixel array from the canvas
......@@ -145,8 +143,7 @@ THREE.VolumeSlice.prototype = {
}
}
else {
} else {
for ( var j = 0; j < jLength; j ++ ) {
......@@ -184,7 +181,7 @@ THREE.VolumeSlice.prototype = {
* @see THREE.Volume.extractPerpendicularPlane
* @memberof THREE.VolumeSlice
*/
updateGeometry : function() {
updateGeometry: function () {
var extracted = this.volume.extractPerpendicularPlane( this.axis, this.index );
this.sliceAccess = extracted.sliceAccess;
......
......@@ -221,7 +221,7 @@ THREE.MMDAnimationHelper = ( function () {
if ( params.ik !== false ) {
this._createCCDIKSolver( mesh ).update( params.saveOriginalBonesBeforeIK ); // this param is experimental
this._createCCDIKSolver( mesh ).update( params.saveOriginalBonesBeforeIK ); // this param is experimental
}
......@@ -324,7 +324,7 @@ THREE.MMDAnimationHelper = ( function () {
if ( params.animation !== undefined ) {
this._setupCameraAnimation( camera, params.animation )
this._setupCameraAnimation( camera, params.animation );
}
......@@ -668,7 +668,7 @@ THREE.MMDAnimationHelper = ( function () {
objects.set( clip, {
duration: clip.duration
} )
} );
}
......@@ -692,7 +692,7 @@ THREE.MMDAnimationHelper = ( function () {
objects.set( clip, {
duration: clip.duration
} )
} );
}
......
......@@ -43,21 +43,21 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
var _changed = true;
var _state = STATE.NONE,
_prevState = STATE.NONE,
_prevState = STATE.NONE,
_eye = new THREE.Vector3(),
_eye = new THREE.Vector3(),
_rotateStart = new THREE.Vector3(),
_rotateEnd = new THREE.Vector3(),
_rotateStart = new THREE.Vector3(),
_rotateEnd = new THREE.Vector3(),
_zoomStart = new THREE.Vector2(),
_zoomEnd = new THREE.Vector2(),
_zoomStart = new THREE.Vector2(),
_zoomEnd = new THREE.Vector2(),
_touchZoomDistanceStart = 0,
_touchZoomDistanceEnd = 0,
_touchZoomDistanceStart = 0,
_touchZoomDistanceEnd = 0,
_panStart = new THREE.Vector2(),
_panEnd = new THREE.Vector2();
_panStart = new THREE.Vector2(),
_panEnd = new THREE.Vector2();
// for reset
......@@ -176,7 +176,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
}() );
this.rotateCamera = ( function() {
this.rotateCamera = ( function () {
var axis = new THREE.Vector3(),
quaternion = new THREE.Quaternion();
......@@ -214,7 +214,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
}
}
};
}() );
......@@ -255,7 +255,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
};
this.panCamera = ( function() {
this.panCamera = ( function () {
var mouseChange = new THREE.Vector2(),
objectUp = new THREE.Vector3(),
......@@ -293,7 +293,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
}
}
};
}() );
......@@ -429,7 +429,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
} else if ( _state === STATE.PAN && ! _this.noPan ) {
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
_panEnd.copy( _panStart )
_panEnd.copy( _panStart );
}
......@@ -586,7 +586,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
}
this.dispose = function() {
this.dispose = function () {
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
this.domElement.removeEventListener( 'mousedown', mousedown, false );
......
......@@ -52,7 +52,7 @@ THREE.TransformControls = function ( camera, domElement ) {
X: new THREE.Vector3( 1, 0, 0 ),
Y: new THREE.Vector3( 0, 1, 0 ),
Z: new THREE.Vector3( 0, 0, 1 )
}
};
var _identityQuaternion = new THREE.Quaternion();
var _alignVector = new THREE.Vector3();
......@@ -232,7 +232,7 @@ THREE.TransformControls = function ( camera, domElement ) {
}
}
};
this.pointerDown = function( pointer ) {
......@@ -289,7 +289,7 @@ THREE.TransformControls = function ( camera, domElement ) {
}
}
};
this.pointerMove = function( pointer ) {
......@@ -483,7 +483,7 @@ THREE.TransformControls = function ( camera, domElement ) {
this.dispatchEvent( changeEvent );
this.dispatchEvent( objectChangeEvent );
}
};
this.pointerUp = function( pointer ) {
......@@ -500,7 +500,7 @@ THREE.TransformControls = function ( camera, domElement ) {
if ( pointer.button === undefined ) this.axis = null;
}
};
// normalize mouse / touch pointer and remap {x,y} to view space.
......
......@@ -61,22 +61,24 @@ function Transition ( sceneA, sceneB ) {
"void main() {",
"vec4 texel1 = texture2D( tDiffuse1, vUv );",
"vec4 texel2 = texture2D( tDiffuse2, vUv );",
" vec4 texel1 = texture2D( tDiffuse1, vUv );",
" vec4 texel2 = texture2D( tDiffuse2, vUv );",
"if (useTexture==1) {",
" if (useTexture==1) {",
"vec4 transitionTexel = texture2D( tMixTexture, vUv );",
"float r = mixRatio * (1.0 + threshold * 2.0) - threshold;",
"float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);",
" vec4 transitionTexel = texture2D( tMixTexture, vUv );",
" float r = mixRatio * (1.0 + threshold * 2.0) - threshold;",
" float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);",
"gl_FragColor = mix( texel1, texel2, mixf );",
"} else {",
" gl_FragColor = mix( texel1, texel2, mixf );",
"gl_FragColor = mix( texel2, texel1, mixRatio );",
" } else {",
"}",
"}"
" gl_FragColor = mix( texel2, texel1, mixRatio );",
" }",
"}"
].join( "\n" )
......@@ -114,7 +116,7 @@ function Transition ( sceneA, sceneB ) {
};
this.render = function( delta ) {
this.render = function ( delta ) {
// Transition animation
if ( transitionParams.animateTransition ) {
......@@ -159,6 +161,6 @@ function Transition ( sceneA, sceneB ) {
}
}
};
}
......@@ -129,7 +129,7 @@ THREE.DRACOLoader.prototype = {
console.log('Loaded a point cloud.');
}
} else {
var errorMsg = 'THREE.DRACOLoader: Unknown geometry type.'
var errorMsg = 'THREE.DRACOLoader: Unknown geometry type.';
console.error(errorMsg);
throw new Error(errorMsg);
}
......
......@@ -132,7 +132,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) {
for ( var i = 0; i < HUF_DECSIZE; i ++ ) {
hdec[ i ] = {}
hdec[ i ] = {};
hdec[ i ].len = 0;
hdec[ i ].lit = 0;
hdec[ i ].p = null;
......@@ -692,7 +692,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) {
if ( maxNonZero >= BITMAP_SIZE ) {
throw 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE'
throw 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE';
}
......@@ -715,7 +715,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) {
var pizChannelData = new Array( num_channels );
var outBufferEnd = 0
var outBufferEnd = 0;
for ( var i = 0; i < num_channels; i ++ ) {
......
......@@ -5,7 +5,11 @@
'use strict';
if ( THREE.LoaderSupport === undefined ) { THREE.LoaderSupport = {} }
if ( THREE.LoaderSupport === undefined ) {
THREE.LoaderSupport = {};
}
/**
* Validation functions.
......@@ -943,7 +947,7 @@ THREE.LoaderSupport.WorkerSupport = (function () {
payload.logging = {
enabled: true,
debug: false
}
};
}
this._postMessage();
......
......@@ -218,7 +218,7 @@ THREE.OBJLoader2 = (function () {
if ( ! Validator.isValid( onError ) ) {
onError = function ( event ) {
scope._onError( event );
}
};
}
// fast-fail
......@@ -419,7 +419,7 @@ THREE.OBJLoader2 = (function () {
if ( ! Validator.isValid( content ) ) {
console.warn( 'Provided content is not a valid ArrayBuffer.' );
scopedOnLoad()
scopedOnLoad();
} else {
......@@ -1427,7 +1427,7 @@ THREE.OBJLoader2 = (function () {
if ( ! Validator.isValid( onError ) ) {
onError = function ( event ) {
scope._onError( event );
}
};
}
if ( ! Validator.isValid( onProgress ) ) {
var numericalValueRef = 0;
......
......@@ -21,8 +21,6 @@ THREE.RaytracingRenderer = function ( parameters ) {
alpha: parameters.alpha === true
} );
var maxRecursionDepth = 3;
var canvasWidth, canvasHeight;
var clearColor = new THREE.Color( 0x000000 );
......@@ -39,15 +37,16 @@ THREE.RaytracingRenderer = function ( parameters ) {
console.log( '%cSpinning off ' + workers + ' Workers ', 'font-size: 20px; background: black; color: white; font-family: monospace;' );
this.setWorkers = function( w ) {
this.setWorkers = function ( w ) {
workers = w || navigator.hardwareConcurrency || 4;
while ( pool.length < workers ) {
var worker = new Worker( parameters.workerPath );
worker.id = workerId++;
worker.id = workerId ++;
worker.onmessage = function( e ) {
worker.onmessage = function ( e ) {
var data = e.data;
......@@ -75,7 +74,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
};
worker.color = new THREE.Color().setHSL( Math.random() , 0.8, 0.8 ).getHexString();
worker.color = new THREE.Color().setHSL( Math.random(), 0.8, 0.8 ).getHexString();
pool.push( worker );
updateSettings( worker );
......@@ -109,7 +108,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
this.setWorkers( workers );
this.setClearColor = function ( color, alpha ) {
this.setClearColor = function ( color /*, alpha */ ) {
clearColor.set( color );
......@@ -155,6 +154,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
}
function renderNext( worker ) {
if ( ! toRender.length ) {
renderering = false;
......@@ -213,6 +213,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
}
materials[ mat.uuid ] = props;
}
this.render = function ( scene, camera ) {
......@@ -234,7 +235,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
scene.traverse( serializeObject );
pool.forEach( function( worker ) {
pool.forEach( function ( worker ) {
worker.postMessage( {
scene: sceneJSON,
......@@ -242,6 +243,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
annex: materials,
sceneId: sceneId
} );
} );
context.clearRect( 0, 0, canvasWidth, canvasHeight );
......@@ -266,7 +268,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
for ( var i = 0; i < totalBlocks; i ++ ) {
var swap = Math.random() * totalBlocks | 0;
var swap = Math.random() * totalBlocks | 0;
var tmp = toRender[ swap ];
toRender[ swap ] = toRender[ i ];
toRender[ i ] = tmp;
......
var worker;
var BLOCK = 128;
var startX, startY, division, completed = 0;
var startX, startY;
var scene, camera, renderer, loader, sceneId;
importScripts( '../../../build/three.js' );
self.onmessage = function( e ) {
self.onmessage = function ( e ) {
var data = e.data;
if ( ! data ) return;
......@@ -18,7 +17,6 @@ self.onmessage = function( e ) {
width = data.init[ 0 ],
height = data.init[ 1 ];
worker = data.worker;
BLOCK = data.blockSize;
if ( ! renderer ) renderer = new THREE.RaytracingRendererWorker();
......@@ -29,8 +27,6 @@ self.onmessage = function( e ) {
// TODO fix passing maxRecursionDepth as parameter.
// if (data.maxRecursionDepth) maxRecursionDepth = data.maxRecursionDepth;
completed = 0;
}
if ( data.scene ) {
......@@ -39,7 +35,7 @@ self.onmessage = function( e ) {
camera = loader.parse( data.camera );
var meta = data.annex;
scene.traverse( function( o ) {
scene.traverse( function ( o ) {
if ( o.isPointLight ) {
......@@ -49,10 +45,11 @@ self.onmessage = function( e ) {
var mat = o.material;
if (!mat) return;
if ( ! mat ) return;
var material = meta[ mat.uuid ];
for (var m in material) {
for ( var m in material ) {
mat[ m ] = material[ m ];
......@@ -61,6 +58,7 @@ self.onmessage = function( e ) {
} );
sceneId = data.sceneId;
}
if ( data.render && scene && camera ) {
......@@ -71,7 +69,7 @@ self.onmessage = function( e ) {
}
}
};
/**
* DOM-less version of Raytracing Renderer
......@@ -84,8 +82,6 @@ THREE.RaytracingRendererWorker = function () {
console.log( 'THREE.RaytracingRendererWorker', THREE.REVISION );
var scope = this;
var maxRecursionDepth = 3;
var canvasWidth, canvasHeight;
......@@ -479,22 +475,17 @@ THREE.RaytracingRendererWorker = function () {
blockY: blockY,
blockSize: blockSize,
sceneId: sceneId,
time: Date.now() - reallyThen, // time for this renderer
time: Date.now(), // time for this renderer
}, [ data.buffer ] );
data = new Uint8ClampedArray( blockSize * blockSize * 4 );
// OK Done!
completed ++;
};
}() );
this.render = function ( scene, camera ) {
reallyThen = Date.now()
// update scene graph
if ( scene.autoUpdate === true ) scene.updateMatrixWorld();
......
......@@ -76,7 +76,7 @@
controls.screenSpacePanning = false;
controls.minDistance = 100;
controls.maxDistance = 500
controls.maxDistance = 500;
controls.maxPolarAngle = Math.PI / 2;
......
......@@ -118,7 +118,7 @@
} else if ( type === 4 || type === 5 ) {
var material = new THREE.MeshLambertMaterial( { color : 0x00cc00 } );
var geometry = generateTriangleGeometry()
var geometry = generateTriangleGeometry();
var mesh = new THREE.Mesh( geometry, material );
mesh.position.x = -200;
......
......@@ -118,7 +118,7 @@
Binary: function() {
exportBinary();
}
}
};
var gui = new dat.GUI();
var folder = gui.addFolder( 'Export' );
......
......@@ -160,7 +160,7 @@
//
var gui = new dat.GUI()
var gui = new dat.GUI();
gui.add( material, 'wireframe' );
//
......
......@@ -172,7 +172,7 @@
renderer.domElement.id = 'renderer_' + name;
framecontainer.appendChild(renderer.domElement);
return { container: framecontainer, renderer: renderer, scene: scene, camera: camera }
return { container: framecontainer, renderer: renderer, scene: scene, camera: camera };
}
......
......@@ -149,7 +149,7 @@
tweenParameters[ prop ] = position;
target[ prop ] = THREE.Math.randInt( joint.limits.min, joint.limits.max )
target[ prop ] = THREE.Math.randInt( joint.limits.min, joint.limits.max );
}
......
......@@ -124,7 +124,7 @@
head3.position.x = 900;
head3.material = cubeMaterial3;
scene.add( head, head2, head3 )
scene.add( head, head2, head3 );
} );
......
......@@ -49,7 +49,7 @@
var wireframeMaterial = new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, opacity: 0.15, transparent: true } );
var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
var smoothMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors } )
var smoothMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors } );
// Cube
......
......@@ -143,7 +143,7 @@
geometry = new THREE.BufferGeometry().fromGeometry( geometry );
var numFaces = geometry.attributes.position.count / 3
var numFaces = geometry.attributes.position.count / 3;
var colors = new Float32Array( numFaces * 3 * 3 );
var displacement = new Float32Array( numFaces * 3 * 3 );
......
......@@ -339,7 +339,7 @@
volumeSoftBody.get_m_materials().at( 0 ).set_m_kLST( 0.9 );
volumeSoftBody.get_m_materials().at( 0 ).set_m_kAST( 0.9 );
volumeSoftBody.setTotalMass( mass, false )
volumeSoftBody.setTotalMass( mass, false );
Ammo.castObject( volumeSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin );
physicsWorld.addSoftBody( volumeSoftBody, 1, -1 );
volume.userData.physicsBody = volumeSoftBody;
......
......@@ -136,7 +136,7 @@
} else {
mesh = new THREE.Mesh( geo, new THREE.MeshBasicMaterial( parameters ) );
materials[ count ] = mesh.material
materials[ count ] = mesh.material;
}
......
......@@ -73,7 +73,7 @@
saoBlurRadius: 12,
saoBlurStdDev: 6,
saoBlurDepthCutoff: 0.01
}
};
var supportsDepthTextureExtension = false;
var isWebGL2 = false;
......
......@@ -148,7 +148,7 @@
clone = scene.clone();
clone.autoUpdate = false;
bounces ++
bounces ++;
currentVertex = 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册