未验证 提交 067a9301 编写于 作者: T Temdog007 提交者: GitHub

Merge pull request #6 from mrdoob/dev

Update
......@@ -19,7 +19,7 @@ Please also include a live example if possible. You can start from these templat
##### Three.js version
- [ ] Dev
- [ ] r102
- [ ] r103
- [ ] ...
##### Browser
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -229,6 +229,8 @@
recursive -- if true, descendants of the object are also copied. Default is true.<br /><br />
Copy the given object into this object.
Note: event listeners and user-defined callbacks ([page:.onAfterRender] and [page:.onBeforeRender]) are not copied.
</p>
<h3>[method:Object3D getObjectById]( [param:Integer id] )</h3>
......
......@@ -95,7 +95,7 @@
<h3>[method:null raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
<p>
Get intersections between a casted ray and this mesh.
[page:Raycaster.intersectObject] will call this method.
[page:Raycaster.intersectObject] will call this method, but the results are not ordered.
</p>
<h3>[method:null updateMorphTargets]()</h3>
......
......@@ -279,13 +279,6 @@
<h2>Methods</h2>
<h3>[method:Integer allocTextureUnit]</h3>
<p>
Attempt to allocate a texture unit for use by a shader. Will warn if trying to allocate
more texture units than the GPU supports. This is mainly used internally.
See [page:WebGLRenderer.capabilities capabilities.maxTextures].
</p>
<h3>[method:null clear]( [param:Boolean color], [param:Boolean depth], [param:Boolean stencil] )</h3>
<p>
Tells the renderer to clear its color, depth or stencil drawing buffer(s).
......@@ -346,7 +339,7 @@
<p>Returns an object that describes the attributes set on the WebGL context when it was created.</p>
<h3>[method:RenderTarget getRenderTarget]()</h3>
<p>Returns the current RenderTarget, if any.</p>
<p>Returns the current [page:RenderTarget RenderTarget] if there are; returns *null* otherwise.</p>
<h3>[method:Vector4 getCurrentViewport]( [param:Vector4 target] )</h3>
<p>
......@@ -436,10 +429,10 @@
<h3>[method:null setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipMapLevel] )</h3>
<p>
renderTarget -- The [page:WebGLRenderTarget renderTarget] that needs to be activated (optional).<br />
renderTarget -- The [page:WebGLRenderTarget renderTarget] that needs to be activated. When *null* is given, the canvas is set as the active render target instead.<br />
activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLRenderTargetCube] (optional).<br />
activeMipMapLevel -- Specifies the active mipmap level (optional).<br /><br />
This method sets the active rendertarget. If the parameter is omitted the canvas is set as the active rendertarget.
This method sets the active rendertarget.
</p>
<h3>[method:null setScissor]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
......@@ -466,26 +459,6 @@
Setting [page:Boolean updateStyle] to false prevents any style changes to the output canvas.
</p>
<h3>[method:null setTexture2D]( [param:Texture texture], [param:number slot] )</h3>
<p>
texture -- The [page:Texture texture] that needs to be set.<br />
slot -- The number indicating which slot should be used by the texture.<br /><br />
This method sets the correct texture to the correct slot for the WebGL shader.
The slot number can be found as a value of the uniform of the sampler.<br /><br />
Note: This method replaces the older [method:null setTexture] method.
</p>
<h3>[method:null setTextureCube]( [param:CubeTexture cubeTexture], [param:Number slot] )</h3>
<p>
texture -- The [page:CubeTexture cubeTexture] that needs to be set.<br />
slot -- The number indicating which slot should be used by the texture.<br /><br />
This method sets the correct texture to the correct slot for the WebGL shader.
The slot number can be found as a value of the uniform of the sampler.
</p>
<h3>[method:null setViewport]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
[method:null setViewport]( [param:Vector4 vector] )</h3>
......
......@@ -91,7 +91,7 @@
<h3>[method:null raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
<p>
在一条投射出去的[page:Ray](射线)和这个网格之间产生交互。
[page:Raycaster.intersectObject]将会调用这个方法
[page:Raycaster.intersectObject]将会调用这个方法但是这个结果是未排序的
</p>
<h3>[method:null updateMorphTargets]()</h3>
......
......@@ -254,12 +254,6 @@
<h2>方法</h2>
<h3>[method:Integer allocTextureUnit]</h3>
<p>
尝试分配纹理单元以供着色器使用。如果尝试分配超过GPU支持量的纹理单元,则会报警告。主要供内部使用。
请参阅[page:WebGLRenderer.capabilities capabilities.maxTextures]。
</p>
<h3>[method:null clear]( [param:Boolean color], [param:Boolean depth], [param:Boolean stencil] )</h3>
<p>
告诉渲染器清除颜色、深度或模板缓存.
......@@ -412,23 +406,6 @@
将[page:Boolean updateStyle]设置为false以阻止对canvas的样式做任何改变。
</p>
<h3>[method:null setTexture2D]( [param:Texture texture], [param:number slot] )</h3>
<p>
texture -- 需被设置的[page:Texture texture]<br />
slot -- 纹理应该使用的插槽号<br /><br />
该方法为WebGL着色器将正确的纹理设置到正确的插槽中。插槽号可作为取样器的全局变量(uniform)<br /><br />
说明: 该方法取代了旧的[method:null setTexture]方法
</p>
<h3>[method:null setTextureCube]( [param:CubeTexture cubeTexture], [param:Number slot] )</h3>
<p>
texture -- 需要被设置的[page:CubeTexture cubeTexture]<br />
slot -- 纹理应该使用的插槽号<br /><br />
该方法为WebGL着色器将正确的纹理设置到正确的插槽中。插槽号可作为取样器的全局变量(uniform)
</p>
<h3>[method:null setViewport]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )</h3>
<p>将视口大小设置为(x, y)到 (x + width, y + height).</p>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
<p class="desc">
A loader for geometry compressed with the Draco library. <br /><br />
[link:https://google.github.io/draco/ Draco] is an open source library for compressing and
decompressing 3D meshes and point clouds. Compressed geometry can be significantly smaller,
at the cost of additional decoding time on the client device.
</p>
<p>
Standalone Draco files have a <em>.drc</em> extension, and contain vertex positions,
normals, colors, and other attributes. Draco files <em>do not</em> contain materials,
textures, animation, or node hierarchies – to use these features, embed Draco geometry
inside of a glTF file. A normal glTF file can be converted to a Draco-compressed glTF file
using [link:https://github.com/AnalyticalGraphicsInc/gltf-pipeline glTF-Pipeline]. When
using Draco with glTF, an instance of DRACOLoader will be used internally by [page:GLTFLoader].
</p>
<h2>Example</h2>
<code>
// Instantiate a loader
var loader = new THREE.DRACOLoader();
// Specify path to a folder containing WASM/JS decoding libraries.
THREE.DRACOLoader.setDecoderPath( '/examples/js/libs/draco' );
// Optional: Pre-fetch Draco WASM/JS module.
THREE.DRACOLoader.getDecoderModule();
// Load a Draco geometry
loader.load(
// resource URL
'model.drc',
// called when the resource is loaded
function ( geometry ) {
var material = new THREE.MeshStandardMaterial( { color: 0x606060 } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
},
// called as loading progresses
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened' );
}
);
</code>
[example:webgl_loader_draco]
<h2>Browser compatibility</h2>
<p>DRACOLoader relies on ES6 [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promises],
which are not supported in IE11. To use the loader in IE11, you must
[link:https://github.com/stefanpenner/es6-promise include a polyfill]
providing a Promise replacement. DRACOLoader will automatically use
either the JS or the WASM decoding library, based on browser
capabilities.</p>
<br>
<hr>
<h2>Constructor</h2>
<h3>[name]( [param:LoadingManager manager] )</h3>
<p>
[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
</p>
<p>
Creates a new [name].
</p>
<h2>Static Methods</h2>
<h3>[method:null setDecoderPath]( [param:String value] )</h3>
<p>
[page:String value] — Path to folder containing the JS and WASM decoder libraries.
</p>
<h3>[method:null setDecoderConfig]( [param:Object config] )</h3>
<p>
[page:String config.type] - (Optional) <em>"js"</em> or <em>"wasm"</em>.<br />
</p>
<p>
Provides configuration for the decoder libraries. Configuration cannot be changed
after loading the decoders.
</p>
<h3>[method:Promise getDecoderModule]()</h3>
<p>
Requests the decoder libraries, if not already loaded.
</p>
<h3>[method:null releaseDecoderModule]()</h3>
<p>
Disposes of the decoder library and deallocates memory. The decoder
[link:https://github.com/google/draco/issues/349 cannot be reloaded afterward].
</p>
<h2>Methods</h2>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
[page:String url] — A string containing the path/URL of the <em>.drc</em> file.<br />
[page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
[page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
</p>
<p>
Begin loading from url and call the <em>onLoad</em> function with the decompressed geometry.
</p>
<h3>[method:DRACOLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Set the base path for the <em>.drc</em> file.
</p>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DRACOLoader.js examples/js/loaders/DRACOLoader.js]
</body>
</html>
......@@ -52,7 +52,7 @@
<h2>Methods</h2>
<h3>[method:Object3D parse]( {[param:arraybuffer content]|[param:String content]] )</h3>
<h3>[method:Object3D parse]( [param:arraybuffer content]|[param:String content] )</h3>
<p>
[[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String
</p>
......
......@@ -26,8 +26,9 @@
// resource URL
'data/svgSample.svg',
// called when the resource is loaded
function ( paths ) {
function ( data ) {
var paths = data.paths;
var group = new THREE.Group();
for ( var i = 0; i < paths.length; i ++ ) {
......
......@@ -44,13 +44,12 @@ light.add( lensflare );
<h2>Constructor</h2>
<h3>LensflareElement( [param:Texture texture], [param:Float size], [param:Float distance], [param:Color color], [param:Materials blending] )</h3>
<h3>LensflareElement( [param:Texture texture], [param:Float size], [param:Float distance], [param:Color color] )</h3>
<p>
[page:Texture texture] - THREE.Texture to use for the flare. <br />
[page:Float size] - (optional) size in pixels <br />
[page:Float distance] - (optional) (0-1) from light source (0 = at light source) <br />
[page:Color color] - (optional) the [page:Color] of the lens flare<br />
[page:Materials blending] - (optional) [page:Materials Blending Mode] - Defaults to THREE.NormalBlending
[page:Color color] - (optional) the [page:Color] of the lens flare
</p>
<h2>Properties</h2>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p class="desc">Utility functions for [page:Skeleton], [page:SkinnedMesh], and [page:Bone] manipulation.</p>
<h2>Methods</h2>
<h3>[method:Object3D clone]( [param:Object3D object] )</h3>
<p>
Clones the given object and its descendants, ensuring that any [page:SkinnedMesh] instances
are correctly associated with their bones. Bones are also cloned, and must be descendants of
the object passed to this method. Other data, like geometries and materials, are reused by
reference.
</p>
<h3>[method:Object findBoneTrackData]( [param:String name], [param:Array tracks] )</h3>
<p></p>
<h3>[method:Bone getBoneByName]( [param:String name], [param:Skeleton skeleton] )</h3>
<p></p>
<h3>[method:Array getBones]( [param:Skeleton skeleton] )</h3>
<p></p>
<h3>[method:Array getEqualsBonesNames]( [param:Skeleton skeleton], [param:Skeleton targetSkeleton] )</h3>
<p></p>
<h3>[method:SkeletonHelper getHelperFromSkeleton]( [param:Skeleton skeleton] )</h3>
<p></p>
<h3>[method:Bone getNearestBone]( [param:Bone bone], [param:Array names] )</h3>
<p></p>
<h3>[method:Object getSkeletonOffsets]( [param:SkeletonHelper target], [param:SkeletonHelper source], [param:Object options] )</h3>
<p></p>
<h3>[method:this renameBones]( [param:Skeleton skeleton], [param:Array names] )</h3>
<p></p>
<h3>[method:null retarget]( [param:SkeletonHelper target], [param:SkeletonHelper source], [param:Object options] )</h3>
<p></p>
<h3>[method:AnimationClip retargetClip]( [param:SkeletonHelper target], [param:SkeletonHelper source], [param:AnimationClip clip], [param:Object options] )</h3>
<p></p>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/SkeletonUtils.js examples/js/utils/SkeletonUtils.js]
</body>
</html>
......@@ -363,6 +363,7 @@ var list = {
"Loaders": {
"BabylonLoader": "examples/loaders/BabylonLoader",
"DRACOLoader": "examples/loaders/DRACOLoader",
"GLTFLoader": "examples/loaders/GLTFLoader",
"MMDLoader": "examples/loaders/MMDLoader",
"MTLLoader": "examples/loaders/MTLLoader",
......@@ -407,7 +408,8 @@ var list = {
"Utils": {
"BufferGeometryUtils": "examples/utils/BufferGeometryUtils",
"SceneUtils": "examples/utils/SceneUtils"
"SceneUtils": "examples/utils/SceneUtils",
"SkeletonUtils": "examples/utils/SkeletonUtils"
}
},
......
......@@ -294,7 +294,7 @@ select {
#toolbar {
left: calc(50% - 140px);
width: 280px;
top: 52px;
top: 68px;
}
}
......@@ -287,7 +287,7 @@ select {
#toolbar {
left: calc(50% - 140px);
width: 280px;
top: 52px;
top: 68px;
}
}
......@@ -4,8 +4,7 @@
<title>three.js / editor</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- Origin Trial Token, feature = WebXR Device API (For Chrome M69+), origin = https://threejs.org, expires = 2019-03-06 -->
<meta http-equiv="origin-trial" data-feature="WebXR Device API (For Chrome M69+)" data-expires="2019-03-06" content="AvDjbxYpoTgOL1PS0JEra7KFCehfTlKnXpU/ORSwNdCQ35cX70cTUkXOnQ26A5XJi3eXHSKpBPchdt5lbcxDuAIAAABTeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJYUkRldmljZU02OSIsImV4cGlyeSI6MTU1MTgzMDM5OX0=">
<link rel="apple-touch-icon" href="images/icon.png">
<link rel="manifest" href="manifest.json">
</head>
<body ontouchstart="">
......@@ -142,6 +141,7 @@
<script src="js/Strings.js"></script>
<script src="js/Toolbar.js"></script>
<script src="js/Viewport.js"></script>
<script src="js/Viewport.Camera.js"></script>
<script src="js/Viewport.Info.js"></script>
<script src="js/Command.js"></script>
......@@ -191,14 +191,11 @@
var player = new Player( editor );
document.body.appendChild( player.dom );
var menubar = new Menubar( editor );
document.body.appendChild( menubar.dom );
var sidebar = new Sidebar( editor );
document.body.appendChild( sidebar.dom );
var modal = new UI.Modal();
document.body.appendChild( modal.dom );
var menubar = new Menubar( editor );
document.body.appendChild( menubar.dom );
//
......@@ -269,12 +266,6 @@
signals.scriptChanged.add( saveState );
signals.historyChanged.add( saveState );
signals.showModal.add( function ( content ) {
modal.show( content );
} );
} );
//
......
......@@ -22,10 +22,6 @@ var Editor = function () {
startPlayer: new Signal(),
stopPlayer: new Signal(),
// actions
showModal: new Signal(),
// notifications
editorCleared: new Signal(),
......@@ -55,6 +51,9 @@ var Editor = function () {
objectChanged: new Signal(),
objectRemoved: new Signal(),
cameraAdded: new Signal(),
cameraRemoved: new Signal(),
helperAdded: new Signal(),
helperRemoved: new Signal(),
......@@ -68,7 +67,9 @@ var Editor = function () {
showGridChanged: new Signal(),
refreshSidebarObject3D: new Signal(),
historyChanged: new Signal()
historyChanged: new Signal(),
viewportCameraChanged: new Signal()
};
......@@ -99,6 +100,11 @@ var Editor = function () {
this.selected = null;
this.helpers = {};
this.cameras = {};
this.viewportCamera = this.camera;
this.addCamera( this.camera );
};
Editor.prototype = {
......@@ -149,6 +155,7 @@ Editor.prototype = {
if ( child.geometry !== undefined ) scope.addGeometry( child.geometry );
if ( child.material !== undefined ) scope.addMaterial( child.material );
scope.addCamera( child );
scope.addHelper( child );
} );
......@@ -199,6 +206,7 @@ Editor.prototype = {
object.traverse( function ( child ) {
scope.removeCamera( child );
scope.removeHelper( child );
} );
......@@ -254,6 +262,32 @@ Editor.prototype = {
//
addCamera: function ( camera ) {
if ( camera.isCamera ) {
this.cameras[ camera.uuid ] = camera;
this.signals.cameraAdded.dispatch( camera );
}
},
removeCamera: function ( camera ) {
if ( this.cameras[ camera.uuid ] !== undefined ) {
delete this.cameras[ camera.uuid ];
this.signals.cameraRemoved.dispatch( camera );
}
},
//
addHelper: function () {
var geometry = new THREE.SphereBufferGeometry( 2, 4, 2 );
......@@ -383,6 +417,13 @@ Editor.prototype = {
},
setViewportCamera: function ( uuid ) {
this.viewportCamera = this.cameras[ uuid ];
this.signals.viewportCameraChanged.dispatch( this.viewportCamera );
},
//
select: function ( object ) {
......
......@@ -453,7 +453,7 @@ var Loader = function ( editor ) {
var contents = event.target.result;
var loader = new THREE.SVGLoader();
var paths = loader.parse( contents );
var paths = loader.parse( contents ).paths;
//
......
......@@ -380,7 +380,7 @@ Menubar.Add = function ( editor ) {
option.setTextContent( strings.getKey( 'menubar/add/perspectivecamera' ) );
option.onClick( function () {
var camera = new THREE.PerspectiveCamera( 50, 1, 1, 10000 );
var camera = new THREE.PerspectiveCamera();
camera.name = 'PerspectiveCamera';
editor.execute( new AddObjectCommand( camera ) );
......
......@@ -72,7 +72,7 @@ Sidebar.Settings = function ( editor ) {
themeRow.add( new UI.Text( strings.getKey( 'sidebar/settings/theme' ) ).setWidth( '90px' ) );
themeRow.add( theme );
container.add( themeRow );
container.add( themeRow );
container.add( new Sidebar.Settings.Shortcuts( editor ) );
container.add( new Sidebar.Settings.Viewport( editor ) );
......
/**
* @author mrdoob / http://mrdoob.com/
*/
Viewport.Camera = function ( editor ) {
var signals = editor.signals;
//
var cameraSelect = new UI.Select();
cameraSelect.setPosition( 'absolute' );
cameraSelect.setRight( '10px' );
cameraSelect.setTop( '10px' );
cameraSelect.onChange( function () {
editor.setViewportCamera( this.getValue() );
} );
signals.cameraAdded.add( update );
signals.cameraRemoved.add( update );
update();
//
function update() {
var options = {};
var cameras = editor.cameras;
for ( var key in cameras ) {
var camera = cameras[ key ];
options[ camera.uuid ] = camera.name;
}
cameraSelect.setOptions( options );
cameraSelect.setValue( editor.viewportCamera.uuid );
}
return cameraSelect;
};
......@@ -10,6 +10,7 @@ var Viewport = function ( editor ) {
container.setId( 'viewport' );
container.setPosition( 'absolute' );
container.add( new Viewport.Camera( editor ) );
container.add( new Viewport.Info( editor ) );
//
......@@ -198,7 +199,7 @@ var Viewport = function ( editor ) {
function onMouseDown( event ) {
event.preventDefault();
// event.preventDefault();
var array = getMousePosition( container.dom, event.clientX, event.clientY );
onDownPosition.fromArray( array );
......@@ -478,16 +479,20 @@ var Viewport = function ( editor ) {
}
if ( scene.fog.isFog ) {
if ( scene.fog ) {
scene.fog.color.setHex( fogColor );
scene.fog.near = fogNear;
scene.fog.far = fogFar;
if ( scene.fog.isFog ) {
} else if ( scene.fog.isFogExp2 ) {
scene.fog.color.setHex( fogColor );
scene.fog.near = fogNear;
scene.fog.far = fogFar;
scene.fog.color.setHex( fogColor );
scene.fog.density = fogDensity;
} else if ( scene.fog.isFogExp2 ) {
scene.fog.color.setHex( fogColor );
scene.fog.density = fogDensity;
}
}
......@@ -495,6 +500,17 @@ var Viewport = function ( editor ) {
} );
signals.viewportCameraChanged.add( function ( viewportCamera ) {
camera = viewportCamera;
camera.aspect = editor.camera.aspect;
camera.projectionMatrix.copy( editor.camera.projectionMatrix );
render();
} );
//
signals.windowResize.add( function () {
......@@ -547,14 +563,17 @@ var Viewport = function ( editor ) {
function render() {
sceneHelpers.updateMatrixWorld();
scene.updateMatrixWorld();
renderer.render( scene, camera );
if ( renderer instanceof THREE.RaytracingRenderer === false ) {
renderer.render( sceneHelpers, camera );
if ( camera === editor.camera ) {
sceneHelpers.updateMatrixWorld();
renderer.render( sceneHelpers, camera );
}
}
......
......@@ -625,6 +625,56 @@ UI.Number = function ( number ) {
}
function onTouchStart( event ) {
if ( event.touches.length === 1 ) {
distance = 0;
onMouseDownValue = scope.value;
prevPointer = [ event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ];
document.addEventListener( 'touchmove', onTouchMove, false );
document.addEventListener( 'touchend', onTouchEnd, false );
}
}
function onTouchMove( event ) {
var currentValue = scope.value;
pointer = [ event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ];
distance += ( pointer[ 0 ] - prevPointer[ 0 ] ) - ( pointer[ 1 ] - prevPointer[ 1 ] );
var value = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;
value = Math.min( scope.max, Math.max( scope.min, value ) );
if ( currentValue !== value ) {
scope.setValue( value );
dom.dispatchEvent( changeEvent );
}
prevPointer = [ event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ];
}
function onTouchEnd( event ) {
if ( event.touches.length === 0 ) {
document.removeEventListener( 'touchmove', onTouchMove, false );
document.removeEventListener( 'touchend', onTouchEnd, false );
}
}
function onChange( event ) {
scope.setValue( dom.value );
......@@ -648,6 +698,7 @@ UI.Number = function ( number ) {
onBlur();
dom.addEventListener( 'mousedown', onMouseDown, false );
dom.addEventListener( 'touchstart', onTouchStart, false );
dom.addEventListener( 'change', onChange, false );
dom.addEventListener( 'focus', onFocus, false );
dom.addEventListener( 'blur', onBlur, false );
......@@ -944,61 +995,3 @@ UI.Button.prototype.setLabel = function ( value ) {
return this;
};
// Modal
UI.Modal = function ( value ) {
var scope = this;
var dom = document.createElement( 'div' );
dom.style.position = 'absolute';
dom.style.width = '100%';
dom.style.height = '100%';
dom.style.backgroundColor = 'rgba(0,0,0,0.5)';
dom.style.display = 'none';
dom.style.alignItems = 'center';
dom.style.justifyContent = 'center';
dom.addEventListener( 'click', function ( event ) {
scope.hide();
} );
this.dom = dom;
this.container = new UI.Panel();
this.container.dom.style.width = '200px';
this.container.dom.style.padding = '20px';
this.container.dom.style.backgroundColor = '#ffffff';
this.container.dom.style.boxShadow = '0px 5px 10px rgba(0,0,0,0.5)';
this.add( this.container );
return this;
};
UI.Modal.prototype = Object.create( UI.Element.prototype );
UI.Modal.prototype.constructor = UI.Modal;
UI.Modal.prototype.show = function ( content ) {
this.container.clear();
this.container.add( content );
this.dom.style.display = 'flex';
return this;
};
UI.Modal.prototype.hide = function () {
this.dom.style.display = 'none';
return this;
};
// r102.1
// r103
const staticAssets = [
'./',
......
......@@ -4,6 +4,7 @@ var files = {
"webgl_animation_keyframes",
"webgl_animation_skinning_blending",
"webgl_animation_skinning_morph",
"webgl_animation_multiple",
"webgl_camera",
"webgl_camera_array",
"webgl_camera_cinematic",
......@@ -43,6 +44,7 @@ var files = {
"webgl_geometry_terrain_raycast",
"webgl_geometry_text",
"webgl_geometry_text_shapes",
"webgl_geometry_text_stroke",
"webgl_hdr",
"webgl_helpers",
"webgl_interactive_buffergeometry",
......@@ -66,6 +68,7 @@ var files = {
"webgl_lights_spotlight",
"webgl_lights_spotlights",
"webgl_lights_rectarealight",
"webgl_lightshafts",
"webgl_lines_colors",
"webgl_lines_dashed",
"webgl_lines_fat",
......@@ -94,6 +97,7 @@ var files = {
"webgl_loader_json_claraio",
"webgl_loader_kmz",
"webgl_loader_ldraw",
"webgl_loader_lwo",
"webgl_loader_md2",
"webgl_loader_md2_control",
"webgl_loader_mmd",
......@@ -310,6 +314,7 @@ var files = {
"webgldeferred_animation"
],
"webgl2": [
"webgl2_loader_gltf",
"webgl2_materials_texture2darray",
"webgl2_materials_texture3d",
"webgl2_multisampled_renderbuffers",
......@@ -355,6 +360,7 @@ var files = {
"misc_controls_trackball",
"misc_controls_transform",
"misc_exporter_collada",
"misc_exporter_draco",
"misc_exporter_gltf",
"misc_exporter_obj",
"misc_exporter_stl",
......
......@@ -44,8 +44,10 @@ THREE.MD2Character = function () {
loader.load( config.baseUrl + config.body, function ( geo ) {
geo.computeBoundingBox();
scope.root.position.y = - scope.scale * geo.boundingBox.min.y;
var boundingBox = new THREE.Box3();
boundingBox.setFromBufferAttribute( geo.attributes.position );
scope.root.position.y = - scope.scale * boundingBox.min.y;
var mesh = createPart( geo, scope.skinsBody[ 0 ] );
mesh.scale.set( scope.scale, scope.scale, scope.scale );
......
......@@ -156,8 +156,10 @@ THREE.MD2CharacterComplex = function () {
loader.load( config.baseUrl + config.body, function( geo ) {
geo.computeBoundingBox();
scope.root.position.y = - scope.scale * geo.boundingBox.min.y;
var boundingBox = new THREE.Box3();
boundingBox.setFromBufferAttribute( geo.attributes.position );
scope.root.position.y = - scope.scale * boundingBox.min.y;
var mesh = createPart( geo, scope.skinsBody[ 0 ] );
mesh.scale.set( scope.scale, scope.scale, scope.scale );
......
......@@ -13,7 +13,7 @@ THREE.EditorControls = function ( object, domElement ) {
this.enabled = true;
this.center = new THREE.Vector3();
this.panSpeed = 0.001;
this.panSpeed = 0.002;
this.zoomSpeed = 0.1;
this.rotationSpeed = 0.005;
......@@ -104,8 +104,8 @@ THREE.EditorControls = function ( object, domElement ) {
spherical.setFromVector3( vector );
spherical.theta += delta.x;
spherical.phi += delta.y;
spherical.theta += delta.x * scope.rotationSpeed;
spherical.phi += delta.y * scope.rotationSpeed;
spherical.makeSafe();
......@@ -159,7 +159,7 @@ THREE.EditorControls = function ( object, domElement ) {
if ( state === STATE.ROTATE ) {
scope.rotate( delta.set( - movementX * scope.rotationSpeed, - movementY * scope.rotationSpeed, 0 ) );
scope.rotate( delta.set( - movementX, - movementY, 0 ) );
} else if ( state === STATE.ZOOM ) {
......@@ -235,13 +235,13 @@ THREE.EditorControls = function ( object, domElement ) {
switch ( event.touches.length ) {
case 1:
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
break;
case 2:
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 );
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
prevDistance = touches[ 0 ].distanceTo( touches[ 1 ] );
break;
......@@ -277,14 +277,14 @@ THREE.EditorControls = function ( object, domElement ) {
switch ( event.touches.length ) {
case 1:
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - scope.rotationSpeed ) );
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - 1 ) );
break;
case 2:
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 );
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 ).divideScalar( window.devicePixelRatio );
var distance = touches[ 0 ].distanceTo( touches[ 1 ] );
scope.zoom( delta.set( 0, 0, prevDistance - distance ) );
prevDistance = distance;
......@@ -295,7 +295,7 @@ THREE.EditorControls = function ( object, domElement ) {
offset0.x = - offset0.x;
offset1.x = - offset1.x;
scope.pan( offset0.add( offset1 ).multiplyScalar( 0.5 ) );
scope.pan( offset0.add( offset1 ) );
break;
......
......@@ -128,6 +128,13 @@ THREE.TransformControls = function ( camera, domElement ) {
domElement.removeEventListener( "touchcancel", onPointerUp );
domElement.removeEventListener( "touchleave", onPointerUp );
this.traverse( function ( child ) {
if ( child.geometry ) child.geometry.dispose();
if ( child.material ) child.material.dispose();
} );
};
// Set current object
......@@ -396,27 +403,33 @@ THREE.TransformControls = function ( camera, domElement ) {
if ( pointEnd.dot( pointStart ) < 0 ) d *= -1;
_tempVector.set( d, d, d );
_tempVector2.set( d, d, d );
} else {
_tempVector.copy( pointEnd ).divide( pointStart );
_tempVector.copy(pointStart);
_tempVector2.copy(pointEnd);
_tempVector.applyQuaternion( worldQuaternionInv );
_tempVector2.applyQuaternion( worldQuaternionInv );
_tempVector2.divide( _tempVector );
if ( axis.search( 'X' ) === -1 ) {
_tempVector.x = 1;
_tempVector2.x = 1;
}
if ( axis.search( 'Y' ) === -1 ) {
_tempVector.y = 1;
_tempVector2.y = 1;
}
if ( axis.search( 'Z' ) === -1 ) {
_tempVector.z = 1;
_tempVector2.z = 1;
}
}
// Apply scale
object.scale.copy( scaleStart ).multiply( _tempVector );
object.scale.copy( scaleStart ).multiply( _tempVector2 );
} else if ( mode === 'rotate' ) {
......@@ -1183,7 +1196,7 @@ THREE.TransformControlsGizmo = function () {
var AXIS_HIDE_TRESHOLD = 0.99;
var PLANE_HIDE_TRESHOLD = 0.2;
var AXIS_FLIP_TRESHOLD = -0.4;
var AXIS_FLIP_TRESHOLD = 0.0;
if ( handle.name === 'X' || handle.name === 'XYZX' ) {
......
......@@ -66,9 +66,9 @@ THREE.OutlineEffect = function ( renderer, parameters ) {
};
var uniformsChunk = {
outlineThickness: { type: "f", value: defaultThickness },
outlineColor: { type: "c", value: defaultColor },
outlineAlpha: { type: "f", value: defaultAlpha }
outlineThickness: { value: defaultThickness },
outlineColor: { value: defaultColor },
outlineAlpha: { value: defaultAlpha }
};
var vertexShaderChunk = [
......
'use strict';
/**
* Export draco compressed files from threejs geometry objects.
*
* Draco files are compressed and usually are smaller than conventional 3D file formats.
*
* The exporter receives a options object containing
* - decodeSpeed, indicates how to tune the encoder regarding decode speed (0 gives better speed but worst quality)
* - encodeSpeed, indicates how to tune the encoder parameters (0 gives better speed but worst quality)
* - encoderMethod
* - quantization, indicates the presision of each type of data stored in the draco file in the order (POSITION, NORMAL, COLOR, TEX_COORD, GENERIC)
* - exportUvs
* - exportNormals
*
* @class DRACOExporter
* @author tentone
*/
THREE.DRACOExporter = function () {};
THREE.DRACOExporter.prototype = {
constructor: THREE.DRACOExporter,
parse: function ( geometry, options ) {
if ( DracoEncoderModule === undefined ) {
throw new Error( 'THREE.DRACOExporter: required the draco_decoder to work.' );
}
if ( options === undefined ) {
options = {
decodeSpeed: 5,
encodeSpeed: 5,
encoderMethod: THREE.DRACOExporter.MESH_EDGEBREAKER_ENCODING,
quantization: [ 16, 8, 8, 8, 8 ],
exportUvs: true,
exportNormals: true,
exportColor: false,
};
}
var dracoEncoder = DracoEncoderModule();
var encoder = new dracoEncoder.Encoder();
var builder = new dracoEncoder.MeshBuilder();
var mesh = new dracoEncoder.Mesh();
if ( geometry.isGeometry === true ) {
var bufferGeometry = new THREE.BufferGeometry();
bufferGeometry.fromGeometry( geometry );
geometry = bufferGeometry;
}
if ( geometry.isBufferGeometry !== true ) {
throw new Error( 'THREE.DRACOExporter.parse(geometry, options): geometry is not a THREE.Geometry or THREE.BufferGeometry instance.' );
}
var vertices = geometry.getAttribute( 'position' );
builder.AddFloatAttributeToMesh( mesh, dracoEncoder.POSITION, vertices.count, vertices.itemSize, vertices.array );
var faces = geometry.getIndex();
if ( faces !== null ) {
builder.AddFacesToMesh( mesh, faces.count, faces.array );
} else {
var faces = new ( vertices.count > 65535 ? Uint32Array : Uint16Array ) ( vertices.count );
for ( var i = 0; i < faces.length; i ++ ) {
faces[ i ] = i;
}
builder.AddFacesToMesh( mesh, vertices.count, faces );
}
if ( options.exportNormals === true ) {
var normals = geometry.getAttribute( 'normal' );
if ( normals !== undefined ) {
builder.AddFloatAttributeToMesh( mesh, dracoEncoder.NORMAL, normals.count, normals.itemSize, normals.array );
}
}
if ( options.exportUvs === true ) {
var uvs = geometry.getAttribute( 'uv' );
if ( uvs !== undefined ) {
builder.AddFloatAttributeToMesh( mesh, dracoEncoder.TEX_COORD, uvs.count, uvs.itemSize, uvs.array );
}
}
if ( options.exportColor === true ) {
var colors = geometry.getAttribute( 'color' );
if ( colors !== undefined ) {
builder.AddFloatAttributeToMesh( mesh, dracoEncoder.COLOR, colors.count, colors.itemSize, colors.array );
}
}
//Compress using draco encoder
var encodedData = new dracoEncoder.DracoInt8Array();
//Sets the desired encoding and decoding speed for the given options from 0 (slowest speed, but the best compression) to 10 (fastest, but the worst compression).
encoder.SetSpeedOptions( options.encodeSpeed || 5, options.decodeSpeed || 5 );
// Sets the desired encoding method for a given geometry.
if ( options.encoderMethod !== undefined ) {
encoder.SetEncodingMethod( options.encoderMethod );
}
// Sets the quantization (number of bits used to represent) compression options for a named attribute.
// The attribute values will be quantized in a box defined by the maximum extent of the attribute values.
if ( options.quantization !== undefined ) {
for ( var i = 0; i < 5; i ++ ) {
if ( options.quantization[ i ] !== undefined ) {
encoder.SetAttributeQuantization( i, options.quantization[ i ] );
}
}
}
var length = encoder.EncodeMeshToDracoBuffer( mesh, encodedData );
dracoEncoder.destroy( mesh );
if ( length === 0 ) {
throw new Error( 'THREE.DRACOExporter: Draco encoding failed.' );
}
//Copy encoded data to buffer.
var outputData = new Int8Array( new ArrayBuffer( length ) );
for ( var i = 0; i < length; i ++ ) {
outputData[ i ] = encodedData.GetValue( i );
}
dracoEncoder.destroy( encodedData );
dracoEncoder.destroy( encoder );
dracoEncoder.destroy( builder );
return outputData;
}
};
// Encoder methods
THREE.DRACOExporter.MESH_EDGEBREAKER_ENCODING = 1;
THREE.DRACOExporter.MESH_SEQUENTIAL_ENCODING = 0;
// Geometry type
THREE.DRACOExporter.POINT_CLOUD = 0;
THREE.DRACOExporter.TRIANGULAR_MESH = 1;
// Attribute type
THREE.DRACOExporter.INVALID = - 1;
THREE.DRACOExporter.POSITION = 0;
THREE.DRACOExporter.NORMAL = 1;
THREE.DRACOExporter.COLOR = 2;
THREE.DRACOExporter.TEX_COORD = 3;
THREE.DRACOExporter.GENERIC = 4;
......@@ -1162,9 +1162,22 @@ THREE.GLTFExporter.prototype = {
var modifiedAttribute = null;
for ( var attributeName in geometry.attributes ) {
// Ignore morph target attributes, which are exported later.
if ( attributeName.substr( 0, 5 ) === 'morph' ) continue;
var attribute = geometry.attributes[ attributeName ];
attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
// Prefix all geometry attributes except the ones specifically
// listed in the spec; non-spec attributes are considered custom.
var validVertexAttributes =
/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;
if ( ! validVertexAttributes.test( attributeName ) ) {
attributeName = '_' + attributeName;
}
if ( cachedData.attributes.has( attribute ) ) {
attributes[ attributeName ] = cachedData.attributes.get( attribute );
......@@ -1184,15 +1197,11 @@ THREE.GLTFExporter.prototype = {
}
if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) {
var accessor = processAccessor( modifiedAttribute || attribute, geometry );
if ( accessor !== null ) {
var accessor = processAccessor( modifiedAttribute || attribute, geometry );
if ( accessor !== null ) {
attributes[ attributeName ] = accessor;
cachedData.attributes.set( attribute, accessor );
}
attributes[ attributeName ] = accessor;
cachedData.attributes.set( attribute, accessor );
}
......@@ -1360,6 +1369,8 @@ THREE.GLTFExporter.prototype = {
}
if ( primitive.indices === null ) delete primitive.indices;
}
var material = processMaterial( materials[ groups[ i ].materialIndex ] );
......@@ -1754,7 +1765,7 @@ THREE.GLTFExporter.prototype = {
} else if ( object.isLight ) {
console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.' );
console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.', object );
return null;
}
......@@ -2147,7 +2158,7 @@ THREE.GLTFExporter.Utils = {
console.warn( 'THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.' );
sourceTrack = sourceTrack.clone();
sourceTrack.setInterpolation( InterpolateLinear );
sourceTrack.setInterpolation( THREE.InterpolateLinear );
}
......
此差异已折叠。
此差异已折叠。
......@@ -146,7 +146,7 @@ THREE.GCodeLoader.prototype.parse = function ( data ) {
} else if ( cmd === 'G2' || cmd === 'G3' ) {
//G2/G3 - Arc Movement ( G2 clock wise and G3 counter clock wise )
console.warn( 'THREE.GCodeLoader: Arc command not supported' );
//console.warn( 'THREE.GCodeLoader: Arc command not supported' );
} else if ( cmd === 'G90' ) {
......@@ -170,7 +170,7 @@ THREE.GCodeLoader.prototype.parse = function ( data ) {
} else {
console.warn( 'THREE.GCodeLoader: Command not supported:' + cmd );
//console.warn( 'THREE.GCodeLoader: Command not supported:' + cmd );
}
......
此差异已折叠。
此差异已折叠。
......@@ -15,6 +15,7 @@ function init( canvas, width, height, pixelRatio, path ) {
// we don't use ImageLoader since it has a DOM dependency (HTML5 image element)
var loader = new THREE.ImageBitmapLoader().setPath( path );
loader.setOptions( { imageOrientation: 'flipY' } );
loader.load( 'textures/matcaps/matcap-porcelain-white.jpg', function ( imageBitmap ) {
var texture = new THREE.CanvasTexture( imageBitmap );
......
......@@ -117,12 +117,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
blending: THREE.NoBlending
} );
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
this.scene.add( this.quad );
this.fsQuad = new THREE.Pass.FullScreenQuad( null );
};
......@@ -146,35 +141,35 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
if ( this.adaptive ) {
//Render the luminance of the current scene into a render target with mipmapping enabled
this.quad.material = this.materialLuminance;
this.fsQuad.material = this.materialLuminance;
this.materialLuminance.uniforms.tDiffuse.value = readBuffer.texture;
renderer.setRenderTarget( this.currentLuminanceRT );
renderer.render( this.scene, this.camera );
this.fsQuad.render( renderer );
//Use the new luminance values, the previous luminance and the frame delta to
//adapt the luminance over time.
this.quad.material = this.materialAdaptiveLum;
this.fsQuad.material = this.materialAdaptiveLum;
this.materialAdaptiveLum.uniforms.delta.value = deltaTime;
this.materialAdaptiveLum.uniforms.lastLum.value = this.previousLuminanceRT.texture;
this.materialAdaptiveLum.uniforms.currentLum.value = this.currentLuminanceRT.texture;
renderer.setRenderTarget( this.luminanceRT );
renderer.render( this.scene, this.camera );
this.fsQuad.render( renderer );
//Copy the new adapted luminance value so that it can be used by the next frame.
this.quad.material = this.materialCopy;
this.fsQuad.material = this.materialCopy;
this.copyUniforms.tDiffuse.value = this.luminanceRT.texture;
renderer.setRenderTarget( this.previousLuminanceRT );
renderer.render( this.scene, this.camera );
this.fsQuad.render( renderer );
}
this.quad.material = this.materialToneMap;
this.fsQuad.material = this.materialToneMap;
this.materialToneMap.uniforms.tDiffuse.value = readBuffer.texture;
if ( this.renderToScreen ) {
renderer.setRenderTarget( null );
renderer.render( this.scene, this.camera );
this.fsQuad.render( renderer );
} else {
......@@ -182,7 +177,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
if ( this.clear ) renderer.clear();
renderer.render( this.scene, this.camera );
this.fsQuad.render( renderer );
}
......@@ -230,7 +225,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
}
//Put something in the adaptive luminance texture so that the scene can render initially
this.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 } );
this.fsQuad.material = new THREE.MeshBasicMaterial( { color: 0x777777 } );
this.materialLuminance.needsUpdate = true;
this.materialAdaptiveLum.needsUpdate = true;
this.materialToneMap.needsUpdate = true;
......
......@@ -39,23 +39,10 @@ THREE.AfterimagePass = function ( damp ) {
} );
this.sceneComp = new THREE.Scene();
this.scene = new THREE.Scene();
this.compFsQuad = new THREE.Pass.FullScreenQuad( this.shaderMaterial );
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.camera.position.z = 1;
var geometry = new THREE.PlaneBufferGeometry( 2, 2 );
this.quadComp = new THREE.Mesh( geometry, this.shaderMaterial );
this.sceneComp.add( this.quadComp );
var material = new THREE.MeshBasicMaterial( {
map: this.textureComp.texture
} );
var quadScreen = new THREE.Mesh( geometry, material );
this.scene.add( quadScreen );
var material = new THREE.MeshBasicMaterial();
this.copyFsQuad = new THREE.Pass.FullScreenQuad( material );
};
......@@ -68,18 +55,15 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot
this.uniforms[ "tOld" ].value = this.textureOld.texture;
this.uniforms[ "tNew" ].value = readBuffer.texture;
this.quadComp.material = this.shaderMaterial;
renderer.setRenderTarget( this.textureComp );
renderer.render( this.sceneComp, this.camera );
this.compFsQuad.render( renderer );
renderer.setRenderTarget( this.textureOld );
renderer.render( this.scene, this.camera );
this.copyFsQuad.material.map = this.textureComp.texture;
if ( this.renderToScreen ) {
renderer.setRenderTarget( null );
renderer.render( this.scene, this.camera );
this.copyFsQuad.render( renderer );
} else {
......@@ -87,10 +71,23 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot
if ( this.clear ) renderer.clear();
renderer.render( this.scene, this.camera );
this.copyFsQuad.render( renderer );
}
// Swap buffers.
var temp = this.textureOld;
this.textureOld = this.textureComp;
this.textureComp = temp;
// Now textureOld contains the latest image, ready for the next frame.
},
setSize: function ( width, height ) {
this.textureComp.setSize( width, height );
this.textureOld.setSize( width, height );
}
} );
......@@ -160,10 +160,7 @@ THREE.SAOPass = function ( scene, camera, depthTexture, useNormals, resolution )
blending: THREE.NoBlending
} );
this.quadCamera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.quadScene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quadScene.add( this.quad );
this.fsQuad = new THREE.Pass.FullScreenQuad( null );
};
......@@ -331,8 +328,8 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
}
this.quad.material = passMaterial;
renderer.render( this.quadScene, this.quadCamera );
this.fsQuad.material = passMaterial;
this.fsQuad.render( renderer );
// restore original state
renderer.autoClear = originalAutoClear;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -240,8 +240,6 @@
var renderModel = new THREE.RenderPass( scene, camera );
var effectFilm = new THREE.FilmPass( 0.35, 0.75, 2048, false );
effectFilm.renderToScreen = true;
composer = new THREE.EffectComposer( renderer );
composer.addPass( renderModel );
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册