提交 92dc9c58 编写于 作者: N Neha Agarwal

Merge pull request #2 from mrdoob/dev

Dev
{
"name": "three.js",
"version": "0.0.71",
"homepage": "http://threejs.org/",
"description": "JavaScript 3D library",
"main": "build/three.js",
......
......@@ -10012,14 +10012,11 @@ THREE.DirectGeometry.prototype = {
},
fromGeometry: function ( geometry, material ) {
material = material || { 'vertexColors': THREE.NoColors };
fromGeometry: function ( geometry ) {
var faces = geometry.faces;
var vertices = geometry.vertices;
var faceVertexUvs = geometry.faceVertexUvs;
var materialVertexColors = material.vertexColors;
var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;
var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
......@@ -10085,11 +10082,11 @@ THREE.DirectGeometry.prototype = {
var vertexColors = face.vertexColors;
if ( materialVertexColors === THREE.VertexColors ) {
if ( vertexColors.length === 3 ) {
this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );
} else if ( materialVertexColors === THREE.FaceColors ) {
} else {
var color = face.color;
......@@ -10452,9 +10449,9 @@ THREE.BufferGeometry.prototype = {
},
fromGeometry: function ( geometry, material ) {
fromGeometry: function ( geometry ) {
geometry.__directGeometry = new THREE.DirectGeometry().fromGeometry( geometry, material );
geometry.__directGeometry = new THREE.DirectGeometry().fromGeometry( geometry );
return this.fromDirectGeometry( geometry.__directGeometry );
......@@ -15669,6 +15666,36 @@ THREE.Texture.prototype = {
}
function getDataURL( image ) {
var canvas;
if ( image.toDataURL !== undefined ) {
canvas = image;
} else {
canvas = document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext( '2d' ).drawImage( image, 0, 0, image.width, image.height );
}
if ( canvas.width > 2048 || canvas.height > 2048 ) {
return canvas.toDataURL( 'image/jpeg', 0.6 );
} else {
return canvas.toDataURL( 'image/png' );
}
}
var output = {
metadata: {
version: 4.4,
......@@ -15702,28 +15729,12 @@ THREE.Texture.prototype = {
}
if ( meta.images[ this.image.uuid ] === undefined ) {
var canvas = document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext( '2d' );
context.drawImage( image, 0, 0, image.width, image.height );
var src;
if ( meta.images[ image.uuid ] === undefined ) {
if ( image.width > 2048 || image.height > 2048 ) {
src = canvas.toDataURL( 'image/jpeg', 0.6 );
} else {
src = canvas.toDataURL( 'image/png' );
}
meta.images[ this.image.uuid ] = { uuid: this.image.uuid, url: src };
meta.images[ image.uuid ] = {
uuid: image.uuid,
url: getDataURL( image )
};
}
......@@ -23326,9 +23337,11 @@ THREE.WebGLObjects = function ( gl, info ) {
if ( material.program !== undefined ) {
if ( material.program.uniforms.morphTargetInfluences !== null ) {
var uniforms = material.program.getUniforms();
if ( uniforms.morphTargetInfluences !== null ) {
gl.uniform1fv( material.program.uniforms.morphTargetInfluences, morphInfluences );
gl.uniform1fv( uniforms.morphTargetInfluences, morphInfluences );
}
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -34,6 +34,14 @@
<h2>Methods</h2>
<h3>[method:Vector3 getWorldDirection]([page:Vector3 vector])</h3>
<div>
vector — (optional)<br />
<br />
It returns a vector representing the direction in which the camera is looking, in world space.
</div>
<h3>[method:null lookAt]( [page:Vector3 vector] )</h3>
<div>
......@@ -41,6 +49,13 @@
<br />
This makes the camera look at the vector position in the global space as long as the parent of this camera is the scene or at position (0,0,0).
</div>
<h3>[method:Camera clone]( [page:Camera camera] )</h3>
<div>
camera — camera to clone<br />
<br />
It returns a clone of camera.
</div>
<h2>Source</h2>
......
......@@ -17,7 +17,7 @@
<div>[example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]</div>
<div>[example:webgl_materials_cubemap_dynamic2 materials / cubemap / dynamic2 ]</div>
<div>[example:webgl_materials_cubemap_dynamic2 shading / physical ]</div>
<div>[example:webgl_shading_physical shading / physical ]</div>
<code>//Create cube camera
var cubeCamera = new THREE.CubeCamera( 1, 100000, 128 );
......
......@@ -15,7 +15,21 @@
<h2>Example</h2>
<div>[example:canvas_camera_orthographic camera / orthographic ]</div>
<div>[example:canvas_camera_orthographic2 camera / orthographic2 ]</div>
<div>[example:webgl_camera camera ]</div>
<div>[example:webgl_interactive_cubes_ortho interactive / cubes / ortho ]</div>
<div>[example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]</div>
<div>[example:webgl_materials_normaldisplacementmap materials / normaldisplacementmap ]</div>
<div>[example:webgl_postprocessing_advanced postprocessing / advanced ]</div>
<div>[example:webgl_postprocessing_dof2 postprocessing / dof2 ]</div>
<div>[example:webgl_postprocessing_godrays postprocessing / godrays ]</div>
<div>[example:webgl_rtt rtt ]</div>
<div>[example:webgl_shaders_tonemapping shaders / tonemapping ]</div>
<div>[example:webgl_shadowmap shadowmap ]</div>
<div>[example:webgl_terrain_dynamic terrain / dynamic ]</div>
<code>var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
scene.add( camera );</code>
......@@ -36,6 +50,9 @@ scene.add( camera );</code>
<h2>Properties</h2>
<h3>[property:number zoom]</h3>
<div>Gets or sets the zoom factor of the camera. </div>
<h3>[property:Float left]</h3>
<div>Camera frustum left plane.</div>
......@@ -61,6 +78,18 @@ scene.add( camera );</code>
<div>
Updates the camera projection matrix. Must be called after change of parameters.
</div>
<h3>[method:OrthographicCamera clone]()</h3>
<div>
<br />
It returns a clone of OrthographicCamera.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return camera data in JSON format.
</div>
<h2>Source</h2>
......
......@@ -15,7 +15,15 @@
<h2>Example</h2>
<div>[example:canvas_effects_stereo effects / stereo ]</div>
<div>[example:canvas_geometry_birds geometry / birds ]</div>
<div>[example:canvas_geometry_cube geometry / cube ]</div>
<div>[example:webgl_animation_skinning_blending animation / skinning / blending ]</div>
<div>[example:webgl_animation_skinning_morph animation / skinning / blending ]</div>
<div>[example:webgl_interactive_cubes interactive / cubes ]</div>
<div>[example:webgl_loader_collada_skinning loader / collada / skinning ]</div>
<code>var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
scene.add( camera );</code>
......@@ -33,6 +41,9 @@ scene.add( camera );</code>
<h2>Properties</h2>
<h3>[property:number zoom]</h3>
<div>Gets or sets the zoom factor of the camera. </div>
<h3>[property:Float fov]</h3>
<div>Camera frustum vertical field of view, from bottom to top of view, in degrees.</div>
......@@ -110,7 +121,17 @@ camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
<div>
Updates the camera projection matrix. Must be called after change of parameters.
</div>
<h3>[method:PerspectiveCamera clone]()</h3>
<div>
<br />
It returns a clone of PerspectiveCamera.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return camera data in JSON format.
</div>
<h2>Source</h2>
......
......@@ -16,7 +16,14 @@
Use this only if you do not wish to manage
both an Orthographic and Perspective Camera</div>
<h2>Examples</h2>
<div>[example:canvas_camera_orthographic2 camera / orthographic2 ]</div>
<code>//Create combined camera
camera = new THREE.CombinedCamera( window.innerWidth / 2, window.innerHeight / 2, 70, 1, 1000, - 500, 1000 );
</code>
<h2>Constructor</h2>
......@@ -79,6 +86,11 @@
Gets camera frustum far plane.
</div>
<h3>[property:Matrix4 projectionMatrix]</h3>
<div>
This is the matrix which contains the projection.
</div>
<h3>[property:OrthographicCamera cameraO]</h3>
<div>
Gets or sets the internal OrthographicCamera used as camera.
......@@ -182,6 +194,6 @@
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/cameras/CombinedCamera.js examples/cameras/CombinedCamera.js]
</body>
</html>
......@@ -39,9 +39,16 @@
<h2>Properties</h2>
<div>
Each of the constructor parameters is accessible as a property of the same name. Any modification of these properties after instantiation does not change the geometry.
</div>
<h3>.parameters</h3>
<div>
<p>Using the above example code above as our basis:</p>
<code>
geometry.parameters; // outputs an object {width: 1, height: 1, depth: 1, widthSegments: undefined, heightSegments: undefined}
cube.geometry.parameters; // as above
cube.geometry.parameters.width; // === 1
cube.geometry.parameters.widthSegments // === undefined.
</code>
</div>
<h2>Source</h2>
......
......@@ -17,7 +17,13 @@
<h2>Example</h2>
<div>[example:canvas_camera_orthographic camera / orthographic ]</div>
<div>[example:canvas_interactive_voxelpainter interactive / voxelpainter ]</div>
<div>[example:canvas_materials materials ]</div>
<div>[example:canvas_sandbox sandbox ]</div>
<div>[example:webgl_animation_cloth animation / cloth ]</div>
<div>[example:webgl_animation_skinning_blending animation / skinning / blending ]</div>
<code>var light = new THREE.AmbientLight( 0x404040 ); // soft white light
scene.add( light );</code>
......@@ -32,7 +38,19 @@ scene.add( light );</code>
This creates an Ambientlight with a color.
</div>
<h2>Methods</h2>
<h3>[method:AmbientLight clone]()</h3>
<div>
<br />
It returns a clone of Ambientlight.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return Ambientlight data in JSON format.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -15,6 +15,10 @@
<h2>Example</h2>
<h2>Example</h2>
<div>[example:webgldeferred_arealights arealights ]</div>
<code>areaLight1 = new THREE.AreaLight( 0xffffff, 1 );
areaLight1.position.set( 0.0001, 10.0001, -18.5001 );
areaLight1.rotation.set( -0.74719, 0.0001, 0.0001 );
......@@ -80,8 +84,7 @@ scene.add( areaLight1 );</code>
<div>
Sets or gets the attention of the light in linear space. This increases the attenuation quadratic with the distance from the light.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -17,7 +17,16 @@
<h2>Example</h2>
<div>[example:canvas_morphtargets_horse morphtargets / horse ]</div>
<div>[example:misc_controls_fly controls / fly ]</div>
<div>[example:misc_lights_test lights / test ]</div>
<div>[example:vr_cubes cubes ]</div>
<div>[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]</div>
<div>[example:webgl_effects_stereo effects / stereo ]</div>
<div>[example:webgl_geometry_extrude_splines geometry / extrude / splines ]</div>
<div>[example:webgl_materials_bumpmap materials / bumpmap ]</div>
<div>[example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection ]</div>
<code>// White directional light at half intensity shining from the top.
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
......@@ -58,7 +67,13 @@ scene.add( directionalLight );</code>
If set to *true* light will only cast shadow but not contribute any lighting (as if *intensity* was 0 but cheaper to compute).<br />
Default — *false*.
</div>
<h3>[property:Boolean castShadow]</h3>
<div>
If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right.<br />
Default — *false*.
</div>
<h3>[property:Float shadowCameraNear]</h3>
<div>
Orthographic shadow camera frustum parameter.<br />
......@@ -199,8 +214,16 @@ scene.add( directionalLight );</code>
</div>
<h2>Methods</h2>
<h3>[method:DirectionalLight clone]()</h3>
<div>
It returns a clone of DirectionalLight.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return DirectionalLight data in JSON format.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -12,6 +12,18 @@
<h1>[name]</h1>
<div class="desc">A light source positioned directly above the scene.</div>
<h2>Example</h2>
<div>[example:webgl_lights_hemisphere lights / hemisphere ]</div>
<div>[example:misc_controls_pointerlock controls / pointerlock ]</div>
<div>[example:webgl_decals decals ]</div>
<div>[example:webgl_loader_collada_kinematics loader / collada / kinematics ]</div>
<div>[example:webgl_materials_lightmap materials / lightmap ]</div>
<div>[example:webgl_shaders_ocean shaders / ocean ]</div>
<code>var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 );
scene.add( light );</code>
<h2>Constructor</h2>
......@@ -38,7 +50,17 @@
</div>
<h2>Methods</h2>
<h3>[method:HemisphereLight clone]()</h3>
<div>
<br />
It returns a clone of HemisphereLight.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return HemisphereLight data in JSON format.
</div>
<h2>Source</h2>
......
......@@ -32,7 +32,15 @@
<div>
Color of the light.<br />
</div>
<h2>Methods</h2>
<h3>[method:Light clone]()</h3>
<div>
<br />
It returns a clone of Light.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -18,6 +18,16 @@
<h2>Example</h2>
<div>[example:canvas_lights_pointlights lights / pointlights ]</div>
<div>[example:webgl_lights_pointlights lights / pointlights ]</div>
<div>[example:webgl_lights_pointlights2 lights / pointlights2 ]</div>
<div>[example:webgldeferred_animation animation ]</div>
<div>[example:webgldeferred_pointlights pointlights ]</div>
<div>[example:webgl_effects_anaglyph effects / anaglyph ]</div>
<div>[example:webgl_geometry_large_mesh geometry / large / mesh ]</div>
<div>[example:webgl_geometry_text geometry / text ]</div>
<div>[example:webgl_lensflares lensflares ]</div>
<code>var light = new THREE.PointLight( 0xff0000, 1, 100 );
light.position.set( 50, 50, 50 );
scene.add( light );</code>
......@@ -26,11 +36,12 @@ scene.add( light );</code>
<h2>Constructor</h2>
<h3>[name]([page:Integer hex], [page:Float intensity], [page:Number distance])</h3>
<h3>[name]([page:Integer hex], [page:Float intensity], [page:Number distance], [page:Float decay])</h3>
<div>
[page:Integer hex] — Numeric value of the RGB component of the color. <br />
[page:Float intensity] — Numeric value of the light's strength/intensity. <br />
[page:Number distance] -- The distance of the light where the intensity is 0. When distance is 0, then the distance is endless.
[page:Number distance] -- The distance of the light where the intensity is 0. When distance is 0, then the distance is endless. <br />
[page:Float decay] -- The amount the light dims along the distance of the light.
</div>
<div>
Creates a light at a specific position in the scene. The light shines in all directions (roughly similar to a light bulb.)
......@@ -52,7 +63,24 @@ scene.add( light );</code>
Default — *0.0*.
</div>
<h3>[property:Float decay]</h3>
<div>
The amount the light dims along the distance of the light<br />
Default — *1*.
</div>
<h2>Methods</h2>
<h3>[method:PointLight clone]()</h3>
<div>
<br />
It returns a clone of PointLight.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return PointLight data in JSON format.
</div>
<h2>Source</h2>
......
......@@ -17,7 +17,13 @@
<h2>Example</h2>
<div>[example:webgl_interactive_cubes_gpu interactive / cubes / gpu ]</div>
<div>[example:webgl_interactive_draggablecubes interactive / draggablecubes ]</div>
<div>[example:webgl_materials_bumpmap_skin materials / bumpmap / skin ]</div>
<div>[example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]</div>
<div>[example:webgl_morphtargets_md2 morphtargets / md2 ]</div>
<div>[example:webgl_shading_physical shading / physical ]</div>
<code>
// white spotlight shining from the side, casting shadow
......@@ -178,7 +184,16 @@
</div>
<h2>Methods</h2>
<h3>[method:SpotLight clone]()</h3>
<div>
<br />
It returns a clone of SpotLight.
</div>
<h3>[method:JSON toJSON]()</h3>
<div>
Return SpotLight data in JSON format.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -312,6 +312,7 @@
"webgl_multiple_canvases_circle",
"webgl_multiple_canvases_complex",
"webgl_multiple_canvases_grid",
"webgl_multiple_elements",
"webgl_multiple_views",
"webgl_nearestneighbour",
"webgl_octree",
......
......@@ -112,7 +112,7 @@
window.addEventListener( 'resize', onWindowResize, false );
window.addEventListener( "keypress", onKeyPress, true);
window.addEventListener( "keydown", onKeyDown, true);
}
......@@ -272,7 +272,7 @@
}
function onKeyPress ( e ) {
function onKeyDown ( e ) {
var maps = [ 'rainbow', 'cooltowarm', 'blackbody', 'grayscale' ];
......
......@@ -132,7 +132,7 @@
function onload() {
window.addEventListener( 'resize', onWindowResize, false );
document.addEventListener( 'keypress', function(e) { onKeyPress(e); }, false );
document.addEventListener( 'keydown', function(e) { onKeyDown(e); }, false );
buildSceneList();
switchScene(0);
......@@ -343,7 +343,7 @@
renderer.render( scene, camera );
}
function onKeyPress(event) {
function onKeyDown(event) {
var chr = String.fromCharCode(event.keyCode);
......
......@@ -233,7 +233,7 @@
var y = ( i - dst.length / 2 ) * 110 + 50;
var mesh = new THREE.Mesh( geo1, material );
mesh.position.set( x, y, z );
mesh.position.set( x, -y, z );
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
scene.add( mesh );
......@@ -269,7 +269,7 @@
var y = ( i - dst.length / 2 ) * 110 + 165;
var mesh = new THREE.Mesh( geo2, generateLabelMaterial( blendDst.replace( "Factor", "" ), "rgba( 150, 0, 0, 1 )" ) );
mesh.position.set( x, - (y - 70), z );
mesh.position.set( x, - (y - 120), z );
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
scene.add( mesh );
......
......@@ -62,13 +62,7 @@
var loader = new THREE.JSONLoader( true );
loader.load( "models/animated/horse.js", function( geometry ) {
var material = new THREE.MeshPhongMaterial( {
color: 0x606060,
shading: THREE.FlatShading,
morphTargets: true
} );
mesh = new THREE.Mesh( geometry, material );
mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0x606060, morphTargets: true } ) );
mesh.scale.set( 1.5, 1.5, 1.5 );
scene.add( mesh );
......
......@@ -30,11 +30,10 @@
position: absolute;
top: 0px; width: 100%;
z-index: 1;
padding: 2em;
padding: 3em 0 0 0;
}
a {
color: #0080ff;
}
......@@ -46,47 +45,30 @@
}
.list-item {
display: inline-block;
margin: 1em;
padding: 2em;
display: -webkit-flex;
display: flex;
flex-direction: row;
-webkit-flex-direction: row;
padding: 1em;
box-shadow: 1px 2px 4px 0px rgba(0,0,0,0.25);
}
.list-item .scene {
width: 200px;
height: 200px;
flex: 0 0 auto;
-webkit-flex: 0 0 auto;
}
.list-item .description {
color: #888;
font-family: sans-serif;
font-size: large;
padding-left: 2em;
flex: 1 1 auto;
-webkit-flex: 1 1 auto;
}
@media only screen and (max-width : 600px) {
#content {
width: 100%;
}
.list-item {
margin: 0.5em;
padding: 0.5em;
flex-direction: column;
-webkit-flex-direction: column;
}
.list-item .description {
padding-left: 0em;
}
width: 200px;
margin-top: 0.5em;
}
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="content">
<div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - multiple elements - webgl</div>
</div>
......@@ -97,7 +79,7 @@
<script id="template" type="notjs">
<div class="scene"></div>
<div class="description">some random text about this object, scene, whatever</div>
<div class="description">Scene $</div>
</script>
<script>
......@@ -114,8 +96,8 @@
canvas = document.getElementById( "c" );
camera = new THREE.PerspectiveCamera( 75, 1, 0.1, 100 );
camera.position.z = 1.5;
camera = new THREE.PerspectiveCamera( 50, 1, 0.1, 100 );
camera.position.z = 2;
var geometries = [
new THREE.BoxGeometry( 1, 1, 1 ),
......@@ -129,37 +111,32 @@
var emptyScene = new THREE.Scene();
var numScenes = 100;
for ( var ii = 0; ii < numScenes; ++ii ) {
for ( var i = 0; i < 100; i ++ ) {
var scene = new THREE.Scene();
// make a list item.
// make a list item
var element = document.createElement( "div" );
element.innerHTML = template;
element.className = "list-item";
element.innerHTML = template.replace('$', i + 1 );
// Look up the element that represents the area
// we want to render the scene
scene.element = element.querySelector(".scene");
content.appendChild(element);
content.appendChild( element );
// add one random mesh to each scene
var geometry = geometries[ geometries.length * Math.random() | 0 ];
var material = new THREE.MeshLambertMaterial( { color: randColor() } );
var material = new THREE.MeshLambertMaterial( { color: 0xffffff * Math.random() } );
scene.add( new THREE.Mesh( geometry, material ) );
light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0.5, 0.8, 1 );
scene.add( light );
light = new THREE.DirectionalLight( 0xffffff );
light.position.set( -0.5, -0.8, -1 );
light = new THREE.HemisphereLight( 0xffbbbb, 0x444488 );
light.position.set( - 0.5, 0.8, 1 );
scene.add( light );
scenes.push( scene );
}
......@@ -232,23 +209,6 @@
}
function rand( min, max ) {
if ( max == undefined ) {
max = min;
min = 0;
}
return Math.random() * ( max - min ) + min;
}
function randColor() {
var colors = [ rand( 256 ), rand ( 256 ), rand( 256 ) ];
colors[ Math.random() * 3 | 0 ] = 255;
return ( colors[0] << 16 ) |
( colors[1] << 8 ) |
( colors[2] << 0 ) ;
}
</script>
</body>
......
......@@ -253,9 +253,9 @@ THREE.BufferGeometry.prototype = {
},
fromGeometry: function ( geometry, material ) {
fromGeometry: function ( geometry ) {
geometry.__directGeometry = new THREE.DirectGeometry().fromGeometry( geometry, material );
geometry.__directGeometry = new THREE.DirectGeometry().fromGeometry( geometry );
return this.fromDirectGeometry( geometry.__directGeometry );
......
......@@ -61,14 +61,11 @@ THREE.DirectGeometry.prototype = {
},
fromGeometry: function ( geometry, material ) {
material = material || { 'vertexColors': THREE.NoColors };
fromGeometry: function ( geometry ) {
var faces = geometry.faces;
var vertices = geometry.vertices;
var faceVertexUvs = geometry.faceVertexUvs;
var materialVertexColors = material.vertexColors;
var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;
var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
......@@ -134,11 +131,11 @@ THREE.DirectGeometry.prototype = {
var vertexColors = face.vertexColors;
if ( materialVertexColors === THREE.VertexColors ) {
if ( vertexColors.length === 3 ) {
this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );
} else if ( materialVertexColors === THREE.FaceColors ) {
} else {
var color = face.color;
......
......@@ -5,8 +5,6 @@
THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
console.log( 'THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint.' );
THREE.Geometry.call( this );
this.type = 'PlaneGeometry';
......
......@@ -159,9 +159,9 @@ THREE.Mesh.prototype.raycast = ( function () {
distance: distance,
point: intersectionPoint,
face: new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) ),
faceIndex: null,
faceIndex: Math.floor(i/3), // triangle number in indices buffer semantics
object: this
} );
}
......@@ -205,7 +205,7 @@ THREE.Mesh.prototype.raycast = ( function () {
distance: distance,
point: intersectionPoint,
face: new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) ),
faceIndex: null,
index: Math.floor(i/3), // triangle number in positions buffer semantics
object: this
} );
......
......@@ -160,9 +160,11 @@ THREE.WebGLObjects = function ( gl, info ) {
if ( material.program !== undefined ) {
if ( material.program.uniforms.morphTargetInfluences !== null ) {
var uniforms = material.program.getUniforms();
gl.uniform1fv( material.program.uniforms.morphTargetInfluences, morphInfluences );
if ( uniforms.morphTargetInfluences !== null ) {
gl.uniform1fv( uniforms.morphTargetInfluences, morphInfluences );
}
......
......@@ -103,6 +103,36 @@ THREE.Texture.prototype = {
}
function getDataURL( image ) {
var canvas;
if ( image.toDataURL !== undefined ) {
canvas = image;
} else {
canvas = document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext( '2d' ).drawImage( image, 0, 0, image.width, image.height );
}
if ( canvas.width > 2048 || canvas.height > 2048 ) {
return canvas.toDataURL( 'image/jpeg', 0.6 );
} else {
return canvas.toDataURL( 'image/png' );
}
}
var output = {
metadata: {
version: 4.4,
......@@ -136,28 +166,12 @@ THREE.Texture.prototype = {
}
if ( meta.images[ this.image.uuid ] === undefined ) {
var canvas = document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext( '2d' );
context.drawImage( image, 0, 0, image.width, image.height );
var src;
if ( image.width > 2048 || image.height > 2048 ) {
src = canvas.toDataURL( 'image/jpeg', 0.6 );
} else {
src = canvas.toDataURL( 'image/png' );
}
if ( meta.images[ image.uuid ] === undefined ) {
meta.images[ this.image.uuid ] = { uuid: this.image.uuid, url: src };
meta.images[ image.uuid ] = {
uuid: image.uuid,
url: getDataURL( image )
};
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册