提交 6b080840 编写于 作者: M Mr.doob 提交者: GitHub

Merge branch 'dev' into manual/Movepage/runningLocally

......@@ -13,7 +13,7 @@ The aim of the project is to create an easy to use, lightweight, 3D library. The
[Examples](http://threejs.org/examples/) —
[Documentation](http://threejs.org/docs/) —
[Wiki](https://github.com/mrdoob/three.js/wiki) —
[Migrating](https://github.com/mrdoob/three.js/wiki/Migration) —
[Migrating](https://github.com/mrdoob/three.js/wiki/Migration-Guide) —
[Help](http://stackoverflow.com/questions/tagged/three.js)
### Usage ###
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -3,12 +3,15 @@ var list = {
"Manual": {
"Introduction": [
[ "Creating a scene", "manual/introduction/Creating-a-scene" ],
[ "Matrix transformations", "manual/introduction/Matrix-transformations" ],
[ "Useful links", "manual/introduction/Useful-links" ],
[ "Drawing Lines", "manual/introduction/Drawing-lines" ],
[ "Creating Text", "manual/introduction/Creating-text" ],
[ "Code Style Guide", "manual/introduction/Code-style-guide" ],
[ "Migration Guide", "manual/introduction/Migration-guide" ],
[ "How to run things locally", "manual/introduction/How-to-run-thing-locally" ],
[ "Matrix transformations", "manual/introduction/Matrix-transformations" ]
[ "Matrix transformations", "manual/introduction/Matrix-transformations" ],
[ "FAQ", "manual/introduction/FAQ" ]
],
"Build Tools": [
......@@ -80,7 +83,7 @@ var list = {
[ "Layers", "api/core/Layers" ],
[ "Object3D", "api/core/Object3D" ],
[ "Raycaster", "api/core/Raycaster" ],
[ "Uniform", "api/core/Uniform"]
[ "Uniform", "api/core/Uniform" ]
],
"Core / BufferAttributes": [
......
<!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>
<h2>Which Import Format/Exporter is best supported?</h2>
<div>
TODO
</div>
<h2>Why are there meta viewport tags in examples?</h2>
<div>
<div class="highlight highlight-text-html-basic"><pre>&lt;<span class="pl-ent">meta</span> <span class="pl-e">name</span>=<span class="pl-s"><span class="pl-pds">"</span>viewport<span class="pl-pds">"</span></span> <span class="pl-e">content</span>=<span class="pl-s"><span class="pl-pds">"</span>width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0<span class="pl-pds">"</span></span>&gt;</pre></div>
<p>These tags control viewport size and scale for mobile browsers (where page content may be rendered at different size than visible viewport).</p>
<p><a href="http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html">http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html</a></p>
<p><a href="https://developer.mozilla.org/en/Mobile/Viewport_meta_tag">https://developer.mozilla.org/en/Mobile/Viewport_meta_tag</a></p>
</div>
<h2>How can scene scale be preserved on resize?</h2>
<div>
We want all objects, regardless of their distance from the camera, to appear the same size, even as the window is resized.
The key equation to solving this is this formula for the visible height at a given distance:
<code>s
visible_height = 2 * Math.tan( ( Math.PI / 180 ) * camera.fov / 2 ) * distance_from_camera;
</code>
If we increase the window height by a certain percentage, then what we want is the visible height at all distances
to increase by the same percentage.
This can not be done by changing the camera position. Instead you have to change the camera field-of-view.
[link:http://jsfiddle.net/Q4Jpu/ Example].
</div>
<h2>Why is part of my object invisible?</h2>
<div>
This could be because of face culling. Faces have an orientation that decides which side is which. And the culling removes the backside in normal circumstances. To see if this is your problem, change the material side to THREE.DoubleSide.
<code>material.side = THREE.DoubleSide</code>
</div>
</body>
</html>
<!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><br />
<div class="desc">
The following is a collection of links that you might find useful when learning Three.<br />
If you find something that you'd like to add here, or think that one of the links below is no longer
relevant or working, feel free to click the 'edit' button in the top right and make some changes!<br /><br />
Note also that as three.js is under rapid development, a lot of these links will contain information that is
out of date - if something isn't working as you'd expect or one of these links says it should,
check the browser console for warning, the relevant docs pages and especially the [page:DeprecatedList].
</div>
<h2>More documentation</h2>
<ul>
<li>
[link:http://threejsdoc.appspot.com/doc/index.html threejsdoc] - useful because it links every API element to to every official example that uses it.
</li>
<li>
[link:http://ushiroad.com/3j/ Three.js walking map] - a graphical breakdown of the structure of a three.js scene.
</li>
<li>
[link:http://www.reddit.com/r/threejs/ Three.js] subreddit.
</li>
<li>
[link:http://www.reddit.com/r/webgl/ WebGL] subreddit.
</li>
</ul>
<h2>News and Updates</h2>
<ul>
<li>
[link:http://learningwebgl.com/blog/ Learning WebGL Blog] – The authoritaive news source for WebGL.
</li>
<li>
[link:https://plus.google.com/104300307601542851567/posts Three.js posts] on Google+ – frequent posts on Three.js
</li>
</ul>
<h2>Articles</h2>
<ul>
<li>
[link:http://bkcore.com/blog/3d/webgl-three-js-animated-selective-glow.html Animated selective glow in Three.js]
by [link:https://github.com/BKcore BKcore]
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
<h2>Examples</h2>
<ul>
<li>
[link:http://stemkoski.github.io/Three.js/index.html Professor Stemkoskis Examples] - a collection of beginner friendly
examples built using three.js r60.
</li>
<li>
[link:https://threejs.org/examples/ Official three.js Examples] - these examples are
maintained as part of the three.js repository, and always use the latest version of three.js.
</li>
<li>
[link:https://rawgit.com/mrdoob/three.js/dev/examples/ Official three.js Examples] (dev branch) -
Same as the above, except these use the dev branch of three.js, and are used to check that
everything is working as three.js being is developed.
</li>
</ul>
<h2>Tools</h2>
<ul>
<li>
[link:http://www.physgl.org/ physgl.org] - javascript front-end with wrappers to three.js, to bring WebGL
graphics to students learning physics and math.
</li>
<li>
[link:http://whitestormjs.xyz/ Whitestorm.js] – A wrapper around Three.js and custom [link:https://github.com/chandlerprall/Physijs physi.js].
</li>
<li>
[link:http://zz85.github.io/zz85-bookmarklets/threelabs.html Three.js Inspector]
</li>
<li>
[link:http://idflood.github.io/ThreeNodes.js/ ThreeNodes.js].
</li>
</ul>
<h2>Tutorials and courses</h2>
<ul>
<li>
[link:https://www.udacity.com/course/cs291 Interactive 3D Graphics] - a free course on Udacity that teaches the fundamentals of 3D Graphics,
and uses three.js as it coding tool.
</li>
<li>
[Link:https://aerotwist.com/tutorials/ Aerotwist] tutorials by [link:https://github.com/paullewis/ Paul Lewis].
</li>
<li>
[link:http://www.natural-science.or.jp/article/20120220155529.php Building A Physics Simulation Environment] - three.js tutorial in Japanese
</li>
<li>
[link:http://www.senaeh.de/einstieg-in-webgl-mit-three-js/ Einstieg in WebGL mit three.js] - three.js tutorial in German
</li>
<li>
[link:http://learningthreejs.com/ Learning Three.js] – blog where each post is dedicated to teaching an aspect of three.js
</li>
</ul>
<h2>Old Links</h2>
<div>
These links are kept for historical purposes - you may still find them useful, but be warned that
they may have information relating to very old versions of three.js.
</div>
<ul>
<li>
<a href="https://www.youtube.com/watch?v=Dir4KO9RdhM">AlterQualia at WebGL Camp 3</a>
</li>
<li>
[link:http://yomotsu.github.io/threejs-examples/ Yomotsus Examples] - a collection of examples using three.js r45.
</li>
<li>
[link:http://fhtr.org/BasicsOfThreeJS/#1 Introduction to Three.js] by [link:http://github.com/kig/ Ilmari Heikkinen] (slideshow).
</li>
<li>
[link:http://www.slideshare.net/yomotsu/webgl-and-threejs WebGL and Three.js] by [link:http://github.com/yomotsu Akihiro Oyamada] (slideshow).
</li>
<li>
[link:http://bkcore.com/blog/general/adobe-user-group-nl-talk-video-hexgl.html Fast HTML5 game development using three.js] by [link:https://github.com/BKcore BKcore] (video).
</li>
<li>
<a href="http://www.youtube.com/watch?v=VdQnOaolrPA">Trigger Rally</a> by [link:https://github.com/jareiko jareiko] (video).
</li>
<li>
[link:http://blackjk3.github.io/threefab/ ThreeFab] - scene editor, maintained up until around three.js r50.
</li>
<li>
[link:http://bkcore.com/blog/3d/webgl-three-js-workflow-tips.html Max to Three.js workflow tips and tricks] by https://github.com/BKcore BKcore]
</li>
<li>
[link:http://12devsofxmas.co.uk/2012/01/webgl-and-three-js/ On the twelfth day of Xmas, take a whirlwind look at Three.js]
by [link:http://github.com/nrocy Paul King]
</li>
</ul>
</body>
</html>
......@@ -4,6 +4,16 @@
Menubar.File = function ( editor ) {
var NUMBER_PRECISION = 6;
function parseNumber( key, value ) {
return typeof value === 'number' ? parseFloat( value.toFixed( NUMBER_PRECISION ) ) : value;
}
//
var container = new UI.Panel();
container.setClass( 'menu' );
......@@ -89,7 +99,7 @@ Menubar.File = function ( editor ) {
try {
output = JSON.stringify( output, null, '\t' );
output = JSON.stringify( output, parseNumber, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
} catch ( e ) {
......@@ -123,7 +133,7 @@ Menubar.File = function ( editor ) {
try {
output = JSON.stringify( output, null, '\t' );
output = JSON.stringify( output, parseNumber, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
} catch ( e ) {
......@@ -148,7 +158,7 @@ Menubar.File = function ( editor ) {
try {
output = JSON.stringify( output, null, '\t' );
output = JSON.stringify( output, parseNumber, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
} catch ( e ) {
......@@ -220,7 +230,7 @@ Menubar.File = function ( editor ) {
var vr = output.project.vr;
output = JSON.stringify( output, null, '\t' );
output = JSON.stringify( output, parseNumber, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
zip.file( 'app.json', output );
......
......@@ -1487,6 +1487,13 @@ THREE.GLTFLoader = ( function () {
var mesh = node.meshes[ meshId ];
var group = dependencies.meshes[ mesh ];
if ( group === undefined ) {
console.warn( 'GLTFLoader: Couldn\'t find node "' + mesh + '".' );
continue;
}
for ( var childrenId in group.children ) {
var child = group.children[ childrenId ];
......
......@@ -119,6 +119,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
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 );
};
......
......@@ -69,6 +69,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
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 );
};
......
......@@ -63,6 +63,7 @@ THREE.BokehPass = function ( scene, camera, params ) {
this.scene2 = new THREE.Scene();
this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad2.frustumCulled = false; // Avoid getting clipped
this.scene2.add( this.quad2 );
};
......
......@@ -29,6 +29,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
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 );
};
......
......@@ -30,6 +30,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount,
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 );
};
......
......@@ -27,6 +27,7 @@ THREE.GlitchPass = function ( dt_size ) {
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.goWild = false;
......
......@@ -97,6 +97,7 @@ THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
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.tempPulseColor1 = new THREE.Color();
......
......@@ -100,6 +100,7 @@ THREE.SMAAPass = function ( width, height ) {
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 );
};
......
......@@ -43,6 +43,7 @@ THREE.SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene2 = new THREE.Scene();
this.quad2 = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), this.copyMaterial );
this.quad2.frustumCulled = false; // Avoid getting clipped
this.scene2.add( this.quad2 );
};
......
......@@ -38,6 +38,7 @@ THREE.SavePass = function ( renderTarget ) {
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 );
};
......
......@@ -33,6 +33,7 @@ THREE.ShaderPass = function ( shader, textureID ) {
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 );
};
......
......@@ -32,6 +32,7 @@ THREE.TexturePass = function ( map, opacity ) {
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 );
};
......
......@@ -124,6 +124,7 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
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 );
};
......
import { FileLoader } from './FileLoader';
import { DefaultLoadingManager } from './LoadingManager';
/**
* @author mrdoob / http://mrdoob.com/
*/
import { Cache } from './Cache';
import { DefaultLoadingManager } from './LoadingManager';
function ImageLoader( manager ) {
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
......@@ -15,56 +16,64 @@ Object.assign( ImageLoader.prototype, {
load: function ( url, onLoad, onProgress, onError ) {
if ( url === undefined ) url = '';
if ( this.path !== undefined ) url = this.path + url;
var scope = this;
var image = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'img' );
image.onload = function () {
var cached = Cache.get( url );
image.onload = null;
if ( cached !== undefined ) {
URL.revokeObjectURL( image.src );
scope.manager.itemStart( url );
if ( onLoad ) onLoad( image );
setTimeout( function () {
scope.manager.itemEnd( url );
if ( onLoad ) onLoad( cached );
scope.manager.itemEnd( url );
}, 0 );
return cached;
};
image.onerror = onError;
}
var image = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'img' );
if ( url.indexOf( 'data:' ) === 0 ) {
image.addEventListener( 'load', function () {
image.src = url;
THREE.Cache.add( url, this );
} else if ( this.crossOrigin !== undefined ) {
if ( onLoad ) onLoad( this );
// crossOrigin doesn't work with URL.createObjectURL()?
scope.manager.itemEnd( url );
image.crossOrigin = this.crossOrigin;
image.src = url;
}, false );
} else {
/*
image.addEventListener( 'progress', function ( event ) {
var loader = new FileLoader();
loader.setPath( this.path );
loader.setResponseType( 'blob' );
loader.setWithCredentials( this.withCredentials );
if ( onProgress ) onProgress( event );
// By default the FileLoader requests files to be loaded with a MIME
// type of `text/plain`. Using `URL.createObjectURL()` with SVGs that
// have a MIME type of `text/plain` results in an error, so explicitly
// set the SVG MIME type.
if ( /\.svg$/.test( url ) ) loader.setMimeType( 'image/svg+xml' );
}, false );
*/
loader.load( url, function ( blob ) {
image.addEventListener( 'error', function ( event ) {
image.src = URL.createObjectURL( blob );
if ( onError ) onError( event );
}, onProgress, onError );
scope.manager.itemError( url );
}
}, false );
if ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin;
scope.manager.itemStart( url );
image.src = url;
return image;
},
......@@ -76,13 +85,6 @@ Object.assign( ImageLoader.prototype, {
},
setWithCredentials: function ( value ) {
this.withCredentials = value;
return this;
},
setPath: function ( value ) {
this.path = value;
......
/**
* @author mrdoob / http://mrdoob.com/
*/
import { RGBAFormat, RGBFormat } from '../constants';
import { ImageLoader } from './ImageLoader';
import { Texture } from '../textures/Texture';
import { DefaultLoadingManager } from './LoadingManager';
/**
* @author mrdoob / http://mrdoob.com/
*/
function TextureLoader( manager ) {
......@@ -21,7 +22,6 @@ Object.assign( TextureLoader.prototype, {
var loader = new ImageLoader( this.manager );
loader.setCrossOrigin( this.crossOrigin );
loader.setWithCredentials( this.withCredentials );
loader.setPath( this.path );
loader.load( url, function ( image ) {
......@@ -51,13 +51,6 @@ Object.assign( TextureLoader.prototype, {
},
setWithCredentials: function ( value ) {
this.withCredentials = value;
return this;
},
setPath: function ( value ) {
this.path = value;
......@@ -65,8 +58,6 @@ Object.assign( TextureLoader.prototype, {
}
} );
......
......@@ -259,11 +259,13 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
} else if ( geometry.isGeometry ) {
var fvA, fvB, fvC;
var isFaceMaterial = (material && material.isMultiMaterial);
var isFaceMaterial = ( material && material.isMultiMaterial );
var materials = isFaceMaterial === true ? material.materials : null;
var vertices = geometry.vertices;
var faces = geometry.faces;
var uvs;
var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
......
......@@ -159,12 +159,12 @@ EXPORT_OPTIONS = {
EMBED_TEXTURES: False,
TEXTURE_FOLDER: '',
LOGGING: DEBUG,
ENABLE_PRECISION: True,
ENABLE_PRECISION: False,
PRECISION: DEFAULT_PRECISION,
CUSTOM_PROPERTIES: False,
EMBED_GEOMETRY: True,
EMBED_ANIMATION: True,
GEOMETRY_TYPE: GEOMETRY,
GEOMETRY_TYPE: BUFFER_GEOMETRY,
INFLUENCES_PER_VERTEX: 2,
INDENT: True
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册