提交 cb7628ae 编写于 作者: K Kyle Larson

Merge branch 'dev' into FBX-Loader-AnimationFixes

此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -52,12 +52,12 @@ scene.add(rectLight)
<h2>Constructor</h2>
<h3>[name]( [page:Integer color], [page:Float intensity], [page:Float distance], [page:Radians angle], [page:Float penumbra], [page:Float decay] )</h3>
<h3>[name]( [page:Integer color], [page:Float intensity], [page:Float width], [page:Float height] )</h3>
<div>
[page:Integer color] - (optional) hexadecimal color of the light. Default is 0xffffff (white).<br />
[page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br /><br />
[page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br />
[page:Float width] - (optional) width of the light. Default is 10.<br />
[page:Float height] - (optional) height of the light. Default is 10.
[page:Float height] - (optional) height of the light. Default is 10.<br /><br />
Creates a new [name].
</div>
......
......@@ -862,10 +862,10 @@ UI.Integer.prototype.setValue = function ( value ) {
};
UI.Number.prototype.setStep = function ( step ) {
this.step = step;
UI.Integer.prototype.setStep = function ( step ) {
this.step = parseInt( step );
return this;
};
......
......@@ -163,7 +163,9 @@
* @type {[number, number, string][]}
*/
var connectionArray = FBXTree.Connections.properties.connections;
connectionArray.forEach( function ( connection ) {
for ( var connectionArrayIndex = 0, connectionArrayLength = connectionArray.length; connectionArrayIndex < connectionArrayLength; ++ connectionArrayIndex ) {
var connection = connectionArray[ connectionArrayIndex ];
if ( ! connectionMap.has( connection[ 0 ] ) ) {
......@@ -189,7 +191,7 @@
var childRelationship = { ID: connection[ 0 ], relationship: connection[ 2 ] };
connectionMap.get( connection[ 1 ] ).children.push( childRelationship );
} );
}
}
......@@ -370,7 +372,9 @@
}
childrenRelationships.forEach( function ( relationship ) {
for ( var childrenRelationshipsIndex = 0, childrenRelationshipsLength = childrenRelationships.length; childrenRelationshipsIndex < childrenRelationshipsLength; ++ childrenRelationshipsIndex ) {
var relationship = childrenRelationships[ childrenRelationshipsIndex ];
var type = relationship.relationship;
switch ( type ) {
......@@ -389,7 +393,7 @@
}
} );
}
return parameters;
......@@ -440,7 +444,9 @@
var subDeformers = new Map();
var subDeformerArray = [];
connections.children.forEach( function ( child ) {
for ( var childrenIndex = 0, childrenLength = connections.children.length; childrenIndex < childrenLength; ++ childrenIndex ) {
var child = connections.children[ childrenIndex ];
var subDeformerNode = DeformerNodes[ child.ID ];
var subDeformer = {
......@@ -454,7 +460,7 @@
subDeformers.set( child.ID, subDeformer );
subDeformerArray.push( subDeformer );
} );
}
return {
map: subDeformers,
......@@ -800,11 +806,11 @@
// we expect. So we create an intermediate buffer that points to the index in the buffer,
// for conforming with the other functions we've written for other data.
var materialIndices = [];
materialIndexBuffer.forEach( function ( materialIndex, index ) {
for ( var materialIndexBufferIndex = 0, materialIndexBufferLength = materialIndexBuffer.length; materialIndexBufferIndex < materialIndexBufferLength; ++ materialIndexBufferIndex ) {
materialIndices.push( index );
materialIndices.push( materialIndexBufferIndex );
} );
}
return {
dataSize: 1,
......@@ -966,12 +972,14 @@
var vertices = curve.getPoints( controlPoints.length * 1.5 );
var vertexBuffer = [];
vertices.forEach( function ( position ) {
for ( var verticesIndex = 0, verticesLength = vertices.length; verticesIndex < verticesLength; ++ verticesIndex ) {
var position = vertices[ verticesIndex ];
var array = position.toArray();
vertexBuffer = vertexBuffer.concat( array );
} );
}
var geometry = new THREE.BufferGeometry();
geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertexBuffer ), 3 ) );
......@@ -1054,7 +1062,9 @@
*/
var materials = [];
conns.children.forEach( function ( child ) {
for ( var childrenIndex = 0, childrenLength = conns.children.length; childrenIndex < childrenLength; ++ childrenIndex ) {
var child = conns.children[ childrenIndex ];
if ( geometryMap.has( child.ID ) ) {
......@@ -1068,7 +1078,7 @@
}
} );
}
if ( materials.length > 1 ) {
material = new THREE.MultiMaterial( materials );
......@@ -1084,11 +1094,13 @@
}
if ( geometry.FBX_Deformer ) {
materials.forEach( function ( material ) {
for ( var materialsIndex = 0, materialsLength = materials.length; materialsIndex < materialsLength; ++ materialsIndex ) {
var material = materials[ materialsIndex ];
material.skinning = true;
} );
}
material.skinning = true;
model = new THREE.SkinnedMesh( geometry, material );
......@@ -1102,7 +1114,9 @@
case "NurbsCurve":
var geometry = null;
conns.children.forEach( function ( child ) {
for ( var childrenIndex = 0, childrenLength = conns.children.length; childrenIndex < childrenLength; ++ childrenIndex ) {
var child = conns.children[ childrenIndex ];
if ( geometryMap.has( child.ID ) ) {
......@@ -1110,7 +1124,7 @@
}
} );
}
// FBX does not list materials for Nurbs lines, so we'll just put our own in here.
material = new THREE.LineBasicMaterial( { color: 0x3300ff, linewidth: 5 } );
......@@ -1133,7 +1147,9 @@
}
modelArray.forEach( function ( model ) {
for ( var modelArrayIndex = 0, modelArrayLength = modelArray.length; modelArrayIndex < modelArrayLength; ++ modelArrayIndex ) {
var model = modelArray[ modelArrayIndex ];
var node = ModelNode[ model.FBX_ID ];
......@@ -1183,7 +1199,7 @@
}
} );
}
// Now with the bones created, we can update the skeletons and bind them to the skinned meshes.
......@@ -1206,19 +1222,24 @@
var PoseNode = BindPoseNode.subNodes.PoseNode;
var worldMatrices = new Map();
PoseNode.forEach( function ( node ) {
for ( var PoseNodeIndex = 0, PoseNodeLength = PoseNode.length; PoseNodeIndex < PoseNodeLength; ++ PoseNodeIndex ) {
var node = PoseNode[ PoseNodeIndex ];
var rawMatWrd = parseMatrixArray( node.subNodes.Matrix.properties.a );
worldMatrices.set( parseInt( node.id ), rawMatWrd );
} );
}
}
deformerMap.forEach( function ( deformer, FBX_ID ) {
deformer.array.forEach( function ( subDeformer, subDeformerIndex ) {
for ( var deformerArrayIndex = 0, deformerArrayLength = deformer.array.length; deformerArrayIndex < deformerArrayLength; ++ deformerArrayIndex ) {
//var subDeformer = deformer.array[ deformerArrayIndex ];
var subDeformerIndex = deformerArrayIndex;
/**
* @type {THREE.Bone}
......@@ -1226,18 +1247,20 @@
var bone = deformer.bones[ subDeformerIndex ];
if ( ! worldMatrices.has( bone.FBX_ID ) ) {
return;
break;
}
var mat = worldMatrices.get( bone.FBX_ID );
bone.matrixWorld.copy( mat );
} );
}
// Now that skeleton is in bind pose, bind to model.
deformer.skeleton = new THREE.Skeleton( deformer.bones );
var conns = connections.get( FBX_ID );
conns.parents.forEach( function ( parent ) {
for ( var parentsIndex = 0, parentsLength = conns.parents.length; parentsIndex < parentsLength; ++ parentsIndex ) {
var parent = conns.parents[ parentsIndex ];
if ( geometryMap.has( parent.ID ) ) {
......@@ -1258,13 +1281,15 @@
}
} );
}
} );
// Skeleton is now bound, we are now free to set up the
// scene graph.
modelArray.forEach( function ( model ) {
for ( var modelArrayIndex = 0, modelArrayLength = modelArray.length; modelArrayIndex < modelArrayLength; ++ modelArrayIndex ) {
var model = modelArray[ modelArrayIndex ];
var node = ModelNode[ model.FBX_ID ];
......@@ -1292,7 +1317,7 @@
}
} );
}
// Silly hack with the animation parsing. We're gonna pretend the scene graph has a skeleton
// to attach animations to, since FBXs treat animations as animations for the entire scene,
......@@ -2001,7 +2026,9 @@
var currentLayer = returnObject.layers.get( children[ childIndex ].ID );
layers.push( currentLayer );
currentLayer.forEach( function ( layer ) {
for ( var currentLayerIndex = 0, currentLayerLength = currentLayer.length; currentLayerIndex < currentLayerLength; ++ currentLayerIndex ) {
var layer = currentLayer[ currentLayerIndex ];
if ( layer ) {
......@@ -2216,7 +2243,7 @@
}
} );
}
}
......@@ -2776,7 +2803,9 @@
var bones = group.skeleton.bones;
bones.forEach( function ( bone ) {
for ( var bonesIndex = 0, bonesLength = bones.length; bonesIndex < bonesLength; ++ bonesIndex ) {
var bone = bones[ bonesIndex ];
var name = bone.name.replace( /.*:/, '' );
var parentIndex = bones.findIndex( function ( parentBone ) {
......@@ -2786,15 +2815,20 @@
} );
animationData.hierarchy.push( { parent: parentIndex, name: name, keys: [] } );
} );
}
for ( var frame = 0; frame < stack.frames; frame ++ ) {
bones.forEach( function ( bone, boneIndex ) {
for ( var bonesIndex = 0, bonesLength = bones.length; bonesIndex < bonesLength; ++ bonesIndex ) {
var bone = bones[ bonesIndex ];
var boneIndex = bonesIndex;
var animationNode = stack.layers[ 0 ][ boneIndex ];
animationData.hierarchy.forEach( function ( node ) {
for ( var hierarchyIndex = 0, hierarchyLength = animationData.hierarchy.length; hierarchyIndex < hierarchyLength; ++ hierarchyIndex ) {
var node = animationData.hierarchy[ hierarchyIndex ];
if ( node.name === bone.name ) {
......@@ -2802,9 +2836,9 @@
}
} );
}
} );
}
}
......@@ -3047,7 +3081,9 @@
var skinIndexBuffer = [];
var skinWeightBuffer = [];
this.vertices.forEach( function ( vertex ) {
for ( var verticesIndex = 0, verticesLength = this.vertices.length; verticesIndex < verticesLength; ++ verticesIndex ) {
var vertex = this.vertices[ verticesIndex ];
var flatVertex = vertex.flattenToBuffers();
vertexBuffer = vertexBuffer.concat( flatVertex.vertexBuffer );
......@@ -3056,7 +3092,7 @@
skinIndexBuffer = skinIndexBuffer.concat( flatVertex.skinIndexBuffer );
skinWeightBuffer = skinWeightBuffer.concat( flatVertex.skinWeightBuffer );
} );
}
return {
vertexBuffer: vertexBuffer,
......@@ -3127,8 +3163,9 @@
var materialIndex = this.materialIndex;
this.triangles.forEach( function ( triangle ) {
for ( var triangleIndex = 0, triangleLength = this.triangles.length; triangleIndex < triangleLength; ++ triangleIndex ) {
var triangle = this.triangles[ triangleIndex ];
var flatTriangle = triangle.flattenToBuffers();
vertexBuffer = vertexBuffer.concat( flatTriangle.vertexBuffer );
normalBuffer = normalBuffer.concat( flatTriangle.normalBuffer );
......@@ -3137,7 +3174,7 @@
skinWeightBuffer = skinWeightBuffer.concat( flatTriangle.skinWeightBuffer );
materialIndexBuffer = materialIndexBuffer.concat( [ materialIndex, materialIndex, materialIndex ] );
} );
}
return {
vertexBuffer: vertexBuffer,
......@@ -3184,8 +3221,9 @@
var materialIndexBuffer = [];
this.faces.forEach( function ( face ) {
for ( var faceIndex = 0, faceLength = this.faces.length; faceIndex < faceLength; ++ faceIndex ) {
var face = this.faces[ faceIndex ];
var flatFace = face.flattenToBuffers();
vertexBuffer = vertexBuffer.concat( flatFace.vertexBuffer );
normalBuffer = normalBuffer.concat( flatFace.normalBuffer );
......@@ -3194,7 +3232,7 @@
skinWeightBuffer = skinWeightBuffer.concat( flatFace.skinWeightBuffer );
materialIndexBuffer = materialIndexBuffer.concat( flatFace.materialIndexBuffer );
} );
}
return {
vertexBuffer: vertexBuffer,
......
......@@ -10,7 +10,7 @@ THREE.CSS3DObject = function ( element ) {
this.element = element;
this.element.style.position = 'absolute';
this.addEventListener( 'removed', function ( event ) {
this.addEventListener( 'removed', function () {
if ( this.element.parentNode !== null ) {
......@@ -41,7 +41,6 @@ THREE.CSS3DRenderer = function () {
console.log( 'THREE.CSS3DRenderer', THREE.REVISION );
var _width, _height;
var _widthHalf, _heightHalf;
var matrix = new THREE.Matrix4();
......@@ -62,6 +61,10 @@ THREE.CSS3DRenderer = function () {
var cameraElement = document.createElement( 'div' );
cameraElement.style.position = 'absolute';
cameraElement.style.left = '50%';
cameraElement.style.top = '50%';
cameraElement.style.WebkitTransformStyle = 'preserve-3d';
cameraElement.style.MozTransformStyle = 'preserve-3d';
cameraElement.style.oTransformStyle = 'preserve-3d';
......@@ -71,7 +74,7 @@ THREE.CSS3DRenderer = function () {
this.setClearColor = function () {};
this.getSize = function() {
this.getSize = function () {
return {
width: _width,
......@@ -85,24 +88,18 @@ THREE.CSS3DRenderer = function () {
_width = width;
_height = height;
_widthHalf = _width / 2;
_heightHalf = _height / 2;
domElement.style.width = width + 'px';
domElement.style.height = height + 'px';
cameraElement.style.width = width + 'px';
cameraElement.style.height = height + 'px';
};
var epsilon = function ( value ) {
function epsilon( value ) {
return Math.abs( value ) < Number.EPSILON ? 0 : value;
};
}
var getCameraCSSMatrix = function ( matrix ) {
function getCameraCSSMatrix( matrix ) {
var elements = matrix.elements;
......@@ -125,9 +122,9 @@ THREE.CSS3DRenderer = function () {
epsilon( elements[ 15 ] ) +
')';
};
}
var getObjectCSSMatrix = function ( matrix ) {
function getObjectCSSMatrix( matrix ) {
var elements = matrix.elements;
......@@ -150,9 +147,9 @@ THREE.CSS3DRenderer = function () {
epsilon( elements[ 15 ] ) +
')';
};
}
var renderObject = function ( object, camera ) {
function renderObject( object, camera ) {
if ( object instanceof THREE.CSS3DObject ) {
......@@ -208,7 +205,7 @@ THREE.CSS3DRenderer = function () {
}
};
}
this.render = function ( scene, camera ) {
......@@ -231,8 +228,7 @@ THREE.CSS3DRenderer = function () {
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
var style = "translate3d(0,0," + fov + "px)" + getCameraCSSMatrix( camera.matrixWorldInverse ) +
" translate3d(" + _widthHalf + "px," + _heightHalf + "px, 0)";
var style = 'translateZ(' + fov + 'px)' + getCameraCSSMatrix( camera.matrixWorldInverse );
if ( cache.camera.style !== style ) {
......
......@@ -25,17 +25,18 @@ THREE.PaintViveController = function ( id ) {
var context = canvas.getContext( '2d' );
var imageData = context.getImageData( 0, 0, 256, 256 );
var data = imageData.data;
var swatchColor = new THREE.Color();
for ( var i = 0, j = 0; i < data.length; i += 4, j ++ ) {
var x = ( ( j % 256 ) / 256 ) - 0.5;
var y = ( Math.floor( j / 256 ) / 256 ) - 0.5;
color.setHSL( Math.atan2( y, x ) / PI2, 1,( 0.5 - Math.sqrt( x * x + y * y ) ) * 2.0 );
swatchColor.setHSL( Math.atan2( y, x ) / PI2, 1,( 0.5 - Math.sqrt( x * x + y * y ) ) * 2.0 );
data[ i + 0 ] = color.r * 256;
data[ i + 1 ] = color.g * 256;
data[ i + 2 ] = color.b * 256;
data[ i + 0 ] = swatchColor.r * 256;
data[ i + 1 ] = swatchColor.g * 256;
data[ i + 2 ] = swatchColor.b * 256;
data[ i + 3 ] = 256;
}
......@@ -46,19 +47,53 @@ THREE.PaintViveController = function ( id ) {
}
// COLOR UI
var geometry = new THREE.CircleGeometry( 1, 32 );
var material = new THREE.MeshBasicMaterial( { map: generateHueTexture() } );
var mesh = new THREE.Mesh( geometry, material );
mesh.position.set( 0, 0.005, 0.0495 );
mesh.rotation.x = - 1.45;
mesh.scale.setScalar( 0.02 );
this.add( mesh );
var colorUI = new THREE.Mesh( geometry, material );
colorUI.position.set( 0, 0.005, 0.0495 );
colorUI.rotation.x = - 1.45;
colorUI.scale.setScalar( 0.02 );
this.add( colorUI );
var geometry = new THREE.IcosahedronGeometry( 0.1, 2 );
var material = new THREE.MeshBasicMaterial();
material.color = color;
var ball = new THREE.Mesh( geometry, material );
mesh.add( ball );
colorUI.add( ball );
// SIZE UI
var sizeUI = new THREE.Group();
sizeUI.position.set( 0, 0.005, 0.0495 );
sizeUI.rotation.x = - 1.45;
sizeUI.scale.setScalar( 0.02 );
this.add( sizeUI );
var triangleShape = new THREE.Shape();
triangleShape.moveTo( 0, -1 );
triangleShape.lineTo( 1, 1 );
triangleShape.lineTo( -1, 1 );
var geometry = new THREE.ShapeGeometry( triangleShape );
var material = new THREE.MeshBasicMaterial( { color: 0x222222, wireframe:true } );
var sizeUIOutline = new THREE.Mesh( geometry, material ) ;
sizeUIOutline.position.z = 0.001;
resizeTriangleGeometry(sizeUIOutline.geometry, 1.0);
sizeUI.add( sizeUIOutline );
var geometry = new THREE.ShapeGeometry( triangleShape );
var material = new THREE.MeshBasicMaterial( {side: THREE.DoubleSide } );
material.color = color;
var sizeUIFill = new THREE.Mesh( geometry, material ) ;
sizeUIFill.position.z = 0.0011;
resizeTriangleGeometry(sizeUIFill.geometry, 0.5);
sizeUI.add( sizeUIFill );
sizeUI.visible = false;
function onAxisChanged( event ) {
......@@ -69,27 +104,52 @@ THREE.PaintViveController = function ( id ) {
if ( mode === MODES.COLOR ) {
color.setHSL( Math.atan2( y, x ) / PI2, 1, ( 0.5 - Math.sqrt( x * x + y * y ) ) * 2.0 );
ball.position.x = event.axes[ 0 ];
ball.position.y = event.axes[ 1 ];
ball.position.set(event.axes[ 0 ], event.axes[ 1 ], 0);
}
if ( mode === MODES.SIZE ) {
size = y + 1;
var ratio = (0.5 - y);
size = ratio * 2;
resizeTriangleGeometry(sizeUIFill.geometry, ratio);
}
}
function resizeTriangleGeometry(geometry, ratio) {
var x = 0, y =0;
var fullWidth = 0.75; fullHeight = 1.5;
var angle = Math.atan((fullWidth/2)/fullHeight);
var bottomY = y - fullHeight/2;
var height = fullHeight * ratio;
var width = (Math.tan(angle) * height) * 2;
geometry.vertices[0].set( x, bottomY, 0);
geometry.vertices[1].set( x + width/2, bottomY + height, 0 );
geometry.vertices[2].set( x - width/2, bottomY + height, 0 );
geometry.verticesNeedUpdate = true;
}
function onGripsDown( event ) {
if ( mode === MODES.COLOR ) {
mode = MODES.SIZE;
mesh.visible = false;
colorUI.visible = false;
sizeUI.visible = true;
return;
}
if ( mode === MODES.SIZE ) {
mode = MODES.COLOR;
mesh.visible = true;
colorUI.visible = true;
sizeUI.visible = false;
return;
}
......
......@@ -174,7 +174,7 @@
// var pivot = new THREE.Group();
// var pivot = new THREE.Mesh( new THREE.BoxGeometry( 0.01, 0.01, 0.01 ) );
var pivot = new THREE.Mesh( new THREE.IcosahedronGeometry( 0.002, 2 ) );
var pivot = new THREE.Mesh( new THREE.IcosahedronGeometry( 0.01, 2 ) );
pivot.name = 'pivot';
pivot.position.y = -0.016;
pivot.position.z = -0.043;
......@@ -249,28 +249,31 @@
scene.add( line );
// Shapes
shapes[ 'tube' ] = getTubeShapes(1.0);
}
function getTubeShapes(size) {
var PI2 = Math.PI * 2;
var sides = 10;
var array = [];
for ( var i = 0; i < sides; i ++ ) {
var radius = 0.01 * size;
for( var i = 0; i < sides; i ++ ){
var angle = ( i / sides ) * PI2;
array.push( new THREE.Vector3( Math.sin( angle ) * 0.01, Math.cos( angle ) * 0.01, 0 ) );
array.push( new THREE.Vector3( Math.sin( angle ) * radius, Math.cos( angle ) * radius, 0 ) );
}
shapes[ 'tube' ] = array;
return array;
}
function stroke( controller, point1, point2, matrix1, matrix2 ) {
var color = controller.getColor();
var shape = shapes[ 'tube' ];
var shapes = getTubeShapes( controller.getSize() );
var geometry = line.geometry;
var attributes = geometry.attributes;
......@@ -280,10 +283,10 @@
var normals = attributes.normal.array;
var colors = attributes.color.array;
for ( var j = 0, jl = shape.length; j < jl; j ++ ) {
for ( var j = 0, jl = shapes.length; j < jl; j ++ ) {
var vertex1 = shape[ j ];
var vertex2 = shape[ ( j + 1 ) % jl ];
var vertex1 = shapes[ j ];
var vertex2 = shapes[ ( j + 1 ) % jl ];
// positions
......@@ -406,6 +409,7 @@
if ( pivot ) {
pivot.material.color.copy( controller.getColor() );
pivot.scale.setScalar(controller.getSize());
var matrix = pivot.matrixWorld;
......
......@@ -76,9 +76,7 @@ function AnimationAction( mixer, clip, localRoot ) {
}
AnimationAction.prototype = {
constructor: AnimationAction,
Object.assign( AnimationAction.prototype, {
// State & Scheduling
......@@ -651,7 +649,7 @@ AnimationAction.prototype = {
}
};
} );
export { AnimationAction };
......@@ -32,55 +32,6 @@ function AnimationClip( name, duration, tracks ) {
}
AnimationClip.prototype = {
constructor: AnimationClip,
resetDuration: function() {
var tracks = this.tracks,
duration = 0;
for ( var i = 0, n = tracks.length; i !== n; ++ i ) {
var track = this.tracks[ i ];
duration = Math.max( duration, track.times[ track.times.length - 1 ] );
}
this.duration = duration;
},
trim: function() {
for ( var i = 0; i < this.tracks.length; i ++ ) {
this.tracks[ i ].trim( 0, this.duration );
}
return this;
},
optimize: function() {
for ( var i = 0; i < this.tracks.length; i ++ ) {
this.tracks[ i ].optimize();
}
return this;
}
};
// Static methods:
Object.assign( AnimationClip, {
parse: function( json ) {
......@@ -98,8 +49,7 @@ Object.assign( AnimationClip, {
return new AnimationClip( json.name, json.duration, tracks );
},
toJSON: function( clip ) {
var tracks = [],
......@@ -122,8 +72,7 @@ Object.assign( AnimationClip, {
return json;
},
CreateFromMorphTargetSequence: function( name, morphTargetSequence, fps, noLoop ) {
var numMorphTargets = morphTargetSequence.length;
......@@ -359,5 +308,50 @@ Object.assign( AnimationClip, {
} );
Object.assign( AnimationClip.prototype, {
resetDuration: function() {
var tracks = this.tracks,
duration = 0;
for ( var i = 0, n = tracks.length; i !== n; ++ i ) {
var track = this.tracks[ i ];
duration = Math.max( duration, track.times[ track.times.length - 1 ] );
}
this.duration = duration;
},
trim: function() {
for ( var i = 0; i < this.tracks.length; i ++ ) {
this.tracks[ i ].trim( 0, this.duration );
}
return this;
},
optimize: function() {
for ( var i = 0; i < this.tracks.length; i ++ ) {
this.tracks[ i ].optimize();
}
return this;
}
} );
export { AnimationClip };
此差异已折叠。
......@@ -71,9 +71,7 @@ function AnimationObjectGroup( var_args ) {
}
AnimationObjectGroup.prototype = {
constructor: AnimationObjectGroup,
Object.assign( AnimationObjectGroup.prototype, {
isAnimationObjectGroup: true,
......@@ -371,8 +369,7 @@ AnimationObjectGroup.prototype = {
}
};
} );
export { AnimationObjectGroup };
此差异已折叠。
......@@ -56,9 +56,7 @@ function PropertyMixer( binding, typeName, valueSize ) {
}
PropertyMixer.prototype = {
constructor: PropertyMixer,
Object.assign( PropertyMixer.prototype, {
// accumulate data in the 'incoming' region into 'accu<i>'
accumulate: function( accuIndex, weight ) {
......@@ -118,7 +116,7 @@ PropertyMixer.prototype = {
var originalValueOffset = stride * 3;
this._mixBufferRegion(
buffer, offset, originalValueOffset, 1 - weight, stride );
buffer, offset, originalValueOffset, 1 - weight, stride );
}
......@@ -188,7 +186,7 @@ PropertyMixer.prototype = {
_slerp: function( buffer, dstOffset, srcOffset, t, stride ) {
Quaternion.slerpFlat( buffer, dstOffset,
buffer, dstOffset, buffer, srcOffset, t );
buffer, dstOffset, buffer, srcOffset, t );
},
......@@ -206,7 +204,7 @@ PropertyMixer.prototype = {
}
};
} );
export { PropertyMixer };
......@@ -286,8 +286,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
return this.gain.gain.value;
},
setVolume: function ( value ) {
this.gain.gain.value = value;
......
......@@ -32,17 +32,19 @@ function BufferAttribute( array, itemSize, normalized ) {
}
BufferAttribute.prototype = {
Object.defineProperty( BufferAttribute.prototype, "needsUpdate", {
constructor: BufferAttribute,
isBufferAttribute: true,
set: function(value) {
if ( value === true ) this.version ++;
}
set needsUpdate( value ) {
});
if ( value === true ) this.version ++;
Object.assign( BufferAttribute.prototype, {
},
isBufferAttribute: true,
setArray: function ( array ) {
......@@ -335,7 +337,7 @@ BufferAttribute.prototype = {
}
};
} );
//
......
......@@ -39,9 +39,9 @@ function BufferGeometry() {
}
BufferGeometry.prototype = {
BufferGeometry.MaxIndex = 65535;
constructor: BufferGeometry,
Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
isBufferGeometry: true,
......@@ -173,12 +173,10 @@ BufferGeometry.prototype = {
// rotate geometry around world x-axis
var m1;
var m1 = new Matrix4();
return function rotateX( angle ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeRotationX( angle );
this.applyMatrix( m1 );
......@@ -193,12 +191,10 @@ BufferGeometry.prototype = {
// rotate geometry around world y-axis
var m1;
var m1 = new Matrix4();
return function rotateY( angle ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeRotationY( angle );
this.applyMatrix( m1 );
......@@ -213,12 +209,10 @@ BufferGeometry.prototype = {
// rotate geometry around world z-axis
var m1;
var m1 = new Matrix4();
return function rotateZ( angle ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeRotationZ( angle );
this.applyMatrix( m1 );
......@@ -233,12 +227,10 @@ BufferGeometry.prototype = {
// translate geometry
var m1;
var m1 = new Matrix4();
return function translate( x, y, z ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeTranslation( x, y, z );
this.applyMatrix( m1 );
......@@ -253,12 +245,10 @@ BufferGeometry.prototype = {
// scale geometry
var m1;
var m1 = new Matrix4();
return function scale( x, y, z ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeScale( x, y, z );
this.applyMatrix( m1 );
......@@ -271,12 +261,10 @@ BufferGeometry.prototype = {
lookAt: function () {
var obj;
var obj = new Object3D();
return function lookAt( vector ) {
if ( obj === undefined ) obj = new Object3D();
obj.lookAt( vector );
obj.updateMatrix();
......@@ -979,28 +967,28 @@ BufferGeometry.prototype = {
clone: function () {
/*
// Handle primitives
// Handle primitives
var parameters = this.parameters;
var parameters = this.parameters;
if ( parameters !== undefined ) {
if ( parameters !== undefined ) {
var values = [];
var values = [];
for ( var key in parameters ) {
for ( var key in parameters ) {
values.push( parameters[ key ] );
values.push( parameters[ key ] );
}
}
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
}
}
return new this.constructor().copy( this );
*/
return new this.constructor().copy( this );
*/
return new BufferGeometry().copy( this );
......@@ -1109,10 +1097,7 @@ BufferGeometry.prototype = {
}
};
BufferGeometry.MaxIndex = 65535;
} );
Object.assign( BufferGeometry.prototype, EventDispatcher.prototype );
export { BufferGeometry };
......@@ -14,9 +14,7 @@ function Clock( autoStart ) {
}
Clock.prototype = {
constructor: Clock,
Object.assign( Clock.prototype, {
start: function () {
......@@ -67,7 +65,7 @@ Clock.prototype = {
}
};
} );
export { Clock };
......@@ -4,7 +4,7 @@
function EventDispatcher() {}
EventDispatcher.prototype = {
Object.assign( EventDispatcher.prototype, {
addEventListener: function ( type, listener ) {
......@@ -87,7 +87,7 @@ EventDispatcher.prototype = {
}
};
} );
export { EventDispatcher };
......@@ -22,9 +22,7 @@ function Face3( a, b, c, normal, color, materialIndex ) {
}
Face3.prototype = {
constructor: Face3,
Object.assign( Face3.prototype, {
clone: function () {
......@@ -59,7 +57,7 @@ Face3.prototype = {
}
};
} );
export { Face3 };
......@@ -59,9 +59,7 @@ function Geometry() {
}
Geometry.prototype = {
constructor: Geometry,
Object.assign( Geometry.prototype, EventDispatcher.prototype, {
isGeometry: true,
......@@ -112,12 +110,10 @@ Geometry.prototype = {
// rotate geometry around world x-axis
var m1;
var m1 = new Matrix4();
return function rotateX( angle ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeRotationX( angle );
this.applyMatrix( m1 );
......@@ -132,12 +128,10 @@ Geometry.prototype = {
// rotate geometry around world y-axis
var m1;
var m1 = new Matrix4();
return function rotateY( angle ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeRotationY( angle );
this.applyMatrix( m1 );
......@@ -152,12 +146,10 @@ Geometry.prototype = {
// rotate geometry around world z-axis
var m1;
var m1 = new Matrix4();
return function rotateZ( angle ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeRotationZ( angle );
this.applyMatrix( m1 );
......@@ -172,12 +164,10 @@ Geometry.prototype = {
// translate geometry
var m1;
var m1 = new Matrix4();
return function translate( x, y, z ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeTranslation( x, y, z );
this.applyMatrix( m1 );
......@@ -192,12 +182,10 @@ Geometry.prototype = {
// scale geometry
var m1;
var m1 = new Matrix4();
return function scale( x, y, z ) {
if ( m1 === undefined ) m1 = new Matrix4();
m1.makeScale( x, y, z );
this.applyMatrix( m1 );
......@@ -210,12 +198,10 @@ Geometry.prototype = {
lookAt: function () {
var obj;
var obj = new Object3D();
return function lookAt( vector ) {
if ( obj === undefined ) obj = new Object3D();
obj.lookAt( vector );
obj.updateMatrix();
......@@ -714,15 +700,15 @@ Geometry.prototype = {
}
var normalMatrix,
vertexOffset = this.vertices.length,
vertices1 = this.vertices,
vertices2 = geometry.vertices,
faces1 = this.faces,
faces2 = geometry.faces,
uvs1 = this.faceVertexUvs[ 0 ],
uvs2 = geometry.faceVertexUvs[ 0 ],
colors1 = this.colors,
colors2 = geometry.colors;
vertexOffset = this.vertices.length,
vertices1 = this.vertices,
vertices2 = geometry.vertices,
faces1 = this.faces,
faces2 = geometry.faces,
uvs1 = this.faceVertexUvs[ 0 ],
uvs2 = geometry.faceVertexUvs[ 0 ],
colors1 = this.colors,
colors2 = geometry.colors;
if ( materialIndexOffset === undefined ) materialIndexOffset = 0;
......@@ -759,8 +745,8 @@ Geometry.prototype = {
for ( i = 0, il = faces2.length; i < il; i ++ ) {
var face = faces2[ i ], faceCopy, normal, color,
faceVertexNormals = face.vertexNormals,
faceVertexColors = face.vertexColors;
faceVertexNormals = face.vertexNormals,
faceVertexColors = face.vertexColors;
faceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );
faceCopy.normal.copy( face.normal );
......@@ -1171,28 +1157,28 @@ Geometry.prototype = {
clone: function () {
/*
// Handle primitives
// Handle primitives
var parameters = this.parameters;
var parameters = this.parameters;
if ( parameters !== undefined ) {
if ( parameters !== undefined ) {
var values = [];
var values = [];
for ( var key in parameters ) {
for ( var key in parameters ) {
values.push( parameters[ key ] );
values.push( parameters[ key ] );
}
}
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
}
}
return new this.constructor().copy( this );
*/
return new this.constructor().copy( this );
*/
return new Geometry().copy( this );
......@@ -1438,8 +1424,7 @@ Geometry.prototype = {
}
};
} );
Object.assign( Geometry.prototype, EventDispatcher.prototype );
export { GeometryIdCount, Geometry };
此差异已折叠。
......@@ -8,9 +8,7 @@ function Layers() {
}
Layers.prototype = {
constructor: Layers,
Object.assign( Layers.prototype, {
set: function ( channel ) {
......@@ -42,7 +40,7 @@ Layers.prototype = {
}
};
} );
export { Layers };
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -23,7 +23,7 @@ import { ShapeUtils } from '../extras/ShapeUtils';
* extrudePath: <THREE.Curve> // curve to extrude shape along
* frames: <Object> // containing arrays of tangents, normals, binormals
*
* uvGenerator: <Object> // object that provides UV generator functions
* UVGenerator: <Object> // object that provides UV generator functions
*
* }
**/
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册