diff --git a/build/three.js b/build/three.js
index 6ad8a582745f94fec9d1ab8f448aeea101203f3a..e803466e5839e8d53b11dbadbe9dfb948ecf89f7 100644
--- a/build/three.js
+++ b/build/three.js
@@ -97,90 +97,6 @@
}
- /**
- * https://github.com/mrdoob/eventdispatcher.js/
- */
-
- function EventDispatcher() {}
-
- Object.assign( EventDispatcher.prototype, {
-
- addEventListener: function ( type, listener ) {
-
- if ( this._listeners === undefined ) { this._listeners = {}; }
-
- var listeners = this._listeners;
-
- if ( listeners[ type ] === undefined ) {
-
- listeners[ type ] = [];
-
- }
-
- if ( listeners[ type ].indexOf( listener ) === - 1 ) {
-
- listeners[ type ].push( listener );
-
- }
-
- },
-
- hasEventListener: function ( type, listener ) {
-
- if ( this._listeners === undefined ) { return false; }
-
- var listeners = this._listeners;
-
- return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
-
- },
-
- removeEventListener: function ( type, listener ) {
-
- if ( this._listeners === undefined ) { return; }
-
- var listeners = this._listeners;
- var listenerArray = listeners[ type ];
-
- if ( listenerArray !== undefined ) {
-
- var index = listenerArray.indexOf( listener );
-
- if ( index !== - 1 ) {
-
- listenerArray.splice( index, 1 );
-
- }
-
- }
-
- },
-
- dispatchEvent: function ( event ) {
-
- if ( this._listeners === undefined ) { return; }
-
- var listeners = this._listeners;
- var listenerArray = listeners[ event.type ];
-
- if ( listenerArray !== undefined ) {
-
- event.target = this;
-
- var array = listenerArray.slice( 0 );
-
- for ( var i = 0, l = array.length; i < l; i ++ ) {
-
- array[ i ].call( this, event );
-
- }
-
- }
-
- }
-
- } );
-
var REVISION = '109dev';
var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -350,6 +266,90 @@
var GreaterEqualStencilFunc = 518;
var AlwaysStencilFunc = 519;
+ /**
+ * https://github.com/mrdoob/eventdispatcher.js/
+ */
+
+ function EventDispatcher() {}
+
+ Object.assign( EventDispatcher.prototype, {
+
+ addEventListener: function ( type, listener ) {
+
+ if ( this._listeners === undefined ) { this._listeners = {}; }
+
+ var listeners = this._listeners;
+
+ if ( listeners[ type ] === undefined ) {
+
+ listeners[ type ] = [];
+
+ }
+
+ if ( listeners[ type ].indexOf( listener ) === - 1 ) {
+
+ listeners[ type ].push( listener );
+
+ }
+
+ },
+
+ hasEventListener: function ( type, listener ) {
+
+ if ( this._listeners === undefined ) { return false; }
+
+ var listeners = this._listeners;
+
+ return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
+
+ },
+
+ removeEventListener: function ( type, listener ) {
+
+ if ( this._listeners === undefined ) { return; }
+
+ var listeners = this._listeners;
+ var listenerArray = listeners[ type ];
+
+ if ( listenerArray !== undefined ) {
+
+ var index = listenerArray.indexOf( listener );
+
+ if ( index !== - 1 ) {
+
+ listenerArray.splice( index, 1 );
+
+ }
+
+ }
+
+ },
+
+ dispatchEvent: function ( event ) {
+
+ if ( this._listeners === undefined ) { return; }
+
+ var listeners = this._listeners;
+ var listenerArray = listeners[ event.type ];
+
+ if ( listenerArray !== undefined ) {
+
+ event.target = this;
+
+ var array = listenerArray.slice( 0 );
+
+ for ( var i = 0, l = array.length; i < l; i ++ ) {
+
+ array[ i ].call( this, event );
+
+ }
+
+ }
+
+ }
+
+ } );
+
/**
* @author alteredq / http://alteredqualia.com/
* @author mrdoob / http://mrdoob.com/
@@ -8330,9 +8330,10 @@
this.depthTest = true;
this.depthWrite = true;
+ this.stencilWriteMask = 0xff;
this.stencilFunc = AlwaysStencilFunc;
this.stencilRef = 0;
- this.stencilMask = 0xff;
+ this.stencilFuncMask = 0xff;
this.stencilFail = KeepStencilOp;
this.stencilZFail = KeepStencilOp;
this.stencilZPass = KeepStencilOp;
@@ -8458,6 +8459,7 @@
if ( this.roughness !== undefined ) { data.roughness = this.roughness; }
if ( this.metalness !== undefined ) { data.metalness = this.metalness; }
+ if ( this.sheen && this.sheen.isColor ) { data.sheen = this.sheen.getHex(); }
if ( this.emissive && this.emissive.isColor ) { data.emissive = this.emissive.getHex(); }
if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) { data.emissiveIntensity = this.emissiveIntensity; }
@@ -8547,9 +8549,10 @@
data.depthWrite = this.depthWrite;
data.stencilWrite = this.stencilWrite;
+ data.stencilWriteMask = this.stencilWriteMask;
data.stencilFunc = this.stencilFunc;
data.stencilRef = this.stencilRef;
- data.stencilMask = this.stencilMask;
+ data.stencilFuncMask = this.stencilFuncMask;
data.stencilFail = this.stencilFail;
data.stencilZFail = this.stencilZFail;
data.stencilZPass = this.stencilZPass;
@@ -8651,9 +8654,10 @@
this.depthWrite = source.depthWrite;
this.stencilWrite = source.stencilWrite;
+ this.stencilWriteMask = source.stencilWriteMask;
this.stencilFunc = source.stencilFunc;
this.stencilRef = source.stencilRef;
- this.stencilMask = source.stencilMask;
+ this.stencilFuncMask = source.stencilFuncMask;
this.stencilFail = source.stencilFail;
this.stencilZFail = source.stencilZFail;
this.stencilZPass = source.stencilZPass;
@@ -15545,6 +15549,10 @@
var maxSamples = isWebGL2 ? gl.getParameter( 36183 ) : 0;
+ var multiviewExt = extensions.get( 'OVR_multiview2' );
+ var multiview = isWebGL2 && !! multiviewExt && ! gl.getContextAttributes().antialias;
+ var maxMultiviewViews = multiview ? gl.getParameter( multiviewExt.MAX_VIEWS_OVR ) : 0;
+
return {
isWebGL2: isWebGL2,
@@ -15569,7 +15577,10 @@
floatFragmentTextures: floatFragmentTextures,
floatVertexTextures: floatVertexTextures,
- maxSamples: maxSamples
+ maxSamples: maxSamples,
+
+ multiview: multiview,
+ maxMultiviewViews: maxMultiviewViews
};
@@ -17599,6 +17610,9 @@
var prefixVertex, prefixFragment;
+ var renderTarget = renderer.getRenderTarget();
+ var numMultiviewViews = renderTarget && renderTarget.isWebGLMultiviewRenderTarget ? renderTarget.numViews : 0;
+
if ( material.isRawShaderMaterial ) {
prefixVertex = [
@@ -17686,14 +17700,27 @@
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
-
'uniform mat4 modelMatrix;',
- 'uniform mat4 modelViewMatrix;',
- 'uniform mat4 projectionMatrix;',
- 'uniform mat4 viewMatrix;',
- 'uniform mat3 normalMatrix;',
'uniform vec3 cameraPosition;',
+ numMultiviewViews > 0 ? [
+ 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
+ 'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
+ 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
+
+ '#define modelViewMatrix modelViewMatrices[VIEW_ID]',
+ '#define normalMatrix normalMatrices[VIEW_ID]',
+ '#define viewMatrix viewMatrices[VIEW_ID]',
+ '#define projectionMatrix projectionMatrices[VIEW_ID]'
+
+ ].join( '\n' ) : [
+
+ 'uniform mat4 modelViewMatrix;',
+ 'uniform mat4 projectionMatrix;',
+ 'uniform mat4 viewMatrix;',
+ 'uniform mat3 normalMatrix;' ].join( '\n' ),
+
'attribute vec3 position;',
'attribute vec3 normal;',
'attribute vec2 uv;',
@@ -17810,9 +17837,15 @@
( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '',
- 'uniform mat4 viewMatrix;',
'uniform vec3 cameraPosition;',
+ numMultiviewViews > 0 ? [
+
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
+ '#define viewMatrix viewMatrices[VIEW_ID]'
+
+ ].join( '\n' ) : 'uniform mat4 viewMatrix;',
+
( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',
( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below
( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',
@@ -17866,6 +17899,15 @@
// GLSL 3.0 conversion
prefixVertex = [
'#version 300 es\n',
+
+ numMultiviewViews > 0 ? [
+
+ '#extension GL_OVR_multiview2 : require',
+ 'layout(num_views = ' + numMultiviewViews + ') in;',
+ '#define VIEW_ID gl_ViewID_OVR'
+
+ ].join( '\n' ) : '',
+
'#define attribute in',
'#define varying out',
'#define texture2D texture'
@@ -17873,6 +17915,12 @@
prefixFragment = [
'#version 300 es\n',
+ numMultiviewViews > 0 ? [
+
+ '#extension GL_OVR_multiview2 : require',
+ '#define VIEW_ID gl_ViewID_OVR'
+
+ ].join( '\n' ) : '',
'#define varying in',
isGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',
isGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',
@@ -18030,6 +18078,7 @@
this.program = program;
this.vertexShader = glVertexShader;
this.fragmentShader = glFragmentShader;
+ this.numMultiviewViews = numMultiviewViews;
return this;
@@ -20398,7 +20447,8 @@
stencilBuffer.setTest( stencilWrite );
if ( stencilWrite ) {
- stencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilMask );
+ stencilBuffer.setMask( material.stencilWriteMask );
+ stencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );
stencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );
}
@@ -20959,6 +21009,21 @@
}
+ if ( renderTarget.isWebGLMultiviewRenderTarget ) {
+
+ _gl.deleteTexture( renderTargetProperties.__webglColorTexture );
+ _gl.deleteTexture( renderTargetProperties.__webglDepthStencilTexture );
+
+ info.memory.textures -= 2;
+
+ for ( var i = 0, il = renderTargetProperties.__webglViewFramebuffers.length; i < il; i ++ ) {
+
+ _gl.deleteFramebuffer( renderTargetProperties.__webglViewFramebuffers[ i ] );
+
+ }
+
+ }
+
properties.remove( renderTarget.texture );
properties.remove( renderTarget );
@@ -21645,6 +21710,7 @@
var isCube = ( renderTarget.isWebGLRenderTargetCube === true );
var isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );
+ var isMultiview = ( renderTarget.isWebGLMultiviewRenderTarget === true );
var supportsMips = isPowerOfTwo( renderTarget ) || capabilities.isWebGL2;
// Setup framebuffer
@@ -21697,6 +21763,56 @@
}
+ } else if ( isMultiview ) {
+
+ if ( capabilities.multiview ) {
+
+ var width = renderTarget.width;
+ var height = renderTarget.height;
+ var numViews = renderTarget.numViews;
+
+ _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer );
+
+ var ext = extensions.get( 'OVR_multiview2' );
+
+ info.memory.textures += 2;
+
+ var colorTexture = _gl.createTexture();
+ _gl.bindTexture( 35866, colorTexture );
+ _gl.texParameteri( 35866, 10240, 9728 );
+ _gl.texParameteri( 35866, 10241, 9728 );
+ _gl.texImage3D( 35866, 0, 32856, width, height, numViews, 0, 6408, 5121, null );
+ ext.framebufferTextureMultiviewOVR( 36160, 36064, colorTexture, 0, 0, numViews );
+
+ var depthStencilTexture = _gl.createTexture();
+ _gl.bindTexture( 35866, depthStencilTexture );
+ _gl.texParameteri( 35866, 10240, 9728 );
+ _gl.texParameteri( 35866, 10241, 9728 );
+ _gl.texImage3D( 35866, 0, 35056, width, height, numViews, 0, 34041, 34042, null );
+ ext.framebufferTextureMultiviewOVR( 36160, 33306, depthStencilTexture, 0, 0, numViews );
+
+ var viewFramebuffers = new Array( numViews );
+ for ( var i = 0; i < numViews; ++ i ) {
+
+ viewFramebuffers[ i ] = _gl.createFramebuffer();
+ _gl.bindFramebuffer( 36160, viewFramebuffers[ i ] );
+ _gl.framebufferTextureLayer( 36160, 36064, colorTexture, 0, i );
+
+ }
+
+ renderTargetProperties.__webglColorTexture = colorTexture;
+ renderTargetProperties.__webglDepthStencilTexture = depthStencilTexture;
+ renderTargetProperties.__webglViewFramebuffers = viewFramebuffers;
+
+ _gl.bindFramebuffer( 36160, null );
+ _gl.bindTexture( 35866, null );
+
+ } else {
+
+ console.warn( 'THREE.WebGLRenderer: WebGLMultiviewRenderTarget can only be used with WebGL2 and Multiview extension support.' );
+
+ }
+
}
}
@@ -21722,7 +21838,7 @@
state.bindTexture( 34067, null );
- } else {
+ } else if ( ! isMultiview ) {
state.bindTexture( 3553, textureProperties.__webglTexture );
setTextureParameters( 3553, renderTarget.texture, supportsMips );
@@ -22059,6 +22175,258 @@
}
+ /**
+ * @author fernandojsg / http://fernandojsg.com
+ * @author Takahiro https://github.com/takahirox
+ */
+
+ function WebGLMultiviewRenderTarget( width, height, numViews, options ) {
+
+ WebGLRenderTarget.call( this, width, height, options );
+
+ this.depthBuffer = false;
+ this.stencilBuffer = false;
+
+ this.numViews = numViews;
+
+ }
+
+ WebGLMultiviewRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), {
+
+ constructor: WebGLMultiviewRenderTarget,
+
+ isWebGLMultiviewRenderTarget: true,
+
+ copy: function ( source ) {
+
+ WebGLRenderTarget.prototype.copy.call( this, source );
+
+ this.numViews = source.numViews;
+
+ return this;
+
+ },
+
+ setNumViews: function ( numViews ) {
+
+ if ( this.numViews !== numViews ) {
+
+ this.numViews = numViews;
+ this.dispose();
+
+ }
+
+ return this;
+
+ }
+
+ } );
+
+ /**
+ * @author fernandojsg / http://fernandojsg.com
+ * @author Takahiro https://github.com/takahirox
+ */
+
+ function WebGLMultiview( renderer, gl ) {
+
+ var DEFAULT_NUMVIEWS = 2;
+
+ var capabilities = renderer.capabilities;
+ var properties = renderer.properties;
+
+ var maxNumViews = capabilities.maxMultiviewViews;
+
+ var renderTarget, currentRenderTarget;
+ var mat3, mat4, cameraArray, renderSize;
+
+ function getCameraArray( camera ) {
+
+ if ( camera.isArrayCamera ) { return camera.cameras; }
+
+ cameraArray[ 0 ] = camera;
+
+ return cameraArray;
+
+ }
+
+ //
+
+ function updateCameraProjectionMatricesUniform( camera, uniforms ) {
+
+ var cameras = getCameraArray( camera );
+
+ for ( var i = 0; i < cameras.length; i ++ ) {
+
+ mat4[ i ].copy( cameras[ i ].projectionMatrix );
+
+ }
+
+ uniforms.setValue( gl, 'projectionMatrices', mat4 );
+
+ }
+
+ function updateCameraViewMatricesUniform( camera, uniforms ) {
+
+ var cameras = getCameraArray( camera );
+
+ for ( var i = 0; i < cameras.length; i ++ ) {
+
+ mat4[ i ].copy( cameras[ i ].matrixWorldInverse );
+
+ }
+
+ uniforms.setValue( gl, 'viewMatrices', mat4 );
+
+ }
+
+ function updateObjectMatricesUniforms( object, camera, uniforms ) {
+
+ var cameras = getCameraArray( camera );
+
+ for ( var i = 0; i < cameras.length; i ++ ) {
+
+ mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld );
+ mat3[ i ].getNormalMatrix( mat4[ i ] );
+
+ }
+
+ uniforms.setValue( gl, 'modelViewMatrices', mat4 );
+ uniforms.setValue( gl, 'normalMatrices', mat3 );
+
+ }
+
+ function isMultiviewCompatible( camera ) {
+
+ if ( ! camera.isArrayCamera ) { return true; }
+
+ var cameras = camera.cameras;
+
+ if ( cameras.length > maxNumViews ) { return false; }
+
+ for ( var i = 1, il = cameras.length; i < il; i ++ ) {
+
+ if ( cameras[ 0 ].viewport.z !== cameras[ i ].viewport.z ||
+ cameras[ 0 ].viewport.w !== cameras[ i ].viewport.w ) { return false; }
+
+ }
+
+ return true;
+
+ }
+
+ function resizeRenderTarget( camera ) {
+
+ if ( currentRenderTarget ) {
+
+ renderSize.set( currentRenderTarget.width, currentRenderTarget.height );
+
+ } else {
+
+ renderer.getDrawingBufferSize( renderSize );
+
+ }
+
+ if ( camera.isArrayCamera ) {
+
+ var viewport = camera.cameras[ 0 ].viewport;
+
+ renderTarget.setSize( viewport.z, viewport.w );
+
+ renderTarget.setNumViews( camera.cameras.length );
+
+ } else {
+
+ renderTarget.setSize( renderSize.x, renderSize.y );
+ renderTarget.setNumViews( DEFAULT_NUMVIEWS );
+
+ }
+
+ }
+
+ function attachCamera( camera ) {
+
+ if ( ! isMultiviewCompatible( camera ) ) { return; }
+
+ currentRenderTarget = renderer.getRenderTarget();
+ resizeRenderTarget( camera );
+ renderer.setRenderTarget( renderTarget );
+
+ }
+
+ function detachCamera( camera ) {
+
+ if ( renderTarget !== renderer.getRenderTarget() ) { return; }
+
+ renderer.setRenderTarget( currentRenderTarget );
+ flush( camera );
+
+ }
+
+ function flush( camera ) {
+
+ var srcRenderTarget = renderTarget;
+ var numViews = srcRenderTarget.numViews;
+
+ var srcFramebuffers = properties.get( srcRenderTarget ).__webglViewFramebuffers;
+
+ var viewWidth = srcRenderTarget.width;
+ var viewHeight = srcRenderTarget.height;
+
+ if ( camera.isArrayCamera ) {
+
+ for ( var i = 0; i < numViews; i ++ ) {
+
+ var viewport = camera.cameras[ i ].viewport;
+
+ var x1 = viewport.x;
+ var y1 = viewport.y;
+ var x2 = x1 + viewport.z;
+ var y2 = y1 + viewport.w;
+
+ gl.bindFramebuffer( 36008, srcFramebuffers[ i ] );
+ gl.blitFramebuffer( 0, 0, viewWidth, viewHeight, x1, y1, x2, y2, 16384, 9728 );
+
+ }
+
+ } else {
+
+ gl.bindFramebuffer( 36008, srcFramebuffers[ 0 ] );
+ gl.blitFramebuffer( 0, 0, viewWidth, viewHeight, 0, 0, renderSize.x, renderSize.y, 16384, 9728 );
+
+ }
+
+ }
+
+
+ if ( renderer.capabilities.multiview ) {
+
+ renderTarget = new WebGLMultiviewRenderTarget( 0, 0, DEFAULT_NUMVIEWS );
+
+ renderSize = new Vector2();
+ mat4 = [];
+ mat3 = [];
+ cameraArray = [];
+
+ var maxViews = capabilities.maxMultiviewViews;
+
+ for ( var i = 0; i < maxViews; i ++ ) {
+
+ mat4[ i ] = new Matrix4();
+ mat3[ i ] = new Matrix3();
+
+ }
+
+ }
+
+
+ this.attachCamera = attachCamera;
+ this.detachCamera = detachCamera;
+ this.updateCameraProjectionMatricesUniform = updateCameraProjectionMatricesUniform;
+ this.updateCameraViewMatricesUniform = updateCameraViewMatricesUniform;
+ this.updateObjectMatricesUniforms = updateObjectMatricesUniforms;
+
+ }
+
/**
* @author mrdoob / http://mrdoob.com/
*/
@@ -23162,6 +23530,10 @@
this.vr = vr;
+ // Multiview
+
+ var multiview = new WebGLMultiview( _this, _gl );
+
// shadow map
var shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize );
@@ -24025,6 +24397,12 @@
}
+ if ( capabilities.multiview ) {
+
+ multiview.attachCamera( camera );
+
+ }
+
//
background.render( currentRenderList, scene, camera, forceClear );
@@ -24079,6 +24457,12 @@
state.setPolygonOffset( false );
+ if ( capabilities.multiview ) {
+
+ multiview.detachCamera( camera );
+
+ }
+
if ( vr.enabled ) {
vr.submitFrame();
@@ -24225,19 +24609,27 @@
_currentArrayCamera = camera;
- var cameras = camera.cameras;
+ if ( capabilities.multiview ) {
+
+ renderObject( object, scene, camera, geometry, material, group );
+
+ } else {
+
+ var cameras = camera.cameras;
+
+ for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
- for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
+ var camera2 = cameras[ j ];
- var camera2 = cameras[ j ];
+ if ( object.layers.test( camera2.layers ) ) {
- if ( object.layers.test( camera2.layers ) ) {
+ state.viewport( _currentViewport.copy( camera2.viewport ) );
- state.viewport( _currentViewport.copy( camera2.viewport ) );
+ currentRenderState.setupLights( camera2 );
- currentRenderState.setupLights( camera2 );
+ renderObject( object, scene, camera2, geometry, material, group );
- renderObject( object, scene, camera2, geometry, material, group );
+ }
}
@@ -24532,7 +24924,15 @@
if ( refreshProgram || _currentCamera !== camera ) {
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
+ if ( program.numMultiviewViews > 0 ) {
+
+ multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms );
+
+ } else {
+
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
+
+ }
if ( capabilities.logarithmicDepthBuffer ) {
@@ -24580,7 +24980,15 @@
material.isShaderMaterial ||
material.skinning ) {
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
+ if ( program.numMultiviewViews > 0 ) {
+
+ multiview.updateCameraViewMatricesUniform( camera, p_uniforms );
+
+ } else {
+
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
+
+ }
}
@@ -24785,8 +25193,17 @@
// common matrices
- p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
- p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
+ if ( program.numMultiviewViews > 0 ) {
+
+ multiview.updateObjectMatricesUniforms( object, camera, p_uniforms );
+
+ } else {
+
+ p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
+ p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
+
+ }
+
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
return program;
@@ -34481,6 +34898,7 @@
var itemsLoaded = 0;
var itemsTotal = 0;
var urlModifier = undefined;
+ var handlers = [];
// Refer to #5689 for the reason why we don't set .onStart
// in the constructor
@@ -34557,10 +34975,52 @@
this.setURLModifier = function ( transform ) {
urlModifier = transform;
+
return this;
};
+ this.addHandler = function ( regex, loader ) {
+
+ handlers.push( regex, loader );
+
+ return this;
+
+ };
+
+ this.removeHandler = function ( regex ) {
+
+ var index = handlers.indexOf( regex );
+
+ if ( index !== - 1 ) {
+
+ handlers.splice( index, 2 );
+
+ }
+
+ return this;
+
+ };
+
+ this.getHandler = function ( file ) {
+
+ for ( var i = 0, l = handlers.length; i < l; i += 2 ) {
+
+ var regex = handlers[ i ];
+ var loader = handlers[ i + 1 ];
+
+ if ( regex.test( file ) ) {
+
+ return loader;
+
+ }
+
+ }
+
+ return null;
+
+ };
+
}
var DefaultLoadingManager = new LoadingManager();
@@ -34608,41 +35068,6 @@
} );
- //
-
- Loader.Handlers = {
-
- handlers: [],
-
- add: function ( regex, loader ) {
-
- this.handlers.push( regex, loader );
-
- },
-
- get: function ( file ) {
-
- var handlers = this.handlers;
-
- for ( var i = 0, l = handlers.length; i < l; i += 2 ) {
-
- var regex = handlers[ i ];
- var loader = handlers[ i + 1 ];
-
- if ( regex.test( file ) ) {
-
- return loader;
-
- }
-
- }
-
- return null;
-
- }
-
- };
-
/**
* @author mrdoob / http://mrdoob.com/
*/
@@ -38194,6 +38619,7 @@
if ( json.color !== undefined ) { material.color.setHex( json.color ); }
if ( json.roughness !== undefined ) { material.roughness = json.roughness; }
if ( json.metalness !== undefined ) { material.metalness = json.metalness; }
+ if ( json.sheen !== undefined ) { material.sheen = new Color().setHex( json.sheen ); }
if ( json.emissive !== undefined ) { material.emissive.setHex( json.emissive ); }
if ( json.specular !== undefined ) { material.specular.setHex( json.specular ); }
if ( json.shininess !== undefined ) { material.shininess = json.shininess; }
@@ -38211,6 +38637,16 @@
if ( json.depthTest !== undefined ) { material.depthTest = json.depthTest; }
if ( json.depthWrite !== undefined ) { material.depthWrite = json.depthWrite; }
if ( json.colorWrite !== undefined ) { material.colorWrite = json.colorWrite; }
+
+ if ( json.stencilWrite !== undefined ) { material.stencilWrite = json.stencilWrite; }
+ if ( json.stencilWriteMask !== undefined ) { material.stencilWriteMask = json.stencilWriteMask; }
+ if ( json.stencilFunc !== undefined ) { material.stencilFunc = json.stencilFunc; }
+ if ( json.stencilRef !== undefined ) { material.stencilRef = json.stencilRef; }
+ if ( json.stencilFuncMask !== undefined ) { material.stencilFuncMask = json.stencilFuncMask; }
+ if ( json.stencilFail !== undefined ) { material.stencilFail = json.stencilFail; }
+ if ( json.stencilZFail !== undefined ) { material.stencilZFail = json.stencilZFail; }
+ if ( json.stencilZPass !== undefined ) { material.stencilZPass = json.stencilZPass; }
+
if ( json.wireframe !== undefined ) { material.wireframe = json.wireframe; }
if ( json.wireframeLinewidth !== undefined ) { material.wireframeLinewidth = json.wireframeLinewidth; }
if ( json.wireframeLinecap !== undefined ) { material.wireframeLinecap = json.wireframeLinecap; }
@@ -46569,7 +47005,7 @@
if ( headLength === undefined ) { headLength = 0.2 * length; }
if ( headWidth === undefined ) { headWidth = 0.2 * headLength; }
- this.line.scale.set( 1, Math.max( 0, length - headLength ), 1 );
+ this.line.scale.set( 1, Math.max( 0.0001, length - headLength ), 1 ); // see #17458
this.line.updateMatrix();
this.cone.scale.set( headWidth, headLength, headWidth );
@@ -46982,6 +47418,22 @@
} );
+ Loader.Handlers = {
+
+ add: function ( /* regex, loader */ ) {
+
+ console.error( 'THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.' );
+
+ },
+
+ get: function ( /* file */ ) {
+
+ console.error( 'THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.' );
+
+ }
+
+ };
+
function XHRLoader( manager ) {
console.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' );
@@ -47869,6 +48321,21 @@
console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );
this.flatShading = ( value === FlatShading );
+ }
+ },
+
+ stencilMask: {
+ get: function () {
+
+ console.warn( 'THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.' );
+ return this.stencilFuncMask;
+
+ },
+ set: function ( value ) {
+
+ console.warn( 'THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.' );
+ this.stencilFuncMask = value;
+
}
}
@@ -48500,6 +48967,16 @@
}
+ if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
+
+ /* eslint-disable no-undef */
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
+ revision: REVISION,
+ } } ) );
+ /* eslint-enable no-undef */
+
+ }
+
exports.ACESFilmicToneMapping = ACESFilmicToneMapping;
exports.AddEquation = AddEquation;
exports.AddOperation = AddOperation;
diff --git a/build/three.min.js b/build/three.min.js
index 75c3229d54566064183db3ca43a285b83d8cf626..e986df6770d1c3758a342a4b34cffedae3a870e3 100644
--- a/build/three.min.js
+++ b/build/three.min.js
@@ -1,84 +1,84 @@
-// threejs.org/license
-(function(k,za){"object"===typeof exports&&"undefined"!==typeof module?za(exports):"function"===typeof define&&define.amd?define(["exports"],za):(k=k||self,za(k.THREE={}))})(this,function(k){function za(){}function v(a,b){this.x=a||0;this.y=b||0}function sa(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function n(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function S(){this.elements=[1,0,0,0,1,0,0,0,1];0b&&(b=a[c]);return b}function D(){Object.defineProperty(this,"id",{value:Qi+=2});this.uuid=N.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}function R(a,b){C.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new D;this.material=void 0!==b?b:new Ga({color:16777215*Math.random()});
+this.drawMode=0;this.updateMorphTargets()}function jh(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==b.side,h)))return null;Ee.copy(h);Ee.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Ee);return b
+ The bit mask to use when writing to the stencil buffer. Default is *0xFF*. +
+The stencil comparison function to use. Default is [page:Materials AlwaysStencilFunc]. See stencil function [page:Materials constants] for all possible values. @@ -138,9 +143,9 @@ The value to use when performing stencil comparisons or stencil operations. Default is *0*.
-- The bit mask to use when comparing against or writing to the stencil buffer. Default is *0xFF*. + The bit mask to use when comparing against the stencil buffer. Default is *0xFF*.
+The bit mask to use when writing to the stencil buffer. Default is *0xFF*. +
+The stencil comparison function to use. Default is [page:Materials AlwaysStencilFunc]. See stencil function [page:Materials constants] for all possible values. @@ -118,9 +123,9 @@ The stencil comparison function to use. Default is [page:Materials AlwaysStencil The value to use when performing stencil comparisons or stencil operations. Default is *0*.
--The bit mask to use when comparing against or writing to the stencil buffer. Default is *0xFF*. +The bit mask to use when comparing against the stencil buffer. Default is *0xFF*.
+ Can be used to orient the camera based on the mobile device's orientation. +
+ +[example:misc_controls_deviceorientation misc / controls / deviceorientation ]
+ ++
+ [page:Camera object]: The camera to be controlled. +
++ Creates a new instance of [name]. +
+ + ++ The alpha offset in radians. Default is *0*. +
+ ++ The current *deviceorientation* event object. +
+ ++ Whether or not the controls are enabled. +
+ ++ The camera to be controlled. +
+ ++ The orientation in degrees (in 90-degree increments) of the viewport relative to the device's natural orientation. Default is *0*. +
+ ++ Adds the event listeners of the controls and enables it. +
+ ++ Removes the event listeners of the controls and disables it. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Updates the controls. Usually called in the animation loop. +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DeviceOrientationControls.js examples/js/controls/DeviceOrientationControls.js] +
+ + diff --git a/docs/examples/en/controls/DragControls.html b/docs/examples/en/controls/DragControls.html new file mode 100644 index 0000000000000000000000000000000000000000..a22c12445d66accfddb95de347f30e04bd8ae61d --- /dev/null +++ b/docs/examples/en/controls/DragControls.html @@ -0,0 +1,119 @@ + + + + ++ This class can be used to provide a drag'n'drop interaction. +
+ +[example:misc_controls_drag misc / controls / drag ]
+ +
+var controls = new THREE.DragControls( objects, camera, renderer.domElement );
+
+// add event listener to highlight dragged objects
+
+controls.addEventListener( 'dragstart', function ( event ) {
+
+ event.object.material.emissive.set( 0xaaaaaa );
+
+} );
+
+controls.addEventListener( 'dragend', function ( event ) {
+
+ event.object.material.emissive.set( 0x000000 );
+
+} );
+
+
+
+ +
+ [page:Array objects]: An array of draggable 3D objects. +
++ [page:Camera camera]: The camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: The HTML element used for event listeners. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the user starts to drag a 3D object. +
+ ++ Fires when the user drags a 3D object. +
+ ++ Fires when the user has finished dragging a 3D object. +
+ ++ Fires when the pointer is moved onto a 3D object, or onto one of its children. +
+ ++ Fires when the pointer is moved out of a 3D object. +
+ ++ Whether or not the controls are enabled. +
+ +See the base [page:EventDispatcher] class for common methods.
+ ++ Adds the event listeners of the controls. +
+ ++ Removes the event listeners of the controls. +
+ ++ Should be called if the controls is no longer required. +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DragControls.js examples/js/controls/DragControls.js] +
+ + diff --git a/docs/examples/en/controls/FirstPersonControls.html b/docs/examples/en/controls/FirstPersonControls.html new file mode 100644 index 0000000000000000000000000000000000000000..b1032350e86125b436a16f1b218695a5dcc3767e --- /dev/null +++ b/docs/examples/en/controls/FirstPersonControls.html @@ -0,0 +1,166 @@ + + + + ++ This class is an alternative implementation of [page:FlyControls]. +
+ +[example:webgl_geometry_terrain webgl / geometry / terrain ]
+ ++
+ [page:Camera object]: The camera to be controlled. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Whether or not it's possible to look around. Default is *true*. +
+ ++ Whether or not the camera is automatically moved forward. Default is *false*. +
+ ++ Whether or not looking around is vertically constrained by [[page:.verticalMin], [page:.verticalMax]]. Default is *false*. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Whether or not the controls are enabled. Default is *true*. +
+ ++ Determines how much faster the camera moves when it's y-component is near [page:.heightMax]. Default is *1*. +
+ ++ Upper camera height limit used for movement speed adjusment. Default is *1*. +
+ ++ Lower camera height limit used for movement speed adjusment. Default is *0*. +
+ ++ Whether or not the camera's height influences the forward movement speed. Default is *false*. + Use the properties [page:.heightCoef], [page:.heightMin] and [page:.heightMax] for configuration. +
+ ++ Whether or not it's possible to vertically look around. Default is *true*. +
+ ++ The look around speed. Default is *0.005*. +
+ ++ Whether or not the mouse is pressed down. Read-only property. +
+ ++ The movement speed. Default is *1*. +
+ ++ The camera to be controlled. +
+ ++ How far you can vertically look around, upper limit. Range is 0 to Math.PI radians. Default is *Math.PI*. +
+ ++ How far you can vertically look around, lower limit. Range is 0 to Math.PI radians. Default is *0*. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Should be called if the application window is resized. +
+ ++
+
+ vector - A vector representing the target position. +
++ Optionally, the x, y, z components of the world space position. +
+ ++ Ensures the controls orient the camera towards the defined target position. +
+ + ++
+ [page:Number delta]: Time delta value. +
++ Updates the controls. Usually called in the animation loop. +
+ + ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FirstPersonControls.js examples/js/controls/FirstPersonControls.js] +
+ + diff --git a/docs/examples/en/controls/FlyControls.html b/docs/examples/en/controls/FlyControls.html new file mode 100644 index 0000000000000000000000000000000000000000..06f1631e848d78f451c20c988ff960c1866f967b --- /dev/null +++ b/docs/examples/en/controls/FlyControls.html @@ -0,0 +1,95 @@ + + + + ++ [name] enables a navigation similar to fly modes in DCC tools like Blender. You can arbitrarily transform the camera in + 3D space without any limitations (e.g. focus on a specific target). +
+ +[example:misc_controls_fly misc / controls / fly ]
+ ++
+ [page:Camera object]: The camera to be controlled. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ If set to *true*, the camera automatically moves forward (and does not stop) when initially translated. Default is *false*. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ If set to *true*, you can only look around by performing a drag interaction. Default is *false*. +
+ ++ The movement speed. Default is *1*. +
+ ++ The camera to be controlled. +
+ ++ The rotation speed. Default is *0.005*. +
+ ++ Should be called if the controls is no longer required. +
+ ++
+ [page:Number delta]: Time delta value. +
++ Updates the controls. Usually called in the animation loop. +
+ + ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FlyControls.js examples/js/controls/FlyControls.js] +
+ + diff --git a/docs/examples/en/controls/OrthographicTrackballControls.html b/docs/examples/en/controls/OrthographicTrackballControls.html new file mode 100644 index 0000000000000000000000000000000000000000..1b12f89a2975ed7b6a4b4cc0bce6f65c4218852e --- /dev/null +++ b/docs/examples/en/controls/OrthographicTrackballControls.html @@ -0,0 +1,187 @@ + + + + ++
+ This class is a special version of [page:TrackballControls] which supports orthographic cameras. +
+ + +[example:misc_controls_trackball_orthographic misc / controls / trackball / orthographic ]
+ ++
+ [page:OrthographicCamera camera]: The orthographic camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the camera has been transformed by the controls. +
+ ++ Fires when an interaction (e.g. touch) was initiated. +
+ ++ Fires when an interaction has finished. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Defines the intensity of damping. Only considered if [page:.staticMoving staticMoving] is set to *false*. Default is *0.2*. +
+ ++ Whether or not the controls are enabled. +
+ ++ This array holds keycodes for controlling interactions. +
+ Whether or not panning is disabled. Default is *false*. +
+ ++ Whether or not rolling is disabled. Default is *false*. +
+ ++ Whether or not rotation is disabled. Default is *false*. +
+ ++ Whether or not zooming is disabled. Default is *false*. +
+ ++ The camera being controlled. +
+ ++ The zoom speed. Default is *0.3*. +
+ ++ The rotation speed. Default is *1.0*. +
+ ++ Represents the properties of the screen. Automatically set when [page:.handleResize handleResize]() is called. +
+ Whether or not damping is disabled. Default is *false*. +
+ ++ The zoom speed. Default is *1.2*. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Should be called if the application window is resized. +
+ ++ Performs panning if necessary. Called by [page:.update update](). +
+ ++ Resets the controls to its initial state. +
+ ++ Rotates the camera if necessary. Called by [page:.update update](). +
+ ++ Updates the controls. Usually called in the animation loop. +
+ ++ Performs zooming if necessary. Called by [page:.update update](). +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js examples/js/controls/TrackballControls.js] +
+ + diff --git a/docs/examples/en/controls/PointerLockControls.html b/docs/examples/en/controls/PointerLockControls.html new file mode 100644 index 0000000000000000000000000000000000000000..c36c54e6239f0179ef0d846cb7ffd60c894252fd --- /dev/null +++ b/docs/examples/en/controls/PointerLockControls.html @@ -0,0 +1,149 @@ + + + + ++ The implementation of this class is based on the [link:https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API Pointer Lock API]. + [name] is a perfect choice for first person 3D games. +
+ +[example:misc_controls_pointerlock misc / controls / pointerlock ]
+ +
+var controls = new PointerLockControls( camera );
+
+// add event listener to show/hide a UI (e.g. the game's menu)
+
+controls.addEventListener( 'lock', function () {
+
+ menu.style.display = 'none';
+
+} );
+
+controls.addEventListener( 'unlock', function () {
+
+ menu.style.display = 'block';
+
+} );
+
+
+
+ +
+ [page:Camera camera]: The camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the document's body. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the user moves the mouse. +
+ ++ Fires when the pointer lock status is "locked" (in other words: the mouse is captured). +
+ ++ Fires when the pointer lock status is "unlocked" (in other words: the mouse is not captured anymore). +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the document's body. +
+ + ++ Whether or not the controls are locked. +
+ +See the base [page:EventDispatcher] class for common methods.
+ ++ Adds the event listeners of the controls. +
+ ++ Removes the event listeners of the controls. +
+ ++
+ [page:Vector3 target]: The target vector. +
++ Returns the look direction of the camera. +
+ + ++ Activates the pointer lock. +
+ ++
+ [page:Number distance]: The signed distance. +
++ Moves the camera forward parallel to the xz-plane. Assumes camera.up is y-up. +
+ + ++
+ [page:Number distance]: The signed distance. +
++ Moves the camera sidewards parallel to the xz-plane. +
+ + ++ Exits the pointer lock. +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js examples/js/controls/PointerLockControls.js] +
+ + diff --git a/docs/examples/en/controls/TrackballControls.html b/docs/examples/en/controls/TrackballControls.html new file mode 100644 index 0000000000000000000000000000000000000000..c460af81ef6a7f8d38023d21bc5c8048c117865c --- /dev/null +++ b/docs/examples/en/controls/TrackballControls.html @@ -0,0 +1,211 @@ + + + + ++
+ [name] is similar to [page:OrbitControls]. However, it does not maintain a constant camera [page:Object3D.up up] vector. + That means if the camera orbits over the “north” and “south” poles, it does not flip to stay "right side up". +
++ Notice that [name] can only be used with a perspective camera. Use [page:OrthographicTrackballControls] when working with an orthographic camera. +
+ + +[example:misc_controls_trackball misc / controls / trackball ]
+ ++
+ [page:PerspectiveCamera camera]: The perspective camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the camera has been transformed by the controls. +
+ ++ Fires when an interaction (e.g. touch) was initiated. +
+ ++ Fires when an interaction has finished. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Defines the intensity of damping. Only considered if [page:.staticMoving staticMoving] is set to *false*. Default is *0.2*. +
+ ++ Whether or not the controls are enabled. +
+ ++ This array holds keycodes for controlling interactions. +
+ How far you can zoom in. Default is *Infinity*. +
+ ++ How far you can zoom in. Default is *0*. +
+ ++ This object contains references to the mouse actions used by the controls. +
+ Whether or not panning is disabled. Default is *false*. +
+ ++ Whether or not rotation is disabled. Default is *false*. +
+ ++ Whether or not zooming is disabled. Default is *false*. +
+ ++ The camera being controlled. +
+ ++ The zoom speed. Default is *0.3*. +
+ ++ The rotation speed. Default is *1.0*. +
+ ++ Represents the properties of the screen. Automatically set when [page:.handleResize handleResize]() is called. +
+ Whether or not damping is disabled. Default is *false*. +
+ ++ The zoom speed. Default is *1.2*. +
+ ++ Ensures the controls stay in the range [minDistance, maxDistance]. Called by [page:.update update](). +
+ ++ Should be called if the controls is no longer required. +
+ ++ Should be called if the application window is resized. +
+ ++ Performs panning if necessary. Called by [page:.update update](). +
+ ++ Resets the controls to its initial state. +
+ ++ Rotates the camera if necessary. Called by [page:.update update](). +
+ ++ Updates the controls. Usually called in the animation loop. +
+ ++ Performs zooming if necessary. Called by [page:.update update](). +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js examples/js/controls/TrackballControls.js] +
+ + diff --git a/docs/examples/en/controls/TransformControls.html b/docs/examples/en/controls/TransformControls.html new file mode 100644 index 0000000000000000000000000000000000000000..b4bcc5b253db41c4f7d6b8417736c157d98f8469 --- /dev/null +++ b/docs/examples/en/controls/TransformControls.html @@ -0,0 +1,225 @@ + + + + ++ This class can be used to transform objects in 3D space by adapting a similar interaction model of DCC tools like Blender. + Unlike other controls, it is not intended to transform the scene's camera. +
+ +[example:misc_controls_transform misc / controls / transform ]
+ ++
+ [page:Camera camera]: The camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Fires if any type of change (object or property change) is performed. Property changes + are separate events you can add event listeners to. The event type is "propertyname-changed". +
+ ++ Fires if a pointer (mouse/touch) becomes active. +
+ ++ Fires if a pointer (mouse/touch) is no longer active. +
+ ++ Fires if the controlled 3D object is changed. +
+ +See the base [page:Object3D] class for common properties.
+ ++ The current transformation axis. +
+ ++ The camera of the rendered scene. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Whether or not dragging is currently performed. Read-only property. +
+ ++ Whether or not the controls are enabled. +
+ ++ The current transformation mode. Possible values are "translate", "rotate" and "scale". Default is *translate*. +
+ ++ The 3D object being controlled. +
+ ++ By default, 3D objects are continously rotated. If you set this property to a numeric value (radians), you can define in which + steps the 3D object should be rotated. Deault is *null*. +
+ ++ Whether or not the x-axis helper should be visible. Default is *true*. +
+ ++ Whether or not the y-axis helper should be visible. Default is *true*. +
+ ++ Whether or not the z-axis helper should be visible. Default is *true*. +
+ ++ The size of the helper UI (axes/planes). Default is *1*. +
+ ++ Defines in which coordinate space transformations should be performed. Possible values are "world" and "local". Default is *world*. +
+ ++ By default, 3D objects are continously translated. If you set this property to a numeric value (world units), you can define in which + steps the 3D object should be translated. Deault is *null*. +
+ +See the base [page:Object3D] class for common methods.
+ ++
+ [page:Object3D object]: The 3D object that should be transformed. +
++ Sets the 3D object that should be transformed and ensures the controls UI is visible. +
+ + ++ Removes the current 3D object from the controls and makes the helper UI is invisible. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Returns the transformation mode. +
+ ++
+ [page:String mode]: The transformation mode. +
++ Sets the transformation mode. +
+ + ++
+ [page:Number rotationSnap]: The rotation snap. +
++ Sets the rotation snap. +
+ + ++
+ [page:Number size]: The size of the helper UI. +
++ Sets the size of the helper UI. +
+ + ++
+ [page:String space]: The coordinate space in which transformations are applied. +
++ Sets the coordinate space in which transformations are applied. +
+ + ++
+ [page:Number translationSnap]: The translation snap. +
++ Sets the translation snap. +
+ + ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TransformControls.js examples/js/controls/TransformControls.js] +
+ + diff --git a/docs/examples/zh/controls/DeviceOrientationControls.html b/docs/examples/zh/controls/DeviceOrientationControls.html new file mode 100644 index 0000000000000000000000000000000000000000..34cdd9ea0cb4b892e4dac56202cd7e8e3b0715dd --- /dev/null +++ b/docs/examples/zh/controls/DeviceOrientationControls.html @@ -0,0 +1,89 @@ + + + + ++ Can be used to orient the camera based on the mobile device's orientation. +
+ +[example:misc_controls_deviceorientation misc / controls / deviceorientation ]
+ ++
+ [page:Camera object]: The camera to be controlled. +
++ Creates a new instance of [name]. +
+ + ++ The alpha offset in radians. Default is *0*. +
+ ++ The current *deviceorientation* event object. +
+ ++ Whether or not the controls are enabled. +
+ ++ The camera to be controlled. +
+ ++ The orientation in degrees (in 90-degree increments) of the viewport relative to the device's natural orientation. Default is *0*. +
+ ++ Adds the event listeners of the controls and enables it. +
+ ++ Removes the event listeners of the controls and disables it. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Updates the controls. Usually called in the animation loop. +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DeviceOrientationControls.js examples/js/controls/DeviceOrientationControls.js] +
+ + diff --git a/docs/examples/zh/controls/DragControls.html b/docs/examples/zh/controls/DragControls.html new file mode 100644 index 0000000000000000000000000000000000000000..a22c12445d66accfddb95de347f30e04bd8ae61d --- /dev/null +++ b/docs/examples/zh/controls/DragControls.html @@ -0,0 +1,119 @@ + + + + ++ This class can be used to provide a drag'n'drop interaction. +
+ +[example:misc_controls_drag misc / controls / drag ]
+ +
+var controls = new THREE.DragControls( objects, camera, renderer.domElement );
+
+// add event listener to highlight dragged objects
+
+controls.addEventListener( 'dragstart', function ( event ) {
+
+ event.object.material.emissive.set( 0xaaaaaa );
+
+} );
+
+controls.addEventListener( 'dragend', function ( event ) {
+
+ event.object.material.emissive.set( 0x000000 );
+
+} );
+
+
+
+ +
+ [page:Array objects]: An array of draggable 3D objects. +
++ [page:Camera camera]: The camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: The HTML element used for event listeners. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the user starts to drag a 3D object. +
+ ++ Fires when the user drags a 3D object. +
+ ++ Fires when the user has finished dragging a 3D object. +
+ ++ Fires when the pointer is moved onto a 3D object, or onto one of its children. +
+ ++ Fires when the pointer is moved out of a 3D object. +
+ ++ Whether or not the controls are enabled. +
+ +See the base [page:EventDispatcher] class for common methods.
+ ++ Adds the event listeners of the controls. +
+ ++ Removes the event listeners of the controls. +
+ ++ Should be called if the controls is no longer required. +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DragControls.js examples/js/controls/DragControls.js] +
+ + diff --git a/docs/examples/zh/controls/FirstPersonControls.html b/docs/examples/zh/controls/FirstPersonControls.html new file mode 100644 index 0000000000000000000000000000000000000000..b1032350e86125b436a16f1b218695a5dcc3767e --- /dev/null +++ b/docs/examples/zh/controls/FirstPersonControls.html @@ -0,0 +1,166 @@ + + + + ++ This class is an alternative implementation of [page:FlyControls]. +
+ +[example:webgl_geometry_terrain webgl / geometry / terrain ]
+ ++
+ [page:Camera object]: The camera to be controlled. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Whether or not it's possible to look around. Default is *true*. +
+ ++ Whether or not the camera is automatically moved forward. Default is *false*. +
+ ++ Whether or not looking around is vertically constrained by [[page:.verticalMin], [page:.verticalMax]]. Default is *false*. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Whether or not the controls are enabled. Default is *true*. +
+ ++ Determines how much faster the camera moves when it's y-component is near [page:.heightMax]. Default is *1*. +
+ ++ Upper camera height limit used for movement speed adjusment. Default is *1*. +
+ ++ Lower camera height limit used for movement speed adjusment. Default is *0*. +
+ ++ Whether or not the camera's height influences the forward movement speed. Default is *false*. + Use the properties [page:.heightCoef], [page:.heightMin] and [page:.heightMax] for configuration. +
+ ++ Whether or not it's possible to vertically look around. Default is *true*. +
+ ++ The look around speed. Default is *0.005*. +
+ ++ Whether or not the mouse is pressed down. Read-only property. +
+ ++ The movement speed. Default is *1*. +
+ ++ The camera to be controlled. +
+ ++ How far you can vertically look around, upper limit. Range is 0 to Math.PI radians. Default is *Math.PI*. +
+ ++ How far you can vertically look around, lower limit. Range is 0 to Math.PI radians. Default is *0*. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Should be called if the application window is resized. +
+ ++
+
+ vector - A vector representing the target position. +
++ Optionally, the x, y, z components of the world space position. +
+ ++ Ensures the controls orient the camera towards the defined target position. +
+ + ++
+ [page:Number delta]: Time delta value. +
++ Updates the controls. Usually called in the animation loop. +
+ + ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FirstPersonControls.js examples/js/controls/FirstPersonControls.js] +
+ + diff --git a/docs/examples/zh/controls/FlyControls.html b/docs/examples/zh/controls/FlyControls.html new file mode 100644 index 0000000000000000000000000000000000000000..06f1631e848d78f451c20c988ff960c1866f967b --- /dev/null +++ b/docs/examples/zh/controls/FlyControls.html @@ -0,0 +1,95 @@ + + + + ++ [name] enables a navigation similar to fly modes in DCC tools like Blender. You can arbitrarily transform the camera in + 3D space without any limitations (e.g. focus on a specific target). +
+ +[example:misc_controls_fly misc / controls / fly ]
+ ++
+ [page:Camera object]: The camera to be controlled. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ If set to *true*, the camera automatically moves forward (and does not stop) when initially translated. Default is *false*. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ If set to *true*, you can only look around by performing a drag interaction. Default is *false*. +
+ ++ The movement speed. Default is *1*. +
+ ++ The camera to be controlled. +
+ ++ The rotation speed. Default is *0.005*. +
+ ++ Should be called if the controls is no longer required. +
+ ++
+ [page:Number delta]: Time delta value. +
++ Updates the controls. Usually called in the animation loop. +
+ + ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FlyControls.js examples/js/controls/FlyControls.js] +
+ + diff --git a/docs/examples/zh/controls/OrthographicTrackballControls.html b/docs/examples/zh/controls/OrthographicTrackballControls.html new file mode 100644 index 0000000000000000000000000000000000000000..1b12f89a2975ed7b6a4b4cc0bce6f65c4218852e --- /dev/null +++ b/docs/examples/zh/controls/OrthographicTrackballControls.html @@ -0,0 +1,187 @@ + + + + ++
+ This class is a special version of [page:TrackballControls] which supports orthographic cameras. +
+ + +[example:misc_controls_trackball_orthographic misc / controls / trackball / orthographic ]
+ ++
+ [page:OrthographicCamera camera]: The orthographic camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the camera has been transformed by the controls. +
+ ++ Fires when an interaction (e.g. touch) was initiated. +
+ ++ Fires when an interaction has finished. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Defines the intensity of damping. Only considered if [page:.staticMoving staticMoving] is set to *false*. Default is *0.2*. +
+ ++ Whether or not the controls are enabled. +
+ ++ This array holds keycodes for controlling interactions. +
+ Whether or not panning is disabled. Default is *false*. +
+ ++ Whether or not rolling is disabled. Default is *false*. +
+ ++ Whether or not rotation is disabled. Default is *false*. +
+ ++ Whether or not zooming is disabled. Default is *false*. +
+ ++ The camera being controlled. +
+ ++ The zoom speed. Default is *0.3*. +
+ ++ The rotation speed. Default is *1.0*. +
+ ++ Represents the properties of the screen. Automatically set when [page:.handleResize handleResize]() is called. +
+ Whether or not damping is disabled. Default is *false*. +
+ ++ The zoom speed. Default is *1.2*. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Should be called if the application window is resized. +
+ ++ Performs panning if necessary. Called by [page:.update update](). +
+ ++ Resets the controls to its initial state. +
+ ++ Rotates the camera if necessary. Called by [page:.update update](). +
+ ++ Updates the controls. Usually called in the animation loop. +
+ ++ Performs zooming if necessary. Called by [page:.update update](). +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js examples/js/controls/TrackballControls.js] +
+ + diff --git a/docs/examples/zh/controls/PointerLockControls.html b/docs/examples/zh/controls/PointerLockControls.html new file mode 100644 index 0000000000000000000000000000000000000000..c36c54e6239f0179ef0d846cb7ffd60c894252fd --- /dev/null +++ b/docs/examples/zh/controls/PointerLockControls.html @@ -0,0 +1,149 @@ + + + + ++ The implementation of this class is based on the [link:https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API Pointer Lock API]. + [name] is a perfect choice for first person 3D games. +
+ +[example:misc_controls_pointerlock misc / controls / pointerlock ]
+ +
+var controls = new PointerLockControls( camera );
+
+// add event listener to show/hide a UI (e.g. the game's menu)
+
+controls.addEventListener( 'lock', function () {
+
+ menu.style.display = 'none';
+
+} );
+
+controls.addEventListener( 'unlock', function () {
+
+ menu.style.display = 'block';
+
+} );
+
+
+
+ +
+ [page:Camera camera]: The camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the document's body. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the user moves the mouse. +
+ ++ Fires when the pointer lock status is "locked" (in other words: the mouse is captured). +
+ ++ Fires when the pointer lock status is "unlocked" (in other words: the mouse is not captured anymore). +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the document's body. +
+ + ++ Whether or not the controls are locked. +
+ +See the base [page:EventDispatcher] class for common methods.
+ ++ Adds the event listeners of the controls. +
+ ++ Removes the event listeners of the controls. +
+ ++
+ [page:Vector3 target]: The target vector. +
++ Returns the look direction of the camera. +
+ + ++ Activates the pointer lock. +
+ ++
+ [page:Number distance]: The signed distance. +
++ Moves the camera forward parallel to the xz-plane. Assumes camera.up is y-up. +
+ + ++
+ [page:Number distance]: The signed distance. +
++ Moves the camera sidewards parallel to the xz-plane. +
+ + ++ Exits the pointer lock. +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js examples/js/controls/PointerLockControls.js] +
+ + diff --git a/docs/examples/zh/controls/TrackballControls.html b/docs/examples/zh/controls/TrackballControls.html new file mode 100644 index 0000000000000000000000000000000000000000..c460af81ef6a7f8d38023d21bc5c8048c117865c --- /dev/null +++ b/docs/examples/zh/controls/TrackballControls.html @@ -0,0 +1,211 @@ + + + + ++
+ [name] is similar to [page:OrbitControls]. However, it does not maintain a constant camera [page:Object3D.up up] vector. + That means if the camera orbits over the “north” and “south” poles, it does not flip to stay "right side up". +
++ Notice that [name] can only be used with a perspective camera. Use [page:OrthographicTrackballControls] when working with an orthographic camera. +
+ + +[example:misc_controls_trackball misc / controls / trackball ]
+ ++
+ [page:PerspectiveCamera camera]: The perspective camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Fires when the camera has been transformed by the controls. +
+ ++ Fires when an interaction (e.g. touch) was initiated. +
+ ++ Fires when an interaction has finished. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Defines the intensity of damping. Only considered if [page:.staticMoving staticMoving] is set to *false*. Default is *0.2*. +
+ ++ Whether or not the controls are enabled. +
+ ++ This array holds keycodes for controlling interactions. +
+ How far you can zoom in. Default is *Infinity*. +
+ ++ How far you can zoom in. Default is *0*. +
+ ++ This object contains references to the mouse actions used by the controls. +
+ Whether or not panning is disabled. Default is *false*. +
+ ++ Whether or not rotation is disabled. Default is *false*. +
+ ++ Whether or not zooming is disabled. Default is *false*. +
+ ++ The camera being controlled. +
+ ++ The zoom speed. Default is *0.3*. +
+ ++ The rotation speed. Default is *1.0*. +
+ ++ Represents the properties of the screen. Automatically set when [page:.handleResize handleResize]() is called. +
+ Whether or not damping is disabled. Default is *false*. +
+ ++ The zoom speed. Default is *1.2*. +
+ ++ Ensures the controls stay in the range [minDistance, maxDistance]. Called by [page:.update update](). +
+ ++ Should be called if the controls is no longer required. +
+ ++ Should be called if the application window is resized. +
+ ++ Performs panning if necessary. Called by [page:.update update](). +
+ ++ Resets the controls to its initial state. +
+ ++ Rotates the camera if necessary. Called by [page:.update update](). +
+ ++ Updates the controls. Usually called in the animation loop. +
+ ++ Performs zooming if necessary. Called by [page:.update update](). +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js examples/js/controls/TrackballControls.js] +
+ + diff --git a/docs/examples/zh/controls/TransformControls.html b/docs/examples/zh/controls/TransformControls.html new file mode 100644 index 0000000000000000000000000000000000000000..b4bcc5b253db41c4f7d6b8417736c157d98f8469 --- /dev/null +++ b/docs/examples/zh/controls/TransformControls.html @@ -0,0 +1,225 @@ + + + + ++ This class can be used to transform objects in 3D space by adapting a similar interaction model of DCC tools like Blender. + Unlike other controls, it is not intended to transform the scene's camera. +
+ +[example:misc_controls_transform misc / controls / transform ]
+ ++
+ [page:Camera camera]: The camera of the rendered scene. +
++ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document, + however if you only want the controls to work over a specific element (e.g. the canvas) you can specify that here. +
++ Creates a new instance of [name]. +
+ + ++ Fires if any type of change (object or property change) is performed. Property changes + are separate events you can add event listeners to. The event type is "propertyname-changed". +
+ ++ Fires if a pointer (mouse/touch) becomes active. +
+ ++ Fires if a pointer (mouse/touch) is no longer active. +
+ ++ Fires if the controlled 3D object is changed. +
+ +See the base [page:Object3D] class for common properties.
+ ++ The current transformation axis. +
+ ++ The camera of the rendered scene. +
+ ++ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will + not set up new event listeners. Default is the whole document. +
+ ++ Whether or not dragging is currently performed. Read-only property. +
+ ++ Whether or not the controls are enabled. +
+ ++ The current transformation mode. Possible values are "translate", "rotate" and "scale". Default is *translate*. +
+ ++ The 3D object being controlled. +
+ ++ By default, 3D objects are continously rotated. If you set this property to a numeric value (radians), you can define in which + steps the 3D object should be rotated. Deault is *null*. +
+ ++ Whether or not the x-axis helper should be visible. Default is *true*. +
+ ++ Whether or not the y-axis helper should be visible. Default is *true*. +
+ ++ Whether or not the z-axis helper should be visible. Default is *true*. +
+ ++ The size of the helper UI (axes/planes). Default is *1*. +
+ ++ Defines in which coordinate space transformations should be performed. Possible values are "world" and "local". Default is *world*. +
+ ++ By default, 3D objects are continously translated. If you set this property to a numeric value (world units), you can define in which + steps the 3D object should be translated. Deault is *null*. +
+ +See the base [page:Object3D] class for common methods.
+ ++
+ [page:Object3D object]: The 3D object that should be transformed. +
++ Sets the 3D object that should be transformed and ensures the controls UI is visible. +
+ + ++ Removes the current 3D object from the controls and makes the helper UI is invisible. +
+ ++ Should be called if the controls is no longer required. +
+ ++ Returns the transformation mode. +
+ ++
+ [page:String mode]: The transformation mode. +
++ Sets the transformation mode. +
+ + ++
+ [page:Number rotationSnap]: The rotation snap. +
++ Sets the rotation snap. +
+ + ++
+ [page:Number size]: The size of the helper UI. +
++ Sets the size of the helper UI. +
+ + ++
+ [page:String space]: The coordinate space in which transformations are applied. +
++ Sets the coordinate space in which transformations are applied. +
+ + ++
+ [page:Number translationSnap]: The translation snap. +
++ Sets the translation snap. +
+ + ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TransformControls.js examples/js/controls/TransformControls.js] +
+ + diff --git a/docs/list.js b/docs/list.js index 06a3cc356592dae90623899a2a1bb669f8751e3a..e024da377606716022ceecf23988d61431dbd960 100644 --- a/docs/list.js +++ b/docs/list.js @@ -354,7 +354,15 @@ var list = { }, "Controls": { - "OrbitControls": "examples/en/controls/OrbitControls" + "DeviceOrientationControls": "examples/en/controls/DeviceOrientationControls", + "DragControls": "examples/en/controls/DragControls", + "FirstPersonControls": "examples/en/controls/FirstPersonControls", + "FlyControls": "examples/en/controls/FlyControls", + "OrbitControls": "examples/en/controls/OrbitControls", + "OrthographicTrackballControls": "examples/en/controls/OrthographicTrackballControls", + "PointerLockControls": "examples/en/controls/PointerLockControls", + "TrackballControls": "examples/en/controls/TrackballControls", + "TransformControls": "examples/en/controls/TransformControls" }, "Geometries": { @@ -790,7 +798,15 @@ var list = { }, "控制": { - "OrbitControls": "examples/zh/controls/OrbitControls" + "DeviceOrientationControls": "examples/zh/controls/DeviceOrientationControls", + "DragControls": "examples/zh/controls/DragControls", + "FirstPersonControls": "examples/zh/controls/FirstPersonControls", + "FlyControls": "examples/zh/controls/FlyControls", + "OrbitControls": "examples/zh/controls/OrbitControls", + "OrthographicTrackballControls": "examples/zh/controls/OrthographicTrackballControls", + "PointerLockControls": "examples/zh/controls/PointerLockControls", + "TrackballControls": "examples/zh/controls/TrackballControls", + "TransformControls": "examples/zh/controls/TransformControls" }, "几何体": { diff --git a/editor/index.html b/editor/index.html index 48bd5f0de0965b06f927a3dcffc0c50a046e642c..520d9f5fab3d8939c80edc26377dde6d97d81d31 100644 --- a/editor/index.html +++ b/editor/index.html @@ -7,8 +7,8 @@ - - + + @@ -126,6 +126,7 @@ + diff --git a/editor/js/Menubar.Add.js b/editor/js/Menubar.Add.js index 39439d5e4a8d07e2720bab290c5f61d447ed911f..447c9fcb260bc1546bd12129832dd7cc28917f68 100644 --- a/editor/js/Menubar.Add.js +++ b/editor/js/Menubar.Add.js @@ -85,6 +85,22 @@ Menubar.Add = function ( editor ) { } ); options.add( option ); + // Dodecahedron + + var option = new UI.Row(); + option.setClass( 'option' ); + option.setTextContent( strings.getKey( 'menubar/add/dodecahedron' ) ); + option.onClick( function () { + + var geometry = new THREE.DodecahedronBufferGeometry( 1, 0 ); + var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); + mesh.name = 'Dodecahedron'; + + editor.execute( new AddObjectCommand( editor, mesh ) ); + + } ); + options.add( option ); + // Icosahedron var option = new UI.Row(); @@ -162,7 +178,7 @@ Menubar.Add = function ( editor ) { editor.execute( new AddObjectCommand( editor, mesh ) ); } ); - options.add( option ) + options.add( option ); // Ring diff --git a/editor/js/Sidebar.Geometry.BoxGeometry.js b/editor/js/Sidebar.Geometry.BoxGeometry.js index e158f673099b027ecc431e7b6a14a4bc77dad641..bc93ed6610231eaec9effd3017b49b32272a22ed 100644 --- a/editor/js/Sidebar.Geometry.BoxGeometry.js +++ b/editor/js/Sidebar.Geometry.BoxGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.BoxGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.CircleGeometry.js b/editor/js/Sidebar.Geometry.CircleGeometry.js index ce3a52514d2cc077333dc13ae6e38a27050f48a8..081b98a16730f7396cdb925df5063ad3653e1ac0 100644 --- a/editor/js/Sidebar.Geometry.CircleGeometry.js +++ b/editor/js/Sidebar.Geometry.CircleGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.CircleGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.CylinderGeometry.js b/editor/js/Sidebar.Geometry.CylinderGeometry.js index a4d64b6b47afdeaebb69b79a399506b17b984fc7..8dc208e2f0e023087980eeb3a778939e8f33a762 100644 --- a/editor/js/Sidebar.Geometry.CylinderGeometry.js +++ b/editor/js/Sidebar.Geometry.CylinderGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.CylinderGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.DodecahedronGeometry.js b/editor/js/Sidebar.Geometry.DodecahedronGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..aa19bff668861a15ca6325ad0f7ee77988616d0c --- /dev/null +++ b/editor/js/Sidebar.Geometry.DodecahedronGeometry.js @@ -0,0 +1,49 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +Sidebar.Geometry.DodecahedronGeometry = function ( editor, object ) { + + var strings = editor.strings; + + var container = new UI.Row(); + + var geometry = object.geometry; + var parameters = geometry.parameters; + + // radius + + var radiusRow = new UI.Row(); + var radius = new UI.Number( parameters.radius ).onChange( update ); + + radiusRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/dodecahedron_geometry/radius' ) ).setWidth( '90px' ) ); + radiusRow.add( radius ); + + container.add( radiusRow ); + + // detail + + var detailRow = new UI.Row(); + var detail = new UI.Integer( parameters.detail ).setRange( 0, Infinity ).onChange( update ); + + detailRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/dodecahedron_geometry/detail' ) ).setWidth( '90px' ) ); + detailRow.add( detail ); + + container.add( detailRow ); + + // + + function update() { + + editor.execute( new SetGeometryCommand( editor, object, new THREE[ geometry.type ]( + radius.getValue(), + detail.getValue() + ) ) ); + + } + + return container; + +}; + +Sidebar.Geometry.DodecahedronBufferGeometry = Sidebar.Geometry.DodecahedronGeometry; diff --git a/editor/js/Sidebar.Geometry.ExtrudeGeometry.js b/editor/js/Sidebar.Geometry.ExtrudeGeometry.js index 99f5e9a38f86895592335f864638a158b458c5d2..f43344c86e082b3f205e67b7828e23d0fe82e15a 100644 --- a/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +++ b/editor/js/Sidebar.Geometry.ExtrudeGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.IcosahedronGeometry.js b/editor/js/Sidebar.Geometry.IcosahedronGeometry.js index 8309f5acfc2ae5cec5bdce17818bed11063b8e52..e5f4082a94efb29bd314de119464bb01402f6e12 100644 --- a/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +++ b/editor/js/Sidebar.Geometry.IcosahedronGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.IcosahedronGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; @@ -33,7 +31,6 @@ Sidebar.Geometry.IcosahedronGeometry = function ( editor, object ) { container.add( detailRow ); - // function update() { @@ -43,8 +40,6 @@ Sidebar.Geometry.IcosahedronGeometry = function ( editor, object ) { detail.getValue() ) ) ); - signals.objectChanged.dispatch( object ); - } return container; diff --git a/editor/js/Sidebar.Geometry.LatheGeometry.js b/editor/js/Sidebar.Geometry.LatheGeometry.js index 93dbde8e9a026ce842b0eb65cb3059764f66a9c6..2fd691c7fbf54d6f5da7f1a15f4434258c5b7921 100644 --- a/editor/js/Sidebar.Geometry.LatheGeometry.js +++ b/editor/js/Sidebar.Geometry.LatheGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.LatheGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.OctahedronGeometry.js b/editor/js/Sidebar.Geometry.OctahedronGeometry.js index 16d99f805dae20e128ac8d1284819ec41cdb4b6e..30eab9ed72e9d5411e3eb9ada1bdbc6e05b2e040 100644 --- a/editor/js/Sidebar.Geometry.OctahedronGeometry.js +++ b/editor/js/Sidebar.Geometry.OctahedronGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.OctahedronGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; @@ -43,8 +41,6 @@ Sidebar.Geometry.OctahedronGeometry = function ( editor, object ) { detail.getValue() ) ) ); - signals.objectChanged.dispatch( object ); - } return container; diff --git a/editor/js/Sidebar.Geometry.PlaneGeometry.js b/editor/js/Sidebar.Geometry.PlaneGeometry.js index 0afbd984a59db03d626779268b40e25e3f17cccd..e789a196d3a4ad614bf5514930544b0133b66bca 100644 --- a/editor/js/Sidebar.Geometry.PlaneGeometry.js +++ b/editor/js/Sidebar.Geometry.PlaneGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.PlaneGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.RingGeometry.js b/editor/js/Sidebar.Geometry.RingGeometry.js index f455a9b4ab548bc121e569fb6aeb4c6d99216dac..1bcea461cabb761ddef2fa6671cb6c6d76f16bb8 100644 --- a/editor/js/Sidebar.Geometry.RingGeometry.js +++ b/editor/js/Sidebar.Geometry.RingGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.RingGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.ShapeGeometry.js b/editor/js/Sidebar.Geometry.ShapeGeometry.js index 7c287bbca292ddb9474dd1a01fe50cb1bfdc699b..12b2b8a68e1052a46fb99a34217c996577309cfb 100644 --- a/editor/js/Sidebar.Geometry.ShapeGeometry.js +++ b/editor/js/Sidebar.Geometry.ShapeGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.ShapeGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.SphereGeometry.js b/editor/js/Sidebar.Geometry.SphereGeometry.js index 4baa21cf967cdfe9cad8b8055b79d153d420fa57..d904524a1ffd56caa65c2a532e050fe07d74248a 100644 --- a/editor/js/Sidebar.Geometry.SphereGeometry.js +++ b/editor/js/Sidebar.Geometry.SphereGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.SphereGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.TetrahedronGeometry.js b/editor/js/Sidebar.Geometry.TetrahedronGeometry.js index 51423a79cd96742b96e88f872bcb966e419f21ef..20787c7183e22fde7694c5e5d918da335df10bb8 100644 --- a/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +++ b/editor/js/Sidebar.Geometry.TetrahedronGeometry.js @@ -7,8 +7,6 @@ Sidebar.Geometry.TetrahedronGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; @@ -44,8 +42,6 @@ Sidebar.Geometry.TetrahedronGeometry = function ( editor, object ) { detail.getValue() ) ) ); - signals.objectChanged.dispatch( object ); - } return container; diff --git a/editor/js/Sidebar.Geometry.TorusGeometry.js b/editor/js/Sidebar.Geometry.TorusGeometry.js index ff196cefd10a84989f75bb092a58c894023f8883..d1fd8480fcde284088bbba53f4d18fb58e2b2f92 100644 --- a/editor/js/Sidebar.Geometry.TorusGeometry.js +++ b/editor/js/Sidebar.Geometry.TorusGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.TorusGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.TorusKnotGeometry.js b/editor/js/Sidebar.Geometry.TorusKnotGeometry.js index dfdaf2aa9af1ccd68103216bfcfe8f30129fa60e..d4fbf2d1c92e4c43ae6bce89eafb712085ddb8c8 100644 --- a/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +++ b/editor/js/Sidebar.Geometry.TorusKnotGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.TorusKnotGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Geometry.TubeGeometry.js b/editor/js/Sidebar.Geometry.TubeGeometry.js index 24405fa7ddcfa2899dc769df9192228e7117764a..e04d778e26ae888b6ace27ec7bc2007263a7d89e 100644 --- a/editor/js/Sidebar.Geometry.TubeGeometry.js +++ b/editor/js/Sidebar.Geometry.TubeGeometry.js @@ -6,8 +6,6 @@ Sidebar.Geometry.TubeGeometry = function ( editor, object ) { var strings = editor.strings; - var signals = editor.signals; - var container = new UI.Row(); var geometry = object.geometry; diff --git a/editor/js/Sidebar.Properties.js b/editor/js/Sidebar.Properties.js index 0aed9bd77f3bbf50f7fe9cda386a1a2abc2fdba5..5cf9c3e5b89c7786093bd4213aa5800f849dd90e 100644 --- a/editor/js/Sidebar.Properties.js +++ b/editor/js/Sidebar.Properties.js @@ -9,9 +9,9 @@ Sidebar.Properties = function ( editor ) { var container = new UI.TabbedPanel(); container.setId( 'properties' ); - container.addPanel( 'object', strings.getKey( 'sidebar/properties/object' ), new Sidebar.Object( editor ) ); - container.addPanel( 'geometry', strings.getKey( 'sidebar/properties/geometry' ), new Sidebar.Geometry( editor ) ); - container.addPanel( 'material', strings.getKey( 'sidebar/properties/material' ), new Sidebar.Material( editor ) ); + container.addTab( 'object', strings.getKey( 'sidebar/properties/object' ), new Sidebar.Object( editor ) ); + container.addTab( 'geometry', strings.getKey( 'sidebar/properties/geometry' ), new Sidebar.Geometry( editor ) ); + container.addTab( 'material', strings.getKey( 'sidebar/properties/material' ), new Sidebar.Material( editor ) ); return container; diff --git a/editor/js/Sidebar.js b/editor/js/Sidebar.js index 129a2eaf89aced4193d9edad3e9f6dcb0f36620c..e3d3e9023f083e9178e29da71a3d9559a1c22f25 100644 --- a/editor/js/Sidebar.js +++ b/editor/js/Sidebar.js @@ -21,9 +21,9 @@ var Sidebar = function ( editor ) { new Sidebar.History( editor ) ); - container.addPanel( 'scene', strings.getKey( 'sidebar/scene' ), scene ); - container.addPanel( 'project', strings.getKey( 'sidebar/project' ), new Sidebar.Project( editor ) ); - container.addPanel( 'settings', strings.getKey( 'sidebar/settings' ), settings ); + container.addTab( 'scene', strings.getKey( 'sidebar/scene' ), scene ); + container.addTab( 'project', strings.getKey( 'sidebar/project' ), new Sidebar.Project( editor ) ); + container.addTab( 'settings', strings.getKey( 'sidebar/settings' ), settings ); return container; diff --git a/editor/js/Strings.js b/editor/js/Strings.js index 3c05ce0eff504777df5eb46075fd1871ff098899..975db9132627bd8a37d98e73a44154c8608e8efe 100644 --- a/editor/js/Strings.js +++ b/editor/js/Strings.js @@ -41,6 +41,7 @@ var Strings = function ( config ) { 'menubar/add/cylinder': 'Cylinder', 'menubar/add/ring': 'Ring', 'menubar/add/sphere': 'Sphere', + 'menubar/add/dodecahedron': 'Dodecahedron', 'menubar/add/icosahedron': 'Icosahedron', 'menubar/add/octahedron': 'Octahedron', 'menubar/add/tetrahedron': 'Tetrahedron', @@ -148,6 +149,9 @@ var Strings = function ( config ) { 'sidebar/geometry/geometry/vertices': 'Vertices', 'sidebar/geometry/geometry/faces': 'Faces', + 'sidebar/geometry/dodecahedron_geometry/radius': 'Radius', + 'sidebar/geometry/dodecahedron_geometry/detail': 'Detail', + 'sidebar/geometry/icosahedron_geometry/radius': 'Radius', 'sidebar/geometry/icosahedron_geometry/detail': 'Detail', @@ -338,6 +342,7 @@ var Strings = function ( config ) { 'menubar/add/cylinder': '圆柱体', 'menubar/add/ring': '环', 'menubar/add/sphere': '球体', + 'menubar/add/dodecahedron': 'Dodecahedron', 'menubar/add/icosahedron': '二十面体', 'menubar/add/octahedron': '八面体', 'menubar/add/tetrahedron': '四面体', @@ -435,6 +440,9 @@ var Strings = function ( config ) { 'sidebar/geometry/geometry/vertices': '顶点', 'sidebar/geometry/geometry/faces': '面', + 'sidebar/geometry/dodecahedron_geometry/radius': '半径', + 'sidebar/geometry/dodecahedron_geometry/detail': '面片分段', + 'sidebar/geometry/icosahedron_geometry/radius': '半径', 'sidebar/geometry/icosahedron_geometry/detail': '面片分段', diff --git a/editor/js/libs/ui.js b/editor/js/libs/ui.js index 2a7c2e38d7c5aa652135812a884fcfa851085fbf..17a2d8d8fc84e0f1c9f61d87f0432309298e3b3b 100644 --- a/editor/js/libs/ui.js +++ b/editor/js/libs/ui.js @@ -1098,7 +1098,7 @@ UI.TabbedPanel.prototype.select = function ( id ) { } -UI.TabbedPanel.prototype.addPanel = function ( id, label, items ) { +UI.TabbedPanel.prototype.addTab = function ( id, label, items ) { var tab = new UI.TabbedPanel.Tab( label, this ); tab.setId( id ); diff --git a/examples/files.js b/examples/files.js index 5af31eb9b3b73d8a32373443e1068dd538ca5577..c82359328113065bfe8a92cd8a609d6e94532623 100644 --- a/examples/files.js +++ b/examples/files.js @@ -52,7 +52,6 @@ var files = { "webgl_interactive_cubes_gpu", "webgl_interactive_instances_gpu", "webgl_interactive_cubes_ortho", - "webgl_interactive_draggablecubes", "webgl_interactive_lines", "webgl_interactive_points", "webgl_interactive_raycasting_points", @@ -338,6 +337,7 @@ var files = { "webvr_cubes", "webvr_dragging", "webvr_lorenzattractor", + "webvr_multiview", "webvr_panorama", "webvr_paint", "webvr_rollercoaster", @@ -360,6 +360,7 @@ var files = { "misc_animation_keys", "misc_boxselection", "misc_controls_deviceorientation", + "misc_controls_drag", "misc_controls_fly", "misc_controls_map", "misc_controls_orbit", diff --git a/examples/js/controls/FirstPersonControls.js b/examples/js/controls/FirstPersonControls.js index 34c255109891346efd4dfbfbacd5c25074e54a1b..b3332b1f17b9d50fa6b9d502025864c8d228e154 100644 --- a/examples/js/controls/FirstPersonControls.js +++ b/examples/js/controls/FirstPersonControls.js @@ -10,6 +10,8 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.domElement = ( domElement !== undefined ) ? domElement : document; + // API + this.enabled = true; this.movementSpeed = 1.0; @@ -29,6 +31,10 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.verticalMin = 0; this.verticalMax = Math.PI; + this.mouseDragOn = false; + + // internals + this.autoSpeedFactor = 0.0; this.mouseX = 0; @@ -39,8 +45,6 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.moveLeft = false; this.moveRight = false; - this.mouseDragOn = false; - this.viewHalfX = 0; this.viewHalfY = 0; diff --git a/examples/js/controls/OrthographicTrackballControls.js b/examples/js/controls/OrthographicTrackballControls.js index 1d5e4f909e95943639029fc5f42e2e1d46f8b235..156a6b4202ee3b2469539ccb48b9aca169343889 100644 --- a/examples/js/controls/OrthographicTrackballControls.js +++ b/examples/js/controls/OrthographicTrackballControls.js @@ -19,8 +19,6 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { this.screen = { left: 0, top: 0, width: 0, height: 0 }; - this.radius = 0; - this.rotateSpeed = 1.0; this.zoomSpeed = 1.2; @@ -36,6 +34,8 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { // internals + this.radius = 0; + this.target = new THREE.Vector3(); var EPS = 0.000001; diff --git a/examples/js/controls/PointerLockControls.js b/examples/js/controls/PointerLockControls.js index 38d9e02d6c68ae2761f58c54436a6f51d1f6d74a..6ba64529788d8e4ee7af06755c2aaf653b08a61d 100644 --- a/examples/js/controls/PointerLockControls.js +++ b/examples/js/controls/PointerLockControls.js @@ -22,7 +22,7 @@ THREE.PointerLockControls = function ( camera, domElement ) { var PI_2 = Math.PI / 2; - var vec = new Vector3(); + var vec = new THREE.Vector3(); function onMouseMove( event ) { diff --git a/examples/js/postprocessing/OutlinePass.js b/examples/js/postprocessing/OutlinePass.js index 8c9fd452c7de3727ff2bc6a4f7b960a6acc36cad..84d93a730a0780a67b59aa4948ce6aa5c92aa33d 100644 --- a/examples/js/postprocessing/OutlinePass.js +++ b/examples/js/postprocessing/OutlinePass.js @@ -510,18 +510,18 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype void main() {\ vec2 invSize = 1.0 / texSize;\ float weightSum = gaussianPdf(0.0, kernelRadius);\ - vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\ + vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\ vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\ vec2 uvOffset = delta;\ for( int i = 1; i <= MAX_RADIUS; i ++ ) {\ float w = gaussianPdf(uvOffset.x, kernelRadius);\ - vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\ - vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\ + vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\ + vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\ diffuseSum += ((sample1 + sample2) * w);\ weightSum += (2.0 * w);\ uvOffset += delta;\ }\ - gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\ + gl_FragColor = diffuseSum/weightSum;\ }" } ); diff --git a/examples/jsm/controls/DeviceOrientationControls.d.ts b/examples/jsm/controls/DeviceOrientationControls.d.ts index 17b5c9d18062eb83a368be9246181ea4be5f3a6e..56a855bff19f630edd89d40f130022b93e950a4a 100644 --- a/examples/jsm/controls/DeviceOrientationControls.d.ts +++ b/examples/jsm/controls/DeviceOrientationControls.d.ts @@ -1,6 +1,5 @@ import { - Camera, - Vector3 + Camera } from '../../../src/Three'; export class DeviceOrientationControls { @@ -14,7 +13,6 @@ export class DeviceOrientationControls { deviceOrientation: any; enabled: boolean; screenOrientation: number; - target: Vector3; connect(): void; disconnect(): void; diff --git a/examples/jsm/controls/FirstPersonControls.d.ts b/examples/jsm/controls/FirstPersonControls.d.ts index 31b6e4d239826e9a2be8e3e10f8113a4d1bd339c..7ad6791711ef807582f594e952af699c1f7e7970 100644 --- a/examples/jsm/controls/FirstPersonControls.d.ts +++ b/examples/jsm/controls/FirstPersonControls.d.ts @@ -22,7 +22,7 @@ export class FirstPersonControls { constrainVertical: boolean; verticalMin: number; verticalMax: number; - autoSpeedFactor: number; + mouseDragOn: boolean; handleResize(): void; lookAt(x: number | Vector3, y: number, z: number): this; diff --git a/examples/jsm/controls/FirstPersonControls.js b/examples/jsm/controls/FirstPersonControls.js index 772fc5b198906e21a47de664d152869336d74ab4..fd1449bb9c14732c4ba02040150fa47188244638 100644 --- a/examples/jsm/controls/FirstPersonControls.js +++ b/examples/jsm/controls/FirstPersonControls.js @@ -16,6 +16,8 @@ var FirstPersonControls = function ( object, domElement ) { this.domElement = ( domElement !== undefined ) ? domElement : document; + // API + this.enabled = true; this.movementSpeed = 1.0; @@ -35,11 +37,6 @@ var FirstPersonControls = function ( object, domElement ) { this.verticalMin = 0; this.verticalMax = Math.PI; - this.autoSpeedFactor = 0.0; - - this.mouseX = 0; - this.mouseY = 0; - this.moveForward = false; this.moveBackward = false; this.moveLeft = false; @@ -47,6 +44,13 @@ var FirstPersonControls = function ( object, domElement ) { this.mouseDragOn = false; + // internals + + this.autoSpeedFactor = 0.0; + + this.mouseX = 0; + this.mouseY = 0; + this.viewHalfX = 0; this.viewHalfY = 0; diff --git a/examples/jsm/controls/OrthographicTrackballControls.d.ts b/examples/jsm/controls/OrthographicTrackballControls.d.ts index f647a3f0971fd1815775c565078f3d5e7d3f9354..ffa937386d1cd751b09e9a5379456eb4c93599fa 100644 --- a/examples/jsm/controls/OrthographicTrackballControls.d.ts +++ b/examples/jsm/controls/OrthographicTrackballControls.d.ts @@ -8,7 +8,6 @@ export class OrthographicTrackballControls extends EventDispatcher { enabled: boolean; screen: {left: number; top: number; width: number; height: number}; - radius: number; rotateSpeed: number; zoomSpeed: number; noRotate: boolean; diff --git a/examples/jsm/controls/OrthographicTrackballControls.js b/examples/jsm/controls/OrthographicTrackballControls.js index 0c49d9453ef556d73f238cf06a32805564b22492..60734eb709ff6cbedf5834580c7451121f85b5f4 100644 --- a/examples/jsm/controls/OrthographicTrackballControls.js +++ b/examples/jsm/controls/OrthographicTrackballControls.js @@ -26,8 +26,6 @@ var OrthographicTrackballControls = function ( object, domElement ) { this.screen = { left: 0, top: 0, width: 0, height: 0 }; - this.radius = 0; - this.rotateSpeed = 1.0; this.zoomSpeed = 1.2; @@ -43,6 +41,8 @@ var OrthographicTrackballControls = function ( object, domElement ) { // internals + this.radius = 0; + this.target = new Vector3(); var EPS = 0.000001; diff --git a/examples/jsm/controls/PointerLockControls.d.ts b/examples/jsm/controls/PointerLockControls.d.ts index 64b419220f15fca2cc7b2fd6c9a3a3fc19d73c03..bf57c1840c518c72c714f32f41947c6b875cc440 100644 --- a/examples/jsm/controls/PointerLockControls.d.ts +++ b/examples/jsm/controls/PointerLockControls.d.ts @@ -8,7 +8,6 @@ export class PointerLockControls extends EventDispatcher { constructor(camera: Camera, domElement?: HTMLElement); domElement: HTMLElement; - object: Camera; // API @@ -19,6 +18,8 @@ export class PointerLockControls extends EventDispatcher { dispose(): void; getObject(): Camera; getDirection(v: Vector3): Vector3; + moveForward(distance: number): void; + moveRight(distance: number): void; lock(): void; unlock(): void; diff --git a/examples/jsm/controls/TrackballControls.d.ts b/examples/jsm/controls/TrackballControls.d.ts index 46ea05898eeecd0333a426e6d1553120d4357b6a..01b33d424d6708a65336f60753ef54e9b34257b7 100644 --- a/examples/jsm/controls/TrackballControls.d.ts +++ b/examples/jsm/controls/TrackballControls.d.ts @@ -42,6 +42,4 @@ export class TrackballControls extends EventDispatcher { rotateCamera(): void; handleResize(): void; - - handleEvent(event: any): void; } diff --git a/examples/jsm/controls/TransformControls.d.ts b/examples/jsm/controls/TransformControls.d.ts index d03c2e27f52afaf3273442a36d7b718aac374e6c..2aa9d237a450760c71914b9aa3d8b7e8e64b0291 100644 --- a/examples/jsm/controls/TransformControls.d.ts +++ b/examples/jsm/controls/TransformControls.d.ts @@ -14,12 +14,12 @@ export class TransformControls extends Object3D { // API camera: Camera; - object: Object3D; + object: Object3D | undefined; enabled: boolean; - axis: string; + axis: string | null; mode: string; - translationSnap: Vector3; - rotationSnap: Vector3; + translationSnap: number | null; + rotationSnap: number | null; space: string; size: number; dragging: boolean; @@ -27,19 +27,14 @@ export class TransformControls extends Object3D { showY: boolean; showZ: boolean; isTransformControls: boolean; - visible: boolean; mouseButtons: { - LEFT: MOUSE; + LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE; }; attach(object: Object3D): this; detach(): this; - pointerHover(pointer: Object): void; - pointerDown(pointer: Object): void; - pointerMove(pointer: Object): void; - pointerUp(pointer: Object): void; getMode(): string; setMode(mode: string): void; setTranslationSnap(translationSnap: Number | null): void; @@ -47,6 +42,5 @@ export class TransformControls extends Object3D { setSize(size: number): void; setSpace(space: string): void; dispose(): void; - update(): void; } diff --git a/examples/jsm/loaders/MMDLoader.d.ts b/examples/jsm/loaders/MMDLoader.d.ts index 70de07275d2b4df62222015ec399fc373f67ab66..c77056dbec0c38149e65a83cda1449f2a19a12a9 100644 --- a/examples/jsm/loaders/MMDLoader.d.ts +++ b/examples/jsm/loaders/MMDLoader.d.ts @@ -20,11 +20,11 @@ export class MMDLoader extends Loader { parser: object | null; load(url: string, onLoad: (mesh: SkinnedMesh) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; - loadAnimation(url: string, onLoad: (object: SkinnedMesh | AnimationClip) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; + loadAnimation(url: string, object: SkinnedMesh | THREE.Camera, onLoad: (object: SkinnedMesh | AnimationClip) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; loadPMD(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; loadPMX(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; loadVMD(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; - loadVPD(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; + loadVPD(url: string, isUnicode: boolean, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; loadWithAnimation(url: string, vmdUrl: string | string[], onLoad: (object: MMDLoaderAnimationObject) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; setAnimationPath(animationPath: string): this; } diff --git a/examples/jsm/loaders/VTKLoader.d.ts b/examples/jsm/loaders/VTKLoader.d.ts index c7c411d822f8a334e472eac803f0ef0f6e535fa5..7b72ffaa8bd22f5882a06a4a532adf35e38b17b3 100644 --- a/examples/jsm/loaders/VTKLoader.d.ts +++ b/examples/jsm/loaders/VTKLoader.d.ts @@ -4,7 +4,7 @@ import { LoadingManager } from '../../../src/Three'; -export class VRMLLoader extends Loader { +export class VTKLoader extends Loader { constructor(manager?: LoadingManager); load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; diff --git a/examples/jsm/loaders/obj2/utils/CodeSerializer.js b/examples/jsm/loaders/obj2/utils/CodeSerializer.js index a8c484a3385b2c472c44f44498597a3a58b52ae7..8b9ccf73336d03036a4b70880f98a3da60542e1d 100644 --- a/examples/jsm/loaders/obj2/utils/CodeSerializer.js +++ b/examples/jsm/loaders/obj2/utils/CodeSerializer.js @@ -21,8 +21,8 @@ const CodeSerializer = { part = serializationTarget[ name ]; if ( typeof ( part ) === 'string' || part instanceof String ) { - part = part.replace( '\n', '\\n' ); - part = part.replace( '\r', '\\r' ); + part = part.replace( /\n/g, '\\n' ); + part = part.replace( /\r/g, '\\r' ); objectString += '\t' + name + ': "' + part + '",\n'; } else if ( part instanceof Array ) { @@ -31,7 +31,7 @@ const CodeSerializer = { } else if ( typeof part === 'object' ) { - console.log( 'Omitting object "' + name + '" and replace it with empty object.'); + console.log( 'Omitting object "' + name + '" and replace it with empty object.' ); objectString += '\t' + name + ': {},\n'; } else { @@ -75,7 +75,7 @@ const CodeSerializer = { if ( name === 'constructor' ) { - if ( !funcInstructions.isRemoveCode() ) { + if ( ! funcInstructions.isRemoveCode() ) { constructorString = fullObjectName + ' = ' + funcInstructions.getCode() + ';\n\n'; @@ -89,7 +89,7 @@ const CodeSerializer = { funcInstructions = funcTemp; } - if ( !funcInstructions.isRemoveCode() ) { + if ( ! funcInstructions.isRemoveCode() ) { if ( isExtended ) { @@ -136,7 +136,7 @@ const CodeSerializer = { } else if ( typeof objectPart === 'object' ) { - console.log( 'Omitting object "' + funcInstructions.getName() + '" and replace it with empty object.'); + console.log( 'Omitting object "' + funcInstructions.getName() + '" and replace it with empty object.' ); funcInstructions.setCode( "{}" ); } else { @@ -257,7 +257,7 @@ CodeSerializationInstruction.prototype = { * Returns the serialized function code * @return {String} */ - getCode: function() { + getCode: function () { return this.code; diff --git a/examples/jsm/postprocessing/OutlinePass.js b/examples/jsm/postprocessing/OutlinePass.js index e5515e73a479e84d9c993b167ff4de9cd7159db4..7f909b5195e34d1a32994509ece1b6d369278c23 100644 --- a/examples/jsm/postprocessing/OutlinePass.js +++ b/examples/jsm/postprocessing/OutlinePass.js @@ -530,18 +530,18 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), { void main() {\ vec2 invSize = 1.0 / texSize;\ float weightSum = gaussianPdf(0.0, kernelRadius);\ - vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\ + vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\ vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\ vec2 uvOffset = delta;\ for( int i = 1; i <= MAX_RADIUS; i ++ ) {\ float w = gaussianPdf(uvOffset.x, kernelRadius);\ - vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\ - vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\ + vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\ + vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\ diffuseSum += ((sample1 + sample2) * w);\ weightSum += (2.0 * w);\ uvOffset += delta;\ }\ - gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\ + gl_FragColor = diffuseSum/weightSum;\ }" } ); diff --git a/examples/jsm/renderers/WebGLDeferredRenderer.d.ts b/examples/jsm/renderers/WebGLDeferredRenderer.d.ts index 8f6b68800f559015fd6c60eb73dc224a4fe69ae6..76b5463e7266ef0de49dab12c1fe64154cf03cea 100644 --- a/examples/jsm/renderers/WebGLDeferredRenderer.d.ts +++ b/examples/jsm/renderers/WebGLDeferredRenderer.d.ts @@ -8,9 +8,9 @@ import { export interface WebGLDeferredRendererParameters { antialias?: boolean; cacheKeepAlive?: boolean; - height?: Vector2; + height?: number; renderer?: WebGLRenderer; - width?: Vector2; + width?: number; } export class WebGLDeferredRenderer { diff --git a/examples/webgl_interactive_draggablecubes.html b/examples/misc_controls_drag.html similarity index 78% rename from examples/webgl_interactive_draggablecubes.html rename to examples/misc_controls_drag.html index 3d3aa6380b5438a492cd83df78d47a0376315107..f11a947ce1b78d1ef17dc647cc5ff4ec53f939ca 100644 --- a/examples/webgl_interactive_draggablecubes.html +++ b/examples/misc_controls_drag.html @@ -1,7 +1,7 @@ -