提交 e47032d0 编写于 作者: B Ben Houston

Merge branch 'dev' of git://github.com/mrdoob/three.js.git into ray3

此差异已折叠。
此差异已折叠。
......@@ -9,7 +9,7 @@
<body>
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc">An extensible curve object which contains methods for interpolation</div>
<h2>Constructor</h2>
......@@ -25,37 +25,34 @@
<h2>Methods</h2>
<h3>.getPoint ( t )</h3>
<div>todo</div>
<div>Returns a vector for point t of the curve where t is between 0 and 1</div>
<h3>.getPointAt ( u )</h3>
<div>todo</div>
<div>Returns a vector for point at relative position in curve according to arc length</div>
<h3>.getPoints ( divisions )</h3>
<div>todo</div>
<div>Get sequence of points using getPoint( t ) </div>
<h3>.getSpacedPoints ( divisions )</h3>
<div>todo</div>
<div>Get sequence of equi-spaced points using getPointAt( u )</div>
<h3>.getLength ()</h3>
<div>todo</div>
<div>Get total curve arc length</div>
<h3>.getLengths ( divisions )</h3>
<div>todo</div>
<div>Get list of cumulative segment lengths</div>
<h3>.updateArcLengths ()</h3>
<div>todo</div>
<div>Update the cumlative segment distance cache</div>
<h3>.getUtoTmapping ( u, distance )</h3>
<div>todo</div>
<h3>.getNormalVector ( t )</h3>
<div>todo</div>
<div>Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance</div>
<h3>.getTangent ( t )</h3>
<div>todo</div>
<div>Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation</div>
<h3>.getTangentAt ( u )</h3>
<div>todo</div>
<div>Returns tangent at equidistance point u on the curve</div>
<h2>Source</h2>
......
......@@ -9,12 +9,12 @@
<body>
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc">Creates extruded geometry from a path shape</div>
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( shapes, options )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( radius, detail )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( points, steps, angle )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( radius, detail )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( width, height, widthSegments, heightSegments )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( vertices, faces, radius, detail )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( radius, detail )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( text, parameters )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( radius, tube, radialSegments, tubularSegments, arc )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( radius, tube, radialSegments, tubularSegments, arc )</h3>
<h2>Properties</h2>
......
......@@ -9,17 +9,18 @@
<body>
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc">Applies Catmull-Clark Subdivision Surfaces for creating smooth geometry meshes</div>
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( subdivisions )</h3>
<h2>Properties</h2>
<h3>.subdivisions</h3>
<div>Number of time subdivision will be applied</div>
<h3>.useOldVertexColors</h3>
......@@ -30,10 +31,10 @@
<h2>Methods</h2>
<h3>.modify ( geometry )</h3>
<div>todo</div>
<div>Modifies the geometry by running subdivision surfaces. This calls .smooth() internally</div>
<h3>.smooth ( oldGeometry )</h3>
<div>todo</div>
<div>Performs an iteration of Catmull-Clark Subdivision</div>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( texture, size, distance, blending, color )</h3>
<h2>Properties</h2>
......
......@@ -11,12 +11,14 @@
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc">Material rendered with custom shaders</div>
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( parameters )
</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy )</h3>
<h2>Properties</h2>
......
......@@ -14,7 +14,7 @@
<h2>Constructor</h2>
<h3>[name]()</h3>
<h3>[name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy )</h3>
<h2>Properties</h2>
......
......@@ -104,6 +104,9 @@
var html = '<h1><a href="http://threejs.org">three.js</a><span style="font-size: 50%; vertical-align: super;"> r' + REVISION + '</span></h1>';
var DELIMITER = '/';
var nameCategoryMap = {};
for ( var section in list ) {
html += '<h2>' + section + '</h2>';
......@@ -122,6 +125,12 @@
html += '<li><a href="javascript:goTo(\'' + section + '\', \'' + category + '\', \'' + page[ 0 ] + '\')">' + page[ 0 ] + '</a></li>';
nameCategoryMap[page[0]] = {
section: section,
category: category,
name: page[0]
};
}
html += '</ul>';
......@@ -134,13 +143,36 @@
panel.innerHTML += html;
function encodeUrl( path ) {
return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');
}
function decodeUrl( path ) {
return path.replace(/_/g, ' ').replace(/\./g, ' / ');
}
// Page loading
function goTo( section, category, name ) {
window.document.title = 'three.js - documentation - ' + section + ' - ' + name;
// Fully resolve links that only provide a name
if(arguments.length == 1) {
var location = nameCategoryMap[section];
section = location.section;
category = location.category;
name = location.name;
}
var title = 'three.js - documentation - ' + section + ' - ' + name;
var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name);
window.location.hash = url;
window.document.title = title;
window.location.hash = section + '/' + category + '/' + name.replace(/\ /g, '-');
viewer.src = pages[ section ][ category ][ name ] + '.html';
......@@ -148,8 +180,8 @@
function goToHash() {
var hash = window.location.hash.substring( 1 ).split('/');
goTo( hash[0], hash[1], hash[2].replace(/\-/g, ' ') );
var hash = window.location.hash.substring( 1 ).split(DELIMITER);
goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(hash[2]) );
}
......
......@@ -714,7 +714,7 @@ var Viewport = function ( signals ) {
defaultScene.add( defaultCamera );
signals.sceneAdded.dispatch( defaultScene, defaultCamera, defaultBgColor );
signals.objectSelected.dispatch( defaultScene.properties.defaultSelection );
signals.objectSelected.dispatch( defaultCamera );
} );
......@@ -872,6 +872,8 @@ var Viewport = function ( signals ) {
var scene = new THREE.Scene();
/*
// create lights
var light1 = new THREE.DirectionalLight( 0xffffff, 0.8 );
......@@ -925,6 +927,8 @@ var Viewport = function ( signals ) {
scene.add( light4 );
scene.add( mesh );
*/
return scene;
}
......
......@@ -17,9 +17,11 @@ THREE.ShaderDeferred = {
THREE.UniformsLib[ "shadowmap" ],
{
"emissive" : { type: "c", value: new THREE.Color( 0x000000 ) },
"specular" : { type: "c", value: new THREE.Color( 0x111111 ) },
"shininess": { type: "f", value: 30 }
"emissive" : { type: "c", value: new THREE.Color( 0x000000 ) },
"specular" : { type: "c", value: new THREE.Color( 0x111111 ) },
"shininess": { type: "f", value: 30 },
"wrapAround": { type: "f", value: 1 },
"additiveSpecular": { type: "f", value: 1 }
}
] ),
......@@ -30,6 +32,8 @@ THREE.ShaderDeferred = {
"uniform vec3 specular;",
"uniform vec3 emissive;",
"uniform float shininess;",
"uniform float wrapAround;",
"uniform float additiveSpecular;",
THREE.ShaderChunk[ "color_pars_fragment" ],
THREE.ShaderChunk[ "map_pars_fragment" ],
......@@ -66,21 +70,33 @@ THREE.ShaderDeferred = {
THREE.ShaderChunk[ "fog_fragment" ],
//
"const float compressionScale = 0.999;",
// diffuse color
"gl_FragColor.x = vec3_to_float( 0.999 * gl_FragColor.xyz );",
"gl_FragColor.x = vec3_to_float( compressionScale * gl_FragColor.xyz );",
// specular color
"gl_FragColor.y = vec3_to_float( 0.999 * specular );",
"gl_FragColor.y = additiveSpecular * vec3_to_float( compressionScale * specular );",
// shininess
"gl_FragColor.z = shininess;",
"gl_FragColor.z = wrapAround * shininess;",
// emissive color
"gl_FragColor.w = vec3_to_float( 0.999 * emissive );",
"#ifdef USE_MAP",
"gl_FragColor.w = vec3_to_float( compressionScale * emissive * texelColor.xyz );",
"#else",
"gl_FragColor.w = vec3_to_float( compressionScale * emissive );",
"#endif",
"}"
......@@ -125,60 +141,62 @@ THREE.ShaderDeferred = {
},
"clipDepth" : {
"normalDepth" : {
uniforms: { },
uniforms: {
fragmentShader : [
bumpMap: { type: "t", value: null },
bumpScale: { type: "f", value: 1 },
offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }
"varying vec4 clipPos;",
},
"void main() {",
fragmentShader : [
"gl_FragColor = vec4( clipPos.z / clipPos.w, 1.0, 1.0, 1.0 );",
"#ifdef USE_BUMPMAP",
"}"
"#extension GL_OES_standard_derivatives : enable\n",
].join("\n"),
"varying vec2 vUv;",
"varying vec3 vViewPosition;",
vertexShader : [
THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
"varying vec4 clipPos;",
"#endif",
THREE.ShaderChunk[ "morphtarget_pars_vertex" ],
"varying vec3 normalView;",
"varying vec4 clipPos;",
"void main() {",
THREE.ShaderChunk[ "morphtarget_vertex" ],
THREE.ShaderChunk[ "default_vertex" ],
"vec3 normal = normalize( normalView );",
"clipPos = gl_Position;",
"#ifdef USE_BUMPMAP",
"}"
"normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );",
].join("\n")
"#endif",
},
"gl_FragColor.xyz = normal * 0.5 + 0.5;",
"gl_FragColor.w = clipPos.z / clipPos.w;",
"normals" : {
"}"
uniforms: { },
].join("\n"),
fragmentShader : [
vertexShader : [
"varying vec3 normalView;",
"varying vec4 clipPos;",
"void main() {",
"gl_FragColor = vec4( vec3( normalView * 0.5 + 0.5 ), 1.0 );",
"#ifdef USE_BUMPMAP",
"}"
"varying vec2 vUv;",
"varying vec3 vViewPosition;",
].join("\n"),
"uniform vec4 offsetRepeat;",
vertexShader : [
"varying vec3 normalView;",
"#endif",
THREE.ShaderChunk[ "morphtarget_pars_vertex" ],
......@@ -204,105 +222,13 @@ THREE.ShaderDeferred = {
"normalView = normalize( normalMatrix * objectNormal );",
"}"
].join("\n")
},
"bump" : {
uniforms: {
bumpMap: { type: "t", value: null },
bumpScale: { type: "f", value: 1 },
offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }
},
fragmentShader : [
"#extension GL_OES_standard_derivatives : enable\n",
"varying vec3 normalView;",
"varying vec2 vUv;",
"varying vec3 vViewPosition;",
THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
"#ifdef USE_BUMPMAP",
"void main() {",
"vec3 normal = normalize( normalView );",
"normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );",
"gl_FragColor = vec4( vec3( normal * 0.5 + 0.5 ), 1.0 );",
"}"
].join("\n"),
vertexShader : [
"vUv = uv * offsetRepeat.zw + offsetRepeat.xy;",
"vViewPosition = -mvPosition.xyz;",
"varying vec3 normalView;",
"varying vec2 vUv;",
"varying vec3 vViewPosition;",
"uniform vec4 offsetRepeat;",
"void main() {",
"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
"gl_Position = projectionMatrix * mvPosition;",
"normalView = normalize( normalMatrix * normal );",
"vUv = uv * offsetRepeat.zw + offsetRepeat.xy;",
"vViewPosition = -mvPosition.xyz;",
"}"
].join("\n")
},
"unlit" : {
uniforms: {
samplerDepth: { type: "t", value: null },
viewWidth: { type: "f", value: 800 },
viewHeight: { type: "f", value: 600 },
lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }
},
fragmentShader : [
"varying vec4 clipPos;",
"uniform sampler2D samplerDepth;",
"uniform float viewHeight;",
"uniform float viewWidth;",
"uniform vec3 lightColor;",
"void main() {",
"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
"float z = texture2D( samplerDepth, texCoord ).x;",
"vec4 color = vec4( lightColor, 1.0 );",
"float depth = clipPos.z / clipPos.w;",
"if( depth > z && z > 0.0 ) color.w = 0.0;",
"gl_FragColor = color;",
"}"
].join("\n"),
vertexShader : [
"varying vec4 clipPos;",
"void main() {",
"#endif",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"clipPos = gl_Position;",
"}"
......@@ -316,7 +242,7 @@ THREE.ShaderDeferred = {
uniforms: {
samplerLight: { type: "t", value: null },
multiply: { type: "f", value: 1 }
brightness: { type: "f", value: 1 }
},
......@@ -324,12 +250,12 @@ THREE.ShaderDeferred = {
"varying vec2 texCoord;",
"uniform sampler2D samplerLight;",
"uniform float multiply;",
"uniform float brightness;",
"void main() {",
"vec3 color = texture2D( samplerLight, texCoord ).xyz;",
"gl_FragColor = vec4( multiply * sqrt( color ), 1.0 );",
"gl_FragColor = vec4( brightness * sqrt( color ), 1.0 );",
"}"
......@@ -355,9 +281,8 @@ THREE.ShaderDeferred = {
uniforms: {
samplerNormals: { type: "t", value: null },
samplerDepth: { type: "t", value: null },
samplerColor: { type: "t", value: null },
samplerNormalDepth: { type: "t", value: null },
samplerColor: { type: "t", value: null },
matView: { type: "m4", value: new THREE.Matrix4() },
matProjInverse: { type: "m4", value: new THREE.Matrix4() },
viewWidth: { type: "f", value: 800 },
......@@ -375,8 +300,7 @@ THREE.ShaderDeferred = {
"varying vec4 clipPos;",
"uniform sampler2D samplerColor;",
"uniform sampler2D samplerDepth;",
"uniform sampler2D samplerNormals;",
"uniform sampler2D samplerNormalDepth;",
"uniform float lightRadius;",
"uniform float lightIntensity;",
......@@ -402,17 +326,10 @@ THREE.ShaderDeferred = {
"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
"float z = texture2D( samplerDepth, texCoord ).x;",
"float lightZ = clipPos.z / clipPos.w;",
/*
"if ( z == 0.0 ) {",
"gl_FragColor = vec4( vec3( 0.0 ), 1.0 );",
"return;",
"vec4 normalDepth = texture2D( samplerNormalDepth, texCoord );",
"}",
*/
"float z = normalDepth.w;",
"float lightZ = clipPos.z / clipPos.w;",
"if ( z == 0.0 || lightZ > z ) discard;",
......@@ -441,7 +358,7 @@ THREE.ShaderDeferred = {
// normal
"vec3 normal = texture2D( samplerNormals, texCoord ).xyz * 2.0 - 1.0;",
"vec3 normal = normalDepth.xyz * 2.0 - 1.0;",
// color
......@@ -449,20 +366,31 @@ THREE.ShaderDeferred = {
"vec3 albedo = float_to_vec3( abs( colorMap.x ) );",
"vec3 specularColor = float_to_vec3( abs( colorMap.y ) );",
"float shininess = colorMap.z;",
"float shininess = abs( colorMap.z );",
"float wrapAround = sign( colorMap.z );",
// wrap around lighting
// light
"vec3 diffuse;",
"float diffuseFull = max( dot( normal, lightDir ), 0.0 );",
"float diffuseHalf = max( 0.5 + 0.5 * dot( normal, lightDir ), 0.0 );",
"const vec3 wrapRGB = vec3( 0.6, 0.2, 0.2 );",
"vec3 diffuse = mix( vec3 ( diffuseFull ), vec3( diffuseHalf ), wrapRGB );",
"if ( wrapAround < 0.0 ) {",
// simple lighting
// wrap around lighting
//"float diffuseFull = max( dot( normal, lightDir ), 0.0 );",
//"vec3 diffuse = vec3 ( diffuseFull );",
"float diffuseHalf = max( 0.5 + 0.5 * dot( normal, lightDir ), 0.0 );",
"const vec3 wrapRGB = vec3( 0.6, 0.2, 0.2 );",
"diffuse = mix( vec3( diffuseFull ), vec3( diffuseHalf ), wrapRGB );",
"} else {",
// simple lighting
"diffuse = vec3( diffuseFull );",
"}",
// specular
......@@ -484,15 +412,17 @@ THREE.ShaderDeferred = {
"vec3 light = lightIntensity * lightColor;",
"#ifdef ADDITIVE_SPECULAR",
"float additiveSpecular = sign( colorMap.y );",
"if ( additiveSpecular < 0.0 ) {",
"gl_FragColor = vec4( albedo * light * diffuse, attenuation ) + vec4( light * specular, attenuation );",
"#else",
"} else {",
"gl_FragColor = vec4( albedo * light * ( diffuse + specular ), attenuation );",
"#endif",
"}",
"}"
......@@ -522,9 +452,8 @@ THREE.ShaderDeferred = {
uniforms: {
samplerNormals: { type: "t", value: null },
samplerDepth: { type: "t", value: null },
samplerColor: { type: "t", value: null },
samplerNormalDepth: { type: "t", value: null },
samplerColor: { type: "t", value: null },
matView: { type: "m4", value: new THREE.Matrix4() },
matProjInverse: { type: "m4", value: new THREE.Matrix4() },
viewWidth: { type: "f", value: 800 },
......@@ -541,8 +470,7 @@ THREE.ShaderDeferred = {
"varying vec4 clipPos;",
"uniform sampler2D samplerColor;",
"uniform sampler2D samplerDepth;",
"uniform sampler2D samplerNormals;",
"uniform sampler2D samplerNormalDepth;",
"uniform float lightRadius;",
"uniform float lightIntensity;",
......@@ -568,7 +496,8 @@ THREE.ShaderDeferred = {
"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
"float z = texture2D( samplerDepth, texCoord ).x;",
"vec4 normalDepth = texture2D( samplerNormalDepth, texCoord );",
"float z = normalDepth.w;",
"if ( z == 0.0 ) discard;",
......@@ -585,7 +514,7 @@ THREE.ShaderDeferred = {
// normal
"vec3 normal = texture2D( samplerNormals, texCoord ).xyz * 2.0 - 1.0;",
"vec3 normal = normalDepth.xyz * 2.0 - 1.0;",
// color
......@@ -665,7 +594,6 @@ THREE.ShaderDeferred = {
uniforms: {
samplerDepth: { type: "t", value: null },
samplerColor: { type: "t", value: null },
viewWidth: { type: "f", value: 800 },
viewHeight: { type: "f", value: 600 },
......@@ -674,7 +602,6 @@ THREE.ShaderDeferred = {
fragmentShader : [
"uniform sampler2D samplerDepth;",
"uniform sampler2D samplerColor;",
"uniform float viewHeight;",
......@@ -695,10 +622,6 @@ THREE.ShaderDeferred = {
"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
"float z = texture2D( samplerDepth, texCoord ).x;",
"if ( z == 0.0 ) discard;",
"vec4 colorMap = texture2D( samplerColor, texCoord );",
"vec3 emissiveColor = float_to_vec3( abs( colorMap.w ) );",
......
......@@ -121,10 +121,10 @@ THREE.CSS3DRenderer = function () {
epsilon( elements[ 1 ] ) + ',' +
epsilon( elements[ 2 ] ) + ',' +
epsilon( elements[ 3 ] ) + ',' +
epsilon( elements[ 4 ] ) + ',' +
epsilon( elements[ 5 ] ) + ',' +
epsilon( elements[ 6 ] ) + ',' +
epsilon( elements[ 7 ] ) + ',' +
epsilon( - elements[ 4 ] ) + ',' +
epsilon( - elements[ 5 ] ) + ',' +
epsilon( - elements[ 6 ] ) + ',' +
epsilon( - elements[ 7 ] ) + ',' +
epsilon( elements[ 8 ] ) + ',' +
epsilon( elements[ 9 ] ) + ',' +
epsilon( elements[ 10 ] ) + ',' +
......@@ -133,7 +133,7 @@ THREE.CSS3DRenderer = function () {
epsilon( elements[ 13 ] ) + ',' +
epsilon( elements[ 14 ] ) + ',' +
epsilon( elements[ 15 ] ) +
') scale3d(1,-1,1)';
')';
}
......@@ -146,6 +146,8 @@ THREE.CSS3DRenderer = function () {
this.domElement.style.oPerspective = fov + "px";
this.domElement.style.perspective = fov + "px";
var objects = _projector.projectScene( scene, camera, false ).objects;
var style = "translate3d(0,0," + fov + "px)" + getCameraCSSMatrix( camera.matrixWorldInverse ) + " translate3d(" + _widthHalf + "px," + _heightHalf + "px, 0)";
this.cameraElement.style.WebkitTransform = style;
......@@ -153,8 +155,6 @@ THREE.CSS3DRenderer = function () {
this.cameraElement.style.oTransform = style;
this.cameraElement.style.transform = style;
var objects = _projector.projectScene( scene, camera, false ).objects;
for ( var i = 0, il = objects.length; i < il; i ++ ) {
var object = objects[ i ].object;
......
......@@ -55,7 +55,7 @@ THREE.DOMRenderer = function () {
if ( element instanceof THREE.RenderableParticle && element.material instanceof THREE.ParticleDOMMaterial ) {
dom = element.material.domElement;
dom = element.material.element;
v1x = element.x * _widthHalf + _widthHalf - ( dom.offsetWidth >> 1 );
v1y = element.y * _heightHalf + _heightHalf - ( dom.offsetHeight >> 1 );
......
......@@ -14,8 +14,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var scaledWidth = Math.floor( scale * width );
var scaledHeight = Math.floor( scale * height );
var additiveSpecular = parameters.additiveSpecular;
var multiply = parameters.multiply;
var brightness = parameters.brightness;
this.renderer = parameters.renderer;
......@@ -23,7 +22,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
this.renderer = new THREE.WebGLRenderer( { alpha: false } );
this.renderer.setSize( width, height );
this.renderer.setClearColorHex( 0x000000, 1 );
this.renderer.setClearColorHex( 0x000000, 0 );
this.renderer.autoClear = false;
......@@ -39,9 +38,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var black = new THREE.Color( 0x000000 );
var colorShader = THREE.ShaderDeferred[ "color" ];
var normalShader = THREE.ShaderDeferred[ "normals" ];
var bumpShader = THREE.ShaderDeferred[ "bump" ];
var clipDepthShader = THREE.ShaderDeferred[ "clipDepth" ];
var normalDepthShader = THREE.ShaderDeferred[ "normalDepth" ];
//
......@@ -65,19 +62,11 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
//
var defaultNormalMaterial = new THREE.ShaderMaterial( {
var defaultNormalDepthMaterial = new THREE.ShaderMaterial( {
uniforms: THREE.UniformsUtils.clone( normalShader.uniforms ),
vertexShader: normalShader.vertexShader,
fragmentShader: normalShader.fragmentShader
} );
var defaultDepthMaterial = new THREE.ShaderMaterial( {
uniforms: THREE.UniformsUtils.clone( clipDepthShader.uniforms ),
vertexShader: clipDepthShader.vertexShader,
fragmentShader: clipDepthShader.fragmentShader
uniforms: THREE.UniformsUtils.clone( normalDepthShader.uniforms ),
vertexShader: normalDepthShader.vertexShader,
fragmentShader: normalDepthShader.fragmentShader
} );
......@@ -88,8 +77,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
if ( object.material instanceof THREE.MeshFaceMaterial ) {
var colorMaterials = [];
var depthMaterials = [];
var normalMaterials = [];
var normalDepthMaterials = [];
var materials = object.material.materials;
......@@ -98,22 +86,19 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var deferredMaterials = createDeferredMaterials( materials[ i ] );
colorMaterials.push( deferredMaterials.colorMaterial );
depthMaterials.push( deferredMaterials.depthMaterial );
normalMaterials.push( deferredMaterials.normalMaterial );
normalDepthMaterials.push( deferredMaterials.normalDepthMaterial );
}
object.properties.colorMaterial = new THREE.MeshFaceMaterial( colorMaterials );
object.properties.depthMaterial = new THREE.MeshFaceMaterial( depthMaterials );
object.properties.normalMaterial = new THREE.MeshFaceMaterial( normalMaterials );
object.properties.normalDepthMaterial = new THREE.MeshFaceMaterial( normalDepthMaterials );
} else {
var deferredMaterials = createDeferredMaterials( object.material );
object.properties.colorMaterial = deferredMaterials.colorMaterial;
object.properties.depthMaterial = deferredMaterials.depthMaterial;
object.properties.normalMaterial = deferredMaterials.normalMaterial;
object.properties.normalDepthMaterial = deferredMaterials.normalDepthMaterial;
}
......@@ -161,11 +146,15 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var specular = originalMaterial.specular !== undefined ? originalMaterial.specular : black;
var shininess = originalMaterial.shininess !== undefined ? originalMaterial.shininess : 1;
var wrapAround = originalMaterial.wrapAround !== undefined ? ( originalMaterial.wrapAround ? -1 : 1 ) : 1;
var additiveSpecular = originalMaterial.metal !== undefined ? ( originalMaterial.metal ? 1 : -1 ) : -1;
uniforms.emissive.value.copy( emissive );
uniforms.diffuse.value.copy( diffuse );
uniforms.specular.value.copy( specular );
uniforms.shininess.value = shininess;
uniforms.wrapAround.value = wrapAround;
uniforms.additiveSpecular.value = additiveSpecular;
uniforms.map.value = originalMaterial.map;
......@@ -186,77 +175,54 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
deferredMaterials.colorMaterial = material;
// normal material
// normal + depth material
// -----------------
// vertex normals
// morph normals
// bump map
// bump scale
// clip depth
if ( originalMaterial.bumpMap ) {
if ( originalMaterial.morphTargets || originalMaterial.bumpMap ) {
var uniforms = THREE.UniformsUtils.clone( bumpShader.uniforms );
var uniforms = THREE.UniformsUtils.clone( normalDepthShader.uniforms );
var defines = { "USE_BUMPMAP": !!originalMaterial.bumpMap };
var normalMaterial = new THREE.ShaderMaterial( {
var normalDepthMaterial = new THREE.ShaderMaterial( {
uniforms: uniforms,
vertexShader: bumpShader.vertexShader,
fragmentShader: bumpShader.fragmentShader,
defines: { "USE_BUMPMAP": true }
uniforms: uniforms,
vertexShader: normalDepthShader.vertexShader,
fragmentShader: normalDepthShader.fragmentShader,
shading: originalMaterial.shading,
defines: defines,
blending: THREE.NoBlending
} );
uniforms.bumpMap.value = originalMaterial.bumpMap;
uniforms.bumpScale.value = originalMaterial.bumpScale;
var offset = originalMaterial.bumpMap.offset;
var repeat = originalMaterial.bumpMap.repeat;
uniforms.offsetRepeat.value.set( offset.x, offset.y, repeat.x, repeat.y );
if ( originalMaterial.morphTargets ) {
deferredMaterials.normalMaterial = normalMaterial;
} else if ( originalMaterial.morphTargets ) {
var normalMaterial = new THREE.ShaderMaterial( {
uniforms: THREE.UniformsUtils.clone( normalShader.uniforms ),
vertexShader: normalShader.vertexShader,
fragmentShader: normalShader.fragmentShader,
shading: originalMaterial.shading
} );
normalMaterial.morphTargets = originalMaterial.morphTargets;
normalMaterial.morphNormals = originalMaterial.morphNormals;
deferredMaterials.normalMaterial = normalMaterial;
} else {
normalDepthMaterial.morphTargets = originalMaterial.morphTargets;
normalDepthMaterial.morphNormals = originalMaterial.morphNormals;
deferredMaterials.normalMaterial = defaultNormalMaterial;
}
// depth material
}
if ( originalMaterial.morphTargets ) {
if ( originalMaterial.bumpMap ) {
var depthMaterial = new THREE.ShaderMaterial( {
uniforms.bumpMap.value = originalMaterial.bumpMap;
uniforms.bumpScale.value = originalMaterial.bumpScale;
uniforms: THREE.UniformsUtils.clone( clipDepthShader.uniforms ),
vertexShader: clipDepthShader.vertexShader,
fragmentShader: clipDepthShader.fragmentShader
var offset = originalMaterial.bumpMap.offset;
var repeat = originalMaterial.bumpMap.repeat;
} );
uniforms.offsetRepeat.value.set( offset.x, offset.y, repeat.x, repeat.y );
depthMaterial.morphTargets = originalMaterial.morphTargets;
}
deferredMaterials.depthMaterial = depthMaterial;
deferredMaterials.normalDepthMaterial = normalDepthMaterial;
} else {
deferredMaterials.depthMaterial = defaultDepthMaterial;
deferredMaterials.normalDepthMaterial = defaultNormalDepthMaterial;
}
......@@ -273,7 +239,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
uniforms: THREE.UniformsUtils.clone( pointLightShader.uniforms ),
vertexShader: pointLightShader.vertexShader,
fragmentShader: pointLightShader.fragmentShader,
defines: { "ADDITIVE_SPECULAR": additiveSpecular },
blending: THREE.AdditiveBlending,
depthWrite: false,
......@@ -290,8 +255,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
materialLight.uniforms[ 'samplerNormals' ].value = compNormal.renderTarget2;
materialLight.uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
materialLight.uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
// create light proxy mesh
......@@ -316,7 +280,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
uniforms: THREE.UniformsUtils.clone( directionalLightShader.uniforms ),
vertexShader: directionalLightShader.vertexShader,
fragmentShader: directionalLightShader.fragmentShader,
defines: { "ADDITIVE_SPECULAR": additiveSpecular },
blending: THREE.AdditiveBlending,
depthWrite: false,
......@@ -332,8 +295,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
materialLight.uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
materialLight.uniforms[ 'samplerNormals' ].value = compNormal.renderTarget2;
materialLight.uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
// create light proxy mesh
......@@ -358,7 +320,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
vertexShader: emissiveLightShader.vertexShader,
fragmentShader: emissiveLightShader.fragmentShader,
depthTest: false,
depthWrite: false
depthWrite: false,
blending: THREE.NoBlending
} );
......@@ -367,7 +330,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
materialLight.uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
// create light proxy mesh
......@@ -412,15 +374,9 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
};
var setMaterialDepth = function ( object ) {
if ( object.material ) object.material = object.properties.depthMaterial;
};
var setMaterialNormal = function ( object ) {
var setMaterialNormalDepth = function ( object ) {
if ( object.material ) object.material = object.properties.normalMaterial;
if ( object.material ) object.material = object.properties.normalDepthMaterial;
};
......@@ -434,8 +390,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
scaledHeight = Math.floor( scale * height );
compColor.setSize( scaledWidth, scaledHeight );
compNormal.setSize( scaledWidth, scaledHeight );
compDepth.setSize( scaledWidth, scaledHeight );
compNormalDepth.setSize( scaledWidth, scaledHeight );
compLight.setSize( scaledWidth, scaledHeight );
compFinal.setSize( scaledWidth, scaledHeight );
......@@ -447,11 +402,10 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
uniforms[ "viewHeight" ].value = scaledHeight;
uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
if ( uniforms[ 'samplerNormals' ] ) {
if ( uniforms[ 'samplerNormalDepth' ] ) {
uniforms[ 'samplerNormals' ].value = compNormal.renderTarget2;
uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
}
......@@ -483,33 +437,33 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
lightSceneFullscreen = scene.properties.lightSceneFullscreen;
passColor.camera = camera;
passNormal.camera = camera;
passDepth.camera = camera;
passNormalDepth.camera = camera;
passLightProxy.camera = camera;
passLightFullscreen.camera = THREE.EffectComposer.camera;
passColor.scene = scene;
passNormal.scene = scene;
passDepth.scene = scene;
passNormalDepth.scene = scene;
passLightFullscreen.scene = lightSceneFullscreen;
passLightProxy.scene = lightSceneProxy;
scene.traverse( initDeferredProperties );
// update scene graph only once per frame
this.renderer.autoUpdateScene = false;
scene.updateMatrixWorld();
// g-buffer color
scene.traverse( setMaterialColor );
compColor.render();
// g-buffer depth
scene.traverse( setMaterialDepth );
compDepth.render();
// g-buffer normals + depth
// g-buffer normals
scene.traverse( setMaterialNormalDepth );
compNormalDepth.render();
scene.traverse( setMaterialNormal );
compNormal.render();
this.renderer.autoUpdateScene = true;
// light pass
......@@ -554,32 +508,36 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// g-buffers
var rtColor = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatNearest );
var rtNormal = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
var rtDepth = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
var rtNormalDepth = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
var rtLight = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
var rtFinal = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsUByte );
rtColor.generateMipmaps = false;
rtNormal.generateMipmaps = false;
rtDepth.generateMipmaps = false;
rtNormalDepth.generateMipmaps = false;
rtLight.generateMipmaps = false;
rtFinal.generateMipmaps = false;
// composers
// color composer
passColor = new THREE.RenderPass();
passColor.clear = true;
compColor = new THREE.EffectComposer( _this.renderer, rtColor );
compColor.addPass( passColor );
passNormal = new THREE.RenderPass();
compNormal = new THREE.EffectComposer( _this.renderer, rtNormal );
compNormal.addPass( passNormal );
// normal + depth composer
passNormalDepth = new THREE.RenderPass();
passNormalDepth.clear = true;
passDepth = new THREE.RenderPass();
compDepth = new THREE.EffectComposer( _this.renderer, rtDepth );
compDepth.addPass( passDepth );
compNormalDepth = new THREE.EffectComposer( _this.renderer, rtNormalDepth );
compNormalDepth.addPass( passNormalDepth );
// light composer
passLightFullscreen = new THREE.RenderPass();
passLightFullscreen.clear = true;
passLightProxy = new THREE.RenderPass();
passLightProxy.clear = false;
......@@ -587,11 +545,13 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
compLight.addPass( passLightFullscreen );
compLight.addPass( passLightProxy );
// composite
// final composer
compositePass = new THREE.ShaderPass( compositeShader );
compositePass.uniforms[ 'samplerLight' ].value = compLight.renderTarget2;
compositePass.uniforms[ 'multiply' ].value = multiply;
compositePass.uniforms[ 'brightness' ].value = brightness;
compositePass.material.blending = THREE.NoBlending;
compositePass.clear = true;
// FXAA
......
......@@ -111,7 +111,7 @@
// renderer
renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, multiply: 2, additiveSpecular: true } );
renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, brightness: 2 } );
renderer.domElement.style.position = "absolute";
renderer.domElement.style.top = MARGIN + "px";
......@@ -215,7 +215,7 @@
geometry.computeMorphNormals();
var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x333333, shininess: 20, morphTargets: true, morphNormals: true, vertexColors: THREE.NoColors, shading: THREE.FlatShading } );
var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x333333, shininess: 20, wrapAround: true, morphTargets: true, morphNormals: true, vertexColors: THREE.NoColors, shading: THREE.FlatShading } );
var meshAnim = new THREE.MorphAnimMesh( geometry, material );
meshAnim.duration = 3000;
......
......@@ -111,7 +111,7 @@
// renderer
renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, additiveSpecular: false, multiply: 2 } );
renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, brightness: 2 } );
renderer.domElement.style.position = "absolute";
renderer.domElement.style.top = MARGIN + "px";
......@@ -242,7 +242,7 @@
mapHeight.anisotropy = 4;
mapHeight.format = THREE.RGBFormat;
var material = new THREE.MeshPhongMaterial( { map: mapColor, bumpMap: mapHeight, bumpScale: 2.5, shininess: 75, specular: 0x090909 } );
var material = new THREE.MeshPhongMaterial( { map: mapColor, bumpMap: mapHeight, bumpScale: 2.5, shininess: 75, specular: 0x090909, wrapAround: true, metal: true } );
var object = new THREE.Mesh( geometry, material );
object.scale.multiplyScalar( 8 );
......@@ -254,7 +254,7 @@
var loader = new THREE.BinaryLoader();
loader.load( "obj/female02/Female02_bin.js", function( geometry, materials ) {
var material = new THREE.MeshPhongMaterial( { shininess: 175, specular: 0x999999 } );
for ( var i = 0; i < materials.length; i ++ ) materials[ i ].wrapAround = true;
var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
object.position.x = -50;
......@@ -266,7 +266,7 @@
loader.load( "obj/male02/Male02_bin.js", function( geometry, materials ) {
var material = new THREE.MeshPhongMaterial( { shininess: 175, specular: 0x999999 } );
for ( var i = 0; i < materials.length; i ++ ) materials[ i ].wrapAround = true;
var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
object.position.x = 50;
......@@ -306,7 +306,7 @@
var matPlane = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 50, bumpMap: mapHeight2, bumpScale: 0.5 } );
var matPlane2 = new THREE.MeshPhongMaterial( { color: 0x331919, specular: 0x111111, shininess: 50, bumpMap: mapHeight2, bumpScale: 1 } );
var matPlane3 = new THREE.MeshPhongMaterial( { color: 0x00aaff, specular: 0xffffff, shininess: 200, bumpMap: mapHeight3, bumpScale: 1.2 } );
var matPlane3 = new THREE.MeshPhongMaterial( { color: 0x00aaff, specular: 0xffffff, shininess: 200, bumpMap: mapHeight3, bumpScale: 1.2, wrapAround: true } );
var matPlane4 = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 50, bumpMap: mapHeight3, bumpScale: 1 } );
// bottom
......
......@@ -4,8 +4,6 @@
THREE.BufferGeometry = function () {
THREE.GeometryLibrary.push( this );
this.id = THREE.GeometryIdCount ++;
// attributes
......@@ -31,6 +29,8 @@ THREE.BufferGeometry = function () {
this.morphTargets = [];
THREE.GeometryLibrary[ this.id ] = this;
};
THREE.BufferGeometry.prototype = {
......@@ -69,7 +69,7 @@ THREE.BufferGeometry.prototype = {
computeBoundingBox: function () {
if ( ! this.boundingBox ) {
if ( this.boundingBox === null ) {
this.boundingBox = new THREE.Box3();
......@@ -141,8 +141,10 @@ THREE.BufferGeometry.prototype = {
computeBoundingSphere: function () {
if ( ! this.boundingSphere ) {
if ( this.boundingSphere === null ) {
this.boundingSphere = new THREE.Sphere();
}
var positions = this.attributes[ "position" ].array;
......@@ -251,15 +253,15 @@ THREE.BufferGeometry.prototype = {
ab.sub( pA, pB );
cb.crossSelf( ab );
normals[ vA * 3 ] += cb.x;
normals[ vA * 3 ] += cb.x;
normals[ vA * 3 + 1 ] += cb.y;
normals[ vA * 3 + 2 ] += cb.z;
normals[ vB * 3 ] += cb.x;
normals[ vB * 3 ] += cb.x;
normals[ vB * 3 + 1 ] += cb.y;
normals[ vB * 3 + 2 ] += cb.z;
normals[ vC * 3 ] += cb.x;
normals[ vC * 3 ] += cb.x;
normals[ vC * 3 + 1 ] += cb.y;
normals[ vC * 3 + 2 ] += cb.z;
......@@ -544,8 +546,7 @@ THREE.BufferGeometry.prototype = {
deallocate: function () {
var index = THREE.GeometryLibrary.indexOf( this );
if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
delete THREE.GeometryLibrary[ this.id ];
}
......
......@@ -9,8 +9,6 @@
THREE.Geometry = function () {
THREE.GeometryLibrary.push( this );
this.id = THREE.GeometryIdCount ++;
this.name = '';
......@@ -52,11 +50,13 @@ THREE.Geometry = function () {
this.buffersNeedUpdate = false;
THREE.GeometryLibrary[ this.id ] = this;
};
THREE.Geometry.prototype = {
constructor : THREE.Geometry,
constructor: THREE.Geometry,
applyMatrix: function ( matrix ) {
......@@ -577,12 +577,26 @@ THREE.Geometry.prototype = {
computeBoundingBox: function () {
this.boundingBox = new THREE.Box3().setFromPoints( this.vertices );
if ( this.boundingBox === null ) {
this.boundingBox = new THREE.Box3();
}
this.boundingBox.setFromPoints( this.vertices );
},
computeBoundingSphere: function () {
this.boundingSphere = new THREE.Sphere().setFromCenterAndPoints( new THREE.Vector3(), this.vertices );
if ( this.boundingSphere === null ) {
this.boundingSphere = new THREE.Sphere();
}
this.boundingSphere.setFromCenterAndPoints( this.boundingSphere.center, this.vertices );
},
/*
......@@ -724,12 +738,11 @@ THREE.Geometry.prototype = {
deallocate: function () {
var index = THREE.GeometryLibrary.indexOf( this );
if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
delete THREE.GeometryLibrary[ this.id ];
}
};
THREE.GeometryIdCount = 0;
THREE.GeometryLibrary = [];
THREE.GeometryLibrary = {};
......@@ -6,8 +6,6 @@
THREE.Object3D = function () {
THREE.Object3DLibrary.push( this );
this.id = THREE.Object3DIdCount ++;
this.name = '';
......@@ -49,6 +47,8 @@ THREE.Object3D = function () {
this._vector = new THREE.Vector3();
THREE.Object3DLibrary[ this.id ] = this;
};
......@@ -362,8 +362,7 @@ THREE.Object3D.prototype = {
deallocate: function () {
var index = THREE.Object3DLibrary.indexOf( this );
if ( index !== -1 ) THREE.Object3DLibrary.splice( index, 1 );
delete THREE.Object3DLibrary[ this.id ];
}
......@@ -373,4 +372,4 @@ THREE.Object3D.__m1 = new THREE.Matrix4();
THREE.Object3D.defaultEulerOrder = 'XYZ',
THREE.Object3DIdCount = 0;
THREE.Object3DLibrary = [];
THREE.Object3DLibrary = {};
......@@ -350,11 +350,6 @@ THREE.FontUtils.generateShapes = function( text, parameters ) {
/* output Triangle */
/*
result.push( contour[ a ] );
result.push( contour[ b ] );
result.push( contour[ c ] );
*/
result.push( [ contour[ a ],
contour[ b ],
contour[ c ] ] );
......@@ -402,34 +397,6 @@ THREE.FontUtils.generateShapes = function( text, parameters ) {
};
// see if p is inside triangle abc
var insideTriangle = function( ax, ay,
bx, by,
cx, cy,
px, py ) {
var aX, aY, bX, bY;
var cX, cY, apx, apy;
var bpx, bpy, cpx, cpy;
var cCROSSap, bCROSScp, aCROSSbp;
aX = cx - bx; aY = cy - by;
bX = ax - cx; bY = ay - cy;
cX = bx - ax; cY = by - ay;
apx= px -ax; apy= py - ay;
bpx= px - bx; bpy= py - by;
cpx= px - cx; cpy= py - cy;
aCROSSbp = aX*bpy - aY*bpx;
cCROSSap = cX*apy - cY*apx;
bCROSScp = bX*cpy - bY*cpx;
return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) );
};
var snip = function ( contour, u, v, w, n, verts ) {
var p;
......@@ -447,18 +414,36 @@ THREE.FontUtils.generateShapes = function( text, parameters ) {
if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false;
for ( p = 0; p < n; p++ ) {
var aX, aY, bX, bY, cX, cY;
var apx, apy, bpx, bpy, cpx, cpy;
var cCROSSap, bCROSScp, aCROSSbp;
aX = cx - bx; aY = cy - by;
bX = ax - cx; bY = ay - cy;
cX = bx - ax; cY = by - ay;
for ( p = 0; p < n; p++ ) {
if( (p === u) || (p === v) || (p === w) ) continue;
if( (p == u) || (p == v) || (p == w) ) continue;
px = contour[ verts[ p ] ].x
py = contour[ verts[ p ] ].y
px = contour[ verts[ p ] ].x
py = contour[ verts[ p ] ].y
apx = px - ax; apy = py - ay;
bpx = px - bx; bpy = py - by;
cpx = px - cx; cpy = py - cy;
if ( insideTriangle( ax, ay, bx, by, cx, cy, px, py ) ) return false;
// see if p is inside triangle abc
}
aCROSSbp = aX*bpy - aY*bpx;
cCROSSap = cX*apy - cY*apx;
bCROSScp = bX*cpy - bY*cpx;
if ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) ) return false;
}
return true;
return true;
};
......
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* Extensible curve object
*
*
* Some common of Curve methods
* .getPoint(t), getTangent(t)
* .getPointAt(u), getTagentAt(u)
......@@ -110,8 +110,8 @@ THREE.Curve.prototype.getLengths = function ( divisions ) {
if ( !divisions ) divisions = (this.__arcLengthDivisions) ? (this.__arcLengthDivisions): 200;
if ( this.cacheArcLengths
&& ( this.cacheArcLengths.length == divisions + 1 )
if ( this.cacheArcLengths
&& ( this.cacheArcLengths.length == divisions + 1 )
&& !this.needsUpdate) {
//console.log( "cached", this.cacheArcLengths );
......@@ -231,22 +231,10 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
};
// In 2D space, there are actually 2 normal vectors,
// and in 3D space, infinte
// TODO this should be depreciated.
THREE.Curve.prototype.getNormalVector = function( t ) {
var vec = this.getTangent( t );
return new THREE.Vector2( -vec.y , vec.x );
};
// Returns a unit vector tangent at t
// In case any sub curve does not implement its tangent / normal finding,
// we get 2 points with a small delta and find a gradient of the 2 points
// which seems to make a reasonable approximation
// In case any sub curve does not implement its tangent derivation,
// 2 points a small delta apart will be used to find its gradient
// which seems to give a reasonable approximation
THREE.Curve.prototype.getTangent = function( t ) {
......@@ -261,7 +249,7 @@ THREE.Curve.prototype.getTangent = function( t ) {
var pt1 = this.getPoint( t1 );
var pt2 = this.getPoint( t2 );
var vec = pt2.clone().subSelf(pt1);
return vec.normalize();
......@@ -715,7 +703,7 @@ THREE.SplineCurve3 = THREE.Curve.create(
// v.z = THREE.Curve.Utils.tangentSpline( t, pt0.z, pt1.z, pt2.z, pt3.z );
// return v;
// }
/**************************************************************
......@@ -741,7 +729,7 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create(
intPoint = Math.floor( point );
weight = point - intPoint;
intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length;
c[ 0 ] = ( intPoint - 1 ) % points.length;
c[ 1 ] = ( intPoint ) % points.length;
......@@ -751,7 +739,7 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create(
v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight );
return v;
}
......
......@@ -420,6 +420,12 @@ THREE.Loader.prototype = {
var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
var material = new THREE.ShaderMaterial( parameters );
if ( mpars.transparent ) {
material.transparent = true;
}
} else {
var material = new THREE[ mtype ]( mpars );
......
......@@ -5,8 +5,6 @@
THREE.Material = function () {
THREE.MaterialLibrary.push( this );
this.id = THREE.MaterialIdCount ++;
this.name = '';
......@@ -37,6 +35,8 @@ THREE.Material = function () {
this.needsUpdate = true;
THREE.MaterialLibrary[ this.id ] = this;
};
THREE.Material.prototype.setValues = function ( values ) {
......@@ -118,10 +118,9 @@ THREE.Material.prototype.clone = function ( material ) {
THREE.Material.prototype.deallocate = function () {
var index = THREE.MaterialLibrary.indexOf( this );
if ( index !== -1 ) THREE.MaterialLibrary.splice( index, 1 );
delete THREE.MaterialLibrary[ this.id ];
};
THREE.MaterialIdCount = 0;
THREE.MaterialLibrary = [];
THREE.MaterialLibrary = {};
......@@ -65,20 +65,19 @@ THREE.Math = {
return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 );
}
degreesToRadians: function( degrees ) {
},
return degrees * THREE.Math.__d2r;
degreesToRadians: function ( degrees ) {
};
return degrees * THREE.Math.__d2r;
radiansToDegrees: function( radians ) {
},
return radians * THREE.Math.__r2d;
radiansToDegrees: function ( radians ) {
};
return radians * THREE.Math.__r2d;
}
};
......
......@@ -4,19 +4,9 @@
THREE.Sphere = function ( center, radius ) {
this.center = center === undefined ? new THREE.Vector3() : center.clone();
this.radius = radius === undefined ? 0 : radius;
if ( center === undefined && radius === undefined ) {
this.center = new THREE.Vector3();
this.radius = 0;
} else {
this.center = center.clone();
this.radius = radius || 0;
}
};
THREE.Sphere.prototype = {
......@@ -29,7 +19,6 @@ THREE.Sphere.prototype = {
this.radius = radius;
return this;
},
setFromCenterAndPoints: function ( center, points ) {
......
......@@ -268,19 +268,16 @@ THREE.ShaderChunk = {
"#ifdef USE_MAP",
"vec4 texelColor = texture2D( map, vUv );",
"#ifdef GAMMA_INPUT",
"vec4 texelColor = texture2D( map, vUv );",
"texelColor.xyz *= texelColor.xyz;",
"gl_FragColor = gl_FragColor * texelColor;",
"#else",
"gl_FragColor = gl_FragColor * texture2D( map, vUv );",
"#endif",
"gl_FragColor = gl_FragColor * texelColor;",
"#endif"
].join("\n"),
......
......@@ -6,8 +6,6 @@
THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
THREE.TextureLibrary.push( this );
this.id = THREE.TextureIdCount ++;
this.name = '';
......@@ -39,6 +37,8 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
this.needsUpdate = false;
this.onUpdate = null;
THREE.TextureLibrary[ this.id ] = this;
};
THREE.Texture.prototype = {
......@@ -79,12 +79,11 @@ THREE.Texture.prototype = {
deallocate: function () {
var index = THREE.TextureLibrary.indexOf( this );
if ( index !== -1 ) THREE.TextureLibrary.splice( index, 1 );
delete THREE.TextureLibrary[ this.id ];
}
};
THREE.TextureIdCount = 0;
THREE.TextureLibrary = [];
THREE.TextureLibrary = {};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册